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AAiB,KAAK,cAAc,SACP,KAAK,QAAQ,GAG1C,EAAQ,KAAO,kBACf,IAAI,QAAkB,KAAK,eAC3B,QAAkB,KAAK,cAAc,GACrC,EAAQ,KAAO,uBACa,KAAK,YAAY,SAGvC,KAAK,eAGP,KAAK,OAAO,OAAkC,OAAzB,KAAK,OAAO,WACjC,EAAQ,KAAO,oBACT,KAAK,oBAIX,KAAK,OAAO,SACZ,EAAQ,KAAO,sBACT,KAAK,kBAIf,EAAQ,KAAO,uBACT,KAAK,aAGX,EAAQ,KAAO,mBACT,KAAK,UAEX,EAAQ,QAAQ,cAChB,QAAQ,KAAK,EACjB,CAAE,MAAO,GACL,QAAQ,IAAI,GACZ,EAAQ,KAAK,GACb,QAAQ,IAAI,MACZ,QAAQ,KAAK,EACjB,CACJ,EAEJ,IAAI","file":"/npm/cssmonster@0.7.3/cssmonster.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/cssmonster@0.7.3/cssmonster.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#!/usr/bin/env node\n\nimport fs from \"fs\";\nimport path from \"path\";\nimport glob from \"glob\";\nimport semver from \"semver\";\nimport * as sass from \"sass\";\nimport yargs from \"yargs\";\nimport { minify } from \"minify\";\nimport ora from \"ora\";\nimport PurgeCSS from \"purgecss\";\nimport { fileURLToPath } from 'url';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst cwd = process.cwd();\n\n/** Verify Nodejs version */\nconst packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, \"package.json\"), \"utf8\"));\nconst version = packageJson.engines.node;\nif (!semver.satisfies(process.version, version)) {\n    const rawVersion = version.replace(/[^\\d\\.]*/, \"\");\n    console.log(`CSSMonster requires at least Node v${rawVersion} and you're using Node ${process.version}`);\n    process.exit(1);\n}\n\n/** Get config file path */\nconst configFile = yargs.c || yargs.config;\nlet configPath;\nif (configFile) {\n    configPath = path.resolve(cwd, configFile);\n    if (!fs.existsSync(configPath)) {\n        console.log(`Missing config file. Did you move the file without updating the --config flag?`);\n        process.exit(1);\n    }\n} else {\n    configPath = path.join(cwd, \"cssmonster.json\");\n    if (!fs.existsSync(configPath)) {\n        configPath = path.join(cwd, \"cssmonster.config.json\");\n        if (!fs.existsSync(configPath)) {\n            configPath = null;\n        }\n    }\n}\n\nlet config = fs.readFileSync(configPath, \"utf8\") || null;\nif (config !== null) {\n    try{\n        config = JSON.parse(config);\n    } catch (e) {\n        console.log(`Error parsing config file: ${e}`);\n        process.exit(1);\n    }\n}\nlet mode = yargs.e || yargs.env || \"production\";\n\n/** Output CSS */\nclass CSSMonster {\n    constructor() {\n        this.tempDir = path.join(__dirname, \"temp\");\n        this.config = {\n            env: mode,\n            outDir: path.resolve(cwd, \"cssmonster\"),\n            sources: [path.resolve(cwd, \"src\")],\n            minify: true,\n            purge: false,\n            purgeCSS: null,\n            blacklist: [],\n            include: [],\n            autoresolve: false,\n        };\n        this.run();\n    }\n\n    async reset() {\n        if (fs.existsSync(this.tempDir)) {\n            await fs.promises.rm(this.tempDir, { recursive: true });\n        }\n        await fs.promises.mkdir(this.tempDir);\n    }\n\n    handleConfig() {\n        return new Promise((resolve, reject) => {\n            if (!config) {\n                resolve();\n            }\n            /** Update outDir */\n            if (typeof config.outDir !== \"undefined\") {\n                if (typeof config.outDir === \"string\") {\n                    this.config.outDir = path.resolve(cwd, config.outDir);\n                } else {\n                    reject(\"Incorrect configuration: outDir must be a string.\");\n                }\n            }\n\n            /** Update sources array */\n            if (typeof config.sources !== \"undefined\") {\n                if (typeof config.sources === \"string\") {\n                    this.config.sources = [path.resolve(cwd, config.sources)];\n                } else if (Array.isArray(config.sources)) {\n                    this.config.sources = [];\n                    for (let i = 0; i < config.sources.length; i++) {\n                        const srcPath = path.resolve(cwd, config.sources[i]);\n                        this.config.sources.push(srcPath);\n                    }\n                } else {\n                    reject(\"Incorrect configuration: sources must be a string or an array of strings.\");\n                }\n            }\n\n            /** Override CLI env value */\n            if (typeof config.env !== \"undefined\") {\n                if (typeof config.env === \"string\") {\n                    if (config.env !== \"production\" || config.env !== \"development\" || config.env !== \"dev\") {\n                        this.config.env = config.env;\n                    } else {\n                        reject(`Incorrect configuration: env must be 'production' or 'development' or 'dev'.`);\n                    }\n                } else {\n                    reject(\"Incorrect configuration: env must be a boolean.\");\n                }\n            }\n\n            /** Set purgeCSS options */\n            if (typeof config.purgeCSS !== \"undefined\") {\n                if (typeof config.purgeCSS === \"object\") {\n                    this.config.purgeCSS = config.purgeCSS;\n                } else {\n                    reject(\"Incorrect configuration: purgeCSS must be a purgeCSS config object. See https://www.purgecss.com/configuration#options for additional information.\");\n                }\n            }\n\n            /** Update sources array */\n            if (typeof config.blacklist !== \"undefined\") {\n                if (typeof config.blacklist === \"string\") {\n                    this.config.blacklist = [path.resolve(cwd, config.blacklist)];\n                } else if (Array.isArray(config.blacklist)) {\n                    this.config.blacklist = [];\n                    for (let i = 0; i < config.blacklist.length; i++) {\n                        const filePath = path.resolve(cwd, config.blacklist[i]);\n                        this.config.blacklist.push(filePath);\n                    }\n                } else {\n                    reject(\"Incorrect configuration: blacklist must be a string or an array of strings.\");\n                }\n            }\n\n            /** Purge */\n            if (typeof config.purge !== \"undefined\") {\n                if (typeof config.purge === \"boolean\") {\n                    this.config.purge = config.purge;\n                } else {\n                    reject(\"Incorrect configuration: purge must be a boolean.\");\n                }\n            }\n\n            /** Minify */\n            if (typeof config.minify !== \"undefined\") {\n                if (typeof config.minify === \"boolean\") {\n                    this.config.minify = config.minify;\n                } else {\n                    reject(\"Incorrect configuration: minify must be a boolean.\");\n                }\n            }\n\n            /** Set values based on env */\n            if (this.config.env === \"dev\" || this.config.env === \"development\") {\n                this.config.minify = false;\n                this.config.purge = false;\n            }\n\n            /** Included paths */\n            if (typeof this.config.include !== \"undefined\") {\n                if (typeof config.include === \"string\") {\n                    this.config.include = [path.resolve(cwd, config.include)];\n                } else if (Array.isArray(config.include)) {\n                    this.config.include = [];\n                    for (let i = 0; i < config.include.length; i++) {\n                        const filePath = path.resolve(cwd, config.include[i]);\n                        this.config.include.push(filePath);\n                    }\n                }\n            }\n\n            /** autoresolve */\n            if (typeof config.autoresolve !== \"undefined\") {\n                if (typeof config.autoresolve === \"boolean\") {\n                    this.config.autoresolve = config.autoresolve;\n                } else {\n                    reject(\"Incorrect configuration: autoresolve must be a boolean.\");\n                }\n            }\n\n            resolve();\n        });\n    }\n\n    removeIgnored(files) {\n        return new Promise((resolve) => {\n            if (!files.length || !this.config.blacklist.length) {\n                resolve(files);\n            }\n            const cleanFiles = [];\n            for (let i = 0; i < files.length; i++) {\n                let allowed = true;\n                for (let k = 0; k < this.config.blacklist.length; k++) {\n                    if (new RegExp(this.config.blacklist[k]).test(files[i])) {\n                        allowed = false;\n                        break;\n                    }\n                }\n                if (allowed) {\n                    cleanFiles.push(files[i]);\n                }\n            }\n            resolve(cleanFiles);\n        });\n    }\n\n    getCSSFiles() {\n        return new Promise((resolve, reject) => {\n            if (!this.config.sources.length) {\n                reject(\"Missing source paths.\");\n            }\n            let files = [];\n            for (let i = 0; i < this.config.sources.length; i++) {\n                const newFiles = glob.sync(`${this.config.sources[i]}/**/*.css`);\n                files = [...files, ...newFiles];\n            }\n            resolve(files);\n        });\n    }\n\n    copyCSS(files) {\n        return new Promise((resolve, reject) => {\n            if (!files.length) {\n                resolve(files);\n            }\n            const movedFiles = [];\n            let count = 0;\n            for (let i = 0; i < files.length; i++) {\n                const filename = files[i].replace(/(.*\\/)|(.*\\\\)/, \"\");\n                if (!fs.existsSync(`${this.tempDir}/${filename}`)) {\n                    fs.copyFileSync(files[i], `${this.tempDir}/${filename}`);\n                    movedFiles.push(`${this.tempDir}/${filename}`);\n                    count++;\n                    if (count === files.length) {\n                        resolve(movedFiles);\n                    }\n                } else {\n                    if (this.config.autoresolve) {\n                        const newFileData = fs.readFileSync(files[i]).toString();\n                        let tempFileData = fs.readFileSync(`${this.tempDir}/${filename}`).toString();\n                        tempFileData += \"\\n\";\n                        tempFileData += newFileData;\n                        fs.writeFileSync(`${this.tempDir}/${filename}`, tempFileData);\n                        count++;\n                        if (count === files.length) {\n                            resolve(movedFiles);\n                        }\n                    } else {\n                        reject(`Two css files have the same name \"${filename}\". Rename one of the files or enable the CSSMonster autoresolve setting.`);\n                    }\n                }\n            }\n        });\n    }\n\n    normalizeCSS() {\n        return new Promise((resolve, reject) => {\n            let data = \"\";\n            if (fs.existsSync(`${this.tempDir}/normalize.css`)) {\n                data = fs.readFileSync(`${this.tempDir}/normalize.css`).toString();\n            }\n            const normalizePath = path.resolve(cwd, \"node_modules/normalize.css/normalize.css\");\n            const preflightPath = path.join(__dirname, \"preflight.css\");\n            data += fs.readFileSync(normalizePath).toString();\n            data += fs.readFileSync(preflightPath).toString();\n            if (fs.existsSync(`${this.tempDir}/normalize.css`)) {\n                fs.unlinkSync(`${this.tempDir}/normalize.css`);\n            }\n            fs.writeFile(`${this.tempDir}/normalize.css`, data, (error) => {\n                if (error) {\n                    reject(error);\n                }\n                resolve();\n            });\n        });\n    }\n\n    getSCSSFiles() {\n        return new Promise((resolve, reject) => {\n            if (!this.config.sources.length) {\n                reject(\"Missing source paths.\");\n            }\n            let files = [];\n            for (let i = 0; i < this.config.sources.length; i++) {\n                const newFiles = glob.sync(`${this.config.sources[i]}/**/*.scss`);\n                files = [...files, ...newFiles];\n            }\n            resolve(files);\n        });\n    }\n\n    compileSCSS(files) {\n        return new Promise((resolve, reject) => {\n            if (!files.length) {\n                resolve(files);\n            }\n            const compiledFiles = [];\n            let count = 0;\n            for (let i = 0; i < files.length; i++) {\n                const file = files[i];\n                sass.render(\n                    {\n                        file: file,\n                        outputStyle: \"expanded\",\n                        includePaths: this.config.include,\n                    },\n                    (error, result) => {\n                        if (error) {\n                            reject(`SCSS Error: ${error.message} at line ${error.line} ${error.file}`);\n                        } else {\n                            let fileName = result.stats.entry.replace(/(.*\\/)|(.*\\\\)/, \"\").replace(/(.scss)$/g, \"\");\n                            if (fileName) {\n                                const newFile = `${this.tempDir}/${fileName}.css`;\n                                if (!fs.existsSync(newFile)) {\n                                    fs.writeFileSync(newFile, result.css.toString());\n                                    compiledFiles.push(newFile);\n                                    count++;\n                                    if (count === files.length) {\n                                        resolve(compiledFiles);\n                                    }\n                                } else {\n                                    if (this.config.autoresolve) {\n                                        let tempFileData = fs.readFileSync(newFile).toString();\n                                        tempFileData += \"\\n\";\n                                        tempFileData += result.css.toString();\n                                        fs.writeFileSync(newFile, tempFileData);\n                                        count++;\n                                        if (count === files.length) {\n                                            resolve(compiledFiles);\n                                        }\n                                    } else {\n                                        reject(`Two scss files have the same name \"${fileName}\". Rename one of the files or enable the CSSMonster autoresolve setting.`);\n                                    }\n                                }\n                            } else {\n                                reject(\"Something went wrong with the file name of \" + result.stats.entry);\n                            }\n                        }\n                    }\n                );\n            }\n        });\n    }\n\n    minifyCSSFiles() {\n        return new Promise((resolve, reject) => {\n            glob(`${this.tempDir}/*.css`, (error, files) => {\n                if (error) {\n                    reject(error);\n                } else if (!files.length || !this.config.minify) {\n                    resolve();\n                }\n                let minified = 0;\n                for (let i = 0; i < files.length; i++) {\n                    minify(files[i])\n                        .then((css) => {\n                            fs.unlink(files[i], (error) => {\n                                if (error) {\n                                    reject(error);\n                                }\n                                fs.writeFile(files[i], css, (error) => {\n                                    if (error) {\n                                        reject(error);\n                                    }\n                                    minified++;\n                                    if (minified === files.length) {\n                                        resolve();\n                                    }\n                                });\n                            });\n                        })\n                        .catch((error) => {\n                            reject(error);\n                        });\n                }\n            });\n        });\n    }\n\n    async commenceThePurge() {\n        const purgeCSSConfig = this.config.purgeCSS;\n        let normalizedContentPaths = [];\n        for (let i = 0; i < purgeCSSConfig.content.length; i++) {\n            const fullPath = path.resolve(cwd, purgeCSSConfig.content[i]);\n            normalizedContentPaths.push(fullPath);\n        }\n        purgeCSSConfig.content = normalizedContentPaths;\n        purgeCSSConfig.css = [`${this.tempDir}/**/*.css`];\n        const purgecssResult = await new PurgeCSS().purge(purgeCSSConfig);\n        const purgedFiles = [];\n        purgecssResult.forEach((result) => {\n            fs.unlink(result.file, (error) => {\n                if (error) {\n                    throw error;\n                }\n                fs.writeFile(result.file, result.css, (error) => {\n                    if (error) {\n                        throw error;\n                    }\n                    purgedFiles.push(result.file);\n                    if (purgedFiles.length === purgecssResult.length) {\n                        return purgedFiles;\n                    }\n                });\n            });\n        });\n    }\n\n    async deliverCSS() {\n        if (fs.existsSync(this.config.outDir)) {\n            await fs.promises.rm(this.config.outDir, { recursive: true });\n        }\n        await fs.promises.rename(this.tempDir, this.config.outDir);\n    }\n\n    async cleanup() {\n        if (fs.existsSync(this.tempDir)) {\n            await fs.process.rm(this.tempDir, { recursive: true });\n        }\n    }\n\n    async run() {\n        const spinner = ora(\"Running CSSMonster\").start();\n        try {\n            /** Preflight */\n            await this.reset();\n            spinner.text = \"Updating Config\";\n            await this.handleConfig();\n\n            /** Handle CSS */\n            spinner.text = \"Managing CSS\";\n            let cssFiles = await this.getCSSFiles();\n            cssFiles = await this.removeIgnored(cssFiles);\n            const copiedCSSFiles = await this.copyCSS(cssFiles);\n\n            /** Handle SCSS */\n            spinner.text = \"Collecting SCSS\";\n            let scssFiles = await this.getSCSSFiles();\n            scssFiles = await this.removeIgnored(scssFiles);\n            spinner.text = \"Compiling SCSS\";\n            const compiledFiles = await this.compileSCSS(scssFiles);\n\n            /** Normalize */\n            await this.normalizeCSS();\n\n            /** PurgeCSS */\n            if (this.config.purge && this.config.purgeCSS !== null) {\n                spinner.text = \"Purging CSS\";\n                await this.commenceThePurge();\n            }\n\n            /** Handle Minify */\n            if (this.config.minify) {\n                spinner.text = \"Minifying CSS\";\n                await this.minifyCSSFiles();\n            }\n\n            /** Deliver CSS */\n            spinner.text = \"Delivering CSS\";\n            await this.deliverCSS();\n\n            /** Finalize */\n            spinner.text = \"Finalizing\";\n            await this.cleanup();\n\n            spinner.succeed(\"CSSMonster\");\n            process.exit(0);\n        } catch (error) {\n            console.log(error);\n            spinner.fail(error);\n            console.log(\"\\n\");\n            process.exit(1);\n        }\n    }\n}\nnew CSSMonster();\n"]}