import{u as L,b9 as T,y as P,r as s,q as k,p as E,iZ as v,bu as w,i_ as B,jf as F,bx as M,by as N,j as a,D as O,cq as $,bA as q}from"./index-ljTaFLaB.js";import{d as G,e as z,f as A}from"./index-FNYIAcGm.js";import{D as Q}from"./DataSourceCreate-BqPfrtJC.js";import"./useScreenWithScroll-zcr7TMGO.js";import"./index-WyeuJRlK.js";import"./flip-DVsL-10L.js";import"./FeaturesForm-CmOULT7K.js";import"./sum-DmZpJiQ9.js";import"./countBy-Bp9Idv1G.js";const Y=()=>{const{connectorName:o,id:n,fsId:t}=L(),l=T(),[f,i]=P(),[p,{error:h,isLoading:g}]=G(),[u,{isLoading:m}]=z(),{currentData:e,isUninitialized:j,isFetching:C}=A({pId:+n,fsId:+t,id:o}),D=s.useCallback(()=>{l(k.project.storageConnector.list,{fsId:t})},[t,l]),y=s.useCallback(async(c,d)=>{const{storageConnectorType:b}=c,I=E(w("type",B(b)),v(b))(c);await p({pId:+n,fsId:+t,id:o,data:I}).unwrap().then(R=>{d==null||d(c)})},[p,n,t,o]),x=s.useCallback(()=>u({pId:+n,fsId:+t,id:o}).unwrap().then(D),[u,n,t,o,D]),r=e==null?void 0:e.storageConnectorType,S=s.useMemo(()=>F(r)(e),[e,r]);return M(`${N.editStorageConnector} - ${e==null?void 0:e.name}`),C&&!e||j?a.jsx(O,{}):!e&&!C?a.jsx($,{}):a.jsxs(a.Fragment,{children:[a.jsx(Q,{error:h,isSaving:g||m,isDisabled:g,onSubmit:y,initialProtocol:r,initialData:S,onDelete:i,isEdit:!0}),a.jsx(q,{title:`Delete ${e==null?void 0:e.name}`,secondaryText:"Once you delete a storage connector, there is no going back. Please be certain.",isOpen:f,onClose:i,mainButtonProps:{children:"Delete",onClick:x,isLoading:m,"data-test":"delete-ds"},secondaryButtonProps:{children:"Back",onClick:i}})]})};export{Y as default};
