import{r as T,u as Z,ee,bI as te,bo as ae,y as ie,g7 as se,eP as oe,ec as re,w as $,x as ne,az as pe,h as C,ek as L,g9 as y,ga as ue,gb as N,gc as P,Q as U,o as ce,q as A,bJ as me,bx as de,by as le,j as n,D as ge,cq as fe,bA as xe}from"./index-ljTaFLaB.js";import{u as Fe,a as Se}from"./index-CRcQpcPt.js";import{F as he}from"./FeatureGroupForm-DFR6uGgJ.js";import{u as ye}from"./useDeleteFG-Dfm0R3aS.js";import"./Anchor-Cg_B9iW8.js";import"./useScreenWithScroll-zcr7TMGO.js";import"./schematised-tags.selectors-WK3AUml0.js";import"./AlertForm-BNPL7Piu.js";import"./alertManagerConfig.selectors-DirIHxFq.js";import"./Project-BXqiQm5O.js";import"./complement-DcmnDjwS.js";import"./index-WyeuJRlK.js";import"./symmetricDifference-Chhazvqc.js";import"./git-BLdzamrJ.js";import"./useCopyToClipboard-CNgp2sLY.js";import"./ServiceAlertList-DPC1ApKd.js";import"./index-CFrWJVZR.js";import"./transformations.selectors-DnzHXZ16.js";import"./LabelsForm-rGCSSNxA.js";import"./randomString-D3iDJlGT.js";import"./project-FezsFbBI.js";import"./where-CKvYL2Df.js";import"./intersection-B1iDcdOv.js";import"./flip-DVsL-10L.js";import"./isAfter-DUSi0zl2.js";import"./useUpdateTdOrFvInfoService-BmKEmn5U.js";import"./SingleSelect-6Q2B8ZHD.js";import"./FeaturesForm-CmOULT7K.js";import"./SchematisedTagsForm-DnH6WBYV.js";import"./randomArrayString---X8tfjV.js";import"./sort-BOLIcXtz.js";import"./index-Df7phmI_.js";import"./StatisticsConfigurationForm-D_70U16b.js";import"./index-FNYIAcGm.js";import"./NewTransformationPopup-C6hqMfNs.js";import"./ViewTransformation-Di63QQDd.js";import"./index-D4sG62Gj.js";import"./zoom-A7rKCg-F.js";import"./transform-DZgNhtp2.js";import"./string-CFFdVFMV.js";const Te=()=>{const{id:t,fsId:a,fgId:i}=Z(),{data:O}=ee(),r=te(),b=ae(),[q,u]=ie(),{currentData:B,isFetching:M}=se(),[v,{isLoading:Q}]=Fe(),[E,{isLoading:_}]=Se(),{deleteFg:H,isDeleting:D}=ye(),R=()=>{u(),H()},{currentData:l,isLoading:z}=oe({pId:+t,fsId:+a,fgId:+i},{skip:!O});T.useEffect(()=>{r.schematisedTags.fetch()},[r,t,B,a,i]);const{currentData:s,isFetching:J}=re({pId:+t,fsId:+a,fgId:+i},{selectFromResult:$({currentData:ne($({transformationFunctions:pe(({version:e,hopsworksUdf:{name:G,transformationFeatures:g}})=>({features:g,transformation:{name:`${G} v${e}`}}))}))})}),K=T.useCallback(async(e,G,g)=>{let j=i;try{if(g){const{features:o,enabled:f,histograms:x,correlations:F,exactUniqueness:S,expectationSuite:h,type:c,spine:m,...p}=e,d=await r.featureGroups.create({projectId:+t,featureStoreId:+a,data:{...p,type:c,features:N(o),timeTravelFormat:p.timeTravelFormat.toUpperCase(),descStatsEnabled:!!y(o).length,validationType:p.validationType[0].toUpperCase(),eventTime:ue(o),jobs:[],statisticsConfig:{columns:y(o),correlations:F,enabled:f,histograms:x,exactUniqueness:S},...!C(h.expectations??[])&&(c!==L.ON_DEMAND||!m&&e.onlineEnabled)?{expectationSuite:e.expectationSuite}:{}}});d&&(j=String(d))}else{const{features:o,transformationFunctions:f,description:x,enabled:F,histograms:S,correlations:h,exactUniqueness:c,onlineEnabled:m,tags:p,keywords:d,validationType:V,type:k,expectationSuite:w,notificationTopicName:W,spine:X}=e;e.expectationSuite&&Object.keys(e.expectationSuite).length>1&&(e.expectationSuite.id?await E({id:t,fgId:i,fsId:a,data:e.expectationSuite}).unwrap():await v({id:t,fgId:i,fsId:a,data:e.expectationSuite}).unwrap()),await r.featureGroups.edit({projectId:+t,featureStoreId:+a,featureGroupId:+i,data:{description:x,keywords:d,features:N(o),transformationFunctions:f,onlineEnabled:m,tags:p,type:k,validationType:V[0],prevTags:l.map(({name:Y})=>Y),statisticsConfig:{columns:y(o),correlations:h,enabled:F,histograms:S,exactUniqueness:c},...!C(w.expectations??[])&&(k!==L.ON_DEMAND||!X&&m)?{expectationSuite:w}:{},notificationTopicName:W}})}r(P.invalidateTags([U.ProjectTags.FeatureGroup])),r(P.invalidateTags([{type:U.ProjectTags.FeatureGroupKeyword,id:i}])),b(ce(A.project.featureGroup.overview,A.project.value,{id:t,fsId:a,fgId:j}))}catch{}},[i,r,b,t,a,l,E,v]),I=me(e=>e.loading.effects.featureGroups.edit);return de(`${le.editFg} - ${s==null?void 0:s.name}`),J||z?n.jsx(ge,{}):s?n.jsxs(n.Fragment,{children:[n.jsx(he,{isEdit:!0,isLoading:I||D||M||Q||_,isDisabled:I,submitHandler:K,onDelete:u,initialData:{...s,tags:l}}),n.jsx(xe,{title:`Delete ${s.name} v${s.version}`,secondaryText:"Once you delete a feature group, there is no going back. Please be certain.",isOpen:q,onClose:u,mainButtonProps:{children:`Delete ${s.name} v${s.version}`,onClick:R,isLoading:D,"data-test":"delete-feature-group"},secondaryButtonProps:{children:"Back",onClick:u}})]}):n.jsx(fe,{})},pt=T.memo(Te);export{pt as default};
