import{g as f}from"./codemirror-core-DIzFijqu.js";import{_ as u}from"./react-dom-BT-HHJs9.js";import{s as r}from"./index-tO5nu8Yv.js";var i={exports:{}},p,m;function b(){if(m)return p;m=1;var s="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return p=s,p}var d,y;function F(){if(y)return d;y=1;var s=b();function t(){}function a(){}return a.resetWarningCache=t,d=function(){function e(c,v,U,g,C,w){if(w!==s){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}e.isRequired=e;function n(){return e}var o={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:n,element:e,elementType:e,instanceOf:n,node:e,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:a,resetWarningCache:t};return o.PropTypes=o,o},d}var h;function T(){return h||(h=1,i.exports=F()()),i.exports}var R=T();const E=f(R);class I{static async listFiles(t="/"){const{data:a}=await r.get(`/File/list?path=${encodeURIComponent(t)}`);return a.data}static async listDirectories(t="/"){const{data:a}=await r.get(`/File/list?path=${encodeURIComponent(t)}&onlyDirectory=true`);return a.data}static async createDirectory(t){const{data:a}=await r.post("/File/mkdir",{path:t});return a.data}static async delete(t){const{data:a}=await r.post("/File/delete",{path:t});return a.data}static async readFile(t){const{data:a}=await r.get(`/File/read?path=${encodeURIComponent(t)}`);return a.data}static async writeFile(t,a){const{data:e}=await r.post("/File/write",{path:t,content:a});return e.data}static async createFile(t){const{data:a}=await r.post("/File/create",{path:t});return a.data}static async batchDelete(t){const{data:a}=await r.post("/File/batchDelete",{paths:t});return a.data}static async rename(t,a){const{data:e}=await r.post("/File/rename",{oldPath:t,newPath:a});return e.data}static async move(t,a){const{data:e}=await r.post("/File/move",{sourcePath:t,targetPath:a});return e.data}static async batchMove(t){const{data:a}=await r.post("/File/batchMove",{items:t});return a.data}static download(t){const a=`/File/download?path=${encodeURIComponent(t)}`;u.promise(r.post(a,void 0,{responseType:"blob"}).catch(e=>{throw console.error(e),new Error("下载失败")}),{loading:"正在下载文件...",success:"下载成功",error:"下载失败"}).then(e=>{const n=window.URL.createObjectURL(new Blob([e.data])),o=document.createElement("a");o.href=n;let c=t.split("/").pop()||"";t.split(".").length===1&&(c+=".zip"),o.setAttribute("download",c),document.body.appendChild(o),o.click(),document.body.removeChild(o)}).catch(e=>{console.error(e)})}static async batchDownload(t){u.promise(r.post("/File/batchDownload",{paths:t},{responseType:"blob"}).catch(e=>{throw console.error(e),new Error("下载失败")}),{loading:"正在下载文件...",success:"下载成功",error:"下载失败"}).then(e=>{const n=window.URL.createObjectURL(new Blob([e.data])),o=document.createElement("a");o.href=n,o.setAttribute("download","files.zip"),document.body.appendChild(o),o.click(),document.body.removeChild(o)}).catch(e=>{console.error(e)})}static async downloadToURL(t){const a=`/File/download?path=${encodeURIComponent(t)}`,e=await r.post(a,void 0,{responseType:"blob"});return window.URL.createObjectURL(new Blob([e.data]))}static async upload(t,a){const e=new FormData;a.forEach(o=>{e.append("files",o)});const{data:n}=await r.post(`/File/upload?path=${encodeURIComponent(t)}`,e,{headers:{"Content-Type":"multipart/form-data"}});return n.data}static async uploadWebUIFont(t){const a=new FormData;a.append("file",t);const{data:e}=await r.post("/File/font/upload/webui",a,{headers:{"Content-Type":"multipart/form-data"}});return e.data}static async deleteWebUIFont(){const{data:t}=await r.post("/File/font/delete/webui");return t.data}}export{I as F,E as P};
