import"./jwt-decode.esm-CQm3LY6y.js";import{C as i}from"./router-iclNQ3sb.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]="ec9ec834-f332-45e3-b086-38a216c2e171",t._sentryDebugIdIdentifier="sentry-dbid-ec9ec834-f332-45e3-b086-38a216c2e171")}catch{}})();function f(t){return t.split(/\/|\\/).pop()??""}function T(t){return[".png",".svg",".jpg",".jpeg",".ico",".webp"].some(e=>t.endsWith(e))}const d=5*1024*1024,p={"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"],"application/pdf":[".pdf"],"text/plain":[".txt",".xml",".py",".js",".ts",".java",".tsx",".jsx",".cpp",".c",".go",".sql",".yaml",".yml",".env",".html",".css"],"text/csv":[".csv"],"text/markdown":[".md"],"application/json":[".json"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":[".xlsx"],"application/vnd.ms-excel":[".xls"]},b=()=>Object.values(p).flat(),g=t=>Object.keys(p).includes(t),y=t=>{const e=t.lastIndexOf(".");return e===-1?"":t.substring(e).toLowerCase()},u=t=>{const e=y(t);if(!e)return null;for(const[o,n]of Object.entries(p))if(n.includes(e))return o;return null},j=t=>u(t)!==null,w=t=>{if(t.size>d)return{valid:!1,error:`File size exceeds ${x(d)} limit`};const e=t.type&&g(t.type),o=j(t.name);return!e&&!o?{valid:!1,error:"Unsupported file type"}:{valid:!0}},h=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)}),S=async t=>{const e=w(t);if(!e.valid)throw new Error(e.error);const o=await h(t),n=t.type||u(t.name)||"application/octet-stream";return{fileName:t.name,fileContent:o,fileSize:t.size,mimeType:n}},x=t=>{const o=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(1024));return Math.round(t/Math.pow(1024,n)*100)/100+" "+o[n]};class m{constructor(e){this.projectId=e}static fromProjectId(e){return new m(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 a=s.toString(),c=`projects/${this.projectId}/files?${a}`,l=await i.get(c);return{items:l.items,totalCount:l.totalCount}}async upload(e,o,n){const r={"Content-Type":"multipart/form-data"},s=new File([o||new Uint8Array],f(e)),a=n?"&overwrite=true":"",c=`projects/${this.projectId}/files/upload?path=${encodeURIComponent(e)}${a}`;return i.post(c,s,r)}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{m as F,b as g,T as i,S as p};
//# sourceMappingURL=file-BFCWKKzv.js.map
