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AQ,GACzB,EAAI,KAAK,GAAG,EAAK,MAAM,MAAM,SAAoC,GAA1B,EAAK,MAAM,MAAM,MAAc,OAAO,WAC/D,GAAd,EAAI,QAAa,EAAI,KAAK,WAC9B,EAAK,MAAM,aAAe,EAAI,KAAK,SAEnC,EAAK,KAAO,UAAU,EAAK,MAAM,kCAE7B,EAAQ,CAER,EAAK,OAAS,CACV,KAAM,OAAO,MAAM,GAAG,aAAa,EAAO,SAAS,YACnD,KAAM,EAAO,SAGjB,MAAM,EAAO,EAAwB,EAAK,OAAO,MAC7C,IAAM,EAAK,KAAO,EAC1B,CACA,OAAO,GAAQ,CAClB","file":"/npm/cyberfiles-lite@2.4.10/main.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/cyberfiles-lite@2.4.10/main.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\nconst fs = require('fs');\nconst path = require('path');\nconst crypto = require('crypto');\nconst express = require('express');\nconst cookie = require('cookie');\nconst ejs = require('ejs');\nconst mime = require('mime');\nconst htmlParser = require('node-html-parser');\nconst dayjs = require('dayjs');\nconst archiver = require('archiver');\nconst sharp = require('sharp');\nconst ffmpegExtractFrame = require('ffmpeg-extract-frame');\nconst Prism = require('prismjs');\nconst loadLanguages = require('prismjs/components/');\nconst utils = require('web-resources');\nconst { marked } = require('marked');\nconst prismLangs = require(path.join(__dirname, `prism-lang-exts.json`));\nconst fileTypes = require(path.join(__dirname, `file-types.json`));\nloadLanguages();\n\nfunction iconFromExt(filePath) {\n    const ext = path.extname(filePath).substring(1).trim();\n    const mimeType = mime.getType(ext) || '';\n    if (filePath.toLowerCase().match(/readme.md$/))\n        return 'info';\n    if (ext.match(/^(txt|osu)$/gi))\n        return 'text_snippet';\n    if (ext.match(/^(md|markdown)$/))\n        return 'description';\n    if (prismLangs[ext])\n        return 'code';\n    if (mimeType.match(/^application\\/(zip|x-gzip|x-bzip2|x-tar|x-7z-compressed|x-rar-compressed)$/gi) || ext.match(/^(osk|osb)$/gi))\n        return 'folder_zip';\n    if (mimeType.match(/^application\\/pdf$/gi))\n        return 'picture_as_pdf';\n    if (mimeType.match(/^video\\/.*$/gi))\n        return 'movie';\n    if (mimeType.match(/^text\\/.*$/gi))\n        return 'text_snippet';\n    if (mimeType.match(/^audio\\/.*$/gi))\n        return 'headphones';\n    if (mimeType.match(/^image\\/.*$/gi))\n        return 'image';\n    if (mimeType.match(/^application\\/.*$/gi))\n        return 'widgets';\n    return 'draft';\n}\n\nfunction typeFromExt(filePath) {\n    const ext = path.extname(filePath).substring(1).toLowerCase();\n    if (ext)\n        return fileTypes[ext] || `${ext.toUpperCase()} File`;\n    else\n        return `File`;\n}\n\nconst themes = require('./themes.json');\n\nconst sortOrder = {\n    name: {\n        f: (a, b) => {\n            return a.name.localeCompare(b.name, undefined, {\n                numeric: true,\n                sensitivity: 'base'\n            });\n        },\n        display: 'Name'\n    },\n    mtime: {\n        f: (a, b) => {\n            return a.mtime-b.mtime\n        },\n        display: 'Date'\n    },\n    type: {\n        f: (a, b) => {\n            return a.ext.localeCompare(b.ext, undefined, {\n                numeric: true,\n                sensitivity: 'base'\n            });\n        },\n        display: 'Type'\n    },\n    size: {\n        f: (a, b) => {\n            return a.size-b.size\n        },\n        display: 'Size'\n    }\n};\n\n/**\n * @typedef CyberFilesLiteOptions\n * @type {object}\n * @property {string} [root] A directory path to serve as the root of your file index. \n * \n * Defaults to the directory of the parent module.\n * \n * Relative paths are relative to the directory of the parent module.\n * \n * @property {string} [data_dir] A separate directory where thumbnails should be stored to prevent them from being deleted when updating. A `thumbs` directory will be created inside this directory.\n * \n * Defaults to where `cyberfiles-lite` is installed.\n * \n * Relative paths are relative to `cyberfiles-lite`'s installation directory.\n * \n * @property {string} [site_name] The name of this file index, used in various places around the site.\n * \n * Defaults to `\"CyberFiles Lite\"`\n * \n * @property {string} [icon] A URL to use as the tab icon for the file index.\n * \n * Defaults to one of the built-in themed icons: `?asset=icons/icon-<theme>.svg`\n * \n * @property {string} [theme] A theme to use for the file index. This value must be the same as one of the keys in `themes.json`.\n * \n * Defaults to `\"darkmuted\"`\n * \n * @property {string[]} [index_files] An array of file names to checked for and sent when a directory is accessed. If one of these files exist in a directory, they'll be sent instead of the file index.\n * \n * Defaults to `[ \"index.html\" ]`\n * \n * @property {string[]} [hide_patterns] An array of RegEx strings to be checked against the absolute file/directory path of each request. If the pattern matches, the file/directory will be hidden from view.\n * \n * Defaults to `[ /\\/(\\.|_).*?(\\/|$)/ ]`, which will hide all files and directories whose paths contain a node/segment starting with `.` or `_`.\n * \n * When storing these options in JSON, be sure to escape backslashes when escaping other characters.\n * \n * @property {boolean} [handle_404] If `true`, CyberFiles Lite will handle requests for nonexistent paths (error 404s) and show the user an error page. If `false`, `next()` will be called, passing control to the next middleware.\n * \n * Defaults to `false`\n * \n * @property {boolean} [get_dir_sizes] If `true`, the index will recurse through directories to get and display their total sizes. This will impact performance with lots of files.\n * \n * Defaults to `false`\n * \n * @property {boolean} [make_thumbs] If `true`, thumbnails to show in the index will be generated for image and video files. `ffmpeg` needs to be installed for video thumbnail generation.\n * \n * Defaults to `false`\n * \n * @property {boolean} [auto_view] If this and `make_thumbs` are `true`, and if more than 50% (or the value of `auto_view_threshold`) of the files in a directory have thumbnails, the directory will automatically be switched to `tiles` view.\n * \n * Defaults to `true`\n * \n * @property {number} [auto_view_threshold] A float between 0 and 1, representing the percentage of files in a directory that need to have thumbnails for the directory to be switched to `tiles` view.\n * \n * Defaults to `0.5`\n * \n * @property {boolean} [show_path_subfolders] If `true`, you'll be able to view the subfolders of a directory when you right-click on it in the path bar. This might affect performance in large directories.\n * \n * Defaults to `true`\n * \n * @property {boolean} [debug] If `true`, debug messages will be logged to the console.\n * \n * Defaults to `false`\n */\n\n/**\n * Get a handler for CyberFiles Lite\n * @param {CyberFilesLiteOptions} opts Options for the file index\n */\nmodule.exports = (opts = {}) => {\n    const __dirnameParent = path.dirname(require.main.filename);\n    // Set default options\n    if (!opts.root) opts.root = __dirnameParent;\n    if (!path.isAbsolute(opts.root)) opts.root = path.join(__dirnameParent, opts.root);\n    opts.root = path.normalize(opts.root);\n    const defaultHidePatterns = [ /\\/(\\.|_).*?(\\/|$)/ ];\n    if (!opts.data_dir) opts.data_dir = __dirname;\n    if (!path.isAbsolute(opts.data_dir)) opts.data_dir = path.join(__dirname, opts.data_dir);\n    opts.data_dir = path.normalize(opts.data_dir);\n    if (!opts.hide_patterns) opts.hide_patterns = defaultHidePatterns;\n    else opts.hide_patterns.unshift(...defaultHidePatterns);\n    if (!opts.index_files) opts.index_files = [ 'index.html' ];\n    if (!opts.theme) opts.theme = 'darkmuted';\n    const theme = themes[opts.theme];\n    if (!theme) throw new Error(`[CyberFiles] Invalid theme! Make sure your provided theme matches one of the keys in themes.json.`);\n    if (!opts.icon) opts.icon = `?asset=icons/icon-${opts.theme}.svg`;\n    if (!opts.site_name) opts.site_name = `CyberFiles Lite`;\n    if (opts.handle_404 == undefined) opts.handle_404 = false;\n    if (opts.get_dir_sizes == undefined) opts.get_dir_sizes = false;\n    if (opts.make_thumbs == undefined) opts.make_thumbs = false;\n    if (opts.auto_view == undefined) opts.auto_view = true;\n    if (!opts.auto_view_threshold) opts.auto_view_threshold = 0.5;\n    if (opts.show_path_subfolders == undefined) opts.show_path_subfolders = true;\n    const logDebug = (...params) => {\n        if (opts.debug) console.log(`[CyberFiles]`, ...params);\n    }\n    logDebug(`Debug logs are enabled`);\n    logDebug(`Configuration:`, opts);\n    // Set variables\n    const sessions = {};\n    const thumbQueue = [];\n    const thumbHandlers = {};\n    const thumbsDir = path.join(opts.data_dir, 'thumbs');\n    const thumbMapFile = path.join(opts.data_dir, 'thumbs', `thumb-map-${crypto.createHash('md5').update(opts.root).digest('hex')}.json`);\n    logDebug(`Thumbs directory:`, thumbsDir);\n    logDebug(`Thumbs map file:`, thumbMapFile);\n    let thumbMap = {};\n    if (!fs.existsSync(thumbsDir)) fs.mkdirSync(thumbsDir);\n    if (fs.existsSync(thumbMapFile)) {\n        thumbMap = require(thumbMapFile);\n        logDebug(`Loaded`, Object.keys(thumbMap).length, `entries from thumb map`);\n    } else logDebug(`Starting a fresh thumb map`);\n    // Delete old or unused sessions\n    setInterval(() => {\n        const now = Date.now();\n        for (const id in sessions) {\n            const session = sessions[id];\n            if (now-session.lastRequestTime > 1000*60*15 && session.requestCount == 1) {\n                logDebug(`Deleting unused session`, id);\n                delete sessions[id];\n            }\n            if (now-session.lastRequestTime > 1000*60*60*24*2) {\n                logDebug(`Deleting old session`, id);\n                delete sessions[id];\n            }\n        }\n    }, 1000);\n    // Checks of a file path should be hidden\n    // As determined by opts.hide_patterns\n    const isPathHidden = filePath => {\n        for (const pattern of opts.hide_patterns) {\n            const regex = new RegExp(pattern);\n            if (filePath.match(regex)) {\n                return true;\n            }\n        }\n        // Deem the file path hidden if we don't have read access\n        try {\n            fs.accessSync(path.join(opts.root, filePath), fs.constants.R_OK);\n        } catch (error) {\n            console.error(error);\n            return true;\n        }\n        return false;\n    }\n    // Get the total size of a folder\n    const getFolderSize = basePathAbs => {\n        logDebug(`Getting total size of`, basePathAbs);\n        let totalSize = 0;\n        const recurse = (pathAbs) => {\n            const files = fs.readdirSync(pathAbs);\n            for (const name of files) {\n                const filePathAbs = path.join(pathAbs, name);\n                const filePathRel = path.join('/', filePathAbs.replace(opts.root, ''));\n                if (isPathHidden(filePathRel)) continue;\n                const stats = fs.statSync(filePathAbs);\n                if (stats.isDirectory()) {\n                    recurse(filePathAbs);\n                    continue;\n                }\n                totalSize += stats.size;\n            }\n        }\n        recurse(basePathAbs);\n        return totalSize;\n    }\n    // Get details about a file\n    const getFileObject = async(filePathAbs, filePathRel, folderSizes = opts.get_dir_sizes) => {\n        // If this file should be hidden, return false\n        let isHidden = isPathHidden(filePathRel);\n        if (isHidden) return false;\n        // Get file stats\n        const stats = fs.statSync(filePathAbs);\n        const ext = path.extname(filePathAbs).substring(1).toLowerCase();\n        const isDir = stats.isDirectory();\n        // Create file object\n        const file = {\n            name: path.basename(filePathAbs),\n            path: encodeURI(filePathRel),\n            isDir: stats.isDirectory(),\n            mtime: stats.mtimeMs,\n            icon: 'folder',\n            ext: ext,\n            type: 'Folder'\n        };\n        // Add more to file object if it's not a directory\n        if (!isDir) {\n            file.type = typeFromExt(filePathAbs);\n            file.size = stats.size;\n            file.sizeHuman = utils.formatSize(stats.size),\n            file.icon = iconFromExt(filePathAbs),\n            file.shouldRender = true;\n            file.hasThumb = false;\n            if (ext.match(/^(png|jpg|jpeg|gif|webp|mp4|mov|webm)$/) && opts.make_thumbs) {\n                file.hasThumb = true;\n                const mapEntry = thumbMap[filePathAbs];\n                if (!mapEntry || mapEntry.mtime !== file.mtime) {\n                    thumbQueuePaths.push(filePathAbs);\n                    thumbQueue.push({\n                        path: filePathAbs,\n                        mtime: file.mtime\n                    });\n                }\n            }\n        }\n        // Add things for only folders\n        if (isDir) {\n            if (folderSizes) {\n                const size = getFolderSize(filePathAbs);\n                file.size = size;\n                file.sizeHuman = utils.formatSize(file.size);\n            }\n        }\n        return file;\n    }\n    // Get the names of the subfolders of a folder\n    const getSubfolders = (folderPathAbs, folderPathRel) => {\n        if (!fs.existsSync(folderPathAbs) || isPathHidden(folderPathRel))\n            return [];\n        const sourceStats = fs.statSync(folderPathAbs);\n        if (!sourceStats.isDirectory()) return [];\n        const subfolders = fs.readdirSync(folderPathAbs).filter(name => {\n            const stats = fs.statSync(path.join(folderPathAbs, name));\n            return stats.isDirectory() && !isPathHidden(path.join(folderPathRel, name));\n        });\n        subfolders.sort((a, b) => a.localeCompare(b, undefined, {\n            numeric: true,\n            sensitivity: 'base'\n        }));\n        return subfolders;\n    }\n    // Extract starting text from Markdown HTML\n    const getTextFromMarkdownHTML = html => {\n        logDebug(`Extracting text from markdown file`);\n        const el = htmlParser.parse(html);\n        const children = el.querySelectorAll('h1, h2, h3, h4, h5, h6, p, li');\n        let isParagraphFound = false;\n        let content = [];\n        for (const child of children) {\n            let text = child.textContent.trim().replace(/\\n/g, ' ');\n            if (child.tagName.match(/(p|li)/gi) && text) {\n                isParagraphFound = true;\n                if (child.tagName == 'LI') text += ',';\n                content.push(text);\n            }\n            if (isParagraphFound && child.tagName !== 'P') break;\n        }\n        content = content.join(' ');\n        const words = content.split(' ').filter(String);\n        content = '';\n        for (const word of words) {\n            if (content.length > 250) {\n                content = `${content.trim()}...`\n                break;\n            }\n            content += `${word} `;\n        }\n        return content;\n    };\n    // Handle zipping directories\n    const handleZip = async(pathRel, req, res) => {\n        pathRel = path.join(pathRel, req.query.zip);\n        const pathAbs = path.join(opts.root, pathRel);\n        logDebug(`Scanning files of`, pathAbs, `for zip`);\n        if (!fs.existsSync(pathAbs) || isPathHidden(pathRel))\n            return res.end(`This directory doesn't exist.`);\n        if (!fs.statSync(pathAbs).isDirectory())\n            return res.end(`This isn't a directory.`);\n        const files = [];\n        const getFiles = folderPathRel => {\n            const folderPathAbs = path.join(opts.root, folderPathRel);\n            const fileList = fs.readdirSync(folderPathAbs);\n            for (const name of fileList) {\n                const filePathRel = path.join(folderPathRel, name);\n                if (isPathHidden(filePathRel)) continue;\n                const filePathAbs = path.join(folderPathAbs, name);\n                const stats = fs.statSync(filePathAbs);\n                if (stats.isDirectory()) {\n                    getFiles(path.join(folderPathRel, name));\n                    continue;\n                }\n                const file = {\n                    pathRel: filePathRel.replace(pathRel, ''),\n                    pathAbs: filePathAbs\n                };\n                files.push(file);\n            }\n        };\n        getFiles(pathRel);\n        const archive = archiver('zip');\n        res.setHeader('content-type', 'application/zip');\n        archive.pipe(res);\n        for (const file of files) {\n            logDebug(`Zipping`, file.pathRel);\n            archive.file(file.pathAbs, { name: file.pathRel });\n        }\n        await archive.finalize();\n    };\n    // Handle thumbnail generation\n    let thumbsInProgress = 0;\n    const thumbQueuePaths = [];\n    setInterval(async() => {\n        if (thumbsInProgress > 3 || thumbQueue.length == 0) return;\n        thumbsInProgress++;\n        try {\n            const entry = thumbQueue.shift();\n            const filePath = entry.path;\n            let tmpPath = '';\n            const thumbName = `${utils.randomHex()}.png`;\n            const thumbPath = path.join(thumbsDir, thumbName);\n            if ((mime.getType(filePath) || '').match(/^video\\/.*/)) {\n                logDebug(`Extracting video frame from`, filePath);\n                tmpPath = path.join(thumbsDir, `tmp-${utils.randomHex()}.png`);\n                await ffmpegExtractFrame({\n                    input: filePath,\n                    output: tmpPath,\n                    offset: 1000\n                });\n            }\n            logDebug(`Generating thumbnail for`, tmpPath || filePath);\n            const meta = await sharp(tmpPath || filePath).metadata();\n            if (!meta.width || !meta.height) return;\n            const isVertical = (meta.height > meta.width);\n            const resizeOpts = {};\n            (isVertical) ? resizeOpts.height = 128 : resizeOpts.width = 128;\n            await sharp(tmpPath || filePath).resize(resizeOpts).toFile(thumbPath);\n            if (tmpPath) fs.unlinkSync(tmpPath);\n            thumbMap[filePath] = { name: thumbName, mtime: entry.mtime };\n            fs.writeFileSync(thumbMapFile, JSON.stringify(thumbMap));\n            thumbQueuePaths.splice(thumbQueuePaths.indexOf(entry.path), 1);\n            if (thumbHandlers[filePath]) {\n                thumbHandlers[filePath](thumbPath);\n                delete thumbHandlers[filePath];\n            }\n        } catch (error) {\n            logDebug(`Error while generating thumbnail:`, error);\n        }\n        thumbsInProgress--;\n    }, 100);\n    // Handle thumbnail requests\n    const handleThumb = (pathRel, req, res) => {\n        const filePathRel = path.join(pathRel, req.query.thumb);\n        const filePathAbs = path.join(opts.root, filePathRel);\n        if (thumbMap[filePathAbs]) {\n            res.sendFile(path.join(thumbsDir, thumbMap[filePathAbs].name));\n        } else if (thumbQueuePaths.includes(filePathAbs)) {\n            res.setHeader('content-type', 'image/png');\n            thumbHandlers[filePathAbs] = image => {\n                res.sendFile(image);\n            };\n        } else {\n            res.status(404).end(`404 Not Found`);\n        }\n    };\n    /** @type {express.RequestHandler} */\n    return async(req, res, next) => {\n        if (req.method == 'HEAD') return res.json({ success: true });\n        const startTime = Date.now();\n        try {\n            decodeURI(req.path);\n        } catch (error) {\n            return res.status(400).end(`400 Bad Request`);\n        }\n        const pathRel = path.normalize(decodeURI(req.path));\n        const pathAbs = path.join(opts.root, pathRel);\n        // If this is a zip request, handle it\n        if (req.query.zip) return handleZip(pathRel, req, res);\n        // If this is a thumbnail request, handle it\n        if (req.query.thumb) return handleThumb(pathRel, req, res);\n        // Parse session cookie\n        const cookies = cookie.parse(req.headers.cookie || '');\n        let sessionId = '';\n        if (cookies['cyberfiles-session'])\n            sessionId = cookies['cyberfiles-session'];\n        if (!sessions[sessionId]) {\n            sessionId = utils.randomHex(32);\n            sessions[sessionId] = {\n                requestCount: 0,\n                dir: {}\n            };\n            logDebug(`Created new session`, sessionId);\n        }\n        const session = sessions[sessionId];\n        session.requestCount++;\n        session.lastRequestTime = Date.now();\n        // Set session cookie\n        res.setHeader('set-cookie', cookie.serialize('cyberfiles-session', sessionId, {\n            expires: 0,\n            path: '/'\n        }));\n        // For debugging, return session data as JSON if requested\n        if (req.query.session) return res.json(session);\n        // Redirect without query params\n        const redirect = () => {\n            res.redirect(pathRel);\n        };\n        // Update session if parameters are supplied\n        let isSessionChanged = false;\n        if (req.query.sort) {\n            const values = Object.keys(sortOrder);\n            if (values.includes(req.query.sort)) {\n                session.dir[pathRel] = session.dir[pathRel] || {};\n                session.dir[pathRel].order = req.query.sort;\n                isSessionChanged = true;\n                logDebug(`Session`, sessionId, `set sort order to`, req.query.sort, `in`, pathRel);\n            }\n        }\n        if (req.query.direction) {\n            const values = [ 'asc', 'desc' ];\n            if (values.includes(req.query.direction)) {\n                session.dir[pathRel] = session.dir[pathRel] || {};\n                session.dir[pathRel].direction = req.query.direction;\n                isSessionChanged = true;\n                logDebug(`Session`, sessionId, `set sort direction to`, req.query.direction, `in`, pathRel);\n            }\n        }\n        if (req.query.view) {\n            const values = [ 'list', 'tiles' ];\n            if (values.includes(req.query.view)) {\n                session.dir[pathRel] = session.dir[pathRel] || {};\n                session.dir[pathRel].view = req.query.view;\n                isSessionChanged = true;\n                logDebug(`Session`, sessionId, `set view to`, req.query.view, `in`, pathRel);\n            }\n        }\n        if (isSessionChanged) return redirect();\n        const sessionDir = session.dir[pathRel] || {};\n        // Build data object\n        let data = {\n            site_name: opts.site_name,\n            site_name_meta: opts.site_name,\n            icon: opts.icon,\n            theme: opts.theme,\n            themes: themes,\n            theme_color: themes[opts.theme].themeColor,\n            dirName: pathRel.split('/').filter(String).reverse()[0] || 'Root',\n            files: null,\n            file: null,\n            readme: null,\n            previewType: null,\n            error: null,\n        };\n        // Handle rendering\n        const render = async() => {\n            res.setHeader('content-type', 'text/html');\n            res.end(await ejs.renderFile(path.join(__dirname, 'assets/index.ejs'), data));\n        }\n        // Handle 404s\n        const send404 = () => {\n            if (!opts.handle_404)\n                return next();\n            data.error = 404;\n            data.desc = `This file or directory doesn't exist!`;\n            data.dirName = 'Error 404';\n            res.status(404);\n            return render();\n        };\n        // If this is an asset request, handle it\n        if (req.query.asset) {\n            const filePathRel = path.normalize(req.query.asset);\n            const filePath = path.join(__dirname, 'assets', filePathRel);\n            if (!fs.existsSync(filePath)) return res.status(404).end();\n            return res.sendFile(filePath);\n        }\n        // Build file path tree\n        const tree = [{\n            name: opts.site_name,\n            path: '/',\n            dirs: opts.show_path_subfolders ? getSubfolders(opts.root, '/') : []\n        }];\n        const parts = pathRel.split('/').filter(String);\n        for (const part of parts) {\n            const partPath = path.join(tree[tree.length-1].path, part);\n            const partPathAbs = path.join(opts.root, partPath);\n            const item = {\n                name: part,\n                path: partPath,\n                dirs: opts.show_path_subfolders ? getSubfolders(partPathAbs, partPath) : []\n            };\n            tree.push(item);\n        }\n        tree[tree.length-1].path = '';\n        data.tree = tree;\n        // If this path is hidden, return 404\n        if (isPathHidden(pathRel)) return send404();\n        // If the path doesn't exist, return 404\n        if (!fs.existsSync(pathAbs)) return send404();\n        // Save if the file is a directory\n        const targetStats = fs.statSync(pathAbs);\n        const isDir = targetStats.isDirectory();\n        // If we aren't at the root, change meta site name\n        if (tree.length > 2 && opts.site_name.length < 64) {\n            let tmp = [...parts];\n            tmp.pop();\n            const getSiteName = () => `${opts.site_name} > ${tmp.join(' > ')}`;\n            while (getSiteName() > 64) tmp.shift();\n            data.site_name_meta = getSiteName();\n        }\n        // If the file isn't a directory...\n        if (!isDir) {\n            // If we aren't rendering, send the file\n            if (!req.query.render) {\n                logDebug(`Handling raw request for`, pathAbs);\n                return res.sendFile(pathAbs);\n            }\n            // Get file details\n            logDebug(`Getting file details for`, pathAbs);\n            const file = await getFileObject(pathAbs, pathRel);\n            // Get file list\n            const dirAbs = path.dirname(pathAbs);\n            const dirRel = path.dirname(pathRel);\n            logDebug(`Scanning directory`, dirAbs);\n            const fileList = fs.readdirSync(dirAbs);\n            const files = [];\n            for (const name of fileList) {\n                const filePathAbs = path.join(dirAbs, name);\n                const filePathRel = path.join(dirRel, name);\n                const file = await getFileObject(filePathAbs, filePathRel, false);\n                if (file && !file.isDir) files.push(file);\n            }\n            const sessionDir = session.dir[dirRel] || {};\n            files.sort(sortOrder[sessionDir.order || 'name'].f);\n            if (sessionDir.direction == 'desc') files.reverse();\n            // Get current file index\n            let currentFileIndex = 0;\n            let i = 0;\n            for (const entry of files) {\n                if (entry.name == file.name) {\n                    currentFileIndex = i;\n                    break;\n                }\n                i++;\n            }\n            // Set render data\n            data.file = file;\n            data.filePrev = files[currentFileIndex-1] || files[files.length-1];\n            data.fileNext = files[currentFileIndex+1] || files[0];\n            data.currentFileIndex = currentFileIndex+1;\n            data.fileCount = files.length;\n            data.desc = [\n                `Type: ${file.type}`,\n                `Modified: ${dayjs(file.mtime).format(`MMM D, YYYY`)}`,\n                `Size: ${file.sizeHuman}`\n            ].join('\\n');\n            data.path = encodeURI(pathRel);\n            // Markdown files\n            if (file.ext.match(/^(md|markdown)$/)) {\n                data.previewType = 'markdown';\n                data.html = marked.parse(fs.readFileSync(pathAbs).toString());\n                data.desc = getTextFromMarkdownHTML(data.html)\n                return render();\n            // Images\n            } else if (file.ext.match(/^(png|jpg|jpeg|gif|webp|svg|apng|avif)$/)) {\n                data.previewType = 'image';\n                return render();\n            // Videos\n            } else if (file.ext.match(/^(mp4|webm|mov|mpg|wmv)$/)) {\n                data.previewType = 'video';\n                return render();\n            // Audio files\n            } else if (file.ext.match(/^(mp3|weba|ogg|m4a)$/)) {\n                data.previewType = 'audio';\n                return render();\n            // Text files\n            } else if (prismLangs[file.ext] && file.size < (1024*512)) {\n                data.previewType = 'text';\n                data.language = prismLangs[file.ext];\n                const contents = fs.readFileSync(pathAbs).toString();\n                try {\n                    data.text = Prism.highlight(contents, Prism.languages[data.language], data.language).trim();\n                } catch (error) {\n                    console.error(`Error syntax highlighting ${pathAbs}:`, error);\n                    data.text = utils.escapeHTML(contents.trim());\n                }\n                return render();\n            // Everything else\n            } else {\n                data.previewType = 'default';\n                return render();\n            }\n        }\n        // Send index file if it exists\n        const fileList = fs.readdirSync(pathAbs);\n        for (const name of opts.index_files) {\n            if (fileList.includes(name)) {\n                logDebug(`Sending index file`, pathAbs);\n                return res.sendFile(path.join(pathAbs, name));\n            }\n        }\n        // Get and iterate through directory contents\n        logDebug(`Scanning directory`, pathAbs);\n        let totalSize = 0;\n        let readme = false;\n        const filesWorking = { files: [], dirs: [] };\n        for (const name of fileList) {\n            // Get paths\n            const filePathAbs = path.join(pathAbs, name);\n            const filePathRel = path.join(pathRel, name);\n            // Get file details\n            const file = await getFileObject(filePathAbs, filePathRel);\n            if (!file) continue;\n            if (parseInt(file.size))\n                totalSize += file.size;\n            // Add file to list\n            filesWorking[(file.isDir) ? 'dirs':'files'].push(file);\n            // If this is a readme file, save it\n            if (name.toLowerCase().match('readme.md'))\n                readme = { pathAbs: filePathAbs, pathRel: filePathRel };\n        }\n        // Sort directories and files\n        logDebug(`Sorting files`);\n        const sort = sessionDir.order || 'name';\n        const isDescending = (sessionDir.direction == 'desc') ? true : false;\n        filesWorking.dirs.sort(sortOrder[sort].f);\n        filesWorking.files.sort(sortOrder[sort].f);\n        if (isDescending) {\n            filesWorking.dirs.reverse();\n            filesWorking.files.reverse();\n        }\n        data.sort = {\n            order: sortOrder[sort],\n            descending: isDescending\n        };\n        // Set view\n        const isViewSetByUser = (sessionDir.view) ? true : false;\n        data.view = sessionDir.view || 'list';\n        // If the view isn't manually set\n        if (opts.auto_view && !isViewSetByUser) {\n            // Count the number of files with thumbnails\n            let countFilesWithThumbs = 0;\n            for (const file of filesWorking.files) {\n                if (file.hasThumb) countFilesWithThumbs++;\n            }\n            // If more than 50% of the files have thumbs, set view to tiles\n            if ((countFilesWithThumbs/filesWorking.files.length) > opts.auto_view_threshold) {\n                logDebug(countFilesWithThumbs, 'of', filesWorking.files.length, `have thumbs, using tiles view`);\n                data.view = 'tiles';\n            }\n        }\n        // Combine files and directories\n        const files = [ ...filesWorking.dirs, ...filesWorking.files ];\n        // Add \"up\" entry if we aren't at the root\n        if (tree.length > 1) {\n            files.unshift({\n                name: `Up to ${tree[tree.length-2].name}...`,\n                isDir: true,\n                path: tree[tree.length-2].path,\n                icon: 'arrow_upward'\n            });\n        }\n        // Set files object\n        data.files = files;\n        // Compile stats\n        data.stats = {\n            count: { files: filesWorking.files.length, dirs: filesWorking.dirs.length },\n            totalSize: totalSize,\n            totalSizeHuman: utils.formatSize(totalSize),\n            totalSizeIncludesSubdirs: opts.get_dir_sizes,\n            mtime: targetStats.mtimeMs,\n            duration: Math.round(Date.now()-startTime)\n        };\n        // Count files and dirs and make a human-readable string\n        let tmp = [];\n        if (data.stats.count.dirs > 0)\n            tmp.push(`${data.stats.count.dirs} ${(data.stats.count.dirs == 1) ? 'folder':'folders'}`);\n        if (data.stats.count.files > 0)\n            tmp.push(`${data.stats.count.files} ${(data.stats.count.files == 1) ? 'file':'files'}`);\n        if (tmp.length == 0) tmp.push(`0 files`);\n        data.stats.count_string = tmp.join(' and ');\n        // Set meta description\n        data.desc = `Browse ${data.stats.count_string} in this directory.`;\n        // If a readme file exists\n        if (readme) {\n            // Parse readme\n            data.readme = {\n                html: marked.parse(fs.readFileSync(readme.pathAbs).toString()),\n                path: readme.pathRel\n            };\n            // Change meta description to readme contents\n            const text = getTextFromMarkdownHTML(data.readme.html);\n            if (text) data.desc = text;\n        }\n        return render();\n    };\n};"]}