import{u as w,r as k,ee as c,j as e,b as F,$ as o,v as y,L as p,en as T,b8 as l,c as d,by as D,he as E,w as L,x as G,p as S,bs as M,fU as R,hf as A,bP as B,gw as _,hg as N,hh as I,az as V,B as $,h as C,b1 as P}from"./index-46ma1THH.js";import{a as Q,u as U}from"./index-Dp4ot73A.js";import{b as z,S as H,a as J}from"./StatisticsTables-C8cLXJBs.js";import{u as O}from"./Deprecated-CcWZugSq.js";import{T as W}from"./TdFeatureGroupHandle-DNdFQDy0.js";import{F as q}from"./FeaturesLayout-C2iMigz-.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}=w(),{isActiveFeature:m,handleBasket:g,isSwitch:v}=O(),b=k.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(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(o,{alignItems:"flex-end",children:e.jsxs(o,{flexDirection:"column",children:[e.jsxs(o,{children:[e.jsx(y,{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(z,{data:t}),(x=t.extendedStatistics)!=null&&x.histogram?e.jsx(p,{width:"calc((100% - 60px) / 4)",children:e.jsx(H,{dataType:s,data:t.extendedStatistics.histogram,type:t.featureType})}):e.jsx(p,{width:"calc((100% - 60px) / 4)"}),s===c.fg?e.jsx(J,{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(q,{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}=w(),{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:L({currentData:G(S(M,R))})}),n=t?h:j,[m,{isLoading:g}]=U(),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=k.useMemo(()=>S(V(S($(0,"computationTime"),I)),_(N,I(0)),A(B.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{X as C,ae as S};
