import{b as e,f as a,r as t,ba as i,bb as o,X as r,i as s,bc as n,bd as c,be as l,I as d,az as p,aU as h,bf as b,p as u,a5 as m,bg as f,G as y,T as g,aW as v,aa as x,Q as w,bh as L,ab as S,bi as k,aQ as A,y as j,Y as z,Z as C,v as N,w as E,b0 as H,B as R,z as T,a6 as I}from"./index-BoVUr2mk.js";import{h as M}from"./hasRouteMatch-DaOdXEtJ.js";import{B as V}from"./Background-D7AbUVrH.js";import{A as B}from"./Article-CSLbW4S3.js";import{C as D,R as F}from"./Refresh-GywkMeC9.js";import{K}from"./KeyboardArrowLeft-BC2GbqOB.js";const W=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"),P=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"),Q="65px",X=e=>e.mimeType.startsWith("image/")?a(W,{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(P,{sx:{color:"#546e7a",fontSize:20}}),G=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:Q},input:{height:Q,paddingRight:e.spacing(2),paddingLeft:e.spacing(1),width:"100%"},container:{position:"absolute",top:Q,left:0,right:0,bottom:0,height:`calc(100% - ${Q})`,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)}})),O=({outlinePaper:e,className:u,style:m,sx:j,nodes:z,initialSearch:C=""})=>{const{classes:N,cx:E}=G(),[H,R]=t.useState(C),T=i(H),[I,{flush:M}]=o(H,2500),[V,{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})(I,z),{onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1),deps:[I,z]}),{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(N.root,u),style:m,sx:j,children:[a("div",{className:N.header,children:a(c,{disabled:B,className:N.input,endAdornment:a(l,{position:"end",children:a(d,{disabled:B||!H,onClick:()=>{T.once(async()=>{await f(500),M()}),R("")},edge:"end",children:a(H?p:h,{})})}),placeholder:"Search",value:H,onBlur:()=>M(),onChange:({target:e})=>R(e.value),onKeyDown:({key:e,currentTarget:a})=>"Enter"===e&&a.blur()})}),a("div",{className:N.container,children:a("div",{className:N.content,children:V?V.length?a(A,{withScrollbar:!0,children:V.map((e,t)=>a(x,{className:E({[N.accent]:t%2==1}),component:w,onClick:()=>(async e=>{await D(e)})(e.id),children:[a(L,{children:X(e)}),a(S,{primary:e.label,secondary:e.path}),a(k,{content:e.path,label:"Copy path"})]},e.id))}):a(v,{sx:{height:"100%",width:"100%"},children:a(g,{variant:"h6",sx:{opacity:.5},children:"Not found"})}):a(y,{className:N.loader})})})]})},U=[{type:E.Link,action:"back-action",label:a(K,{sx:{display:"block"}})},{type:E.Link,action:"back-action",label:"Main"},{type:E.Link,action:"back-action",label:"Dump Explorer"}],Y=[{action:"update-now",label:"Refresh",icon:()=>a(T,{icon:F,color:"#4caf50"})}],Z=new C,$=({params:e})=>{const[t,{loading:i,execute:o}]=r(async()=>await s.explorerViewService.getFolderTree(),{onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1)});z(()=>Z.subscribe(o));return a(D,{children:[a(N,{items:U,actions:Y,onAction:e=>{"back-action"===e&&s.routerService.push("/"),"update-now"===e&&(s.explorerViewService.clear(),Z.next())}}),a(H,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"calc(100vh - 150px)"},children:a(R,{pr:2,pl:2,children:i||!t?a(v,{children:a(g,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):a(O,{nodes:t,initialSearch:e.search})})}),a(V,{})]})},q=[{id:"search",element:$,isActive:e=>M(["/dump/:search"],e)},{id:"main",element:$,isActive:e=>M(["/dump"],e)}],J=({search:e=""})=>a(I,{history:s.routerService,onLoadStart:()=>s.layoutService.setAppbarLoader(!0),onLoadEnd:()=>s.layoutService.setAppbarLoader(!1),routes:q,params:{search:e}});export{J as DumpPage,J as default};
