import{_ as N}from"./DocsButton.vue_vue_type_script_setup_true_lang.a6841fb4.js";import{C as D}from"./ContentLayout.4be61bce.js";import{f as P,F as R,s as x}from"./FilesNavigator.41d150e8.js";import{a as B}from"./asyncComputed.d7c4e941.js";import{d as U,e4 as z,g as S,c as k,w as u,o as A,a as w,b as c,az as f,u as l,d6 as T,O as V,d4 as H,eP as M,eQ as Q,Q as E}from"./index.b7bd503f.js";import{C as i}from"./gateway.6db311e2.js";import"./columns.c99cb402.js";import"./popupNotifcation.bbf38424.js";import"./ant-design.9ec9316b.js";import"./string.9a3a939b.js";import"./PhDotsThree.vue.7a9da04b.js";import"./PhFolder.vue.84e81256.js";import"./record.c86f39d9.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]="c5d2c77c-17aa-4bac-b825-c59d5a3dbee1",s._sentryDebugIdIdentifier="sentry-dbid-c5d2c77c-17aa-4bac-b825-c59d5a3dbee1")}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,n){const r={"Content-Type":"multipart/form-data"},d=new File([new Blob(n?[n]:[])],P(e));return i.post(`projects/${this.projectId}/files/upload?path=${encodeURIComponent(e)}`,d,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,n){return i.patch(`projects/${this.projectId}/files?path=${encodeURIComponent(e)}&newPath=${encodeURIComponent(n)}`,{})}}const G=s=>(M("data-v-4b0cf5fc"),s=s(),Q(),s),L={class:"files-layout"},O=G(()=>w("br",null,null,-1)),q=U({__name:"Files",setup(s){const n=z().params.projectId,r=h.fromProjectId(n),{loading:d,result:m,refetch:_}=B(()=>r.list()),y=a=>a.reduce((o,t)=>{var I,b;const $=t.type==="file"?[]:(b=(I=t.children)==null?void 0:I.map(p=>p.path.split("/")))!=null?b:[],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(a,o){const t=a.join("/");await r.upload(t,o),await _()}function C(a){const o=a.join("/");return r.download(o)}function v(a){const o=a.join("/");return r.delete(o)}return(a,o)=>(A(),k(D,null,{default:u(()=>[w("div",L,[c(l(T),null,{default:u(()=>[f("Files")]),_:1}),c(l(H),null,{default:u(()=>[f(" Here you can upload, download and delete files in your persistent dir."),O,f(" Files can be used in your scripts. "),c(N,{path:"tools/files"}),V(a.$slots,"description",{},void 0,!0)]),_:3}),c(R,{files:j.value,loading:l(d),separator:"/",onCreate:g,onDownload:C,onDelete:v,onRefetch:l(_)},null,8,["files","loading","onRefetch"])])]),_:3}))}});const ie=E(q,[["__scopeId","data-v-4b0cf5fc"]]);export{ie as default};
//# sourceMappingURL=Files.affedff3.js.map
