import{b8 as _,u as y,gW as M,b2 as j,e as u,b0 as A,aR as O,r as d,b7 as I,g as S,aX as U,aY as Y,j as c,a_ as E,dF as z}from"./index-d6499a22.js";import{N as H}from"./NoData-789df290.js";import{P as K}from"./Panel-b19e8cc0.js";import{S as W}from"./StatisticsContent-88ec2161.js";import{u as X}from"./useUserPermissions-3851a25d.js";import{u as q}from"./useFeatureGroupView-0bc6732c.js";import{u as B}from"./useFeatureGroupVersions-ae275115.js";import"./Deprecated-ec8916ed.js";import"./CardActionButton-ccf1bc35.js";import"./index-620add9c.js";import"./StatisticsTables-f4036ad4.js";import"./generateCategoricalChart-1633db29.js";import"./index-ddf2d065.js";import"./index-038a72d6.js";import"./point-ea70dc51.js";import"./TdFeatureGroupHandle-84d5ab3b.js";import"./FeatureGroupTypeBadge-0a81479c.js";import"./FeaturesLayout-e0d1f0d6.js";import"./FilterResult-550b3b9f.js";import"./useFeatureFilters-659d6dec.js";import"./utils-2cbbb028.js";import"./FeatureFilters-d7ede7cc.js";import"./index-da50fbe6.js";import"./file-utils-b5704e1c.js";import"./useCurrentProject-b23444be.js";import"./useProject-0d0fdeb3.js";import"./project-e798ae71.js";const bt=()=>{const{DATE_TIME_FULL:n}=_.DATE_TIME,{id:s,fsId:i,fgId:r,commitTime:p}=y(),[f]=M(),{canEdit:F,isLoading:P,isDataScientist:x}=X(),T=j(e=>{var m;return(m=e.featureGroupStatistics)==null?void 0:m.entities.statistics}),o=j(e=>e.featureGroupStatisticsCommits),b=j(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(S(l,u.project.value,G)+(f?`?${f}`:""));return}h(S(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(K,{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||x||P,onClickEdit:()=>h(S(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:x?"Your role is not allowed to perform this action":void 0}),b&&c.jsx(E,{}),!b&&(!(t!=null&&t.features.length)||!T?c.jsx(H,{mainText:"No data available"}):c.jsx(W,{data:t,statistics:T}))]})};export{bt as default};
