import{c as e,f as a,aO as t,X as r,w as i,Z as o,V as n,Y as c,t as s,v as l,aW as p,B as d,F as h,z as m,T as u,aR as f,P as x,O as y,as as b,S as v,b5 as S,y as g,aV as L}from"./index-B0xWR_Ua.js";import{h as k}from"./hasRouteMatch-DUJkFZih.js";import{B as w}from"./Background-Cg_pRnA2.js";import{R as z}from"./Refresh-pgeEdZyY.js";import{K as A}from"./KeyboardArrowLeft-CRSPaoDv.js";import{A as j}from"./Article-8KNWLEdt.js";const I=e(a("path",{d:"M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"}),"Folder"),V=e(a("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"}),"Image"),H=e(a("path",{d:"M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"}),"InsertDriveFile"),C=[{type:l.Link,action:"back-action",label:a(A,{sx:{display:"block"}})},{type:l.Link,action:"back-action",label:"Main"},{type:l.Link,action:"back-action",label:"Dump Explorer"}],E=[{action:"update-now",label:"Refresh",icon:()=>a(m,{icon:z,color:"#4caf50"})}],M=e=>e.mimeType.startsWith("image/")?a(V,{sx:{color:"#f57c00",fontSize:20}}):"application/json"===e.mimeType?a(g,{sx:{color:"#7b1fa2",fontSize:20}}):e.mimeType.startsWith("text/")?a(j,{sx:{color:"#1976d2",fontSize:20}}):a(H,{sx:{color:"#546e7a",fontSize:20}}),R=new n,T=({params:e})=>{const[n,l]=t(e.search),[m,{loading:g,execute:L}]=r(async()=>await i.explorerViewService.getFolderTree(),{onLoadStart:()=>i.layoutService.setAppbarLoader(!0),onLoadEnd:()=>i.layoutService.setAppbarLoader(!1)});o(()=>R.subscribe(L));const k=c(m);return a(h,{children:[a(s,{items:C,actions:E,onAction:e=>{"back-action"===e&&i.routerService.push("/"),"update-now"===e&&(i.explorerViewService.clear(),R.next())}}),a(p,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"calc(100vh - 150px)"},children:a(d,{pr:2,pl:2,children:g||!m?a(f,{children:a(u,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):a(S,{component:x,withExpandRoot:!0,maxItems:25,search:n.current,onSearchChanged:e=>l(e),sx:{background:e=>e.palette.background.default,minHeight:"calc(100vh - 160px)",p:1},formatSearch:e=>{const a=k.current.map[e];return a?`${a.label}`:""},formatKey:e=>{const t=k.current.map[e];return t?a(v,{direction:"row",alignItems:"center",gap:1,children:["directory"===t.type&&a(I,{sx:{color:"#1976d2",fontSize:20}}),a(u,{children:t?t.label:e}),a(d,{sx:{flex:1}})]}):null},EmptyItem:()=>a("span",{children:"No files"}),CustomItem:({itemKey:e,index:t,withDarkParent:r})=>{const o=k.current.map[e];return o?"file"!==o.type?null:a(y,{sx:{width:"100%",display:"flex",alignItems:"center",justifyContent:"stretch",direction:"row",background:t%2==0?"transparent":r?"#fff6":"#ccc6",gap:1,p:1,mt:0===t?1:0},onClick:()=>{return a=e,void i.layoutService.pickDumpContent(a);var a},children:[M(o),a(d,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",justifyContent:"stretch","& > *":{width:"100%",textAlign:"start"}},children:[a(u,{variant:"body2",children:o.label}),a(u,{variant:"caption",sx:{opacity:.5},children:o.mimeType})]}),a(d,{sx:{flex:1}}),a(b,{sx:{mr:2,pointerEvents:"none"},variant:"text",children:"Open"})]}):null},data:m.record,keyWidth:3,valueWidth:9})})}),a(w,{})]})},D=[{id:"search",element:T,isActive:e=>k(["/dump/:search"],e)},{id:"main",element:T,isActive:e=>k(["/dump"],e)}],W=({search:e=""})=>a(L,{history:i.routerService,onLoadStart:()=>i.layoutService.setAppbarLoader(!0),onLoadEnd:()=>i.layoutService.setAppbarLoader(!1),routes:D,params:{search:e}});export{W as DumpPage,W as default};
