import{u as k,r as w,dX as c,j as e,y as F,B as o,p as S,d as p,e4 as T,bb as l,c as d,bz as D,hc as E,x as B,z as G,f as y,bu as L,f_ as M,gV as R,bR as A,gD as V,hd as _,he as I,aB as N,E as z,h as C,b4 as P}from"./index-C1DmWO_C.js";import{a as Q,u as H}from"./index-BduZzu1m.js";import{b as J,S as K,a as O}from"./StatisticsTables-gOzf3GUA.js";import{u as U}from"./Deprecated-BQWZLUTP.js";import{T as W}from"./TdFeatureGroupHandle-BpWo7RRg.js";import{F as X}from"./FeaturesLayout-2WejLh-p.js";const $=({data:r,parent:a,statistics:t,type:s})=>{var x;const{name:i,primary:u,partition:f}=r,{id:h,fgId:j,fsId:n}=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(o,{alignItems:"flex-end",children:[e.jsx(S,{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(o,{alignItems:"flex-end",children:e.jsxs(o,{flexDirection:"column",children:[e.jsxs(o,{children:[e.jsx(S,{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(W,{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(K,{dataType:s,data:t.extendedStatistics.histogram,type:t.featureType})}):e.jsx(p,{width:"calc((100% - 60px) / 4)"}),s===c.fg?e.jsx(O,{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(X,{data:r,type:t,"data-test":"stats-container",renderChild:({type:s,parent:i,data:u})=>e.jsx($,{type:s,parent:i,data:u,statistics:a[u.name]??{}}),extraActions:e.jsx(q,{})}),q=()=>{const r=D(),{id:a,fgId:t,fsId:s,fvName:i,fvVersion:u,tdVersion:f}=k(),{currentData:{items:h}={}}=Q({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:B({currentData:G(y(L,M))})}),n=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(()=>y(N(y(z(0,"computationTime"),I)),V(_,I(0)),R(A.DATE_TIME.DATE_TIME_FULL))(n??[]),[n]);return e.jsxs(o,{alignItems:"center",sx:{gap:"10px"},children:[n!==void 0&&!C(n)&&e.jsxs(d,{gray:!0,children:["computed at ",b]}),(n===void 0||C(n))&&e.jsx(d,{gray:!0,children:"Statistics are not configured for this version"}),t&&e.jsx(P,{intent:"ghost",onClick:v,isLoading:g,children:"Recompute"})]})};export{q as C,ae as S};
