import{b9 as y,u as M,gX as _,b3 as S,b as u,b1 as A,aS as O,r as d,b8 as I,c as j,aY as U,aZ as Y,j as c,a$ as E,dJ as z}from"./index-ea7817a2.js";import{N as H}from"./NoData-8733f606.js";import{P as J}from"./Panel-041c5d61.js";import{S as X}from"./StatisticsContent-3bf60bee.js";import{u as Z}from"./useUserPermissions-d2903885.js";import{u as q}from"./useFeatureGroupView-80b143cb.js";import{u as B}from"./useFeatureGroupVersions-ee161b97.js";import"./Deprecated-9bfe2e44.js";import"./CardActionButton-6aa39bc1.js";import"./index-0443c26e.js";import"./StatisticsTables-d20123a2.js";import"./generateCategoricalChart-e28fa4a2.js";import"./index-43e7382e.js";import"./index-1c428bf7.js";import"./point-ea70dc51.js";import"./TdFeatureGroupHandle-d5486ece.js";import"./FeatureGroupTypeBadge-0e65ce60.js";import"./FeaturesLayout-990a2693.js";import"./FilterResult-9d9dd7e5.js";import"./useFeatureFilters-c103b717.js";import"./utils-aedc41ca.js";import"./FeatureFilters-9d528cd7.js";import"./index-8f672200.js";import"./file-utils-a5f053e8.js";import"./useCurrentProject-0132f110.js";import"./useProject-77619fff.js";import"./project-c611a3ec.js";const Tt=()=>{const{DATE_TIME_FULL:n}=y.DATE_TIME,{id:s,fsId:i,fgId:r,commitTime:p}=M(),[f]=_(),{canEdit:F,isLoading:P,isDataScientist:b}=Z(),x=S(e=>{var m;return(m=e.featureGroupStatistics)==null?void 0:m.entities.statistics}),o=S(e=>e.featureGroupStatisticsCommits),T=S(e=>e.loading.effects.featureGroupStatistics.fetch),{data:t,isLoading:L}=q(+s,+r,+i),{currentData:V=[t],isFetching:$,handleVersionChange:N}=B(t==null?void 0:t.name,u.featureGroup.statistics),a=A(),h=O(),k=d.useCallback(()=>{a.featureGroupStatisticsCommits.fetch({projectId:+s,featureStoreId:+i,featureGroupId:+r}),a.featureGroupStatistics.fetch({projectId:+s,featureStoreId:+i,featureGroupId:+r,timeCommit:p})},[a.featureGroupStatisticsCommits,a.featureGroupStatistics,s,i,r,p]),g=d.useMemo(()=>{let e=p;return o.length>0&&(!e||e===o[0]?e=`${I(+o[0],n)} (latest)`:Number.isInteger(+e)&&(e=I(+e,n))),e},[p,o,n]),v=d.useCallback((e,m=r)=>{let D=e;e!=null&&e.includes("(latest)")&&(D=e.slice(0,e.indexOf(" (latest)")));const C=o.find(l=>I(+l,n)===D),R=o.find(l=>{const G=I(+l,n);return G===g||`${G} (latest)`===g});if(C&&R!==C){const l=u.featureGroup.statisticsViewCommit,G={id:s,fsId:i,fgId:m,commitTime:C};h(j(l,u.project.value,G)+(f?`?${f}`:""));return}h(j(u.featureGroup.statistics,u.project.value,{id:s,fsId:i,fgId:m})+(f?`?${f}`:""))},[s,i,o,h,r,g,n,f]),w=d.useCallback(e=>{const[m]=e;v(m)},[v]);return d.useEffect(()=>(a.featureGroupStatisticsCommits.fetch({projectId:+s,featureStoreId:+i,featureGroupId:+r}),a.featureGroupStatistics.fetch({projectId:+s,featureStoreId:+i,featureGroupId:+r,timeCommit:p}),()=>{a.featureGroupDataPreview.clear()}),[s,r,a,i,p]),U(`${Y.statistics} ${t!=null&&t.name?` - ${t.name}`:""}`),L?c.jsx(E,{}):c.jsxs(c.Fragment,{children:[c.jsx(J,{type:z.fg,data:t,title:t==null?void 0:t.name,idColor:(t==null?void 0:t.type)==="onDemandFeaturegroupDTO"?"labels.blue":"labels.orange",isEditDisabled:!F||b||P,onClickEdit:()=>h(j(u.featureGroup.edit,u.project.value,{id:s,fsId:i,fgId:r})),onClickRefresh:k,version:t==null?void 0:t.version,versions:V,isVersionsLoading:$,onVersionChange:N,hasCommits:!0,commits:o||[],commit:g,handleCommitChange:w,pathnamePostFix:"/statistics",editRightText:b?"Your role is not allowed to perform this action":void 0}),T&&c.jsx(E,{}),!T&&(!(t!=null&&t.features.length)||!x?c.jsx(H,{mainText:"No data available"}):c.jsx(X,{data:t,statistics:x}))]})};export{Tt as default};
