import{u as k,r as w,ef as c,j as e,b as F,$ as n,v as y,L as p,eo as T,b8 as l,c as d,bz as D,hh as E,w as L,x as G,p as S,bt as M,fX as R,hi as A,bQ as B,gz as _,hj as N,hk as I,az as V,B as z,h as C,b1 as Q}from"./index-ljTaFLaB.js";import{a as $,u as H}from"./index-Dchy0RpL.js";import{b as J,S as O,a as P}from"./StatisticsTables-BKh0n-_K.js";import{u as U}from"./Deprecated-D_iwBiXP.js";import{T as W}from"./TdFeatureGroupHandle-DxWALHuI.js";import{F as X}from"./FeaturesLayout-B4roF-PA.js";const q=({data:r,parent:a,statistics:t,type:s})=>{var x;const{name:i,primary:u,partition:f}=r,{id:h,fgId:j,fsId:o}=k(),{isActiveFeature:m,handleBasket:g,isSwitch:v}=U(),b=w.useMemo(()=>s===c.fg?a.eventTime===i:!1,[i,a,s]);return e.jsxs(F,{children:[s===c.fg&&e.jsxs(n,{alignItems:"flex-end",children:[e.jsx(y,{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"}),b&&e.jsx(l,{ml:"20px",value:"event time",variant:"label"})]}),s===c.td&&e.jsx(n,{alignItems:"flex-end",children:e.jsxs(n,{flexDirection:"column",children:[e.jsxs(n,{children:[e.jsx(y,{children:i}),e.jsx(l,{ml:"20px",value:(t==null?void 0:t.featureType)??""})]}),e.jsx(n,{mt:"5px",children:r.featuregroup?e.jsxs(n,{children:[e.jsx(d,{bold:!0,gray:!0,mr:"5px",children:"from"}),e.jsx(W,{featureGroup:r==null?void 0:r.featuregroup})]}):e.jsx(d,{bold:!0,gray:!0,children:"unavailable origin feature group"})})]})}),t&&e.jsxs(n,{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(O,{dataType:s,data:t.extendedStatistics.histogram,type:t.featureType})}):e.jsx(p,{width:"calc((100% - 60px) / 4)"}),s===c.fg?e.jsx(P,{projectId:+h,fgId:+j,featureStoreId:+o,featureName:i,featureGroup:a}):e.jsx(p,{width:"calc((100% - 60px) / 4)"})]})]})},ae=({data:r,statistics:a,type:t=c.fg})=>e.jsx(X,{data:r,type:t,"data-test":"stats-container",renderChild:({type:s,parent:i,data:u})=>e.jsx(q,{type:s,parent:i,data:u,statistics:a[u.name]??{}}),extraActions:e.jsx(K,{})}),K=()=>{const r=D(),{id:a,fgId:t,fsId:s,fvName:i,fvVersion:u,tdVersion:f}=k(),{currentData:{items:h}={}}=$({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(S(M,R))})}),o=t?h:j,[m,{isLoading:g}]=H(),v=()=>{try{m({pId:a,fgId:t,fsId:s}).unwrap().then(x=>{r.success({title:"New computation started",content:`Job ${x.name} started`})})}catch{}},b=w.useMemo(()=>S(V(S(z(0,"computationTime"),I)),_(N,I(0)),A(B.DATE_TIME.DATE_TIME_FULL))(o??[]),[o]);return e.jsxs(n,{alignItems:"center",sx:{gap:"10px"},children:[o!==void 0&&!C(o)&&e.jsxs(d,{gray:!0,children:["computed at ",b]}),(o===void 0||C(o))&&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{K as C,ae as S};
