import{$ as e,Ct as t,Gt as n,Ot as r,Q as i,X as a,mn as o,pn as s}from"./src-DTHkTkyy-Ce1TZuRw.js";import{n as c}from"./connect-BSkeWkEI-BYzoVZOI.js";import{n as l}from"./toast-DnODOv28-DJtc4rMD.js";import{r as u}from"./i18next-CPoJkeJl.js";import{jsx as d}from"react/jsx-runtime";async function f(e,t){let n=await fetch(e,{headers:t??{}});if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()}function p(){let p=n()?.type===`addDrive`,m=o(),h=s(),g=r(),_=async e=>{try{let n=g?.find(t=>t.config.id===e.id),r=await a({id:``,slug:``,global:{name:e.name,icon:null},local:{availableOffline:e.availableOffline,sharingType:e.sharingType.toLowerCase(),listeners:[],triggers:[]}},n?.config.id);if(l(u(`notifications.addDriveSuccess`),{type:`connect-success`}),!r)return;t(r)}catch(e){console.error(e)}},v=async e=>{try{let n=await i(e.url,e.id);l(u(`notifications.addDriveSuccess`),{type:`connect-success`}),t(n)}catch(e){console.error(e)}};async function y(t){await _(t),e()}async function b(t){await v(t),e()}let x=!!g?.length;return d(c,{open:p&&x,onAddLocalDrive:y,onAddRemoteDrive:b,requestPublicDrive:async e=>{try{return m?f(e,{Authorization:`Bearer ${await h?.getBearerToken?.({expiresIn:10,aud:e})}`}):f(e)}catch(t){return console.error(t),f(e)}},onOpenChange:t=>{if(!t)return e()},appOptions:g?.map(e=>({id:e.config.id,name:e.config.name,sharingType:`LOCAL`,availableOffline:!1}))||[]})}export{p as AddDriveModal};
//# sourceMappingURL=AddDriveModal-B9BPORvo-DbU7VeEC.js.map