import{u as C,r as w,eh as c,j as e,W as F,a as o,k as I,L as p,eq as T,b8 as l,c as d,bz as D,hw as E,w as L,x as G,p as y,bt as M,f$ as A,hx as B,bQ as R,gE as N,hy as V,hz as b,az as _,B as z,l as k,aJ as Q}from"./index-_eM6l4Nf.js";import{a as W,u as q}from"./index-CF1bKnX4.js";import{b as J,S as $,a as H}from"./StatisticsTables-C0Yy4Jvz.js";import{u as O}from"./Deprecated-Cn0z8EIY.js";import{T as P}from"./TdFeatureGroupHandle-nOWLgnW1.js";import{F as U}from"./FeaturesLayout-B9Mpmu_2.js";const K=({data:r,parent:a,statistics:t,type:s})=>{var x;const{name:i,primary:u,partition:f}=r,{id:h,fgId:j,fsId:n}=C(),{isActiveFeature:m,handleBasket:g,isSwitch:v}=O(),S=w.useMemo(()=>s===c.fg?a.eventTime===i:!1,[i,a,s]);return e.jsxs(F,{children:[s===c.fg&&e.jsxs(o,{alignItems:"flex-end",children:[e.jsx(I,{children:i}),v&&s===c.fg&&e.jsx(p,{ml:"10px",children:e.jsx(T,{handleClick:g([r],a),inBasket:m(r,a),tooltipMainText:m(r,a)?"Remove this feature from basket":"Add this feature to basket"})}),e.jsx(l,{ml:"20px",value:(t==null?void 0:t.featureType)??""}),u&&e.jsx(l,{ml:"20px",value:"primary key",variant:"success"}),f&&e.jsx(l,{ml:"20px",value:"partition key",variant:"success"}),S&&e.jsx(l,{ml:"20px",value:"event time",variant:"label"})]}),s===c.td&&e.jsx(o,{alignItems:"flex-end",children:e.jsxs(o,{flexDirection:"column",children:[e.jsxs(o,{children:[e.jsx(I,{children:i}),e.jsx(l,{ml:"20px",value:(t==null?void 0:t.featureType)??""})]}),e.jsx(o,{mt:"5px",children:r.featuregroup?e.jsxs(o,{children:[e.jsx(d,{bold:!0,gray:!0,mr:"5px",children:"from"}),e.jsx(P,{featureGroup:r==null?void 0:r.featuregroup})]}):e.jsx(d,{bold:!0,gray:!0,children:"unavailable origin feature group"})})]})}),t&&e.jsxs(o,{justifyContent:"space-between",alignItems:"flex-start",mt:"20px",flexWrap:"wrap",children:[e.jsx(J,{data:t}),(x=t.extendedStatistics)!=null&&x.histogram?e.jsx(p,{width:"calc((100% - 60px) / 4)",children:e.jsx($,{dataType:s,data:t.extendedStatistics.histogram,type:t.featureType})}):e.jsx(p,{width:"calc((100% - 60px) / 4)"}),s===c.fg?e.jsx(H,{projectId:+h,fgId:+j,featureStoreId:+n,featureName:i,featureGroup:a}):e.jsx(p,{width:"calc((100% - 60px) / 4)"})]})]})},ae=({data:r,statistics:a,type:t=c.fg})=>e.jsx(U,{data:r,type:t,"data-test":"stats-container",renderChild:({type:s,parent:i,data:u})=>e.jsx(K,{type:s,parent:i,data:u,statistics:a[u.name]??{}}),extraActions:e.jsx(X,{})}),X=()=>{const r=D(),{id:a,fgId:t,fsId:s,fvName:i,fvVersion:u,tdVersion:f}=C(),{currentData:{items:h}={}}=W({pId:a,fgId:t,fsId:s},{skip:!t}),{currentData:j}=E({pId:a,fsId:+s,fvName:i,fvVersion:+u,id:+f,params:{fields:"content"}},{skip:!!t,selectFromResult:L({currentData:G(y(M,A))})}),n=t?h:j,[m,{isLoading:g}]=q(),v=()=>{try{m({pId:a,fgId:t,fsId:s}).unwrap().then(x=>{r.success({title:"New computation started",content:`Job ${x.name} started`})})}catch{}},S=w.useMemo(()=>y(_(y(z(0,"computationTime"),b)),N(V,b(0)),B(R.DATE_TIME.DATE_TIME_FULL))(n??[]),[n]);return e.jsxs(o,{alignItems:"center",sx:{gap:"10px"},children:[n!==void 0&&!k(n)&&e.jsxs(d,{gray:!0,children:["computed at ",S]}),(n===void 0||k(n))&&e.jsx(d,{gray:!0,children:"Statistics are not configured for this version"}),t&&e.jsx(Q,{intent:"ghost",onClick:v,isLoading:g,children:"Recompute"})]})};export{X as C,ae as S};
