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