import{u as L,b9 as T,y as P,r as s,q as k,p as E,i$ as v,bu as $,j0 as w,jg as B,bx as F,by as M,j as a,D as N,cq as O,bA as q}from"./index-Cc-6WbPt.js";import{d as G,e as z,f as A}from"./index-B586lZFk.js";import{D as Q}from"./DataSourceCreate-B15ZtAYK.js";import"./useScreenWithScroll-zcr7TMGO.js";import"./index-DeWhk8_Z.js";import"./flip-DZcY_k0G.js";import"./FeaturesForm-DS-x18mi.js";import"./sum-Bb5aTXea.js";import"./countBy-Ds8vJrZu.js";const _=()=>{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($("type",w(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(()=>B(r)(e),[e,r]);return F(`${M.editStorageConnector} - ${e==null?void 0:e.name}`),C&&!e||j?a.jsx(N,{}):!e&&!C?a.jsx(O,{}):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{_ as default};
