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B,GAAiB,iBAAN,EAAgB,MAAM,IAAI,MAAM,0BAC3C,MAAM,EAAI,EAAI,EAAI,KAAK,SAAS,GAC1B,EAAI,KAAK,KAAK,KAAK,KAAK,IAAK,GACnC,IAEI,MAAO,CAAC,QADQ,KAAK,GAAG,QAAQ,EAAG,CAAE,eAAe,IAExD,CAAE,MAAO,GACL,MAAkB,WAAX,EAAE,KAAoB,CAAC,KAAM,MAAQ,QAAQ,OAAO,EAC/D,CACJ,CAEA,YAAM,CAAO,GACT,IAAK,KAAK,EAAG,MAAM,IAAI,MAAM,sBAC7B,GAAiB,iBAAN,EAAgB,MAAM,IAAI,MAAM,0BAC3C,IAAI,EAAI,KAAK,IAAK,EAAI,EAAG,EAAI,GAAI,EAAI,KACrC,IAAK,MAAM,KAAK,EAAG,CAIf,GAFA,GADkB,MAAT,EAAE,GAAa,IAAM,EAAE,GAEhC,IACI,IAAM,KAAK,EAAG,CACV,SAAS,KAAO,EAAE,OAAS,IAAG,EAAI,IAAM,GAC5C,EAAI,KAAK,KAAK,KAAK,EAAG,UACN,KAAK,GAAG,QAAQ,EAAG,CAAE,eAAe,KAClC,QAAO,GAAK,EAAE,gBAAe,OACjC,EAAG,EAAI,KACX,IAAG,EAAI,GACjB,EAAI,EACJ,EAAI,EACR,CACJ,CACI,IAAM,IAAG,EAAI,KAAK,KAAK,KAAK,EAAG,IAC/B,SAAS,KAAK,GAAG,GAAG,EAAG,CAAE,WAAW,GAC5C,EAGJ,OAAO,QAAU,CAAE","file":"/npm/trie-fs@2.1.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/trie-fs@2.1.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","class Trie {\r\n    constructor(c) {\r\n        this.fs = require(\"fs\").promises;\r\n        this.path = require(\"path\");\r\n        this.s = false;\r\n        this.g = 1;\r\n    }\r\n\r\n    async init(d, g) {\r\n        if (typeof d !== \"string\") throw new Error(\"Directory must be a string.\");\r\n        try {\r\n            this.dir = this.path.join(process.cwd(), d);\r\n            await this.fs.mkdir(this.dir);\r\n        } catch (e) {\r\n            if (e.code !== \"EEXIST\") throw new Error(\"Invalid directory.\");\r\n        }\r\n        if (typeof g === \"number\") this.g = g > 0 ? parseInt(g) : 1;\r\n        this.s = true;\r\n    }\r\n\r\n    makePath(s) {\r\n        if (!this.s) throw new Error(\"Call init() first.\");\r\n        if (typeof s !== \"string\") throw new Error(\"Path must be a string.\");\r\n        let c = 0, t = \"\", d = \"\";\r\n        for (const p in s) {\r\n            let ch = s[p] === \" \" ? \"-\" : s[p];\r\n            t += ch;\r\n            c++;\r\n            if (c === this.g) {\r\n                if (parseInt(p) !== s.length - 1) d += \"-\";\r\n                d += t + \"/\";\r\n                c = 0;\r\n                t = \"\";\r\n            }\r\n        }\r\n        d += t;\r\n        return d;\r\n    }\r\n\r\n    async add(s, r) {\r\n        if (!this.s) throw new Error(\"Call init() first.\");\r\n        if (typeof s !== \"string\") throw new Error(\"Path must be a string.\");\r\n        const d = r ? s : this.makePath(s);\r\n        const f = this.path.join(this.dir, d);\r\n        await this.fs.mkdir(f, { recursive: true });\r\n        return f;\r\n    }\r\n\r\n    async search(s, r) {\r\n        if (!this.s) throw new Error(\"Call init() first.\");\r\n        if (typeof s !== \"string\") throw new Error(\"Path must be a string.\");\r\n        const d = r ? s : this.makePath(s);\r\n        const f = this.path.join(this.dir, d);\r\n        try {\r\n            const i = await this.fs.readdir(f, { withFileTypes: true });\r\n            return [f, i];\r\n        } catch (e) {\r\n            return e.code === \"ENOENT\" ? [null, null] : Promise.reject(e);\r\n        }\r\n    }\r\n\r\n    async delete(s) {\r\n        if (!this.s) throw new Error(\"Call init() first.\");\r\n        if (typeof s !== \"string\") throw new Error(\"Path must be a string.\");\r\n        let p = this.dir, c = 0, t = \"\", d = null;\r\n        for (const l in s) {\r\n            let ch = s[l] === \" \" ? \"-\" : s[l];\r\n            t += ch;\r\n            c++;\r\n            if (c === this.g) {\r\n                if (parseInt(l) !== s.length - 1) t = \"-\" + t;\r\n                p = this.path.join(p, t);\r\n                const e = await this.fs.readdir(p, { withFileTypes: true });\r\n                const subdirs = e.filter(f => f.isDirectory()).length;\r\n                if (subdirs > 1) d = null;\r\n                else if (!d) d = p;\r\n                c = 0;\r\n                t = \"\";\r\n            }\r\n        }\r\n        if (t && !d) d = this.path.join(p, t);\r\n        if (d) await this.fs.rm(d, { recursive: true });\r\n    }\r\n}\r\n\r\nmodule.exports = { Trie };"]}