import{A as e,I as t,M as n,N as r,P as i,a,j as o,t as s}from"./jsx-runtime-BciRPUQx.js";import{t as c}from"./styling-C_P8q9X5.js";import{t as l}from"./loading-B5ND0RTV.js";import{a as u,n as d}from"./item-menu-Cfh9B9In.js";var f=t(i(),1),p={container:`_container_137fq_1`,home:`_home_137fq_11`,"home-icon":`_home-icon_137fq_17`,separator:`_separator_137fq_28`,directory:`_directory_137fq_38`},m=s();function h({parentDirectories:e}){let t=o(),n=(0,f.useCallback)(n=>{if(n===-1)return t(`/explore`);t(`/explore/${e.slice(0,n+1).join(`/`)}`)},[e,t]);return(0,m.jsxs)(`div`,{className:p.container,children:[(0,m.jsxs)(`div`,{...c([p.home,p.directory]),onClick:()=>n(-1),children:[(0,m.jsx)(`div`,{className:p[`home-icon`]}),e.length==0&&(0,m.jsx)(`div`,{children:`home`})]}),e.map((e,t)=>(0,m.jsxs)(f.Fragment,{children:[(0,m.jsx)(`div`,{className:p.separator}),(0,m.jsx)(`div`,{className:p.directory,onClick:()=>n(t),children:e})]},t))]})}var g={container:`_container_1ipbz_1`,item:`_item_1ipbz_12`,"item-content":`_item-content_1ipbz_44`,"item-menu":`_item-menu_1ipbz_65`,"item-info":`_item-info_1ipbz_71`,"item-name":`_item-name_1ipbz_79`,"item-size":`_item-size_1ipbz_84`,loading:`_loading_1ipbz_90`,hidden:`_hidden_1ipbz_97`,"open-item-menu":`_open-item-menu_1ipbz_119`,"directory-icon":`_directory-icon_1ipbz_135`,"file-icon":`_file-icon_1ipbz_145`,"video-icon":`_video-icon_1ipbz_155`,"image-icon":`_image-icon_1ipbz_165`},_=r(function({loaderData:e}){return(0,m.jsx)(v,{...e})});function v(t){let r=e(),i=n(),o=!!i.location,s=t.items,c=o?w(S(i.location.pathname)):t.parentDirectories,p=(0,f.useCallback)(e=>`${r.pathname}/${encodeURIComponent(e)}`,[r.pathname]),_=(0,f.useCallback)(e=>{let t=C(x(r.pathname),encodeURIComponent(e.name)),n=y(e.name),i=n?`&extension=${n}`:``;return`/view/${t}?downloadKey=${e.downloadKey}${i}`},[r.pathname]);return(0,m.jsxs)(`div`,{className:g.container,children:[(0,m.jsx)(h,{parentDirectories:c}),!o&&(0,m.jsxs)(`div`,{children:[s.filter(e=>e.isDirectory).map((e,t)=>(0,m.jsx)(`div`,{className:T(e),children:(0,m.jsx)(a,{to:p(e.name),children:(0,m.jsxs)(`div`,{className:g[`item-content`],children:[(0,m.jsx)(`div`,{className:g[`directory-icon`]}),(0,m.jsx)(`div`,{className:g[`item-name`],children:e.name})]})})},`${t}_dir_item`)),s.filter(e=>!e.isDirectory).map((e,t)=>(0,m.jsxs)(`div`,{className:T(e),children:[(0,m.jsxs)(`a`,{href:_(e),className:g[`item-content`],children:[(0,m.jsx)(`div`,{className:b(e)}),(0,m.jsxs)(`div`,{className:g[`item-info`],children:[(0,m.jsx)(`div`,{className:g[`item-name`],children:e.name}),(0,m.jsx)(`div`,{className:g[`item-size`],children:u(e.size)})]})]}),(0,m.jsx)(d,{className:g[`item-menu`],openClassName:g[`open-item-menu`],exploreFile:e,previewPath:_(e)})]},`${t}_file_item`))]}),o&&(0,m.jsx)(l,{className:g.loading})]})}function y(e){let t=e.lastIndexOf(`.`);if(!(t===-1||t===0))return e.slice(t)}function b(e){return e.name.toLowerCase().endsWith(`.mkv`)||e.mimeType===`application/mp4`||e.mimeType&&e.mimeType.startsWith(`video`)?g[`video-icon`]:e.mimeType&&e.mimeType.startsWith(`image`)?g[`image-icon`]:g[`file-icon`]}function x(e){return e.startsWith(`/`)&&(e=e.slice(1)),e.startsWith(`explore`)&&(e=e.slice(7)),e.startsWith(`/`)&&(e=e.slice(1)),e}function S(e){return decodeURIComponent(x(e))}function C(e,t){return e===``?t:`${e}/${t}`}function w(e){return e==``?[]:e.split(`/`)}function T(e){let t=g.item;return e.name.startsWith(`.`)&&(t+=` `+g.hidden),t}export{_ as default};