import{_ as F}from"./DocsButton.vue_vue_type_script_setup_true_lang.97173c26.js";import{C as D}from"./ContentLayout.4f819aa5.js";import{F as R}from"./FilesNavigator.91d0433e.js";import{a as P}from"./asyncComputed.8007720a.js";import{a as x,s as B}from"./files.7d0ee655.js";import{d as U,e4 as z,g as S,c as k,w as f,o as A,a as j,b as l,az as u,u as c,d6 as T,O as V,d4 as H,eN as M,eO as O,Q as E}from"./index.2bd55860.js";import{C as i}from"./gateway.79c1aab3.js";import"./columns.0eb7599e.js";import"./popupNotifcation.44e16211.js";import"./ant-design.52becce9.js";import"./string.fcee8e82.js";import"./PhFolder.vue.0fd5da48.js";import"./record.5f72dfbb.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]="ff98ea96-0cfd-49e8-aef9-9676a07f7276",s._sentryDebugIdIdentifier="sentry-dbid-ff98ea96-0cfd-49e8-aef9-9676a07f7276")}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"},d=new File([new Blob(n?[n]:[])],x(e));return i.post(`projects/${this.projectId}/files/upload?path=${encodeURIComponent(e)}`,d,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=>(M("data-v-4b0cf5fc"),s=s(),O(),s),L={class:"files-layout"},Q=G(()=>j("br",null,null,-1)),q=U({__name:"Files",setup(s){const n=z().params.projectId,a=h.fromProjectId(n),{loading:d,result:m,refetch:_}=P(()=>a.list()),y=r=>r.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:[],N={pathParts:t.path.split("/"),size:t.type==="file"?B(t.size):0,lastModified:t.date,type:t.type,children:$};if(o.push(N),t.type==="directory"&&t.children&&t.children.length>0){const p=y(t.children);o.push(...p)}return o},[]),g=S(()=>m.value?y(m.value):[]);async function b(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:f(()=>[j("div",L,[l(c(T),null,{default:f(()=>[u("Files")]),_:1}),l(c(H),null,{default:f(()=>[u(" Here you can upload, download and delete files in your persistent dir."),Q,u(" Files can be used in your scripts. "),l(F,{path:"tools/files"}),V(r.$slots,"description",{},void 0,!0)]),_:3}),l(R,{files:g.value,loading:c(d),separator:"/",onCreate:b,onDownload:C,onDelete:v,onRefetch:c(_)},null,8,["files","loading","onRefetch"])])]),_:3}))}});const ie=E(q,[["__scopeId","data-v-4b0cf5fc"]]);export{ie as default};
//# sourceMappingURL=Files.81b36bfa.js.map
