import{r as b,u as Z,dW as ee,bI as te,bp as ae,w as ie,eW as se,et as re,dU as oe,x as L,z as ne,aB as pe,gb as U,gc as h,gd as ue,h as $,e0 as C,ge as N,T as P,q as ce,s as A,bK as me,bx as de,by as le,j as n,L as ge,cr as fe,bA as xe}from"./index-C1DmWO_C.js";import{u as Fe,a as Se}from"./index-LyaEmxl4.js";import{F as Te}from"./FeatureGroupForm-DU_uYWp7.js";import{u as he}from"./useDeleteFG-Cx9HaRlJ.js";import"./Anchor-DFXOcnPw.js";import"./useScreenWithScroll-zcr7TMGO.js";import"./schematised-tags.selectors-xn4c-iOu.js";import"./storage-connector-BuEuJyVA.js";import"./AlertForm-CkZ7DISl.js";import"./alertManagerConfig.selectors-B9ELaxCY.js";import"./Project-CpwJZ-CK.js";import"./index-Dub34MAX.js";import"./FileUploaderButton-BtxUzlTS.js";import"./zipObj-D8EtfWld.js";import"./symmetricDifference-B3GPGppJ.js";import"./git-C8OLuEaG.js";import"./NoData-Y_e6mfNf.js";import"./useCopyToClipboard-v9FBn9Nz.js";import"./ServiceAlertList-CzBjm52H.js";import"./index-BnHp_Wzf.js";import"./transformations.selectors-DnzHXZ16.js";import"./LabelsForm-d9ejhXSo.js";import"./randomString-D3iDJlGT.js";import"./project-VxxpMOY0.js";import"./where-C_FV43Y5.js";import"./intersection-BP3rSf7y.js";import"./flip-DcJ5-1Gs.js";import"./isAfter-7Oi83Q9_.js";import"./useUpdateTdOrFvInfoService-BlTBzWj5.js";import"./SingleSelect-DvF8BLvQ.js";import"./SchematisedTagsForm-Cki5D0WB.js";import"./randomArrayString---X8tfjV.js";import"./sort-BOLIcXtz.js";import"./index-DMOJMCC5.js";import"./StatisticsConfigurationForm-B3NadTLP.js";import"./index-DDgDmsNg.js";import"./NewTransformationPopup-Y5zAhCoA.js";import"./ViewTransformation-CvML2ehg.js";import"./index-DMvrjxdW.js";import"./zoom-CRTJnDeN.js";import"./transform-C0Urpblx.js";import"./string-CFFdVFMV.js";const be=()=>{const{id:t,fsId:a,fgId:i}=Z(),{data:O}=ee(),o=te(),v=ae(),[B,u]=ie(),{currentData:M,isFetching:_}=se(),[y,{isLoading:q}]=Fe(),[E,{isLoading:Q}]=Se(),{deleteFg:H,isDeleting:D}=he(),K=()=>{u(),H()},{currentData:l,isLoading:R}=re({pId:+t,fsId:+a,fgId:+i},{skip:!O});b.useEffect(()=>{o.schematisedTags.fetch()},[o,t,M,a,i]);const{currentData:s,isFetching:W}=oe({pId:+t,fsId:+a,fgId:+i},{selectFromResult:L({currentData:ne(L({transformationFunctions:pe(({version:e,hopsworksUdf:{name:G,transformationFeatures:g}})=>({features:g,transformation:{name:`${G} v${e}`}}))}))})}),z=b.useCallback(async(e,G,g)=>{let j=i;try{if(g){const{features:r,enabled:f,histograms:x,correlations:F,exactUniqueness:S,expectationSuite:T,type:c,spine:m,...p}=e,d=await o.featureGroups.create({projectId:+t,featureStoreId:+a,data:{...p,type:c,features:U(r),timeTravelFormat:p.timeTravelFormat.toUpperCase(),descStatsEnabled:!!h(r).length,validationType:p.validationType[0].toUpperCase(),eventTime:ue(r),jobs:[],statisticsConfig:{columns:h(r),correlations:F,enabled:f,histograms:x,exactUniqueness:S},...!$(T.expectations??[])&&(c!==C.ON_DEMAND||!m&&e.onlineEnabled)?{expectationSuite:e.expectationSuite}:{}}});d&&(j=String(d))}else{const{features:r,transformationFunctions:f,description:x,enabled:F,histograms:S,correlations:T,exactUniqueness:c,onlineEnabled:m,tags:p,keywords:d,validationType:J,type:w,expectationSuite:k,notificationTopicName:V,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 y({id:t,fgId:i,fsId:a,data:e.expectationSuite}).unwrap()),await o.featureGroups.edit({projectId:+t,featureStoreId:+a,featureGroupId:+i,data:{description:x,keywords:d,features:U(r),transformationFunctions:f,onlineEnabled:m,tags:p,type:w,validationType:J[0],prevTags:l.map(({name:Y})=>Y),statisticsConfig:{columns:h(r),correlations:T,enabled:F,histograms:S,exactUniqueness:c},...!$(k.expectations??[])&&(w!==C.ON_DEMAND||!X&&m)?{expectationSuite:k}:{},notificationTopicName:V}})}o(N.invalidateTags([P.ProjectTags.FeatureGroup])),o(N.invalidateTags([{type:P.ProjectTags.FeatureGroupKeyword,id:i}])),v(ce(A.featureGroup.overview,A.project.value,{id:t,fsId:a,fgId:j}))}catch{}},[i,o,v,t,a,l,E,y]),I=me(e=>e.loading.effects.featureGroups.edit);return de(`${le.editFg} - ${s==null?void 0:s.name}`),W||R?n.jsx(ge,{}):s?n.jsxs(n.Fragment,{children:[n.jsx(Te,{isEdit:!0,isLoading:I||D||_||q||Q,isDisabled:I,submitHandler:z,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:K,isLoading:D,"data-test":"delete-feature-group"},secondaryButtonProps:{children:"Back",onClick:u}})]}):n.jsx(fe,{})},ct=b.memo(be);export{ct as default};
