import{r as f,j as e}from"./vendor-react-wBh_31cN.js";import{t as D}from"./toast-3g7Fh-a0.js";import{e as T,u as w,h as S,ac as V,aa as G,ao as L,b0 as E,b1 as R,eh as b,m as q,a as B,q as k,R as x,G as H,cg as N}from"./index-BKr2rJhV.js";import{a as Q,u as _}from"./index-BDIYwql2.js";import{a as $}from"./index-BP2S764X.js";import{c as I}from"./vendor-router-D1GqFWiT.js";import{ak as z}from"./vendor-icons-BUUmD6ht.js";import{B as d}from"./badge-nyizWwTN.js";import{C as A,c as J,b as O}from"./card-DISTA6Ay.js";import{M as F}from"./metadata-field-B_vcklh-.js";import{S as p}from"./separator-2OqrG5Vy.js";import{V as C}from"./value-76ihWpF6.js";import{S as P,a as U}from"./StatisticsCharts-CPV0wWWx.js";import{T as K}from"./TdFeatureGroupHandle-BLHPEQOs.js";const W="yyyy/MM/dd HH:mm:ss",fe=()=>{const{id:t,fgId:r,fsId:s,fvName:a,fvVersion:i,tdVersion:y}=I(),{currentData:{items:g}={}}=Q({pId:t,fgId:r,fsId:s},{skip:!r}),{currentData:h}=$({pId:t,fsId:+s,fvName:a,fvVersion:+i,id:+y,params:{fields:"content"}},{skip:!!r,selectFromResult:T({currentData:w(S(V,G))})}),n=r?g:h,[j,{isLoading:o}]=_(),c=()=>{try{j({pId:t,fgId:r,fsId:s}).unwrap().then(u=>{D.success(`Job ${u.name} started`,{description:"New computation started"})})}catch{}},l=f.useMemo(()=>S(q(S(B(0,"computationTime"),b)),E(R,b(0)),L(W))(n??[]),[n]);return e.jsxs("div",{className:"flex items-center gap-2.5",children:[n!==void 0&&!k(n)&&e.jsxs(x,{gray:!0,children:["computed at ",l]}),(n===void 0||k(n))&&e.jsx(x,{gray:!0,children:"Statistics are not configured for this version"}),r&&e.jsxs(H,{variant:"outline",loading:o,onClick:c,children:[!o&&e.jsx(z,{className:"size-4"}),o?"Computing...":"Recompute"]})]})},X=[{key:"min",label:"min"},{key:"max",label:"max"},{key:"mean",label:"mean"},{key:"stddev",label:"std dev"},{key:"sum",label:"sum"}],Y=[{key:"completeness",label:"completeness"},{key:"approxNumDistinctValues",label:"distinct count"},{key:"exactNumDistinctValues",label:"exact distinct count"},{key:"uniqueness",label:"uniqueness"},{key:"distinctness",label:"distinctness"},{key:"entropy",label:"entropy"}],Z=(t,r)=>{if(t==null)return"-";const s=Number(t);return Number.isNaN(s)?String(t):r==="completeness"?`${(s*100).toFixed(s===1||s===0?0:1)}%`:Number.isInteger(s)?s.toLocaleString():Number(s.toFixed(4)).toLocaleString()},M=(t,r)=>r.filter(({key:s})=>{const a=t[s];return a!=null}).map(({key:s,label:a})=>({label:a,value:Z(t[s],s)})),xe=({data:t,parent:r,statistics:s,type:a})=>{var u;const{name:i,primary:y,partition:g}=t,{id:h,fgId:n,fsId:j}=I(),o=f.useMemo(()=>a===N.fg?r.eventTime===i:!1,[i,r,a]),c=f.useMemo(()=>s?M(s,X):[],[s]),l=f.useMemo(()=>s?M(s,Y):[],[s]);return e.jsx(A,{children:e.jsxs(J,{className:"p-5",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{children:i}),(s==null?void 0:s.featureType)&&e.jsx(d,{children:s.featureType}),y&&e.jsx(d,{variant:"success",children:"primary key"}),g&&e.jsx(d,{variant:"success",children:"partition key"}),o&&e.jsx(d,{children:"event time"}),a===N.td&&(t.featuregroup?e.jsxs(e.Fragment,{children:[e.jsx(x,{gray:!0,children:"from"}),e.jsx(K,{featureGroup:t.featuregroup})]}):e.jsx(x,{gray:!0,children:"unavailable origin"}))]})}),s&&e.jsxs(e.Fragment,{children:[c.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(p,{className:"my-3"}),e.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-2",children:c.map(({label:m,value:v})=>e.jsx(F,{label:m,children:e.jsx(C,{primary:!0,children:v})},m))})]}),l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(p,{className:"my-3"}),e.jsx("div",{className:"flex flex-wrap gap-x-8 gap-y-2",children:l.map(({label:m,value:v})=>e.jsx(F,{label:m,children:e.jsx(C,{primary:!0,children:v})},m))})]}),((u=s.extendedStatistics)==null?void 0:u.histogram)&&e.jsxs(e.Fragment,{children:[e.jsx(p,{className:"my-3"}),e.jsx(P,{dataType:a,data:s.extendedStatistics.histogram,type:s.featureType})]}),a===N.fg&&e.jsxs(e.Fragment,{children:[e.jsx(p,{className:"my-3"}),e.jsx(U,{projectId:+h,fgId:+n,featureStoreId:+j,featureName:i,featureGroup:r,showLoadButton:!1})]})]})]})})};export{fe as C,xe as S};
