import{t as e}from"./http-BrugN6o-.js";import{n as t,t as n}from"./notification-BM55Quw3.js";import{t as r}from"./error-handling-CRDNZ9kr.js";var i=(i=!1)=>{let a=i?window.pinia.defineStore:t,{global:o}=window.i18n;return a(`disk`,{state:()=>({disks:[],diskDrivers:[],diskConfigData:null,selected_driver:`local`,doSpaceDiskConfig:{name:``,selected_driver:`doSpaces`,key:``,secret:``,region:``,bucket:``,endpoint:``,root:``},dropBoxDiskConfig:{name:``,selected_driver:`dropbox`,token:``,key:``,secret:``,app:``},localDiskConfig:{name:``,selected_driver:`local`,root:``},s3DiskConfigData:{name:``,selected_driver:`s3`,key:``,secret:``,region:``,bucket:``,root:``},s3CompatDiskConfigData:{name:``,selected_driver:`s3compat`,key:``,secret:``,region:``,bucket:``,root:``,endpoint:``}}),getters:{getDiskDrivers:e=>e.diskDrivers},actions:{fetchDiskEnv(t){return new Promise((n,i)=>{e.get(`/api/v1/disks/${t.disk}`).then(e=>{n(e)}).catch(e=>{r(e),i(e)})})},fetchDisks(t){return new Promise((n,i)=>{e.get(`/api/v1/disks`,{params:t}).then(e=>{this.disks=e.data.data,n(e)}).catch(e=>{r(e),i(e)})})},fetchDiskDrivers(){return new Promise((t,n)=>{e.get(`/api/v1/disk/drivers`).then(e=>{this.diskConfigData=e.data,this.diskDrivers=e.data.drivers,t(e)}).catch(e=>{r(e),n(e)})})},deleteFileDisk(t){return new Promise((i,a)=>{e.delete(`/api/v1/disks/${t}`).then(e=>{if(e.data.success){let e=this.disks.findIndex(e=>e.id===t);this.disks.splice(e,1),n().showNotification({type:`success`,message:o.t(`settings.disk.deleted_message`)})}i(e)}).catch(e=>{r(e),a(e)})})},updateDisk(t){return new Promise((i,a)=>{e.put(`/api/v1/disks/${t.id}`,t).then(e=>{if(e.data){let r=this.disks.findIndex(t=>t.id===e.data.data);this.disks[r]=t.disks,n().showNotification({type:`success`,message:o.t(`settings.disk.success_set_default_disk`)})}i(e)}).catch(e=>{r(e),a(e)})})},createDisk(t){return new Promise((i,a)=>{e.post(`/api/v1/disks`,t).then(e=>{e.data&&n().showNotification({type:`success`,message:o.t(`settings.disk.success_create`)}),this.disks.push(e.data),i(e)}).catch(e=>{r(e),a(e)})})}}})()};export{i as t};