import{_ as N}from"./DocsButton.vue_vue_type_script_setup_true_lang.d13fff5d.js";import{C as D}from"./ContentLayout.991bbf22.js";import{f as R,F as P,s as x}from"./FilesNavigator.9246e3d8.js";import{a as B}from"./asyncComputed.6b1d4165.js";import{d as U,e4 as z,g as S,c as k,w as u,o as A,a as b,b as l,az as f,u as d,d6 as M,O as T,d4 as V,eL as H,eM as L,Q as E}from"./index.e310aebb.js";import{C as i}from"./gateway.4d0dc75b.js";import"./columns.b1346706.js";import"./popupNotifcation.fa3e65fc.js";import"./ant-design.e632b777.js";import"./string.a01d17aa.js";import"./PhFolder.vue.6d10f5fd.js";import"./record.d2935dfa.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[e]="5b4c911d-d287-4883-8646-9e09df799b4e",s._sentryDebugIdIdentifier="sentry-dbid-5b4c911d-d287-4883-8646-9e09df799b4e")}catch{}})();class h{constructor(e){this.projectId=e}static fromProjectId(e){return new h(e)}async list(){return i.get(`projects/${this.projectId}/files`)}async upload(e,r){const a={"Content-Type":"multipart/form-data"},c=new File([new Blob(r?[r]:[])],R(e));return i.post(`projects/${this.projectId}/files/upload?path=${encodeURIComponent(e)}`,c,a)}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,r){return i.patch(`projects/${this.projectId}/files?path=${encodeURIComponent(e)}&newPath=${encodeURIComponent(r)}`,{})}}const G=s=>(H("data-v-4b0cf5fc"),s=s(),L(),s),O={class:"files-layout"},Q=G(()=>b("br",null,null,-1)),q=U({__name:"Files",setup(s){const r=z().params.projectId,a=h.fromProjectId(r),{loading:c,result:m,refetch:_}=B(()=>a.list()),y=n=>n.reduce((o,t)=>{var I,w;const $=t.type==="file"?[]:(w=(I=t.children)==null?void 0:I.map(p=>p.path.split("/")))!=null?w:[],F={pathParts:t.path.split("/"),size:t.type==="file"?x(t.size):0,lastModified:t.date,type:t.type,children:$};if(o.push(F),t.type==="directory"&&t.children&&t.children.length>0){const p=y(t.children);o.push(...p)}return o},[]),j=S(()=>m.value?y(m.value):[]);async function g(n,o){const t=n.join("/");await a.upload(t,o),await _()}function C(n){const o=n.join("/");return a.download(o)}function v(n){const o=n.join("/");return a.delete(o)}return(n,o)=>(A(),k(D,null,{default:u(()=>[b("div",O,[l(d(M),null,{default:u(()=>[f("Files")]),_:1}),l(d(V),null,{default:u(()=>[f(" Here you can upload, download and delete files in your persistent dir."),Q,f(" Files can be used in your scripts. "),l(N,{path:"tools/files"}),T(n.$slots,"description",{},void 0,!0)]),_:3}),l(P,{files:j.value,loading:d(c),separator:"/",onCreate:g,onDownload:C,onDelete:v,onRefetch:d(_)},null,8,["files","loading","onRefetch"])])]),_:3}))}});const ae=E(q,[["__scopeId","data-v-4b0cf5fc"]]);export{ae as default};
//# sourceMappingURL=Files.ef505da7.js.map
