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EACN,WAAY,EAAiB,WACxB,QAAQ,GAAqB,UAAf,EAAE,WAChB,KAAK,GAAM,EAAE,WACrB,GAET","file":"/npm/esbuild-plugin-sass@1.0.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/esbuild-plugin-sass@1.0.1/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","\"use strict\";\nconst external_1 = require(\"./internals/external\");\nconst fs = require(\"fs-extra\");\nconst sass = require(\"sass\");\nconst tmp = require(\"tmp\");\nconst path = require(\"path\");\nconst csstree = require(\"css-tree\");\nasync function replaceUrls(css, newCssFileName, sourceDir, rootDir, externals) {\n    const ast = csstree.parse(css);\n    csstree.walk(ast, {\n        enter(node) {\n            // Special case for import, since it supports raw strings as url\n            if (node.type === \"Atrule\" &&\n                node.name === \"import\" &&\n                node.prelude != null &&\n                node.prelude.type === \"AtrulePrelude\") {\n                if (!node.prelude.children.isEmpty()) {\n                    const urlNode = node.prelude.children.first();\n                    if (urlNode != null && urlNode.type === \"String\") {\n                        const normalizedUrl = normalizeQuotes(urlNode.value);\n                        if (isLocalFileUrl(normalizedUrl)) {\n                            const resolved = resolveUrl(normalizedUrl, sourceDir, rootDir);\n                            const relativePath = path.relative(newCssFileName, resolved.file);\n                            urlNode.value = `\"${fixCssUrl(relativePath)}\"`;\n                        }\n                    }\n                }\n            }\n            if (node.type === \"Url\") {\n                const value = node.value;\n                const normalizedUrl = value.type === \"String\" ? normalizeQuotes(value.value) : value.value;\n                if ((0, external_1.isExternal)(normalizedUrl, externals)) {\n                    return;\n                }\n                if (isLocalFileUrl(normalizedUrl)) {\n                    const resolved = resolveUrl(normalizedUrl, sourceDir, rootDir);\n                    const relativePath = path.relative(newCssFileName, resolved.file);\n                    node.value = {\n                        ...node.value,\n                        type: \"String\",\n                        // disable keeping query and hash parts of original url, since esbuild doesn't support it yet\n                        // value: `\"${relativePath}${resolved.query}${resolved.hash}\"`,\n                        value: `\"${fixCssUrl(relativePath)}\"`,\n                    };\n                }\n            }\n        },\n    });\n    return csstree.generate(ast);\n}\nfunction isLocalFileUrl(url) {\n    if (/^https?:\\/\\//i.test(url)) {\n        return false;\n    }\n    if (/^data:/.test(url)) {\n        return false;\n    }\n    if (/^#/.test(url)) {\n        return false;\n    }\n    return true;\n}\nfunction normalizeQuotes(stringValue) {\n    var _a;\n    const match = stringValue.match(/^['\"](.*)[\"']$/s);\n    return match != null ? (_a = match[1]) !== null && _a !== void 0 ? _a : \"\" : stringValue;\n}\n// Always use unix-style path separator (/) in urls in CSS, since Windows-style\n// separator doesn't work on Windows\nfunction fixCssUrl(filePath) {\n    return filePath.split(path.sep).join(\"/\");\n}\nfunction resolveUrl(url, originalFolder, rootDir) {\n    const match = url.match(/^(.*?)(\\?.*?)?(#.*?)?$/);\n    if (match == null) {\n        throw new Error(`Unable to parse url: ${url}`);\n    }\n    const [_, pathname = \"\", query, hash] = match;\n    let file = \"\";\n    if (pathname.startsWith(\"/\")) {\n        file = path.resolve(rootDir, pathname.substring(1));\n        // todo: resolve by root dir\n    }\n    else {\n        file = path.resolve(originalFolder, pathname);\n    }\n    return {\n        file,\n        pathname,\n        query: query || \"\",\n        hash: hash || \"\",\n    };\n}\nmodule.exports = (options = {}) => ({\n    name: \"sass\",\n    setup: function (build) {\n        const { rootDir = process.cwd(), customSassOptions = {} } = options;\n        const { external = [] } = build.initialOptions;\n        const tmpDirPath = tmp.dirSync().name;\n        build.onResolve({ filter: /.\\.(scss|sass)$/, namespace: \"file\" }, async (args) => {\n            const sourceFullPath = require.resolve(args.path, {\n                paths: [args.resolveDir],\n            });\n            const sourceExt = path.extname(sourceFullPath);\n            const sourceBaseName = path.basename(sourceFullPath, sourceExt);\n            const sourceDir = path.dirname(sourceFullPath);\n            const sourceRelDir = path.relative(path.dirname(rootDir), sourceDir);\n            const tmpDir = path.resolve(tmpDirPath, sourceRelDir);\n            const tmpFilePath = path.resolve(tmpDir, `${sourceBaseName}.css`);\n            await fs.ensureDir(tmpDir);\n            // Compile SASS to CSS\n            const sassRenderResult = await sass.compile(sourceFullPath, customSassOptions);\n            let css = sassRenderResult.css.toString();\n            // Replace all relative urls\n            css = await replaceUrls(css, tmpFilePath, sourceDir, rootDir, (0, external_1.compilePatterns)(external));\n            // Write result file\n            await fs.writeFile(tmpFilePath, css);\n            return {\n                path: tmpFilePath,\n                watchFiles: sassRenderResult.loadedUrls\n                    .filter((x) => x.protocol === \"file:\")\n                    .map((x) => x.pathname),\n            };\n        });\n    },\n});\n"]}