import{b as e,f as a,r as t,bb as i,bc as o,Z as r,i as s,bd as n,be as c,bf as l,I as d,a5 as p,aY as h,bg as b,p as u,a9 as m,bh as f,K as y,T as g,a_ as x,af as v,V as w,bi as L,ag as S,bj as k,aU as A,A as j,$ as C,a0 as N,x as z,y as E,b3 as H,B as R,E as T,ab as V}from"./index-B3YL1iYZ.js";import{h as I}from"./hasRouteMatch-C1ixqcBH.js";import{B as M}from"./Background-nRt8nfzS.js";import{A as B}from"./Article-CVaSMs6N.js";import{C as D,R as K}from"./Refresh-Bg8tiYpa.js";import{K as F}from"./KeyboardArrowLeft-DjOOr9jL.js";const P=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"),W=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"),$="65px",O=e=>e.mimeType.startsWith("image/")?a(P,{sx:{color:"#f57c00",fontSize:20}}):"application/json"===e.mimeType?a(j,{sx:{color:"#7b1fa2",fontSize:20}}):e.mimeType.startsWith("text/")?a(B,{sx:{color:"#1976d2",fontSize:20}}):a(W,{sx:{color:"#546e7a",fontSize:20}}),U=u()(e=>({root:{position:"relative",height:"100%",width:"100%",background:"#eee",overflow:"clip"},header:{position:"absolute",top:0,left:0,width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"8px",paddingRight:"4px",height:$},input:{height:$,paddingRight:e.spacing(2),paddingLeft:e.spacing(1),width:"100%"},container:{position:"absolute",top:$,left:0,right:0,bottom:0,height:`calc(100% - ${$})`,width:"100%",background:"white",overflow:"clip",display:"flex",alignItems:"stretch",justifyContent:"stretch"},content:{display:"flex",flex:1},loader:{height:"100%",width:"100%"},accent:{background:m("#00c3ff",.05)}})),X=({outlinePaper:e,className:u,style:m,sx:j,nodes:C,initialSearch:N=""})=>{const{classes:z,cx:E}=U(),[H,R]=t.useState(N),T=i(H),[V,{flush:I}]=o(H,2500),[M,{loading:B}]=r(async()=>await(async(e,a)=>{const t=e.trim().toLowerCase(),i=[];let o=0;for(const r of s.explorerHelperService.deepFlat(a))if("file"!==r.type||t&&!r.path.toLowerCase().includes(t)||i.push(r),++o%1e4==0&&await f(0),i.length>25e3)break;return i})(V,C),{onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1),deps:[V,C]}),{execute:D}=n(async e=>{await s.layoutService.pickDumpContent(e)},{onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1)});return a(b,{outlinePaper:e,className:E(z.root,u),style:m,sx:j,children:[a("div",{className:z.header,children:a(c,{disabled:B,className:z.input,endAdornment:a(l,{position:"end",children:a(d,{disabled:B||!H,onClick:()=>{T.once(async()=>{await f(500),I()}),R("")},edge:"end",children:a(H?p:h,{})})}),placeholder:"Search",value:H,onBlur:()=>I(),onChange:({target:e})=>R(e.value),onKeyDown:({key:e,currentTarget:a})=>"Enter"===e&&a.blur()})}),a("div",{className:z.container,children:a("div",{className:z.content,children:M?M.length?a(A,{withScrollbar:!0,children:M.map((e,t)=>a(v,{className:E({[z.accent]:t%2==1}),component:w,onClick:()=>(async e=>{await D(e)})(e.id),children:[a(L,{children:O(e)}),a(S,{primary:e.label,secondary:e.path}),a(k,{content:e.path,label:"Copy path"})]},e.id))}):a(x,{sx:{height:"100%",width:"100%"},children:a(g,{variant:"h6",sx:{opacity:.5},children:"Not found"})}):a(y,{className:z.loader})})})]})},Y=[{type:E.Link,action:"back-action",label:a(F,{sx:{display:"block"}})},{type:E.Link,action:"back-action",label:"Main"},{type:E.Link,action:"back-action",label:"Dump Explorer"}],Z=[{action:"update-now",label:"Refresh",icon:()=>a(T,{icon:K,color:"#4caf50"})}],_=new N,q=({params:e})=>{const[t,{loading:i,execute:o}]=r(async()=>await s.explorerViewService.getFolderTree(),{onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1)});C(()=>_.subscribe(o));return a(D,{children:[a(z,{items:Y,actions:Z,onAction:e=>{"back-action"===e&&s.routerService.push("/"),"update-now"===e&&(s.explorerViewService.clear(),_.next())}}),a(H,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"calc(100vh - 150px)"},children:a(R,{pr:2,pl:2,children:i||!t?a(x,{children:a(g,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):a(X,{nodes:t,initialSearch:e.search})})}),a(M,{})]})},G=[{id:"search",element:q,isActive:e=>I(["/dump/:search"],e)},{id:"main",element:q,isActive:e=>I(["/dump"],e)}],J=({search:e=""})=>a(V,{history:s.routerService,onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1),routes:G,params:{search:e}});export{J as DumpPage,J as default};
