import{b8 as M,u as _,b2 as S,e as f,aR as $,b0 as A,r as p,b7 as g,g as F,as as O,dm as U,fs as Y,aX as z,aY as H,j as a,ce as K,a_ as v,ak as X,dF as q}from"./index-d6499a22.js";import{P as B}from"./Panel-b19e8cc0.js";import{N as J}from"./NoData-789df290.js";import{C as Q}from"./Correlation-581c8cf0.js";import{u as W}from"./useUserPermissions-3851a25d.js";import{u as Z}from"./useFeatureGroupView-0bc6732c.js";import{u as tt}from"./useFeatureGroupVersions-ae275115.js";import"./Deprecated-ec8916ed.js";import"./CardActionButton-ccf1bc35.js";import"./setPrototypeOf-8d862a7d.js";import"./objectWithoutPropertiesLoose-4f48578a.js";import"./utils-2832fe88.js";import"./useCurrentProject-b23444be.js";import"./useProject-0d0fdeb3.js";import"./FileUploaderButton-c4f1b533.js";import"./useDownload-7167ff3b.js";import"./props-01648cd9.js";import"./zipObj-e651182a.js";import"./index-da50fbe6.js";import"./file-utils-b5704e1c.js";import"./project-e798ae71.js";const xt=()=>{const{DATE_TIME_FULL:m}=M.DATE_TIME,{id:s,fsId:r,fgId:o,commitTime:u}=_(),l=S(t=>{var c;return(c=t.featureGroupStatistics)==null?void 0:c.entities.statistics}),j=S(t=>t.loading.effects.featureGroupStatistics.fetch),i=S(t=>t.featureGroupStatisticsCommits),{isLoading:x,data:e}=Z(+s,+o,+r),{currentData:L=[e],isFetching:N,handleVersionChange:V}=tt(e==null?void 0:e.name,f.featureGroup.correlation),h=$(),n=A(),{canEdit:k,isLoading:P,isDataScientist:T}=W();p.useEffect(()=>{n.featureGroupStatisticsCommits.fetch({projectId:+s,featureStoreId:+r,featureGroupId:+o}),n.featureGroupStatistics.fetch({projectId:+s,featureStoreId:+r,featureGroupId:+o,timeCommit:u})},[s,o,n,r,u]);const y=p.useCallback(()=>{n.featureGroupStatisticsCommits.fetch({projectId:+s,featureStoreId:+r,featureGroupId:+o}),n.featureGroupStatistics.fetch({projectId:+s,featureStoreId:+r,featureGroupId:+o,timeCommit:u})},[n.featureGroupStatisticsCommits,n.featureGroupStatistics,s,r,o,u]),d=p.useMemo(()=>{let t=u;return i.length>0&&(!t||t===i[0]?t=`${g(+i[0],m)} (latest)`:Number.isInteger(+t)&&(t=g(+t,m))),t},[u,i,m]),b=p.useCallback((t,c=o)=>{let E=t;t.includes("(latest)")&&(E=t.slice(0,t.indexOf(" (latest)")));const I=i.find(G=>g(+G,m)===E),w=i.find(G=>{const D=g(+G,m);return D===d||`${D} (latest)`===d});I&&w!==I&&h(F(f.featureGroup.correlationViewCommit,f.project.value,{id:s,fsId:r,fgId:c,commitTime:I}))},[s,r,i,h,o,d,m]),R=p.useCallback(t=>{const[c]=t;b(c)},[b]),C=p.useMemo(()=>l&&O(U(Y,"correlations"),l),[l]);return z(`${H.correlation} ${e!=null&&e.name?e.name:"Feature group"}`),!x&&!e?a.jsx(K,{}):x?a.jsx(v,{}):a.jsxs(a.Fragment,{children:[a.jsx(B,{title:e.name,data:e,idColor:(e==null?void 0:e.type)==="onDemandFeaturegroupDTO"?"labels.blue":"labels.orange",isEditDisabled:!k||T||P,onClickEdit:()=>h(F(f.featureGroup.edit,f.project.value,{id:s,fsId:r,fgId:o})),onClickRefresh:y,version:e==null?void 0:e.version,versions:L||[],isVersionsLoading:N,onVersionChange:V,hasCommits:!0,commits:i||[],commit:d,handleCommitChange:R,pathnamePostFix:"/correlation",editRightText:T?"Your role is not allowed to perform this action":void 0}),j&&a.jsx(v,{}),!j&&(!C||X(C)?a.jsx(J,{mainText:"No feature correlation",secondaryText:""}):a.jsx(Q,{item:e,correlation:C,type:q.fg}))]})};export{xt as default};
