diff --git a/.changeset/shaggy-rabbits-remain.md b/.changeset/shaggy-rabbits-remain.md new file mode 100644 index 00000000000..ac4e628e931 --- /dev/null +++ b/.changeset/shaggy-rabbits-remain.md @@ -0,0 +1,5 @@ +--- +'highlight.run': minor +--- + +update rrweb to use postcss css parser diff --git a/.reflame.config.jsonc b/.reflame.config.jsonc index 792dba22b62..1177bc36066 100644 --- a/.reflame.config.jsonc +++ b/.reflame.config.jsonc @@ -374,10 +374,10 @@ ], }, "highlight.run": { - "version": "9.3.4" + "version": "9.4.2" }, "@highlight-run/react": { - "version": "5.0.4" + "version": "6.0.2" }, "antd": { "entryPoints": [ diff --git a/__generated/rr/rrweb/rr.js b/__generated/rr/rrweb/rr.js index 3e6ee426338..b86bcfa9265 100644 --- a/__generated/rr/rrweb/rr.js +++ b/__generated/rr/rrweb/rr.js @@ -185,21 +185,21 @@ function fixBrowserCompatibilityIssuesInCSS(cssText) { } return cssText; } -function escapeImportStatement(rule) { - const { cssText } = rule; +function escapeImportStatement(rule2) { + const { cssText } = rule2; if (cssText.split('"').length < 3) return cssText; - const statement = ["@import", `url(${JSON.stringify(rule.href)})`]; - if (rule.layerName === "") { + const statement = ["@import", `url(${JSON.stringify(rule2.href)})`]; + if (rule2.layerName === "") { statement.push(`layer`); - } else if (rule.layerName) { - statement.push(`layer(${rule.layerName})`); + } else if (rule2.layerName) { + statement.push(`layer(${rule2.layerName})`); } - if (rule.supportsText) { - statement.push(`supports(${rule.supportsText})`); + if (rule2.supportsText) { + statement.push(`supports(${rule2.supportsText})`); } - if (rule.media.length) { - statement.push(rule.media.mediaText); + if (rule2.media.length) { + statement.push(rule2.media.mediaText); } return statement.join(" ") + ";"; } @@ -215,31 +215,31 @@ function stringifyStylesheet(s2) { } const stringifiedRules = Array.from( rules2, - (rule) => stringifyRule(rule, sheetHref) + (rule2) => stringifyRule(rule2, sheetHref) ).join(""); return fixBrowserCompatibilityIssuesInCSS(stringifiedRules); } catch (error) { return null; } } -function stringifyRule(rule, sheetHref) { - if (isCSSImportRule(rule)) { +function stringifyRule(rule2, sheetHref) { + if (isCSSImportRule(rule2)) { let importStringified; try { importStringified = // for same-origin stylesheets, // we can access the imported stylesheet rules directly - stringifyStylesheet(rule.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement - escapeImportStatement(rule); + stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement + escapeImportStatement(rule2); } catch (error) { - importStringified = rule.cssText; + importStringified = rule2.cssText; } - if (rule.styleSheet.href) { - return absolutifyURLs(importStringified, rule.styleSheet.href); + if (rule2.styleSheet.href) { + return absolutifyURLs(importStringified, rule2.styleSheet.href); } return importStringified; } else { - let ruleStringified = rule.cssText; - if (isCSSStyleRule(rule) && rule.selectorText.includes(":")) { + let ruleStringified = rule2.cssText; + if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) { ruleStringified = fixSafariColons(ruleStringified); } if (sheetHref) { @@ -252,11 +252,11 @@ function fixSafariColons(cssStringified) { const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm; return cssStringified.replace(regex, "$1\\$2"); } -function isCSSImportRule(rule) { - return "styleSheet" in rule; +function isCSSImportRule(rule2) { + return "styleSheet" in rule2; } -function isCSSStyleRule(rule) { - return "selectorText" in rule; +function isCSSStyleRule(rule2) { + return "selectorText" in rule2; } var Mirror = class { constructor() { @@ -293,8 +293,8 @@ var Mirror = class { has(id) { return this.idNodeMap.has(id); } - hasNode(node) { - return this.nodeMetaMap.has(node); + hasNode(node2) { + return this.nodeMetaMap.has(node2); } add(n2, meta) { const id = meta.id; @@ -351,7 +351,7 @@ function is2DCanvasBlank(canvas) { if (!ctx) return true; const chunkSize = 50; - for (let x = 0; x < canvas.width; x += chunkSize) { + for (let x2 = 0; x2 < canvas.width; x2 += chunkSize) { for (let y = 0; y < canvas.height; y += chunkSize) { const getImageData = ctx.getImageData; const originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData; @@ -359,9 +359,9 @@ function is2DCanvasBlank(canvas) { // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access originalGetImageData.call( ctx, - x, + x2, y, - Math.min(chunkSize, canvas.width - x), + Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y) ).data.buffer ); @@ -669,35 +669,35 @@ function _isBlockedElement(element, blockClass, blockSelector) { } return false; } -function classMatchesRegex(node, regex, checkAncestors) { - if (!node) +function classMatchesRegex(node2, regex, checkAncestors) { + if (!node2) return false; - if (node.nodeType !== node.ELEMENT_NODE) { + if (node2.nodeType !== node2.ELEMENT_NODE) { if (!checkAncestors) return false; - return classMatchesRegex(index$1.parentNode(node), regex, checkAncestors); + return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors); } - for (let eIndex = node.classList.length; eIndex--; ) { - const className = node.classList[eIndex]; + for (let eIndex = node2.classList.length; eIndex--; ) { + const className = node2.classList[eIndex]; if (regex.test(className)) { return true; } } if (!checkAncestors) return false; - return classMatchesRegex(index$1.parentNode(node), regex, checkAncestors); + return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors); } -function needMaskingText(node, maskTextClass, maskTextSelector, checkAncestors) { +function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) { let el; - if (isElement(node)) { - el = node; + if (isElement(node2)) { + el = node2; if (!index$1.childNodes(el).length) { return false; } - } else if (index$1.parentElement(node) === null) { + } else if (index$1.parentElement(node2) === null) { return false; } else { - el = index$1.parentElement(node); + el = index$1.parentElement(node2); } try { if (typeof maskTextClass === "string") { @@ -1504,505 +1504,3768 @@ function snapshot(n2, options) { privacySetting }); } -var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g; -function parse(css, options = {}) { - let lineno = 1; - let column = 1; - function updatePosition(str) { - const lines = str.match(/\n/g); - if (lines) { - lineno += lines.length; - } - const i2 = str.lastIndexOf("\n"); - column = i2 === -1 ? column + str.length : str.length - i2; - } - function position() { - const start = { line: lineno, column }; - return (node) => { - node.position = new Position(start); - whitespace(); - return node; +var MEDIA_SELECTOR = /(max|min)-device-(width|height)/; +var MEDIA_SELECTOR_GLOBAL = new RegExp(MEDIA_SELECTOR.source, "g"); +var mediaSelectorPlugin = { + postcssPlugin: "postcss-custom-selectors", + prepare() { + return { + postcssPlugin: "postcss-custom-selectors", + AtRule: function(atrule) { + if (atrule.params.match(MEDIA_SELECTOR_GLOBAL)) { + atrule.params = atrule.params.replace(MEDIA_SELECTOR_GLOBAL, "$1-$2"); + } + } }; } - const _Position = class _Position2 { - constructor(start) { - __publicField$1(this, "content"); - __publicField$1(this, "start"); - __publicField$1(this, "end"); - __publicField$1(this, "source"); - this.start = start; - this.end = { line: lineno, column }; - this.source = options.source; - this.content = _Position2.content; - } - }; - __publicField$1(_Position, "content"); - let Position = _Position; - Position.content = css; - const errorsList = []; - function error(msg) { - const err = new Error( - `${options.source || ""}:${lineno}:${column}: ${msg}` - ); - err.reason = msg; - err.filename = options.source; - err.line = lineno; - err.column = column; - err.source = css; - if (options.silent) { - errorsList.push(err); - } else { - throw err; - } - } - function stylesheet() { - const rulesList = rules2(); +}; +var pseudoClassPlugin = { + postcssPlugin: "postcss-hover-classes", + prepare: function() { + const fixed = []; return { - type: "stylesheet", - stylesheet: { - source: options.source, - rules: rulesList, - parsingErrors: errorsList + Rule: function(rule2) { + if (fixed.indexOf(rule2) !== -1) { + return; + } + fixed.push(rule2); + rule2.selectors.forEach(function(selector) { + if (selector.includes(":hover")) { + rule2.selector += ",\n" + selector.replace(/:hover/g, ".\\:hover"); + } + }); } }; } - function open() { - return match(/^{\s*/); - } - function close() { - return match(/^}/); - } - function rules2() { - let node; - const rules22 = []; - whitespace(); - comments(rules22); - while (css.length && css.charAt(0) !== "}" && (node = atrule() || rule())) { - if (node) { - rules22.push(node); - comments(rules22); +}; +function getDefaultExportFromCjs$1(x2) { + return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2; +} +function getAugmentedNamespace$1(n2) { + if (n2.__esModule) + return n2; + var f2 = n2.default; + if (typeof f2 == "function") { + var a2 = function a22() { + if (this instanceof a22) { + return Reflect.construct(f2, arguments, this.constructor); + } + return f2.apply(this, arguments); + }; + a2.prototype = f2.prototype; + } else + a2 = {}; + Object.defineProperty(a2, "__esModule", { value: true }); + Object.keys(n2).forEach(function(k) { + var d = Object.getOwnPropertyDescriptor(n2, k); + Object.defineProperty(a2, k, d.get ? d : { + enumerable: true, + get: function() { + return n2[k]; + } + }); + }); + return a2; +} +var picocolors_browser$1 = { exports: {} }; +var x$1 = String; +var create$1 = function() { + return { isColorSupported: false, reset: x$1, bold: x$1, dim: x$1, italic: x$1, underline: x$1, inverse: x$1, hidden: x$1, strikethrough: x$1, black: x$1, red: x$1, green: x$1, yellow: x$1, blue: x$1, magenta: x$1, cyan: x$1, white: x$1, gray: x$1, bgBlack: x$1, bgRed: x$1, bgGreen: x$1, bgYellow: x$1, bgBlue: x$1, bgMagenta: x$1, bgCyan: x$1, bgWhite: x$1, blackBright: x$1, redBright: x$1, greenBright: x$1, yellowBright: x$1, blueBright: x$1, magentaBright: x$1, cyanBright: x$1, whiteBright: x$1, bgBlackBright: x$1, bgRedBright: x$1, bgGreenBright: x$1, bgYellowBright: x$1, bgBlueBright: x$1, bgMagentaBright: x$1, bgCyanBright: x$1, bgWhiteBright: x$1 }; +}; +picocolors_browser$1.exports = create$1(); +picocolors_browser$1.exports.createColors = create$1; +var picocolors_browserExports$1 = picocolors_browser$1.exports; +var __viteBrowserExternal$2 = {}; +var __viteBrowserExternal$1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + default: __viteBrowserExternal$2 +}, Symbol.toStringTag, { value: "Module" })); +var require$$2$1 = /* @__PURE__ */ getAugmentedNamespace$1(__viteBrowserExternal$1$1); +var pico$1 = picocolors_browserExports$1; +var terminalHighlight$1$1 = require$$2$1; +var CssSyntaxError$3$1 = class CssSyntaxError extends Error { + constructor(message, line, column, source, file, plugin22) { + super(message); + this.name = "CssSyntaxError"; + this.reason = message; + if (file) { + this.file = file; + } + if (source) { + this.source = source; + } + if (plugin22) { + this.plugin = plugin22; + } + if (typeof line !== "undefined" && typeof column !== "undefined") { + if (typeof line === "number") { + this.line = line; + this.column = column; + } else { + this.line = line.line; + this.column = line.column; + this.endLine = column.line; + this.endColumn = column.column; } } - return rules22; - } - function match(re) { - const m = re.exec(css); - if (!m) { - return; - } - const str = m[0]; - updatePosition(str); - css = css.slice(str.length); - return m; - } - function whitespace() { - match(/^\s*/); - } - function comments(rules22 = []) { - let c2; - while (c2 = comment()) { - if (c2) { - rules22.push(c2); + this.setMessage(); + if (Error.captureStackTrace) { + Error.captureStackTrace(this, CssSyntaxError); + } + } + setMessage() { + this.message = this.plugin ? this.plugin + ": " : ""; + this.message += this.file ? this.file : ""; + if (typeof this.line !== "undefined") { + this.message += ":" + this.line + ":" + this.column; + } + this.message += ": " + this.reason; + } + showSourceCode(color) { + if (!this.source) + return ""; + let css = this.source; + if (color == null) + color = pico$1.isColorSupported; + let aside = (text) => text; + let mark = (text) => text; + let highlight = (text) => text; + if (color) { + let { bold, gray, red } = pico$1.createColors(true); + mark = (text) => bold(red(text)); + aside = (text) => gray(text); + if (terminalHighlight$1$1) { + highlight = (text) => terminalHighlight$1$1(text); } - c2 = comment(); } - return rules22; + let lines = css.split(/\r?\n/); + let start = Math.max(this.line - 3, 0); + let end = Math.min(this.line + 2, lines.length); + let maxWidth = String(end).length; + return lines.slice(start, end).map((line, index2) => { + let number = start + 1 + index2; + let gutter = " " + (" " + number).slice(-maxWidth) + " | "; + if (number === this.line) { + if (line.length > 160) { + let padding = 20; + let subLineStart = Math.max(0, this.column - padding); + let subLineEnd = Math.max( + this.column + padding, + this.endColumn + padding + ); + let subLine = line.slice(subLineStart, subLineEnd); + let spacing2 = aside(gutter.replace(/\d/g, " ")) + line.slice(0, Math.min(this.column - 1, padding - 1)).replace(/[^\t]/g, " "); + return mark(">") + aside(gutter) + highlight(subLine) + "\n " + spacing2 + mark("^"); + } + let spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, this.column - 1).replace(/[^\t]/g, " "); + return mark(">") + aside(gutter) + highlight(line) + "\n " + spacing + mark("^"); + } + return " " + aside(gutter) + highlight(line); + }).join("\n"); } - function comment() { - const pos = position(); - if ("/" !== css.charAt(0) || "*" !== css.charAt(1)) { - return; + toString() { + let code = this.showSourceCode(); + if (code) { + code = "\n\n" + code + "\n"; } - let i2 = 2; - while ("" !== css.charAt(i2) && ("*" !== css.charAt(i2) || "/" !== css.charAt(i2 + 1))) { - ++i2; - } - i2 += 2; - if ("" === css.charAt(i2 - 1)) { - return error("End of comment missing"); - } - const str = css.slice(2, i2 - 2); - column += 2; - updatePosition(str); - css = css.slice(i2); - column += 2; - return pos({ - type: "comment", - comment: str - }); + return this.name + ": " + this.message + code; } - const selectorMatcher = new RegExp( - "^((" + [ - /[^\\]"(?:\\"|[^"])*"/.source, - // consume any quoted parts (checking that the double quote isn't itself escaped) - /[^\\]'(?:\\'|[^'])*'/.source, - // same but for single quotes - "[^{]" - ].join("|") + ")+)" - ); - function selector() { - whitespace(); - while (css[0] == "}") { - error("extra closing bracket"); - css = css.slice(1); - whitespace(); - } - const m = match(selectorMatcher); - if (!m) { - return; +}; +var cssSyntaxError$1 = CssSyntaxError$3$1; +CssSyntaxError$3$1.default = CssSyntaxError$3$1; +var DEFAULT_RAW$1 = { + after: "\n", + beforeClose: "\n", + beforeComment: "\n", + beforeDecl: "\n", + beforeOpen: " ", + beforeRule: "\n", + colon: ": ", + commentLeft: " ", + commentRight: " ", + emptyBody: "", + indent: " ", + semicolon: false +}; +function capitalize$1(str) { + return str[0].toUpperCase() + str.slice(1); +} +var Stringifier$2$1 = class Stringifier { + constructor(builder) { + this.builder = builder; + } + atrule(node2, semicolon) { + let name = "@" + node2.name; + let params = node2.params ? this.rawValue(node2, "params") : ""; + if (typeof node2.raws.afterName !== "undefined") { + name += node2.raws.afterName; + } else if (params) { + name += " "; + } + if (node2.nodes) { + this.block(node2, name + params); + } else { + let end = (node2.raws.between || "") + (semicolon ? ";" : ""); + this.builder(name + params + end, node2); } - const cleanedInput = m[0].trim().replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, "").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, (m2) => { - return m2.replace(/,/g, "\u200C"); - }); - return customSplit(cleanedInput).map( - (s2) => s2.replace(/\u200C/g, ",").trim() - ); } - function customSplit(input) { - const result = []; - let currentSegment = ""; - let depthParentheses = 0; - let depthBrackets = 0; - let currentStringChar = null; - for (const char of input) { - const hasStringEscape = currentSegment.endsWith("\\"); - if (currentStringChar) { - if (currentStringChar === char && !hasStringEscape) { - currentStringChar = null; - } - } else if (char === "(") { - depthParentheses++; - } else if (char === ")") { - depthParentheses--; - } else if (char === "[") { - depthBrackets++; - } else if (char === "]") { - depthBrackets--; - } else if (`'"`.includes(char)) { - currentStringChar = char; - } - if (char === "," && depthParentheses === 0 && depthBrackets === 0) { - result.push(currentSegment); - currentSegment = ""; - } else { - currentSegment += char; + beforeAfter(node2, detect) { + let value; + if (node2.type === "decl") { + value = this.raw(node2, null, "beforeDecl"); + } else if (node2.type === "comment") { + value = this.raw(node2, null, "beforeComment"); + } else if (detect === "before") { + value = this.raw(node2, null, "beforeRule"); + } else { + value = this.raw(node2, null, "beforeClose"); + } + let buf = node2.parent; + let depth = 0; + while (buf && buf.type !== "root") { + depth += 1; + buf = buf.parent; + } + if (value.includes("\n")) { + let indent = this.raw(node2, null, "indent"); + if (indent.length) { + for (let step = 0; step < depth; step++) + value += indent; } } - if (currentSegment) { - result.push(currentSegment); + return value; + } + block(node2, start) { + let between = this.raw(node2, "between", "beforeOpen"); + this.builder(start + between + "{", node2, "start"); + let after; + if (node2.nodes && node2.nodes.length) { + this.body(node2); + after = this.raw(node2, "after"); + } else { + after = this.raw(node2, "after", "emptyBody"); } - return result; + if (after) + this.builder(after); + this.builder("}", node2, "end"); } - function declaration() { - const pos = position(); - const propMatch = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/); - if (!propMatch) { - return; + body(node2) { + let last = node2.nodes.length - 1; + while (last > 0) { + if (node2.nodes[last].type !== "comment") + break; + last -= 1; } - const prop = trim(propMatch[0]); - if (!match(/^:\s*/)) { - return error(`property missing ':'`); + let semicolon = this.raw(node2, "semicolon"); + for (let i2 = 0; i2 < node2.nodes.length; i2++) { + let child = node2.nodes[i2]; + let before = this.raw(child, "before"); + if (before) + this.builder(before); + this.stringify(child, last !== i2 || semicolon); } - const val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/); - const ret = pos({ - type: "declaration", - property: prop.replace(commentre, ""), - value: val ? trim(val[0]).replace(commentre, "") : "" - }); - match(/^[;\s]*/); - return ret; } - function declarations() { - const decls = []; - if (!open()) { - return error(`missing '{'`); + comment(node2) { + let left = this.raw(node2, "left", "commentLeft"); + let right = this.raw(node2, "right", "commentRight"); + this.builder("/*" + left + node2.text + right + "*/", node2); + } + decl(node2, semicolon) { + let between = this.raw(node2, "between", "colon"); + let string = node2.prop + between + this.rawValue(node2, "value"); + if (node2.important) { + string += node2.raws.important || " !important"; } - comments(decls); - let decl; - while (decl = declaration()) { - if (decl !== false) { - decls.push(decl); - comments(decls); + if (semicolon) + string += ";"; + this.builder(string, node2); + } + document(node2) { + this.body(node2); + } + raw(node2, own, detect) { + let value; + if (!detect) + detect = own; + if (own) { + value = node2.raws[own]; + if (typeof value !== "undefined") + return value; + } + let parent = node2.parent; + if (detect === "before") { + if (!parent || parent.type === "root" && parent.first === node2) { + return ""; + } + if (parent && parent.type === "document") { + return ""; } - decl = declaration(); } - if (!close()) { - return error(`missing '}'`); + if (!parent) + return DEFAULT_RAW$1[detect]; + let root2 = node2.root(); + if (!root2.rawCache) + root2.rawCache = {}; + if (typeof root2.rawCache[detect] !== "undefined") { + return root2.rawCache[detect]; + } + if (detect === "before" || detect === "after") { + return this.beforeAfter(node2, detect); + } else { + let method = "raw" + capitalize$1(detect); + if (this[method]) { + value = this[method](root2, node2); + } else { + root2.walk((i2) => { + value = i2.raws[own]; + if (typeof value !== "undefined") + return false; + }); + } } - return decls; + if (typeof value === "undefined") + value = DEFAULT_RAW$1[detect]; + root2.rawCache[detect] = value; + return value; + } + rawBeforeClose(root2) { + let value; + root2.walk((i2) => { + if (i2.nodes && i2.nodes.length > 0) { + if (typeof i2.raws.after !== "undefined") { + value = i2.raws.after; + if (value.includes("\n")) { + value = value.replace(/[^\n]+$/, ""); + } + return false; + } + } + }); + if (value) + value = value.replace(/\S/g, ""); + return value; } - function keyframe() { - let m; - const vals = []; - const pos = position(); - while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) { - vals.push(m[1]); - match(/^,\s*/); + rawBeforeComment(root2, node2) { + let value; + root2.walkComments((i2) => { + if (typeof i2.raws.before !== "undefined") { + value = i2.raws.before; + if (value.includes("\n")) { + value = value.replace(/[^\n]+$/, ""); + } + return false; + } + }); + if (typeof value === "undefined") { + value = this.raw(node2, null, "beforeDecl"); + } else if (value) { + value = value.replace(/\S/g, ""); } - if (!vals.length) { - return; + return value; + } + rawBeforeDecl(root2, node2) { + let value; + root2.walkDecls((i2) => { + if (typeof i2.raws.before !== "undefined") { + value = i2.raws.before; + if (value.includes("\n")) { + value = value.replace(/[^\n]+$/, ""); + } + return false; + } + }); + if (typeof value === "undefined") { + value = this.raw(node2, null, "beforeRule"); + } else if (value) { + value = value.replace(/\S/g, ""); } - return pos({ - type: "keyframe", - values: vals, - declarations: declarations() + return value; + } + rawBeforeOpen(root2) { + let value; + root2.walk((i2) => { + if (i2.type !== "decl") { + value = i2.raws.between; + if (typeof value !== "undefined") + return false; + } }); + return value; } - function atkeyframes() { - const pos = position(); - let m = match(/^@([-\w]+)?keyframes\s*/); - if (!m) { - return; - } - const vendor = m[1]; - m = match(/^([-\w]+)\s*/); - if (!m) { - return error("@keyframes missing name"); - } - const name = m[1]; - if (!open()) { - return error(`@keyframes missing '{'`); - } - let frame; - let frames = comments(); - while (frame = keyframe()) { - frames.push(frame); - frames = frames.concat(comments()); - } - if (!close()) { - return error(`@keyframes missing '}'`); - } - return pos({ - type: "keyframes", - name, - vendor, - keyframes: frames + rawBeforeRule(root2) { + let value; + root2.walk((i2) => { + if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) { + if (typeof i2.raws.before !== "undefined") { + value = i2.raws.before; + if (value.includes("\n")) { + value = value.replace(/[^\n]+$/, ""); + } + return false; + } + } }); + if (value) + value = value.replace(/\S/g, ""); + return value; } - function atsupports() { - const pos = position(); - const m = match(/^@supports *([^{]+)/); - if (!m) { - return; + rawColon(root2) { + let value; + root2.walkDecls((i2) => { + if (typeof i2.raws.between !== "undefined") { + value = i2.raws.between.replace(/[^\s:]/g, ""); + return false; + } + }); + return value; + } + rawEmptyBody(root2) { + let value; + root2.walk((i2) => { + if (i2.nodes && i2.nodes.length === 0) { + value = i2.raws.after; + if (typeof value !== "undefined") + return false; + } + }); + return value; + } + rawIndent(root2) { + if (root2.raws.indent) + return root2.raws.indent; + let value; + root2.walk((i2) => { + let p = i2.parent; + if (p && p !== root2 && p.parent && p.parent === root2) { + if (typeof i2.raws.before !== "undefined") { + let parts = i2.raws.before.split("\n"); + value = parts[parts.length - 1]; + value = value.replace(/\S/g, ""); + return false; + } + } + }); + return value; + } + rawSemicolon(root2) { + let value; + root2.walk((i2) => { + if (i2.nodes && i2.nodes.length && i2.last.type === "decl") { + value = i2.raws.semicolon; + if (typeof value !== "undefined") + return false; + } + }); + return value; + } + rawValue(node2, prop) { + let value = node2[prop]; + let raw = node2.raws[prop]; + if (raw && raw.value === value) { + return raw.raw; } - const supports = trim(m[1]); - if (!open()) { - return error(`@supports missing '{'`); + return value; + } + root(node2) { + this.body(node2); + if (node2.raws.after) + this.builder(node2.raws.after); + } + rule(node2) { + this.block(node2, this.rawValue(node2, "selector")); + if (node2.raws.ownSemicolon) { + this.builder(node2.raws.ownSemicolon, node2, "end"); } - const style = comments().concat(rules2()); - if (!close()) { - return error(`@supports missing '}'`); + } + stringify(node2, semicolon) { + if (!this[node2.type]) { + throw new Error( + "Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier." + ); } - return pos({ - type: "supports", - supports, - rules: style - }); + this[node2.type](node2, semicolon); } - function athost() { - const pos = position(); - const m = match(/^@host\s*/); - if (!m) { - return; +}; +var stringifier$1 = Stringifier$2$1; +Stringifier$2$1.default = Stringifier$2$1; +var Stringifier$1$1 = stringifier$1; +function stringify$4$1(node2, builder) { + let str = new Stringifier$1$1(builder); + str.stringify(node2); +} +var stringify_1$1 = stringify$4$1; +stringify$4$1.default = stringify$4$1; +var symbols$1 = {}; +symbols$1.isClean = Symbol("isClean"); +symbols$1.my = Symbol("my"); +var CssSyntaxError$2$1 = cssSyntaxError$1; +var Stringifier2$1 = stringifier$1; +var stringify$3$1 = stringify_1$1; +var { isClean: isClean$2$1, my: my$2$1 } = symbols$1; +function cloneNode$1(obj, parent) { + let cloned = new obj.constructor(); + for (let i2 in obj) { + if (!Object.prototype.hasOwnProperty.call(obj, i2)) { + continue; } - if (!open()) { - return error(`@host missing '{'`); + if (i2 === "proxyCache") + continue; + let value = obj[i2]; + let type = typeof value; + if (i2 === "parent" && type === "object") { + if (parent) + cloned[i2] = parent; + } else if (i2 === "source") { + cloned[i2] = value; + } else if (Array.isArray(value)) { + cloned[i2] = value.map((j) => cloneNode$1(j, cloned)); + } else { + if (type === "object" && value !== null) + value = cloneNode$1(value); + cloned[i2] = value; } - const style = comments().concat(rules2()); - if (!close()) { - return error(`@host missing '}'`); + } + return cloned; +} +var Node$4$1 = class Node2 { + constructor(defaults = {}) { + this.raws = {}; + this[isClean$2$1] = false; + this[my$2$1] = true; + for (let name in defaults) { + if (name === "nodes") { + this.nodes = []; + for (let node2 of defaults[name]) { + if (typeof node2.clone === "function") { + this.append(node2.clone()); + } else { + this.append(node2); + } + } + } else { + this[name] = defaults[name]; + } } - return pos({ - type: "host", - rules: style - }); } - function atmedia() { - const pos = position(); - const m = match(/^@media *([^{]+)/); - if (!m) { - return; + addToError(error) { + error.postcssNode = this; + if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) { + let s2 = this.source; + error.stack = error.stack.replace( + /\n\s{4}at /, + `$&${s2.input.from}:${s2.start.line}:${s2.start.column}$&` + ); } - const media = trim(m[1]); - if (!open()) { - return error(`@media missing '{'`); + return error; + } + after(add) { + this.parent.insertAfter(this, add); + return this; + } + assign(overrides = {}) { + for (let name in overrides) { + this[name] = overrides[name]; } - const style = comments().concat(rules2()); - if (!close()) { - return error(`@media missing '}'`); + return this; + } + before(add) { + this.parent.insertBefore(this, add); + return this; + } + cleanRaws(keepBetween) { + delete this.raws.before; + delete this.raws.after; + if (!keepBetween) + delete this.raws.between; + } + clone(overrides = {}) { + let cloned = cloneNode$1(this); + for (let name in overrides) { + cloned[name] = overrides[name]; + } + return cloned; + } + cloneAfter(overrides = {}) { + let cloned = this.clone(overrides); + this.parent.insertAfter(this, cloned); + return cloned; + } + cloneBefore(overrides = {}) { + let cloned = this.clone(overrides); + this.parent.insertBefore(this, cloned); + return cloned; + } + error(message, opts = {}) { + if (this.source) { + let { end, start } = this.rangeBy(opts); + return this.source.input.error( + message, + { column: start.column, line: start.line }, + { column: end.column, line: end.line }, + opts + ); } - return pos({ - type: "media", - media, - rules: style - }); + return new CssSyntaxError$2$1(message); } - function atcustommedia() { - const pos = position(); - const m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/); - if (!m) { - return; + getProxyProcessor() { + return { + get(node2, prop) { + if (prop === "proxyOf") { + return node2; + } else if (prop === "root") { + return () => node2.root().toProxy(); + } else { + return node2[prop]; + } + }, + set(node2, prop, value) { + if (node2[prop] === value) + return true; + node2[prop] = value; + if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ + prop === "text") { + node2.markDirty(); + } + return true; + } + }; + } + /* c8 ignore next 3 */ + markClean() { + this[isClean$2$1] = true; + } + markDirty() { + if (this[isClean$2$1]) { + this[isClean$2$1] = false; + let next = this; + while (next = next.parent) { + next[isClean$2$1] = false; + } } - return pos({ - type: "custom-media", - name: trim(m[1]), - media: trim(m[2]) - }); } - function atpage() { - const pos = position(); - const m = match(/^@page */); - if (!m) { - return; + next() { + if (!this.parent) + return void 0; + let index2 = this.parent.index(this); + return this.parent.nodes[index2 + 1]; + } + positionBy(opts, stringRepresentation) { + let pos = this.source.start; + if (opts.index) { + pos = this.positionInside(opts.index, stringRepresentation); + } else if (opts.word) { + stringRepresentation = this.toString(); + let index2 = stringRepresentation.indexOf(opts.word); + if (index2 !== -1) + pos = this.positionInside(index2, stringRepresentation); } - const sel = selector() || []; - if (!open()) { - return error(`@page missing '{'`); + return pos; + } + positionInside(index2, stringRepresentation) { + let string = stringRepresentation || this.toString(); + let column = this.source.start.column; + let line = this.source.start.line; + for (let i2 = 0; i2 < index2; i2++) { + if (string[i2] === "\n") { + column = 1; + line += 1; + } else { + column += 1; + } } - let decls = comments(); - let decl; - while (decl = declaration()) { - decls.push(decl); - decls = decls.concat(comments()); + return { column, line }; + } + prev() { + if (!this.parent) + return void 0; + let index2 = this.parent.index(this); + return this.parent.nodes[index2 - 1]; + } + rangeBy(opts) { + let start = { + column: this.source.start.column, + line: this.source.start.line + }; + let end = this.source.end ? { + column: this.source.end.column + 1, + line: this.source.end.line + } : { + column: start.column + 1, + line: start.line + }; + if (opts.word) { + let stringRepresentation = this.toString(); + let index2 = stringRepresentation.indexOf(opts.word); + if (index2 !== -1) { + start = this.positionInside(index2, stringRepresentation); + end = this.positionInside( + index2 + opts.word.length, + stringRepresentation + ); + } + } else { + if (opts.start) { + start = { + column: opts.start.column, + line: opts.start.line + }; + } else if (opts.index) { + start = this.positionInside(opts.index); + } + if (opts.end) { + end = { + column: opts.end.column, + line: opts.end.line + }; + } else if (typeof opts.endIndex === "number") { + end = this.positionInside(opts.endIndex); + } else if (opts.index) { + end = this.positionInside(opts.index + 1); + } } - if (!close()) { - return error(`@page missing '}'`); + if (end.line < start.line || end.line === start.line && end.column <= start.column) { + end = { column: start.column + 1, line: start.line }; } - return pos({ - type: "page", - selectors: sel, - declarations: decls - }); + return { end, start }; } - function atdocument() { - const pos = position(); - const m = match(/^@([-\w]+)?document *([^{]+)/); - if (!m) { - return; - } - const vendor = trim(m[1]); - const doc = trim(m[2]); - if (!open()) { - return error(`@document missing '{'`); + raw(prop, defaultType) { + let str = new Stringifier2$1(); + return str.raw(this, prop, defaultType); + } + remove() { + if (this.parent) { + this.parent.removeChild(this); } - const style = comments().concat(rules2()); - if (!close()) { - return error(`@document missing '}'`); + this.parent = void 0; + return this; + } + replaceWith(...nodes) { + if (this.parent) { + let bookmark = this; + let foundSelf = false; + for (let node2 of nodes) { + if (node2 === this) { + foundSelf = true; + } else if (foundSelf) { + this.parent.insertAfter(bookmark, node2); + bookmark = node2; + } else { + this.parent.insertBefore(bookmark, node2); + } + } + if (!foundSelf) { + this.remove(); + } } - return pos({ - type: "document", - document: doc, - vendor, - rules: style - }); + return this; } - function atfontface() { - const pos = position(); - const m = match(/^@font-face\s*/); - if (!m) { - return; + root() { + let result2 = this; + while (result2.parent && result2.parent.type !== "document") { + result2 = result2.parent; } - if (!open()) { - return error(`@font-face missing '{'`); + return result2; + } + toJSON(_, inputs) { + let fixed = {}; + let emitInputs = inputs == null; + inputs = inputs || /* @__PURE__ */ new Map(); + let inputsNextIndex = 0; + for (let name in this) { + if (!Object.prototype.hasOwnProperty.call(this, name)) { + continue; + } + if (name === "parent" || name === "proxyCache") + continue; + let value = this[name]; + if (Array.isArray(value)) { + fixed[name] = value.map((i2) => { + if (typeof i2 === "object" && i2.toJSON) { + return i2.toJSON(null, inputs); + } else { + return i2; + } + }); + } else if (typeof value === "object" && value.toJSON) { + fixed[name] = value.toJSON(null, inputs); + } else if (name === "source") { + let inputId = inputs.get(value.input); + if (inputId == null) { + inputId = inputsNextIndex; + inputs.set(value.input, inputsNextIndex); + inputsNextIndex++; + } + fixed[name] = { + end: value.end, + inputId, + start: value.start + }; + } else { + fixed[name] = value; + } } - let decls = comments(); - let decl; - while (decl = declaration()) { - decls.push(decl); - decls = decls.concat(comments()); + if (emitInputs) { + fixed.inputs = [...inputs.keys()].map((input2) => input2.toJSON()); } - if (!close()) { - return error(`@font-face missing '}'`); + return fixed; + } + toProxy() { + if (!this.proxyCache) { + this.proxyCache = new Proxy(this, this.getProxyProcessor()); } - return pos({ - type: "font-face", - declarations: decls + return this.proxyCache; + } + toString(stringifier2 = stringify$3$1) { + if (stringifier2.stringify) + stringifier2 = stringifier2.stringify; + let result2 = ""; + stringifier2(this, (i2) => { + result2 += i2; }); + return result2; } - const atimport = _compileAtrule("import"); - const atcharset = _compileAtrule("charset"); - const atnamespace = _compileAtrule("namespace"); - function _compileAtrule(name) { - const re = new RegExp( - "^@" + name + "\\s*((?:" + [ - /[^\\]"(?:\\"|[^"])*"/.source, - // consume any quoted parts (checking that the double quote isn't itself escaped) - /[^\\]'(?:\\'|[^'])*'/.source, - // same but for single quotes - "[^;]" - ].join("|") + ")+);" - ); - return () => { - const pos = position(); - const m = match(re); - if (!m) { - return; - } - const ret = { type: name }; - ret[name] = m[1].trim(); - return pos(ret); - }; + warn(result2, text, opts) { + let data = { node: this }; + for (let i2 in opts) + data[i2] = opts[i2]; + return result2.warn(text, data); } - function atrule() { - if (css[0] !== "@") { - return; - } - return atkeyframes() || atmedia() || atcustommedia() || atsupports() || atimport() || atcharset() || atnamespace() || atdocument() || atpage() || athost() || atfontface(); + get proxyOf() { + return this; } - function rule() { - const pos = position(); - const sel = selector(); - if (!sel) { - return error("selector missing"); +}; +var node$1 = Node$4$1; +Node$4$1.default = Node$4$1; +var Node$3$1 = node$1; +var Comment$4$1 = class Comment extends Node$3$1 { + constructor(defaults) { + super(defaults); + this.type = "comment"; + } +}; +var comment$1 = Comment$4$1; +Comment$4$1.default = Comment$4$1; +var Node$2$1 = node$1; +var Declaration$4$1 = class Declaration extends Node$2$1 { + constructor(defaults) { + if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") { + defaults = { ...defaults, value: String(defaults.value) }; } - comments(); - return pos({ - type: "rule", - selectors: sel, - declarations: declarations() - }); + super(defaults); + this.type = "decl"; } - return addParent(stylesheet()); + get variable() { + return this.prop.startsWith("--") || this.prop[0] === "$"; + } +}; +var declaration$1 = Declaration$4$1; +Declaration$4$1.default = Declaration$4$1; +var Comment$3$1 = comment$1; +var Declaration$3$1 = declaration$1; +var Node$1$1 = node$1; +var { isClean: isClean$1$1, my: my$1$1 } = symbols$1; +var AtRule$4$1; +var parse$4$1; +var Root$6$1; +var Rule$4$1; +function cleanSource$1(nodes) { + return nodes.map((i2) => { + if (i2.nodes) + i2.nodes = cleanSource$1(i2.nodes); + delete i2.source; + return i2; + }); } -function trim(str) { - return str ? str.replace(/^\s+|\s+$/g, "") : ""; +function markTreeDirty$1(node2) { + node2[isClean$1$1] = false; + if (node2.proxyOf.nodes) { + for (let i2 of node2.proxyOf.nodes) { + markTreeDirty$1(i2); + } + } } -function addParent(obj, parent) { - const isNode = obj && typeof obj.type === "string"; - const childParent = isNode ? obj : parent; - for (const k of Object.keys(obj)) { - const value = obj[k]; - if (Array.isArray(value)) { - value.forEach((v2) => { - addParent(v2, childParent); - }); - } else if (value && typeof value === "object") { - addParent(value, childParent); +var Container$7$1 = class Container extends Node$1$1 { + append(...children) { + for (let child of children) { + let nodes = this.normalize(child, this.last); + for (let node2 of nodes) + this.proxyOf.nodes.push(node2); + } + this.markDirty(); + return this; + } + cleanRaws(keepBetween) { + super.cleanRaws(keepBetween); + if (this.nodes) { + for (let node2 of this.nodes) + node2.cleanRaws(keepBetween); + } + } + each(callback) { + if (!this.proxyOf.nodes) + return void 0; + let iterator = this.getIterator(); + let index2, result2; + while (this.indexes[iterator] < this.proxyOf.nodes.length) { + index2 = this.indexes[iterator]; + result2 = callback(this.proxyOf.nodes[index2], index2); + if (result2 === false) + break; + this.indexes[iterator] += 1; } + delete this.indexes[iterator]; + return result2; } - if (isNode) { - Object.defineProperty(obj, "parent", { - configurable: true, - writable: true, - enumerable: false, - value: parent || null - }); + every(condition) { + return this.nodes.every(condition); } - return obj; -} -var tagMap = { - script: "noscript", - // camel case svg element tag names - altglyph: "altGlyph", - altglyphdef: "altGlyphDef", - altglyphitem: "altGlyphItem", - animatecolor: "animateColor", - animatemotion: "animateMotion", - animatetransform: "animateTransform", - clippath: "clipPath", - feblend: "feBlend", - fecolormatrix: "feColorMatrix", - fecomponenttransfer: "feComponentTransfer", + getIterator() { + if (!this.lastEach) + this.lastEach = 0; + if (!this.indexes) + this.indexes = {}; + this.lastEach += 1; + let iterator = this.lastEach; + this.indexes[iterator] = 0; + return iterator; + } + getProxyProcessor() { + return { + get(node2, prop) { + if (prop === "proxyOf") { + return node2; + } else if (!node2[prop]) { + return node2[prop]; + } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) { + return (...args) => { + return node2[prop]( + ...args.map((i2) => { + if (typeof i2 === "function") { + return (child, index2) => i2(child.toProxy(), index2); + } else { + return i2; + } + }) + ); + }; + } else if (prop === "every" || prop === "some") { + return (cb) => { + return node2[prop]( + (child, ...other) => cb(child.toProxy(), ...other) + ); + }; + } else if (prop === "root") { + return () => node2.root().toProxy(); + } else if (prop === "nodes") { + return node2.nodes.map((i2) => i2.toProxy()); + } else if (prop === "first" || prop === "last") { + return node2[prop].toProxy(); + } else { + return node2[prop]; + } + }, + set(node2, prop, value) { + if (node2[prop] === value) + return true; + node2[prop] = value; + if (prop === "name" || prop === "params" || prop === "selector") { + node2.markDirty(); + } + return true; + } + }; + } + index(child) { + if (typeof child === "number") + return child; + if (child.proxyOf) + child = child.proxyOf; + return this.proxyOf.nodes.indexOf(child); + } + insertAfter(exist, add) { + let existIndex = this.index(exist); + let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse(); + existIndex = this.index(exist); + for (let node2 of nodes) + this.proxyOf.nodes.splice(existIndex + 1, 0, node2); + let index2; + for (let id in this.indexes) { + index2 = this.indexes[id]; + if (existIndex < index2) { + this.indexes[id] = index2 + nodes.length; + } + } + this.markDirty(); + return this; + } + insertBefore(exist, add) { + let existIndex = this.index(exist); + let type = existIndex === 0 ? "prepend" : false; + let nodes = this.normalize( + add, + this.proxyOf.nodes[existIndex], + type + ).reverse(); + existIndex = this.index(exist); + for (let node2 of nodes) + this.proxyOf.nodes.splice(existIndex, 0, node2); + let index2; + for (let id in this.indexes) { + index2 = this.indexes[id]; + if (existIndex <= index2) { + this.indexes[id] = index2 + nodes.length; + } + } + this.markDirty(); + return this; + } + normalize(nodes, sample) { + if (typeof nodes === "string") { + nodes = cleanSource$1(parse$4$1(nodes).nodes); + } else if (typeof nodes === "undefined") { + nodes = []; + } else if (Array.isArray(nodes)) { + nodes = nodes.slice(0); + for (let i2 of nodes) { + if (i2.parent) + i2.parent.removeChild(i2, "ignore"); + } + } else if (nodes.type === "root" && this.type !== "document") { + nodes = nodes.nodes.slice(0); + for (let i2 of nodes) { + if (i2.parent) + i2.parent.removeChild(i2, "ignore"); + } + } else if (nodes.type) { + nodes = [nodes]; + } else if (nodes.prop) { + if (typeof nodes.value === "undefined") { + throw new Error("Value field is missed in node creation"); + } else if (typeof nodes.value !== "string") { + nodes.value = String(nodes.value); + } + nodes = [new Declaration$3$1(nodes)]; + } else if (nodes.selector || nodes.selectors) { + nodes = [new Rule$4$1(nodes)]; + } else if (nodes.name) { + nodes = [new AtRule$4$1(nodes)]; + } else if (nodes.text) { + nodes = [new Comment$3$1(nodes)]; + } else { + throw new Error("Unknown node type in node creation"); + } + let processed = nodes.map((i2) => { + if (!i2[my$1$1]) + Container.rebuild(i2); + i2 = i2.proxyOf; + if (i2.parent) + i2.parent.removeChild(i2); + if (i2[isClean$1$1]) + markTreeDirty$1(i2); + if (!i2.raws) + i2.raws = {}; + if (typeof i2.raws.before === "undefined") { + if (sample && typeof sample.raws.before !== "undefined") { + i2.raws.before = sample.raws.before.replace(/\S/g, ""); + } + } + i2.parent = this.proxyOf; + return i2; + }); + return processed; + } + prepend(...children) { + children = children.reverse(); + for (let child of children) { + let nodes = this.normalize(child, this.first, "prepend").reverse(); + for (let node2 of nodes) + this.proxyOf.nodes.unshift(node2); + for (let id in this.indexes) { + this.indexes[id] = this.indexes[id] + nodes.length; + } + } + this.markDirty(); + return this; + } + push(child) { + child.parent = this; + this.proxyOf.nodes.push(child); + return this; + } + removeAll() { + for (let node2 of this.proxyOf.nodes) + node2.parent = void 0; + this.proxyOf.nodes = []; + this.markDirty(); + return this; + } + removeChild(child) { + child = this.index(child); + this.proxyOf.nodes[child].parent = void 0; + this.proxyOf.nodes.splice(child, 1); + let index2; + for (let id in this.indexes) { + index2 = this.indexes[id]; + if (index2 >= child) { + this.indexes[id] = index2 - 1; + } + } + this.markDirty(); + return this; + } + replaceValues(pattern, opts, callback) { + if (!callback) { + callback = opts; + opts = {}; + } + this.walkDecls((decl) => { + if (opts.props && !opts.props.includes(decl.prop)) + return; + if (opts.fast && !decl.value.includes(opts.fast)) + return; + decl.value = decl.value.replace(pattern, callback); + }); + this.markDirty(); + return this; + } + some(condition) { + return this.nodes.some(condition); + } + walk(callback) { + return this.each((child, i2) => { + let result2; + try { + result2 = callback(child, i2); + } catch (e2) { + throw child.addToError(e2); + } + if (result2 !== false && child.walk) { + result2 = child.walk(callback); + } + return result2; + }); + } + walkAtRules(name, callback) { + if (!callback) { + callback = name; + return this.walk((child, i2) => { + if (child.type === "atrule") { + return callback(child, i2); + } + }); + } + if (name instanceof RegExp) { + return this.walk((child, i2) => { + if (child.type === "atrule" && name.test(child.name)) { + return callback(child, i2); + } + }); + } + return this.walk((child, i2) => { + if (child.type === "atrule" && child.name === name) { + return callback(child, i2); + } + }); + } + walkComments(callback) { + return this.walk((child, i2) => { + if (child.type === "comment") { + return callback(child, i2); + } + }); + } + walkDecls(prop, callback) { + if (!callback) { + callback = prop; + return this.walk((child, i2) => { + if (child.type === "decl") { + return callback(child, i2); + } + }); + } + if (prop instanceof RegExp) { + return this.walk((child, i2) => { + if (child.type === "decl" && prop.test(child.prop)) { + return callback(child, i2); + } + }); + } + return this.walk((child, i2) => { + if (child.type === "decl" && child.prop === prop) { + return callback(child, i2); + } + }); + } + walkRules(selector, callback) { + if (!callback) { + callback = selector; + return this.walk((child, i2) => { + if (child.type === "rule") { + return callback(child, i2); + } + }); + } + if (selector instanceof RegExp) { + return this.walk((child, i2) => { + if (child.type === "rule" && selector.test(child.selector)) { + return callback(child, i2); + } + }); + } + return this.walk((child, i2) => { + if (child.type === "rule" && child.selector === selector) { + return callback(child, i2); + } + }); + } + get first() { + if (!this.proxyOf.nodes) + return void 0; + return this.proxyOf.nodes[0]; + } + get last() { + if (!this.proxyOf.nodes) + return void 0; + return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]; + } +}; +Container$7$1.registerParse = (dependant) => { + parse$4$1 = dependant; +}; +Container$7$1.registerRule = (dependant) => { + Rule$4$1 = dependant; +}; +Container$7$1.registerAtRule = (dependant) => { + AtRule$4$1 = dependant; +}; +Container$7$1.registerRoot = (dependant) => { + Root$6$1 = dependant; +}; +var container$1 = Container$7$1; +Container$7$1.default = Container$7$1; +Container$7$1.rebuild = (node2) => { + if (node2.type === "atrule") { + Object.setPrototypeOf(node2, AtRule$4$1.prototype); + } else if (node2.type === "rule") { + Object.setPrototypeOf(node2, Rule$4$1.prototype); + } else if (node2.type === "decl") { + Object.setPrototypeOf(node2, Declaration$3$1.prototype); + } else if (node2.type === "comment") { + Object.setPrototypeOf(node2, Comment$3$1.prototype); + } else if (node2.type === "root") { + Object.setPrototypeOf(node2, Root$6$1.prototype); + } + node2[my$1$1] = true; + if (node2.nodes) { + node2.nodes.forEach((child) => { + Container$7$1.rebuild(child); + }); + } +}; +var Container$6$1 = container$1; +var AtRule$3$1 = class AtRule extends Container$6$1 { + constructor(defaults) { + super(defaults); + this.type = "atrule"; + } + append(...children) { + if (!this.proxyOf.nodes) + this.nodes = []; + return super.append(...children); + } + prepend(...children) { + if (!this.proxyOf.nodes) + this.nodes = []; + return super.prepend(...children); + } +}; +var atRule$1 = AtRule$3$1; +AtRule$3$1.default = AtRule$3$1; +Container$6$1.registerAtRule(AtRule$3$1); +var Container$5$1 = container$1; +var LazyResult$4$1; +var Processor$3$1; +var Document$3$1 = class Document2 extends Container$5$1 { + constructor(defaults) { + super({ type: "document", ...defaults }); + if (!this.nodes) { + this.nodes = []; + } + } + toResult(opts = {}) { + let lazy = new LazyResult$4$1(new Processor$3$1(), this, opts); + return lazy.stringify(); + } +}; +Document$3$1.registerLazyResult = (dependant) => { + LazyResult$4$1 = dependant; +}; +Document$3$1.registerProcessor = (dependant) => { + Processor$3$1 = dependant; +}; +var document$1$1 = Document$3$1; +Document$3$1.default = Document$3$1; +var urlAlphabet$1 = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"; +var customAlphabet$1 = (alphabet, defaultSize = 21) => { + return (size = defaultSize) => { + let id = ""; + let i2 = size; + while (i2--) { + id += alphabet[Math.random() * alphabet.length | 0]; + } + return id; + }; +}; +var nanoid$1$1 = (size = 21) => { + let id = ""; + let i2 = size; + while (i2--) { + id += urlAlphabet$1[Math.random() * 64 | 0]; + } + return id; +}; +var nonSecure$1 = { nanoid: nanoid$1$1, customAlphabet: customAlphabet$1 }; +var { existsSync: existsSync$1, readFileSync: readFileSync$1 } = require$$2$1; +var { dirname: dirname$1$1, join: join$1 } = require$$2$1; +var { SourceMapConsumer: SourceMapConsumer$2$1, SourceMapGenerator: SourceMapGenerator$2$1 } = require$$2$1; +function fromBase64$1(str) { + if (Buffer) { + return Buffer.from(str, "base64").toString(); + } else { + return window.atob(str); + } +} +var PreviousMap$2$1 = class PreviousMap { + constructor(css, opts) { + if (opts.map === false) + return; + this.loadAnnotation(css); + this.inline = this.startWith(this.annotation, "data:"); + let prev = opts.map ? opts.map.prev : void 0; + let text = this.loadMap(opts.from, prev); + if (!this.mapFile && opts.from) { + this.mapFile = opts.from; + } + if (this.mapFile) + this.root = dirname$1$1(this.mapFile); + if (text) + this.text = text; + } + consumer() { + if (!this.consumerCache) { + this.consumerCache = new SourceMapConsumer$2$1(this.text); + } + return this.consumerCache; + } + decodeInline(text) { + let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/; + let baseUri = /^data:application\/json;base64,/; + let charsetUri = /^data:application\/json;charset=utf-?8,/; + let uri = /^data:application\/json,/; + let uriMatch = text.match(charsetUri) || text.match(uri); + if (uriMatch) { + return decodeURIComponent(text.substr(uriMatch[0].length)); + } + let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri); + if (baseUriMatch) { + return fromBase64$1(text.substr(baseUriMatch[0].length)); + } + let encoding = text.match(/data:application\/json;([^,]+),/)[1]; + throw new Error("Unsupported source map encoding " + encoding); + } + getAnnotationURL(sourceMapString) { + return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim(); + } + isMap(map) { + if (typeof map !== "object") + return false; + return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections); + } + loadAnnotation(css) { + let comments = css.match(/\/\*\s*# sourceMappingURL=/g); + if (!comments) + return; + let start = css.lastIndexOf(comments.pop()); + let end = css.indexOf("*/", start); + if (start > -1 && end > -1) { + this.annotation = this.getAnnotationURL(css.substring(start, end)); + } + } + loadFile(path) { + this.root = dirname$1$1(path); + if (existsSync$1(path)) { + this.mapFile = path; + return readFileSync$1(path, "utf-8").toString().trim(); + } + } + loadMap(file, prev) { + if (prev === false) + return false; + if (prev) { + if (typeof prev === "string") { + return prev; + } else if (typeof prev === "function") { + let prevPath = prev(file); + if (prevPath) { + let map = this.loadFile(prevPath); + if (!map) { + throw new Error( + "Unable to load previous source map: " + prevPath.toString() + ); + } + return map; + } + } else if (prev instanceof SourceMapConsumer$2$1) { + return SourceMapGenerator$2$1.fromSourceMap(prev).toString(); + } else if (prev instanceof SourceMapGenerator$2$1) { + return prev.toString(); + } else if (this.isMap(prev)) { + return JSON.stringify(prev); + } else { + throw new Error( + "Unsupported previous source map format: " + prev.toString() + ); + } + } else if (this.inline) { + return this.decodeInline(this.annotation); + } else if (this.annotation) { + let map = this.annotation; + if (file) + map = join$1(dirname$1$1(file), map); + return this.loadFile(map); + } + } + startWith(string, start) { + if (!string) + return false; + return string.substr(0, start.length) === start; + } + withContent() { + return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0); + } +}; +var previousMap$1 = PreviousMap$2$1; +PreviousMap$2$1.default = PreviousMap$2$1; +var { nanoid: nanoid$2 } = nonSecure$1; +var { isAbsolute: isAbsolute$1, resolve: resolve$1$1 } = require$$2$1; +var { SourceMapConsumer: SourceMapConsumer$1$1, SourceMapGenerator: SourceMapGenerator$1$1 } = require$$2$1; +var { fileURLToPath: fileURLToPath$1, pathToFileURL: pathToFileURL$1$1 } = require$$2$1; +var CssSyntaxError$1$1 = cssSyntaxError$1; +var PreviousMap$1$1 = previousMap$1; +var terminalHighlight$2 = require$$2$1; +var fromOffsetCache$1 = Symbol("fromOffsetCache"); +var sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1); +var pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1); +var Input$4$1 = class Input { + constructor(css, opts = {}) { + if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) { + throw new Error(`PostCSS received ${css} instead of CSS string`); + } + this.css = css.toString(); + if (this.css[0] === "\uFEFF" || this.css[0] === "\uFFFE") { + this.hasBOM = true; + this.css = this.css.slice(1); + } else { + this.hasBOM = false; + } + if (opts.from) { + if (!pathAvailable$1$1 || /^\w+:\/\//.test(opts.from) || isAbsolute$1(opts.from)) { + this.file = opts.from; + } else { + this.file = resolve$1$1(opts.from); + } + } + if (pathAvailable$1$1 && sourceMapAvailable$1$1) { + let map = new PreviousMap$1$1(this.css, opts); + if (map.text) { + this.map = map; + let file = map.consumer().file; + if (!this.file && file) + this.file = this.mapResolve(file); + } + } + if (!this.file) { + this.id = ""; + } + if (this.map) + this.map.file = this.from; + } + error(message, line, column, opts = {}) { + let endColumn, endLine, result2; + if (line && typeof line === "object") { + let start = line; + let end = column; + if (typeof start.offset === "number") { + let pos = this.fromOffset(start.offset); + line = pos.line; + column = pos.col; + } else { + line = start.line; + column = start.column; + } + if (typeof end.offset === "number") { + let pos = this.fromOffset(end.offset); + endLine = pos.line; + endColumn = pos.col; + } else { + endLine = end.line; + endColumn = end.column; + } + } else if (!column) { + let pos = this.fromOffset(line); + line = pos.line; + column = pos.col; + } + let origin = this.origin(line, column, endLine, endColumn); + if (origin) { + result2 = new CssSyntaxError$1$1( + message, + origin.endLine === void 0 ? origin.line : { column: origin.column, line: origin.line }, + origin.endLine === void 0 ? origin.column : { column: origin.endColumn, line: origin.endLine }, + origin.source, + origin.file, + opts.plugin + ); + } else { + result2 = new CssSyntaxError$1$1( + message, + endLine === void 0 ? line : { column, line }, + endLine === void 0 ? column : { column: endColumn, line: endLine }, + this.css, + this.file, + opts.plugin + ); + } + result2.input = { column, endColumn, endLine, line, source: this.css }; + if (this.file) { + if (pathToFileURL$1$1) { + result2.input.url = pathToFileURL$1$1(this.file).toString(); + } + result2.input.file = this.file; + } + return result2; + } + fromOffset(offset) { + let lastLine, lineToIndex; + if (!this[fromOffsetCache$1]) { + let lines = this.css.split("\n"); + lineToIndex = new Array(lines.length); + let prevIndex = 0; + for (let i2 = 0, l2 = lines.length; i2 < l2; i2++) { + lineToIndex[i2] = prevIndex; + prevIndex += lines[i2].length + 1; + } + this[fromOffsetCache$1] = lineToIndex; + } else { + lineToIndex = this[fromOffsetCache$1]; + } + lastLine = lineToIndex[lineToIndex.length - 1]; + let min = 0; + if (offset >= lastLine) { + min = lineToIndex.length - 1; + } else { + let max = lineToIndex.length - 2; + let mid; + while (min < max) { + mid = min + (max - min >> 1); + if (offset < lineToIndex[mid]) { + max = mid - 1; + } else if (offset >= lineToIndex[mid + 1]) { + min = mid + 1; + } else { + min = mid; + break; + } + } + } + return { + col: offset - lineToIndex[min] + 1, + line: min + 1 + }; + } + mapResolve(file) { + if (/^\w+:\/\//.test(file)) { + return file; + } + return resolve$1$1(this.map.consumer().sourceRoot || this.map.root || ".", file); + } + origin(line, column, endLine, endColumn) { + if (!this.map) + return false; + let consumer = this.map.consumer(); + let from = consumer.originalPositionFor({ column, line }); + if (!from.source) + return false; + let to; + if (typeof endLine === "number") { + to = consumer.originalPositionFor({ column: endColumn, line: endLine }); + } + let fromUrl; + if (isAbsolute$1(from.source)) { + fromUrl = pathToFileURL$1$1(from.source); + } else { + fromUrl = new URL( + from.source, + this.map.consumer().sourceRoot || pathToFileURL$1$1(this.map.mapFile) + ); + } + let result2 = { + column: from.column, + endColumn: to && to.column, + endLine: to && to.line, + line: from.line, + url: fromUrl.toString() + }; + if (fromUrl.protocol === "file:") { + if (fileURLToPath$1) { + result2.file = fileURLToPath$1(fromUrl); + } else { + throw new Error(`file: protocol is not available in this PostCSS build`); + } + } + let source = consumer.sourceContentFor(from.source); + if (source) + result2.source = source; + return result2; + } + toJSON() { + let json = {}; + for (let name of ["hasBOM", "css", "file", "id"]) { + if (this[name] != null) { + json[name] = this[name]; + } + } + if (this.map) { + json.map = { ...this.map }; + if (json.map.consumerCache) { + json.map.consumerCache = void 0; + } + } + return json; + } + get from() { + return this.file || this.id; + } +}; +var input$1 = Input$4$1; +Input$4$1.default = Input$4$1; +if (terminalHighlight$2 && terminalHighlight$2.registerInput) { + terminalHighlight$2.registerInput(Input$4$1); +} +var Container$4$1 = container$1; +var LazyResult$3$1; +var Processor$2$1; +var Root$5$1 = class Root extends Container$4$1 { + constructor(defaults) { + super(defaults); + this.type = "root"; + if (!this.nodes) + this.nodes = []; + } + normalize(child, sample, type) { + let nodes = super.normalize(child); + if (sample) { + if (type === "prepend") { + if (this.nodes.length > 1) { + sample.raws.before = this.nodes[1].raws.before; + } else { + delete sample.raws.before; + } + } else if (this.first !== sample) { + for (let node2 of nodes) { + node2.raws.before = sample.raws.before; + } + } + } + return nodes; + } + removeChild(child, ignore) { + let index2 = this.index(child); + if (!ignore && index2 === 0 && this.nodes.length > 1) { + this.nodes[1].raws.before = this.nodes[index2].raws.before; + } + return super.removeChild(child); + } + toResult(opts = {}) { + let lazy = new LazyResult$3$1(new Processor$2$1(), this, opts); + return lazy.stringify(); + } +}; +Root$5$1.registerLazyResult = (dependant) => { + LazyResult$3$1 = dependant; +}; +Root$5$1.registerProcessor = (dependant) => { + Processor$2$1 = dependant; +}; +var root$1 = Root$5$1; +Root$5$1.default = Root$5$1; +Container$4$1.registerRoot(Root$5$1); +var list$2$1 = { + comma(string) { + return list$2$1.split(string, [","], true); + }, + space(string) { + let spaces = [" ", "\n", " "]; + return list$2$1.split(string, spaces); + }, + split(string, separators, last) { + let array = []; + let current = ""; + let split = false; + let func = 0; + let inQuote = false; + let prevQuote = ""; + let escape = false; + for (let letter of string) { + if (escape) { + escape = false; + } else if (letter === "\\") { + escape = true; + } else if (inQuote) { + if (letter === prevQuote) { + inQuote = false; + } + } else if (letter === '"' || letter === "'") { + inQuote = true; + prevQuote = letter; + } else if (letter === "(") { + func += 1; + } else if (letter === ")") { + if (func > 0) + func -= 1; + } else if (func === 0) { + if (separators.includes(letter)) + split = true; + } + if (split) { + if (current !== "") + array.push(current.trim()); + current = ""; + split = false; + } else { + current += letter; + } + } + if (last || current !== "") + array.push(current.trim()); + return array; + } +}; +var list_1$1 = list$2$1; +list$2$1.default = list$2$1; +var Container$3$1 = container$1; +var list$1$1 = list_1$1; +var Rule$3$1 = class Rule extends Container$3$1 { + constructor(defaults) { + super(defaults); + this.type = "rule"; + if (!this.nodes) + this.nodes = []; + } + get selectors() { + return list$1$1.comma(this.selector); + } + set selectors(values) { + let match = this.selector ? this.selector.match(/,\s*/) : null; + let sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen"); + this.selector = values.join(sep2); + } +}; +var rule$1 = Rule$3$1; +Rule$3$1.default = Rule$3$1; +Container$3$1.registerRule(Rule$3$1); +var AtRule$2$1 = atRule$1; +var Comment$2$1 = comment$1; +var Declaration$2$1 = declaration$1; +var Input$3$1 = input$1; +var PreviousMap2$1 = previousMap$1; +var Root$4$1 = root$1; +var Rule$2$1 = rule$1; +function fromJSON$1$1(json, inputs) { + if (Array.isArray(json)) + return json.map((n2) => fromJSON$1$1(n2)); + let { inputs: ownInputs, ...defaults } = json; + if (ownInputs) { + inputs = []; + for (let input2 of ownInputs) { + let inputHydrated = { ...input2, __proto__: Input$3$1.prototype }; + if (inputHydrated.map) { + inputHydrated.map = { + ...inputHydrated.map, + __proto__: PreviousMap2$1.prototype + }; + } + inputs.push(inputHydrated); + } + } + if (defaults.nodes) { + defaults.nodes = json.nodes.map((n2) => fromJSON$1$1(n2, inputs)); + } + if (defaults.source) { + let { inputId, ...source } = defaults.source; + defaults.source = source; + if (inputId != null) { + defaults.source.input = inputs[inputId]; + } + } + if (defaults.type === "root") { + return new Root$4$1(defaults); + } else if (defaults.type === "decl") { + return new Declaration$2$1(defaults); + } else if (defaults.type === "rule") { + return new Rule$2$1(defaults); + } else if (defaults.type === "comment") { + return new Comment$2$1(defaults); + } else if (defaults.type === "atrule") { + return new AtRule$2$1(defaults); + } else { + throw new Error("Unknown node type: " + json.type); + } +} +var fromJSON_1$1 = fromJSON$1$1; +fromJSON$1$1.default = fromJSON$1$1; +var { dirname: dirname$2, relative: relative$1, resolve: resolve$2, sep: sep$1 } = require$$2$1; +var { SourceMapConsumer: SourceMapConsumer$3, SourceMapGenerator: SourceMapGenerator$3 } = require$$2$1; +var { pathToFileURL: pathToFileURL$2 } = require$$2$1; +var Input$2$1 = input$1; +var sourceMapAvailable$2 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$3); +var pathAvailable$2 = Boolean(dirname$2 && resolve$2 && relative$1 && sep$1); +var MapGenerator$2$1 = class MapGenerator { + constructor(stringify2, root2, opts, cssString) { + this.stringify = stringify2; + this.mapOpts = opts.map || {}; + this.root = root2; + this.opts = opts; + this.css = cssString; + this.originalCSS = cssString; + this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute; + this.memoizedFileURLs = /* @__PURE__ */ new Map(); + this.memoizedPaths = /* @__PURE__ */ new Map(); + this.memoizedURLs = /* @__PURE__ */ new Map(); + } + addAnnotation() { + let content; + if (this.isInline()) { + content = "data:application/json;base64," + this.toBase64(this.map.toString()); + } else if (typeof this.mapOpts.annotation === "string") { + content = this.mapOpts.annotation; + } else if (typeof this.mapOpts.annotation === "function") { + content = this.mapOpts.annotation(this.opts.to, this.root); + } else { + content = this.outputFile() + ".map"; + } + let eol = "\n"; + if (this.css.includes("\r\n")) + eol = "\r\n"; + this.css += eol + "/*# sourceMappingURL=" + content + " */"; + } + applyPrevMaps() { + for (let prev of this.previous()) { + let from = this.toUrl(this.path(prev.file)); + let root2 = prev.root || dirname$2(prev.file); + let map; + if (this.mapOpts.sourcesContent === false) { + map = new SourceMapConsumer$3(prev.text); + if (map.sourcesContent) { + map.sourcesContent = null; + } + } else { + map = prev.consumer(); + } + this.map.applySourceMap(map, from, this.toUrl(this.path(root2))); + } + } + clearAnnotation() { + if (this.mapOpts.annotation === false) + return; + if (this.root) { + let node2; + for (let i2 = this.root.nodes.length - 1; i2 >= 0; i2--) { + node2 = this.root.nodes[i2]; + if (node2.type !== "comment") + continue; + if (node2.text.startsWith("# sourceMappingURL=")) { + this.root.removeChild(i2); + } + } + } else if (this.css) { + this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, ""); + } + } + generate() { + this.clearAnnotation(); + if (pathAvailable$2 && sourceMapAvailable$2 && this.isMap()) { + return this.generateMap(); + } else { + let result2 = ""; + this.stringify(this.root, (i2) => { + result2 += i2; + }); + return [result2]; + } + } + generateMap() { + if (this.root) { + this.generateString(); + } else if (this.previous().length === 1) { + let prev = this.previous()[0].consumer(); + prev.file = this.outputFile(); + this.map = SourceMapGenerator$3.fromSourceMap(prev, { + ignoreInvalidMapping: true + }); + } else { + this.map = new SourceMapGenerator$3({ + file: this.outputFile(), + ignoreInvalidMapping: true + }); + this.map.addMapping({ + generated: { column: 0, line: 1 }, + original: { column: 0, line: 1 }, + source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "" + }); + } + if (this.isSourcesContent()) + this.setSourcesContent(); + if (this.root && this.previous().length > 0) + this.applyPrevMaps(); + if (this.isAnnotation()) + this.addAnnotation(); + if (this.isInline()) { + return [this.css]; + } else { + return [this.css, this.map]; + } + } + generateString() { + this.css = ""; + this.map = new SourceMapGenerator$3({ + file: this.outputFile(), + ignoreInvalidMapping: true + }); + let line = 1; + let column = 1; + let noSource = ""; + let mapping = { + generated: { column: 0, line: 0 }, + original: { column: 0, line: 0 }, + source: "" + }; + let last, lines; + this.stringify(this.root, (str, node2, type) => { + this.css += str; + if (node2 && type !== "end") { + mapping.generated.line = line; + mapping.generated.column = column - 1; + if (node2.source && node2.source.start) { + mapping.source = this.sourcePath(node2); + mapping.original.line = node2.source.start.line; + mapping.original.column = node2.source.start.column - 1; + this.map.addMapping(mapping); + } else { + mapping.source = noSource; + mapping.original.line = 1; + mapping.original.column = 0; + this.map.addMapping(mapping); + } + } + lines = str.match(/\n/g); + if (lines) { + line += lines.length; + last = str.lastIndexOf("\n"); + column = str.length - last; + } else { + column += str.length; + } + if (node2 && type !== "start") { + let p = node2.parent || { raws: {} }; + let childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes; + if (!childless || node2 !== p.last || p.raws.semicolon) { + if (node2.source && node2.source.end) { + mapping.source = this.sourcePath(node2); + mapping.original.line = node2.source.end.line; + mapping.original.column = node2.source.end.column - 1; + mapping.generated.line = line; + mapping.generated.column = column - 2; + this.map.addMapping(mapping); + } else { + mapping.source = noSource; + mapping.original.line = 1; + mapping.original.column = 0; + mapping.generated.line = line; + mapping.generated.column = column - 1; + this.map.addMapping(mapping); + } + } + } + }); + } + isAnnotation() { + if (this.isInline()) { + return true; + } + if (typeof this.mapOpts.annotation !== "undefined") { + return this.mapOpts.annotation; + } + if (this.previous().length) { + return this.previous().some((i2) => i2.annotation); + } + return true; + } + isInline() { + if (typeof this.mapOpts.inline !== "undefined") { + return this.mapOpts.inline; + } + let annotation = this.mapOpts.annotation; + if (typeof annotation !== "undefined" && annotation !== true) { + return false; + } + if (this.previous().length) { + return this.previous().some((i2) => i2.inline); + } + return true; + } + isMap() { + if (typeof this.opts.map !== "undefined") { + return !!this.opts.map; + } + return this.previous().length > 0; + } + isSourcesContent() { + if (typeof this.mapOpts.sourcesContent !== "undefined") { + return this.mapOpts.sourcesContent; + } + if (this.previous().length) { + return this.previous().some((i2) => i2.withContent()); + } + return true; + } + outputFile() { + if (this.opts.to) { + return this.path(this.opts.to); + } else if (this.opts.from) { + return this.path(this.opts.from); + } else { + return "to.css"; + } + } + path(file) { + if (this.mapOpts.absolute) + return file; + if (file.charCodeAt(0) === 60) + return file; + if (/^\w+:\/\//.test(file)) + return file; + let cached = this.memoizedPaths.get(file); + if (cached) + return cached; + let from = this.opts.to ? dirname$2(this.opts.to) : "."; + if (typeof this.mapOpts.annotation === "string") { + from = dirname$2(resolve$2(from, this.mapOpts.annotation)); + } + let path = relative$1(from, file); + this.memoizedPaths.set(file, path); + return path; + } + previous() { + if (!this.previousMaps) { + this.previousMaps = []; + if (this.root) { + this.root.walk((node2) => { + if (node2.source && node2.source.input.map) { + let map = node2.source.input.map; + if (!this.previousMaps.includes(map)) { + this.previousMaps.push(map); + } + } + }); + } else { + let input2 = new Input$2$1(this.originalCSS, this.opts); + if (input2.map) + this.previousMaps.push(input2.map); + } + } + return this.previousMaps; + } + setSourcesContent() { + let already = {}; + if (this.root) { + this.root.walk((node2) => { + if (node2.source) { + let from = node2.source.input.from; + if (from && !already[from]) { + already[from] = true; + let fromUrl = this.usesFileUrls ? this.toFileUrl(from) : this.toUrl(this.path(from)); + this.map.setSourceContent(fromUrl, node2.source.input.css); + } + } + }); + } else if (this.css) { + let from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : ""; + this.map.setSourceContent(from, this.css); + } + } + sourcePath(node2) { + if (this.mapOpts.from) { + return this.toUrl(this.mapOpts.from); + } else if (this.usesFileUrls) { + return this.toFileUrl(node2.source.input.from); + } else { + return this.toUrl(this.path(node2.source.input.from)); + } + } + toBase64(str) { + if (Buffer) { + return Buffer.from(str).toString("base64"); + } else { + return window.btoa(unescape(encodeURIComponent(str))); + } + } + toFileUrl(path) { + let cached = this.memoizedFileURLs.get(path); + if (cached) + return cached; + if (pathToFileURL$2) { + let fileURL = pathToFileURL$2(path).toString(); + this.memoizedFileURLs.set(path, fileURL); + return fileURL; + } else { + throw new Error( + "`map.absolute` option is not available in this PostCSS build" + ); + } + } + toUrl(path) { + let cached = this.memoizedURLs.get(path); + if (cached) + return cached; + if (sep$1 === "\\") { + path = path.replace(/\\/g, "/"); + } + let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent); + this.memoizedURLs.set(path, url); + return url; + } +}; +var mapGenerator$1 = MapGenerator$2$1; +var SINGLE_QUOTE$1 = "'".charCodeAt(0); +var DOUBLE_QUOTE$1 = '"'.charCodeAt(0); +var BACKSLASH$1 = "\\".charCodeAt(0); +var SLASH$1 = "/".charCodeAt(0); +var NEWLINE$1 = "\n".charCodeAt(0); +var SPACE$1 = " ".charCodeAt(0); +var FEED$1 = "\f".charCodeAt(0); +var TAB$1 = " ".charCodeAt(0); +var CR$1 = "\r".charCodeAt(0); +var OPEN_SQUARE$1 = "[".charCodeAt(0); +var CLOSE_SQUARE$1 = "]".charCodeAt(0); +var OPEN_PARENTHESES$1 = "(".charCodeAt(0); +var CLOSE_PARENTHESES$1 = ")".charCodeAt(0); +var OPEN_CURLY$1 = "{".charCodeAt(0); +var CLOSE_CURLY$1 = "}".charCodeAt(0); +var SEMICOLON$1 = ";".charCodeAt(0); +var ASTERISK$1 = "*".charCodeAt(0); +var COLON$1 = ":".charCodeAt(0); +var AT$1 = "@".charCodeAt(0); +var RE_AT_END$1 = /[\t\n\f\r "#'()/;[\\\]{}]/g; +var RE_WORD_END$1 = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g; +var RE_BAD_BRACKET$1 = /.[\r\n"'(/\\]/; +var RE_HEX_ESCAPE$1 = /[\da-f]/i; +var tokenize$1 = function tokenizer(input2, options = {}) { + let css = input2.css.valueOf(); + let ignore = options.ignoreErrors; + let code, content, escape, next, quote; + let currentToken, escaped, escapePos, n2, prev; + let length = css.length; + let pos = 0; + let buffer = []; + let returned = []; + function position() { + return pos; + } + function unclosed(what) { + throw input2.error("Unclosed " + what, pos); + } + function endOfFile() { + return returned.length === 0 && pos >= length; + } + function nextToken(opts) { + if (returned.length) + return returned.pop(); + if (pos >= length) + return; + let ignoreUnclosed = opts ? opts.ignoreUnclosed : false; + code = css.charCodeAt(pos); + switch (code) { + case NEWLINE$1: + case SPACE$1: + case TAB$1: + case CR$1: + case FEED$1: { + next = pos; + do { + next += 1; + code = css.charCodeAt(next); + } while (code === SPACE$1 || code === NEWLINE$1 || code === TAB$1 || code === CR$1 || code === FEED$1); + currentToken = ["space", css.slice(pos, next)]; + pos = next - 1; + break; + } + case OPEN_SQUARE$1: + case CLOSE_SQUARE$1: + case OPEN_CURLY$1: + case CLOSE_CURLY$1: + case COLON$1: + case SEMICOLON$1: + case CLOSE_PARENTHESES$1: { + let controlChar = String.fromCharCode(code); + currentToken = [controlChar, controlChar, pos]; + break; + } + case OPEN_PARENTHESES$1: { + prev = buffer.length ? buffer.pop()[1] : ""; + n2 = css.charCodeAt(pos + 1); + if (prev === "url" && n2 !== SINGLE_QUOTE$1 && n2 !== DOUBLE_QUOTE$1 && n2 !== SPACE$1 && n2 !== NEWLINE$1 && n2 !== TAB$1 && n2 !== FEED$1 && n2 !== CR$1) { + next = pos; + do { + escaped = false; + next = css.indexOf(")", next + 1); + if (next === -1) { + if (ignore || ignoreUnclosed) { + next = pos; + break; + } else { + unclosed("bracket"); + } + } + escapePos = next; + while (css.charCodeAt(escapePos - 1) === BACKSLASH$1) { + escapePos -= 1; + escaped = !escaped; + } + } while (escaped); + currentToken = ["brackets", css.slice(pos, next + 1), pos, next]; + pos = next; + } else { + next = css.indexOf(")", pos + 1); + content = css.slice(pos, next + 1); + if (next === -1 || RE_BAD_BRACKET$1.test(content)) { + currentToken = ["(", "(", pos]; + } else { + currentToken = ["brackets", content, pos, next]; + pos = next; + } + } + break; + } + case SINGLE_QUOTE$1: + case DOUBLE_QUOTE$1: { + quote = code === SINGLE_QUOTE$1 ? "'" : '"'; + next = pos; + do { + escaped = false; + next = css.indexOf(quote, next + 1); + if (next === -1) { + if (ignore || ignoreUnclosed) { + next = pos + 1; + break; + } else { + unclosed("string"); + } + } + escapePos = next; + while (css.charCodeAt(escapePos - 1) === BACKSLASH$1) { + escapePos -= 1; + escaped = !escaped; + } + } while (escaped); + currentToken = ["string", css.slice(pos, next + 1), pos, next]; + pos = next; + break; + } + case AT$1: { + RE_AT_END$1.lastIndex = pos + 1; + RE_AT_END$1.test(css); + if (RE_AT_END$1.lastIndex === 0) { + next = css.length - 1; + } else { + next = RE_AT_END$1.lastIndex - 2; + } + currentToken = ["at-word", css.slice(pos, next + 1), pos, next]; + pos = next; + break; + } + case BACKSLASH$1: { + next = pos; + escape = true; + while (css.charCodeAt(next + 1) === BACKSLASH$1) { + next += 1; + escape = !escape; + } + code = css.charCodeAt(next + 1); + if (escape && code !== SLASH$1 && code !== SPACE$1 && code !== NEWLINE$1 && code !== TAB$1 && code !== CR$1 && code !== FEED$1) { + next += 1; + if (RE_HEX_ESCAPE$1.test(css.charAt(next))) { + while (RE_HEX_ESCAPE$1.test(css.charAt(next + 1))) { + next += 1; + } + if (css.charCodeAt(next + 1) === SPACE$1) { + next += 1; + } + } + } + currentToken = ["word", css.slice(pos, next + 1), pos, next]; + pos = next; + break; + } + default: { + if (code === SLASH$1 && css.charCodeAt(pos + 1) === ASTERISK$1) { + next = css.indexOf("*/", pos + 2) + 1; + if (next === 0) { + if (ignore || ignoreUnclosed) { + next = css.length; + } else { + unclosed("comment"); + } + } + currentToken = ["comment", css.slice(pos, next + 1), pos, next]; + pos = next; + } else { + RE_WORD_END$1.lastIndex = pos + 1; + RE_WORD_END$1.test(css); + if (RE_WORD_END$1.lastIndex === 0) { + next = css.length - 1; + } else { + next = RE_WORD_END$1.lastIndex - 2; + } + currentToken = ["word", css.slice(pos, next + 1), pos, next]; + buffer.push(currentToken); + pos = next; + } + break; + } + } + pos++; + return currentToken; + } + function back(token) { + returned.push(token); + } + return { + back, + endOfFile, + nextToken, + position + }; +}; +var AtRule$1$1 = atRule$1; +var Comment$1$1 = comment$1; +var Declaration$1$1 = declaration$1; +var Root$3$1 = root$1; +var Rule$1$1 = rule$1; +var tokenizer2$1 = tokenize$1; +var SAFE_COMMENT_NEIGHBOR$1 = { + empty: true, + space: true +}; +function findLastWithPosition$1(tokens) { + for (let i2 = tokens.length - 1; i2 >= 0; i2--) { + let token = tokens[i2]; + let pos = token[3] || token[2]; + if (pos) + return pos; + } +} +var Parser$1$1 = class Parser { + constructor(input2) { + this.input = input2; + this.root = new Root$3$1(); + this.current = this.root; + this.spaces = ""; + this.semicolon = false; + this.createTokenizer(); + this.root.source = { input: input2, start: { column: 1, line: 1, offset: 0 } }; + } + atrule(token) { + let node2 = new AtRule$1$1(); + node2.name = token[1].slice(1); + if (node2.name === "") { + this.unnamedAtrule(node2, token); + } + this.init(node2, token[2]); + let type; + let prev; + let shift; + let last = false; + let open = false; + let params = []; + let brackets = []; + while (!this.tokenizer.endOfFile()) { + token = this.tokenizer.nextToken(); + type = token[0]; + if (type === "(" || type === "[") { + brackets.push(type === "(" ? ")" : "]"); + } else if (type === "{" && brackets.length > 0) { + brackets.push("}"); + } else if (type === brackets[brackets.length - 1]) { + brackets.pop(); + } + if (brackets.length === 0) { + if (type === ";") { + node2.source.end = this.getPosition(token[2]); + node2.source.end.offset++; + this.semicolon = true; + break; + } else if (type === "{") { + open = true; + break; + } else if (type === "}") { + if (params.length > 0) { + shift = params.length - 1; + prev = params[shift]; + while (prev && prev[0] === "space") { + prev = params[--shift]; + } + if (prev) { + node2.source.end = this.getPosition(prev[3] || prev[2]); + node2.source.end.offset++; + } + } + this.end(token); + break; + } else { + params.push(token); + } + } else { + params.push(token); + } + if (this.tokenizer.endOfFile()) { + last = true; + break; + } + } + node2.raws.between = this.spacesAndCommentsFromEnd(params); + if (params.length) { + node2.raws.afterName = this.spacesAndCommentsFromStart(params); + this.raw(node2, "params", params); + if (last) { + token = params[params.length - 1]; + node2.source.end = this.getPosition(token[3] || token[2]); + node2.source.end.offset++; + this.spaces = node2.raws.between; + node2.raws.between = ""; + } + } else { + node2.raws.afterName = ""; + node2.params = ""; + } + if (open) { + node2.nodes = []; + this.current = node2; + } + } + checkMissedSemicolon(tokens) { + let colon = this.colon(tokens); + if (colon === false) + return; + let founded = 0; + let token; + for (let j = colon - 1; j >= 0; j--) { + token = tokens[j]; + if (token[0] !== "space") { + founded += 1; + if (founded === 2) + break; + } + } + throw this.input.error( + "Missed semicolon", + token[0] === "word" ? token[3] + 1 : token[2] + ); + } + colon(tokens) { + let brackets = 0; + let prev, token, type; + for (let [i2, element] of tokens.entries()) { + token = element; + type = token[0]; + if (type === "(") { + brackets += 1; + } + if (type === ")") { + brackets -= 1; + } + if (brackets === 0 && type === ":") { + if (!prev) { + this.doubleColon(token); + } else if (prev[0] === "word" && prev[1] === "progid") { + continue; + } else { + return i2; + } + } + prev = token; + } + return false; + } + comment(token) { + let node2 = new Comment$1$1(); + this.init(node2, token[2]); + node2.source.end = this.getPosition(token[3] || token[2]); + node2.source.end.offset++; + let text = token[1].slice(2, -2); + if (/^\s*$/.test(text)) { + node2.text = ""; + node2.raws.left = text; + node2.raws.right = ""; + } else { + let match = text.match(/^(\s*)([^]*\S)(\s*)$/); + node2.text = match[2]; + node2.raws.left = match[1]; + node2.raws.right = match[3]; + } + } + createTokenizer() { + this.tokenizer = tokenizer2$1(this.input); + } + decl(tokens, customProperty) { + let node2 = new Declaration$1$1(); + this.init(node2, tokens[0][2]); + let last = tokens[tokens.length - 1]; + if (last[0] === ";") { + this.semicolon = true; + tokens.pop(); + } + node2.source.end = this.getPosition( + last[3] || last[2] || findLastWithPosition$1(tokens) + ); + node2.source.end.offset++; + while (tokens[0][0] !== "word") { + if (tokens.length === 1) + this.unknownWord(tokens); + node2.raws.before += tokens.shift()[1]; + } + node2.source.start = this.getPosition(tokens[0][2]); + node2.prop = ""; + while (tokens.length) { + let type = tokens[0][0]; + if (type === ":" || type === "space" || type === "comment") { + break; + } + node2.prop += tokens.shift()[1]; + } + node2.raws.between = ""; + let token; + while (tokens.length) { + token = tokens.shift(); + if (token[0] === ":") { + node2.raws.between += token[1]; + break; + } else { + if (token[0] === "word" && /\w/.test(token[1])) { + this.unknownWord([token]); + } + node2.raws.between += token[1]; + } + } + if (node2.prop[0] === "_" || node2.prop[0] === "*") { + node2.raws.before += node2.prop[0]; + node2.prop = node2.prop.slice(1); + } + let firstSpaces = []; + let next; + while (tokens.length) { + next = tokens[0][0]; + if (next !== "space" && next !== "comment") + break; + firstSpaces.push(tokens.shift()); + } + this.precheckMissedSemicolon(tokens); + for (let i2 = tokens.length - 1; i2 >= 0; i2--) { + token = tokens[i2]; + if (token[1].toLowerCase() === "!important") { + node2.important = true; + let string = this.stringFrom(tokens, i2); + string = this.spacesFromEnd(tokens) + string; + if (string !== " !important") + node2.raws.important = string; + break; + } else if (token[1].toLowerCase() === "important") { + let cache = tokens.slice(0); + let str = ""; + for (let j = i2; j > 0; j--) { + let type = cache[j][0]; + if (str.trim().startsWith("!") && type !== "space") { + break; + } + str = cache.pop()[1] + str; + } + if (str.trim().startsWith("!")) { + node2.important = true; + node2.raws.important = str; + tokens = cache; + } + } + if (token[0] !== "space" && token[0] !== "comment") { + break; + } + } + let hasWord = tokens.some((i2) => i2[0] !== "space" && i2[0] !== "comment"); + if (hasWord) { + node2.raws.between += firstSpaces.map((i2) => i2[1]).join(""); + firstSpaces = []; + } + this.raw(node2, "value", firstSpaces.concat(tokens), customProperty); + if (node2.value.includes(":") && !customProperty) { + this.checkMissedSemicolon(tokens); + } + } + doubleColon(token) { + throw this.input.error( + "Double colon", + { offset: token[2] }, + { offset: token[2] + token[1].length } + ); + } + emptyRule(token) { + let node2 = new Rule$1$1(); + this.init(node2, token[2]); + node2.selector = ""; + node2.raws.between = ""; + this.current = node2; + } + end(token) { + if (this.current.nodes && this.current.nodes.length) { + this.current.raws.semicolon = this.semicolon; + } + this.semicolon = false; + this.current.raws.after = (this.current.raws.after || "") + this.spaces; + this.spaces = ""; + if (this.current.parent) { + this.current.source.end = this.getPosition(token[2]); + this.current.source.end.offset++; + this.current = this.current.parent; + } else { + this.unexpectedClose(token); + } + } + endFile() { + if (this.current.parent) + this.unclosedBlock(); + if (this.current.nodes && this.current.nodes.length) { + this.current.raws.semicolon = this.semicolon; + } + this.current.raws.after = (this.current.raws.after || "") + this.spaces; + this.root.source.end = this.getPosition(this.tokenizer.position()); + } + freeSemicolon(token) { + this.spaces += token[1]; + if (this.current.nodes) { + let prev = this.current.nodes[this.current.nodes.length - 1]; + if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) { + prev.raws.ownSemicolon = this.spaces; + this.spaces = ""; + } + } + } + // Helpers + getPosition(offset) { + let pos = this.input.fromOffset(offset); + return { + column: pos.col, + line: pos.line, + offset + }; + } + init(node2, offset) { + this.current.push(node2); + node2.source = { + input: this.input, + start: this.getPosition(offset) + }; + node2.raws.before = this.spaces; + this.spaces = ""; + if (node2.type !== "comment") + this.semicolon = false; + } + other(start) { + let end = false; + let type = null; + let colon = false; + let bracket = null; + let brackets = []; + let customProperty = start[1].startsWith("--"); + let tokens = []; + let token = start; + while (token) { + type = token[0]; + tokens.push(token); + if (type === "(" || type === "[") { + if (!bracket) + bracket = token; + brackets.push(type === "(" ? ")" : "]"); + } else if (customProperty && colon && type === "{") { + if (!bracket) + bracket = token; + brackets.push("}"); + } else if (brackets.length === 0) { + if (type === ";") { + if (colon) { + this.decl(tokens, customProperty); + return; + } else { + break; + } + } else if (type === "{") { + this.rule(tokens); + return; + } else if (type === "}") { + this.tokenizer.back(tokens.pop()); + end = true; + break; + } else if (type === ":") { + colon = true; + } + } else if (type === brackets[brackets.length - 1]) { + brackets.pop(); + if (brackets.length === 0) + bracket = null; + } + token = this.tokenizer.nextToken(); + } + if (this.tokenizer.endOfFile()) + end = true; + if (brackets.length > 0) + this.unclosedBracket(bracket); + if (end && colon) { + if (!customProperty) { + while (tokens.length) { + token = tokens[tokens.length - 1][0]; + if (token !== "space" && token !== "comment") + break; + this.tokenizer.back(tokens.pop()); + } + } + this.decl(tokens, customProperty); + } else { + this.unknownWord(tokens); + } + } + parse() { + let token; + while (!this.tokenizer.endOfFile()) { + token = this.tokenizer.nextToken(); + switch (token[0]) { + case "space": + this.spaces += token[1]; + break; + case ";": + this.freeSemicolon(token); + break; + case "}": + this.end(token); + break; + case "comment": + this.comment(token); + break; + case "at-word": + this.atrule(token); + break; + case "{": + this.emptyRule(token); + break; + default: + this.other(token); + break; + } + } + this.endFile(); + } + precheckMissedSemicolon() { + } + raw(node2, prop, tokens, customProperty) { + let token, type; + let length = tokens.length; + let value = ""; + let clean = true; + let next, prev; + for (let i2 = 0; i2 < length; i2 += 1) { + token = tokens[i2]; + type = token[0]; + if (type === "space" && i2 === length - 1 && !customProperty) { + clean = false; + } else if (type === "comment") { + prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty"; + next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty"; + if (!SAFE_COMMENT_NEIGHBOR$1[prev] && !SAFE_COMMENT_NEIGHBOR$1[next]) { + if (value.slice(-1) === ",") { + clean = false; + } else { + value += token[1]; + } + } else { + clean = false; + } + } else { + value += token[1]; + } + } + if (!clean) { + let raw = tokens.reduce((all, i2) => all + i2[1], ""); + node2.raws[prop] = { raw, value }; + } + node2[prop] = value; + } + rule(tokens) { + tokens.pop(); + let node2 = new Rule$1$1(); + this.init(node2, tokens[0][2]); + node2.raws.between = this.spacesAndCommentsFromEnd(tokens); + this.raw(node2, "selector", tokens); + this.current = node2; + } + spacesAndCommentsFromEnd(tokens) { + let lastTokenType; + let spaces = ""; + while (tokens.length) { + lastTokenType = tokens[tokens.length - 1][0]; + if (lastTokenType !== "space" && lastTokenType !== "comment") + break; + spaces = tokens.pop()[1] + spaces; + } + return spaces; + } + // Errors + spacesAndCommentsFromStart(tokens) { + let next; + let spaces = ""; + while (tokens.length) { + next = tokens[0][0]; + if (next !== "space" && next !== "comment") + break; + spaces += tokens.shift()[1]; + } + return spaces; + } + spacesFromEnd(tokens) { + let lastTokenType; + let spaces = ""; + while (tokens.length) { + lastTokenType = tokens[tokens.length - 1][0]; + if (lastTokenType !== "space") + break; + spaces = tokens.pop()[1] + spaces; + } + return spaces; + } + stringFrom(tokens, from) { + let result2 = ""; + for (let i2 = from; i2 < tokens.length; i2++) { + result2 += tokens[i2][1]; + } + tokens.splice(from, tokens.length - from); + return result2; + } + unclosedBlock() { + let pos = this.current.source.start; + throw this.input.error("Unclosed block", pos.line, pos.column); + } + unclosedBracket(bracket) { + throw this.input.error( + "Unclosed bracket", + { offset: bracket[2] }, + { offset: bracket[2] + 1 } + ); + } + unexpectedClose(token) { + throw this.input.error( + "Unexpected }", + { offset: token[2] }, + { offset: token[2] + 1 } + ); + } + unknownWord(tokens) { + throw this.input.error( + "Unknown word", + { offset: tokens[0][2] }, + { offset: tokens[0][2] + tokens[0][1].length } + ); + } + unnamedAtrule(node2, token) { + throw this.input.error( + "At-rule without name", + { offset: token[2] }, + { offset: token[2] + token[1].length } + ); + } +}; +var parser$1 = Parser$1$1; +var Container$2$1 = container$1; +var Input$1$1 = input$1; +var Parser2$1 = parser$1; +function parse$3$1(css, opts) { + let input2 = new Input$1$1(css, opts); + let parser2 = new Parser2$1(input2); + try { + parser2.parse(); + } catch (e2) { + if (true) { + if (e2.name === "CssSyntaxError" && opts && opts.from) { + if (/\.scss$/i.test(opts.from)) { + e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser"; + } else if (/\.sass/i.test(opts.from)) { + e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser"; + } else if (/\.less$/i.test(opts.from)) { + e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser"; + } + } + } + throw e2; + } + return parser2.root; +} +var parse_1$1 = parse$3$1; +parse$3$1.default = parse$3$1; +Container$2$1.registerParse(parse$3$1); +var Warning$2$1 = class Warning { + constructor(text, opts = {}) { + this.type = "warning"; + this.text = text; + if (opts.node && opts.node.source) { + let range = opts.node.rangeBy(opts); + this.line = range.start.line; + this.column = range.start.column; + this.endLine = range.end.line; + this.endColumn = range.end.column; + } + for (let opt in opts) + this[opt] = opts[opt]; + } + toString() { + if (this.node) { + return this.node.error(this.text, { + index: this.index, + plugin: this.plugin, + word: this.word + }).message; + } + if (this.plugin) { + return this.plugin + ": " + this.text; + } + return this.text; + } +}; +var warning$1 = Warning$2$1; +Warning$2$1.default = Warning$2$1; +var Warning$1$1 = warning$1; +var Result$3$1 = class Result { + constructor(processor2, root2, opts) { + this.processor = processor2; + this.messages = []; + this.root = root2; + this.opts = opts; + this.css = void 0; + this.map = void 0; + } + toString() { + return this.css; + } + warn(text, opts = {}) { + if (!opts.plugin) { + if (this.lastPlugin && this.lastPlugin.postcssPlugin) { + opts.plugin = this.lastPlugin.postcssPlugin; + } + } + let warning2 = new Warning$1$1(text, opts); + this.messages.push(warning2); + return warning2; + } + warnings() { + return this.messages.filter((i2) => i2.type === "warning"); + } + get content() { + return this.css; + } +}; +var result$1 = Result$3$1; +Result$3$1.default = Result$3$1; +var printed$1 = {}; +var warnOnce$2$1 = function warnOnce(message) { + if (printed$1[message]) + return; + printed$1[message] = true; + if (typeof console !== "undefined" && console.warn) { + console.warn(message); + } +}; +var Container$1$1 = container$1; +var Document$2$1 = document$1$1; +var MapGenerator$1$1 = mapGenerator$1; +var parse$2$1 = parse_1$1; +var Result$2$1 = result$1; +var Root$2$1 = root$1; +var stringify$2$1 = stringify_1$1; +var { isClean: isClean$3, my: my$3 } = symbols$1; +var warnOnce$1$1 = warnOnce$2$1; +var TYPE_TO_CLASS_NAME$1 = { + atrule: "AtRule", + comment: "Comment", + decl: "Declaration", + document: "Document", + root: "Root", + rule: "Rule" +}; +var PLUGIN_PROPS$1 = { + AtRule: true, + AtRuleExit: true, + Comment: true, + CommentExit: true, + Declaration: true, + DeclarationExit: true, + Document: true, + DocumentExit: true, + Once: true, + OnceExit: true, + postcssPlugin: true, + prepare: true, + Root: true, + RootExit: true, + Rule: true, + RuleExit: true +}; +var NOT_VISITORS$1 = { + Once: true, + postcssPlugin: true, + prepare: true +}; +var CHILDREN$1 = 0; +function isPromise$1(obj) { + return typeof obj === "object" && typeof obj.then === "function"; +} +function getEvents$1(node2) { + let key = false; + let type = TYPE_TO_CLASS_NAME$1[node2.type]; + if (node2.type === "decl") { + key = node2.prop.toLowerCase(); + } else if (node2.type === "atrule") { + key = node2.name.toLowerCase(); + } + if (key && node2.append) { + return [ + type, + type + "-" + key, + CHILDREN$1, + type + "Exit", + type + "Exit-" + key + ]; + } else if (key) { + return [type, type + "-" + key, type + "Exit", type + "Exit-" + key]; + } else if (node2.append) { + return [type, CHILDREN$1, type + "Exit"]; + } else { + return [type, type + "Exit"]; + } +} +function toStack$1(node2) { + let events; + if (node2.type === "document") { + events = ["Document", CHILDREN$1, "DocumentExit"]; + } else if (node2.type === "root") { + events = ["Root", CHILDREN$1, "RootExit"]; + } else { + events = getEvents$1(node2); + } + return { + eventIndex: 0, + events, + iterator: 0, + node: node2, + visitorIndex: 0, + visitors: [] + }; +} +function cleanMarks$1(node2) { + node2[isClean$3] = false; + if (node2.nodes) + node2.nodes.forEach((i2) => cleanMarks$1(i2)); + return node2; +} +var postcss$2$1 = {}; +var LazyResult$2$1 = class LazyResult { + constructor(processor2, css, opts) { + this.stringified = false; + this.processed = false; + let root2; + if (typeof css === "object" && css !== null && (css.type === "root" || css.type === "document")) { + root2 = cleanMarks$1(css); + } else if (css instanceof LazyResult || css instanceof Result$2$1) { + root2 = cleanMarks$1(css.root); + if (css.map) { + if (typeof opts.map === "undefined") + opts.map = {}; + if (!opts.map.inline) + opts.map.inline = false; + opts.map.prev = css.map; + } + } else { + let parser2 = parse$2$1; + if (opts.syntax) + parser2 = opts.syntax.parse; + if (opts.parser) + parser2 = opts.parser; + if (parser2.parse) + parser2 = parser2.parse; + try { + root2 = parser2(css, opts); + } catch (error) { + this.processed = true; + this.error = error; + } + if (root2 && !root2[my$3]) { + Container$1$1.rebuild(root2); + } + } + this.result = new Result$2$1(processor2, root2, opts); + this.helpers = { ...postcss$2$1, postcss: postcss$2$1, result: this.result }; + this.plugins = this.processor.plugins.map((plugin22) => { + if (typeof plugin22 === "object" && plugin22.prepare) { + return { ...plugin22, ...plugin22.prepare(this.result) }; + } else { + return plugin22; + } + }); + } + async() { + if (this.error) + return Promise.reject(this.error); + if (this.processed) + return Promise.resolve(this.result); + if (!this.processing) { + this.processing = this.runAsync(); + } + return this.processing; + } + catch(onRejected) { + return this.async().catch(onRejected); + } + finally(onFinally) { + return this.async().then(onFinally, onFinally); + } + getAsyncError() { + throw new Error("Use process(css).then(cb) to work with async plugins"); + } + handleError(error, node2) { + let plugin22 = this.result.lastPlugin; + try { + if (node2) + node2.addToError(error); + this.error = error; + if (error.name === "CssSyntaxError" && !error.plugin) { + error.plugin = plugin22.postcssPlugin; + error.setMessage(); + } else if (plugin22.postcssVersion) { + if (true) { + let pluginName = plugin22.postcssPlugin; + let pluginVer = plugin22.postcssVersion; + let runtimeVer = this.result.processor.version; + let a2 = pluginVer.split("."); + let b = runtimeVer.split("."); + if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) { + console.error( + "Unknown error from PostCSS plugin. Your current PostCSS version is " + runtimeVer + ", but " + pluginName + " uses " + pluginVer + ". Perhaps this is the source of the error below." + ); + } + } + } + } catch (err) { + if (console && console.error) + console.error(err); + } + return error; + } + prepareVisitors() { + this.listeners = {}; + let add = (plugin22, type, cb) => { + if (!this.listeners[type]) + this.listeners[type] = []; + this.listeners[type].push([plugin22, cb]); + }; + for (let plugin22 of this.plugins) { + if (typeof plugin22 === "object") { + for (let event in plugin22) { + if (!PLUGIN_PROPS$1[event] && /^[A-Z]/.test(event)) { + throw new Error( + `Unknown event ${event} in ${plugin22.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).` + ); + } + if (!NOT_VISITORS$1[event]) { + if (typeof plugin22[event] === "object") { + for (let filter in plugin22[event]) { + if (filter === "*") { + add(plugin22, event, plugin22[event][filter]); + } else { + add( + plugin22, + event + "-" + filter.toLowerCase(), + plugin22[event][filter] + ); + } + } + } else if (typeof plugin22[event] === "function") { + add(plugin22, event, plugin22[event]); + } + } + } + } + } + this.hasListener = Object.keys(this.listeners).length > 0; + } + async runAsync() { + this.plugin = 0; + for (let i2 = 0; i2 < this.plugins.length; i2++) { + let plugin22 = this.plugins[i2]; + let promise = this.runOnRoot(plugin22); + if (isPromise$1(promise)) { + try { + await promise; + } catch (error) { + throw this.handleError(error); + } + } + } + this.prepareVisitors(); + if (this.hasListener) { + let root2 = this.result.root; + while (!root2[isClean$3]) { + root2[isClean$3] = true; + let stack = [toStack$1(root2)]; + while (stack.length > 0) { + let promise = this.visitTick(stack); + if (isPromise$1(promise)) { + try { + await promise; + } catch (e2) { + let node2 = stack[stack.length - 1].node; + throw this.handleError(e2, node2); + } + } + } + } + if (this.listeners.OnceExit) { + for (let [plugin22, visitor] of this.listeners.OnceExit) { + this.result.lastPlugin = plugin22; + try { + if (root2.type === "document") { + let roots = root2.nodes.map( + (subRoot) => visitor(subRoot, this.helpers) + ); + await Promise.all(roots); + } else { + await visitor(root2, this.helpers); + } + } catch (e2) { + throw this.handleError(e2); + } + } + } + } + this.processed = true; + return this.stringify(); + } + runOnRoot(plugin22) { + this.result.lastPlugin = plugin22; + try { + if (typeof plugin22 === "object" && plugin22.Once) { + if (this.result.root.type === "document") { + let roots = this.result.root.nodes.map( + (root2) => plugin22.Once(root2, this.helpers) + ); + if (isPromise$1(roots[0])) { + return Promise.all(roots); + } + return roots; + } + return plugin22.Once(this.result.root, this.helpers); + } else if (typeof plugin22 === "function") { + return plugin22(this.result.root, this.result); + } + } catch (error) { + throw this.handleError(error); + } + } + stringify() { + if (this.error) + throw this.error; + if (this.stringified) + return this.result; + this.stringified = true; + this.sync(); + let opts = this.result.opts; + let str = stringify$2$1; + if (opts.syntax) + str = opts.syntax.stringify; + if (opts.stringifier) + str = opts.stringifier; + if (str.stringify) + str = str.stringify; + let map = new MapGenerator$1$1(str, this.result.root, this.result.opts); + let data = map.generate(); + this.result.css = data[0]; + this.result.map = data[1]; + return this.result; + } + sync() { + if (this.error) + throw this.error; + if (this.processed) + return this.result; + this.processed = true; + if (this.processing) { + throw this.getAsyncError(); + } + for (let plugin22 of this.plugins) { + let promise = this.runOnRoot(plugin22); + if (isPromise$1(promise)) { + throw this.getAsyncError(); + } + } + this.prepareVisitors(); + if (this.hasListener) { + let root2 = this.result.root; + while (!root2[isClean$3]) { + root2[isClean$3] = true; + this.walkSync(root2); + } + if (this.listeners.OnceExit) { + if (root2.type === "document") { + for (let subRoot of root2.nodes) { + this.visitSync(this.listeners.OnceExit, subRoot); + } + } else { + this.visitSync(this.listeners.OnceExit, root2); + } + } + } + return this.result; + } + then(onFulfilled, onRejected) { + if (true) { + if (!("from" in this.opts)) { + warnOnce$1$1( + "Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning." + ); + } + } + return this.async().then(onFulfilled, onRejected); + } + toString() { + return this.css; + } + visitSync(visitors, node2) { + for (let [plugin22, visitor] of visitors) { + this.result.lastPlugin = plugin22; + let promise; + try { + promise = visitor(node2, this.helpers); + } catch (e2) { + throw this.handleError(e2, node2.proxyOf); + } + if (node2.type !== "root" && node2.type !== "document" && !node2.parent) { + return true; + } + if (isPromise$1(promise)) { + throw this.getAsyncError(); + } + } + } + visitTick(stack) { + let visit2 = stack[stack.length - 1]; + let { node: node2, visitors } = visit2; + if (node2.type !== "root" && node2.type !== "document" && !node2.parent) { + stack.pop(); + return; + } + if (visitors.length > 0 && visit2.visitorIndex < visitors.length) { + let [plugin22, visitor] = visitors[visit2.visitorIndex]; + visit2.visitorIndex += 1; + if (visit2.visitorIndex === visitors.length) { + visit2.visitors = []; + visit2.visitorIndex = 0; + } + this.result.lastPlugin = plugin22; + try { + return visitor(node2.toProxy(), this.helpers); + } catch (e2) { + throw this.handleError(e2, node2); + } + } + if (visit2.iterator !== 0) { + let iterator = visit2.iterator; + let child; + while (child = node2.nodes[node2.indexes[iterator]]) { + node2.indexes[iterator] += 1; + if (!child[isClean$3]) { + child[isClean$3] = true; + stack.push(toStack$1(child)); + return; + } + } + visit2.iterator = 0; + delete node2.indexes[iterator]; + } + let events = visit2.events; + while (visit2.eventIndex < events.length) { + let event = events[visit2.eventIndex]; + visit2.eventIndex += 1; + if (event === CHILDREN$1) { + if (node2.nodes && node2.nodes.length) { + node2[isClean$3] = true; + visit2.iterator = node2.getIterator(); + } + return; + } else if (this.listeners[event]) { + visit2.visitors = this.listeners[event]; + return; + } + } + stack.pop(); + } + walkSync(node2) { + node2[isClean$3] = true; + let events = getEvents$1(node2); + for (let event of events) { + if (event === CHILDREN$1) { + if (node2.nodes) { + node2.each((child) => { + if (!child[isClean$3]) + this.walkSync(child); + }); + } + } else { + let visitors = this.listeners[event]; + if (visitors) { + if (this.visitSync(visitors, node2.toProxy())) + return; + } + } + } + } + warnings() { + return this.sync().warnings(); + } + get content() { + return this.stringify().content; + } + get css() { + return this.stringify().css; + } + get map() { + return this.stringify().map; + } + get messages() { + return this.sync().messages; + } + get opts() { + return this.result.opts; + } + get processor() { + return this.result.processor; + } + get root() { + return this.sync().root; + } + get [Symbol.toStringTag]() { + return "LazyResult"; + } +}; +LazyResult$2$1.registerPostcss = (dependant) => { + postcss$2$1 = dependant; +}; +var lazyResult$1 = LazyResult$2$1; +LazyResult$2$1.default = LazyResult$2$1; +Root$2$1.registerLazyResult(LazyResult$2$1); +Document$2$1.registerLazyResult(LazyResult$2$1); +var MapGenerator2$1 = mapGenerator$1; +var parse$1$1 = parse_1$1; +var Result$1$1 = result$1; +var stringify$1$1 = stringify_1$1; +var warnOnce2$1 = warnOnce$2$1; +var NoWorkResult$1$1 = class NoWorkResult { + constructor(processor2, css, opts) { + css = css.toString(); + this.stringified = false; + this._processor = processor2; + this._css = css; + this._opts = opts; + this._map = void 0; + let root2; + let str = stringify$1$1; + this.result = new Result$1$1(this._processor, root2, this._opts); + this.result.css = css; + let self2 = this; + Object.defineProperty(this.result, "root", { + get() { + return self2.root; + } + }); + let map = new MapGenerator2$1(str, root2, this._opts, css); + if (map.isMap()) { + let [generatedCSS, generatedMap] = map.generate(); + if (generatedCSS) { + this.result.css = generatedCSS; + } + if (generatedMap) { + this.result.map = generatedMap; + } + } else { + map.clearAnnotation(); + this.result.css = map.css; + } + } + async() { + if (this.error) + return Promise.reject(this.error); + return Promise.resolve(this.result); + } + catch(onRejected) { + return this.async().catch(onRejected); + } + finally(onFinally) { + return this.async().then(onFinally, onFinally); + } + sync() { + if (this.error) + throw this.error; + return this.result; + } + then(onFulfilled, onRejected) { + if (true) { + if (!("from" in this._opts)) { + warnOnce2$1( + "Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning." + ); + } + } + return this.async().then(onFulfilled, onRejected); + } + toString() { + return this._css; + } + warnings() { + return []; + } + get content() { + return this.result.css; + } + get css() { + return this.result.css; + } + get map() { + return this.result.map; + } + get messages() { + return []; + } + get opts() { + return this.result.opts; + } + get processor() { + return this.result.processor; + } + get root() { + if (this._root) { + return this._root; + } + let root2; + let parser2 = parse$1$1; + try { + root2 = parser2(this._css, this._opts); + } catch (error) { + this.error = error; + } + if (this.error) { + throw this.error; + } else { + this._root = root2; + return root2; + } + } + get [Symbol.toStringTag]() { + return "NoWorkResult"; + } +}; +var noWorkResult$1 = NoWorkResult$1$1; +NoWorkResult$1$1.default = NoWorkResult$1$1; +var Document$1$1 = document$1$1; +var LazyResult$1$1 = lazyResult$1; +var NoWorkResult2$1 = noWorkResult$1; +var Root$1$1 = root$1; +var Processor$1$1 = class Processor { + constructor(plugins = []) { + this.version = "8.4.47"; + this.plugins = this.normalize(plugins); + } + normalize(plugins) { + let normalized = []; + for (let i2 of plugins) { + if (i2.postcss === true) { + i2 = i2(); + } else if (i2.postcss) { + i2 = i2.postcss; + } + if (typeof i2 === "object" && Array.isArray(i2.plugins)) { + normalized = normalized.concat(i2.plugins); + } else if (typeof i2 === "object" && i2.postcssPlugin) { + normalized.push(i2); + } else if (typeof i2 === "function") { + normalized.push(i2); + } else if (typeof i2 === "object" && (i2.parse || i2.stringify)) { + if (true) { + throw new Error( + "PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation." + ); + } + } else { + throw new Error(i2 + " is not a PostCSS plugin"); + } + } + return normalized; + } + process(css, opts = {}) { + if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) { + return new NoWorkResult2$1(this, css, opts); + } else { + return new LazyResult$1$1(this, css, opts); + } + } + use(plugin22) { + this.plugins = this.plugins.concat(this.normalize([plugin22])); + return this; + } +}; +var processor$1 = Processor$1$1; +Processor$1$1.default = Processor$1$1; +Root$1$1.registerProcessor(Processor$1$1); +Document$1$1.registerProcessor(Processor$1$1); +var AtRule2$1 = atRule$1; +var Comment2$1 = comment$1; +var Container2$1 = container$1; +var CssSyntaxError2$1 = cssSyntaxError$1; +var Declaration2$1 = declaration$1; +var Document22 = document$1$1; +var fromJSON$2 = fromJSON_1$1; +var Input2$1 = input$1; +var LazyResult2$1 = lazyResult$1; +var list$3 = list_1$1; +var Node2$1 = node$1; +var parse$5 = parse_1$1; +var Processor2$1 = processor$1; +var Result2$1 = result$1; +var Root2$1 = root$1; +var Rule2$1 = rule$1; +var stringify$5 = stringify_1$1; +var Warning2$1 = warning$1; +function postcss$3(...plugins) { + if (plugins.length === 1 && Array.isArray(plugins[0])) { + plugins = plugins[0]; + } + return new Processor2$1(plugins); +} +postcss$3.plugin = function plugin(name, initializer) { + let warningPrinted = false; + function creator(...args) { + if (console && console.warn && !warningPrinted) { + warningPrinted = true; + console.warn( + name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration" + ); + if (process.env.LANG && process.env.LANG.startsWith("cn")) { + console.warn( + name + ": \u91CC\u9762 postcss.plugin \u88AB\u5F03\u7528. \u8FC1\u79FB\u6307\u5357:\nhttps://www.w3ctech.com/topic/2226" + ); + } + } + let transformer = initializer(...args); + transformer.postcssPlugin = name; + transformer.postcssVersion = new Processor2$1().version; + return transformer; + } + let cache; + Object.defineProperty(creator, "postcss", { + get() { + if (!cache) + cache = creator(); + return cache; + } + }); + creator.process = function(css, processOpts, pluginOpts) { + return postcss$3([creator(pluginOpts)]).process(css, processOpts); + }; + return creator; +}; +postcss$3.stringify = stringify$5; +postcss$3.parse = parse$5; +postcss$3.fromJSON = fromJSON$2; +postcss$3.list = list$3; +postcss$3.comment = (defaults) => new Comment2$1(defaults); +postcss$3.atRule = (defaults) => new AtRule2$1(defaults); +postcss$3.decl = (defaults) => new Declaration2$1(defaults); +postcss$3.rule = (defaults) => new Rule2$1(defaults); +postcss$3.root = (defaults) => new Root2$1(defaults); +postcss$3.document = (defaults) => new Document22(defaults); +postcss$3.CssSyntaxError = CssSyntaxError2$1; +postcss$3.Declaration = Declaration2$1; +postcss$3.Container = Container2$1; +postcss$3.Processor = Processor2$1; +postcss$3.Document = Document22; +postcss$3.Comment = Comment2$1; +postcss$3.Warning = Warning2$1; +postcss$3.AtRule = AtRule2$1; +postcss$3.Result = Result2$1; +postcss$3.Input = Input2$1; +postcss$3.Rule = Rule2$1; +postcss$3.Root = Root2$1; +postcss$3.Node = Node2$1; +LazyResult2$1.registerPostcss(postcss$3); +var postcss_1$1 = postcss$3; +postcss$3.default = postcss$3; +var postcss$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(postcss_1$1); +postcss$1$1.stringify; +postcss$1$1.fromJSON; +postcss$1$1.plugin; +postcss$1$1.parse; +postcss$1$1.list; +postcss$1$1.document; +postcss$1$1.comment; +postcss$1$1.atRule; +postcss$1$1.rule; +postcss$1$1.decl; +postcss$1$1.root; +postcss$1$1.CssSyntaxError; +postcss$1$1.Declaration; +postcss$1$1.Container; +postcss$1$1.Processor; +postcss$1$1.Document; +postcss$1$1.Comment; +postcss$1$1.Warning; +postcss$1$1.AtRule; +postcss$1$1.Result; +postcss$1$1.Input; +postcss$1$1.Rule; +postcss$1$1.Root; +postcss$1$1.Node; +var tagMap = { + script: "noscript", + // camel case svg element tag names + altglyph: "altGlyph", + altglyphdef: "altGlyphDef", + altglyphitem: "altGlyphItem", + animatecolor: "animateColor", + animatemotion: "animateMotion", + animatetransform: "animateTransform", + clippath: "clipPath", + feblend: "feBlend", + fecolormatrix: "feColorMatrix", + fecomponenttransfer: "feComponentTransfer", fecomposite: "feComposite", feconvolvematrix: "feConvolveMatrix", fediffuselighting: "feDiffuseLighting", @@ -2030,497 +5293,4164 @@ var tagMap = { lineargradient: "linearGradient", radialgradient: "radialGradient" }; -function getTagName(n2) { - let tagName = tagMap[n2.tagName] ? tagMap[n2.tagName] : n2.tagName; - if (tagName === "link" && n2.attributes._cssText) { - tagName = "style"; +function getTagName(n2) { + let tagName = tagMap[n2.tagName] ? tagMap[n2.tagName] : n2.tagName; + if (tagName === "link" && n2.attributes._cssText) { + tagName = "style"; + } + return tagName; +} +function adaptCssForReplay(cssText, cache) { + const cachedStyle = cache == null ? void 0 : cache.stylesWithHoverClass.get(cssText); + if (cachedStyle) + return cachedStyle; + let result2 = cssText; + try { + const ast = postcss$1$1([ + mediaSelectorPlugin, + pseudoClassPlugin + ]).process(cssText); + result2 = ast.css; + } catch (error) { + console.warn("Failed to adapt css for replay", error); + } + cache == null ? void 0 : cache.stylesWithHoverClass.set(cssText, result2); + return result2; +} +function createCache() { + const stylesWithHoverClass = /* @__PURE__ */ new Map(); + return { + stylesWithHoverClass + }; +} +function applyCssSplits(n2, cssText, hackCss, cache) { + const childTextNodes = []; + for (const scn of n2.childNodes) { + if (scn.type === NodeType$2.Text) { + childTextNodes.push(scn); + } + } + const cssTextSplits = cssText.split("/* rr_split */"); + while (cssTextSplits.length > 1 && cssTextSplits.length > childTextNodes.length) { + cssTextSplits.splice(-2, 2, cssTextSplits.slice(-2).join("")); + } + for (let i2 = 0; i2 < childTextNodes.length; i2++) { + const childTextNode = childTextNodes[i2]; + const cssTextSection = cssTextSplits[i2]; + if (childTextNode && cssTextSection) { + try { + childTextNode.textContent = hackCss ? adaptCssForReplay(cssTextSection, cache) : cssTextSection; + } catch (err) { + console.warn(`Highlight failed to set rrweb css ${err}`); + } + } + } +} +function buildStyleNode(n2, styleEl, cssText, options) { + const { doc, hackCss, cache } = options; + if (n2.childNodes.length) { + applyCssSplits(n2, cssText, hackCss, cache); + } else { + if (hackCss) { + cssText = adaptCssForReplay(cssText, cache); + } + styleEl.appendChild(doc.createTextNode(cssText)); + } +} +function buildNode(n2, options) { + var _a2; + const { doc, hackCss, cache } = options; + switch (n2.type) { + case NodeType$2.Document: + return doc.implementation.createDocument(null, "", null); + case NodeType$2.DocumentType: + return doc.implementation.createDocumentType( + n2.name || "html", + n2.publicId, + n2.systemId + ); + case NodeType$2.Element: { + const tagName = getTagName(n2); + let node2; + if (n2.isSVG) { + node2 = doc.createElementNS("http://www.w3.org/2000/svg", tagName); + } else { + if ( + // If the tag name is a custom element name + n2.isCustom && // If the browser supports custom elements + ((_a2 = doc.defaultView) == null ? void 0 : _a2.customElements) && // If the custom element hasn't been defined yet + !doc.defaultView.customElements.get(n2.tagName) + ) + doc.defaultView.customElements.define( + n2.tagName, + class extends doc.defaultView.HTMLElement { + } + ); + node2 = doc.createElement(tagName); + } + const specialAttributes = {}; + for (const name in n2.attributes) { + if (!Object.prototype.hasOwnProperty.call(n2.attributes, name)) { + continue; + } + let value = n2.attributes[name]; + if (tagName === "option" && name === "selected" && value === false) { + continue; + } + if (value === null) { + continue; + } + if (value === true) + value = ""; + if (name.startsWith("rr_")) { + specialAttributes[name] = value; + continue; + } + if (typeof value !== "string") + ; + else if (tagName === "style" && name === "_cssText") { + buildStyleNode(n2, node2, value, options); + continue; + } else if (tagName === "textarea" && name === "value") { + node2.appendChild(doc.createTextNode(value)); + try { + n2.childNodes = []; + } catch (err) { + console.warn(`Highlight failed to set rrweb text area child nodes ${err}`); + } + continue; + } + try { + if (n2.isSVG && name === "xlink:href") { + node2.setAttributeNS( + "http://www.w3.org/1999/xlink", + name, + value.toString() + ); + } else if (name === "onload" || name === "onclick" || name.substring(0, 7) === "onmouse") { + node2.setAttribute("_" + name, value.toString()); + } else if (tagName === "meta" && n2.attributes["http-equiv"] === "Content-Security-Policy" && name === "content") { + node2.setAttribute("csp-content", value.toString()); + continue; + } else if (tagName === "link" && (n2.attributes.rel === "preload" || n2.attributes.rel === "modulepreload") && n2.attributes.as === "script") { + } else if (tagName === "link" && n2.attributes.rel === "prefetch" && typeof n2.attributes.href === "string" && n2.attributes.href.endsWith(".js")) { + } else if (tagName === "img" && n2.attributes.srcset && n2.attributes.rr_dataURL) { + node2.setAttribute( + "rrweb-original-srcset", + n2.attributes.srcset + ); + } else { + node2.setAttribute(name, value.toString()); + } + } catch (error) { + } + } + for (const name in specialAttributes) { + const value = specialAttributes[name]; + if (tagName === "canvas" && name === "rr_dataURL") { + const image = doc.createElement("img"); + image.onload = () => { + const ctx = node2.getContext("2d"); + if (ctx) { + ctx.drawImage(image, 0, 0, image.width, image.height); + } + }; + image.src = value.toString(); + if (node2.RRNodeType) + node2.rr_dataURL = value.toString(); + } else if (tagName === "img" && name === "rr_dataURL") { + const image = node2; + if (!image.currentSrc.startsWith("data:")) { + image.setAttribute( + "rrweb-original-src", + n2.attributes.src + ); + image.src = value.toString(); + } + } + if (name === "rr_width") { + node2.style.setProperty("width", value.toString()); + } else if (name === "rr_height") { + node2.style.setProperty("height", value.toString()); + } else if (name === "rr_mediaCurrentTime" && typeof value === "number") { + node2.currentTime = value; + } else if (name === "rr_mediaState") { + switch (value) { + case "played": + node2.play().catch((e2) => console.warn("media playback error", e2)); + break; + case "paused": + node2.pause(); + break; + } + } else if (name === "rr_mediaPlaybackRate" && typeof value === "number") { + node2.playbackRate = value; + } else if (name === "rr_mediaMuted" && typeof value === "boolean") { + node2.muted = value; + } else if (name === "rr_mediaLoop" && typeof value === "boolean") { + node2.loop = value; + } else if (name === "rr_mediaVolume" && typeof value === "number") { + node2.volume = value; + } else if (name === "rr_open_mode") { + node2.setAttribute( + "rr_open_mode", + value + ); + } + } + if (n2.isShadowHost) { + if (!node2.shadowRoot) { + node2.attachShadow({ mode: "open" }); + } else { + while (node2.shadowRoot.firstChild) { + node2.shadowRoot.removeChild(node2.shadowRoot.firstChild); + } + } + } + return node2; + } + case NodeType$2.Text: + if (n2.isStyle && hackCss) { + return doc.createTextNode(adaptCssForReplay(n2.textContent, cache)); + } + return doc.createTextNode(n2.textContent); + case NodeType$2.CDATA: + return doc.createCDATASection(n2.textContent); + case NodeType$2.Comment: + return doc.createComment(n2.textContent); + default: + return null; + } +} +function buildNodeWithSN(n2, options) { + const { + doc, + mirror: mirror2, + skipChild = false, + hackCss = true, + afterAppend, + cache + } = options; + if (mirror2.has(n2.id)) { + const nodeInMirror = mirror2.getNode(n2.id); + const meta = mirror2.getMeta(nodeInMirror); + if (isNodeMetaEqual(meta, n2)) + return mirror2.getNode(n2.id); + } + let node2 = buildNode(n2, { doc, hackCss, cache }); + if (!node2) { + return null; + } + if (n2.rootId && mirror2.getNode(n2.rootId) !== doc) { + mirror2.replace(n2.rootId, doc); + } + if (n2.type === NodeType$2.Document) { + doc.close(); + doc.open(); + if (n2.compatMode === "BackCompat" && n2.childNodes && n2.childNodes[0].type !== NodeType$2.DocumentType) { + if (n2.childNodes[0].type === NodeType$2.Element && "xmlns" in n2.childNodes[0].attributes && n2.childNodes[0].attributes.xmlns === "http://www.w3.org/1999/xhtml") { + doc.write( + '' + ); + } else { + doc.write( + '' + ); + } + } + node2 = doc; + } + mirror2.add(node2, n2); + if ((n2.type === NodeType$2.Document || n2.type === NodeType$2.Element) && !skipChild) { + for (const childN of n2.childNodes) { + const childNode = buildNodeWithSN(childN, { + doc, + mirror: mirror2, + skipChild: false, + hackCss, + afterAppend, + cache + }); + if (!childNode) { + console.warn("Failed to rebuild", childN); + continue; + } + if (childN.isShadow && isElement(node2) && node2.shadowRoot) { + node2.shadowRoot.appendChild(childNode); + } else if (n2.type === NodeType$2.Document && childN.type == NodeType$2.Element) { + const htmlElement = childNode; + let body = null; + htmlElement.childNodes.forEach((child) => { + if (child.nodeName === "BODY") + body = child; + }); + if (body) { + htmlElement.removeChild(body); + node2.appendChild(childNode); + htmlElement.appendChild(body); + } else { + node2.appendChild(childNode); + } + } else { + node2.appendChild(childNode); + } + if (afterAppend) { + afterAppend(childNode, childN.id); + } + } + } + return node2; +} +function visit(mirror2, onVisit) { + function walk(node2) { + onVisit(node2); + } + for (const id of mirror2.getIds()) { + if (mirror2.has(id)) { + walk(mirror2.getNode(id)); + } + } +} +function handleScroll(node2, mirror2) { + const n2 = mirror2.getMeta(node2); + if ((n2 == null ? void 0 : n2.type) !== NodeType$2.Element) { + return; + } + const el = node2; + for (const name in n2.attributes) { + if (!(Object.prototype.hasOwnProperty.call(n2.attributes, name) && name.startsWith("rr_"))) { + continue; + } + const value = n2.attributes[name]; + if (name === "rr_scrollLeft") { + el.scrollLeft = value; + } + if (name === "rr_scrollTop") { + el.scrollTop = value; + } + } +} +function rebuild(n2, options) { + const { + doc, + onVisit, + hackCss = true, + afterAppend, + cache, + mirror: mirror2 = new Mirror() + } = options; + const node2 = buildNodeWithSN(n2, { + doc, + mirror: mirror2, + skipChild: false, + hackCss, + afterAppend, + cache + }); + visit(mirror2, (visitedNode) => { + if (onVisit) { + onVisit(visitedNode); + } + handleScroll(visitedNode, mirror2); + }); + return node2; +} +var __defProp2 = Object.defineProperty; +var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value); +var __defProp22 = Object.defineProperty; +var __defNormalProp22 = (obj, key, value) => key in obj ? __defProp22(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __publicField22 = (obj, key, value) => __defNormalProp22(obj, typeof key !== "symbol" ? key + "" : key, value); +var NodeType$1 = /* @__PURE__ */ ((NodeType2) => { + NodeType2[NodeType2["Document"] = 0] = "Document"; + NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType"; + NodeType2[NodeType2["Element"] = 2] = "Element"; + NodeType2[NodeType2["Text"] = 3] = "Text"; + NodeType2[NodeType2["CDATA"] = 4] = "CDATA"; + NodeType2[NodeType2["Comment"] = 5] = "Comment"; + return NodeType2; +})(NodeType$1 || {}); +var Mirror$1 = class Mirror2 { + constructor() { + __publicField22(this, "idNodeMap", /* @__PURE__ */ new Map()); + __publicField22(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap()); + } + getId(n2) { + var _a2; + if (!n2) + return -1; + const id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id; + return id ?? -1; + } + getNode(id) { + return this.idNodeMap.get(id) || null; + } + getIds() { + return Array.from(this.idNodeMap.keys()); + } + getMeta(n2) { + return this.nodeMetaMap.get(n2) || null; + } + // removes the node from idNodeMap + // doesn't remove the node from nodeMetaMap + removeNodeFromMap(n2) { + const id = this.getId(n2); + this.idNodeMap.delete(id); + if (n2.childNodes) { + n2.childNodes.forEach( + (childNode) => this.removeNodeFromMap(childNode) + ); + } + } + has(id) { + return this.idNodeMap.has(id); + } + hasNode(node2) { + return this.nodeMetaMap.has(node2); + } + add(n2, meta) { + const id = meta.id; + this.idNodeMap.set(id, n2); + this.nodeMetaMap.set(n2, meta); + } + replace(id, n2) { + const oldNode = this.getNode(id); + if (oldNode) { + const meta = this.nodeMetaMap.get(oldNode); + if (meta) + this.nodeMetaMap.set(n2, meta); + } + this.idNodeMap.set(id, n2); + } + reset() { + this.idNodeMap = /* @__PURE__ */ new Map(); + this.nodeMetaMap = /* @__PURE__ */ new WeakMap(); + } +}; +function createMirror$1() { + return new Mirror$1(); +} +function getDefaultExportFromCjs(x2) { + return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2; +} +function getAugmentedNamespace(n2) { + if (n2.__esModule) + return n2; + var f2 = n2.default; + if (typeof f2 == "function") { + var a2 = function a22() { + if (this instanceof a22) { + return Reflect.construct(f2, arguments, this.constructor); + } + return f2.apply(this, arguments); + }; + a2.prototype = f2.prototype; + } else + a2 = {}; + Object.defineProperty(a2, "__esModule", { value: true }); + Object.keys(n2).forEach(function(k) { + var d = Object.getOwnPropertyDescriptor(n2, k); + Object.defineProperty(a2, k, d.get ? d : { + enumerable: true, + get: function() { + return n2[k]; + } + }); + }); + return a2; +} +var picocolors_browser = { exports: {} }; +var x = String; +var create = function() { + return { isColorSupported: false, reset: x, bold: x, dim: x, italic: x, underline: x, inverse: x, hidden: x, strikethrough: x, black: x, red: x, green: x, yellow: x, blue: x, magenta: x, cyan: x, white: x, gray: x, bgBlack: x, bgRed: x, bgGreen: x, bgYellow: x, bgBlue: x, bgMagenta: x, bgCyan: x, bgWhite: x, blackBright: x, redBright: x, greenBright: x, yellowBright: x, blueBright: x, magentaBright: x, cyanBright: x, whiteBright: x, bgBlackBright: x, bgRedBright: x, bgGreenBright: x, bgYellowBright: x, bgBlueBright: x, bgMagentaBright: x, bgCyanBright: x, bgWhiteBright: x }; +}; +picocolors_browser.exports = create(); +picocolors_browser.exports.createColors = create; +var picocolors_browserExports = picocolors_browser.exports; +var __viteBrowserExternal = {}; +var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + default: __viteBrowserExternal +}, Symbol.toStringTag, { value: "Module" })); +var require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1); +var pico = picocolors_browserExports; +var terminalHighlight$1 = require$$2; +var CssSyntaxError$3 = class CssSyntaxError2 extends Error { + constructor(message, line, column, source, file, plugin22) { + super(message); + this.name = "CssSyntaxError"; + this.reason = message; + if (file) { + this.file = file; + } + if (source) { + this.source = source; + } + if (plugin22) { + this.plugin = plugin22; + } + if (typeof line !== "undefined" && typeof column !== "undefined") { + if (typeof line === "number") { + this.line = line; + this.column = column; + } else { + this.line = line.line; + this.column = line.column; + this.endLine = column.line; + this.endColumn = column.column; + } + } + this.setMessage(); + if (Error.captureStackTrace) { + Error.captureStackTrace(this, CssSyntaxError2); + } + } + setMessage() { + this.message = this.plugin ? this.plugin + ": " : ""; + this.message += this.file ? this.file : ""; + if (typeof this.line !== "undefined") { + this.message += ":" + this.line + ":" + this.column; + } + this.message += ": " + this.reason; + } + showSourceCode(color) { + if (!this.source) + return ""; + let css = this.source; + if (color == null) + color = pico.isColorSupported; + let aside = (text) => text; + let mark = (text) => text; + let highlight = (text) => text; + if (color) { + let { bold, gray, red } = pico.createColors(true); + mark = (text) => bold(red(text)); + aside = (text) => gray(text); + if (terminalHighlight$1) { + highlight = (text) => terminalHighlight$1(text); + } + } + let lines = css.split(/\r?\n/); + let start = Math.max(this.line - 3, 0); + let end = Math.min(this.line + 2, lines.length); + let maxWidth = String(end).length; + return lines.slice(start, end).map((line, index2) => { + let number = start + 1 + index2; + let gutter = " " + (" " + number).slice(-maxWidth) + " | "; + if (number === this.line) { + if (line.length > 160) { + let padding = 20; + let subLineStart = Math.max(0, this.column - padding); + let subLineEnd = Math.max( + this.column + padding, + this.endColumn + padding + ); + let subLine = line.slice(subLineStart, subLineEnd); + let spacing2 = aside(gutter.replace(/\d/g, " ")) + line.slice(0, Math.min(this.column - 1, padding - 1)).replace(/[^\t]/g, " "); + return mark(">") + aside(gutter) + highlight(subLine) + "\n " + spacing2 + mark("^"); + } + let spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, this.column - 1).replace(/[^\t]/g, " "); + return mark(">") + aside(gutter) + highlight(line) + "\n " + spacing + mark("^"); + } + return " " + aside(gutter) + highlight(line); + }).join("\n"); + } + toString() { + let code = this.showSourceCode(); + if (code) { + code = "\n\n" + code + "\n"; + } + return this.name + ": " + this.message + code; + } +}; +var cssSyntaxError = CssSyntaxError$3; +CssSyntaxError$3.default = CssSyntaxError$3; +var DEFAULT_RAW = { + after: "\n", + beforeClose: "\n", + beforeComment: "\n", + beforeDecl: "\n", + beforeOpen: " ", + beforeRule: "\n", + colon: ": ", + commentLeft: " ", + commentRight: " ", + emptyBody: "", + indent: " ", + semicolon: false +}; +function capitalize(str) { + return str[0].toUpperCase() + str.slice(1); +} +var Stringifier$2 = class Stringifier2 { + constructor(builder) { + this.builder = builder; + } + atrule(node2, semicolon) { + let name = "@" + node2.name; + let params = node2.params ? this.rawValue(node2, "params") : ""; + if (typeof node2.raws.afterName !== "undefined") { + name += node2.raws.afterName; + } else if (params) { + name += " "; + } + if (node2.nodes) { + this.block(node2, name + params); + } else { + let end = (node2.raws.between || "") + (semicolon ? ";" : ""); + this.builder(name + params + end, node2); + } + } + beforeAfter(node2, detect) { + let value; + if (node2.type === "decl") { + value = this.raw(node2, null, "beforeDecl"); + } else if (node2.type === "comment") { + value = this.raw(node2, null, "beforeComment"); + } else if (detect === "before") { + value = this.raw(node2, null, "beforeRule"); + } else { + value = this.raw(node2, null, "beforeClose"); + } + let buf = node2.parent; + let depth = 0; + while (buf && buf.type !== "root") { + depth += 1; + buf = buf.parent; + } + if (value.includes("\n")) { + let indent = this.raw(node2, null, "indent"); + if (indent.length) { + for (let step = 0; step < depth; step++) + value += indent; + } + } + return value; + } + block(node2, start) { + let between = this.raw(node2, "between", "beforeOpen"); + this.builder(start + between + "{", node2, "start"); + let after; + if (node2.nodes && node2.nodes.length) { + this.body(node2); + after = this.raw(node2, "after"); + } else { + after = this.raw(node2, "after", "emptyBody"); + } + if (after) + this.builder(after); + this.builder("}", node2, "end"); + } + body(node2) { + let last = node2.nodes.length - 1; + while (last > 0) { + if (node2.nodes[last].type !== "comment") + break; + last -= 1; + } + let semicolon = this.raw(node2, "semicolon"); + for (let i2 = 0; i2 < node2.nodes.length; i2++) { + let child = node2.nodes[i2]; + let before = this.raw(child, "before"); + if (before) + this.builder(before); + this.stringify(child, last !== i2 || semicolon); + } + } + comment(node2) { + let left = this.raw(node2, "left", "commentLeft"); + let right = this.raw(node2, "right", "commentRight"); + this.builder("/*" + left + node2.text + right + "*/", node2); + } + decl(node2, semicolon) { + let between = this.raw(node2, "between", "colon"); + let string = node2.prop + between + this.rawValue(node2, "value"); + if (node2.important) { + string += node2.raws.important || " !important"; + } + if (semicolon) + string += ";"; + this.builder(string, node2); + } + document(node2) { + this.body(node2); + } + raw(node2, own, detect) { + let value; + if (!detect) + detect = own; + if (own) { + value = node2.raws[own]; + if (typeof value !== "undefined") + return value; + } + let parent = node2.parent; + if (detect === "before") { + if (!parent || parent.type === "root" && parent.first === node2) { + return ""; + } + if (parent && parent.type === "document") { + return ""; + } + } + if (!parent) + return DEFAULT_RAW[detect]; + let root2 = node2.root(); + if (!root2.rawCache) + root2.rawCache = {}; + if (typeof root2.rawCache[detect] !== "undefined") { + return root2.rawCache[detect]; + } + if (detect === "before" || detect === "after") { + return this.beforeAfter(node2, detect); + } else { + let method = "raw" + capitalize(detect); + if (this[method]) { + value = this[method](root2, node2); + } else { + root2.walk((i2) => { + value = i2.raws[own]; + if (typeof value !== "undefined") + return false; + }); + } + } + if (typeof value === "undefined") + value = DEFAULT_RAW[detect]; + root2.rawCache[detect] = value; + return value; + } + rawBeforeClose(root2) { + let value; + root2.walk((i2) => { + if (i2.nodes && i2.nodes.length > 0) { + if (typeof i2.raws.after !== "undefined") { + value = i2.raws.after; + if (value.includes("\n")) { + value = value.replace(/[^\n]+$/, ""); + } + return false; + } + } + }); + if (value) + value = value.replace(/\S/g, ""); + return value; + } + rawBeforeComment(root2, node2) { + let value; + root2.walkComments((i2) => { + if (typeof i2.raws.before !== "undefined") { + value = i2.raws.before; + if (value.includes("\n")) { + value = value.replace(/[^\n]+$/, ""); + } + return false; + } + }); + if (typeof value === "undefined") { + value = this.raw(node2, null, "beforeDecl"); + } else if (value) { + value = value.replace(/\S/g, ""); + } + return value; + } + rawBeforeDecl(root2, node2) { + let value; + root2.walkDecls((i2) => { + if (typeof i2.raws.before !== "undefined") { + value = i2.raws.before; + if (value.includes("\n")) { + value = value.replace(/[^\n]+$/, ""); + } + return false; + } + }); + if (typeof value === "undefined") { + value = this.raw(node2, null, "beforeRule"); + } else if (value) { + value = value.replace(/\S/g, ""); + } + return value; + } + rawBeforeOpen(root2) { + let value; + root2.walk((i2) => { + if (i2.type !== "decl") { + value = i2.raws.between; + if (typeof value !== "undefined") + return false; + } + }); + return value; + } + rawBeforeRule(root2) { + let value; + root2.walk((i2) => { + if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) { + if (typeof i2.raws.before !== "undefined") { + value = i2.raws.before; + if (value.includes("\n")) { + value = value.replace(/[^\n]+$/, ""); + } + return false; + } + } + }); + if (value) + value = value.replace(/\S/g, ""); + return value; + } + rawColon(root2) { + let value; + root2.walkDecls((i2) => { + if (typeof i2.raws.between !== "undefined") { + value = i2.raws.between.replace(/[^\s:]/g, ""); + return false; + } + }); + return value; + } + rawEmptyBody(root2) { + let value; + root2.walk((i2) => { + if (i2.nodes && i2.nodes.length === 0) { + value = i2.raws.after; + if (typeof value !== "undefined") + return false; + } + }); + return value; + } + rawIndent(root2) { + if (root2.raws.indent) + return root2.raws.indent; + let value; + root2.walk((i2) => { + let p = i2.parent; + if (p && p !== root2 && p.parent && p.parent === root2) { + if (typeof i2.raws.before !== "undefined") { + let parts = i2.raws.before.split("\n"); + value = parts[parts.length - 1]; + value = value.replace(/\S/g, ""); + return false; + } + } + }); + return value; + } + rawSemicolon(root2) { + let value; + root2.walk((i2) => { + if (i2.nodes && i2.nodes.length && i2.last.type === "decl") { + value = i2.raws.semicolon; + if (typeof value !== "undefined") + return false; + } + }); + return value; + } + rawValue(node2, prop) { + let value = node2[prop]; + let raw = node2.raws[prop]; + if (raw && raw.value === value) { + return raw.raw; + } + return value; + } + root(node2) { + this.body(node2); + if (node2.raws.after) + this.builder(node2.raws.after); + } + rule(node2) { + this.block(node2, this.rawValue(node2, "selector")); + if (node2.raws.ownSemicolon) { + this.builder(node2.raws.ownSemicolon, node2, "end"); + } + } + stringify(node2, semicolon) { + if (!this[node2.type]) { + throw new Error( + "Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier." + ); + } + this[node2.type](node2, semicolon); + } +}; +var stringifier = Stringifier$2; +Stringifier$2.default = Stringifier$2; +var Stringifier$1 = stringifier; +function stringify$4(node2, builder) { + let str = new Stringifier$1(builder); + str.stringify(node2); +} +var stringify_1 = stringify$4; +stringify$4.default = stringify$4; +var symbols = {}; +symbols.isClean = Symbol("isClean"); +symbols.my = Symbol("my"); +var CssSyntaxError$2 = cssSyntaxError; +var Stringifier22 = stringifier; +var stringify$3 = stringify_1; +var { isClean: isClean$2, my: my$2 } = symbols; +function cloneNode(obj, parent) { + let cloned = new obj.constructor(); + for (let i2 in obj) { + if (!Object.prototype.hasOwnProperty.call(obj, i2)) { + continue; + } + if (i2 === "proxyCache") + continue; + let value = obj[i2]; + let type = typeof value; + if (i2 === "parent" && type === "object") { + if (parent) + cloned[i2] = parent; + } else if (i2 === "source") { + cloned[i2] = value; + } else if (Array.isArray(value)) { + cloned[i2] = value.map((j) => cloneNode(j, cloned)); + } else { + if (type === "object" && value !== null) + value = cloneNode(value); + cloned[i2] = value; + } + } + return cloned; +} +var Node$4 = class Node3 { + constructor(defaults = {}) { + this.raws = {}; + this[isClean$2] = false; + this[my$2] = true; + for (let name in defaults) { + if (name === "nodes") { + this.nodes = []; + for (let node2 of defaults[name]) { + if (typeof node2.clone === "function") { + this.append(node2.clone()); + } else { + this.append(node2); + } + } + } else { + this[name] = defaults[name]; + } + } + } + addToError(error) { + error.postcssNode = this; + if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) { + let s2 = this.source; + error.stack = error.stack.replace( + /\n\s{4}at /, + `$&${s2.input.from}:${s2.start.line}:${s2.start.column}$&` + ); + } + return error; + } + after(add) { + this.parent.insertAfter(this, add); + return this; + } + assign(overrides = {}) { + for (let name in overrides) { + this[name] = overrides[name]; + } + return this; + } + before(add) { + this.parent.insertBefore(this, add); + return this; + } + cleanRaws(keepBetween) { + delete this.raws.before; + delete this.raws.after; + if (!keepBetween) + delete this.raws.between; + } + clone(overrides = {}) { + let cloned = cloneNode(this); + for (let name in overrides) { + cloned[name] = overrides[name]; + } + return cloned; + } + cloneAfter(overrides = {}) { + let cloned = this.clone(overrides); + this.parent.insertAfter(this, cloned); + return cloned; + } + cloneBefore(overrides = {}) { + let cloned = this.clone(overrides); + this.parent.insertBefore(this, cloned); + return cloned; + } + error(message, opts = {}) { + if (this.source) { + let { end, start } = this.rangeBy(opts); + return this.source.input.error( + message, + { column: start.column, line: start.line }, + { column: end.column, line: end.line }, + opts + ); + } + return new CssSyntaxError$2(message); + } + getProxyProcessor() { + return { + get(node2, prop) { + if (prop === "proxyOf") { + return node2; + } else if (prop === "root") { + return () => node2.root().toProxy(); + } else { + return node2[prop]; + } + }, + set(node2, prop, value) { + if (node2[prop] === value) + return true; + node2[prop] = value; + if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ + prop === "text") { + node2.markDirty(); + } + return true; + } + }; + } + /* c8 ignore next 3 */ + markClean() { + this[isClean$2] = true; + } + markDirty() { + if (this[isClean$2]) { + this[isClean$2] = false; + let next = this; + while (next = next.parent) { + next[isClean$2] = false; + } + } + } + next() { + if (!this.parent) + return void 0; + let index2 = this.parent.index(this); + return this.parent.nodes[index2 + 1]; + } + positionBy(opts, stringRepresentation) { + let pos = this.source.start; + if (opts.index) { + pos = this.positionInside(opts.index, stringRepresentation); + } else if (opts.word) { + stringRepresentation = this.toString(); + let index2 = stringRepresentation.indexOf(opts.word); + if (index2 !== -1) + pos = this.positionInside(index2, stringRepresentation); + } + return pos; + } + positionInside(index2, stringRepresentation) { + let string = stringRepresentation || this.toString(); + let column = this.source.start.column; + let line = this.source.start.line; + for (let i2 = 0; i2 < index2; i2++) { + if (string[i2] === "\n") { + column = 1; + line += 1; + } else { + column += 1; + } + } + return { column, line }; + } + prev() { + if (!this.parent) + return void 0; + let index2 = this.parent.index(this); + return this.parent.nodes[index2 - 1]; + } + rangeBy(opts) { + let start = { + column: this.source.start.column, + line: this.source.start.line + }; + let end = this.source.end ? { + column: this.source.end.column + 1, + line: this.source.end.line + } : { + column: start.column + 1, + line: start.line + }; + if (opts.word) { + let stringRepresentation = this.toString(); + let index2 = stringRepresentation.indexOf(opts.word); + if (index2 !== -1) { + start = this.positionInside(index2, stringRepresentation); + end = this.positionInside( + index2 + opts.word.length, + stringRepresentation + ); + } + } else { + if (opts.start) { + start = { + column: opts.start.column, + line: opts.start.line + }; + } else if (opts.index) { + start = this.positionInside(opts.index); + } + if (opts.end) { + end = { + column: opts.end.column, + line: opts.end.line + }; + } else if (typeof opts.endIndex === "number") { + end = this.positionInside(opts.endIndex); + } else if (opts.index) { + end = this.positionInside(opts.index + 1); + } + } + if (end.line < start.line || end.line === start.line && end.column <= start.column) { + end = { column: start.column + 1, line: start.line }; + } + return { end, start }; + } + raw(prop, defaultType) { + let str = new Stringifier22(); + return str.raw(this, prop, defaultType); + } + remove() { + if (this.parent) { + this.parent.removeChild(this); + } + this.parent = void 0; + return this; + } + replaceWith(...nodes) { + if (this.parent) { + let bookmark = this; + let foundSelf = false; + for (let node2 of nodes) { + if (node2 === this) { + foundSelf = true; + } else if (foundSelf) { + this.parent.insertAfter(bookmark, node2); + bookmark = node2; + } else { + this.parent.insertBefore(bookmark, node2); + } + } + if (!foundSelf) { + this.remove(); + } + } + return this; + } + root() { + let result2 = this; + while (result2.parent && result2.parent.type !== "document") { + result2 = result2.parent; + } + return result2; + } + toJSON(_, inputs) { + let fixed = {}; + let emitInputs = inputs == null; + inputs = inputs || /* @__PURE__ */ new Map(); + let inputsNextIndex = 0; + for (let name in this) { + if (!Object.prototype.hasOwnProperty.call(this, name)) { + continue; + } + if (name === "parent" || name === "proxyCache") + continue; + let value = this[name]; + if (Array.isArray(value)) { + fixed[name] = value.map((i2) => { + if (typeof i2 === "object" && i2.toJSON) { + return i2.toJSON(null, inputs); + } else { + return i2; + } + }); + } else if (typeof value === "object" && value.toJSON) { + fixed[name] = value.toJSON(null, inputs); + } else if (name === "source") { + let inputId = inputs.get(value.input); + if (inputId == null) { + inputId = inputsNextIndex; + inputs.set(value.input, inputsNextIndex); + inputsNextIndex++; + } + fixed[name] = { + end: value.end, + inputId, + start: value.start + }; + } else { + fixed[name] = value; + } + } + if (emitInputs) { + fixed.inputs = [...inputs.keys()].map((input2) => input2.toJSON()); + } + return fixed; + } + toProxy() { + if (!this.proxyCache) { + this.proxyCache = new Proxy(this, this.getProxyProcessor()); + } + return this.proxyCache; + } + toString(stringifier2 = stringify$3) { + if (stringifier2.stringify) + stringifier2 = stringifier2.stringify; + let result2 = ""; + stringifier2(this, (i2) => { + result2 += i2; + }); + return result2; + } + warn(result2, text, opts) { + let data = { node: this }; + for (let i2 in opts) + data[i2] = opts[i2]; + return result2.warn(text, data); + } + get proxyOf() { + return this; + } +}; +var node = Node$4; +Node$4.default = Node$4; +var Node$3 = node; +var Comment$4 = class Comment2 extends Node$3 { + constructor(defaults) { + super(defaults); + this.type = "comment"; + } +}; +var comment = Comment$4; +Comment$4.default = Comment$4; +var Node$2 = node; +var Declaration$4 = class Declaration2 extends Node$2 { + constructor(defaults) { + if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") { + defaults = { ...defaults, value: String(defaults.value) }; + } + super(defaults); + this.type = "decl"; + } + get variable() { + return this.prop.startsWith("--") || this.prop[0] === "$"; + } +}; +var declaration = Declaration$4; +Declaration$4.default = Declaration$4; +var Comment$3 = comment; +var Declaration$3 = declaration; +var Node$1 = node; +var { isClean: isClean$1, my: my$1 } = symbols; +var AtRule$4; +var parse$4; +var Root$6; +var Rule$4; +function cleanSource(nodes) { + return nodes.map((i2) => { + if (i2.nodes) + i2.nodes = cleanSource(i2.nodes); + delete i2.source; + return i2; + }); +} +function markTreeDirty(node2) { + node2[isClean$1] = false; + if (node2.proxyOf.nodes) { + for (let i2 of node2.proxyOf.nodes) { + markTreeDirty(i2); + } + } +} +var Container$7 = class Container2 extends Node$1 { + append(...children) { + for (let child of children) { + let nodes = this.normalize(child, this.last); + for (let node2 of nodes) + this.proxyOf.nodes.push(node2); + } + this.markDirty(); + return this; + } + cleanRaws(keepBetween) { + super.cleanRaws(keepBetween); + if (this.nodes) { + for (let node2 of this.nodes) + node2.cleanRaws(keepBetween); + } + } + each(callback) { + if (!this.proxyOf.nodes) + return void 0; + let iterator = this.getIterator(); + let index2, result2; + while (this.indexes[iterator] < this.proxyOf.nodes.length) { + index2 = this.indexes[iterator]; + result2 = callback(this.proxyOf.nodes[index2], index2); + if (result2 === false) + break; + this.indexes[iterator] += 1; + } + delete this.indexes[iterator]; + return result2; + } + every(condition) { + return this.nodes.every(condition); + } + getIterator() { + if (!this.lastEach) + this.lastEach = 0; + if (!this.indexes) + this.indexes = {}; + this.lastEach += 1; + let iterator = this.lastEach; + this.indexes[iterator] = 0; + return iterator; + } + getProxyProcessor() { + return { + get(node2, prop) { + if (prop === "proxyOf") { + return node2; + } else if (!node2[prop]) { + return node2[prop]; + } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) { + return (...args) => { + return node2[prop]( + ...args.map((i2) => { + if (typeof i2 === "function") { + return (child, index2) => i2(child.toProxy(), index2); + } else { + return i2; + } + }) + ); + }; + } else if (prop === "every" || prop === "some") { + return (cb) => { + return node2[prop]( + (child, ...other) => cb(child.toProxy(), ...other) + ); + }; + } else if (prop === "root") { + return () => node2.root().toProxy(); + } else if (prop === "nodes") { + return node2.nodes.map((i2) => i2.toProxy()); + } else if (prop === "first" || prop === "last") { + return node2[prop].toProxy(); + } else { + return node2[prop]; + } + }, + set(node2, prop, value) { + if (node2[prop] === value) + return true; + node2[prop] = value; + if (prop === "name" || prop === "params" || prop === "selector") { + node2.markDirty(); + } + return true; + } + }; + } + index(child) { + if (typeof child === "number") + return child; + if (child.proxyOf) + child = child.proxyOf; + return this.proxyOf.nodes.indexOf(child); + } + insertAfter(exist, add) { + let existIndex = this.index(exist); + let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse(); + existIndex = this.index(exist); + for (let node2 of nodes) + this.proxyOf.nodes.splice(existIndex + 1, 0, node2); + let index2; + for (let id in this.indexes) { + index2 = this.indexes[id]; + if (existIndex < index2) { + this.indexes[id] = index2 + nodes.length; + } + } + this.markDirty(); + return this; + } + insertBefore(exist, add) { + let existIndex = this.index(exist); + let type = existIndex === 0 ? "prepend" : false; + let nodes = this.normalize( + add, + this.proxyOf.nodes[existIndex], + type + ).reverse(); + existIndex = this.index(exist); + for (let node2 of nodes) + this.proxyOf.nodes.splice(existIndex, 0, node2); + let index2; + for (let id in this.indexes) { + index2 = this.indexes[id]; + if (existIndex <= index2) { + this.indexes[id] = index2 + nodes.length; + } + } + this.markDirty(); + return this; + } + normalize(nodes, sample) { + if (typeof nodes === "string") { + nodes = cleanSource(parse$4(nodes).nodes); + } else if (typeof nodes === "undefined") { + nodes = []; + } else if (Array.isArray(nodes)) { + nodes = nodes.slice(0); + for (let i2 of nodes) { + if (i2.parent) + i2.parent.removeChild(i2, "ignore"); + } + } else if (nodes.type === "root" && this.type !== "document") { + nodes = nodes.nodes.slice(0); + for (let i2 of nodes) { + if (i2.parent) + i2.parent.removeChild(i2, "ignore"); + } + } else if (nodes.type) { + nodes = [nodes]; + } else if (nodes.prop) { + if (typeof nodes.value === "undefined") { + throw new Error("Value field is missed in node creation"); + } else if (typeof nodes.value !== "string") { + nodes.value = String(nodes.value); + } + nodes = [new Declaration$3(nodes)]; + } else if (nodes.selector || nodes.selectors) { + nodes = [new Rule$4(nodes)]; + } else if (nodes.name) { + nodes = [new AtRule$4(nodes)]; + } else if (nodes.text) { + nodes = [new Comment$3(nodes)]; + } else { + throw new Error("Unknown node type in node creation"); + } + let processed = nodes.map((i2) => { + if (!i2[my$1]) + Container2.rebuild(i2); + i2 = i2.proxyOf; + if (i2.parent) + i2.parent.removeChild(i2); + if (i2[isClean$1]) + markTreeDirty(i2); + if (!i2.raws) + i2.raws = {}; + if (typeof i2.raws.before === "undefined") { + if (sample && typeof sample.raws.before !== "undefined") { + i2.raws.before = sample.raws.before.replace(/\S/g, ""); + } + } + i2.parent = this.proxyOf; + return i2; + }); + return processed; + } + prepend(...children) { + children = children.reverse(); + for (let child of children) { + let nodes = this.normalize(child, this.first, "prepend").reverse(); + for (let node2 of nodes) + this.proxyOf.nodes.unshift(node2); + for (let id in this.indexes) { + this.indexes[id] = this.indexes[id] + nodes.length; + } + } + this.markDirty(); + return this; + } + push(child) { + child.parent = this; + this.proxyOf.nodes.push(child); + return this; + } + removeAll() { + for (let node2 of this.proxyOf.nodes) + node2.parent = void 0; + this.proxyOf.nodes = []; + this.markDirty(); + return this; + } + removeChild(child) { + child = this.index(child); + this.proxyOf.nodes[child].parent = void 0; + this.proxyOf.nodes.splice(child, 1); + let index2; + for (let id in this.indexes) { + index2 = this.indexes[id]; + if (index2 >= child) { + this.indexes[id] = index2 - 1; + } + } + this.markDirty(); + return this; + } + replaceValues(pattern, opts, callback) { + if (!callback) { + callback = opts; + opts = {}; + } + this.walkDecls((decl) => { + if (opts.props && !opts.props.includes(decl.prop)) + return; + if (opts.fast && !decl.value.includes(opts.fast)) + return; + decl.value = decl.value.replace(pattern, callback); + }); + this.markDirty(); + return this; + } + some(condition) { + return this.nodes.some(condition); + } + walk(callback) { + return this.each((child, i2) => { + let result2; + try { + result2 = callback(child, i2); + } catch (e2) { + throw child.addToError(e2); + } + if (result2 !== false && child.walk) { + result2 = child.walk(callback); + } + return result2; + }); + } + walkAtRules(name, callback) { + if (!callback) { + callback = name; + return this.walk((child, i2) => { + if (child.type === "atrule") { + return callback(child, i2); + } + }); + } + if (name instanceof RegExp) { + return this.walk((child, i2) => { + if (child.type === "atrule" && name.test(child.name)) { + return callback(child, i2); + } + }); + } + return this.walk((child, i2) => { + if (child.type === "atrule" && child.name === name) { + return callback(child, i2); + } + }); + } + walkComments(callback) { + return this.walk((child, i2) => { + if (child.type === "comment") { + return callback(child, i2); + } + }); + } + walkDecls(prop, callback) { + if (!callback) { + callback = prop; + return this.walk((child, i2) => { + if (child.type === "decl") { + return callback(child, i2); + } + }); + } + if (prop instanceof RegExp) { + return this.walk((child, i2) => { + if (child.type === "decl" && prop.test(child.prop)) { + return callback(child, i2); + } + }); + } + return this.walk((child, i2) => { + if (child.type === "decl" && child.prop === prop) { + return callback(child, i2); + } + }); + } + walkRules(selector, callback) { + if (!callback) { + callback = selector; + return this.walk((child, i2) => { + if (child.type === "rule") { + return callback(child, i2); + } + }); + } + if (selector instanceof RegExp) { + return this.walk((child, i2) => { + if (child.type === "rule" && selector.test(child.selector)) { + return callback(child, i2); + } + }); + } + return this.walk((child, i2) => { + if (child.type === "rule" && child.selector === selector) { + return callback(child, i2); + } + }); + } + get first() { + if (!this.proxyOf.nodes) + return void 0; + return this.proxyOf.nodes[0]; + } + get last() { + if (!this.proxyOf.nodes) + return void 0; + return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]; + } +}; +Container$7.registerParse = (dependant) => { + parse$4 = dependant; +}; +Container$7.registerRule = (dependant) => { + Rule$4 = dependant; +}; +Container$7.registerAtRule = (dependant) => { + AtRule$4 = dependant; +}; +Container$7.registerRoot = (dependant) => { + Root$6 = dependant; +}; +var container = Container$7; +Container$7.default = Container$7; +Container$7.rebuild = (node2) => { + if (node2.type === "atrule") { + Object.setPrototypeOf(node2, AtRule$4.prototype); + } else if (node2.type === "rule") { + Object.setPrototypeOf(node2, Rule$4.prototype); + } else if (node2.type === "decl") { + Object.setPrototypeOf(node2, Declaration$3.prototype); + } else if (node2.type === "comment") { + Object.setPrototypeOf(node2, Comment$3.prototype); + } else if (node2.type === "root") { + Object.setPrototypeOf(node2, Root$6.prototype); + } + node2[my$1] = true; + if (node2.nodes) { + node2.nodes.forEach((child) => { + Container$7.rebuild(child); + }); + } +}; +var Container$6 = container; +var AtRule$3 = class AtRule2 extends Container$6 { + constructor(defaults) { + super(defaults); + this.type = "atrule"; + } + append(...children) { + if (!this.proxyOf.nodes) + this.nodes = []; + return super.append(...children); + } + prepend(...children) { + if (!this.proxyOf.nodes) + this.nodes = []; + return super.prepend(...children); + } +}; +var atRule = AtRule$3; +AtRule$3.default = AtRule$3; +Container$6.registerAtRule(AtRule$3); +var Container$5 = container; +var LazyResult$4; +var Processor$3; +var Document$3 = class Document23 extends Container$5 { + constructor(defaults) { + super({ type: "document", ...defaults }); + if (!this.nodes) { + this.nodes = []; + } + } + toResult(opts = {}) { + let lazy = new LazyResult$4(new Processor$3(), this, opts); + return lazy.stringify(); + } +}; +Document$3.registerLazyResult = (dependant) => { + LazyResult$4 = dependant; +}; +Document$3.registerProcessor = (dependant) => { + Processor$3 = dependant; +}; +var document$1 = Document$3; +Document$3.default = Document$3; +var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"; +var customAlphabet = (alphabet, defaultSize = 21) => { + return (size = defaultSize) => { + let id = ""; + let i2 = size; + while (i2--) { + id += alphabet[Math.random() * alphabet.length | 0]; + } + return id; + }; +}; +var nanoid$1 = (size = 21) => { + let id = ""; + let i2 = size; + while (i2--) { + id += urlAlphabet[Math.random() * 64 | 0]; + } + return id; +}; +var nonSecure = { nanoid: nanoid$1, customAlphabet }; +var { existsSync, readFileSync } = require$$2; +var { dirname: dirname$1, join } = require$$2; +var { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$2 } = require$$2; +function fromBase64(str) { + if (Buffer) { + return Buffer.from(str, "base64").toString(); + } else { + return window.atob(str); + } +} +var PreviousMap$2 = class PreviousMap2 { + constructor(css, opts) { + if (opts.map === false) + return; + this.loadAnnotation(css); + this.inline = this.startWith(this.annotation, "data:"); + let prev = opts.map ? opts.map.prev : void 0; + let text = this.loadMap(opts.from, prev); + if (!this.mapFile && opts.from) { + this.mapFile = opts.from; + } + if (this.mapFile) + this.root = dirname$1(this.mapFile); + if (text) + this.text = text; + } + consumer() { + if (!this.consumerCache) { + this.consumerCache = new SourceMapConsumer$2(this.text); + } + return this.consumerCache; + } + decodeInline(text) { + let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/; + let baseUri = /^data:application\/json;base64,/; + let charsetUri = /^data:application\/json;charset=utf-?8,/; + let uri = /^data:application\/json,/; + let uriMatch = text.match(charsetUri) || text.match(uri); + if (uriMatch) { + return decodeURIComponent(text.substr(uriMatch[0].length)); + } + let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri); + if (baseUriMatch) { + return fromBase64(text.substr(baseUriMatch[0].length)); + } + let encoding = text.match(/data:application\/json;([^,]+),/)[1]; + throw new Error("Unsupported source map encoding " + encoding); + } + getAnnotationURL(sourceMapString) { + return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim(); + } + isMap(map) { + if (typeof map !== "object") + return false; + return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections); + } + loadAnnotation(css) { + let comments = css.match(/\/\*\s*# sourceMappingURL=/g); + if (!comments) + return; + let start = css.lastIndexOf(comments.pop()); + let end = css.indexOf("*/", start); + if (start > -1 && end > -1) { + this.annotation = this.getAnnotationURL(css.substring(start, end)); + } + } + loadFile(path) { + this.root = dirname$1(path); + if (existsSync(path)) { + this.mapFile = path; + return readFileSync(path, "utf-8").toString().trim(); + } + } + loadMap(file, prev) { + if (prev === false) + return false; + if (prev) { + if (typeof prev === "string") { + return prev; + } else if (typeof prev === "function") { + let prevPath = prev(file); + if (prevPath) { + let map = this.loadFile(prevPath); + if (!map) { + throw new Error( + "Unable to load previous source map: " + prevPath.toString() + ); + } + return map; + } + } else if (prev instanceof SourceMapConsumer$2) { + return SourceMapGenerator$2.fromSourceMap(prev).toString(); + } else if (prev instanceof SourceMapGenerator$2) { + return prev.toString(); + } else if (this.isMap(prev)) { + return JSON.stringify(prev); + } else { + throw new Error( + "Unsupported previous source map format: " + prev.toString() + ); + } + } else if (this.inline) { + return this.decodeInline(this.annotation); + } else if (this.annotation) { + let map = this.annotation; + if (file) + map = join(dirname$1(file), map); + return this.loadFile(map); + } + } + startWith(string, start) { + if (!string) + return false; + return string.substr(0, start.length) === start; + } + withContent() { + return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0); + } +}; +var previousMap = PreviousMap$2; +PreviousMap$2.default = PreviousMap$2; +var { nanoid } = nonSecure; +var { isAbsolute, resolve: resolve$1 } = require$$2; +var { SourceMapConsumer: SourceMapConsumer$1, SourceMapGenerator: SourceMapGenerator$1 } = require$$2; +var { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2; +var CssSyntaxError$1 = cssSyntaxError; +var PreviousMap$1 = previousMap; +var terminalHighlight = require$$2; +var fromOffsetCache = Symbol("fromOffsetCache"); +var sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1); +var pathAvailable$1 = Boolean(resolve$1 && isAbsolute); +var Input$4 = class Input2 { + constructor(css, opts = {}) { + if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) { + throw new Error(`PostCSS received ${css} instead of CSS string`); + } + this.css = css.toString(); + if (this.css[0] === "\uFEFF" || this.css[0] === "\uFFFE") { + this.hasBOM = true; + this.css = this.css.slice(1); + } else { + this.hasBOM = false; + } + if (opts.from) { + if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) { + this.file = opts.from; + } else { + this.file = resolve$1(opts.from); + } + } + if (pathAvailable$1 && sourceMapAvailable$1) { + let map = new PreviousMap$1(this.css, opts); + if (map.text) { + this.map = map; + let file = map.consumer().file; + if (!this.file && file) + this.file = this.mapResolve(file); + } + } + if (!this.file) { + this.id = ""; + } + if (this.map) + this.map.file = this.from; + } + error(message, line, column, opts = {}) { + let endColumn, endLine, result2; + if (line && typeof line === "object") { + let start = line; + let end = column; + if (typeof start.offset === "number") { + let pos = this.fromOffset(start.offset); + line = pos.line; + column = pos.col; + } else { + line = start.line; + column = start.column; + } + if (typeof end.offset === "number") { + let pos = this.fromOffset(end.offset); + endLine = pos.line; + endColumn = pos.col; + } else { + endLine = end.line; + endColumn = end.column; + } + } else if (!column) { + let pos = this.fromOffset(line); + line = pos.line; + column = pos.col; + } + let origin = this.origin(line, column, endLine, endColumn); + if (origin) { + result2 = new CssSyntaxError$1( + message, + origin.endLine === void 0 ? origin.line : { column: origin.column, line: origin.line }, + origin.endLine === void 0 ? origin.column : { column: origin.endColumn, line: origin.endLine }, + origin.source, + origin.file, + opts.plugin + ); + } else { + result2 = new CssSyntaxError$1( + message, + endLine === void 0 ? line : { column, line }, + endLine === void 0 ? column : { column: endColumn, line: endLine }, + this.css, + this.file, + opts.plugin + ); + } + result2.input = { column, endColumn, endLine, line, source: this.css }; + if (this.file) { + if (pathToFileURL$1) { + result2.input.url = pathToFileURL$1(this.file).toString(); + } + result2.input.file = this.file; + } + return result2; + } + fromOffset(offset) { + let lastLine, lineToIndex; + if (!this[fromOffsetCache]) { + let lines = this.css.split("\n"); + lineToIndex = new Array(lines.length); + let prevIndex = 0; + for (let i2 = 0, l2 = lines.length; i2 < l2; i2++) { + lineToIndex[i2] = prevIndex; + prevIndex += lines[i2].length + 1; + } + this[fromOffsetCache] = lineToIndex; + } else { + lineToIndex = this[fromOffsetCache]; + } + lastLine = lineToIndex[lineToIndex.length - 1]; + let min = 0; + if (offset >= lastLine) { + min = lineToIndex.length - 1; + } else { + let max = lineToIndex.length - 2; + let mid; + while (min < max) { + mid = min + (max - min >> 1); + if (offset < lineToIndex[mid]) { + max = mid - 1; + } else if (offset >= lineToIndex[mid + 1]) { + min = mid + 1; + } else { + min = mid; + break; + } + } + } + return { + col: offset - lineToIndex[min] + 1, + line: min + 1 + }; + } + mapResolve(file) { + if (/^\w+:\/\//.test(file)) { + return file; + } + return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file); + } + origin(line, column, endLine, endColumn) { + if (!this.map) + return false; + let consumer = this.map.consumer(); + let from = consumer.originalPositionFor({ column, line }); + if (!from.source) + return false; + let to; + if (typeof endLine === "number") { + to = consumer.originalPositionFor({ column: endColumn, line: endLine }); + } + let fromUrl; + if (isAbsolute(from.source)) { + fromUrl = pathToFileURL$1(from.source); + } else { + fromUrl = new URL( + from.source, + this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile) + ); + } + let result2 = { + column: from.column, + endColumn: to && to.column, + endLine: to && to.line, + line: from.line, + url: fromUrl.toString() + }; + if (fromUrl.protocol === "file:") { + if (fileURLToPath) { + result2.file = fileURLToPath(fromUrl); + } else { + throw new Error(`file: protocol is not available in this PostCSS build`); + } + } + let source = consumer.sourceContentFor(from.source); + if (source) + result2.source = source; + return result2; + } + toJSON() { + let json = {}; + for (let name of ["hasBOM", "css", "file", "id"]) { + if (this[name] != null) { + json[name] = this[name]; + } + } + if (this.map) { + json.map = { ...this.map }; + if (json.map.consumerCache) { + json.map.consumerCache = void 0; + } + } + return json; + } + get from() { + return this.file || this.id; + } +}; +var input = Input$4; +Input$4.default = Input$4; +if (terminalHighlight && terminalHighlight.registerInput) { + terminalHighlight.registerInput(Input$4); +} +var Container$4 = container; +var LazyResult$3; +var Processor$2; +var Root$5 = class Root2 extends Container$4 { + constructor(defaults) { + super(defaults); + this.type = "root"; + if (!this.nodes) + this.nodes = []; + } + normalize(child, sample, type) { + let nodes = super.normalize(child); + if (sample) { + if (type === "prepend") { + if (this.nodes.length > 1) { + sample.raws.before = this.nodes[1].raws.before; + } else { + delete sample.raws.before; + } + } else if (this.first !== sample) { + for (let node2 of nodes) { + node2.raws.before = sample.raws.before; + } + } + } + return nodes; + } + removeChild(child, ignore) { + let index2 = this.index(child); + if (!ignore && index2 === 0 && this.nodes.length > 1) { + this.nodes[1].raws.before = this.nodes[index2].raws.before; + } + return super.removeChild(child); + } + toResult(opts = {}) { + let lazy = new LazyResult$3(new Processor$2(), this, opts); + return lazy.stringify(); + } +}; +Root$5.registerLazyResult = (dependant) => { + LazyResult$3 = dependant; +}; +Root$5.registerProcessor = (dependant) => { + Processor$2 = dependant; +}; +var root = Root$5; +Root$5.default = Root$5; +Container$4.registerRoot(Root$5); +var list$2 = { + comma(string) { + return list$2.split(string, [","], true); + }, + space(string) { + let spaces = [" ", "\n", " "]; + return list$2.split(string, spaces); + }, + split(string, separators, last) { + let array = []; + let current = ""; + let split = false; + let func = 0; + let inQuote = false; + let prevQuote = ""; + let escape = false; + for (let letter of string) { + if (escape) { + escape = false; + } else if (letter === "\\") { + escape = true; + } else if (inQuote) { + if (letter === prevQuote) { + inQuote = false; + } + } else if (letter === '"' || letter === "'") { + inQuote = true; + prevQuote = letter; + } else if (letter === "(") { + func += 1; + } else if (letter === ")") { + if (func > 0) + func -= 1; + } else if (func === 0) { + if (separators.includes(letter)) + split = true; + } + if (split) { + if (current !== "") + array.push(current.trim()); + current = ""; + split = false; + } else { + current += letter; + } + } + if (last || current !== "") + array.push(current.trim()); + return array; + } +}; +var list_1 = list$2; +list$2.default = list$2; +var Container$3 = container; +var list$1 = list_1; +var Rule$3 = class Rule2 extends Container$3 { + constructor(defaults) { + super(defaults); + this.type = "rule"; + if (!this.nodes) + this.nodes = []; + } + get selectors() { + return list$1.comma(this.selector); + } + set selectors(values) { + let match = this.selector ? this.selector.match(/,\s*/) : null; + let sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen"); + this.selector = values.join(sep2); + } +}; +var rule = Rule$3; +Rule$3.default = Rule$3; +Container$3.registerRule(Rule$3); +var AtRule$2 = atRule; +var Comment$2 = comment; +var Declaration$2 = declaration; +var Input$3 = input; +var PreviousMap22 = previousMap; +var Root$4 = root; +var Rule$2 = rule; +function fromJSON$1(json, inputs) { + if (Array.isArray(json)) + return json.map((n2) => fromJSON$1(n2)); + let { inputs: ownInputs, ...defaults } = json; + if (ownInputs) { + inputs = []; + for (let input2 of ownInputs) { + let inputHydrated = { ...input2, __proto__: Input$3.prototype }; + if (inputHydrated.map) { + inputHydrated.map = { + ...inputHydrated.map, + __proto__: PreviousMap22.prototype + }; + } + inputs.push(inputHydrated); + } + } + if (defaults.nodes) { + defaults.nodes = json.nodes.map((n2) => fromJSON$1(n2, inputs)); + } + if (defaults.source) { + let { inputId, ...source } = defaults.source; + defaults.source = source; + if (inputId != null) { + defaults.source.input = inputs[inputId]; + } + } + if (defaults.type === "root") { + return new Root$4(defaults); + } else if (defaults.type === "decl") { + return new Declaration$2(defaults); + } else if (defaults.type === "rule") { + return new Rule$2(defaults); + } else if (defaults.type === "comment") { + return new Comment$2(defaults); + } else if (defaults.type === "atrule") { + return new AtRule$2(defaults); + } else { + throw new Error("Unknown node type: " + json.type); } - return tagName; } -function escapeRegExp(str) { - return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +var fromJSON_1 = fromJSON$1; +fromJSON$1.default = fromJSON$1; +var { dirname, relative, resolve, sep } = require$$2; +var { SourceMapConsumer, SourceMapGenerator } = require$$2; +var { pathToFileURL } = require$$2; +var Input$2 = input; +var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator); +var pathAvailable = Boolean(dirname && resolve && relative && sep); +var MapGenerator$2 = class MapGenerator2 { + constructor(stringify2, root2, opts, cssString) { + this.stringify = stringify2; + this.mapOpts = opts.map || {}; + this.root = root2; + this.opts = opts; + this.css = cssString; + this.originalCSS = cssString; + this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute; + this.memoizedFileURLs = /* @__PURE__ */ new Map(); + this.memoizedPaths = /* @__PURE__ */ new Map(); + this.memoizedURLs = /* @__PURE__ */ new Map(); + } + addAnnotation() { + let content; + if (this.isInline()) { + content = "data:application/json;base64," + this.toBase64(this.map.toString()); + } else if (typeof this.mapOpts.annotation === "string") { + content = this.mapOpts.annotation; + } else if (typeof this.mapOpts.annotation === "function") { + content = this.mapOpts.annotation(this.opts.to, this.root); + } else { + content = this.outputFile() + ".map"; + } + let eol = "\n"; + if (this.css.includes("\r\n")) + eol = "\r\n"; + this.css += eol + "/*# sourceMappingURL=" + content + " */"; + } + applyPrevMaps() { + for (let prev of this.previous()) { + let from = this.toUrl(this.path(prev.file)); + let root2 = prev.root || dirname(prev.file); + let map; + if (this.mapOpts.sourcesContent === false) { + map = new SourceMapConsumer(prev.text); + if (map.sourcesContent) { + map.sourcesContent = null; + } + } else { + map = prev.consumer(); + } + this.map.applySourceMap(map, from, this.toUrl(this.path(root2))); + } + } + clearAnnotation() { + if (this.mapOpts.annotation === false) + return; + if (this.root) { + let node2; + for (let i2 = this.root.nodes.length - 1; i2 >= 0; i2--) { + node2 = this.root.nodes[i2]; + if (node2.type !== "comment") + continue; + if (node2.text.startsWith("# sourceMappingURL=")) { + this.root.removeChild(i2); + } + } + } else if (this.css) { + this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, ""); + } + } + generate() { + this.clearAnnotation(); + if (pathAvailable && sourceMapAvailable && this.isMap()) { + return this.generateMap(); + } else { + let result2 = ""; + this.stringify(this.root, (i2) => { + result2 += i2; + }); + return [result2]; + } + } + generateMap() { + if (this.root) { + this.generateString(); + } else if (this.previous().length === 1) { + let prev = this.previous()[0].consumer(); + prev.file = this.outputFile(); + this.map = SourceMapGenerator.fromSourceMap(prev, { + ignoreInvalidMapping: true + }); + } else { + this.map = new SourceMapGenerator({ + file: this.outputFile(), + ignoreInvalidMapping: true + }); + this.map.addMapping({ + generated: { column: 0, line: 1 }, + original: { column: 0, line: 1 }, + source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "" + }); + } + if (this.isSourcesContent()) + this.setSourcesContent(); + if (this.root && this.previous().length > 0) + this.applyPrevMaps(); + if (this.isAnnotation()) + this.addAnnotation(); + if (this.isInline()) { + return [this.css]; + } else { + return [this.css, this.map]; + } + } + generateString() { + this.css = ""; + this.map = new SourceMapGenerator({ + file: this.outputFile(), + ignoreInvalidMapping: true + }); + let line = 1; + let column = 1; + let noSource = ""; + let mapping = { + generated: { column: 0, line: 0 }, + original: { column: 0, line: 0 }, + source: "" + }; + let last, lines; + this.stringify(this.root, (str, node2, type) => { + this.css += str; + if (node2 && type !== "end") { + mapping.generated.line = line; + mapping.generated.column = column - 1; + if (node2.source && node2.source.start) { + mapping.source = this.sourcePath(node2); + mapping.original.line = node2.source.start.line; + mapping.original.column = node2.source.start.column - 1; + this.map.addMapping(mapping); + } else { + mapping.source = noSource; + mapping.original.line = 1; + mapping.original.column = 0; + this.map.addMapping(mapping); + } + } + lines = str.match(/\n/g); + if (lines) { + line += lines.length; + last = str.lastIndexOf("\n"); + column = str.length - last; + } else { + column += str.length; + } + if (node2 && type !== "start") { + let p = node2.parent || { raws: {} }; + let childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes; + if (!childless || node2 !== p.last || p.raws.semicolon) { + if (node2.source && node2.source.end) { + mapping.source = this.sourcePath(node2); + mapping.original.line = node2.source.end.line; + mapping.original.column = node2.source.end.column - 1; + mapping.generated.line = line; + mapping.generated.column = column - 2; + this.map.addMapping(mapping); + } else { + mapping.source = noSource; + mapping.original.line = 1; + mapping.original.column = 0; + mapping.generated.line = line; + mapping.generated.column = column - 1; + this.map.addMapping(mapping); + } + } + } + }); + } + isAnnotation() { + if (this.isInline()) { + return true; + } + if (typeof this.mapOpts.annotation !== "undefined") { + return this.mapOpts.annotation; + } + if (this.previous().length) { + return this.previous().some((i2) => i2.annotation); + } + return true; + } + isInline() { + if (typeof this.mapOpts.inline !== "undefined") { + return this.mapOpts.inline; + } + let annotation = this.mapOpts.annotation; + if (typeof annotation !== "undefined" && annotation !== true) { + return false; + } + if (this.previous().length) { + return this.previous().some((i2) => i2.inline); + } + return true; + } + isMap() { + if (typeof this.opts.map !== "undefined") { + return !!this.opts.map; + } + return this.previous().length > 0; + } + isSourcesContent() { + if (typeof this.mapOpts.sourcesContent !== "undefined") { + return this.mapOpts.sourcesContent; + } + if (this.previous().length) { + return this.previous().some((i2) => i2.withContent()); + } + return true; + } + outputFile() { + if (this.opts.to) { + return this.path(this.opts.to); + } else if (this.opts.from) { + return this.path(this.opts.from); + } else { + return "to.css"; + } + } + path(file) { + if (this.mapOpts.absolute) + return file; + if (file.charCodeAt(0) === 60) + return file; + if (/^\w+:\/\//.test(file)) + return file; + let cached = this.memoizedPaths.get(file); + if (cached) + return cached; + let from = this.opts.to ? dirname(this.opts.to) : "."; + if (typeof this.mapOpts.annotation === "string") { + from = dirname(resolve(from, this.mapOpts.annotation)); + } + let path = relative(from, file); + this.memoizedPaths.set(file, path); + return path; + } + previous() { + if (!this.previousMaps) { + this.previousMaps = []; + if (this.root) { + this.root.walk((node2) => { + if (node2.source && node2.source.input.map) { + let map = node2.source.input.map; + if (!this.previousMaps.includes(map)) { + this.previousMaps.push(map); + } + } + }); + } else { + let input2 = new Input$2(this.originalCSS, this.opts); + if (input2.map) + this.previousMaps.push(input2.map); + } + } + return this.previousMaps; + } + setSourcesContent() { + let already = {}; + if (this.root) { + this.root.walk((node2) => { + if (node2.source) { + let from = node2.source.input.from; + if (from && !already[from]) { + already[from] = true; + let fromUrl = this.usesFileUrls ? this.toFileUrl(from) : this.toUrl(this.path(from)); + this.map.setSourceContent(fromUrl, node2.source.input.css); + } + } + }); + } else if (this.css) { + let from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : ""; + this.map.setSourceContent(from, this.css); + } + } + sourcePath(node2) { + if (this.mapOpts.from) { + return this.toUrl(this.mapOpts.from); + } else if (this.usesFileUrls) { + return this.toFileUrl(node2.source.input.from); + } else { + return this.toUrl(this.path(node2.source.input.from)); + } + } + toBase64(str) { + if (Buffer) { + return Buffer.from(str).toString("base64"); + } else { + return window.btoa(unescape(encodeURIComponent(str))); + } + } + toFileUrl(path) { + let cached = this.memoizedFileURLs.get(path); + if (cached) + return cached; + if (pathToFileURL) { + let fileURL = pathToFileURL(path).toString(); + this.memoizedFileURLs.set(path, fileURL); + return fileURL; + } else { + throw new Error( + "`map.absolute` option is not available in this PostCSS build" + ); + } + } + toUrl(path) { + let cached = this.memoizedURLs.get(path); + if (cached) + return cached; + if (sep === "\\") { + path = path.replace(/\\/g, "/"); + } + let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent); + this.memoizedURLs.set(path, url); + return url; + } +}; +var mapGenerator = MapGenerator$2; +var SINGLE_QUOTE = "'".charCodeAt(0); +var DOUBLE_QUOTE = '"'.charCodeAt(0); +var BACKSLASH = "\\".charCodeAt(0); +var SLASH = "/".charCodeAt(0); +var NEWLINE = "\n".charCodeAt(0); +var SPACE = " ".charCodeAt(0); +var FEED = "\f".charCodeAt(0); +var TAB = " ".charCodeAt(0); +var CR = "\r".charCodeAt(0); +var OPEN_SQUARE = "[".charCodeAt(0); +var CLOSE_SQUARE = "]".charCodeAt(0); +var OPEN_PARENTHESES = "(".charCodeAt(0); +var CLOSE_PARENTHESES = ")".charCodeAt(0); +var OPEN_CURLY = "{".charCodeAt(0); +var CLOSE_CURLY = "}".charCodeAt(0); +var SEMICOLON = ";".charCodeAt(0); +var ASTERISK = "*".charCodeAt(0); +var COLON = ":".charCodeAt(0); +var AT = "@".charCodeAt(0); +var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g; +var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g; +var RE_BAD_BRACKET = /.[\r\n"'(/\\]/; +var RE_HEX_ESCAPE = /[\da-f]/i; +var tokenize = function tokenizer2(input2, options = {}) { + let css = input2.css.valueOf(); + let ignore = options.ignoreErrors; + let code, content, escape, next, quote; + let currentToken, escaped, escapePos, n2, prev; + let length = css.length; + let pos = 0; + let buffer = []; + let returned = []; + function position() { + return pos; + } + function unclosed(what) { + throw input2.error("Unclosed " + what, pos); + } + function endOfFile() { + return returned.length === 0 && pos >= length; + } + function nextToken(opts) { + if (returned.length) + return returned.pop(); + if (pos >= length) + return; + let ignoreUnclosed = opts ? opts.ignoreUnclosed : false; + code = css.charCodeAt(pos); + switch (code) { + case NEWLINE: + case SPACE: + case TAB: + case CR: + case FEED: { + next = pos; + do { + next += 1; + code = css.charCodeAt(next); + } while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED); + currentToken = ["space", css.slice(pos, next)]; + pos = next - 1; + break; + } + case OPEN_SQUARE: + case CLOSE_SQUARE: + case OPEN_CURLY: + case CLOSE_CURLY: + case COLON: + case SEMICOLON: + case CLOSE_PARENTHESES: { + let controlChar = String.fromCharCode(code); + currentToken = [controlChar, controlChar, pos]; + break; + } + case OPEN_PARENTHESES: { + prev = buffer.length ? buffer.pop()[1] : ""; + n2 = css.charCodeAt(pos + 1); + if (prev === "url" && n2 !== SINGLE_QUOTE && n2 !== DOUBLE_QUOTE && n2 !== SPACE && n2 !== NEWLINE && n2 !== TAB && n2 !== FEED && n2 !== CR) { + next = pos; + do { + escaped = false; + next = css.indexOf(")", next + 1); + if (next === -1) { + if (ignore || ignoreUnclosed) { + next = pos; + break; + } else { + unclosed("bracket"); + } + } + escapePos = next; + while (css.charCodeAt(escapePos - 1) === BACKSLASH) { + escapePos -= 1; + escaped = !escaped; + } + } while (escaped); + currentToken = ["brackets", css.slice(pos, next + 1), pos, next]; + pos = next; + } else { + next = css.indexOf(")", pos + 1); + content = css.slice(pos, next + 1); + if (next === -1 || RE_BAD_BRACKET.test(content)) { + currentToken = ["(", "(", pos]; + } else { + currentToken = ["brackets", content, pos, next]; + pos = next; + } + } + break; + } + case SINGLE_QUOTE: + case DOUBLE_QUOTE: { + quote = code === SINGLE_QUOTE ? "'" : '"'; + next = pos; + do { + escaped = false; + next = css.indexOf(quote, next + 1); + if (next === -1) { + if (ignore || ignoreUnclosed) { + next = pos + 1; + break; + } else { + unclosed("string"); + } + } + escapePos = next; + while (css.charCodeAt(escapePos - 1) === BACKSLASH) { + escapePos -= 1; + escaped = !escaped; + } + } while (escaped); + currentToken = ["string", css.slice(pos, next + 1), pos, next]; + pos = next; + break; + } + case AT: { + RE_AT_END.lastIndex = pos + 1; + RE_AT_END.test(css); + if (RE_AT_END.lastIndex === 0) { + next = css.length - 1; + } else { + next = RE_AT_END.lastIndex - 2; + } + currentToken = ["at-word", css.slice(pos, next + 1), pos, next]; + pos = next; + break; + } + case BACKSLASH: { + next = pos; + escape = true; + while (css.charCodeAt(next + 1) === BACKSLASH) { + next += 1; + escape = !escape; + } + code = css.charCodeAt(next + 1); + if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) { + next += 1; + if (RE_HEX_ESCAPE.test(css.charAt(next))) { + while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) { + next += 1; + } + if (css.charCodeAt(next + 1) === SPACE) { + next += 1; + } + } + } + currentToken = ["word", css.slice(pos, next + 1), pos, next]; + pos = next; + break; + } + default: { + if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) { + next = css.indexOf("*/", pos + 2) + 1; + if (next === 0) { + if (ignore || ignoreUnclosed) { + next = css.length; + } else { + unclosed("comment"); + } + } + currentToken = ["comment", css.slice(pos, next + 1), pos, next]; + pos = next; + } else { + RE_WORD_END.lastIndex = pos + 1; + RE_WORD_END.test(css); + if (RE_WORD_END.lastIndex === 0) { + next = css.length - 1; + } else { + next = RE_WORD_END.lastIndex - 2; + } + currentToken = ["word", css.slice(pos, next + 1), pos, next]; + buffer.push(currentToken); + pos = next; + } + break; + } + } + pos++; + return currentToken; + } + function back(token) { + returned.push(token); + } + return { + back, + endOfFile, + nextToken, + position + }; +}; +var AtRule$1 = atRule; +var Comment$1 = comment; +var Declaration$1 = declaration; +var Root$3 = root; +var Rule$1 = rule; +var tokenizer22 = tokenize; +var SAFE_COMMENT_NEIGHBOR = { + empty: true, + space: true +}; +function findLastWithPosition(tokens) { + for (let i2 = tokens.length - 1; i2 >= 0; i2--) { + let token = tokens[i2]; + let pos = token[3] || token[2]; + if (pos) + return pos; + } } -var MEDIA_SELECTOR = /(max|min)-device-(width|height)/; -var MEDIA_SELECTOR_GLOBAL = new RegExp(MEDIA_SELECTOR.source, "g"); -var HOVER_SELECTOR = /([^\\]):hover/; -var HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, "g"); -function adaptCssForReplay(cssText, cache) { - const cachedStyle = cache == null ? void 0 : cache.stylesWithHoverClass.get(cssText); - if (cachedStyle) - return cachedStyle; - const ast = parse(cssText, { - silent: true - }); - if (!ast.stylesheet) { - return cssText; +var Parser$1 = class Parser2 { + constructor(input2) { + this.input = input2; + this.root = new Root$3(); + this.current = this.root; + this.spaces = ""; + this.semicolon = false; + this.createTokenizer(); + this.root.source = { input: input2, start: { column: 1, line: 1, offset: 0 } }; + } + atrule(token) { + let node2 = new AtRule$1(); + node2.name = token[1].slice(1); + if (node2.name === "") { + this.unnamedAtrule(node2, token); + } + this.init(node2, token[2]); + let type; + let prev; + let shift; + let last = false; + let open = false; + let params = []; + let brackets = []; + while (!this.tokenizer.endOfFile()) { + token = this.tokenizer.nextToken(); + type = token[0]; + if (type === "(" || type === "[") { + brackets.push(type === "(" ? ")" : "]"); + } else if (type === "{" && brackets.length > 0) { + brackets.push("}"); + } else if (type === brackets[brackets.length - 1]) { + brackets.pop(); + } + if (brackets.length === 0) { + if (type === ";") { + node2.source.end = this.getPosition(token[2]); + node2.source.end.offset++; + this.semicolon = true; + break; + } else if (type === "{") { + open = true; + break; + } else if (type === "}") { + if (params.length > 0) { + shift = params.length - 1; + prev = params[shift]; + while (prev && prev[0] === "space") { + prev = params[--shift]; + } + if (prev) { + node2.source.end = this.getPosition(prev[3] || prev[2]); + node2.source.end.offset++; + } + } + this.end(token); + break; + } else { + params.push(token); + } + } else { + params.push(token); + } + if (this.tokenizer.endOfFile()) { + last = true; + break; + } + } + node2.raws.between = this.spacesAndCommentsFromEnd(params); + if (params.length) { + node2.raws.afterName = this.spacesAndCommentsFromStart(params); + this.raw(node2, "params", params); + if (last) { + token = params[params.length - 1]; + node2.source.end = this.getPosition(token[3] || token[2]); + node2.source.end.offset++; + this.spaces = node2.raws.between; + node2.raws.between = ""; + } + } else { + node2.raws.afterName = ""; + node2.params = ""; + } + if (open) { + node2.nodes = []; + this.current = node2; + } + } + checkMissedSemicolon(tokens) { + let colon = this.colon(tokens); + if (colon === false) + return; + let founded = 0; + let token; + for (let j = colon - 1; j >= 0; j--) { + token = tokens[j]; + if (token[0] !== "space") { + founded += 1; + if (founded === 2) + break; + } + } + throw this.input.error( + "Missed semicolon", + token[0] === "word" ? token[3] + 1 : token[2] + ); + } + colon(tokens) { + let brackets = 0; + let prev, token, type; + for (let [i2, element] of tokens.entries()) { + token = element; + type = token[0]; + if (type === "(") { + brackets += 1; + } + if (type === ")") { + brackets -= 1; + } + if (brackets === 0 && type === ":") { + if (!prev) { + this.doubleColon(token); + } else if (prev[0] === "word" && prev[1] === "progid") { + continue; + } else { + return i2; + } + } + prev = token; + } + return false; + } + comment(token) { + let node2 = new Comment$1(); + this.init(node2, token[2]); + node2.source.end = this.getPosition(token[3] || token[2]); + node2.source.end.offset++; + let text = token[1].slice(2, -2); + if (/^\s*$/.test(text)) { + node2.text = ""; + node2.raws.left = text; + node2.raws.right = ""; + } else { + let match = text.match(/^(\s*)([^]*\S)(\s*)$/); + node2.text = match[2]; + node2.raws.left = match[1]; + node2.raws.right = match[3]; + } + } + createTokenizer() { + this.tokenizer = tokenizer22(this.input); + } + decl(tokens, customProperty) { + let node2 = new Declaration$1(); + this.init(node2, tokens[0][2]); + let last = tokens[tokens.length - 1]; + if (last[0] === ";") { + this.semicolon = true; + tokens.pop(); + } + node2.source.end = this.getPosition( + last[3] || last[2] || findLastWithPosition(tokens) + ); + node2.source.end.offset++; + while (tokens[0][0] !== "word") { + if (tokens.length === 1) + this.unknownWord(tokens); + node2.raws.before += tokens.shift()[1]; + } + node2.source.start = this.getPosition(tokens[0][2]); + node2.prop = ""; + while (tokens.length) { + let type = tokens[0][0]; + if (type === ":" || type === "space" || type === "comment") { + break; + } + node2.prop += tokens.shift()[1]; + } + node2.raws.between = ""; + let token; + while (tokens.length) { + token = tokens.shift(); + if (token[0] === ":") { + node2.raws.between += token[1]; + break; + } else { + if (token[0] === "word" && /\w/.test(token[1])) { + this.unknownWord([token]); + } + node2.raws.between += token[1]; + } + } + if (node2.prop[0] === "_" || node2.prop[0] === "*") { + node2.raws.before += node2.prop[0]; + node2.prop = node2.prop.slice(1); + } + let firstSpaces = []; + let next; + while (tokens.length) { + next = tokens[0][0]; + if (next !== "space" && next !== "comment") + break; + firstSpaces.push(tokens.shift()); + } + this.precheckMissedSemicolon(tokens); + for (let i2 = tokens.length - 1; i2 >= 0; i2--) { + token = tokens[i2]; + if (token[1].toLowerCase() === "!important") { + node2.important = true; + let string = this.stringFrom(tokens, i2); + string = this.spacesFromEnd(tokens) + string; + if (string !== " !important") + node2.raws.important = string; + break; + } else if (token[1].toLowerCase() === "important") { + let cache = tokens.slice(0); + let str = ""; + for (let j = i2; j > 0; j--) { + let type = cache[j][0]; + if (str.trim().startsWith("!") && type !== "space") { + break; + } + str = cache.pop()[1] + str; + } + if (str.trim().startsWith("!")) { + node2.important = true; + node2.raws.important = str; + tokens = cache; + } + } + if (token[0] !== "space" && token[0] !== "comment") { + break; + } + } + let hasWord = tokens.some((i2) => i2[0] !== "space" && i2[0] !== "comment"); + if (hasWord) { + node2.raws.between += firstSpaces.map((i2) => i2[1]).join(""); + firstSpaces = []; + } + this.raw(node2, "value", firstSpaces.concat(tokens), customProperty); + if (node2.value.includes(":") && !customProperty) { + this.checkMissedSemicolon(tokens); + } + } + doubleColon(token) { + throw this.input.error( + "Double colon", + { offset: token[2] }, + { offset: token[2] + token[1].length } + ); + } + emptyRule(token) { + let node2 = new Rule$1(); + this.init(node2, token[2]); + node2.selector = ""; + node2.raws.between = ""; + this.current = node2; + } + end(token) { + if (this.current.nodes && this.current.nodes.length) { + this.current.raws.semicolon = this.semicolon; + } + this.semicolon = false; + this.current.raws.after = (this.current.raws.after || "") + this.spaces; + this.spaces = ""; + if (this.current.parent) { + this.current.source.end = this.getPosition(token[2]); + this.current.source.end.offset++; + this.current = this.current.parent; + } else { + this.unexpectedClose(token); + } + } + endFile() { + if (this.current.parent) + this.unclosedBlock(); + if (this.current.nodes && this.current.nodes.length) { + this.current.raws.semicolon = this.semicolon; + } + this.current.raws.after = (this.current.raws.after || "") + this.spaces; + this.root.source.end = this.getPosition(this.tokenizer.position()); + } + freeSemicolon(token) { + this.spaces += token[1]; + if (this.current.nodes) { + let prev = this.current.nodes[this.current.nodes.length - 1]; + if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) { + prev.raws.ownSemicolon = this.spaces; + this.spaces = ""; + } + } + } + // Helpers + getPosition(offset) { + let pos = this.input.fromOffset(offset); + return { + column: pos.col, + line: pos.line, + offset + }; } - const selectors = []; - const medias = []; - function getSelectors(rule) { - if ("selectors" in rule && rule.selectors) { - rule.selectors.forEach((selector) => { - if (HOVER_SELECTOR.test(selector)) { - selectors.push(selector); + init(node2, offset) { + this.current.push(node2); + node2.source = { + input: this.input, + start: this.getPosition(offset) + }; + node2.raws.before = this.spaces; + this.spaces = ""; + if (node2.type !== "comment") + this.semicolon = false; + } + other(start) { + let end = false; + let type = null; + let colon = false; + let bracket = null; + let brackets = []; + let customProperty = start[1].startsWith("--"); + let tokens = []; + let token = start; + while (token) { + type = token[0]; + tokens.push(token); + if (type === "(" || type === "[") { + if (!bracket) + bracket = token; + brackets.push(type === "(" ? ")" : "]"); + } else if (customProperty && colon && type === "{") { + if (!bracket) + bracket = token; + brackets.push("}"); + } else if (brackets.length === 0) { + if (type === ";") { + if (colon) { + this.decl(tokens, customProperty); + return; + } else { + break; + } + } else if (type === "{") { + this.rule(tokens); + return; + } else if (type === "}") { + this.tokenizer.back(tokens.pop()); + end = true; + break; + } else if (type === ":") { + colon = true; } - }); + } else if (type === brackets[brackets.length - 1]) { + brackets.pop(); + if (brackets.length === 0) + bracket = null; + } + token = this.tokenizer.nextToken(); + } + if (this.tokenizer.endOfFile()) + end = true; + if (brackets.length > 0) + this.unclosedBracket(bracket); + if (end && colon) { + if (!customProperty) { + while (tokens.length) { + token = tokens[tokens.length - 1][0]; + if (token !== "space" && token !== "comment") + break; + this.tokenizer.back(tokens.pop()); + } + } + this.decl(tokens, customProperty); + } else { + this.unknownWord(tokens); + } + } + parse() { + let token; + while (!this.tokenizer.endOfFile()) { + token = this.tokenizer.nextToken(); + switch (token[0]) { + case "space": + this.spaces += token[1]; + break; + case ";": + this.freeSemicolon(token); + break; + case "}": + this.end(token); + break; + case "comment": + this.comment(token); + break; + case "at-word": + this.atrule(token); + break; + case "{": + this.emptyRule(token); + break; + default: + this.other(token); + break; + } + } + this.endFile(); + } + precheckMissedSemicolon() { + } + raw(node2, prop, tokens, customProperty) { + let token, type; + let length = tokens.length; + let value = ""; + let clean = true; + let next, prev; + for (let i2 = 0; i2 < length; i2 += 1) { + token = tokens[i2]; + type = token[0]; + if (type === "space" && i2 === length - 1 && !customProperty) { + clean = false; + } else if (type === "comment") { + prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty"; + next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty"; + if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) { + if (value.slice(-1) === ",") { + clean = false; + } else { + value += token[1]; + } + } else { + clean = false; + } + } else { + value += token[1]; + } } - if ("media" in rule && rule.media && MEDIA_SELECTOR.test(rule.media)) { - medias.push(rule.media); + if (!clean) { + let raw = tokens.reduce((all, i2) => all + i2[1], ""); + node2.raws[prop] = { raw, value }; + } + node2[prop] = value; + } + rule(tokens) { + tokens.pop(); + let node2 = new Rule$1(); + this.init(node2, tokens[0][2]); + node2.raws.between = this.spacesAndCommentsFromEnd(tokens); + this.raw(node2, "selector", tokens); + this.current = node2; + } + spacesAndCommentsFromEnd(tokens) { + let lastTokenType; + let spaces = ""; + while (tokens.length) { + lastTokenType = tokens[tokens.length - 1][0]; + if (lastTokenType !== "space" && lastTokenType !== "comment") + break; + spaces = tokens.pop()[1] + spaces; + } + return spaces; + } + // Errors + spacesAndCommentsFromStart(tokens) { + let next; + let spaces = ""; + while (tokens.length) { + next = tokens[0][0]; + if (next !== "space" && next !== "comment") + break; + spaces += tokens.shift()[1]; } - if ("rules" in rule && rule.rules) { - rule.rules.forEach(getSelectors); + return spaces; + } + spacesFromEnd(tokens) { + let lastTokenType; + let spaces = ""; + while (tokens.length) { + lastTokenType = tokens[tokens.length - 1][0]; + if (lastTokenType !== "space") + break; + spaces = tokens.pop()[1] + spaces; + } + return spaces; + } + stringFrom(tokens, from) { + let result2 = ""; + for (let i2 = from; i2 < tokens.length; i2++) { + result2 += tokens[i2][1]; } + tokens.splice(from, tokens.length - from); + return result2; } - getSelectors(ast.stylesheet); - let result = cssText; - if (selectors.length > 0) { - const selectorMatcher = new RegExp( - selectors.filter((selector, index2) => selectors.indexOf(selector) === index2).sort((a2, b) => b.length - a2.length).map((selector) => { - return escapeRegExp(selector); - }).join("|"), - "g" + unclosedBlock() { + let pos = this.current.source.start; + throw this.input.error("Unclosed block", pos.line, pos.column); + } + unclosedBracket(bracket) { + throw this.input.error( + "Unclosed bracket", + { offset: bracket[2] }, + { offset: bracket[2] + 1 } ); - result = result.replace(selectorMatcher, (selector) => { - const newSelector = selector.replace( - HOVER_SELECTOR_GLOBAL, - "$1.\\:hover" - ); - return `${selector}, ${newSelector}`; - }); } - if (medias.length > 0) { - const mediaMatcher = new RegExp( - medias.filter((media, index2) => medias.indexOf(media) === index2).sort((a2, b) => b.length - a2.length).map((media) => { - return escapeRegExp(media); - }).join("|"), - "g" + unexpectedClose(token) { + throw this.input.error( + "Unexpected }", + { offset: token[2] }, + { offset: token[2] + 1 } ); - result = result.replace(mediaMatcher, (media) => { - return media.replace(MEDIA_SELECTOR_GLOBAL, "$1-$2"); - }); } - cache == null ? void 0 : cache.stylesWithHoverClass.set(cssText, result); - return result; -} -function createCache() { - const stylesWithHoverClass = /* @__PURE__ */ new Map(); - return { - stylesWithHoverClass - }; + unknownWord(tokens) { + throw this.input.error( + "Unknown word", + { offset: tokens[0][2] }, + { offset: tokens[0][2] + tokens[0][1].length } + ); + } + unnamedAtrule(node2, token) { + throw this.input.error( + "At-rule without name", + { offset: token[2] }, + { offset: token[2] + token[1].length } + ); + } +}; +var parser = Parser$1; +var Container$2 = container; +var Input$1 = input; +var Parser22 = parser; +function parse$3(css, opts) { + let input2 = new Input$1(css, opts); + let parser2 = new Parser22(input2); + try { + parser2.parse(); + } catch (e2) { + if (true) { + if (e2.name === "CssSyntaxError" && opts && opts.from) { + if (/\.scss$/i.test(opts.from)) { + e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser"; + } else if (/\.sass/i.test(opts.from)) { + e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser"; + } else if (/\.less$/i.test(opts.from)) { + e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser"; + } + } + } + throw e2; + } + return parser2.root; } -function applyCssSplits(n2, cssText, hackCss, cache) { - const childTextNodes = []; - for (const scn of n2.childNodes) { - if (scn.type === NodeType$2.Text) { - childTextNodes.push(scn); +var parse_1 = parse$3; +parse$3.default = parse$3; +Container$2.registerParse(parse$3); +var Warning$2 = class Warning2 { + constructor(text, opts = {}) { + this.type = "warning"; + this.text = text; + if (opts.node && opts.node.source) { + let range = opts.node.rangeBy(opts); + this.line = range.start.line; + this.column = range.start.column; + this.endLine = range.end.line; + this.endColumn = range.end.column; + } + for (let opt in opts) + this[opt] = opts[opt]; + } + toString() { + if (this.node) { + return this.node.error(this.text, { + index: this.index, + plugin: this.plugin, + word: this.word + }).message; } + if (this.plugin) { + return this.plugin + ": " + this.text; + } + return this.text; } - const cssTextSplits = cssText.split("/* rr_split */"); - while (cssTextSplits.length > 1 && cssTextSplits.length > childTextNodes.length) { - cssTextSplits.splice(-2, 2, cssTextSplits.slice(-2).join("")); +}; +var warning = Warning$2; +Warning$2.default = Warning$2; +var Warning$1 = warning; +var Result$3 = class Result2 { + constructor(processor2, root2, opts) { + this.processor = processor2; + this.messages = []; + this.root = root2; + this.opts = opts; + this.css = void 0; + this.map = void 0; } - for (let i2 = 0; i2 < childTextNodes.length; i2++) { - const childTextNode = childTextNodes[i2]; - const cssTextSection = cssTextSplits[i2]; - if (childTextNode && cssTextSection) { - try { - childTextNode.textContent = hackCss ? adaptCssForReplay(cssTextSection, cache) : cssTextSection; - } catch (err) { - console.warn(`Highlight failed to set rrweb css ${err}`); + toString() { + return this.css; + } + warn(text, opts = {}) { + if (!opts.plugin) { + if (this.lastPlugin && this.lastPlugin.postcssPlugin) { + opts.plugin = this.lastPlugin.postcssPlugin; } } + let warning2 = new Warning$1(text, opts); + this.messages.push(warning2); + return warning2; + } + warnings() { + return this.messages.filter((i2) => i2.type === "warning"); + } + get content() { + return this.css; + } +}; +var result = Result$3; +Result$3.default = Result$3; +var printed = {}; +var warnOnce$2 = function warnOnce2(message) { + if (printed[message]) + return; + printed[message] = true; + if (typeof console !== "undefined" && console.warn) { + console.warn(message); } +}; +var Container$1 = container; +var Document$2 = document$1; +var MapGenerator$1 = mapGenerator; +var parse$2 = parse_1; +var Result$2 = result; +var Root$2 = root; +var stringify$2 = stringify_1; +var { isClean, my } = symbols; +var warnOnce$1 = warnOnce$2; +var TYPE_TO_CLASS_NAME = { + atrule: "AtRule", + comment: "Comment", + decl: "Declaration", + document: "Document", + root: "Root", + rule: "Rule" +}; +var PLUGIN_PROPS = { + AtRule: true, + AtRuleExit: true, + Comment: true, + CommentExit: true, + Declaration: true, + DeclarationExit: true, + Document: true, + DocumentExit: true, + Once: true, + OnceExit: true, + postcssPlugin: true, + prepare: true, + Root: true, + RootExit: true, + Rule: true, + RuleExit: true +}; +var NOT_VISITORS = { + Once: true, + postcssPlugin: true, + prepare: true +}; +var CHILDREN = 0; +function isPromise(obj) { + return typeof obj === "object" && typeof obj.then === "function"; } -function buildStyleNode(n2, styleEl, cssText, options) { - const { doc, hackCss, cache } = options; - if (n2.childNodes.length) { - applyCssSplits(n2, cssText, hackCss, cache); +function getEvents(node2) { + let key = false; + let type = TYPE_TO_CLASS_NAME[node2.type]; + if (node2.type === "decl") { + key = node2.prop.toLowerCase(); + } else if (node2.type === "atrule") { + key = node2.name.toLowerCase(); + } + if (key && node2.append) { + return [ + type, + type + "-" + key, + CHILDREN, + type + "Exit", + type + "Exit-" + key + ]; + } else if (key) { + return [type, type + "-" + key, type + "Exit", type + "Exit-" + key]; + } else if (node2.append) { + return [type, CHILDREN, type + "Exit"]; } else { - if (hackCss) { - cssText = adaptCssForReplay(cssText, cache); - } - styleEl.appendChild(doc.createTextNode(cssText)); + return [type, type + "Exit"]; } } -function buildNode(n2, options) { - var _a2; - const { doc, hackCss, cache } = options; - switch (n2.type) { - case NodeType$2.Document: - return doc.implementation.createDocument(null, "", null); - case NodeType$2.DocumentType: - return doc.implementation.createDocumentType( - n2.name || "html", - n2.publicId, - n2.systemId - ); - case NodeType$2.Element: { - const tagName = getTagName(n2); - let node; - if (n2.isSVG) { - node = doc.createElementNS("http://www.w3.org/2000/svg", tagName); +function toStack(node2) { + let events; + if (node2.type === "document") { + events = ["Document", CHILDREN, "DocumentExit"]; + } else if (node2.type === "root") { + events = ["Root", CHILDREN, "RootExit"]; + } else { + events = getEvents(node2); + } + return { + eventIndex: 0, + events, + iterator: 0, + node: node2, + visitorIndex: 0, + visitors: [] + }; +} +function cleanMarks(node2) { + node2[isClean] = false; + if (node2.nodes) + node2.nodes.forEach((i2) => cleanMarks(i2)); + return node2; +} +var postcss$2 = {}; +var LazyResult$2 = class LazyResult2 { + constructor(processor2, css, opts) { + this.stringified = false; + this.processed = false; + let root2; + if (typeof css === "object" && css !== null && (css.type === "root" || css.type === "document")) { + root2 = cleanMarks(css); + } else if (css instanceof LazyResult2 || css instanceof Result$2) { + root2 = cleanMarks(css.root); + if (css.map) { + if (typeof opts.map === "undefined") + opts.map = {}; + if (!opts.map.inline) + opts.map.inline = false; + opts.map.prev = css.map; + } + } else { + let parser2 = parse$2; + if (opts.syntax) + parser2 = opts.syntax.parse; + if (opts.parser) + parser2 = opts.parser; + if (parser2.parse) + parser2 = parser2.parse; + try { + root2 = parser2(css, opts); + } catch (error) { + this.processed = true; + this.error = error; + } + if (root2 && !root2[my]) { + Container$1.rebuild(root2); + } + } + this.result = new Result$2(processor2, root2, opts); + this.helpers = { ...postcss$2, postcss: postcss$2, result: this.result }; + this.plugins = this.processor.plugins.map((plugin22) => { + if (typeof plugin22 === "object" && plugin22.prepare) { + return { ...plugin22, ...plugin22.prepare(this.result) }; } else { - if ( - // If the tag name is a custom element name - n2.isCustom && // If the browser supports custom elements - ((_a2 = doc.defaultView) == null ? void 0 : _a2.customElements) && // If the custom element hasn't been defined yet - !doc.defaultView.customElements.get(n2.tagName) - ) - doc.defaultView.customElements.define( - n2.tagName, - class extends doc.defaultView.HTMLElement { - } - ); - node = doc.createElement(tagName); + return plugin22; } - const specialAttributes = {}; - for (const name in n2.attributes) { - if (!Object.prototype.hasOwnProperty.call(n2.attributes, name)) { - continue; - } - let value = n2.attributes[name]; - if (tagName === "option" && name === "selected" && value === false) { - continue; - } - if (value === null) { - continue; - } - if (value === true) - value = ""; - if (name.startsWith("rr_")) { - specialAttributes[name] = value; - continue; - } - if (typeof value !== "string") - ; - else if (tagName === "style" && name === "_cssText") { - buildStyleNode(n2, node, value, options); - continue; - } else if (tagName === "textarea" && name === "value") { - node.appendChild(doc.createTextNode(value)); - try { - n2.childNodes = []; - } catch (err) { - console.warn(`Highlight failed to set rrweb text area child nodes ${err}`); + }); + } + async() { + if (this.error) + return Promise.reject(this.error); + if (this.processed) + return Promise.resolve(this.result); + if (!this.processing) { + this.processing = this.runAsync(); + } + return this.processing; + } + catch(onRejected) { + return this.async().catch(onRejected); + } + finally(onFinally) { + return this.async().then(onFinally, onFinally); + } + getAsyncError() { + throw new Error("Use process(css).then(cb) to work with async plugins"); + } + handleError(error, node2) { + let plugin22 = this.result.lastPlugin; + try { + if (node2) + node2.addToError(error); + this.error = error; + if (error.name === "CssSyntaxError" && !error.plugin) { + error.plugin = plugin22.postcssPlugin; + error.setMessage(); + } else if (plugin22.postcssVersion) { + if (true) { + let pluginName = plugin22.postcssPlugin; + let pluginVer = plugin22.postcssVersion; + let runtimeVer = this.result.processor.version; + let a2 = pluginVer.split("."); + let b = runtimeVer.split("."); + if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) { + console.error( + "Unknown error from PostCSS plugin. Your current PostCSS version is " + runtimeVer + ", but " + pluginName + " uses " + pluginVer + ". Perhaps this is the source of the error below." + ); } - continue; } - try { - if (n2.isSVG && name === "xlink:href") { - node.setAttributeNS( - "http://www.w3.org/1999/xlink", - name, - value.toString() - ); - } else if (name === "onload" || name === "onclick" || name.substring(0, 7) === "onmouse") { - node.setAttribute("_" + name, value.toString()); - } else if (tagName === "meta" && n2.attributes["http-equiv"] === "Content-Security-Policy" && name === "content") { - node.setAttribute("csp-content", value.toString()); - continue; - } else if (tagName === "link" && (n2.attributes.rel === "preload" || n2.attributes.rel === "modulepreload") && n2.attributes.as === "script") { - } else if (tagName === "link" && n2.attributes.rel === "prefetch" && typeof n2.attributes.href === "string" && n2.attributes.href.endsWith(".js")) { - } else if (tagName === "img" && n2.attributes.srcset && n2.attributes.rr_dataURL) { - node.setAttribute( - "rrweb-original-srcset", - n2.attributes.srcset + } + } catch (err) { + if (console && console.error) + console.error(err); + } + return error; + } + prepareVisitors() { + this.listeners = {}; + let add = (plugin22, type, cb) => { + if (!this.listeners[type]) + this.listeners[type] = []; + this.listeners[type].push([plugin22, cb]); + }; + for (let plugin22 of this.plugins) { + if (typeof plugin22 === "object") { + for (let event in plugin22) { + if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) { + throw new Error( + `Unknown event ${event} in ${plugin22.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).` ); - } else { - node.setAttribute(name, value.toString()); } + if (!NOT_VISITORS[event]) { + if (typeof plugin22[event] === "object") { + for (let filter in plugin22[event]) { + if (filter === "*") { + add(plugin22, event, plugin22[event][filter]); + } else { + add( + plugin22, + event + "-" + filter.toLowerCase(), + plugin22[event][filter] + ); + } + } + } else if (typeof plugin22[event] === "function") { + add(plugin22, event, plugin22[event]); + } + } + } + } + } + this.hasListener = Object.keys(this.listeners).length > 0; + } + async runAsync() { + this.plugin = 0; + for (let i2 = 0; i2 < this.plugins.length; i2++) { + let plugin22 = this.plugins[i2]; + let promise = this.runOnRoot(plugin22); + if (isPromise(promise)) { + try { + await promise; } catch (error) { + throw this.handleError(error); } } - for (const name in specialAttributes) { - const value = specialAttributes[name]; - if (tagName === "canvas" && name === "rr_dataURL") { - const image = doc.createElement("img"); - image.onload = () => { - const ctx = node.getContext("2d"); - if (ctx) { - ctx.drawImage(image, 0, 0, image.width, image.height); + } + this.prepareVisitors(); + if (this.hasListener) { + let root2 = this.result.root; + while (!root2[isClean]) { + root2[isClean] = true; + let stack = [toStack(root2)]; + while (stack.length > 0) { + let promise = this.visitTick(stack); + if (isPromise(promise)) { + try { + await promise; + } catch (e2) { + let node2 = stack[stack.length - 1].node; + throw this.handleError(e2, node2); } - }; - image.src = value.toString(); - if (node.RRNodeType) - node.rr_dataURL = value.toString(); - } else if (tagName === "img" && name === "rr_dataURL") { - const image = node; - if (!image.currentSrc.startsWith("data:")) { - image.setAttribute( - "rrweb-original-src", - n2.attributes.src - ); - image.src = value.toString(); } } - if (name === "rr_width") { - node.style.width = value.toString(); - } else if (name === "rr_height") { - node.style.height = value.toString(); - } else if (name === "rr_mediaCurrentTime" && typeof value === "number") { - node.currentTime = value; - } else if (name === "rr_mediaState") { - switch (value) { - case "played": - node.play().catch((e2) => console.warn("media playback error", e2)); - break; - case "paused": - node.pause(); - break; + } + if (this.listeners.OnceExit) { + for (let [plugin22, visitor] of this.listeners.OnceExit) { + this.result.lastPlugin = plugin22; + try { + if (root2.type === "document") { + let roots = root2.nodes.map( + (subRoot) => visitor(subRoot, this.helpers) + ); + await Promise.all(roots); + } else { + await visitor(root2, this.helpers); + } + } catch (e2) { + throw this.handleError(e2); } - } else if (name === "rr_mediaPlaybackRate" && typeof value === "number") { - node.playbackRate = value; - } else if (name === "rr_mediaMuted" && typeof value === "boolean") { - node.muted = value; - } else if (name === "rr_mediaLoop" && typeof value === "boolean") { - node.loop = value; - } else if (name === "rr_mediaVolume" && typeof value === "number") { - node.volume = value; - } else if (name === "rr_open_mode") { - node.setAttribute( - "rr_open_mode", - value + } + } + } + this.processed = true; + return this.stringify(); + } + runOnRoot(plugin22) { + this.result.lastPlugin = plugin22; + try { + if (typeof plugin22 === "object" && plugin22.Once) { + if (this.result.root.type === "document") { + let roots = this.result.root.nodes.map( + (root2) => plugin22.Once(root2, this.helpers) ); + if (isPromise(roots[0])) { + return Promise.all(roots); + } + return roots; } + return plugin22.Once(this.result.root, this.helpers); + } else if (typeof plugin22 === "function") { + return plugin22(this.result.root, this.result); + } + } catch (error) { + throw this.handleError(error); + } + } + stringify() { + if (this.error) + throw this.error; + if (this.stringified) + return this.result; + this.stringified = true; + this.sync(); + let opts = this.result.opts; + let str = stringify$2; + if (opts.syntax) + str = opts.syntax.stringify; + if (opts.stringifier) + str = opts.stringifier; + if (str.stringify) + str = str.stringify; + let map = new MapGenerator$1(str, this.result.root, this.result.opts); + let data = map.generate(); + this.result.css = data[0]; + this.result.map = data[1]; + return this.result; + } + sync() { + if (this.error) + throw this.error; + if (this.processed) + return this.result; + this.processed = true; + if (this.processing) { + throw this.getAsyncError(); + } + for (let plugin22 of this.plugins) { + let promise = this.runOnRoot(plugin22); + if (isPromise(promise)) { + throw this.getAsyncError(); + } + } + this.prepareVisitors(); + if (this.hasListener) { + let root2 = this.result.root; + while (!root2[isClean]) { + root2[isClean] = true; + this.walkSync(root2); } - if (n2.isShadowHost) { - if (!node.shadowRoot) { - node.attachShadow({ mode: "open" }); - } else { - while (node.shadowRoot.firstChild) { - node.shadowRoot.removeChild(node.shadowRoot.firstChild); + if (this.listeners.OnceExit) { + if (root2.type === "document") { + for (let subRoot of root2.nodes) { + this.visitSync(this.listeners.OnceExit, subRoot); } + } else { + this.visitSync(this.listeners.OnceExit, root2); } } - return node; } - case NodeType$2.Text: - if (n2.isStyle && hackCss) { - return doc.createTextNode(adaptCssForReplay(n2.textContent, cache)); - } - return doc.createTextNode(n2.textContent); - case NodeType$2.CDATA: - return doc.createCDATASection(n2.textContent); - case NodeType$2.Comment: - return doc.createComment(n2.textContent); - default: - return null; - } -} -function buildNodeWithSN(n2, options) { - const { - doc, - mirror: mirror2, - skipChild = false, - hackCss = true, - afterAppend, - cache - } = options; - if (mirror2.has(n2.id)) { - const nodeInMirror = mirror2.getNode(n2.id); - const meta = mirror2.getMeta(nodeInMirror); - if (isNodeMetaEqual(meta, n2)) - return mirror2.getNode(n2.id); + return this.result; } - let node = buildNode(n2, { doc, hackCss, cache }); - if (!node) { - return null; + then(onFulfilled, onRejected) { + if (true) { + if (!("from" in this.opts)) { + warnOnce$1( + "Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning." + ); + } + } + return this.async().then(onFulfilled, onRejected); } - if (n2.rootId && mirror2.getNode(n2.rootId) !== doc) { - mirror2.replace(n2.rootId, doc); + toString() { + return this.css; } - if (n2.type === NodeType$2.Document) { - doc.close(); - doc.open(); - if (n2.compatMode === "BackCompat" && n2.childNodes && n2.childNodes[0].type !== NodeType$2.DocumentType) { - if (n2.childNodes[0].type === NodeType$2.Element && "xmlns" in n2.childNodes[0].attributes && n2.childNodes[0].attributes.xmlns === "http://www.w3.org/1999/xhtml") { - doc.write( - '' - ); - } else { - doc.write( - '' - ); + visitSync(visitors, node2) { + for (let [plugin22, visitor] of visitors) { + this.result.lastPlugin = plugin22; + let promise; + try { + promise = visitor(node2, this.helpers); + } catch (e2) { + throw this.handleError(e2, node2.proxyOf); + } + if (node2.type !== "root" && node2.type !== "document" && !node2.parent) { + return true; + } + if (isPromise(promise)) { + throw this.getAsyncError(); } } - node = doc; } - mirror2.add(node, n2); - if ((n2.type === NodeType$2.Document || n2.type === NodeType$2.Element) && !skipChild) { - for (const childN of n2.childNodes) { - const childNode = buildNodeWithSN(childN, { - doc, - mirror: mirror2, - skipChild: false, - hackCss, - afterAppend, - cache - }); - if (!childNode) { - console.warn("Failed to rebuild", childN); - continue; + visitTick(stack) { + let visit2 = stack[stack.length - 1]; + let { node: node2, visitors } = visit2; + if (node2.type !== "root" && node2.type !== "document" && !node2.parent) { + stack.pop(); + return; + } + if (visitors.length > 0 && visit2.visitorIndex < visitors.length) { + let [plugin22, visitor] = visitors[visit2.visitorIndex]; + visit2.visitorIndex += 1; + if (visit2.visitorIndex === visitors.length) { + visit2.visitors = []; + visit2.visitorIndex = 0; } - if (childN.isShadow && isElement(node) && node.shadowRoot) { - node.shadowRoot.appendChild(childNode); - } else if (n2.type === NodeType$2.Document && childN.type == NodeType$2.Element) { - const htmlElement = childNode; - let body = null; - htmlElement.childNodes.forEach((child) => { - if (child.nodeName === "BODY") - body = child; - }); - if (body) { - htmlElement.removeChild(body); - node.appendChild(childNode); - htmlElement.appendChild(body); - } else { - node.appendChild(childNode); + this.result.lastPlugin = plugin22; + try { + return visitor(node2.toProxy(), this.helpers); + } catch (e2) { + throw this.handleError(e2, node2); + } + } + if (visit2.iterator !== 0) { + let iterator = visit2.iterator; + let child; + while (child = node2.nodes[node2.indexes[iterator]]) { + node2.indexes[iterator] += 1; + if (!child[isClean]) { + child[isClean] = true; + stack.push(toStack(child)); + return; } - } else { - node.appendChild(childNode); } - if (afterAppend) { - afterAppend(childNode, childN.id); + visit2.iterator = 0; + delete node2.indexes[iterator]; + } + let events = visit2.events; + while (visit2.eventIndex < events.length) { + let event = events[visit2.eventIndex]; + visit2.eventIndex += 1; + if (event === CHILDREN) { + if (node2.nodes && node2.nodes.length) { + node2[isClean] = true; + visit2.iterator = node2.getIterator(); + } + return; + } else if (this.listeners[event]) { + visit2.visitors = this.listeners[event]; + return; + } + } + stack.pop(); + } + walkSync(node2) { + node2[isClean] = true; + let events = getEvents(node2); + for (let event of events) { + if (event === CHILDREN) { + if (node2.nodes) { + node2.each((child) => { + if (!child[isClean]) + this.walkSync(child); + }); + } + } else { + let visitors = this.listeners[event]; + if (visitors) { + if (this.visitSync(visitors, node2.toProxy())) + return; + } } } } - return node; -} -function visit(mirror2, onVisit) { - function walk(node) { - onVisit(node); + warnings() { + return this.sync().warnings(); } - for (const id of mirror2.getIds()) { - if (mirror2.has(id)) { - walk(mirror2.getNode(id)); - } + get content() { + return this.stringify().content; } -} -function handleScroll(node, mirror2) { - const n2 = mirror2.getMeta(node); - if ((n2 == null ? void 0 : n2.type) !== NodeType$2.Element) { - return; + get css() { + return this.stringify().css; } - const el = node; - for (const name in n2.attributes) { - if (!(Object.prototype.hasOwnProperty.call(n2.attributes, name) && name.startsWith("rr_"))) { - continue; - } - const value = n2.attributes[name]; - if (name === "rr_scrollLeft") { - el.scrollLeft = value; - } - if (name === "rr_scrollTop") { - el.scrollTop = value; - } + get map() { + return this.stringify().map; } -} -function rebuild(n2, options) { - const { - doc, - onVisit, - hackCss = true, - afterAppend, - cache, - mirror: mirror2 = new Mirror() - } = options; - const node = buildNodeWithSN(n2, { - doc, - mirror: mirror2, - skipChild: false, - hackCss, - afterAppend, - cache - }); - visit(mirror2, (visitedNode) => { - if (onVisit) { - onVisit(visitedNode); + get messages() { + return this.sync().messages; + } + get opts() { + return this.result.opts; + } + get processor() { + return this.result.processor; + } + get root() { + return this.sync().root; + } + get [Symbol.toStringTag]() { + return "LazyResult"; + } +}; +LazyResult$2.registerPostcss = (dependant) => { + postcss$2 = dependant; +}; +var lazyResult = LazyResult$2; +LazyResult$2.default = LazyResult$2; +Root$2.registerLazyResult(LazyResult$2); +Document$2.registerLazyResult(LazyResult$2); +var MapGenerator22 = mapGenerator; +var parse$1 = parse_1; +var Result$1 = result; +var stringify$1 = stringify_1; +var warnOnce22 = warnOnce$2; +var NoWorkResult$1 = class NoWorkResult2 { + constructor(processor2, css, opts) { + css = css.toString(); + this.stringified = false; + this._processor = processor2; + this._css = css; + this._opts = opts; + this._map = void 0; + let root2; + let str = stringify$1; + this.result = new Result$1(this._processor, root2, this._opts); + this.result.css = css; + let self2 = this; + Object.defineProperty(this.result, "root", { + get() { + return self2.root; + } + }); + let map = new MapGenerator22(str, root2, this._opts, css); + if (map.isMap()) { + let [generatedCSS, generatedMap] = map.generate(); + if (generatedCSS) { + this.result.css = generatedCSS; + } + if (generatedMap) { + this.result.map = generatedMap; + } + } else { + map.clearAnnotation(); + this.result.css = map.css; } - handleScroll(visitedNode, mirror2); - }); - return node; -} -var __defProp2 = Object.defineProperty; -var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; -var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value); -var __defProp22 = Object.defineProperty; -var __defNormalProp22 = (obj, key, value) => key in obj ? __defProp22(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; -var __publicField22 = (obj, key, value) => __defNormalProp22(obj, typeof key !== "symbol" ? key + "" : key, value); -var NodeType$1 = /* @__PURE__ */ ((NodeType2) => { - NodeType2[NodeType2["Document"] = 0] = "Document"; - NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType"; - NodeType2[NodeType2["Element"] = 2] = "Element"; - NodeType2[NodeType2["Text"] = 3] = "Text"; - NodeType2[NodeType2["CDATA"] = 4] = "CDATA"; - NodeType2[NodeType2["Comment"] = 5] = "Comment"; - return NodeType2; -})(NodeType$1 || {}); -var Mirror$1 = class Mirror2 { - constructor() { - __publicField22(this, "idNodeMap", /* @__PURE__ */ new Map()); - __publicField22(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap()); } - getId(n2) { - var _a2; - if (!n2) - return -1; - const id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id; - return id ?? -1; + async() { + if (this.error) + return Promise.reject(this.error); + return Promise.resolve(this.result); } - getNode(id) { - return this.idNodeMap.get(id) || null; + catch(onRejected) { + return this.async().catch(onRejected); } - getIds() { - return Array.from(this.idNodeMap.keys()); + finally(onFinally) { + return this.async().then(onFinally, onFinally); } - getMeta(n2) { - return this.nodeMetaMap.get(n2) || null; + sync() { + if (this.error) + throw this.error; + return this.result; } - // removes the node from idNodeMap - // doesn't remove the node from nodeMetaMap - removeNodeFromMap(n2) { - const id = this.getId(n2); - this.idNodeMap.delete(id); - if (n2.childNodes) { - n2.childNodes.forEach( - (childNode) => this.removeNodeFromMap(childNode) - ); + then(onFulfilled, onRejected) { + if (true) { + if (!("from" in this._opts)) { + warnOnce22( + "Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning." + ); + } } + return this.async().then(onFulfilled, onRejected); } - has(id) { - return this.idNodeMap.has(id); + toString() { + return this._css; } - hasNode(node) { - return this.nodeMetaMap.has(node); + warnings() { + return []; } - add(n2, meta) { - const id = meta.id; - this.idNodeMap.set(id, n2); - this.nodeMetaMap.set(n2, meta); + get content() { + return this.result.css; } - replace(id, n2) { - const oldNode = this.getNode(id); - if (oldNode) { - const meta = this.nodeMetaMap.get(oldNode); - if (meta) - this.nodeMetaMap.set(n2, meta); + get css() { + return this.result.css; + } + get map() { + return this.result.map; + } + get messages() { + return []; + } + get opts() { + return this.result.opts; + } + get processor() { + return this.result.processor; + } + get root() { + if (this._root) { + return this._root; + } + let root2; + let parser2 = parse$1; + try { + root2 = parser2(this._css, this._opts); + } catch (error) { + this.error = error; + } + if (this.error) { + throw this.error; + } else { + this._root = root2; + return root2; } - this.idNodeMap.set(id, n2); } - reset() { - this.idNodeMap = /* @__PURE__ */ new Map(); - this.nodeMetaMap = /* @__PURE__ */ new WeakMap(); + get [Symbol.toStringTag]() { + return "NoWorkResult"; } }; -function createMirror$1() { - return new Mirror$1(); +var noWorkResult = NoWorkResult$1; +NoWorkResult$1.default = NoWorkResult$1; +var Document$1 = document$1; +var LazyResult$1 = lazyResult; +var NoWorkResult22 = noWorkResult; +var Root$1 = root; +var Processor$1 = class Processor2 { + constructor(plugins = []) { + this.version = "8.4.47"; + this.plugins = this.normalize(plugins); + } + normalize(plugins) { + let normalized = []; + for (let i2 of plugins) { + if (i2.postcss === true) { + i2 = i2(); + } else if (i2.postcss) { + i2 = i2.postcss; + } + if (typeof i2 === "object" && Array.isArray(i2.plugins)) { + normalized = normalized.concat(i2.plugins); + } else if (typeof i2 === "object" && i2.postcssPlugin) { + normalized.push(i2); + } else if (typeof i2 === "function") { + normalized.push(i2); + } else if (typeof i2 === "object" && (i2.parse || i2.stringify)) { + if (true) { + throw new Error( + "PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation." + ); + } + } else { + throw new Error(i2 + " is not a PostCSS plugin"); + } + } + return normalized; + } + process(css, opts = {}) { + if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) { + return new NoWorkResult22(this, css, opts); + } else { + return new LazyResult$1(this, css, opts); + } + } + use(plugin22) { + this.plugins = this.plugins.concat(this.normalize([plugin22])); + return this; + } +}; +var processor = Processor$1; +Processor$1.default = Processor$1; +Root$1.registerProcessor(Processor$1); +Document$1.registerProcessor(Processor$1); +var AtRule22 = atRule; +var Comment22 = comment; +var Container22 = container; +var CssSyntaxError22 = cssSyntaxError; +var Declaration22 = declaration; +var Document222 = document$1; +var fromJSON = fromJSON_1; +var Input22 = input; +var LazyResult22 = lazyResult; +var list = list_1; +var Node22 = node; +var parse = parse_1; +var Processor22 = processor; +var Result22 = result; +var Root22 = root; +var Rule22 = rule; +var stringify = stringify_1; +var Warning22 = warning; +function postcss(...plugins) { + if (plugins.length === 1 && Array.isArray(plugins[0])) { + plugins = plugins[0]; + } + return new Processor22(plugins); } +postcss.plugin = function plugin2(name, initializer) { + let warningPrinted = false; + function creator(...args) { + if (console && console.warn && !warningPrinted) { + warningPrinted = true; + console.warn( + name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration" + ); + if (process.env.LANG && process.env.LANG.startsWith("cn")) { + console.warn( + name + ": \u91CC\u9762 postcss.plugin \u88AB\u5F03\u7528. \u8FC1\u79FB\u6307\u5357:\nhttps://www.w3ctech.com/topic/2226" + ); + } + } + let transformer = initializer(...args); + transformer.postcssPlugin = name; + transformer.postcssVersion = new Processor22().version; + return transformer; + } + let cache; + Object.defineProperty(creator, "postcss", { + get() { + if (!cache) + cache = creator(); + return cache; + } + }); + creator.process = function(css, processOpts, pluginOpts) { + return postcss([creator(pluginOpts)]).process(css, processOpts); + }; + return creator; +}; +postcss.stringify = stringify; +postcss.parse = parse; +postcss.fromJSON = fromJSON; +postcss.list = list; +postcss.comment = (defaults) => new Comment22(defaults); +postcss.atRule = (defaults) => new AtRule22(defaults); +postcss.decl = (defaults) => new Declaration22(defaults); +postcss.rule = (defaults) => new Rule22(defaults); +postcss.root = (defaults) => new Root22(defaults); +postcss.document = (defaults) => new Document222(defaults); +postcss.CssSyntaxError = CssSyntaxError22; +postcss.Declaration = Declaration22; +postcss.Container = Container22; +postcss.Processor = Processor22; +postcss.Document = Document222; +postcss.Comment = Comment22; +postcss.Warning = Warning22; +postcss.AtRule = AtRule22; +postcss.Result = Result22; +postcss.Input = Input22; +postcss.Rule = Rule22; +postcss.Root = Root22; +postcss.Node = Node22; +LazyResult22.registerPostcss(postcss); +var postcss_1 = postcss; +postcss.default = postcss; +var postcss$1 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1); +postcss$1.stringify; +postcss$1.fromJSON; +postcss$1.plugin; +postcss$1.parse; +postcss$1.list; +postcss$1.document; +postcss$1.comment; +postcss$1.atRule; +postcss$1.rule; +postcss$1.decl; +postcss$1.root; +postcss$1.CssSyntaxError; +postcss$1.Declaration; +postcss$1.Container; +postcss$1.Processor; +postcss$1.Document; +postcss$1.Comment; +postcss$1.Warning; +postcss$1.AtRule; +postcss$1.Result; +postcss$1.Input; +postcss$1.Rule; +postcss$1.Root; +postcss$1.Node; function parseCSSText(cssText) { const res = {}; const listDelimiter = /;(?![^(]*\))/g; const propertyDelimiter = /:(.+)/; - const comment = /\/\*.*?\*\//g; - cssText.replace(comment, "").split(listDelimiter).forEach(function(item) { + const comment2 = /\/\*.*?\*\//g; + cssText.replace(comment2, "").split(listDelimiter).forEach(function(item) { if (item) { const tmp = item.split(propertyDelimiter); tmp.length > 1 && (res[camelize(tmp[0].trim())] = tmp[1].trim()); @@ -2575,17 +9505,17 @@ var BaseRRNode = class _BaseRRNode { } return childNodes2; } - contains(node) { - if (!(node instanceof _BaseRRNode)) + contains(node2) { + if (!(node2 instanceof _BaseRRNode)) return false; - else if (node.ownerDocument !== this.ownerDocument) + else if (node2.ownerDocument !== this.ownerDocument) return false; - else if (node === this) + else if (node2 === this) return true; - while (node.parentNode) { - if (node.parentNode === this) + while (node2.parentNode) { + if (node2.parentNode === this) return true; - node = node.parentNode; + node2 = node2.parentNode; } return false; } @@ -2624,19 +9554,19 @@ var BaseRRDocument = class _BaseRRDocument extends BaseRRNode { } get documentElement() { return this.childNodes.find( - (node) => node.RRNodeType === NodeType$1.Element && node.tagName === "HTML" + (node2) => node2.RRNodeType === NodeType$1.Element && node2.tagName === "HTML" ) || null; } get body() { var _a2; return ((_a2 = this.documentElement) == null ? void 0 : _a2.childNodes.find( - (node) => node.RRNodeType === NodeType$1.Element && node.tagName === "BODY" + (node2) => node2.RRNodeType === NodeType$1.Element && node2.tagName === "BODY" )) || null; } get head() { var _a2; return ((_a2 = this.documentElement) == null ? void 0 : _a2.childNodes.find( - (node) => node.RRNodeType === NodeType$1.Element && node.tagName === "HEAD" + (node2) => node2.RRNodeType === NodeType$1.Element && node2.tagName === "HEAD" )) || null; } get implementation() { @@ -2671,8 +9601,8 @@ var BaseRRDocument = class _BaseRRDocument extends BaseRRNode { child.parentElement = null; return child; } - removeChild(node) { - return removeChild(this, node); + removeChild(node2) { + return removeChild(this, node2); } open() { this.firstChild = null; @@ -2720,9 +9650,9 @@ var BaseRRDocument = class _BaseRRDocument extends BaseRRNode { return text; } createComment(data) { - const comment = new BaseRRComment(data); - comment.ownerDocument = this; - return comment; + const comment2 = new BaseRRComment(data); + comment2.ownerDocument = this; + return comment2; } createCDATASection(data) { const CDATASection = new BaseRRCDATASection(data); @@ -2765,9 +9695,9 @@ var BaseRRElement = class extends BaseRRNode { this.nodeName = tagName.toUpperCase(); } get textContent() { - let result = ""; - this.childNodes.forEach((node) => result += node.textContent); - return result; + let result2 = ""; + this.childNodes.forEach((node2) => result2 += node2.textContent); + return result2; } set textContent(textContent2) { this.firstChild = null; @@ -2834,8 +9764,8 @@ var BaseRRElement = class extends BaseRRNode { insertBefore(newChild, refChild) { return insertBefore(this, newChild, refChild); } - removeChild(node) { - return removeChild(this, node); + removeChild(node2) { + return removeChild(this, node2); } // eslint-disable-next-line @typescript-eslint/no-unused-vars attachShadow(_init) { @@ -3425,12 +10355,12 @@ function diffChildren(oldTree, newTree, replayer, rrnodeMirror) { } } else if (newStartIndex > newEndIndex) { for (; oldStartIndex <= oldEndIndex; oldStartIndex++) { - const node = oldChildren[oldStartIndex]; - if (!node || node.parentNode !== oldTree) + const node2 = oldChildren[oldStartIndex]; + if (!node2 || node2.parentNode !== oldTree) continue; try { - oldTree.removeChild(node); - replayer.mirror.removeNodeFromMap(node); + oldTree.removeChild(node2); + replayer.mirror.removeNodeFromMap(node2); } catch (e2) { console.warn(e2); } @@ -3447,17 +10377,17 @@ function diffChildren(oldTree, newTree, replayer, rrnodeMirror) { function createOrGetNode(rrNode, domMirror, rrnodeMirror) { const nodeId = rrnodeMirror.getId(rrNode); const sn = rrnodeMirror.getMeta(rrNode); - let node = null; + let node2 = null; if (nodeId > -1) - node = domMirror.getNode(nodeId); - if (node !== null && sameNodeType(node, rrNode)) - return node; + node2 = domMirror.getNode(nodeId); + if (node2 !== null && sameNodeType(node2, rrNode)) + return node2; switch (rrNode.RRNodeType) { case NodeType$1.Document: - node = new Document(); + node2 = new Document(); break; case NodeType$1.DocumentType: - node = document.implementation.createDocumentType( + node2 = document.implementation.createDocumentType( rrNode.name, rrNode.publicId, rrNode.systemId @@ -3467,28 +10397,28 @@ function createOrGetNode(rrNode, domMirror, rrnodeMirror) { let tagName = rrNode.tagName.toLowerCase(); tagName = SVGTagMap[tagName] || tagName; if (sn && "isSVG" in sn && (sn == null ? void 0 : sn.isSVG)) { - node = document.createElementNS(NAMESPACES["svg"], tagName); + node2 = document.createElementNS(NAMESPACES["svg"], tagName); } else - node = document.createElement(rrNode.tagName); + node2 = document.createElement(rrNode.tagName); break; } case NodeType$1.Text: - node = document.createTextNode(rrNode.data); + node2 = document.createTextNode(rrNode.data); break; case NodeType$1.Comment: - node = document.createComment(rrNode.data); + node2 = document.createComment(rrNode.data); break; case NodeType$1.CDATA: - node = document.createCDATASection(rrNode.data); + node2 = document.createCDATASection(rrNode.data); break; } if (sn) - domMirror.add(node, { ...sn }); + domMirror.add(node2, { ...sn }); try { - createdNodeSet == null ? void 0 : createdNodeSet.add(node); + createdNodeSet == null ? void 0 : createdNodeSet.add(node2); } catch (e2) { } - return node; + return node2; } function sameNodeType(node1, node2) { if (node1.nodeType !== node2.nodeType) @@ -3630,19 +10560,19 @@ function getValidTagName(element) { } return element.tagName.toUpperCase(); } -function buildFromNode(node, rrdom, domMirror, parentRRNode) { +function buildFromNode(node2, rrdom, domMirror, parentRRNode) { let rrNode; - switch (node.nodeType) { + switch (node2.nodeType) { case NodeType.DOCUMENT_NODE: if (parentRRNode && parentRRNode.nodeName === "IFRAME") rrNode = parentRRNode.contentDocument; else { rrNode = rrdom; - rrNode.compatMode = node.compatMode; + rrNode.compatMode = node2.compatMode; } break; case NodeType.DOCUMENT_TYPE_NODE: { - const documentType = node; + const documentType = node2; rrNode = rrdom.createDocumentType( documentType.name, documentType.publicId, @@ -3651,7 +10581,7 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) { break; } case NodeType.ELEMENT_NODE: { - const elementNode = node; + const elementNode = node2; const tagName = getValidTagName(elementNode); rrNode = rrdom.createElement(tagName); const rrElement = rrNode; @@ -3663,13 +10593,13 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) { break; } case NodeType.TEXT_NODE: - rrNode = rrdom.createTextNode(node.textContent || ""); + rrNode = rrdom.createTextNode(node2.textContent || ""); break; case NodeType.CDATA_SECTION_NODE: - rrNode = rrdom.createCDATASection(node.data); + rrNode = rrdom.createCDATASection(node2.data); break; case NodeType.COMMENT_NODE: - rrNode = rrdom.createComment(node.textContent || ""); + rrNode = rrdom.createComment(node2.textContent || ""); break; case NodeType.DOCUMENT_FRAGMENT_NODE: rrNode = parentRRNode.attachShadow({ mode: "open" }); @@ -3677,37 +10607,37 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) { default: return null; } - let sn = domMirror.getMeta(node); + let sn = domMirror.getMeta(node2); if (rrdom instanceof RRDocument) { if (!sn) { sn = getDefaultSN(rrNode, rrdom.unserializedId); - domMirror.add(node, sn); + domMirror.add(node2, sn); } rrdom.mirror.add(rrNode, { ...sn }); } return rrNode; } function buildFromDom(dom, domMirror = createMirror$1(), rrdom = new RRDocument()) { - function walk2(node, parentRRNode) { - const rrNode = buildFromNode(node, rrdom, domMirror, parentRRNode); + function walk2(node2, parentRRNode) { + const rrNode = buildFromNode(node2, rrdom, domMirror, parentRRNode); if (rrNode === null) return; if ( // if the parentRRNode isn't a RRIFrameElement (parentRRNode == null ? void 0 : parentRRNode.nodeName) !== "IFRAME" && // if node isn't a shadow root - node.nodeType !== NodeType.DOCUMENT_FRAGMENT_NODE + node2.nodeType !== NodeType.DOCUMENT_FRAGMENT_NODE ) { parentRRNode == null ? void 0 : parentRRNode.appendChild(rrNode); rrNode.parentNode = parentRRNode; rrNode.parentElement = parentRRNode; } - if (node.nodeName === "IFRAME") { - const iframeDoc = node.contentDocument; + if (node2.nodeName === "IFRAME") { + const iframeDoc = node2.contentDocument; iframeDoc && walk2(iframeDoc, rrNode); - } else if (node.nodeType === NodeType.DOCUMENT_NODE || node.nodeType === NodeType.ELEMENT_NODE || node.nodeType === NodeType.DOCUMENT_FRAGMENT_NODE) { - if (node.nodeType === NodeType.ELEMENT_NODE && node.shadowRoot) - walk2(node.shadowRoot, rrNode); - node.childNodes.forEach((childNode) => walk2(childNode, rrNode)); + } else if (node2.nodeType === NodeType.DOCUMENT_NODE || node2.nodeType === NodeType.ELEMENT_NODE || node2.nodeType === NodeType.DOCUMENT_FRAGMENT_NODE) { + if (node2.nodeType === NodeType.ELEMENT_NODE && node2.shadowRoot) + walk2(node2.shadowRoot, rrNode); + node2.childNodes.forEach((childNode) => walk2(childNode, rrNode)); } } walk2(dom, null); @@ -3749,8 +10679,8 @@ var Mirror22 = class { has(id) { return this.idNodeMap.has(id); } - hasNode(node) { - return this.nodeMetaMap.has(node); + hasNode(node2) { + return this.nodeMetaMap.has(node2); } add(n2, meta) { const id = meta.id; @@ -3771,19 +10701,19 @@ var Mirror22 = class { this.nodeMetaMap = /* @__PURE__ */ new WeakMap(); } }; -function getDefaultSN(node, id) { - switch (node.RRNodeType) { +function getDefaultSN(node2, id) { + switch (node2.RRNodeType) { case NodeType$1.Document: return { id, - type: node.RRNodeType, + type: node2.RRNodeType, childNodes: [] }; case NodeType$1.DocumentType: { - const doctype = node; + const doctype = node2; return { id, - type: node.RRNodeType, + type: node2.RRNodeType, name: doctype.name, publicId: doctype.publicId, systemId: doctype.systemId @@ -3792,8 +10722,8 @@ function getDefaultSN(node, id) { case NodeType$1.Element: return { id, - type: node.RRNodeType, - tagName: node.tagName.toLowerCase(), + type: node2.RRNodeType, + tagName: node2.tagName.toLowerCase(), // In rrweb data, all tagNames are lowercase. attributes: {}, childNodes: [] @@ -3801,19 +10731,19 @@ function getDefaultSN(node, id) { case NodeType$1.Text: return { id, - type: node.RRNodeType, - textContent: node.textContent || "" + type: node2.RRNodeType, + textContent: node2.textContent || "" }; case NodeType$1.Comment: return { id, - type: node.RRNodeType, - textContent: node.textContent || "" + type: node2.RRNodeType, + textContent: node2.textContent || "" }; case NodeType$1.CDATA: return { id, - type: node.RRNodeType, + type: node2.RRNodeType, textContent: "" }; } @@ -4088,28 +11018,28 @@ function getWindowHeight() { function getWindowWidth() { return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth; } -function closestElementOfNode(node) { - if (!node) { +function closestElementOfNode(node2) { + if (!node2) { return null; } - const el = node.nodeType === node.ELEMENT_NODE ? node : index.parentElement(node); + const el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2); return el; } -var isCanvasNode = (node) => { +var isCanvasNode = (node2) => { try { - if (node instanceof HTMLElement) { - return node.tagName === "CANVAS"; + if (node2 instanceof HTMLElement) { + return node2.tagName === "CANVAS"; } } catch { return false; } return false; }; -function isBlocked(node, blockClass, blockSelector, checkAncestors) { - if (!node) { +function isBlocked(node2, blockClass, blockSelector, checkAncestors) { + if (!node2) { return false; } - const el = closestElementOfNode(node); + const el = closestElementOfNode(node2); if (!el) { return false; } @@ -4222,9 +11152,9 @@ function isSerializedStylesheet(n2, mirror2) { n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2) ); } -function getBaseDimension(node, rootIframe) { +function getBaseDimension(node2, rootIframe) { var _a2, _b; - const frameElement = (_b = (_a2 = node.ownerDocument) == null ? void 0 : _a2.defaultView) == null ? void 0 : _b.frameElement; + const frameElement = (_b = (_a2 = node2.ownerDocument) == null ? void 0 : _a2.defaultView) == null ? void 0 : _b.frameElement; if (!frameElement || frameElement === rootIframe) { return { x: 0, @@ -4252,12 +11182,12 @@ function hasShadowRoot(n2) { return Boolean(index.shadowRoot(n2)); } function getNestedRule(rules2, position) { - const rule = rules2[position[0]]; + const rule2 = rules2[position[0]]; if (position.length === 1) { - return rule; + return rule2; } else { return getNestedRule( - rule.cssRules[position[1]].cssRules, + rule2.cssRules[position[1]].cssRules, position.slice(2) ); } @@ -4487,37 +11417,37 @@ var DoubleLinkedList = class { return current; } addNode(n2) { - const node = { + const node2 = { value: n2, previous: null, next: null }; - n2.__ln = node; + n2.__ln = node2; if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) { const current = n2.previousSibling.__ln.next; - node.next = current; - node.previous = n2.previousSibling.__ln; - n2.previousSibling.__ln.next = node; + node2.next = current; + node2.previous = n2.previousSibling.__ln; + n2.previousSibling.__ln.next = node2; if (current) { - current.previous = node; + current.previous = node2; } } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) { const current = n2.nextSibling.__ln.previous; - node.previous = current; - node.next = n2.nextSibling.__ln; - n2.nextSibling.__ln.previous = node; + node2.previous = current; + node2.next = n2.nextSibling.__ln; + n2.nextSibling.__ln.previous = node2; if (current) { - current.next = node; + current.next = node2; } } else { if (this.head) { - this.head.previous = node; + this.head.previous = node2; } - node.next = this.head; - this.head = node; + node2.next = this.head; + this.head = node2; } - if (node.next === null) { - this.tail = node; + if (node2.next === null) { + this.tail = node2; } this.length++; } @@ -4561,6 +11491,7 @@ var MutationBuffer = class { __publicField(this, "addedSet", /* @__PURE__ */ new Set()); __publicField(this, "movedSet", /* @__PURE__ */ new Set()); __publicField(this, "droppedSet", /* @__PURE__ */ new Set()); + __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set()); __publicField(this, "mutationCb"); __publicField(this, "blockClass"); __publicField(this, "blockSelector"); @@ -4676,13 +11607,13 @@ var MutationBuffer = class { this.mirror.removeNodeFromMap(this.mapRemoves.shift()); } for (const n2 of this.movedSet) { - if (isParentRemoved(this.removes, n2, this.mirror) && !this.movedSet.has(index.parentNode(n2))) { + if (isParentRemoved(this.removesSubTreeCache, n2, this.mirror) && !this.movedSet.has(index.parentNode(n2))) { continue; } pushAdd(n2); } for (const n2 of this.addedSet) { - if (!isAncestorInSet(this.droppedSet, n2) && !isParentRemoved(this.removes, n2, this.mirror)) { + if (!isAncestorInSet(this.droppedSet, n2) && !isParentRemoved(this.removesSubTreeCache, n2, this.mirror)) { pushAdd(n2); } else if (isAncestorInSet(this.movedSet, n2)) { pushAdd(n2); @@ -4692,15 +11623,15 @@ var MutationBuffer = class { } let candidate = null; while (addList.length) { - let node = null; + let node2 = null; if (candidate) { const parentId = this.mirror.getId(index.parentNode(candidate.value)); const nextId = getNextId(candidate.value); if (parentId !== -1 && nextId !== -1) { - node = candidate; + node2 = candidate; } } - if (!node) { + if (!node2) { let tailNode = addList.tail; while (tailNode) { const _node = tailNode; @@ -4711,7 +11642,7 @@ var MutationBuffer = class { if (nextId === -1) continue; else if (parentId !== -1) { - node = _node; + node2 = _node; break; } else { const unhandledNode = _node.value; @@ -4720,7 +11651,7 @@ var MutationBuffer = class { const shadowHost = index.host(parent); const parentId2 = this.mirror.getId(shadowHost); if (parentId2 !== -1) { - node = _node; + node2 = _node; break; } } @@ -4728,15 +11659,15 @@ var MutationBuffer = class { } } } - if (!node) { + if (!node2) { while (addList.head) { addList.removeNode(addList.head.value); } break; } - candidate = node.previous; - addList.removeNode(node.value); - pushAdd(node.value); + candidate = node2.previous; + addList.removeNode(node2.value); + pushAdd(node2.value); } const payload = { texts: this.texts.map((text) => { @@ -4787,6 +11718,7 @@ var MutationBuffer = class { this.addedSet = /* @__PURE__ */ new Set(); this.movedSet = /* @__PURE__ */ new Set(); this.droppedSet = /* @__PURE__ */ new Set(); + this.removesSubTreeCache = /* @__PURE__ */ new Set(); this.movedMap = {}; this.mutationCb(payload); }); @@ -4871,9 +11803,9 @@ var MutationBuffer = class { if (!ignoreAttribute(target.tagName, attributeName)) { const tagName = m.target.tagName; if (tagName === "INPUT") { - const node = m.target; - if (node.type === "password") { - item.attributes["value"] = "*".repeat(node.value.length); + const node2 = m.target; + if (node2.type === "password") { + item.attributes["value"] = "*".repeat(node2.value.length); break; } } @@ -4952,6 +11884,7 @@ var MutationBuffer = class { id: nodeId, isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0 }); + processRemoves(n2, this.removesSubTreeCache); } this.mapRemoves.push(n2); }); @@ -5049,21 +11982,27 @@ function deepDelete(addsSet, n2) { addsSet.delete(n2); index.childNodes(n2).forEach((childN) => deepDelete(addsSet, childN)); } +function processRemoves(n2, cache) { + const queue = [n2]; + while (queue.length) { + const next = queue.pop(); + if (cache.has(next)) + continue; + cache.add(next); + index.childNodes(next).forEach((n22) => queue.push(n22)); + } + return; +} function isParentRemoved(removes, n2, mirror2) { - if (removes.length === 0) + if (removes.size === 0) return false; - return _isParentRemoved(removes, n2, mirror2); + return _isParentRemoved(removes, n2); } -function _isParentRemoved(removes, n2, mirror2) { - let node = index.parentNode(n2); - while (node) { - const parentId = mirror2.getId(node); - if (removes.some((r2) => r2.id === parentId)) { - return true; - } - node = index.parentNode(node); - } - return false; +function _isParentRemoved(removes, n2, _mirror2) { + const node2 = index.parentNode(n2); + if (!node2) + return false; + return removes.has(node2); } function isAncestorInSet(set, n2) { if (set.size === 0) @@ -5479,7 +12418,7 @@ function initInputObserver({ handlers.forEach((h) => h()); }); } -function getNestedCSSRulePositions(rule) { +function getNestedCSSRulePositions(rule2) { const positions = []; function recurse(childRule, pos) { if (hasNestedCSSRule("CSSGroupingRule") && childRule.parentRule instanceof CSSGroupingRule || hasNestedCSSRule("CSSMediaRule") && childRule.parentRule instanceof CSSMediaRule || hasNestedCSSRule("CSSSupportsRule") && childRule.parentRule instanceof CSSSupportsRule || hasNestedCSSRule("CSSConditionRule") && childRule.parentRule instanceof CSSConditionRule) { @@ -5495,7 +12434,7 @@ function getNestedCSSRulePositions(rule) { } return pos; } - return recurse(rule, positions); + return recurse(rule2, positions); } function getIdAndStyleId(sheet, mirror2, styleMirror) { let id, styleId; @@ -5519,7 +12458,7 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, { apply: callbackWrapper( (target, thisArg, argumentsList) => { - const [rule, index2] = argumentsList; + const [rule2, index2] = argumentsList; const { id, styleId } = getIdAndStyleId( thisArg, mirror2, @@ -5529,7 +12468,7 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM styleSheetRuleCb({ id, styleId, - adds: [{ rule, index: index2 }] + adds: [{ rule: rule2, index: index2 }] }); } return target.apply(thisArg, argumentsList); @@ -5537,8 +12476,8 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM ) }); win.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index2 = this.cssRules.length) { - const rule = `${selector} { ${styleBlock} }`; - return win.CSSStyleSheet.prototype.insertRule.apply(this, [rule, index2]); + const rule2 = `${selector} { ${styleBlock} }`; + return win.CSSStyleSheet.prototype.insertRule.apply(this, [rule2, index2]); }; const deleteRule = win.CSSStyleSheet.prototype.deleteRule; win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, { @@ -5639,7 +12578,7 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM { apply: callbackWrapper( (target, thisArg, argumentsList) => { - const [rule, index2] = argumentsList; + const [rule2, index2] = argumentsList; const { id, styleId } = getIdAndStyleId( thisArg.parentStyleSheet, mirror2, @@ -5651,7 +12590,7 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror: mirror2, stylesheetM styleId, adds: [ { - rule, + rule: rule2, index: [ ...getNestedCSSRulePositions(thisArg), index2 || 0 @@ -5730,14 +12669,14 @@ function initAdoptedStyleSheetObserver({ }, set(sheets) { var _a3; - const result = (_a3 = originalPropertyDescriptor.set) == null ? void 0 : _a3.call(this, sheets); + const result2 = (_a3 = originalPropertyDescriptor.set) == null ? void 0 : _a3.call(this, sheets); if (hostId !== null && hostId !== -1) { try { stylesheetManager.adoptStyleSheets(sheets, hostId); } catch (e2) { } } - return result; + return result2; } }); return callbackWrapper(() => { @@ -6099,9 +13038,9 @@ function initObservers(o2, hooks = {}) { const selectionObserver = initSelectionObserver(o2); const customElementObserver = initCustomElementObserver(o2); const pluginHandlers = []; - for (const plugin of o2.plugins) { + for (const plugin3 of o2.plugins) { pluginHandlers.push( - plugin.observer(plugin.callback, currentWindow, plugin.options) + plugin3.observer(plugin3.callback, currentWindow, plugin3.options) ); } return callbackWrapper(() => { @@ -6415,19 +13354,19 @@ var IframeManager = class { replaceStyleIds(obj, iframeEl, keys) { return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys); } - replaceIdOnNode(node, iframeEl) { - this.replaceIds(node, iframeEl, ["id", "rootId"]); - if ("childNodes" in node) { - node.childNodes.forEach((child) => { + replaceIdOnNode(node2, iframeEl) { + this.replaceIds(node2, iframeEl, ["id", "rootId"]); + if ("childNodes" in node2) { + node2.childNodes.forEach((child) => { this.replaceIdOnNode(child, iframeEl); }); } } - patchRootIdOnNode(node, rootId) { - if (node.type !== NodeType$2.Document && !node.rootId) - node.rootId = rootId; - if ("childNodes" in node) { - node.childNodes.forEach((child) => { + patchRootIdOnNode(node2, rootId) { + if (node2.type !== NodeType$2.Document && !node2.rootId) + node2.rootId = rootId; + if ("childNodes" in node2) { + node2.childNodes.forEach((child) => { this.patchRootIdOnNode(child, rootId); }); } @@ -6595,11 +13534,11 @@ var saveWebGLVar = (value, win, ctx) => { if (!value || !(isInstanceOfWebGLObject(value, win) || typeof value === "object")) return; const name = value.constructor.name; - const list = variableListFor$1(ctx, name); - let index2 = list.indexOf(value); + const list2 = variableListFor$1(ctx, name); + let index2 = list2.indexOf(value); if (index2 === -1) { - index2 = list.length; - list.push(value); + index2 = list2.length; + list2.push(value); } return index2; }; @@ -6809,8 +13748,8 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) { prop, function(original) { return function(...args) { - const result = original.apply(this, args); - saveWebGLVar(result, win, this); + const result2 = original.apply(this, args); + saveWebGLVar(result2, win, this); if ("tagName" in this.canvas && !isBlocked( this.canvas, blockClass, @@ -6825,7 +13764,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) { }; cb(this.canvas, mutation); } - return result; + return result2; }; } ); @@ -6876,18 +13815,18 @@ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) { } var encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIGxldCBsb2dEZWJ1ZyA9IGZhbHNlOwogIGNvbnN0IGRlYnVnID0gKC4uLmFyZ3MpID0+IHsKICAgIGlmIChsb2dEZWJ1ZykgewogICAgICBjb25zb2xlLmRlYnVnKC4uLmFyZ3MpOwogICAgfQogIH07CiAgd29ya2VyLm9ubWVzc2FnZSA9IGFzeW5jIGZ1bmN0aW9uKGUpIHsKICAgIGxvZ0RlYnVnID0gISFlLmRhdGEubG9nRGVidWc7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGR4LCBkeSwgZHcsIGRoLCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOwogICAgICBjb25zdCB0cmFuc3BhcmVudEJhc2U2NCA9IGdldFRyYW5zcGFyZW50QmxvYkZvcigKICAgICAgICB3aWR0aCwKICAgICAgICBoZWlnaHQsCiAgICAgICAgZGF0YVVSTE9wdGlvbnMKICAgICAgKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgY29uc3QgY3R4ID0gb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgYml0bWFwLmNsb3NlKCk7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgYXdhaXQgdHJhbnNwYXJlbnRCYXNlNjQgPT09IGJhc2U2NCkgewogICAgICAgIGRlYnVnKCJbaGlnaGxpZ2h0LXdvcmtlcl0gY2FudmFzIGJpdG1hcCBpcyB0cmFuc3BhcmVudCIsIHsKICAgICAgICAgIGlkLAogICAgICAgICAgYmFzZTY0CiAgICAgICAgfSk7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCwgc3RhdHVzOiAidHJhbnNwYXJlbnQiIH0pOwogICAgICB9CiAgICAgIGlmIChsYXN0QmxvYk1hcC5nZXQoaWQpID09PSBiYXNlNjQpIHsKICAgICAgICBkZWJ1ZygiW2hpZ2hsaWdodC13b3JrZXJdIGNhbnZhcyBiaXRtYXAgaXMgdW5jaGFuZ2VkIiwgewogICAgICAgICAgaWQsCiAgICAgICAgICBiYXNlNjQKICAgICAgICB9KTsKICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQsIHN0YXR1czogInVuY2hhbmdlZCIgfSk7CiAgICAgIH0KICAgICAgY29uc3QgbXNnID0gewogICAgICAgIGlkLAogICAgICAgIHR5cGUsCiAgICAgICAgYmFzZTY0LAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkeCwKICAgICAgICBkeSwKICAgICAgICBkdywKICAgICAgICBkaAogICAgICB9OwogICAgICBkZWJ1ZygiW2hpZ2hsaWdodC13b3JrZXJdIGNhbnZhcyBiaXRtYXAgcHJvY2Vzc2VkIiwgbXNnKTsKICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKG1zZyk7CiAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsKICAgIH0gZWxzZSB7CiAgICAgIGRlYnVnKCJbaGlnaGxpZ2h0LXdvcmtlcl0gbm8gb2Zmc2NyZWVuY2FudmFzIHN1cHBvcnQiLCB7CiAgICAgICAgaWQ6IGUuZGF0YS5pZAogICAgICB9KTsKICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkOiBlLmRhdGEuaWQsIHN0YXR1czogInVuc3VwcG9ydGVkIiB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUJpWEpSZjQ3LmpzLm1hcAo="; var decodeBase64 = (base64) => Uint8Array.from(atob(base64), (c2) => c2.charCodeAt(0)); -var blob = typeof window !== "undefined" && window.Blob && new Blob([decodeBase64(encodedJs)], { type: "text/javascript;charset=utf-8" }); +var blob = typeof self !== "undefined" && self.Blob && new Blob([decodeBase64(encodedJs)], { type: "text/javascript;charset=utf-8" }); function WorkerWrapper(options) { let objURL; try { - objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob); + objURL = blob && (self.URL || self.webkitURL).createObjectURL(blob); if (!objURL) throw ""; const worker = new Worker(objURL, { name: options == null ? void 0 : options.name }); worker.addEventListener("error", () => { - (window.URL || window.webkitURL).revokeObjectURL(objURL); + (self.URL || self.webkitURL).revokeObjectURL(objURL); }); return worker; } catch (e2) { @@ -6898,7 +13837,7 @@ function WorkerWrapper(options) { } ); } finally { - objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL); + objURL && (self.URL || self.webkitURL).revokeObjectURL(objURL); } } var CanvasManager = class { @@ -7120,10 +14059,10 @@ var CanvasManager = class { let lastSnapshotTime = 0; let rafId; const elementFoundTime = /* @__PURE__ */ new Map(); - const querySelectorAll2 = (node, selector) => { + const querySelectorAll2 = (node2, selector) => { const nodes = []; - node.querySelectorAll(selector).forEach((n2) => nodes.push(n2)); - const nodeIterator = document.createNodeIterator(node, Node.ELEMENT_NODE); + node2.querySelectorAll(selector).forEach((n2) => nodes.push(n2)); + const nodeIterator = document.createNodeIterator(node2, Node.ELEMENT_NODE); let currentNode; while (currentNode = nodeIterator.nextNode()) { if (currentNode == null ? void 0 : currentNode.shadowRoot) { @@ -7410,11 +14349,11 @@ var ProcessedNodeManager = class { __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap()); __publicField(this, "active", false); } - inOtherBuffer(node, thisBuffer) { - const buffers = this.nodeMap.get(node); + inOtherBuffer(node2, thisBuffer) { + const buffers = this.nodeMap.get(node2); return buffers && Array.from(buffers).some((buffer) => buffer !== thisBuffer); } - add(node, buffer) { + add(node2, buffer) { if (!this.active) { this.active = true; requestAnimationFrame(() => { @@ -7422,7 +14361,7 @@ var ProcessedNodeManager = class { this.active = false; }); } - this.nodeMap.set(node, (this.nodeMap.get(node) || /* @__PURE__ */ new Set()).add(buffer)); + this.nodeMap.set(node2, (this.nodeMap.get(node2) || /* @__PURE__ */ new Set()).add(buffer)); } destroy() { } @@ -7432,7 +14371,7 @@ var takeFullSnapshot$1; var canvasManager; var recording = false; try { - if (Array.from([1], (x) => x * 2)[0] !== 2) { + if (Array.from([1], (x2) => x2 * 2)[0] !== 2) { const cleanFrame = document.createElement("iframe"); document.body.appendChild(cleanFrame); Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from; @@ -7542,9 +14481,9 @@ function record(options = {}) { let lastFullSnapshotEvent; let incrementalSnapshotCount = 0; const eventProcessor = (e2) => { - for (const plugin of plugins || []) { - if (plugin.eventProcessor) { - e2 = plugin.eventProcessor(e2); + for (const plugin3 of plugins || []) { + if (plugin3.eventProcessor) { + e2 = plugin3.eventProcessor(e2); } } if (packFn && // Disable packing events which will be emitted to parent frames. @@ -7627,9 +14566,9 @@ function record(options = {}) { recordCrossOriginIframes, wrappedEmit }); - for (const plugin of plugins || []) { - if (plugin.getMirror) - plugin.getMirror({ + for (const plugin3 of plugins || []) { + if (plugin3.getMirror) + plugin3.getMirror({ nodeMirror: mirror, crossOriginIframeMirror: iframeManager.crossOriginIframeMirror, crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror @@ -7697,7 +14636,7 @@ function record(options = {}) { stylesheetManager.reset(); shadowDomManager.init(); mutationBuffers.forEach((buf) => buf.lock()); - const node = snapshot(document, { + const node2 = snapshot(document, { mirror, blockClass, blockSelector, @@ -7732,14 +14671,14 @@ function record(options = {}) { }, keepIframeSrcFn }); - if (!node) { + if (!node2) { return console.warn("Failed to snapshot the document"); } wrappedEmit( { type: EventType.FullSnapshot, data: { - node, + node: node2, initialOffset: getWindowScroll(window) } }, @@ -7994,8 +14933,8 @@ function polyfill(w = window, d = document) { return new RegExp(userAgentPatterns.join("|")).test(userAgent); } const ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0; - function scrollElement(x, y) { - this.scrollLeft = x; + function scrollElement(x2, y) { + this.scrollLeft = x2; this.scrollTop = y; } function ease(k) { @@ -8050,7 +14989,7 @@ function polyfill(w = window, d = document) { w.requestAnimationFrame(step.bind(w, context)); } } - function smoothScroll(el, x, y) { + function smoothScroll(el, x2, y) { let scrollable; let startX; let startY; @@ -8073,7 +15012,7 @@ function polyfill(w = window, d = document) { startTime, startX, startY, - x, + x: x2, y }); } @@ -8359,9 +15298,9 @@ function s(n2, o2) { var s2 = t(f(r(n2.states[n2.initial].entry).map(function(t2) { return i(t2, o2.actions); }), n2.context, e), 2), l2 = s2[0], v2 = s2[1], y = { config: n2, _options: o2, initialState: { value: n2.initial, actions: l2, context: v2, matches: a(n2.initial) }, transition: function(e2, o3) { - var s3, l3, v3 = "string" == typeof e2 ? { value: e2, context: n2.context } : e2, p = v3.value, g = v3.context, d = u(o3), x = n2.states[p]; - if (x.on) { - var m = r(x.on[d.type]); + var s3, l3, v3 = "string" == typeof e2 ? { value: e2, context: n2.context } : e2, p = v3.value, g = v3.context, d = u(o3), x2 = n2.states[p]; + if (x2.on) { + var m = r(x2.on[d.type]); try { for (var h = function(t2) { var n3 = "function" == typeof Symbol && Symbol.iterator, e3 = n3 && t2[n3], r2 = 0; @@ -8380,7 +15319,7 @@ function s(n2, o2) { if ((void 0 === N ? function() { return true; } : N)(g, d)) { - var _ = n2.states[null != j ? j : p], k = t(f((O ? r(R) : [].concat(x.exit, R, _.entry).filter(function(t2) { + var _ = n2.states[null != j ? j : p], k = t(f((O ? r(R) : [].concat(x2.exit, R, _.entry).filter(function(t2) { return t2; })).map(function(t2) { return i(t2, y._options.actions); @@ -8770,10 +15709,10 @@ function deserializeArg(imageMap, ctx, preload) { return blob2; } } else if (Array.isArray(arg)) { - const result = await Promise.all( + const result2 = await Promise.all( arg.map(deserializeArg(imageMap, ctx, preload)) ); - return result; + return result2; } return arg; }; @@ -8800,15 +15739,15 @@ var WebGLVariableConstructorsNames = [ "WebGLUniformLocation", "WebGLVertexArrayObject" ]; -function saveToWebGLVarMap(ctx, result) { - if (!(result == null ? void 0 : result.constructor)) +function saveToWebGLVarMap(ctx, result2) { + if (!(result2 == null ? void 0 : result2.constructor)) return; - const { name } = result.constructor; + const { name } = result2.constructor; if (!WebGLVariableConstructorsNames.includes(name)) return; const variables = variableListFor(ctx, name); - if (!variables.includes(result)) - variables.push(result); + if (!variables.includes(result2)) + variables.push(result2); } async function webglMutation({ mutation, @@ -8829,8 +15768,8 @@ async function webglMutation({ const args = await Promise.all( mutation.args.map(deserializeArg(imageMap, ctx)) ); - const result = original.apply(ctx, args); - saveToWebGLVarMap(ctx, result); + const result2 = original.apply(ctx, args); + saveToWebGLVarMap(ctx, result2); const debugMode = false; if (debugMode) ; @@ -9044,10 +15983,10 @@ var MediaManager = class { ); } } - addMediaElements(node, timeOffset, mirror2) { - if (!["AUDIO", "VIDEO"].includes(node.nodeName)) + addMediaElements(node2, timeOffset, mirror2) { + if (!["AUDIO", "VIDEO"].includes(node2.nodeName)) return; - const target = node; + const target = node2; const serializedNode = mirror2.getMeta(target); if (!serializedNode || !("attributes" in serializedNode)) return; @@ -9111,17 +16050,17 @@ var MediaManager = class { ); this.syncTargetWithState(target); } - isSupportedMediaElement(node) { - return ["AUDIO", "VIDEO"].includes(node.nodeName); + isSupportedMediaElement(node2) { + return ["AUDIO", "VIDEO"].includes(node2.nodeName); } reset() { this.mediaMap.clear(); } }; -function applyDialogToTopLevel(node, attributeMutation) { - if (node.nodeName !== "DIALOG" || node instanceof BaseRRNode) +function applyDialogToTopLevel(node2, attributeMutation) { + if (node2.nodeName !== "DIALOG" || node2 instanceof BaseRRNode) return; - const dialog = node; + const dialog = node2; const oldIsOpen = dialog.open; const oldIsModalState = oldIsOpen && dialog.matches("dialog:modal"); const rrOpenMode = dialog.getAttribute("rr_open_mode"); @@ -9144,10 +16083,10 @@ function applyDialogToTopLevel(node, attributeMutation) { else dialog.show(); } -function removeDialogFromTopLevel(node, attributeMutation) { - if (node.nodeName !== "DIALOG" || node instanceof BaseRRNode) +function removeDialogFromTopLevel(node2, attributeMutation) { + if (node2.nodeName !== "DIALOG" || node2 instanceof BaseRRNode) return; - const dialog = node; + const dialog = node2; if (!dialog.isConnected) { console.warn("dialog is not attached to the dom", dialog); return; @@ -9312,9 +16251,9 @@ var Replayer = class { if (castFn) { castFn(); } - for (const plugin of this.config.plugins || []) { - if (plugin.handler) - plugin.handler(event, isSync, { replayer: this }); + for (const plugin3 of this.config.plugins || []) { + if (plugin3.handler) + plugin3.handler(event, isSync, { replayer: this }); } this.service.send({ type: "CAST_EVENT", payload: { event } }); const last_index = this.service.state.context.events.length - 1; @@ -9368,9 +16307,9 @@ var Replayer = class { this.applyEventsSynchronously = this.applyEventsSynchronously.bind(this); this.emitter.on(ReplayerEvents.Resize, this.handleResize); this.setupDom(); - for (const plugin of this.config.plugins || []) { - if (plugin.getMirror) - plugin.getMirror({ nodeMirror: this.mirror }); + for (const plugin3 of this.config.plugins || []) { + if (plugin3.getMirror) + plugin3.getMirror({ nodeMirror: this.mirror }); } this.emitter.on(ReplayerEvents.Flush, () => { if (this.usingVirtualDom) { @@ -9394,10 +16333,10 @@ var Replayer = class { else if (data.source === IncrementalSource.StyleDeclaration) this.applyStyleDeclaration(data, styleSheet); }, - afterAppend: (node, id) => { - for (const plugin of this.config.plugins || []) { - if (plugin.onBuild) - plugin.onBuild(node, { id, replayer: this }); + afterAppend: (node2, id) => { + for (const plugin3 of this.config.plugins || []) { + if (plugin3.onBuild) + plugin3.onBuild(node2, { id, replayer: this }); } } }; @@ -9868,9 +16807,9 @@ var Replayer = class { this.mirror ); } - for (const plugin of this.config.plugins || []) { - if (plugin.onBuild) - plugin.onBuild(builtNode, { + for (const plugin3 of this.config.plugins || []) { + if (plugin3.onBuild) + plugin3.onBuild(builtNode, { id, replayer: this }); @@ -9964,9 +16903,9 @@ var Replayer = class { } if (this.usingVirtualDom) return; - for (const plugin of this.config.plugins || []) { - if (plugin.onBuild) - plugin.onBuild(builtNode, { + for (const plugin3 of this.config.plugins || []) { + if (plugin3.onBuild) + plugin3.onBuild(builtNode, { id, replayer: this }); @@ -10471,13 +17410,13 @@ var Replayer = class { ); return; } - const afterAppend = (node, id) => { + const afterAppend = (node2, id) => { if (this.usingVirtualDom) return; - applyDialogToTopLevel(node); - for (const plugin of this.config.plugins || []) { - if (plugin.onBuild) - plugin.onBuild(node, { id, replayer: this }); + applyDialogToTopLevel(node2); + for (const plugin3 of this.config.plugins || []) { + if (plugin3.onBuild) + plugin3.onBuild(node2, { id, replayer: this }); } }; const target = buildNodeWithSN(mutation.node, { @@ -10763,14 +17702,14 @@ var Replayer = class { const endContainer = this.mirror.getNode(end); if (!startContainer || !endContainer) return; - const result = new Range(); - result.setStart(startContainer, startOffset); - result.setEnd(endContainer, endOffset); + const result2 = new Range(); + result2.setStart(startContainer, startOffset); + result2.setEnd(endContainer, endOffset); const doc = startContainer.ownerDocument; const selection = doc == null ? void 0 : doc.getSelection(); selection && selectionSet.add(selection); return { - range: result, + range: result2, selection }; }); @@ -10798,15 +17737,15 @@ var Replayer = class { } applyStyleSheetRule(data, styleSheet) { var _a2, _b, _c, _d; - (_a2 = data.adds) == null ? void 0 : _a2.forEach(({ rule, index: nestedIndex }) => { + (_a2 = data.adds) == null ? void 0 : _a2.forEach(({ rule: rule2, index: nestedIndex }) => { try { if (Array.isArray(nestedIndex)) { const { positions, index: index2 } = getPositionsAndIndex(nestedIndex); const nestedRule = getNestedRule(styleSheet.cssRules, positions); - nestedRule.insertRule(rule, index2); + nestedRule.insertRule(rule2, index2); } else { const index2 = nestedIndex === void 0 ? void 0 : Math.min(nestedIndex, styleSheet.cssRules.length); - styleSheet == null ? void 0 : styleSheet.insertRule(rule, index2); + styleSheet == null ? void 0 : styleSheet.insertRule(rule2, index2); } } catch (e2) { } @@ -10836,22 +17775,22 @@ var Replayer = class { } applyStyleDeclaration(data, styleSheet) { if (data.set) { - const rule = getNestedRule( + const rule2 = getNestedRule( styleSheet.rules, data.index ); - rule.style.setProperty( + rule2.style.setProperty( data.set.property, data.set.value, data.set.priority ); } if (data.remove) { - const rule = getNestedRule( + const rule2 = getNestedRule( styleSheet.rules, data.index ); - rule.style.removeProperty(data.remove.property); + rule2.style.removeProperty(data.remove.property); } } applyAdoptedStyleSheet(data) { @@ -10905,34 +17844,34 @@ var Replayer = class { const previousInMap = previousId && map[previousId]; const nextInMap = nextId && map[nextId]; if (previousInMap) { - const { node, mutation } = previousInMap; - parent.insertBefore(node, target); + const { node: node2, mutation } = previousInMap; + parent.insertBefore(node2, target); delete map[mutation.node.id]; delete this.legacy_missingNodeRetryMap[mutation.node.id]; if (mutation.previousId || mutation.nextId) { - this.legacy_resolveMissingNode(map, parent, node, mutation); + this.legacy_resolveMissingNode(map, parent, node2, mutation); } } if (nextInMap) { - const { node, mutation } = nextInMap; + const { node: node2, mutation } = nextInMap; parent.insertBefore( - node, + node2, target.nextSibling ); delete map[mutation.node.id]; delete this.legacy_missingNodeRetryMap[mutation.node.id]; if (mutation.previousId || mutation.nextId) { - this.legacy_resolveMissingNode(map, parent, node, mutation); + this.legacy_resolveMissingNode(map, parent, node2, mutation); } } } - moveAndHover(x, y, id, isSync, debugData) { + moveAndHover(x2, y, id, isSync, debugData) { const target = this.mirror.getNode(id); if (!target) { return this.debugNodeNotFound(debugData, id); } const base = getBaseDimension(target, this.iframe); - const _x = x * base.absoluteScale + base.x; + const _x = x2 * base.absoluteScale + base.x; const _y = y * base.absoluteScale + base.y; this.mouse.style.left = `${_x}px`; this.mouse.style.top = `${_y}px`; diff --git a/frontend/src/hooks/useFeatureFlag/useFeatureFlag.ts b/frontend/src/hooks/useFeatureFlag/useFeatureFlag.ts index 8b992473d03..19d30c30f99 100644 --- a/frontend/src/hooks/useFeatureFlag/useFeatureFlag.ts +++ b/frontend/src/hooks/useFeatureFlag/useFeatureFlag.ts @@ -15,6 +15,7 @@ interface Config { export enum Feature { EventSearch, + PlayerNoChunkRemoval, } // configures the criteria and percentage of population for which the feature is active. @@ -23,12 +24,12 @@ export const FeatureConfig: { [key: number]: Config } = { [Feature.EventSearch]: { workspace: true, percent: 0, - workspaceOverride: new Set([ - // Highlight - '1', - '15127', - '32550', - ]), + workspaceOverride: new Set(['1', '15127', '32550']), + }, + [Feature.PlayerNoChunkRemoval]: { + workspace: true, + percent: 0, + workspaceOverride: new Set(['13623', '95052']), }, } as const @@ -73,6 +74,14 @@ export const isFeatureOn = async function ( if (config.percent >= 100) { return true } + const overrideKey = `highlight-feature-flag-override-${feature}` + const override = window.localStorage.getItem(overrideKey) + if (override === 'true') { + return true + } else if (override === 'false') { + return true + } + return isActive( feature, (config.project diff --git a/frontend/src/pages/Player/PlayerHook/PlayerHook.tsx b/frontend/src/pages/Player/PlayerHook/PlayerHook.tsx index 808e0c07525..a927a14413d 100644 --- a/frontend/src/pages/Player/PlayerHook/PlayerHook.tsx +++ b/frontend/src/pages/Player/PlayerHook/PlayerHook.tsx @@ -53,11 +53,13 @@ import { useSetPlayerTimestampFromSearchParam, } from './utils' import usePlayerConfiguration from './utils/usePlayerConfiguration' +import useFeatureFlag, { Feature } from '@hooks/useFeatureFlag/useFeatureFlag' export const usePlayer = ( playerRef: RefObject, autoPlay = false, ): ReplayerContextInterface => { + const noChunkRemoval = useFeatureFlag(Feature.PlayerNoChunkRemoval) const { isLoggedIn, isHighlightAdmin } = useAuthContext() const { sessionSecureId, projectId } = useSessionParams() const navigate = useNavigate() @@ -257,6 +259,16 @@ export const usePlayer = ( startIdx: number, ): Set => { const toRemove = new Set() + + if (noChunkRemoval) { + log( + 'PlayerHook.tsx:ensureChunksLoaded', + 'getChunksToRemove', + 'chunk removal disabled', + ) + return toRemove + } + const chunksIndexesWithData = Array.from(chunkEvents.entries()) .filter(([, v]) => !!v.length) .map(([k]) => k) @@ -280,7 +292,7 @@ export const usePlayer = ( } return toRemove }, - [getChunkTs], + [getChunkTs, noChunkRemoval], ) const getLastLoadedEventTimestamp = useCallback(() => { diff --git a/frontend/src/pages/Player/PlayerHook/PlayerState.ts b/frontend/src/pages/Player/PlayerHook/PlayerState.ts index 20282925374..d7354953ac6 100644 --- a/frontend/src/pages/Player/PlayerHook/PlayerState.ts +++ b/frontend/src/pages/Player/PlayerHook/PlayerState.ts @@ -60,7 +60,7 @@ const EMPTY_SESSION_METADATA = { endTime: 0, totalTime: 0, } -const PROJECTS_WITH_CSS_ANIMATIONS: string[] = ['1', '1020', '1021'] +const PROJECTS_WITH_CSS_ANIMATIONS: string[] = ['1', '1020', '1021', '102751'] // assuming 120 fps export const FRAME_MS = 1000 / 120 diff --git a/rrweb b/rrweb index 35e3b963fa3..cb01260d6e0 160000 --- a/rrweb +++ b/rrweb @@ -1 +1 @@ -Subproject commit 35e3b963fa37c866ef303831081df0cee5e4162b +Subproject commit cb01260d6e05a1107dbb8c7613e7462d0d1b041f diff --git a/yarn.lock b/yarn.lock index f372a909d69..537af98b25a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -51118,6 +51118,7 @@ __metadata: "@types/jsdom": "npm:^20.0.0" "@types/node": "npm:^18.15.11" "@types/puppeteer": "npm:^5.4.4" + postcss: "npm:^8.4.38" puppeteer: "npm:^17.1.3" ts-node: "npm:^7.0.1" tslib: "npm:^1.9.3"