import{r as T,u as Z,ed as ee,bH as te,bo as ae,y as ie,g4 as se,eN as oe,eb as re,w as N,x as ne,az as pe,h as $,ej as C,g6 as y,g7 as ue,g8 as L,g9 as U,Q as P,o as ce,q as O,bI as me,bw as de,bx as le,j as n,D as ge,cp as fe,bz as xe}from"./index-46ma1THH.js";import{u as Fe,a as Se}from"./index-CyflCCZl.js";import{F as he}from"./FeatureGroupForm-BCvGH9AR.js";import{u as ye}from"./useDeleteFG-BL2OCAea.js";import"./Anchor-VqM1KJ3L.js";import"./useScreenWithScroll-zcr7TMGO.js";import"./schematised-tags.selectors-WK3AUml0.js";import"./AlertForm-BcJ4dT7r.js";import"./alertManagerConfig.selectors-ByceE4ck.js";import"./Project-DqNODNns.js";import"./complement-Cl658Mix.js";import"./index-CcWUz40c.js";import"./symmetricDifference-Bbf2VNbK.js";import"./git-BLdzamrJ.js";import"./useCopyToClipboard-B8vQLvqE.js";import"./ServiceAlertList-BRlmr1Cp.js";import"./index-BOKQPbnb.js";import"./transformations.selectors-DnzHXZ16.js";import"./LabelsForm-didD155z.js";import"./randomString-D3iDJlGT.js";import"./project-DhxCVD8Q.js";import"./where-BYLuQ215.js";import"./intersection-DOkgR8_-.js";import"./flip-szqi4alz.js";import"./isAfter-C0OnBXsh.js";import"./useUpdateTdOrFvInfoService-BiDORrPs.js";import"./SingleSelect-DyMHGSBW.js";import"./FeaturesForm-CufhwCoR.js";import"./SchematisedTagsForm-dh4vAE2D.js";import"./randomArrayString---X8tfjV.js";import"./sort-BOLIcXtz.js";import"./index-D241LvV7.js";import"./StatisticsConfigurationForm-8hTSbrIW.js";import"./index-CEcdCfcT.js";import"./NewTransformationPopup-BfKLghWw.js";import"./ViewTransformation-BHQuUfcb.js";import"./index-BSYtROPn.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:A}=ee(),r=te(),b=ae(),[B,u]=ie(),{currentData:M,isFetching:Q}=se(),[v,{isLoading:_}]=Fe(),[E,{isLoading:q}]=Se(),{deleteFg:H,isDeleting:D}=ye(),z=()=>{u(),H()},{currentData:l,isLoading:R}=oe({pId:+t,fsId:+a,fgId:+i},{skip:!A});T.useEffect(()=>{r.schematisedTags.fetch()},[r,t,M,a,i]);const{currentData:s,isFetching:K}=re({pId:+t,fsId:+a,fgId:+i},{selectFromResult:N({currentData:ne(N({transformationFunctions:pe(({version:e,hopsworksUdf:{name:G,transformationFeatures:g}})=>({features:g,transformation:{name:`${G} v${e}`}}))}))})}),J=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:L(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},...!$(h.expectations??[])&&(c!==C.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:w,expectationSuite:k,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:L(o),transformationFunctions:f,onlineEnabled:m,tags:p,type:w,validationType:V[0],prevTags:l.map(({name:Y})=>Y),statisticsConfig:{columns:y(o),correlations:h,enabled:F,histograms:S,exactUniqueness:c},...!$(k.expectations??[])&&(w!==C.ON_DEMAND||!X&&m)?{expectationSuite:k}:{},notificationTopicName:W}})}r(U.invalidateTags([P.ProjectTags.FeatureGroup])),r(U.invalidateTags([{type:P.ProjectTags.FeatureGroupKeyword,id:i}])),b(ce(O.project.featureGroup.overview,O.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}`),K||R?n.jsx(ge,{}):s?n.jsxs(n.Fragment,{children:[n.jsx(he,{isEdit:!0,isLoading:I||D||Q||_||q,isDisabled:I,submitHandler:J,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:B,onClose:u,mainButtonProps:{children:`Delete ${s.name} v${s.version}`,onClick:z,isLoading:D,"data-test":"delete-feature-group"},secondaryButtonProps:{children:"Back",onClick:u}})]}):n.jsx(fe,{})},pt=T.memo(Te);export{pt as default};
