import{_ as N}from"./DocsButton.vue_vue_type_script_setup_true_lang.1a5f4246.js";import{C as D}from"./ContentLayout.24733df3.js";import{F as R}from"./FilesNavigator.e61fbf00.js";import{a as P}from"./asyncComputed.fe6ca61b.js";import{a as x,s as B}from"./files.b924b280.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 d,az as f,u as l,d6 as M,O as T,d4 as V,eL as H,eM as L,Q as E}from"./index.6b1213c6.js";import{C as i}from"./gateway.d1bcadc7.js";import"./columns.5cccb454.js";import"./popupNotifcation.97dc9547.js";import"./ant-design.d006a6d7.js";import"./string.8a712bbd.js";import"./PhFolder.vue.552fd64c.js";import"./record.9f32285a.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]="61269499-ebd6-496d-a58b-15e3c4dd73bf",s._sentryDebugIdIdentifier="sentry-dbid-61269499-ebd6-496d-a58b-15e3c4dd73bf")}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 a={"Content-Type":"multipart/form-data"},c=new File([new Blob(n?[n]:[])],x(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,n){return i.patch(`projects/${this.projectId}/files?path=${encodeURIComponent(e)}&newPath=${encodeURIComponent(n)}`,{})}}const G=s=>(H("data-v-4b0cf5fc"),s=s(),L(),s),O={class:"files-layout"},Q=G(()=>w("br",null,null,-1)),q=U({__name:"Files",setup(s){const n=z().params.projectId,a=h.fromProjectId(n),{loading:c,result:m,refetch:_}=P(()=>a.list()),y=r=>r.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"?B(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(r,o){const t=r.join("/");await a.upload(t,o),await _()}function C(r){const o=r.join("/");return a.download(o)}function v(r){const o=r.join("/");return a.delete(o)}return(r,o)=>(A(),k(D,null,{default:u(()=>[w("div",O,[d(l(M),null,{default:u(()=>[f("Files")]),_:1}),d(l(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. "),d(N,{path:"tools/files"}),T(r.$slots,"description",{},void 0,!0)]),_:3}),d(R,{files:j.value,loading:l(c),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.072100d8.js.map
