import"./jwt-decode.esm.f87c17f7.js";import{k as i}from"./router.09566602.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="bd99d5d2-bd8e-4876-a51e-7d99d173eb4f",t._sentryDebugIdIdentifier="sentry-dbid-bd99d5d2-bd8e-4876-a51e-7d99d173eb4f")}catch{}})();function m(t){var e;return(e=t.split(/\/|\\/).pop())!=null?e:""}function T(t){return t.length===0?".":t[t.length-1]}function v(t){return[".png",".svg",".jpg",".jpeg",".ico",".webp"].some(e=>t.endsWith(e))}const d=5*1024*1024,a={"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"],"application/pdf":[".pdf"],"text/plain":[".txt"],"text/csv":[".csv"],"text/markdown":[".md"],"application/json":[".json"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":[".xlsx"],"application/vnd.ms-excel":[".xls"]},S=()=>Object.values(a).flat(),g=t=>Object.keys(a).includes(t),y=t=>{const e=t.lastIndexOf(".");return e===-1?"":t.substring(e).toLowerCase()},l=t=>{const e=y(t);if(!e)return null;for(const[o,n]of Object.entries(a))if(n.includes(e))return o;return null},w=t=>l(t)!==null,h=t=>{if(t.size>d)return{valid:!1,error:`File size exceeds ${b(d)} limit`};const e=t.type&&g(t.type),o=w(t.name);return!e&&!o?{valid:!1,error:"Unsupported file type"}:{valid:!0}},j=t=>new Promise((e,o)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>{const s=n.result.split(",")[1];e(s)},n.onerror=r=>o(r)}),F=async t=>{const e=h(t);if(!e.valid)throw new Error(e.error);const o=await j(t),n=t.type||l(t.name)||"application/octet-stream";return{fileName:t.name,fileContent:o,fileSize:t.size,mimeType:n}},b=t=>{if(t===0)return"0 Bytes";const e=1024,o=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(e));return Math.round(t/Math.pow(e,n)*100)/100+" "+o[n]};class p{constructor(e){this.projectId=e}static fromProjectId(e){return new p(e)}async list(e,o,n,r){const s=new URLSearchParams;s.set("limit",e.toString()),s.set("offset",o.toString()),n&&n.trim()&&s.set("search",n.trim()),r&&r.trim()&&s.set("path",r.trim());const u=s.toString(),f=`projects/${this.projectId}/files?${u}`,c=await i.get(f);return{items:c.items,totalCount:c.totalCount}}async upload(e,o){const n={"Content-Type":"multipart/form-data"},r=new File([o||new Uint8Array],m(e));return i.post(`projects/${this.projectId}/files/upload?path=${encodeURIComponent(e)}`,r,n)}async download(e){return i.getBlob(`projects/${this.projectId}/files/download?path=${encodeURIComponent(e)}`)}async delete(e){return i.delete(`projects/${this.projectId}/files?path=${encodeURIComponent(e)}`)}async move(e,o){return i.post(`projects/${this.projectId}/files/move`,{path:e,newPath:o})}async createFolder(e){return i.post(`projects/${this.projectId}/files/create-folder`,{path:e})}}export{p as F,T as f,S as g,v as i,F as p};
//# sourceMappingURL=file.0cd01b5c.js.map
