@vitest/browser 5.0.0-beta.5 → 5.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4665 @@
1
+ //#region ../../node_modules/.pnpm/rrweb-snapshot@2.0.1_patch_hash=9e976b2c55a5c2ed589c41b8f46cc44b6fe6f528ebb4d3780a44b1ca8cbb17a4/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
4
+ enumerable: true,
5
+ configurable: true,
6
+ writable: true,
7
+ value
8
+ }) : obj[key] = value;
9
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
10
+ var NodeType = /* @__PURE__ */ ((NodeType2) => {
11
+ NodeType2[NodeType2["Document"] = 0] = "Document";
12
+ NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
13
+ NodeType2[NodeType2["Element"] = 2] = "Element";
14
+ NodeType2[NodeType2["Text"] = 3] = "Text";
15
+ NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
16
+ NodeType2[NodeType2["Comment"] = 5] = "Comment";
17
+ return NodeType2;
18
+ })(NodeType || {});
19
+ var testableAccessors = {
20
+ Node: [
21
+ "childNodes",
22
+ "parentNode",
23
+ "parentElement",
24
+ "textContent",
25
+ "ownerDocument"
26
+ ],
27
+ ShadowRoot: ["host", "styleSheets"],
28
+ Element: [
29
+ "shadowRoot",
30
+ "querySelector",
31
+ "querySelectorAll"
32
+ ],
33
+ MutationObserver: []
34
+ };
35
+ var testableMethods = {
36
+ Node: ["contains", "getRootNode"],
37
+ ShadowRoot: ["getSelection"],
38
+ Element: [],
39
+ MutationObserver: ["constructor"]
40
+ };
41
+ var untaintedBasePrototype = {};
42
+ var untaintedBaseIframeCleanup = {};
43
+ var isAngularZonePresent = () => {
44
+ return !!globalThis.Zone;
45
+ };
46
+ function getUntaintedPrototype(key) {
47
+ if (untaintedBasePrototype[key]) return untaintedBasePrototype[key];
48
+ const defaultObj = globalThis[key];
49
+ const defaultPrototype = defaultObj.prototype;
50
+ const accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
51
+ const isUntaintedAccessors = Boolean(accessorNames && accessorNames.every((accessor) => {
52
+ var _a, _b;
53
+ return Boolean((_b = (_a = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a.get) == null ? void 0 : _b.toString().includes("[native code]"));
54
+ }));
55
+ const methodNames = key in testableMethods ? testableMethods[key] : void 0;
56
+ const isUntaintedMethods = Boolean(methodNames && methodNames.every((method) => {
57
+ var _a;
58
+ return typeof defaultPrototype[method] === "function" && ((_a = defaultPrototype[method]) == null ? void 0 : _a.toString().includes("[native code]"));
59
+ }));
60
+ if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
61
+ untaintedBasePrototype[key] = defaultObj.prototype;
62
+ return defaultObj.prototype;
63
+ }
64
+ try {
65
+ const iframeEl = document.createElement("iframe");
66
+ iframeEl.style.display = "none";
67
+ document.body.appendChild(iframeEl);
68
+ const win = iframeEl.contentWindow;
69
+ if (!win) return defaultObj.prototype;
70
+ const untaintedObject = win[key].prototype;
71
+ if (!untaintedObject) {
72
+ iframeEl.remove();
73
+ return defaultPrototype;
74
+ }
75
+ const ua = navigator.userAgent;
76
+ if (ua.includes("Safari") && !ua.includes("Chrome")) {
77
+ iframeEl.classList.add("rr-block");
78
+ iframeEl.setAttribute("__rrwebUntaintedMutationObserver", "");
79
+ untaintedBaseIframeCleanup[key] = () => iframeEl.remove();
80
+ } else iframeEl.remove();
81
+ return untaintedBasePrototype[key] = untaintedObject;
82
+ } catch {
83
+ return defaultPrototype;
84
+ }
85
+ }
86
+ var untaintedAccessorCache = {};
87
+ function getUntaintedAccessor(key, instance, accessor) {
88
+ var _a;
89
+ const cacheKey = `${key}.${String(accessor)}`;
90
+ if (untaintedAccessorCache[cacheKey]) return untaintedAccessorCache[cacheKey].call(instance);
91
+ const untaintedPrototype = getUntaintedPrototype(key);
92
+ const untaintedAccessor = (_a = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a.get;
93
+ if (!untaintedAccessor) return instance[accessor];
94
+ untaintedAccessorCache[cacheKey] = untaintedAccessor;
95
+ return untaintedAccessor.call(instance);
96
+ }
97
+ var untaintedMethodCache = {};
98
+ function getUntaintedMethod(key, instance, method) {
99
+ const cacheKey = `${key}.${String(method)}`;
100
+ if (untaintedMethodCache[cacheKey]) return untaintedMethodCache[cacheKey].bind(instance);
101
+ const untaintedMethod = getUntaintedPrototype(key)[method];
102
+ if (typeof untaintedMethod !== "function") return instance[method];
103
+ untaintedMethodCache[cacheKey] = untaintedMethod;
104
+ return untaintedMethod.bind(instance);
105
+ }
106
+ function ownerDocument(n) {
107
+ return getUntaintedAccessor("Node", n, "ownerDocument");
108
+ }
109
+ function childNodes(n) {
110
+ return getUntaintedAccessor("Node", n, "childNodes");
111
+ }
112
+ function parentNode(n) {
113
+ return getUntaintedAccessor("Node", n, "parentNode");
114
+ }
115
+ function parentElement(n) {
116
+ return getUntaintedAccessor("Node", n, "parentElement");
117
+ }
118
+ function textContent(n) {
119
+ return getUntaintedAccessor("Node", n, "textContent");
120
+ }
121
+ function contains(n, other) {
122
+ return getUntaintedMethod("Node", n, "contains")(other);
123
+ }
124
+ function getRootNode(n) {
125
+ return getUntaintedMethod("Node", n, "getRootNode")();
126
+ }
127
+ function host(n) {
128
+ if (!n || !("host" in n)) return null;
129
+ return getUntaintedAccessor("ShadowRoot", n, "host");
130
+ }
131
+ function styleSheets(n) {
132
+ return n.styleSheets;
133
+ }
134
+ function shadowRoot(n) {
135
+ if (!n || !("shadowRoot" in n)) return null;
136
+ return getUntaintedAccessor("Element", n, "shadowRoot");
137
+ }
138
+ function querySelector(n, selectors) {
139
+ return getUntaintedAccessor("Element", n, "querySelector")(selectors);
140
+ }
141
+ function querySelectorAll(n, selectors) {
142
+ return getUntaintedAccessor("Element", n, "querySelectorAll")(selectors);
143
+ }
144
+ function mutationObserverCtor() {
145
+ return [getUntaintedPrototype("MutationObserver").constructor, untaintedBaseIframeCleanup["MutationObserver"] ?? (() => {})];
146
+ }
147
+ var nowTimestamp = Date.now;
148
+ if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
149
+ function patch(source, name, replacement) {
150
+ try {
151
+ if (!(name in source)) return () => {};
152
+ const original = source[name];
153
+ const wrapped = replacement(original);
154
+ if (typeof wrapped === "function") {
155
+ wrapped.prototype = wrapped.prototype || {};
156
+ Object.defineProperties(wrapped, { __rrweb_original__: {
157
+ enumerable: false,
158
+ value: original
159
+ } });
160
+ }
161
+ source[name] = wrapped;
162
+ return () => {
163
+ source[name] = original;
164
+ };
165
+ } catch {
166
+ return () => {};
167
+ }
168
+ }
169
+ var index = {
170
+ ownerDocument,
171
+ childNodes,
172
+ parentNode,
173
+ parentElement,
174
+ textContent,
175
+ contains,
176
+ getRootNode,
177
+ host,
178
+ styleSheets,
179
+ shadowRoot,
180
+ querySelector,
181
+ querySelectorAll,
182
+ nowTimestamp,
183
+ mutationObserverCtor,
184
+ patch
185
+ };
186
+ function isElement(n) {
187
+ return n.nodeType === n.ELEMENT_NODE;
188
+ }
189
+ function isShadowRoot(n) {
190
+ const hostEl = n && "host" in n && "mode" in n && index.host(n) || null;
191
+ return Boolean(hostEl && "shadowRoot" in hostEl && index.shadowRoot(hostEl) === n);
192
+ }
193
+ function isNativeShadowDom(shadowRoot2) {
194
+ return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
195
+ }
196
+ function fixBrowserCompatibilityIssuesInCSS(cssText) {
197
+ if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) cssText = cssText.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;");
198
+ return cssText;
199
+ }
200
+ function escapeImportStatement(rule2) {
201
+ const { cssText } = rule2;
202
+ if (cssText.split("\"").length < 3) return cssText;
203
+ const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
204
+ if (rule2.layerName === "") statement.push(`layer`);
205
+ else if (rule2.layerName) statement.push(`layer(${rule2.layerName})`);
206
+ if (rule2.supportsText) statement.push(`supports(${rule2.supportsText})`);
207
+ if (rule2.media.length) statement.push(rule2.media.mediaText);
208
+ return statement.join(" ") + ";";
209
+ }
210
+ function stringifyStylesheet(s) {
211
+ try {
212
+ const rules = s.rules || s.cssRules;
213
+ if (!rules) return null;
214
+ let sheetHref = s.href;
215
+ if (!sheetHref && s.ownerNode) sheetHref = s.ownerNode.baseURI;
216
+ return fixBrowserCompatibilityIssuesInCSS(Array.from(rules, (rule2) => stringifyRule(rule2, sheetHref)).join(""));
217
+ } catch (error) {
218
+ return null;
219
+ }
220
+ }
221
+ function stringifyRule(rule2, sheetHref) {
222
+ if (isCSSImportRule(rule2)) {
223
+ let importStringified;
224
+ try {
225
+ importStringified = stringifyStylesheet(rule2.styleSheet) || escapeImportStatement(rule2);
226
+ } catch (error) {
227
+ importStringified = rule2.cssText;
228
+ }
229
+ if (rule2.styleSheet.href) return absolutifyURLs(importStringified, rule2.styleSheet.href);
230
+ return importStringified;
231
+ } else {
232
+ let ruleStringified = rule2.cssText;
233
+ if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) ruleStringified = fixSafariColons(ruleStringified);
234
+ if (sheetHref) return absolutifyURLs(ruleStringified, sheetHref);
235
+ return ruleStringified;
236
+ }
237
+ }
238
+ function fixSafariColons(cssStringified) {
239
+ return cssStringified.replace(/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm, "$1\\$2");
240
+ }
241
+ function isCSSImportRule(rule2) {
242
+ return "styleSheet" in rule2;
243
+ }
244
+ function isCSSStyleRule(rule2) {
245
+ return "selectorText" in rule2;
246
+ }
247
+ var Mirror = class {
248
+ constructor() {
249
+ __publicField(this, "idNodeMap", /* @__PURE__ */ new Map());
250
+ __publicField(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
251
+ }
252
+ getId(n) {
253
+ var _a;
254
+ if (!n) return -1;
255
+ return ((_a = this.getMeta(n)) == null ? void 0 : _a.id) ?? -1;
256
+ }
257
+ getNode(id) {
258
+ return this.idNodeMap.get(id) || null;
259
+ }
260
+ getIds() {
261
+ return Array.from(this.idNodeMap.keys());
262
+ }
263
+ getMeta(n) {
264
+ return this.nodeMetaMap.get(n) || null;
265
+ }
266
+ removeNodeFromMap(n) {
267
+ const id = this.getId(n);
268
+ this.idNodeMap.delete(id);
269
+ if (n.childNodes) n.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode));
270
+ }
271
+ has(id) {
272
+ return this.idNodeMap.has(id);
273
+ }
274
+ hasNode(node2) {
275
+ return this.nodeMetaMap.has(node2);
276
+ }
277
+ add(n, meta) {
278
+ const id = meta.id;
279
+ this.idNodeMap.set(id, n);
280
+ this.nodeMetaMap.set(n, meta);
281
+ }
282
+ replace(id, n) {
283
+ const oldNode = this.getNode(id);
284
+ if (oldNode) {
285
+ const meta = this.nodeMetaMap.get(oldNode);
286
+ if (meta) this.nodeMetaMap.set(n, meta);
287
+ }
288
+ this.idNodeMap.set(id, n);
289
+ }
290
+ reset() {
291
+ this.idNodeMap = /* @__PURE__ */ new Map();
292
+ this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
293
+ }
294
+ };
295
+ function createMirror() {
296
+ return new Mirror();
297
+ }
298
+ function maskInputValue({ element, maskInputOptions, tagName, type, value, maskInputFn }) {
299
+ let text = value || "";
300
+ const actualType = type && toLowerCase(type);
301
+ if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) if (maskInputFn) text = maskInputFn(text, element);
302
+ else text = "*".repeat(text.length);
303
+ return text;
304
+ }
305
+ function toLowerCase(str) {
306
+ return str.toLowerCase();
307
+ }
308
+ var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
309
+ function is2DCanvasBlank(canvas) {
310
+ const ctx = canvas.getContext("2d");
311
+ if (!ctx) return true;
312
+ const chunkSize = 50;
313
+ for (let x = 0; x < canvas.width; x += chunkSize) for (let y = 0; y < canvas.height; y += chunkSize) {
314
+ const getImageData = ctx.getImageData;
315
+ const originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
316
+ if (new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer).some((pixel) => pixel !== 0)) return false;
317
+ }
318
+ return true;
319
+ }
320
+ function isNodeMetaEqual(a, b) {
321
+ if (!a || !b || a.type !== b.type) return false;
322
+ if (a.type === NodeType.Document) return a.compatMode === b.compatMode;
323
+ else if (a.type === NodeType.DocumentType) return a.name === b.name && a.publicId === b.publicId && a.systemId === b.systemId;
324
+ else if (a.type === NodeType.Comment || a.type === NodeType.Text || a.type === NodeType.CDATA) return a.textContent === b.textContent;
325
+ else if (a.type === NodeType.Element) return a.tagName === b.tagName && JSON.stringify(a.attributes) === JSON.stringify(b.attributes) && a.isSVG === b.isSVG && a.needBlock === b.needBlock;
326
+ return false;
327
+ }
328
+ function getInputType(element) {
329
+ const type = element.type;
330
+ return element.hasAttribute("data-rr-is-password") ? "password" : type ? toLowerCase(type) : null;
331
+ }
332
+ function extractFileExtension(path, baseURL) {
333
+ let url;
334
+ try {
335
+ url = new URL(path, baseURL ?? window.location.href);
336
+ } catch (err) {
337
+ return null;
338
+ }
339
+ const match = url.pathname.match(/\.([0-9a-z]+)(?:$)/i);
340
+ return (match == null ? void 0 : match[1]) ?? null;
341
+ }
342
+ function extractOrigin(url) {
343
+ let origin = "";
344
+ if (url.indexOf("//") > -1) origin = url.split("/").slice(0, 3).join("/");
345
+ else origin = url.split("/")[0];
346
+ origin = origin.split("?")[0];
347
+ return origin;
348
+ }
349
+ var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
350
+ var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
351
+ var URL_WWW_MATCH = /^www\..*/i;
352
+ var DATA_URI = /^(data:)([^,]*),(.*)/i;
353
+ function absolutifyURLs(cssText, href) {
354
+ return (cssText || "").replace(URL_IN_CSS_REF, (origin, quote1, path1, quote2, path2, path3) => {
355
+ const filePath = path1 || path2 || path3;
356
+ const maybeQuote = quote1 || quote2 || "";
357
+ if (!filePath) return origin;
358
+ if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) return `url(${maybeQuote}${filePath}${maybeQuote})`;
359
+ if (DATA_URI.test(filePath)) return `url(${maybeQuote}${filePath}${maybeQuote})`;
360
+ if (filePath[0] === "/") return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
361
+ const stack = href.split("/");
362
+ const parts = filePath.split("/");
363
+ stack.pop();
364
+ for (const part of parts) if (part === ".") continue;
365
+ else if (part === "..") stack.pop();
366
+ else stack.push(part);
367
+ return `url(${maybeQuote}${stack.join("/")}${maybeQuote})`;
368
+ });
369
+ }
370
+ function normalizeCssString(cssText, _testNoPxNorm = false) {
371
+ if (_testNoPxNorm) return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
372
+ else return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
373
+ }
374
+ function splitCssText(cssText, style, _testNoPxNorm = false) {
375
+ const childNodes2 = Array.from(style.childNodes);
376
+ const splits = [];
377
+ let iterCount = 0;
378
+ if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
379
+ let cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
380
+ const normFactor = cssTextNorm.length / cssText.length;
381
+ for (let i = 1; i < childNodes2.length; i++) if (childNodes2[i].textContent && typeof childNodes2[i].textContent === "string") {
382
+ const textContentNorm = normalizeCssString(childNodes2[i].textContent, _testNoPxNorm);
383
+ const jLimit = 100;
384
+ let j = 3;
385
+ for (; j < textContentNorm.length; j++) {
386
+ if (textContentNorm[j].match(/[a-zA-Z0-9]/) || textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1) continue;
387
+ break;
388
+ }
389
+ for (; j < textContentNorm.length; j++) {
390
+ let startSubstring = textContentNorm.substring(0, j);
391
+ let cssNormSplits = cssTextNorm.split(startSubstring);
392
+ let splitNorm = -1;
393
+ if (cssNormSplits.length === 2) splitNorm = cssNormSplits[0].length;
394
+ else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i - 1].textContent !== "") splitNorm = cssTextNorm.indexOf(startSubstring, 1);
395
+ else if (cssNormSplits.length === 1) {
396
+ startSubstring = startSubstring.substring(0, startSubstring.length - 1);
397
+ cssNormSplits = cssTextNorm.split(startSubstring);
398
+ if (cssNormSplits.length <= 1) {
399
+ splits.push(cssText);
400
+ return splits;
401
+ }
402
+ j = jLimit + 1;
403
+ } else if (j === textContentNorm.length - 1) splitNorm = cssTextNorm.indexOf(startSubstring);
404
+ if (cssNormSplits.length >= 2 && j > jLimit) {
405
+ const prevTextContent = childNodes2[i - 1].textContent;
406
+ if (prevTextContent && typeof prevTextContent === "string") {
407
+ const prevMinLength = normalizeCssString(prevTextContent).length;
408
+ splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
409
+ }
410
+ if (splitNorm === -1) splitNorm = cssNormSplits[0].length;
411
+ }
412
+ if (splitNorm !== -1) {
413
+ let k = Math.floor(splitNorm / normFactor);
414
+ for (; k > 0 && k < cssText.length;) {
415
+ iterCount += 1;
416
+ if (iterCount > 50 * childNodes2.length) {
417
+ splits.push(cssText);
418
+ return splits;
419
+ }
420
+ const normPart = normalizeCssString(cssText.substring(0, k), _testNoPxNorm);
421
+ if (normPart.length === splitNorm) {
422
+ splits.push(cssText.substring(0, k));
423
+ cssText = cssText.substring(k);
424
+ cssTextNorm = cssTextNorm.substring(splitNorm);
425
+ break;
426
+ } else if (normPart.length < splitNorm) k += Math.max(1, Math.floor((splitNorm - normPart.length) / normFactor));
427
+ else k -= Math.max(1, Math.floor((normPart.length - splitNorm) * normFactor));
428
+ }
429
+ break;
430
+ }
431
+ }
432
+ }
433
+ }
434
+ splits.push(cssText);
435
+ return splits;
436
+ }
437
+ function markCssSplits(cssText, style) {
438
+ return splitCssText(cssText, style).join("/* rr_split */");
439
+ }
440
+ var _id = 1;
441
+ var tagNameRegex = /* @__PURE__ */ new RegExp("[^a-z0-9-_:]");
442
+ var IGNORED_NODE = -2;
443
+ function genId() {
444
+ return _id++;
445
+ }
446
+ function getValidTagName(element) {
447
+ if (element instanceof HTMLFormElement) return "form";
448
+ const processedTagName = toLowerCase(element.tagName);
449
+ if (tagNameRegex.test(processedTagName)) return "div";
450
+ return processedTagName;
451
+ }
452
+ var canvasService;
453
+ var canvasCtx;
454
+ var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
455
+ var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
456
+ function getAbsoluteSrcsetString(doc, attributeValue) {
457
+ if (attributeValue.trim() === "") return attributeValue;
458
+ let pos = 0;
459
+ function collectCharacters(regEx) {
460
+ let chars;
461
+ const match = regEx.exec(attributeValue.substring(pos));
462
+ if (match) {
463
+ chars = match[0];
464
+ pos += chars.length;
465
+ return chars;
466
+ }
467
+ return "";
468
+ }
469
+ const output = [];
470
+ while (true) {
471
+ collectCharacters(SRCSET_COMMAS_OR_SPACES);
472
+ if (pos >= attributeValue.length) break;
473
+ let url = collectCharacters(SRCSET_NOT_SPACES);
474
+ if (url.slice(-1) === ",") {
475
+ url = absoluteToDoc(doc, url.substring(0, url.length - 1));
476
+ output.push(url);
477
+ } else {
478
+ let descriptorsStr = "";
479
+ url = absoluteToDoc(doc, url);
480
+ let inParens = false;
481
+ while (true) {
482
+ const c = attributeValue.charAt(pos);
483
+ if (c === "") {
484
+ output.push((url + descriptorsStr).trim());
485
+ break;
486
+ } else if (!inParens) {
487
+ if (c === ",") {
488
+ pos += 1;
489
+ output.push((url + descriptorsStr).trim());
490
+ break;
491
+ } else if (c === "(") inParens = true;
492
+ } else if (c === ")") inParens = false;
493
+ descriptorsStr += c;
494
+ pos += 1;
495
+ }
496
+ }
497
+ }
498
+ return output.join(", ");
499
+ }
500
+ var cachedDocument = /* @__PURE__ */ new WeakMap();
501
+ function absoluteToDoc(doc, attributeValue) {
502
+ if (!attributeValue || attributeValue.trim() === "") return attributeValue;
503
+ return getHref(doc, attributeValue);
504
+ }
505
+ function isSVGElement(el) {
506
+ return Boolean(el.tagName === "svg" || el.ownerSVGElement);
507
+ }
508
+ function getHref(doc, customHref) {
509
+ let a = cachedDocument.get(doc);
510
+ if (!a) {
511
+ a = doc.createElement("a");
512
+ cachedDocument.set(doc, a);
513
+ }
514
+ if (!customHref) customHref = "";
515
+ else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) return customHref;
516
+ a.setAttribute("href", customHref);
517
+ return a.href;
518
+ }
519
+ function transformAttribute(doc, tagName, name, value) {
520
+ if (!value) return value;
521
+ if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) return absoluteToDoc(doc, value);
522
+ else if (name === "xlink:href" && value[0] !== "#") return absoluteToDoc(doc, value);
523
+ else if (name === "background" && [
524
+ "table",
525
+ "td",
526
+ "th"
527
+ ].includes(tagName)) return absoluteToDoc(doc, value);
528
+ else if (name === "srcset") return getAbsoluteSrcsetString(doc, value);
529
+ else if (name === "style") return absolutifyURLs(value, getHref(doc));
530
+ else if (tagName === "object" && name === "data") return absoluteToDoc(doc, value);
531
+ return value;
532
+ }
533
+ function ignoreAttribute(tagName, name, _value) {
534
+ return ["video", "audio"].includes(tagName) && name === "autoplay";
535
+ }
536
+ function _isBlockedElement(element, blockClass, blockSelector) {
537
+ try {
538
+ if (typeof blockClass === "string") {
539
+ if (element.classList.contains(blockClass)) return true;
540
+ } else for (let eIndex = element.classList.length; eIndex--;) {
541
+ const className = element.classList[eIndex];
542
+ if (blockClass.test(className)) return true;
543
+ }
544
+ if (blockSelector) return element.matches(blockSelector);
545
+ } catch (e) {}
546
+ return false;
547
+ }
548
+ function classMatchesRegex(node2, regex, checkAncestors) {
549
+ if (!node2) return false;
550
+ if (node2.nodeType !== node2.ELEMENT_NODE) {
551
+ if (!checkAncestors) return false;
552
+ return classMatchesRegex(index.parentNode(node2), regex, checkAncestors);
553
+ }
554
+ for (let eIndex = node2.classList.length; eIndex--;) {
555
+ const className = node2.classList[eIndex];
556
+ if (regex.test(className)) return true;
557
+ }
558
+ if (!checkAncestors) return false;
559
+ return classMatchesRegex(index.parentNode(node2), regex, checkAncestors);
560
+ }
561
+ function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
562
+ let el;
563
+ if (isElement(node2)) {
564
+ el = node2;
565
+ if (!index.childNodes(el).length) return false;
566
+ } else if (index.parentElement(node2) === null) return false;
567
+ else el = index.parentElement(node2);
568
+ try {
569
+ if (typeof maskTextClass === "string") {
570
+ if (checkAncestors) {
571
+ if (el.closest(`.${maskTextClass}`)) return true;
572
+ } else if (el.classList.contains(maskTextClass)) return true;
573
+ } else if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
574
+ if (maskTextSelector) {
575
+ if (checkAncestors) {
576
+ if (el.closest(maskTextSelector)) return true;
577
+ } else if (el.matches(maskTextSelector)) return true;
578
+ }
579
+ } catch (e) {}
580
+ return false;
581
+ }
582
+ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
583
+ const win = iframeEl.contentWindow;
584
+ if (!win) return;
585
+ let fired = false;
586
+ let readyState;
587
+ try {
588
+ readyState = win.document.readyState;
589
+ } catch (error) {
590
+ return;
591
+ }
592
+ if (readyState !== "complete") {
593
+ const timer = setTimeout(() => {
594
+ if (!fired) {
595
+ listener();
596
+ fired = true;
597
+ }
598
+ }, iframeLoadTimeout);
599
+ iframeEl.addEventListener("load", () => {
600
+ clearTimeout(timer);
601
+ fired = true;
602
+ listener();
603
+ });
604
+ return;
605
+ }
606
+ const blankUrl = "about:blank";
607
+ if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
608
+ setTimeout(listener, 0);
609
+ return iframeEl.addEventListener("load", listener);
610
+ }
611
+ iframeEl.addEventListener("load", listener);
612
+ }
613
+ function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
614
+ let fired = false;
615
+ let styleSheetLoaded;
616
+ try {
617
+ styleSheetLoaded = link.sheet;
618
+ } catch (error) {
619
+ return;
620
+ }
621
+ if (styleSheetLoaded) return;
622
+ const timer = setTimeout(() => {
623
+ if (!fired) {
624
+ listener();
625
+ fired = true;
626
+ }
627
+ }, styleSheetLoadTimeout);
628
+ link.addEventListener("load", () => {
629
+ clearTimeout(timer);
630
+ fired = true;
631
+ listener();
632
+ });
633
+ }
634
+ function serializeNode(n, options) {
635
+ const { doc, mirror, blockClass, blockSelector, needsMask, inlineStylesheet, maskInputOptions = {}, maskTextFn, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, newlyAddedElement = false, cssCaptured = false } = options;
636
+ const rootId = getRootId(doc, mirror);
637
+ switch (n.nodeType) {
638
+ case n.DOCUMENT_NODE: if (n.compatMode !== "CSS1Compat") return {
639
+ type: NodeType.Document,
640
+ childNodes: [],
641
+ compatMode: n.compatMode
642
+ };
643
+ else return {
644
+ type: NodeType.Document,
645
+ childNodes: []
646
+ };
647
+ case n.DOCUMENT_TYPE_NODE: return {
648
+ type: NodeType.DocumentType,
649
+ name: n.name,
650
+ publicId: n.publicId,
651
+ systemId: n.systemId,
652
+ rootId
653
+ };
654
+ case n.ELEMENT_NODE: return serializeElementNode(n, {
655
+ doc,
656
+ blockClass,
657
+ blockSelector,
658
+ inlineStylesheet,
659
+ maskInputOptions,
660
+ maskInputFn,
661
+ dataURLOptions,
662
+ inlineImages,
663
+ recordCanvas,
664
+ keepIframeSrcFn,
665
+ newlyAddedElement,
666
+ rootId
667
+ });
668
+ case n.TEXT_NODE: return serializeTextNode(n, {
669
+ doc,
670
+ needsMask,
671
+ maskTextFn,
672
+ rootId,
673
+ cssCaptured
674
+ });
675
+ case n.CDATA_SECTION_NODE: return {
676
+ type: NodeType.CDATA,
677
+ textContent: "",
678
+ rootId
679
+ };
680
+ case n.COMMENT_NODE: return {
681
+ type: NodeType.Comment,
682
+ textContent: index.textContent(n) || "",
683
+ rootId
684
+ };
685
+ default: return false;
686
+ }
687
+ }
688
+ function getRootId(doc, mirror) {
689
+ if (!mirror.hasNode(doc)) return void 0;
690
+ const docId = mirror.getId(doc);
691
+ return docId === 1 ? void 0 : docId;
692
+ }
693
+ function serializeTextNode(n, options) {
694
+ const { needsMask, maskTextFn, rootId, cssCaptured } = options;
695
+ const parent = index.parentNode(n);
696
+ const parentTagName = parent && parent.tagName;
697
+ let textContent2 = "";
698
+ const isStyle = parentTagName === "STYLE" ? true : void 0;
699
+ const isScript = parentTagName === "SCRIPT" ? true : void 0;
700
+ if (isScript) textContent2 = "SCRIPT_PLACEHOLDER";
701
+ else if (!cssCaptured) {
702
+ textContent2 = index.textContent(n);
703
+ if (isStyle && textContent2) textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
704
+ }
705
+ if (!isStyle && !isScript && textContent2 && needsMask) textContent2 = maskTextFn ? maskTextFn(textContent2, index.parentElement(n)) : textContent2.replace(/[\S]/g, "*");
706
+ return {
707
+ type: NodeType.Text,
708
+ textContent: textContent2 || "",
709
+ rootId
710
+ };
711
+ }
712
+ function serializeElementNode(n, options) {
713
+ const { doc, blockClass, blockSelector, inlineStylesheet, maskInputOptions = {}, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, newlyAddedElement = false, rootId } = options;
714
+ const needBlock = _isBlockedElement(n, blockClass, blockSelector);
715
+ const tagName = getValidTagName(n);
716
+ let attributes = {};
717
+ const len = n.attributes.length;
718
+ for (let i = 0; i < len; i++) {
719
+ const attr = n.attributes[i];
720
+ if (!ignoreAttribute(tagName, attr.name, attr.value)) attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
721
+ }
722
+ if (tagName === "link" && inlineStylesheet) {
723
+ const stylesheet = Array.from(doc.styleSheets).find((s) => {
724
+ return s.href === n.href;
725
+ });
726
+ let cssText = null;
727
+ if (stylesheet) cssText = stringifyStylesheet(stylesheet);
728
+ if (cssText) {
729
+ delete attributes.rel;
730
+ delete attributes.href;
731
+ attributes._cssText = cssText;
732
+ }
733
+ }
734
+ if (tagName === "style" && n.sheet) {
735
+ let cssText = stringifyStylesheet(n.sheet);
736
+ if (cssText) {
737
+ if (n.childNodes.length > 1) cssText = markCssSplits(cssText, n);
738
+ attributes._cssText = cssText;
739
+ }
740
+ }
741
+ if ([
742
+ "input",
743
+ "textarea",
744
+ "select"
745
+ ].includes(tagName)) {
746
+ const value = n.value;
747
+ const checked = n.checked;
748
+ if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) attributes.value = maskInputValue({
749
+ element: n,
750
+ type: getInputType(n),
751
+ tagName,
752
+ value,
753
+ maskInputOptions,
754
+ maskInputFn
755
+ });
756
+ else if (checked) attributes.checked = checked;
757
+ }
758
+ if (tagName === "option") if (n.selected && !maskInputOptions["select"]) attributes.selected = true;
759
+ else delete attributes.selected;
760
+ if (tagName === "dialog" && n.open) attributes.rr_open_mode = n.matches("dialog:modal") ? "modal" : "non-modal";
761
+ if (tagName === "canvas" && recordCanvas) {
762
+ if (n.__context === "2d") {
763
+ if (!is2DCanvasBlank(n)) attributes.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
764
+ } else if (!("__context" in n)) {
765
+ const canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
766
+ const blankCanvas = doc.createElement("canvas");
767
+ blankCanvas.width = n.width;
768
+ blankCanvas.height = n.height;
769
+ if (canvasDataURL !== blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality)) attributes.rr_dataURL = canvasDataURL;
770
+ }
771
+ }
772
+ if (tagName === "img" && inlineImages) {
773
+ if (!canvasService) {
774
+ canvasService = doc.createElement("canvas");
775
+ canvasCtx = canvasService.getContext("2d");
776
+ }
777
+ const image = n;
778
+ const imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
779
+ const priorCrossOrigin = image.crossOrigin;
780
+ const recordInlineImage = () => {
781
+ image.removeEventListener("load", recordInlineImage);
782
+ try {
783
+ canvasService.width = image.naturalWidth;
784
+ canvasService.height = image.naturalHeight;
785
+ canvasCtx.drawImage(image, 0, 0);
786
+ attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
787
+ } catch (err) {
788
+ if (image.crossOrigin !== "anonymous") {
789
+ image.crossOrigin = "anonymous";
790
+ if (image.complete && image.naturalWidth !== 0) recordInlineImage();
791
+ else image.addEventListener("load", recordInlineImage);
792
+ return;
793
+ } else console.warn(`Cannot inline img src=${imageSrc}! Error: ${err}`);
794
+ }
795
+ if (image.crossOrigin === "anonymous") priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
796
+ };
797
+ if (image.complete && image.naturalWidth !== 0) recordInlineImage();
798
+ else image.addEventListener("load", recordInlineImage);
799
+ }
800
+ if (["audio", "video"].includes(tagName)) {
801
+ const mediaAttributes = attributes;
802
+ mediaAttributes.rr_mediaState = n.paused ? "paused" : "played";
803
+ mediaAttributes.rr_mediaCurrentTime = n.currentTime;
804
+ mediaAttributes.rr_mediaPlaybackRate = n.playbackRate;
805
+ mediaAttributes.rr_mediaMuted = n.muted;
806
+ mediaAttributes.rr_mediaLoop = n.loop;
807
+ mediaAttributes.rr_mediaVolume = n.volume;
808
+ }
809
+ if (!newlyAddedElement) {
810
+ if (n.scrollLeft) attributes.rr_scrollLeft = n.scrollLeft;
811
+ if (n.scrollTop) attributes.rr_scrollTop = n.scrollTop;
812
+ }
813
+ if (needBlock) {
814
+ const { width, height } = n.getBoundingClientRect();
815
+ attributes = {
816
+ class: attributes.class,
817
+ rr_width: `${width}px`,
818
+ rr_height: `${height}px`
819
+ };
820
+ }
821
+ if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
822
+ if (!n.contentDocument) attributes.rr_src = attributes.src;
823
+ delete attributes.src;
824
+ }
825
+ let isCustomElement;
826
+ try {
827
+ if (customElements.get(tagName)) isCustomElement = true;
828
+ } catch (e) {}
829
+ return {
830
+ type: NodeType.Element,
831
+ tagName,
832
+ attributes,
833
+ childNodes: [],
834
+ isSVG: isSVGElement(n) || void 0,
835
+ needBlock,
836
+ rootId,
837
+ isCustom: isCustomElement
838
+ };
839
+ }
840
+ function lowerIfExists(maybeAttr) {
841
+ if (maybeAttr === void 0 || maybeAttr === null) return "";
842
+ else return maybeAttr.toLowerCase();
843
+ }
844
+ function slimDOMDefaults(_slimDOMOptions) {
845
+ if (_slimDOMOptions === true || _slimDOMOptions === "all") return {
846
+ script: true,
847
+ comment: true,
848
+ headFavicon: true,
849
+ headWhitespace: true,
850
+ headMetaSocial: true,
851
+ headMetaRobots: true,
852
+ headMetaHttpEquiv: true,
853
+ headMetaVerification: true,
854
+ headMetaAuthorship: _slimDOMOptions === "all",
855
+ headMetaDescKeywords: _slimDOMOptions === "all",
856
+ headTitleMutations: _slimDOMOptions === "all"
857
+ };
858
+ else if (_slimDOMOptions) return _slimDOMOptions;
859
+ return {};
860
+ }
861
+ function slimDOMExcluded(sn, slimDOMOptions) {
862
+ if (slimDOMOptions.comment && sn.type === NodeType.Comment) return true;
863
+ else if (sn.type === NodeType.Element) {
864
+ if (slimDOMOptions.script && (sn.tagName === "script" || sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) return true;
865
+ else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) || lowerIfExists(sn.attributes.name) === "application-name" || lowerIfExists(sn.attributes.rel) === "icon" || lowerIfExists(sn.attributes.rel) === "apple-touch-icon" || lowerIfExists(sn.attributes.rel) === "shortcut icon"))) return true;
866
+ else if (sn.tagName === "meta") {
867
+ if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) return true;
868
+ else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) return true;
869
+ else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) return true;
870
+ else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) return true;
871
+ else if (slimDOMOptions.headMetaAuthorship && (lowerIfExists(sn.attributes.name) === "author" || lowerIfExists(sn.attributes.name) === "generator" || lowerIfExists(sn.attributes.name) === "framework" || lowerIfExists(sn.attributes.name) === "publisher" || lowerIfExists(sn.attributes.name) === "progid" || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) return true;
872
+ else if (slimDOMOptions.headMetaVerification && (lowerIfExists(sn.attributes.name) === "google-site-verification" || lowerIfExists(sn.attributes.name) === "yandex-verification" || lowerIfExists(sn.attributes.name) === "csrf-token" || lowerIfExists(sn.attributes.name) === "p:domain_verify" || lowerIfExists(sn.attributes.name) === "verify-v1" || lowerIfExists(sn.attributes.name) === "verification" || lowerIfExists(sn.attributes.name) === "shopify-checkout-api-token")) return true;
873
+ }
874
+ }
875
+ return false;
876
+ }
877
+ function serializeNodeWithId(n, options) {
878
+ const { doc, mirror, blockClass, blockSelector, maskTextClass, maskTextSelector, skipChild = false, inlineStylesheet = true, maskInputOptions = {}, maskTextFn, maskInputFn, slimDOMOptions, dataURLOptions = {}, inlineImages = false, recordCanvas = false, onSerialize, onIframeLoad, iframeLoadTimeout = 5e3, onStylesheetLoad, stylesheetLoadTimeout = 5e3, keepIframeSrcFn = () => false, newlyAddedElement = false, cssCaptured = false } = options;
879
+ let { needsMask } = options;
880
+ let { preserveWhiteSpace = true } = options;
881
+ if (!needsMask) needsMask = needMaskingText(n, maskTextClass, maskTextSelector, needsMask === void 0);
882
+ const _serializedNode = serializeNode(n, {
883
+ doc,
884
+ mirror,
885
+ blockClass,
886
+ blockSelector,
887
+ needsMask,
888
+ inlineStylesheet,
889
+ maskInputOptions,
890
+ maskTextFn,
891
+ maskInputFn,
892
+ dataURLOptions,
893
+ inlineImages,
894
+ recordCanvas,
895
+ keepIframeSrcFn,
896
+ newlyAddedElement,
897
+ cssCaptured
898
+ });
899
+ if (!_serializedNode) {
900
+ console.warn(n, "not serialized");
901
+ return null;
902
+ }
903
+ let id;
904
+ if (mirror.hasNode(n)) id = mirror.getId(n);
905
+ else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) id = -2;
906
+ else id = genId();
907
+ const serializedNode = Object.assign(_serializedNode, { id });
908
+ mirror.add(n, serializedNode);
909
+ if (id === -2) return null;
910
+ if (onSerialize) onSerialize(n);
911
+ let recordChild = !skipChild;
912
+ if (serializedNode.type === NodeType.Element) {
913
+ recordChild = recordChild && !serializedNode.needBlock;
914
+ delete serializedNode.needBlock;
915
+ const shadowRootEl = index.shadowRoot(n);
916
+ if (shadowRootEl && isNativeShadowDom(shadowRootEl)) serializedNode.isShadowHost = true;
917
+ }
918
+ if ((serializedNode.type === NodeType.Document || serializedNode.type === NodeType.Element) && recordChild) {
919
+ if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType.Element && serializedNode.tagName === "head") preserveWhiteSpace = false;
920
+ const bypassOptions = {
921
+ doc,
922
+ mirror,
923
+ blockClass,
924
+ blockSelector,
925
+ needsMask,
926
+ maskTextClass,
927
+ maskTextSelector,
928
+ skipChild,
929
+ inlineStylesheet,
930
+ maskInputOptions,
931
+ maskTextFn,
932
+ maskInputFn,
933
+ slimDOMOptions,
934
+ dataURLOptions,
935
+ inlineImages,
936
+ recordCanvas,
937
+ preserveWhiteSpace,
938
+ onSerialize,
939
+ onIframeLoad,
940
+ iframeLoadTimeout,
941
+ onStylesheetLoad,
942
+ stylesheetLoadTimeout,
943
+ keepIframeSrcFn,
944
+ cssCaptured: false
945
+ };
946
+ if (serializedNode.type === NodeType.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0);
947
+ else {
948
+ if (serializedNode.type === NodeType.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") bypassOptions.cssCaptured = true;
949
+ for (const childN of Array.from(index.childNodes(n))) {
950
+ const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
951
+ if (serializedChildNode) serializedNode.childNodes.push(serializedChildNode);
952
+ }
953
+ }
954
+ let shadowRootEl = null;
955
+ if (isElement(n) && (shadowRootEl = index.shadowRoot(n))) for (const childN of Array.from(index.childNodes(shadowRootEl))) {
956
+ const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
957
+ if (serializedChildNode) {
958
+ isNativeShadowDom(shadowRootEl) && (serializedChildNode.isShadow = true);
959
+ serializedNode.childNodes.push(serializedChildNode);
960
+ }
961
+ }
962
+ }
963
+ const parent = index.parentNode(n);
964
+ if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) serializedNode.isShadow = true;
965
+ if (serializedNode.type === NodeType.Element && serializedNode.tagName === "iframe") onceIframeLoaded(n, () => {
966
+ const iframeDoc = n.contentDocument;
967
+ if (iframeDoc && onIframeLoad) {
968
+ const serializedIframeNode = serializeNodeWithId(iframeDoc, {
969
+ doc: iframeDoc,
970
+ mirror,
971
+ blockClass,
972
+ blockSelector,
973
+ needsMask,
974
+ maskTextClass,
975
+ maskTextSelector,
976
+ skipChild: false,
977
+ inlineStylesheet,
978
+ maskInputOptions,
979
+ maskTextFn,
980
+ maskInputFn,
981
+ slimDOMOptions,
982
+ dataURLOptions,
983
+ inlineImages,
984
+ recordCanvas,
985
+ preserveWhiteSpace,
986
+ onSerialize,
987
+ onIframeLoad,
988
+ iframeLoadTimeout,
989
+ onStylesheetLoad,
990
+ stylesheetLoadTimeout,
991
+ keepIframeSrcFn
992
+ });
993
+ if (serializedIframeNode) onIframeLoad(n, serializedIframeNode);
994
+ }
995
+ }, iframeLoadTimeout);
996
+ if (serializedNode.type === NodeType.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && extractFileExtension(serializedNode.attributes.href) === "css")) onceStylesheetLoaded(n, () => {
997
+ if (onStylesheetLoad) {
998
+ const serializedLinkNode = serializeNodeWithId(n, {
999
+ doc,
1000
+ mirror,
1001
+ blockClass,
1002
+ blockSelector,
1003
+ needsMask,
1004
+ maskTextClass,
1005
+ maskTextSelector,
1006
+ skipChild: false,
1007
+ inlineStylesheet,
1008
+ maskInputOptions,
1009
+ maskTextFn,
1010
+ maskInputFn,
1011
+ slimDOMOptions,
1012
+ dataURLOptions,
1013
+ inlineImages,
1014
+ recordCanvas,
1015
+ preserveWhiteSpace,
1016
+ onSerialize,
1017
+ onIframeLoad,
1018
+ iframeLoadTimeout,
1019
+ onStylesheetLoad,
1020
+ stylesheetLoadTimeout,
1021
+ keepIframeSrcFn
1022
+ });
1023
+ if (serializedLinkNode) onStylesheetLoad(n, serializedLinkNode);
1024
+ }
1025
+ }, stylesheetLoadTimeout);
1026
+ return serializedNode;
1027
+ }
1028
+ function snapshot(n, options) {
1029
+ const { mirror = new Mirror(), blockClass = "rr-block", blockSelector = null, maskTextClass = "rr-mask", maskTextSelector = null, inlineStylesheet = true, inlineImages = false, recordCanvas = false, maskAllInputs = false, maskTextFn, maskInputFn, slimDOM = false, dataURLOptions, preserveWhiteSpace, onSerialize, onIframeLoad, iframeLoadTimeout, onStylesheetLoad, stylesheetLoadTimeout, keepIframeSrcFn = () => false } = options || {};
1030
+ return serializeNodeWithId(n, {
1031
+ doc: n,
1032
+ mirror,
1033
+ blockClass,
1034
+ blockSelector,
1035
+ maskTextClass,
1036
+ maskTextSelector,
1037
+ skipChild: false,
1038
+ inlineStylesheet,
1039
+ maskInputOptions: maskAllInputs === true ? {
1040
+ color: true,
1041
+ date: true,
1042
+ "datetime-local": true,
1043
+ email: true,
1044
+ month: true,
1045
+ number: true,
1046
+ range: true,
1047
+ search: true,
1048
+ tel: true,
1049
+ text: true,
1050
+ time: true,
1051
+ url: true,
1052
+ week: true,
1053
+ textarea: true,
1054
+ select: true,
1055
+ password: true
1056
+ } : maskAllInputs === false ? { password: true } : maskAllInputs,
1057
+ maskTextFn,
1058
+ maskInputFn,
1059
+ slimDOMOptions: slimDOMDefaults(slimDOM),
1060
+ dataURLOptions,
1061
+ inlineImages,
1062
+ recordCanvas,
1063
+ preserveWhiteSpace,
1064
+ onSerialize,
1065
+ onIframeLoad,
1066
+ iframeLoadTimeout,
1067
+ onStylesheetLoad,
1068
+ stylesheetLoadTimeout,
1069
+ keepIframeSrcFn,
1070
+ newlyAddedElement: false
1071
+ });
1072
+ }
1073
+ function visitSnapshot(node2, onVisit) {
1074
+ function walk(current) {
1075
+ onVisit(current);
1076
+ if (current.type === NodeType.Document || current.type === NodeType.Element) current.childNodes.forEach(walk);
1077
+ }
1078
+ walk(node2);
1079
+ }
1080
+ function cleanupSnapshot() {
1081
+ _id = 1;
1082
+ }
1083
+ var MEDIA_SELECTOR_GLOBAL = new RegExp(/(max|min)-device-(width|height)/.source, "g");
1084
+ var mediaSelectorPlugin = {
1085
+ postcssPlugin: "postcss-custom-selectors",
1086
+ prepare() {
1087
+ return {
1088
+ postcssPlugin: "postcss-custom-selectors",
1089
+ AtRule: function(atrule) {
1090
+ if (atrule.params.match(MEDIA_SELECTOR_GLOBAL)) atrule.params = atrule.params.replace(MEDIA_SELECTOR_GLOBAL, "$1-$2");
1091
+ }
1092
+ };
1093
+ }
1094
+ };
1095
+ var pseudoClassPlugin = {
1096
+ postcssPlugin: "postcss-hover-classes",
1097
+ prepare: function() {
1098
+ const fixed = [];
1099
+ return { Rule: function(rule2) {
1100
+ if (fixed.indexOf(rule2) !== -1) return;
1101
+ fixed.push(rule2);
1102
+ rule2.selectors.forEach(function(selector) {
1103
+ if (selector.includes(":hover")) rule2.selector += ",\n" + selector.replace(/:hover/g, ".\\:hover");
1104
+ if (selector.includes(":active")) rule2.selector += ",\n" + selector.replace(/:active/g, ".\\:active");
1105
+ if (selector.includes(":focus-visible")) rule2.selector += ",\n" + selector.replace(/:focus-visible/g, ".\\:focus-visible");
1106
+ if (selector.includes(":focus-within")) rule2.selector += ",\n" + selector.replace(/:focus-within/g, ".\\:focus-within");
1107
+ if (/:focus(?![-\w])/.test(selector)) rule2.selector += ",\n" + selector.replace(/:focus(?![-\w])/g, ".\\:focus");
1108
+ });
1109
+ } };
1110
+ }
1111
+ };
1112
+ function getDefaultExportFromCjs(x) {
1113
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1114
+ }
1115
+ function getAugmentedNamespace(n) {
1116
+ if (n.__esModule) return n;
1117
+ var f = n.default;
1118
+ if (typeof f == "function") {
1119
+ var a = function a2() {
1120
+ if (this instanceof a2) return Reflect.construct(f, arguments, this.constructor);
1121
+ return f.apply(this, arguments);
1122
+ };
1123
+ a.prototype = f.prototype;
1124
+ } else a = {};
1125
+ Object.defineProperty(a, "__esModule", { value: true });
1126
+ Object.keys(n).forEach(function(k) {
1127
+ var d = Object.getOwnPropertyDescriptor(n, k);
1128
+ Object.defineProperty(a, k, d.get ? d : {
1129
+ enumerable: true,
1130
+ get: function() {
1131
+ return n[k];
1132
+ }
1133
+ });
1134
+ });
1135
+ return a;
1136
+ }
1137
+ var picocolors_browser = { exports: {} };
1138
+ var hasRequiredPicocolors_browser;
1139
+ function requirePicocolors_browser() {
1140
+ if (hasRequiredPicocolors_browser) return picocolors_browser.exports;
1141
+ hasRequiredPicocolors_browser = 1;
1142
+ var x = String;
1143
+ var create = function() {
1144
+ return {
1145
+ isColorSupported: false,
1146
+ reset: x,
1147
+ bold: x,
1148
+ dim: x,
1149
+ italic: x,
1150
+ underline: x,
1151
+ inverse: x,
1152
+ hidden: x,
1153
+ strikethrough: x,
1154
+ black: x,
1155
+ red: x,
1156
+ green: x,
1157
+ yellow: x,
1158
+ blue: x,
1159
+ magenta: x,
1160
+ cyan: x,
1161
+ white: x,
1162
+ gray: x,
1163
+ bgBlack: x,
1164
+ bgRed: x,
1165
+ bgGreen: x,
1166
+ bgYellow: x,
1167
+ bgBlue: x,
1168
+ bgMagenta: x,
1169
+ bgCyan: x,
1170
+ bgWhite: x
1171
+ };
1172
+ };
1173
+ picocolors_browser.exports = create();
1174
+ picocolors_browser.exports.createColors = create;
1175
+ return picocolors_browser.exports;
1176
+ }
1177
+ var require$$2 = /* @__PURE__ */ getAugmentedNamespace(/* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1178
+ __proto__: null,
1179
+ default: {}
1180
+ }, Symbol.toStringTag, { value: "Module" })));
1181
+ var cssSyntaxError;
1182
+ var hasRequiredCssSyntaxError;
1183
+ function requireCssSyntaxError() {
1184
+ if (hasRequiredCssSyntaxError) return cssSyntaxError;
1185
+ hasRequiredCssSyntaxError = 1;
1186
+ let pico = /* @__PURE__ */ requirePicocolors_browser();
1187
+ let terminalHighlight = require$$2;
1188
+ class CssSyntaxError extends Error {
1189
+ constructor(message, line, column, source, file, plugin) {
1190
+ super(message);
1191
+ this.name = "CssSyntaxError";
1192
+ this.reason = message;
1193
+ if (file) this.file = file;
1194
+ if (source) this.source = source;
1195
+ if (plugin) this.plugin = plugin;
1196
+ if (typeof line !== "undefined" && typeof column !== "undefined") if (typeof line === "number") {
1197
+ this.line = line;
1198
+ this.column = column;
1199
+ } else {
1200
+ this.line = line.line;
1201
+ this.column = line.column;
1202
+ this.endLine = column.line;
1203
+ this.endColumn = column.column;
1204
+ }
1205
+ this.setMessage();
1206
+ if (Error.captureStackTrace) Error.captureStackTrace(this, CssSyntaxError);
1207
+ }
1208
+ setMessage() {
1209
+ this.message = this.plugin ? this.plugin + ": " : "";
1210
+ this.message += this.file ? this.file : "<css input>";
1211
+ if (typeof this.line !== "undefined") this.message += ":" + this.line + ":" + this.column;
1212
+ this.message += ": " + this.reason;
1213
+ }
1214
+ showSourceCode(color) {
1215
+ if (!this.source) return "";
1216
+ let css = this.source;
1217
+ if (color == null) color = pico.isColorSupported;
1218
+ if (terminalHighlight) {
1219
+ if (color) css = terminalHighlight(css);
1220
+ }
1221
+ let lines = css.split(/\r?\n/);
1222
+ let start = Math.max(this.line - 3, 0);
1223
+ let end = Math.min(this.line + 2, lines.length);
1224
+ let maxWidth = String(end).length;
1225
+ let mark, aside;
1226
+ if (color) {
1227
+ let { bold, gray, red } = pico.createColors(true);
1228
+ mark = (text) => bold(red(text));
1229
+ aside = (text) => gray(text);
1230
+ } else mark = aside = (str) => str;
1231
+ return lines.slice(start, end).map((line, index2) => {
1232
+ let number = start + 1 + index2;
1233
+ let gutter = " " + (" " + number).slice(-maxWidth) + " | ";
1234
+ if (number === this.line) {
1235
+ let spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, this.column - 1).replace(/[^\t]/g, " ");
1236
+ return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
1237
+ }
1238
+ return " " + aside(gutter) + line;
1239
+ }).join("\n");
1240
+ }
1241
+ toString() {
1242
+ let code = this.showSourceCode();
1243
+ if (code) code = "\n\n" + code + "\n";
1244
+ return this.name + ": " + this.message + code;
1245
+ }
1246
+ }
1247
+ cssSyntaxError = CssSyntaxError;
1248
+ CssSyntaxError.default = CssSyntaxError;
1249
+ return cssSyntaxError;
1250
+ }
1251
+ var symbols = {};
1252
+ var hasRequiredSymbols;
1253
+ function requireSymbols() {
1254
+ if (hasRequiredSymbols) return symbols;
1255
+ hasRequiredSymbols = 1;
1256
+ symbols.isClean = Symbol("isClean");
1257
+ symbols.my = Symbol("my");
1258
+ return symbols;
1259
+ }
1260
+ var stringifier;
1261
+ var hasRequiredStringifier;
1262
+ function requireStringifier() {
1263
+ if (hasRequiredStringifier) return stringifier;
1264
+ hasRequiredStringifier = 1;
1265
+ const DEFAULT_RAW = {
1266
+ after: "\n",
1267
+ beforeClose: "\n",
1268
+ beforeComment: "\n",
1269
+ beforeDecl: "\n",
1270
+ beforeOpen: " ",
1271
+ beforeRule: "\n",
1272
+ colon: ": ",
1273
+ commentLeft: " ",
1274
+ commentRight: " ",
1275
+ emptyBody: "",
1276
+ indent: " ",
1277
+ semicolon: false
1278
+ };
1279
+ function capitalize(str) {
1280
+ return str[0].toUpperCase() + str.slice(1);
1281
+ }
1282
+ class Stringifier {
1283
+ constructor(builder) {
1284
+ this.builder = builder;
1285
+ }
1286
+ atrule(node2, semicolon) {
1287
+ let name = "@" + node2.name;
1288
+ let params = node2.params ? this.rawValue(node2, "params") : "";
1289
+ if (typeof node2.raws.afterName !== "undefined") name += node2.raws.afterName;
1290
+ else if (params) name += " ";
1291
+ if (node2.nodes) this.block(node2, name + params);
1292
+ else {
1293
+ let end = (node2.raws.between || "") + (semicolon ? ";" : "");
1294
+ this.builder(name + params + end, node2);
1295
+ }
1296
+ }
1297
+ beforeAfter(node2, detect) {
1298
+ let value;
1299
+ if (node2.type === "decl") value = this.raw(node2, null, "beforeDecl");
1300
+ else if (node2.type === "comment") value = this.raw(node2, null, "beforeComment");
1301
+ else if (detect === "before") value = this.raw(node2, null, "beforeRule");
1302
+ else value = this.raw(node2, null, "beforeClose");
1303
+ let buf = node2.parent;
1304
+ let depth = 0;
1305
+ while (buf && buf.type !== "root") {
1306
+ depth += 1;
1307
+ buf = buf.parent;
1308
+ }
1309
+ if (value.includes("\n")) {
1310
+ let indent = this.raw(node2, null, "indent");
1311
+ if (indent.length) for (let step = 0; step < depth; step++) value += indent;
1312
+ }
1313
+ return value;
1314
+ }
1315
+ block(node2, start) {
1316
+ let between = this.raw(node2, "between", "beforeOpen");
1317
+ this.builder(start + between + "{", node2, "start");
1318
+ let after;
1319
+ if (node2.nodes && node2.nodes.length) {
1320
+ this.body(node2);
1321
+ after = this.raw(node2, "after");
1322
+ } else after = this.raw(node2, "after", "emptyBody");
1323
+ if (after) this.builder(after);
1324
+ this.builder("}", node2, "end");
1325
+ }
1326
+ body(node2) {
1327
+ let last = node2.nodes.length - 1;
1328
+ while (last > 0) {
1329
+ if (node2.nodes[last].type !== "comment") break;
1330
+ last -= 1;
1331
+ }
1332
+ let semicolon = this.raw(node2, "semicolon");
1333
+ for (let i = 0; i < node2.nodes.length; i++) {
1334
+ let child = node2.nodes[i];
1335
+ let before = this.raw(child, "before");
1336
+ if (before) this.builder(before);
1337
+ this.stringify(child, last !== i || semicolon);
1338
+ }
1339
+ }
1340
+ comment(node2) {
1341
+ let left = this.raw(node2, "left", "commentLeft");
1342
+ let right = this.raw(node2, "right", "commentRight");
1343
+ this.builder("/*" + left + node2.text + right + "*/", node2);
1344
+ }
1345
+ decl(node2, semicolon) {
1346
+ let between = this.raw(node2, "between", "colon");
1347
+ let string = node2.prop + between + this.rawValue(node2, "value");
1348
+ if (node2.important) string += node2.raws.important || " !important";
1349
+ if (semicolon) string += ";";
1350
+ this.builder(string, node2);
1351
+ }
1352
+ document(node2) {
1353
+ this.body(node2);
1354
+ }
1355
+ raw(node2, own, detect) {
1356
+ let value;
1357
+ if (!detect) detect = own;
1358
+ if (own) {
1359
+ value = node2.raws[own];
1360
+ if (typeof value !== "undefined") return value;
1361
+ }
1362
+ let parent = node2.parent;
1363
+ if (detect === "before") {
1364
+ if (!parent || parent.type === "root" && parent.first === node2) return "";
1365
+ if (parent && parent.type === "document") return "";
1366
+ }
1367
+ if (!parent) return DEFAULT_RAW[detect];
1368
+ let root2 = node2.root();
1369
+ if (!root2.rawCache) root2.rawCache = {};
1370
+ if (typeof root2.rawCache[detect] !== "undefined") return root2.rawCache[detect];
1371
+ if (detect === "before" || detect === "after") return this.beforeAfter(node2, detect);
1372
+ else {
1373
+ let method = "raw" + capitalize(detect);
1374
+ if (this[method]) value = this[method](root2, node2);
1375
+ else root2.walk((i) => {
1376
+ value = i.raws[own];
1377
+ if (typeof value !== "undefined") return false;
1378
+ });
1379
+ }
1380
+ if (typeof value === "undefined") value = DEFAULT_RAW[detect];
1381
+ root2.rawCache[detect] = value;
1382
+ return value;
1383
+ }
1384
+ rawBeforeClose(root2) {
1385
+ let value;
1386
+ root2.walk((i) => {
1387
+ if (i.nodes && i.nodes.length > 0) {
1388
+ if (typeof i.raws.after !== "undefined") {
1389
+ value = i.raws.after;
1390
+ if (value.includes("\n")) value = value.replace(/[^\n]+$/, "");
1391
+ return false;
1392
+ }
1393
+ }
1394
+ });
1395
+ if (value) value = value.replace(/\S/g, "");
1396
+ return value;
1397
+ }
1398
+ rawBeforeComment(root2, node2) {
1399
+ let value;
1400
+ root2.walkComments((i) => {
1401
+ if (typeof i.raws.before !== "undefined") {
1402
+ value = i.raws.before;
1403
+ if (value.includes("\n")) value = value.replace(/[^\n]+$/, "");
1404
+ return false;
1405
+ }
1406
+ });
1407
+ if (typeof value === "undefined") value = this.raw(node2, null, "beforeDecl");
1408
+ else if (value) value = value.replace(/\S/g, "");
1409
+ return value;
1410
+ }
1411
+ rawBeforeDecl(root2, node2) {
1412
+ let value;
1413
+ root2.walkDecls((i) => {
1414
+ if (typeof i.raws.before !== "undefined") {
1415
+ value = i.raws.before;
1416
+ if (value.includes("\n")) value = value.replace(/[^\n]+$/, "");
1417
+ return false;
1418
+ }
1419
+ });
1420
+ if (typeof value === "undefined") value = this.raw(node2, null, "beforeRule");
1421
+ else if (value) value = value.replace(/\S/g, "");
1422
+ return value;
1423
+ }
1424
+ rawBeforeOpen(root2) {
1425
+ let value;
1426
+ root2.walk((i) => {
1427
+ if (i.type !== "decl") {
1428
+ value = i.raws.between;
1429
+ if (typeof value !== "undefined") return false;
1430
+ }
1431
+ });
1432
+ return value;
1433
+ }
1434
+ rawBeforeRule(root2) {
1435
+ let value;
1436
+ root2.walk((i) => {
1437
+ if (i.nodes && (i.parent !== root2 || root2.first !== i)) {
1438
+ if (typeof i.raws.before !== "undefined") {
1439
+ value = i.raws.before;
1440
+ if (value.includes("\n")) value = value.replace(/[^\n]+$/, "");
1441
+ return false;
1442
+ }
1443
+ }
1444
+ });
1445
+ if (value) value = value.replace(/\S/g, "");
1446
+ return value;
1447
+ }
1448
+ rawColon(root2) {
1449
+ let value;
1450
+ root2.walkDecls((i) => {
1451
+ if (typeof i.raws.between !== "undefined") {
1452
+ value = i.raws.between.replace(/[^\s:]/g, "");
1453
+ return false;
1454
+ }
1455
+ });
1456
+ return value;
1457
+ }
1458
+ rawEmptyBody(root2) {
1459
+ let value;
1460
+ root2.walk((i) => {
1461
+ if (i.nodes && i.nodes.length === 0) {
1462
+ value = i.raws.after;
1463
+ if (typeof value !== "undefined") return false;
1464
+ }
1465
+ });
1466
+ return value;
1467
+ }
1468
+ rawIndent(root2) {
1469
+ if (root2.raws.indent) return root2.raws.indent;
1470
+ let value;
1471
+ root2.walk((i) => {
1472
+ let p = i.parent;
1473
+ if (p && p !== root2 && p.parent && p.parent === root2) {
1474
+ if (typeof i.raws.before !== "undefined") {
1475
+ let parts = i.raws.before.split("\n");
1476
+ value = parts[parts.length - 1];
1477
+ value = value.replace(/\S/g, "");
1478
+ return false;
1479
+ }
1480
+ }
1481
+ });
1482
+ return value;
1483
+ }
1484
+ rawSemicolon(root2) {
1485
+ let value;
1486
+ root2.walk((i) => {
1487
+ if (i.nodes && i.nodes.length && i.last.type === "decl") {
1488
+ value = i.raws.semicolon;
1489
+ if (typeof value !== "undefined") return false;
1490
+ }
1491
+ });
1492
+ return value;
1493
+ }
1494
+ rawValue(node2, prop) {
1495
+ let value = node2[prop];
1496
+ let raw = node2.raws[prop];
1497
+ if (raw && raw.value === value) return raw.raw;
1498
+ return value;
1499
+ }
1500
+ root(node2) {
1501
+ this.body(node2);
1502
+ if (node2.raws.after) this.builder(node2.raws.after);
1503
+ }
1504
+ rule(node2) {
1505
+ this.block(node2, this.rawValue(node2, "selector"));
1506
+ if (node2.raws.ownSemicolon) this.builder(node2.raws.ownSemicolon, node2, "end");
1507
+ }
1508
+ stringify(node2, semicolon) {
1509
+ if (!this[node2.type]) throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
1510
+ this[node2.type](node2, semicolon);
1511
+ }
1512
+ }
1513
+ stringifier = Stringifier;
1514
+ Stringifier.default = Stringifier;
1515
+ return stringifier;
1516
+ }
1517
+ var stringify_1;
1518
+ var hasRequiredStringify;
1519
+ function requireStringify() {
1520
+ if (hasRequiredStringify) return stringify_1;
1521
+ hasRequiredStringify = 1;
1522
+ let Stringifier = requireStringifier();
1523
+ function stringify(node2, builder) {
1524
+ new Stringifier(builder).stringify(node2);
1525
+ }
1526
+ stringify_1 = stringify;
1527
+ stringify.default = stringify;
1528
+ return stringify_1;
1529
+ }
1530
+ var node;
1531
+ var hasRequiredNode;
1532
+ function requireNode() {
1533
+ if (hasRequiredNode) return node;
1534
+ hasRequiredNode = 1;
1535
+ let { isClean, my } = requireSymbols();
1536
+ let CssSyntaxError = requireCssSyntaxError();
1537
+ let Stringifier = requireStringifier();
1538
+ let stringify = requireStringify();
1539
+ function cloneNode(obj, parent) {
1540
+ let cloned = new obj.constructor();
1541
+ for (let i in obj) {
1542
+ if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
1543
+ if (i === "proxyCache") continue;
1544
+ let value = obj[i];
1545
+ let type = typeof value;
1546
+ if (i === "parent" && type === "object") {
1547
+ if (parent) cloned[i] = parent;
1548
+ } else if (i === "source") cloned[i] = value;
1549
+ else if (Array.isArray(value)) cloned[i] = value.map((j) => cloneNode(j, cloned));
1550
+ else {
1551
+ if (type === "object" && value !== null) value = cloneNode(value);
1552
+ cloned[i] = value;
1553
+ }
1554
+ }
1555
+ return cloned;
1556
+ }
1557
+ class Node {
1558
+ constructor(defaults = {}) {
1559
+ this.raws = {};
1560
+ this[isClean] = false;
1561
+ this[my] = true;
1562
+ for (let name in defaults) if (name === "nodes") {
1563
+ this.nodes = [];
1564
+ for (let node2 of defaults[name]) if (typeof node2.clone === "function") this.append(node2.clone());
1565
+ else this.append(node2);
1566
+ } else this[name] = defaults[name];
1567
+ }
1568
+ addToError(error) {
1569
+ error.postcssNode = this;
1570
+ if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
1571
+ let s = this.source;
1572
+ error.stack = error.stack.replace(/\n\s{4}at /, `$&${s.input.from}:${s.start.line}:${s.start.column}$&`);
1573
+ }
1574
+ return error;
1575
+ }
1576
+ after(add) {
1577
+ this.parent.insertAfter(this, add);
1578
+ return this;
1579
+ }
1580
+ assign(overrides = {}) {
1581
+ for (let name in overrides) this[name] = overrides[name];
1582
+ return this;
1583
+ }
1584
+ before(add) {
1585
+ this.parent.insertBefore(this, add);
1586
+ return this;
1587
+ }
1588
+ cleanRaws(keepBetween) {
1589
+ delete this.raws.before;
1590
+ delete this.raws.after;
1591
+ if (!keepBetween) delete this.raws.between;
1592
+ }
1593
+ clone(overrides = {}) {
1594
+ let cloned = cloneNode(this);
1595
+ for (let name in overrides) cloned[name] = overrides[name];
1596
+ return cloned;
1597
+ }
1598
+ cloneAfter(overrides = {}) {
1599
+ let cloned = this.clone(overrides);
1600
+ this.parent.insertAfter(this, cloned);
1601
+ return cloned;
1602
+ }
1603
+ cloneBefore(overrides = {}) {
1604
+ let cloned = this.clone(overrides);
1605
+ this.parent.insertBefore(this, cloned);
1606
+ return cloned;
1607
+ }
1608
+ error(message, opts = {}) {
1609
+ if (this.source) {
1610
+ let { end, start } = this.rangeBy(opts);
1611
+ return this.source.input.error(message, {
1612
+ column: start.column,
1613
+ line: start.line
1614
+ }, {
1615
+ column: end.column,
1616
+ line: end.line
1617
+ }, opts);
1618
+ }
1619
+ return new CssSyntaxError(message);
1620
+ }
1621
+ getProxyProcessor() {
1622
+ return {
1623
+ get(node2, prop) {
1624
+ if (prop === "proxyOf") return node2;
1625
+ else if (prop === "root") return () => node2.root().toProxy();
1626
+ else return node2[prop];
1627
+ },
1628
+ set(node2, prop, value) {
1629
+ if (node2[prop] === value) return true;
1630
+ node2[prop] = value;
1631
+ if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || prop === "text") node2.markDirty();
1632
+ return true;
1633
+ }
1634
+ };
1635
+ }
1636
+ markDirty() {
1637
+ if (this[isClean]) {
1638
+ this[isClean] = false;
1639
+ let next = this;
1640
+ while (next = next.parent) next[isClean] = false;
1641
+ }
1642
+ }
1643
+ next() {
1644
+ if (!this.parent) return void 0;
1645
+ let index2 = this.parent.index(this);
1646
+ return this.parent.nodes[index2 + 1];
1647
+ }
1648
+ positionBy(opts, stringRepresentation) {
1649
+ let pos = this.source.start;
1650
+ if (opts.index) pos = this.positionInside(opts.index, stringRepresentation);
1651
+ else if (opts.word) {
1652
+ stringRepresentation = this.toString();
1653
+ let index2 = stringRepresentation.indexOf(opts.word);
1654
+ if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
1655
+ }
1656
+ return pos;
1657
+ }
1658
+ positionInside(index2, stringRepresentation) {
1659
+ let string = stringRepresentation || this.toString();
1660
+ let column = this.source.start.column;
1661
+ let line = this.source.start.line;
1662
+ for (let i = 0; i < index2; i++) if (string[i] === "\n") {
1663
+ column = 1;
1664
+ line += 1;
1665
+ } else column += 1;
1666
+ return {
1667
+ column,
1668
+ line
1669
+ };
1670
+ }
1671
+ prev() {
1672
+ if (!this.parent) return void 0;
1673
+ let index2 = this.parent.index(this);
1674
+ return this.parent.nodes[index2 - 1];
1675
+ }
1676
+ rangeBy(opts) {
1677
+ let start = {
1678
+ column: this.source.start.column,
1679
+ line: this.source.start.line
1680
+ };
1681
+ let end = this.source.end ? {
1682
+ column: this.source.end.column + 1,
1683
+ line: this.source.end.line
1684
+ } : {
1685
+ column: start.column + 1,
1686
+ line: start.line
1687
+ };
1688
+ if (opts.word) {
1689
+ let stringRepresentation = this.toString();
1690
+ let index2 = stringRepresentation.indexOf(opts.word);
1691
+ if (index2 !== -1) {
1692
+ start = this.positionInside(index2, stringRepresentation);
1693
+ end = this.positionInside(index2 + opts.word.length, stringRepresentation);
1694
+ }
1695
+ } else {
1696
+ if (opts.start) start = {
1697
+ column: opts.start.column,
1698
+ line: opts.start.line
1699
+ };
1700
+ else if (opts.index) start = this.positionInside(opts.index);
1701
+ if (opts.end) end = {
1702
+ column: opts.end.column,
1703
+ line: opts.end.line
1704
+ };
1705
+ else if (typeof opts.endIndex === "number") end = this.positionInside(opts.endIndex);
1706
+ else if (opts.index) end = this.positionInside(opts.index + 1);
1707
+ }
1708
+ if (end.line < start.line || end.line === start.line && end.column <= start.column) end = {
1709
+ column: start.column + 1,
1710
+ line: start.line
1711
+ };
1712
+ return {
1713
+ end,
1714
+ start
1715
+ };
1716
+ }
1717
+ raw(prop, defaultType) {
1718
+ return new Stringifier().raw(this, prop, defaultType);
1719
+ }
1720
+ remove() {
1721
+ if (this.parent) this.parent.removeChild(this);
1722
+ this.parent = void 0;
1723
+ return this;
1724
+ }
1725
+ replaceWith(...nodes) {
1726
+ if (this.parent) {
1727
+ let bookmark = this;
1728
+ let foundSelf = false;
1729
+ for (let node2 of nodes) if (node2 === this) foundSelf = true;
1730
+ else if (foundSelf) {
1731
+ this.parent.insertAfter(bookmark, node2);
1732
+ bookmark = node2;
1733
+ } else this.parent.insertBefore(bookmark, node2);
1734
+ if (!foundSelf) this.remove();
1735
+ }
1736
+ return this;
1737
+ }
1738
+ root() {
1739
+ let result2 = this;
1740
+ while (result2.parent && result2.parent.type !== "document") result2 = result2.parent;
1741
+ return result2;
1742
+ }
1743
+ toJSON(_, inputs) {
1744
+ let fixed = {};
1745
+ let emitInputs = inputs == null;
1746
+ inputs = inputs || /* @__PURE__ */ new Map();
1747
+ let inputsNextIndex = 0;
1748
+ for (let name in this) {
1749
+ if (!Object.prototype.hasOwnProperty.call(this, name)) continue;
1750
+ if (name === "parent" || name === "proxyCache") continue;
1751
+ let value = this[name];
1752
+ if (Array.isArray(value)) fixed[name] = value.map((i) => {
1753
+ if (typeof i === "object" && i.toJSON) return i.toJSON(null, inputs);
1754
+ else return i;
1755
+ });
1756
+ else if (typeof value === "object" && value.toJSON) fixed[name] = value.toJSON(null, inputs);
1757
+ else if (name === "source") {
1758
+ let inputId = inputs.get(value.input);
1759
+ if (inputId == null) {
1760
+ inputId = inputsNextIndex;
1761
+ inputs.set(value.input, inputsNextIndex);
1762
+ inputsNextIndex++;
1763
+ }
1764
+ fixed[name] = {
1765
+ end: value.end,
1766
+ inputId,
1767
+ start: value.start
1768
+ };
1769
+ } else fixed[name] = value;
1770
+ }
1771
+ if (emitInputs) fixed.inputs = [...inputs.keys()].map((input2) => input2.toJSON());
1772
+ return fixed;
1773
+ }
1774
+ toProxy() {
1775
+ if (!this.proxyCache) this.proxyCache = new Proxy(this, this.getProxyProcessor());
1776
+ return this.proxyCache;
1777
+ }
1778
+ toString(stringifier2 = stringify) {
1779
+ if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
1780
+ let result2 = "";
1781
+ stringifier2(this, (i) => {
1782
+ result2 += i;
1783
+ });
1784
+ return result2;
1785
+ }
1786
+ warn(result2, text, opts) {
1787
+ let data = { node: this };
1788
+ for (let i in opts) data[i] = opts[i];
1789
+ return result2.warn(text, data);
1790
+ }
1791
+ get proxyOf() {
1792
+ return this;
1793
+ }
1794
+ }
1795
+ node = Node;
1796
+ Node.default = Node;
1797
+ return node;
1798
+ }
1799
+ var declaration;
1800
+ var hasRequiredDeclaration;
1801
+ function requireDeclaration() {
1802
+ if (hasRequiredDeclaration) return declaration;
1803
+ hasRequiredDeclaration = 1;
1804
+ let Node = requireNode();
1805
+ class Declaration extends Node {
1806
+ constructor(defaults) {
1807
+ if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") defaults = {
1808
+ ...defaults,
1809
+ value: String(defaults.value)
1810
+ };
1811
+ super(defaults);
1812
+ this.type = "decl";
1813
+ }
1814
+ get variable() {
1815
+ return this.prop.startsWith("--") || this.prop[0] === "$";
1816
+ }
1817
+ }
1818
+ declaration = Declaration;
1819
+ Declaration.default = Declaration;
1820
+ return declaration;
1821
+ }
1822
+ var nonSecure;
1823
+ var hasRequiredNonSecure;
1824
+ function requireNonSecure() {
1825
+ if (hasRequiredNonSecure) return nonSecure;
1826
+ hasRequiredNonSecure = 1;
1827
+ let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1828
+ let customAlphabet = (alphabet, defaultSize = 21) => {
1829
+ return (size = defaultSize) => {
1830
+ let id = "";
1831
+ let i = size;
1832
+ while (i--) id += alphabet[Math.random() * alphabet.length | 0];
1833
+ return id;
1834
+ };
1835
+ };
1836
+ let nanoid = (size = 21) => {
1837
+ let id = "";
1838
+ let i = size;
1839
+ while (i--) id += urlAlphabet[Math.random() * 64 | 0];
1840
+ return id;
1841
+ };
1842
+ nonSecure = {
1843
+ nanoid,
1844
+ customAlphabet
1845
+ };
1846
+ return nonSecure;
1847
+ }
1848
+ var previousMap;
1849
+ var hasRequiredPreviousMap;
1850
+ function requirePreviousMap() {
1851
+ if (hasRequiredPreviousMap) return previousMap;
1852
+ hasRequiredPreviousMap = 1;
1853
+ let { SourceMapConsumer, SourceMapGenerator } = require$$2;
1854
+ let { existsSync, readFileSync } = require$$2;
1855
+ let { dirname, join } = require$$2;
1856
+ function fromBase64(str) {
1857
+ if (Buffer) return Buffer.from(str, "base64").toString();
1858
+ else return window.atob(str);
1859
+ }
1860
+ class PreviousMap {
1861
+ constructor(css, opts) {
1862
+ if (opts.map === false) return;
1863
+ this.loadAnnotation(css);
1864
+ this.inline = this.startWith(this.annotation, "data:");
1865
+ let prev = opts.map ? opts.map.prev : void 0;
1866
+ let text = this.loadMap(opts.from, prev);
1867
+ if (!this.mapFile && opts.from) this.mapFile = opts.from;
1868
+ if (this.mapFile) this.root = dirname(this.mapFile);
1869
+ if (text) this.text = text;
1870
+ }
1871
+ consumer() {
1872
+ if (!this.consumerCache) this.consumerCache = new SourceMapConsumer(this.text);
1873
+ return this.consumerCache;
1874
+ }
1875
+ decodeInline(text) {
1876
+ let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
1877
+ let baseUri = /^data:application\/json;base64,/;
1878
+ if (/^data:application\/json;charset=utf-?8,/.test(text) || /^data:application\/json,/.test(text)) return decodeURIComponent(text.substr(RegExp.lastMatch.length));
1879
+ if (baseCharsetUri.test(text) || baseUri.test(text)) return fromBase64(text.substr(RegExp.lastMatch.length));
1880
+ let encoding = text.match(/data:application\/json;([^,]+),/)[1];
1881
+ throw new Error("Unsupported source map encoding " + encoding);
1882
+ }
1883
+ getAnnotationURL(sourceMapString) {
1884
+ return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
1885
+ }
1886
+ isMap(map) {
1887
+ if (typeof map !== "object") return false;
1888
+ return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
1889
+ }
1890
+ loadAnnotation(css) {
1891
+ let comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
1892
+ if (!comments) return;
1893
+ let start = css.lastIndexOf(comments.pop());
1894
+ let end = css.indexOf("*/", start);
1895
+ if (start > -1 && end > -1) this.annotation = this.getAnnotationURL(css.substring(start, end));
1896
+ }
1897
+ loadFile(path) {
1898
+ this.root = dirname(path);
1899
+ if (existsSync(path)) {
1900
+ this.mapFile = path;
1901
+ return readFileSync(path, "utf-8").toString().trim();
1902
+ }
1903
+ }
1904
+ loadMap(file, prev) {
1905
+ if (prev === false) return false;
1906
+ if (prev) if (typeof prev === "string") return prev;
1907
+ else if (typeof prev === "function") {
1908
+ let prevPath = prev(file);
1909
+ if (prevPath) {
1910
+ let map = this.loadFile(prevPath);
1911
+ if (!map) throw new Error("Unable to load previous source map: " + prevPath.toString());
1912
+ return map;
1913
+ }
1914
+ } else if (prev instanceof SourceMapConsumer) return SourceMapGenerator.fromSourceMap(prev).toString();
1915
+ else if (prev instanceof SourceMapGenerator) return prev.toString();
1916
+ else if (this.isMap(prev)) return JSON.stringify(prev);
1917
+ else throw new Error("Unsupported previous source map format: " + prev.toString());
1918
+ else if (this.inline) return this.decodeInline(this.annotation);
1919
+ else if (this.annotation) {
1920
+ let map = this.annotation;
1921
+ if (file) map = join(dirname(file), map);
1922
+ return this.loadFile(map);
1923
+ }
1924
+ }
1925
+ startWith(string, start) {
1926
+ if (!string) return false;
1927
+ return string.substr(0, start.length) === start;
1928
+ }
1929
+ withContent() {
1930
+ return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
1931
+ }
1932
+ }
1933
+ previousMap = PreviousMap;
1934
+ PreviousMap.default = PreviousMap;
1935
+ return previousMap;
1936
+ }
1937
+ var input;
1938
+ var hasRequiredInput;
1939
+ function requireInput() {
1940
+ if (hasRequiredInput) return input;
1941
+ hasRequiredInput = 1;
1942
+ let { SourceMapConsumer, SourceMapGenerator } = require$$2;
1943
+ let { fileURLToPath, pathToFileURL } = require$$2;
1944
+ let { isAbsolute, resolve } = require$$2;
1945
+ let { nanoid } = /* @__PURE__ */ requireNonSecure();
1946
+ let terminalHighlight = require$$2;
1947
+ let CssSyntaxError = requireCssSyntaxError();
1948
+ let PreviousMap = requirePreviousMap();
1949
+ let fromOffsetCache = Symbol("fromOffsetCache");
1950
+ let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
1951
+ let pathAvailable = Boolean(resolve && isAbsolute);
1952
+ class Input {
1953
+ constructor(css, opts = {}) {
1954
+ if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) throw new Error(`PostCSS received ${css} instead of CSS string`);
1955
+ this.css = css.toString();
1956
+ if (this.css[0] === "" || this.css[0] === "￾") {
1957
+ this.hasBOM = true;
1958
+ this.css = this.css.slice(1);
1959
+ } else this.hasBOM = false;
1960
+ if (opts.from) if (!pathAvailable || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) this.file = opts.from;
1961
+ else this.file = resolve(opts.from);
1962
+ if (pathAvailable && sourceMapAvailable) {
1963
+ let map = new PreviousMap(this.css, opts);
1964
+ if (map.text) {
1965
+ this.map = map;
1966
+ let file = map.consumer().file;
1967
+ if (!this.file && file) this.file = this.mapResolve(file);
1968
+ }
1969
+ }
1970
+ if (!this.file) this.id = "<input css " + nanoid(6) + ">";
1971
+ if (this.map) this.map.file = this.from;
1972
+ }
1973
+ error(message, line, column, opts = {}) {
1974
+ let result2, endLine, endColumn;
1975
+ if (line && typeof line === "object") {
1976
+ let start = line;
1977
+ let end = column;
1978
+ if (typeof start.offset === "number") {
1979
+ let pos = this.fromOffset(start.offset);
1980
+ line = pos.line;
1981
+ column = pos.col;
1982
+ } else {
1983
+ line = start.line;
1984
+ column = start.column;
1985
+ }
1986
+ if (typeof end.offset === "number") {
1987
+ let pos = this.fromOffset(end.offset);
1988
+ endLine = pos.line;
1989
+ endColumn = pos.col;
1990
+ } else {
1991
+ endLine = end.line;
1992
+ endColumn = end.column;
1993
+ }
1994
+ } else if (!column) {
1995
+ let pos = this.fromOffset(line);
1996
+ line = pos.line;
1997
+ column = pos.col;
1998
+ }
1999
+ let origin = this.origin(line, column, endLine, endColumn);
2000
+ if (origin) result2 = new CssSyntaxError(message, origin.endLine === void 0 ? origin.line : {
2001
+ column: origin.column,
2002
+ line: origin.line
2003
+ }, origin.endLine === void 0 ? origin.column : {
2004
+ column: origin.endColumn,
2005
+ line: origin.endLine
2006
+ }, origin.source, origin.file, opts.plugin);
2007
+ else result2 = new CssSyntaxError(message, endLine === void 0 ? line : {
2008
+ column,
2009
+ line
2010
+ }, endLine === void 0 ? column : {
2011
+ column: endColumn,
2012
+ line: endLine
2013
+ }, this.css, this.file, opts.plugin);
2014
+ result2.input = {
2015
+ column,
2016
+ endColumn,
2017
+ endLine,
2018
+ line,
2019
+ source: this.css
2020
+ };
2021
+ if (this.file) {
2022
+ if (pathToFileURL) result2.input.url = pathToFileURL(this.file).toString();
2023
+ result2.input.file = this.file;
2024
+ }
2025
+ return result2;
2026
+ }
2027
+ fromOffset(offset) {
2028
+ let lastLine, lineToIndex;
2029
+ if (!this[fromOffsetCache]) {
2030
+ let lines = this.css.split("\n");
2031
+ lineToIndex = new Array(lines.length);
2032
+ let prevIndex = 0;
2033
+ for (let i = 0, l = lines.length; i < l; i++) {
2034
+ lineToIndex[i] = prevIndex;
2035
+ prevIndex += lines[i].length + 1;
2036
+ }
2037
+ this[fromOffsetCache] = lineToIndex;
2038
+ } else lineToIndex = this[fromOffsetCache];
2039
+ lastLine = lineToIndex[lineToIndex.length - 1];
2040
+ let min = 0;
2041
+ if (offset >= lastLine) min = lineToIndex.length - 1;
2042
+ else {
2043
+ let max = lineToIndex.length - 2;
2044
+ let mid;
2045
+ while (min < max) {
2046
+ mid = min + (max - min >> 1);
2047
+ if (offset < lineToIndex[mid]) max = mid - 1;
2048
+ else if (offset >= lineToIndex[mid + 1]) min = mid + 1;
2049
+ else {
2050
+ min = mid;
2051
+ break;
2052
+ }
2053
+ }
2054
+ }
2055
+ return {
2056
+ col: offset - lineToIndex[min] + 1,
2057
+ line: min + 1
2058
+ };
2059
+ }
2060
+ mapResolve(file) {
2061
+ if (/^\w+:\/\//.test(file)) return file;
2062
+ return resolve(this.map.consumer().sourceRoot || this.map.root || ".", file);
2063
+ }
2064
+ origin(line, column, endLine, endColumn) {
2065
+ if (!this.map) return false;
2066
+ let consumer = this.map.consumer();
2067
+ let from = consumer.originalPositionFor({
2068
+ column,
2069
+ line
2070
+ });
2071
+ if (!from.source) return false;
2072
+ let to;
2073
+ if (typeof endLine === "number") to = consumer.originalPositionFor({
2074
+ column: endColumn,
2075
+ line: endLine
2076
+ });
2077
+ let fromUrl;
2078
+ if (isAbsolute(from.source)) fromUrl = pathToFileURL(from.source);
2079
+ else fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL(this.map.mapFile));
2080
+ let result2 = {
2081
+ column: from.column,
2082
+ endColumn: to && to.column,
2083
+ endLine: to && to.line,
2084
+ line: from.line,
2085
+ url: fromUrl.toString()
2086
+ };
2087
+ if (fromUrl.protocol === "file:") if (fileURLToPath) result2.file = fileURLToPath(fromUrl);
2088
+ else throw new Error(`file: protocol is not available in this PostCSS build`);
2089
+ let source = consumer.sourceContentFor(from.source);
2090
+ if (source) result2.source = source;
2091
+ return result2;
2092
+ }
2093
+ toJSON() {
2094
+ let json = {};
2095
+ for (let name of [
2096
+ "hasBOM",
2097
+ "css",
2098
+ "file",
2099
+ "id"
2100
+ ]) if (this[name] != null) json[name] = this[name];
2101
+ if (this.map) {
2102
+ json.map = { ...this.map };
2103
+ if (json.map.consumerCache) json.map.consumerCache = void 0;
2104
+ }
2105
+ return json;
2106
+ }
2107
+ get from() {
2108
+ return this.file || this.id;
2109
+ }
2110
+ }
2111
+ input = Input;
2112
+ Input.default = Input;
2113
+ if (terminalHighlight && terminalHighlight.registerInput) terminalHighlight.registerInput(Input);
2114
+ return input;
2115
+ }
2116
+ var mapGenerator;
2117
+ var hasRequiredMapGenerator;
2118
+ function requireMapGenerator() {
2119
+ if (hasRequiredMapGenerator) return mapGenerator;
2120
+ hasRequiredMapGenerator = 1;
2121
+ let { SourceMapConsumer, SourceMapGenerator } = require$$2;
2122
+ let { dirname, relative, resolve, sep } = require$$2;
2123
+ let { pathToFileURL } = require$$2;
2124
+ let Input = requireInput();
2125
+ let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
2126
+ let pathAvailable = Boolean(dirname && resolve && relative && sep);
2127
+ class MapGenerator {
2128
+ constructor(stringify, root2, opts, cssString) {
2129
+ this.stringify = stringify;
2130
+ this.mapOpts = opts.map || {};
2131
+ this.root = root2;
2132
+ this.opts = opts;
2133
+ this.css = cssString;
2134
+ this.originalCSS = cssString;
2135
+ this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
2136
+ this.memoizedFileURLs = /* @__PURE__ */ new Map();
2137
+ this.memoizedPaths = /* @__PURE__ */ new Map();
2138
+ this.memoizedURLs = /* @__PURE__ */ new Map();
2139
+ }
2140
+ addAnnotation() {
2141
+ let content;
2142
+ if (this.isInline()) content = "data:application/json;base64," + this.toBase64(this.map.toString());
2143
+ else if (typeof this.mapOpts.annotation === "string") content = this.mapOpts.annotation;
2144
+ else if (typeof this.mapOpts.annotation === "function") content = this.mapOpts.annotation(this.opts.to, this.root);
2145
+ else content = this.outputFile() + ".map";
2146
+ let eol = "\n";
2147
+ if (this.css.includes("\r\n")) eol = "\r\n";
2148
+ this.css += eol + "/*# sourceMappingURL=" + content + " */";
2149
+ }
2150
+ applyPrevMaps() {
2151
+ for (let prev of this.previous()) {
2152
+ let from = this.toUrl(this.path(prev.file));
2153
+ let root2 = prev.root || dirname(prev.file);
2154
+ let map;
2155
+ if (this.mapOpts.sourcesContent === false) {
2156
+ map = new SourceMapConsumer(prev.text);
2157
+ if (map.sourcesContent) map.sourcesContent = null;
2158
+ } else map = prev.consumer();
2159
+ this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
2160
+ }
2161
+ }
2162
+ clearAnnotation() {
2163
+ if (this.mapOpts.annotation === false) return;
2164
+ if (this.root) {
2165
+ let node2;
2166
+ for (let i = this.root.nodes.length - 1; i >= 0; i--) {
2167
+ node2 = this.root.nodes[i];
2168
+ if (node2.type !== "comment") continue;
2169
+ if (node2.text.indexOf("# sourceMappingURL=") === 0) this.root.removeChild(i);
2170
+ }
2171
+ } else if (this.css) this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
2172
+ }
2173
+ generate() {
2174
+ this.clearAnnotation();
2175
+ if (pathAvailable && sourceMapAvailable && this.isMap()) return this.generateMap();
2176
+ else {
2177
+ let result2 = "";
2178
+ this.stringify(this.root, (i) => {
2179
+ result2 += i;
2180
+ });
2181
+ return [result2];
2182
+ }
2183
+ }
2184
+ generateMap() {
2185
+ if (this.root) this.generateString();
2186
+ else if (this.previous().length === 1) {
2187
+ let prev = this.previous()[0].consumer();
2188
+ prev.file = this.outputFile();
2189
+ this.map = SourceMapGenerator.fromSourceMap(prev, { ignoreInvalidMapping: true });
2190
+ } else {
2191
+ this.map = new SourceMapGenerator({
2192
+ file: this.outputFile(),
2193
+ ignoreInvalidMapping: true
2194
+ });
2195
+ this.map.addMapping({
2196
+ generated: {
2197
+ column: 0,
2198
+ line: 1
2199
+ },
2200
+ original: {
2201
+ column: 0,
2202
+ line: 1
2203
+ },
2204
+ source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
2205
+ });
2206
+ }
2207
+ if (this.isSourcesContent()) this.setSourcesContent();
2208
+ if (this.root && this.previous().length > 0) this.applyPrevMaps();
2209
+ if (this.isAnnotation()) this.addAnnotation();
2210
+ if (this.isInline()) return [this.css];
2211
+ else return [this.css, this.map];
2212
+ }
2213
+ generateString() {
2214
+ this.css = "";
2215
+ this.map = new SourceMapGenerator({
2216
+ file: this.outputFile(),
2217
+ ignoreInvalidMapping: true
2218
+ });
2219
+ let line = 1;
2220
+ let column = 1;
2221
+ let noSource = "<no source>";
2222
+ let mapping = {
2223
+ generated: {
2224
+ column: 0,
2225
+ line: 0
2226
+ },
2227
+ original: {
2228
+ column: 0,
2229
+ line: 0
2230
+ },
2231
+ source: ""
2232
+ };
2233
+ let lines, last;
2234
+ this.stringify(this.root, (str, node2, type) => {
2235
+ this.css += str;
2236
+ if (node2 && type !== "end") {
2237
+ mapping.generated.line = line;
2238
+ mapping.generated.column = column - 1;
2239
+ if (node2.source && node2.source.start) {
2240
+ mapping.source = this.sourcePath(node2);
2241
+ mapping.original.line = node2.source.start.line;
2242
+ mapping.original.column = node2.source.start.column - 1;
2243
+ this.map.addMapping(mapping);
2244
+ } else {
2245
+ mapping.source = noSource;
2246
+ mapping.original.line = 1;
2247
+ mapping.original.column = 0;
2248
+ this.map.addMapping(mapping);
2249
+ }
2250
+ }
2251
+ lines = str.match(/\n/g);
2252
+ if (lines) {
2253
+ line += lines.length;
2254
+ last = str.lastIndexOf("\n");
2255
+ column = str.length - last;
2256
+ } else column += str.length;
2257
+ if (node2 && type !== "start") {
2258
+ let p = node2.parent || { raws: {} };
2259
+ if (!(node2.type === "decl" || node2.type === "atrule" && !node2.nodes) || node2 !== p.last || p.raws.semicolon) if (node2.source && node2.source.end) {
2260
+ mapping.source = this.sourcePath(node2);
2261
+ mapping.original.line = node2.source.end.line;
2262
+ mapping.original.column = node2.source.end.column - 1;
2263
+ mapping.generated.line = line;
2264
+ mapping.generated.column = column - 2;
2265
+ this.map.addMapping(mapping);
2266
+ } else {
2267
+ mapping.source = noSource;
2268
+ mapping.original.line = 1;
2269
+ mapping.original.column = 0;
2270
+ mapping.generated.line = line;
2271
+ mapping.generated.column = column - 1;
2272
+ this.map.addMapping(mapping);
2273
+ }
2274
+ }
2275
+ });
2276
+ }
2277
+ isAnnotation() {
2278
+ if (this.isInline()) return true;
2279
+ if (typeof this.mapOpts.annotation !== "undefined") return this.mapOpts.annotation;
2280
+ if (this.previous().length) return this.previous().some((i) => i.annotation);
2281
+ return true;
2282
+ }
2283
+ isInline() {
2284
+ if (typeof this.mapOpts.inline !== "undefined") return this.mapOpts.inline;
2285
+ let annotation = this.mapOpts.annotation;
2286
+ if (typeof annotation !== "undefined" && annotation !== true) return false;
2287
+ if (this.previous().length) return this.previous().some((i) => i.inline);
2288
+ return true;
2289
+ }
2290
+ isMap() {
2291
+ if (typeof this.opts.map !== "undefined") return !!this.opts.map;
2292
+ return this.previous().length > 0;
2293
+ }
2294
+ isSourcesContent() {
2295
+ if (typeof this.mapOpts.sourcesContent !== "undefined") return this.mapOpts.sourcesContent;
2296
+ if (this.previous().length) return this.previous().some((i) => i.withContent());
2297
+ return true;
2298
+ }
2299
+ outputFile() {
2300
+ if (this.opts.to) return this.path(this.opts.to);
2301
+ else if (this.opts.from) return this.path(this.opts.from);
2302
+ else return "to.css";
2303
+ }
2304
+ path(file) {
2305
+ if (this.mapOpts.absolute) return file;
2306
+ if (file.charCodeAt(0) === 60) return file;
2307
+ if (/^\w+:\/\//.test(file)) return file;
2308
+ let cached = this.memoizedPaths.get(file);
2309
+ if (cached) return cached;
2310
+ let from = this.opts.to ? dirname(this.opts.to) : ".";
2311
+ if (typeof this.mapOpts.annotation === "string") from = dirname(resolve(from, this.mapOpts.annotation));
2312
+ let path = relative(from, file);
2313
+ this.memoizedPaths.set(file, path);
2314
+ return path;
2315
+ }
2316
+ previous() {
2317
+ if (!this.previousMaps) {
2318
+ this.previousMaps = [];
2319
+ if (this.root) this.root.walk((node2) => {
2320
+ if (node2.source && node2.source.input.map) {
2321
+ let map = node2.source.input.map;
2322
+ if (!this.previousMaps.includes(map)) this.previousMaps.push(map);
2323
+ }
2324
+ });
2325
+ else {
2326
+ let input2 = new Input(this.originalCSS, this.opts);
2327
+ if (input2.map) this.previousMaps.push(input2.map);
2328
+ }
2329
+ }
2330
+ return this.previousMaps;
2331
+ }
2332
+ setSourcesContent() {
2333
+ let already = {};
2334
+ if (this.root) this.root.walk((node2) => {
2335
+ if (node2.source) {
2336
+ let from = node2.source.input.from;
2337
+ if (from && !already[from]) {
2338
+ already[from] = true;
2339
+ let fromUrl = this.usesFileUrls ? this.toFileUrl(from) : this.toUrl(this.path(from));
2340
+ this.map.setSourceContent(fromUrl, node2.source.input.css);
2341
+ }
2342
+ }
2343
+ });
2344
+ else if (this.css) {
2345
+ let from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
2346
+ this.map.setSourceContent(from, this.css);
2347
+ }
2348
+ }
2349
+ sourcePath(node2) {
2350
+ if (this.mapOpts.from) return this.toUrl(this.mapOpts.from);
2351
+ else if (this.usesFileUrls) return this.toFileUrl(node2.source.input.from);
2352
+ else return this.toUrl(this.path(node2.source.input.from));
2353
+ }
2354
+ toBase64(str) {
2355
+ if (Buffer) return Buffer.from(str).toString("base64");
2356
+ else return window.btoa(unescape(encodeURIComponent(str)));
2357
+ }
2358
+ toFileUrl(path) {
2359
+ let cached = this.memoizedFileURLs.get(path);
2360
+ if (cached) return cached;
2361
+ if (pathToFileURL) {
2362
+ let fileURL = pathToFileURL(path).toString();
2363
+ this.memoizedFileURLs.set(path, fileURL);
2364
+ return fileURL;
2365
+ } else throw new Error("`map.absolute` option is not available in this PostCSS build");
2366
+ }
2367
+ toUrl(path) {
2368
+ let cached = this.memoizedURLs.get(path);
2369
+ if (cached) return cached;
2370
+ if (sep === "\\") path = path.replace(/\\/g, "/");
2371
+ let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
2372
+ this.memoizedURLs.set(path, url);
2373
+ return url;
2374
+ }
2375
+ }
2376
+ mapGenerator = MapGenerator;
2377
+ return mapGenerator;
2378
+ }
2379
+ var comment;
2380
+ var hasRequiredComment;
2381
+ function requireComment() {
2382
+ if (hasRequiredComment) return comment;
2383
+ hasRequiredComment = 1;
2384
+ let Node = requireNode();
2385
+ class Comment extends Node {
2386
+ constructor(defaults) {
2387
+ super(defaults);
2388
+ this.type = "comment";
2389
+ }
2390
+ }
2391
+ comment = Comment;
2392
+ Comment.default = Comment;
2393
+ return comment;
2394
+ }
2395
+ var container;
2396
+ var hasRequiredContainer;
2397
+ function requireContainer() {
2398
+ if (hasRequiredContainer) return container;
2399
+ hasRequiredContainer = 1;
2400
+ let { isClean, my } = requireSymbols();
2401
+ let Declaration = requireDeclaration();
2402
+ let Comment = requireComment();
2403
+ let Node = requireNode();
2404
+ let parse, Rule, AtRule, Root;
2405
+ function cleanSource(nodes) {
2406
+ return nodes.map((i) => {
2407
+ if (i.nodes) i.nodes = cleanSource(i.nodes);
2408
+ delete i.source;
2409
+ return i;
2410
+ });
2411
+ }
2412
+ function markDirtyUp(node2) {
2413
+ node2[isClean] = false;
2414
+ if (node2.proxyOf.nodes) for (let i of node2.proxyOf.nodes) markDirtyUp(i);
2415
+ }
2416
+ class Container extends Node {
2417
+ append(...children) {
2418
+ for (let child of children) {
2419
+ let nodes = this.normalize(child, this.last);
2420
+ for (let node2 of nodes) this.proxyOf.nodes.push(node2);
2421
+ }
2422
+ this.markDirty();
2423
+ return this;
2424
+ }
2425
+ cleanRaws(keepBetween) {
2426
+ super.cleanRaws(keepBetween);
2427
+ if (this.nodes) for (let node2 of this.nodes) node2.cleanRaws(keepBetween);
2428
+ }
2429
+ each(callback) {
2430
+ if (!this.proxyOf.nodes) return void 0;
2431
+ let iterator = this.getIterator();
2432
+ let index2, result2;
2433
+ while (this.indexes[iterator] < this.proxyOf.nodes.length) {
2434
+ index2 = this.indexes[iterator];
2435
+ result2 = callback(this.proxyOf.nodes[index2], index2);
2436
+ if (result2 === false) break;
2437
+ this.indexes[iterator] += 1;
2438
+ }
2439
+ delete this.indexes[iterator];
2440
+ return result2;
2441
+ }
2442
+ every(condition) {
2443
+ return this.nodes.every(condition);
2444
+ }
2445
+ getIterator() {
2446
+ if (!this.lastEach) this.lastEach = 0;
2447
+ if (!this.indexes) this.indexes = {};
2448
+ this.lastEach += 1;
2449
+ let iterator = this.lastEach;
2450
+ this.indexes[iterator] = 0;
2451
+ return iterator;
2452
+ }
2453
+ getProxyProcessor() {
2454
+ return {
2455
+ get(node2, prop) {
2456
+ if (prop === "proxyOf") return node2;
2457
+ else if (!node2[prop]) return node2[prop];
2458
+ else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) return (...args) => {
2459
+ return node2[prop](...args.map((i) => {
2460
+ if (typeof i === "function") return (child, index2) => i(child.toProxy(), index2);
2461
+ else return i;
2462
+ }));
2463
+ };
2464
+ else if (prop === "every" || prop === "some") return (cb) => {
2465
+ return node2[prop]((child, ...other) => cb(child.toProxy(), ...other));
2466
+ };
2467
+ else if (prop === "root") return () => node2.root().toProxy();
2468
+ else if (prop === "nodes") return node2.nodes.map((i) => i.toProxy());
2469
+ else if (prop === "first" || prop === "last") return node2[prop].toProxy();
2470
+ else return node2[prop];
2471
+ },
2472
+ set(node2, prop, value) {
2473
+ if (node2[prop] === value) return true;
2474
+ node2[prop] = value;
2475
+ if (prop === "name" || prop === "params" || prop === "selector") node2.markDirty();
2476
+ return true;
2477
+ }
2478
+ };
2479
+ }
2480
+ index(child) {
2481
+ if (typeof child === "number") return child;
2482
+ if (child.proxyOf) child = child.proxyOf;
2483
+ return this.proxyOf.nodes.indexOf(child);
2484
+ }
2485
+ insertAfter(exist, add) {
2486
+ let existIndex = this.index(exist);
2487
+ let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
2488
+ existIndex = this.index(exist);
2489
+ for (let node2 of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
2490
+ let index2;
2491
+ for (let id in this.indexes) {
2492
+ index2 = this.indexes[id];
2493
+ if (existIndex < index2) this.indexes[id] = index2 + nodes.length;
2494
+ }
2495
+ this.markDirty();
2496
+ return this;
2497
+ }
2498
+ insertBefore(exist, add) {
2499
+ let existIndex = this.index(exist);
2500
+ let type = existIndex === 0 ? "prepend" : false;
2501
+ let nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
2502
+ existIndex = this.index(exist);
2503
+ for (let node2 of nodes) this.proxyOf.nodes.splice(existIndex, 0, node2);
2504
+ let index2;
2505
+ for (let id in this.indexes) {
2506
+ index2 = this.indexes[id];
2507
+ if (existIndex <= index2) this.indexes[id] = index2 + nodes.length;
2508
+ }
2509
+ this.markDirty();
2510
+ return this;
2511
+ }
2512
+ normalize(nodes, sample) {
2513
+ if (typeof nodes === "string") nodes = cleanSource(parse(nodes).nodes);
2514
+ else if (typeof nodes === "undefined") nodes = [];
2515
+ else if (Array.isArray(nodes)) {
2516
+ nodes = nodes.slice(0);
2517
+ for (let i of nodes) if (i.parent) i.parent.removeChild(i, "ignore");
2518
+ } else if (nodes.type === "root" && this.type !== "document") {
2519
+ nodes = nodes.nodes.slice(0);
2520
+ for (let i of nodes) if (i.parent) i.parent.removeChild(i, "ignore");
2521
+ } else if (nodes.type) nodes = [nodes];
2522
+ else if (nodes.prop) {
2523
+ if (typeof nodes.value === "undefined") throw new Error("Value field is missed in node creation");
2524
+ else if (typeof nodes.value !== "string") nodes.value = String(nodes.value);
2525
+ nodes = [new Declaration(nodes)];
2526
+ } else if (nodes.selector) nodes = [new Rule(nodes)];
2527
+ else if (nodes.name) nodes = [new AtRule(nodes)];
2528
+ else if (nodes.text) nodes = [new Comment(nodes)];
2529
+ else throw new Error("Unknown node type in node creation");
2530
+ return nodes.map((i) => {
2531
+ if (!i[my]) Container.rebuild(i);
2532
+ i = i.proxyOf;
2533
+ if (i.parent) i.parent.removeChild(i);
2534
+ if (i[isClean]) markDirtyUp(i);
2535
+ if (typeof i.raws.before === "undefined") {
2536
+ if (sample && typeof sample.raws.before !== "undefined") i.raws.before = sample.raws.before.replace(/\S/g, "");
2537
+ }
2538
+ i.parent = this.proxyOf;
2539
+ return i;
2540
+ });
2541
+ }
2542
+ prepend(...children) {
2543
+ children = children.reverse();
2544
+ for (let child of children) {
2545
+ let nodes = this.normalize(child, this.first, "prepend").reverse();
2546
+ for (let node2 of nodes) this.proxyOf.nodes.unshift(node2);
2547
+ for (let id in this.indexes) this.indexes[id] = this.indexes[id] + nodes.length;
2548
+ }
2549
+ this.markDirty();
2550
+ return this;
2551
+ }
2552
+ push(child) {
2553
+ child.parent = this;
2554
+ this.proxyOf.nodes.push(child);
2555
+ return this;
2556
+ }
2557
+ removeAll() {
2558
+ for (let node2 of this.proxyOf.nodes) node2.parent = void 0;
2559
+ this.proxyOf.nodes = [];
2560
+ this.markDirty();
2561
+ return this;
2562
+ }
2563
+ removeChild(child) {
2564
+ child = this.index(child);
2565
+ this.proxyOf.nodes[child].parent = void 0;
2566
+ this.proxyOf.nodes.splice(child, 1);
2567
+ let index2;
2568
+ for (let id in this.indexes) {
2569
+ index2 = this.indexes[id];
2570
+ if (index2 >= child) this.indexes[id] = index2 - 1;
2571
+ }
2572
+ this.markDirty();
2573
+ return this;
2574
+ }
2575
+ replaceValues(pattern, opts, callback) {
2576
+ if (!callback) {
2577
+ callback = opts;
2578
+ opts = {};
2579
+ }
2580
+ this.walkDecls((decl) => {
2581
+ if (opts.props && !opts.props.includes(decl.prop)) return;
2582
+ if (opts.fast && !decl.value.includes(opts.fast)) return;
2583
+ decl.value = decl.value.replace(pattern, callback);
2584
+ });
2585
+ this.markDirty();
2586
+ return this;
2587
+ }
2588
+ some(condition) {
2589
+ return this.nodes.some(condition);
2590
+ }
2591
+ walk(callback) {
2592
+ return this.each((child, i) => {
2593
+ let result2;
2594
+ try {
2595
+ result2 = callback(child, i);
2596
+ } catch (e) {
2597
+ throw child.addToError(e);
2598
+ }
2599
+ if (result2 !== false && child.walk) result2 = child.walk(callback);
2600
+ return result2;
2601
+ });
2602
+ }
2603
+ walkAtRules(name, callback) {
2604
+ if (!callback) {
2605
+ callback = name;
2606
+ return this.walk((child, i) => {
2607
+ if (child.type === "atrule") return callback(child, i);
2608
+ });
2609
+ }
2610
+ if (name instanceof RegExp) return this.walk((child, i) => {
2611
+ if (child.type === "atrule" && name.test(child.name)) return callback(child, i);
2612
+ });
2613
+ return this.walk((child, i) => {
2614
+ if (child.type === "atrule" && child.name === name) return callback(child, i);
2615
+ });
2616
+ }
2617
+ walkComments(callback) {
2618
+ return this.walk((child, i) => {
2619
+ if (child.type === "comment") return callback(child, i);
2620
+ });
2621
+ }
2622
+ walkDecls(prop, callback) {
2623
+ if (!callback) {
2624
+ callback = prop;
2625
+ return this.walk((child, i) => {
2626
+ if (child.type === "decl") return callback(child, i);
2627
+ });
2628
+ }
2629
+ if (prop instanceof RegExp) return this.walk((child, i) => {
2630
+ if (child.type === "decl" && prop.test(child.prop)) return callback(child, i);
2631
+ });
2632
+ return this.walk((child, i) => {
2633
+ if (child.type === "decl" && child.prop === prop) return callback(child, i);
2634
+ });
2635
+ }
2636
+ walkRules(selector, callback) {
2637
+ if (!callback) {
2638
+ callback = selector;
2639
+ return this.walk((child, i) => {
2640
+ if (child.type === "rule") return callback(child, i);
2641
+ });
2642
+ }
2643
+ if (selector instanceof RegExp) return this.walk((child, i) => {
2644
+ if (child.type === "rule" && selector.test(child.selector)) return callback(child, i);
2645
+ });
2646
+ return this.walk((child, i) => {
2647
+ if (child.type === "rule" && child.selector === selector) return callback(child, i);
2648
+ });
2649
+ }
2650
+ get first() {
2651
+ if (!this.proxyOf.nodes) return void 0;
2652
+ return this.proxyOf.nodes[0];
2653
+ }
2654
+ get last() {
2655
+ if (!this.proxyOf.nodes) return void 0;
2656
+ return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
2657
+ }
2658
+ }
2659
+ Container.registerParse = (dependant) => {
2660
+ parse = dependant;
2661
+ };
2662
+ Container.registerRule = (dependant) => {
2663
+ Rule = dependant;
2664
+ };
2665
+ Container.registerAtRule = (dependant) => {
2666
+ AtRule = dependant;
2667
+ };
2668
+ Container.registerRoot = (dependant) => {
2669
+ Root = dependant;
2670
+ };
2671
+ container = Container;
2672
+ Container.default = Container;
2673
+ Container.rebuild = (node2) => {
2674
+ if (node2.type === "atrule") Object.setPrototypeOf(node2, AtRule.prototype);
2675
+ else if (node2.type === "rule") Object.setPrototypeOf(node2, Rule.prototype);
2676
+ else if (node2.type === "decl") Object.setPrototypeOf(node2, Declaration.prototype);
2677
+ else if (node2.type === "comment") Object.setPrototypeOf(node2, Comment.prototype);
2678
+ else if (node2.type === "root") Object.setPrototypeOf(node2, Root.prototype);
2679
+ node2[my] = true;
2680
+ if (node2.nodes) node2.nodes.forEach((child) => {
2681
+ Container.rebuild(child);
2682
+ });
2683
+ };
2684
+ return container;
2685
+ }
2686
+ var document$1;
2687
+ var hasRequiredDocument;
2688
+ function requireDocument() {
2689
+ if (hasRequiredDocument) return document$1;
2690
+ hasRequiredDocument = 1;
2691
+ let Container = requireContainer();
2692
+ let LazyResult, Processor;
2693
+ class Document extends Container {
2694
+ constructor(defaults) {
2695
+ super({
2696
+ type: "document",
2697
+ ...defaults
2698
+ });
2699
+ if (!this.nodes) this.nodes = [];
2700
+ }
2701
+ toResult(opts = {}) {
2702
+ return new LazyResult(new Processor(), this, opts).stringify();
2703
+ }
2704
+ }
2705
+ Document.registerLazyResult = (dependant) => {
2706
+ LazyResult = dependant;
2707
+ };
2708
+ Document.registerProcessor = (dependant) => {
2709
+ Processor = dependant;
2710
+ };
2711
+ document$1 = Document;
2712
+ Document.default = Document;
2713
+ return document$1;
2714
+ }
2715
+ var warnOnce;
2716
+ var hasRequiredWarnOnce;
2717
+ function requireWarnOnce() {
2718
+ if (hasRequiredWarnOnce) return warnOnce;
2719
+ hasRequiredWarnOnce = 1;
2720
+ let printed = {};
2721
+ warnOnce = function warnOnce2(message) {
2722
+ if (printed[message]) return;
2723
+ printed[message] = true;
2724
+ if (typeof console !== "undefined" && console.warn) console.warn(message);
2725
+ };
2726
+ return warnOnce;
2727
+ }
2728
+ var warning;
2729
+ var hasRequiredWarning;
2730
+ function requireWarning() {
2731
+ if (hasRequiredWarning) return warning;
2732
+ hasRequiredWarning = 1;
2733
+ class Warning {
2734
+ constructor(text, opts = {}) {
2735
+ this.type = "warning";
2736
+ this.text = text;
2737
+ if (opts.node && opts.node.source) {
2738
+ let range = opts.node.rangeBy(opts);
2739
+ this.line = range.start.line;
2740
+ this.column = range.start.column;
2741
+ this.endLine = range.end.line;
2742
+ this.endColumn = range.end.column;
2743
+ }
2744
+ for (let opt in opts) this[opt] = opts[opt];
2745
+ }
2746
+ toString() {
2747
+ if (this.node) return this.node.error(this.text, {
2748
+ index: this.index,
2749
+ plugin: this.plugin,
2750
+ word: this.word
2751
+ }).message;
2752
+ if (this.plugin) return this.plugin + ": " + this.text;
2753
+ return this.text;
2754
+ }
2755
+ }
2756
+ warning = Warning;
2757
+ Warning.default = Warning;
2758
+ return warning;
2759
+ }
2760
+ var result;
2761
+ var hasRequiredResult;
2762
+ function requireResult() {
2763
+ if (hasRequiredResult) return result;
2764
+ hasRequiredResult = 1;
2765
+ let Warning = requireWarning();
2766
+ class Result {
2767
+ constructor(processor2, root2, opts) {
2768
+ this.processor = processor2;
2769
+ this.messages = [];
2770
+ this.root = root2;
2771
+ this.opts = opts;
2772
+ this.css = void 0;
2773
+ this.map = void 0;
2774
+ }
2775
+ toString() {
2776
+ return this.css;
2777
+ }
2778
+ warn(text, opts = {}) {
2779
+ if (!opts.plugin) {
2780
+ if (this.lastPlugin && this.lastPlugin.postcssPlugin) opts.plugin = this.lastPlugin.postcssPlugin;
2781
+ }
2782
+ let warning2 = new Warning(text, opts);
2783
+ this.messages.push(warning2);
2784
+ return warning2;
2785
+ }
2786
+ warnings() {
2787
+ return this.messages.filter((i) => i.type === "warning");
2788
+ }
2789
+ get content() {
2790
+ return this.css;
2791
+ }
2792
+ }
2793
+ result = Result;
2794
+ Result.default = Result;
2795
+ return result;
2796
+ }
2797
+ var tokenize;
2798
+ var hasRequiredTokenize;
2799
+ function requireTokenize() {
2800
+ if (hasRequiredTokenize) return tokenize;
2801
+ hasRequiredTokenize = 1;
2802
+ const SINGLE_QUOTE = "'".charCodeAt(0);
2803
+ const DOUBLE_QUOTE = "\"".charCodeAt(0);
2804
+ const BACKSLASH = "\\".charCodeAt(0);
2805
+ const SLASH = "/".charCodeAt(0);
2806
+ const NEWLINE = "\n".charCodeAt(0);
2807
+ const SPACE = " ".charCodeAt(0);
2808
+ const FEED = "\f".charCodeAt(0);
2809
+ const TAB = " ".charCodeAt(0);
2810
+ const CR = "\r".charCodeAt(0);
2811
+ const OPEN_SQUARE = "[".charCodeAt(0);
2812
+ const CLOSE_SQUARE = "]".charCodeAt(0);
2813
+ const OPEN_PARENTHESES = "(".charCodeAt(0);
2814
+ const CLOSE_PARENTHESES = ")".charCodeAt(0);
2815
+ const OPEN_CURLY = "{".charCodeAt(0);
2816
+ const CLOSE_CURLY = "}".charCodeAt(0);
2817
+ const SEMICOLON = ";".charCodeAt(0);
2818
+ const ASTERISK = "*".charCodeAt(0);
2819
+ const COLON = ":".charCodeAt(0);
2820
+ const AT = "@".charCodeAt(0);
2821
+ const RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
2822
+ const RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
2823
+ const RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
2824
+ const RE_HEX_ESCAPE = /[\da-f]/i;
2825
+ tokenize = function tokenizer(input2, options = {}) {
2826
+ let css = input2.css.valueOf();
2827
+ let ignore = options.ignoreErrors;
2828
+ let code, next, quote, content, escape;
2829
+ let escaped, escapePos, prev, n, currentToken;
2830
+ let length = css.length;
2831
+ let pos = 0;
2832
+ let buffer = [];
2833
+ let returned = [];
2834
+ function position() {
2835
+ return pos;
2836
+ }
2837
+ function unclosed(what) {
2838
+ throw input2.error("Unclosed " + what, pos);
2839
+ }
2840
+ function endOfFile() {
2841
+ return returned.length === 0 && pos >= length;
2842
+ }
2843
+ function nextToken(opts) {
2844
+ if (returned.length) return returned.pop();
2845
+ if (pos >= length) return;
2846
+ let ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
2847
+ code = css.charCodeAt(pos);
2848
+ switch (code) {
2849
+ case NEWLINE:
2850
+ case SPACE:
2851
+ case TAB:
2852
+ case CR:
2853
+ case FEED:
2854
+ next = pos;
2855
+ do {
2856
+ next += 1;
2857
+ code = css.charCodeAt(next);
2858
+ } while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
2859
+ currentToken = ["space", css.slice(pos, next)];
2860
+ pos = next - 1;
2861
+ break;
2862
+ case OPEN_SQUARE:
2863
+ case CLOSE_SQUARE:
2864
+ case OPEN_CURLY:
2865
+ case CLOSE_CURLY:
2866
+ case COLON:
2867
+ case SEMICOLON:
2868
+ case CLOSE_PARENTHESES: {
2869
+ let controlChar = String.fromCharCode(code);
2870
+ currentToken = [
2871
+ controlChar,
2872
+ controlChar,
2873
+ pos
2874
+ ];
2875
+ break;
2876
+ }
2877
+ case OPEN_PARENTHESES:
2878
+ prev = buffer.length ? buffer.pop()[1] : "";
2879
+ n = css.charCodeAt(pos + 1);
2880
+ if (prev === "url" && n !== SINGLE_QUOTE && n !== DOUBLE_QUOTE && n !== SPACE && n !== NEWLINE && n !== TAB && n !== FEED && n !== CR) {
2881
+ next = pos;
2882
+ do {
2883
+ escaped = false;
2884
+ next = css.indexOf(")", next + 1);
2885
+ if (next === -1) if (ignore || ignoreUnclosed) {
2886
+ next = pos;
2887
+ break;
2888
+ } else unclosed("bracket");
2889
+ escapePos = next;
2890
+ while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
2891
+ escapePos -= 1;
2892
+ escaped = !escaped;
2893
+ }
2894
+ } while (escaped);
2895
+ currentToken = [
2896
+ "brackets",
2897
+ css.slice(pos, next + 1),
2898
+ pos,
2899
+ next
2900
+ ];
2901
+ pos = next;
2902
+ } else {
2903
+ next = css.indexOf(")", pos + 1);
2904
+ content = css.slice(pos, next + 1);
2905
+ if (next === -1 || RE_BAD_BRACKET.test(content)) currentToken = [
2906
+ "(",
2907
+ "(",
2908
+ pos
2909
+ ];
2910
+ else {
2911
+ currentToken = [
2912
+ "brackets",
2913
+ content,
2914
+ pos,
2915
+ next
2916
+ ];
2917
+ pos = next;
2918
+ }
2919
+ }
2920
+ break;
2921
+ case SINGLE_QUOTE:
2922
+ case DOUBLE_QUOTE:
2923
+ quote = code === SINGLE_QUOTE ? "'" : "\"";
2924
+ next = pos;
2925
+ do {
2926
+ escaped = false;
2927
+ next = css.indexOf(quote, next + 1);
2928
+ if (next === -1) if (ignore || ignoreUnclosed) {
2929
+ next = pos + 1;
2930
+ break;
2931
+ } else unclosed("string");
2932
+ escapePos = next;
2933
+ while (css.charCodeAt(escapePos - 1) === BACKSLASH) {
2934
+ escapePos -= 1;
2935
+ escaped = !escaped;
2936
+ }
2937
+ } while (escaped);
2938
+ currentToken = [
2939
+ "string",
2940
+ css.slice(pos, next + 1),
2941
+ pos,
2942
+ next
2943
+ ];
2944
+ pos = next;
2945
+ break;
2946
+ case AT:
2947
+ RE_AT_END.lastIndex = pos + 1;
2948
+ RE_AT_END.test(css);
2949
+ if (RE_AT_END.lastIndex === 0) next = css.length - 1;
2950
+ else next = RE_AT_END.lastIndex - 2;
2951
+ currentToken = [
2952
+ "at-word",
2953
+ css.slice(pos, next + 1),
2954
+ pos,
2955
+ next
2956
+ ];
2957
+ pos = next;
2958
+ break;
2959
+ case BACKSLASH:
2960
+ next = pos;
2961
+ escape = true;
2962
+ while (css.charCodeAt(next + 1) === BACKSLASH) {
2963
+ next += 1;
2964
+ escape = !escape;
2965
+ }
2966
+ code = css.charCodeAt(next + 1);
2967
+ if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
2968
+ next += 1;
2969
+ if (RE_HEX_ESCAPE.test(css.charAt(next))) {
2970
+ while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) next += 1;
2971
+ if (css.charCodeAt(next + 1) === SPACE) next += 1;
2972
+ }
2973
+ }
2974
+ currentToken = [
2975
+ "word",
2976
+ css.slice(pos, next + 1),
2977
+ pos,
2978
+ next
2979
+ ];
2980
+ pos = next;
2981
+ break;
2982
+ default:
2983
+ if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
2984
+ next = css.indexOf("*/", pos + 2) + 1;
2985
+ if (next === 0) if (ignore || ignoreUnclosed) next = css.length;
2986
+ else unclosed("comment");
2987
+ currentToken = [
2988
+ "comment",
2989
+ css.slice(pos, next + 1),
2990
+ pos,
2991
+ next
2992
+ ];
2993
+ pos = next;
2994
+ } else {
2995
+ RE_WORD_END.lastIndex = pos + 1;
2996
+ RE_WORD_END.test(css);
2997
+ if (RE_WORD_END.lastIndex === 0) next = css.length - 1;
2998
+ else next = RE_WORD_END.lastIndex - 2;
2999
+ currentToken = [
3000
+ "word",
3001
+ css.slice(pos, next + 1),
3002
+ pos,
3003
+ next
3004
+ ];
3005
+ buffer.push(currentToken);
3006
+ pos = next;
3007
+ }
3008
+ break;
3009
+ }
3010
+ pos++;
3011
+ return currentToken;
3012
+ }
3013
+ function back(token) {
3014
+ returned.push(token);
3015
+ }
3016
+ return {
3017
+ back,
3018
+ endOfFile,
3019
+ nextToken,
3020
+ position
3021
+ };
3022
+ };
3023
+ return tokenize;
3024
+ }
3025
+ var atRule;
3026
+ var hasRequiredAtRule;
3027
+ function requireAtRule() {
3028
+ if (hasRequiredAtRule) return atRule;
3029
+ hasRequiredAtRule = 1;
3030
+ let Container = requireContainer();
3031
+ class AtRule extends Container {
3032
+ constructor(defaults) {
3033
+ super(defaults);
3034
+ this.type = "atrule";
3035
+ }
3036
+ append(...children) {
3037
+ if (!this.proxyOf.nodes) this.nodes = [];
3038
+ return super.append(...children);
3039
+ }
3040
+ prepend(...children) {
3041
+ if (!this.proxyOf.nodes) this.nodes = [];
3042
+ return super.prepend(...children);
3043
+ }
3044
+ }
3045
+ atRule = AtRule;
3046
+ AtRule.default = AtRule;
3047
+ Container.registerAtRule(AtRule);
3048
+ return atRule;
3049
+ }
3050
+ var root;
3051
+ var hasRequiredRoot;
3052
+ function requireRoot() {
3053
+ if (hasRequiredRoot) return root;
3054
+ hasRequiredRoot = 1;
3055
+ let Container = requireContainer();
3056
+ let LazyResult, Processor;
3057
+ class Root extends Container {
3058
+ constructor(defaults) {
3059
+ super(defaults);
3060
+ this.type = "root";
3061
+ if (!this.nodes) this.nodes = [];
3062
+ }
3063
+ normalize(child, sample, type) {
3064
+ let nodes = super.normalize(child);
3065
+ if (sample) {
3066
+ if (type === "prepend") if (this.nodes.length > 1) sample.raws.before = this.nodes[1].raws.before;
3067
+ else delete sample.raws.before;
3068
+ else if (this.first !== sample) for (let node2 of nodes) node2.raws.before = sample.raws.before;
3069
+ }
3070
+ return nodes;
3071
+ }
3072
+ removeChild(child, ignore) {
3073
+ let index2 = this.index(child);
3074
+ if (!ignore && index2 === 0 && this.nodes.length > 1) this.nodes[1].raws.before = this.nodes[index2].raws.before;
3075
+ return super.removeChild(child);
3076
+ }
3077
+ toResult(opts = {}) {
3078
+ return new LazyResult(new Processor(), this, opts).stringify();
3079
+ }
3080
+ }
3081
+ Root.registerLazyResult = (dependant) => {
3082
+ LazyResult = dependant;
3083
+ };
3084
+ Root.registerProcessor = (dependant) => {
3085
+ Processor = dependant;
3086
+ };
3087
+ root = Root;
3088
+ Root.default = Root;
3089
+ Container.registerRoot(Root);
3090
+ return root;
3091
+ }
3092
+ var list_1;
3093
+ var hasRequiredList;
3094
+ function requireList() {
3095
+ if (hasRequiredList) return list_1;
3096
+ hasRequiredList = 1;
3097
+ let list = {
3098
+ comma(string) {
3099
+ return list.split(string, [","], true);
3100
+ },
3101
+ space(string) {
3102
+ return list.split(string, [
3103
+ " ",
3104
+ "\n",
3105
+ " "
3106
+ ]);
3107
+ },
3108
+ split(string, separators, last) {
3109
+ let array = [];
3110
+ let current = "";
3111
+ let split = false;
3112
+ let func = 0;
3113
+ let inQuote = false;
3114
+ let prevQuote = "";
3115
+ let escape = false;
3116
+ for (let letter of string) {
3117
+ if (escape) escape = false;
3118
+ else if (letter === "\\") escape = true;
3119
+ else if (inQuote) {
3120
+ if (letter === prevQuote) inQuote = false;
3121
+ } else if (letter === "\"" || letter === "'") {
3122
+ inQuote = true;
3123
+ prevQuote = letter;
3124
+ } else if (letter === "(") func += 1;
3125
+ else if (letter === ")") {
3126
+ if (func > 0) func -= 1;
3127
+ } else if (func === 0) {
3128
+ if (separators.includes(letter)) split = true;
3129
+ }
3130
+ if (split) {
3131
+ if (current !== "") array.push(current.trim());
3132
+ current = "";
3133
+ split = false;
3134
+ } else current += letter;
3135
+ }
3136
+ if (last || current !== "") array.push(current.trim());
3137
+ return array;
3138
+ }
3139
+ };
3140
+ list_1 = list;
3141
+ list.default = list;
3142
+ return list_1;
3143
+ }
3144
+ var rule;
3145
+ var hasRequiredRule;
3146
+ function requireRule() {
3147
+ if (hasRequiredRule) return rule;
3148
+ hasRequiredRule = 1;
3149
+ let Container = requireContainer();
3150
+ let list = requireList();
3151
+ class Rule extends Container {
3152
+ constructor(defaults) {
3153
+ super(defaults);
3154
+ this.type = "rule";
3155
+ if (!this.nodes) this.nodes = [];
3156
+ }
3157
+ get selectors() {
3158
+ return list.comma(this.selector);
3159
+ }
3160
+ set selectors(values) {
3161
+ let match = this.selector ? this.selector.match(/,\s*/) : null;
3162
+ let sep = match ? match[0] : "," + this.raw("between", "beforeOpen");
3163
+ this.selector = values.join(sep);
3164
+ }
3165
+ }
3166
+ rule = Rule;
3167
+ Rule.default = Rule;
3168
+ Container.registerRule(Rule);
3169
+ return rule;
3170
+ }
3171
+ var parser;
3172
+ var hasRequiredParser;
3173
+ function requireParser() {
3174
+ if (hasRequiredParser) return parser;
3175
+ hasRequiredParser = 1;
3176
+ let Declaration = requireDeclaration();
3177
+ let tokenizer = requireTokenize();
3178
+ let Comment = requireComment();
3179
+ let AtRule = requireAtRule();
3180
+ let Root = requireRoot();
3181
+ let Rule = requireRule();
3182
+ const SAFE_COMMENT_NEIGHBOR = {
3183
+ empty: true,
3184
+ space: true
3185
+ };
3186
+ function findLastWithPosition(tokens) {
3187
+ for (let i = tokens.length - 1; i >= 0; i--) {
3188
+ let token = tokens[i];
3189
+ let pos = token[3] || token[2];
3190
+ if (pos) return pos;
3191
+ }
3192
+ }
3193
+ class Parser {
3194
+ constructor(input2) {
3195
+ this.input = input2;
3196
+ this.root = new Root();
3197
+ this.current = this.root;
3198
+ this.spaces = "";
3199
+ this.semicolon = false;
3200
+ this.createTokenizer();
3201
+ this.root.source = {
3202
+ input: input2,
3203
+ start: {
3204
+ column: 1,
3205
+ line: 1,
3206
+ offset: 0
3207
+ }
3208
+ };
3209
+ }
3210
+ atrule(token) {
3211
+ let node2 = new AtRule();
3212
+ node2.name = token[1].slice(1);
3213
+ if (node2.name === "") this.unnamedAtrule(node2, token);
3214
+ this.init(node2, token[2]);
3215
+ let type;
3216
+ let prev;
3217
+ let shift;
3218
+ let last = false;
3219
+ let open = false;
3220
+ let params = [];
3221
+ let brackets = [];
3222
+ while (!this.tokenizer.endOfFile()) {
3223
+ token = this.tokenizer.nextToken();
3224
+ type = token[0];
3225
+ if (type === "(" || type === "[") brackets.push(type === "(" ? ")" : "]");
3226
+ else if (type === "{" && brackets.length > 0) brackets.push("}");
3227
+ else if (type === brackets[brackets.length - 1]) brackets.pop();
3228
+ if (brackets.length === 0) if (type === ";") {
3229
+ node2.source.end = this.getPosition(token[2]);
3230
+ node2.source.end.offset++;
3231
+ this.semicolon = true;
3232
+ break;
3233
+ } else if (type === "{") {
3234
+ open = true;
3235
+ break;
3236
+ } else if (type === "}") {
3237
+ if (params.length > 0) {
3238
+ shift = params.length - 1;
3239
+ prev = params[shift];
3240
+ while (prev && prev[0] === "space") prev = params[--shift];
3241
+ if (prev) {
3242
+ node2.source.end = this.getPosition(prev[3] || prev[2]);
3243
+ node2.source.end.offset++;
3244
+ }
3245
+ }
3246
+ this.end(token);
3247
+ break;
3248
+ } else params.push(token);
3249
+ else params.push(token);
3250
+ if (this.tokenizer.endOfFile()) {
3251
+ last = true;
3252
+ break;
3253
+ }
3254
+ }
3255
+ node2.raws.between = this.spacesAndCommentsFromEnd(params);
3256
+ if (params.length) {
3257
+ node2.raws.afterName = this.spacesAndCommentsFromStart(params);
3258
+ this.raw(node2, "params", params);
3259
+ if (last) {
3260
+ token = params[params.length - 1];
3261
+ node2.source.end = this.getPosition(token[3] || token[2]);
3262
+ node2.source.end.offset++;
3263
+ this.spaces = node2.raws.between;
3264
+ node2.raws.between = "";
3265
+ }
3266
+ } else {
3267
+ node2.raws.afterName = "";
3268
+ node2.params = "";
3269
+ }
3270
+ if (open) {
3271
+ node2.nodes = [];
3272
+ this.current = node2;
3273
+ }
3274
+ }
3275
+ checkMissedSemicolon(tokens) {
3276
+ let colon = this.colon(tokens);
3277
+ if (colon === false) return;
3278
+ let founded = 0;
3279
+ let token;
3280
+ for (let j = colon - 1; j >= 0; j--) {
3281
+ token = tokens[j];
3282
+ if (token[0] !== "space") {
3283
+ founded += 1;
3284
+ if (founded === 2) break;
3285
+ }
3286
+ }
3287
+ throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
3288
+ }
3289
+ colon(tokens) {
3290
+ let brackets = 0;
3291
+ let token, type, prev;
3292
+ for (let [i, element] of tokens.entries()) {
3293
+ token = element;
3294
+ type = token[0];
3295
+ if (type === "(") brackets += 1;
3296
+ if (type === ")") brackets -= 1;
3297
+ if (brackets === 0 && type === ":") if (!prev) this.doubleColon(token);
3298
+ else if (prev[0] === "word" && prev[1] === "progid") continue;
3299
+ else return i;
3300
+ prev = token;
3301
+ }
3302
+ return false;
3303
+ }
3304
+ comment(token) {
3305
+ let node2 = new Comment();
3306
+ this.init(node2, token[2]);
3307
+ node2.source.end = this.getPosition(token[3] || token[2]);
3308
+ node2.source.end.offset++;
3309
+ let text = token[1].slice(2, -2);
3310
+ if (/^\s*$/.test(text)) {
3311
+ node2.text = "";
3312
+ node2.raws.left = text;
3313
+ node2.raws.right = "";
3314
+ } else {
3315
+ let match = text.match(/^(\s*)([^]*\S)(\s*)$/);
3316
+ node2.text = match[2];
3317
+ node2.raws.left = match[1];
3318
+ node2.raws.right = match[3];
3319
+ }
3320
+ }
3321
+ createTokenizer() {
3322
+ this.tokenizer = tokenizer(this.input);
3323
+ }
3324
+ decl(tokens, customProperty) {
3325
+ let node2 = new Declaration();
3326
+ this.init(node2, tokens[0][2]);
3327
+ let last = tokens[tokens.length - 1];
3328
+ if (last[0] === ";") {
3329
+ this.semicolon = true;
3330
+ tokens.pop();
3331
+ }
3332
+ node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition(tokens));
3333
+ node2.source.end.offset++;
3334
+ while (tokens[0][0] !== "word") {
3335
+ if (tokens.length === 1) this.unknownWord(tokens);
3336
+ node2.raws.before += tokens.shift()[1];
3337
+ }
3338
+ node2.source.start = this.getPosition(tokens[0][2]);
3339
+ node2.prop = "";
3340
+ while (tokens.length) {
3341
+ let type = tokens[0][0];
3342
+ if (type === ":" || type === "space" || type === "comment") break;
3343
+ node2.prop += tokens.shift()[1];
3344
+ }
3345
+ node2.raws.between = "";
3346
+ let token;
3347
+ while (tokens.length) {
3348
+ token = tokens.shift();
3349
+ if (token[0] === ":") {
3350
+ node2.raws.between += token[1];
3351
+ break;
3352
+ } else {
3353
+ if (token[0] === "word" && /\w/.test(token[1])) this.unknownWord([token]);
3354
+ node2.raws.between += token[1];
3355
+ }
3356
+ }
3357
+ if (node2.prop[0] === "_" || node2.prop[0] === "*") {
3358
+ node2.raws.before += node2.prop[0];
3359
+ node2.prop = node2.prop.slice(1);
3360
+ }
3361
+ let firstSpaces = [];
3362
+ let next;
3363
+ while (tokens.length) {
3364
+ next = tokens[0][0];
3365
+ if (next !== "space" && next !== "comment") break;
3366
+ firstSpaces.push(tokens.shift());
3367
+ }
3368
+ this.precheckMissedSemicolon(tokens);
3369
+ for (let i = tokens.length - 1; i >= 0; i--) {
3370
+ token = tokens[i];
3371
+ if (token[1].toLowerCase() === "!important") {
3372
+ node2.important = true;
3373
+ let string = this.stringFrom(tokens, i);
3374
+ string = this.spacesFromEnd(tokens) + string;
3375
+ if (string !== " !important") node2.raws.important = string;
3376
+ break;
3377
+ } else if (token[1].toLowerCase() === "important") {
3378
+ let cache = tokens.slice(0);
3379
+ let str = "";
3380
+ for (let j = i; j > 0; j--) {
3381
+ let type = cache[j][0];
3382
+ if (str.trim().indexOf("!") === 0 && type !== "space") break;
3383
+ str = cache.pop()[1] + str;
3384
+ }
3385
+ if (str.trim().indexOf("!") === 0) {
3386
+ node2.important = true;
3387
+ node2.raws.important = str;
3388
+ tokens = cache;
3389
+ }
3390
+ }
3391
+ if (token[0] !== "space" && token[0] !== "comment") break;
3392
+ }
3393
+ if (tokens.some((i) => i[0] !== "space" && i[0] !== "comment")) {
3394
+ node2.raws.between += firstSpaces.map((i) => i[1]).join("");
3395
+ firstSpaces = [];
3396
+ }
3397
+ this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
3398
+ if (node2.value.includes(":") && !customProperty) this.checkMissedSemicolon(tokens);
3399
+ }
3400
+ doubleColon(token) {
3401
+ throw this.input.error("Double colon", { offset: token[2] }, { offset: token[2] + token[1].length });
3402
+ }
3403
+ emptyRule(token) {
3404
+ let node2 = new Rule();
3405
+ this.init(node2, token[2]);
3406
+ node2.selector = "";
3407
+ node2.raws.between = "";
3408
+ this.current = node2;
3409
+ }
3410
+ end(token) {
3411
+ if (this.current.nodes && this.current.nodes.length) this.current.raws.semicolon = this.semicolon;
3412
+ this.semicolon = false;
3413
+ this.current.raws.after = (this.current.raws.after || "") + this.spaces;
3414
+ this.spaces = "";
3415
+ if (this.current.parent) {
3416
+ this.current.source.end = this.getPosition(token[2]);
3417
+ this.current.source.end.offset++;
3418
+ this.current = this.current.parent;
3419
+ } else this.unexpectedClose(token);
3420
+ }
3421
+ endFile() {
3422
+ if (this.current.parent) this.unclosedBlock();
3423
+ if (this.current.nodes && this.current.nodes.length) this.current.raws.semicolon = this.semicolon;
3424
+ this.current.raws.after = (this.current.raws.after || "") + this.spaces;
3425
+ this.root.source.end = this.getPosition(this.tokenizer.position());
3426
+ }
3427
+ freeSemicolon(token) {
3428
+ this.spaces += token[1];
3429
+ if (this.current.nodes) {
3430
+ let prev = this.current.nodes[this.current.nodes.length - 1];
3431
+ if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
3432
+ prev.raws.ownSemicolon = this.spaces;
3433
+ this.spaces = "";
3434
+ }
3435
+ }
3436
+ }
3437
+ getPosition(offset) {
3438
+ let pos = this.input.fromOffset(offset);
3439
+ return {
3440
+ column: pos.col,
3441
+ line: pos.line,
3442
+ offset
3443
+ };
3444
+ }
3445
+ init(node2, offset) {
3446
+ this.current.push(node2);
3447
+ node2.source = {
3448
+ input: this.input,
3449
+ start: this.getPosition(offset)
3450
+ };
3451
+ node2.raws.before = this.spaces;
3452
+ this.spaces = "";
3453
+ if (node2.type !== "comment") this.semicolon = false;
3454
+ }
3455
+ other(start) {
3456
+ let end = false;
3457
+ let type = null;
3458
+ let colon = false;
3459
+ let bracket = null;
3460
+ let brackets = [];
3461
+ let customProperty = start[1].startsWith("--");
3462
+ let tokens = [];
3463
+ let token = start;
3464
+ while (token) {
3465
+ type = token[0];
3466
+ tokens.push(token);
3467
+ if (type === "(" || type === "[") {
3468
+ if (!bracket) bracket = token;
3469
+ brackets.push(type === "(" ? ")" : "]");
3470
+ } else if (customProperty && colon && type === "{") {
3471
+ if (!bracket) bracket = token;
3472
+ brackets.push("}");
3473
+ } else if (brackets.length === 0) {
3474
+ if (type === ";") if (colon) {
3475
+ this.decl(tokens, customProperty);
3476
+ return;
3477
+ } else break;
3478
+ else if (type === "{") {
3479
+ this.rule(tokens);
3480
+ return;
3481
+ } else if (type === "}") {
3482
+ this.tokenizer.back(tokens.pop());
3483
+ end = true;
3484
+ break;
3485
+ } else if (type === ":") colon = true;
3486
+ } else if (type === brackets[brackets.length - 1]) {
3487
+ brackets.pop();
3488
+ if (brackets.length === 0) bracket = null;
3489
+ }
3490
+ token = this.tokenizer.nextToken();
3491
+ }
3492
+ if (this.tokenizer.endOfFile()) end = true;
3493
+ if (brackets.length > 0) this.unclosedBracket(bracket);
3494
+ if (end && colon) {
3495
+ if (!customProperty) while (tokens.length) {
3496
+ token = tokens[tokens.length - 1][0];
3497
+ if (token !== "space" && token !== "comment") break;
3498
+ this.tokenizer.back(tokens.pop());
3499
+ }
3500
+ this.decl(tokens, customProperty);
3501
+ } else this.unknownWord(tokens);
3502
+ }
3503
+ parse() {
3504
+ let token;
3505
+ while (!this.tokenizer.endOfFile()) {
3506
+ token = this.tokenizer.nextToken();
3507
+ switch (token[0]) {
3508
+ case "space":
3509
+ this.spaces += token[1];
3510
+ break;
3511
+ case ";":
3512
+ this.freeSemicolon(token);
3513
+ break;
3514
+ case "}":
3515
+ this.end(token);
3516
+ break;
3517
+ case "comment":
3518
+ this.comment(token);
3519
+ break;
3520
+ case "at-word":
3521
+ this.atrule(token);
3522
+ break;
3523
+ case "{":
3524
+ this.emptyRule(token);
3525
+ break;
3526
+ default:
3527
+ this.other(token);
3528
+ break;
3529
+ }
3530
+ }
3531
+ this.endFile();
3532
+ }
3533
+ precheckMissedSemicolon() {}
3534
+ raw(node2, prop, tokens, customProperty) {
3535
+ let token, type;
3536
+ let length = tokens.length;
3537
+ let value = "";
3538
+ let clean = true;
3539
+ let next, prev;
3540
+ for (let i = 0; i < length; i += 1) {
3541
+ token = tokens[i];
3542
+ type = token[0];
3543
+ if (type === "space" && i === length - 1 && !customProperty) clean = false;
3544
+ else if (type === "comment") {
3545
+ prev = tokens[i - 1] ? tokens[i - 1][0] : "empty";
3546
+ next = tokens[i + 1] ? tokens[i + 1][0] : "empty";
3547
+ if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) if (value.slice(-1) === ",") clean = false;
3548
+ else value += token[1];
3549
+ else clean = false;
3550
+ } else value += token[1];
3551
+ }
3552
+ if (!clean) {
3553
+ let raw = tokens.reduce((all, i) => all + i[1], "");
3554
+ node2.raws[prop] = {
3555
+ raw,
3556
+ value
3557
+ };
3558
+ }
3559
+ node2[prop] = value;
3560
+ }
3561
+ rule(tokens) {
3562
+ tokens.pop();
3563
+ let node2 = new Rule();
3564
+ this.init(node2, tokens[0][2]);
3565
+ node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
3566
+ this.raw(node2, "selector", tokens);
3567
+ this.current = node2;
3568
+ }
3569
+ spacesAndCommentsFromEnd(tokens) {
3570
+ let lastTokenType;
3571
+ let spaces = "";
3572
+ while (tokens.length) {
3573
+ lastTokenType = tokens[tokens.length - 1][0];
3574
+ if (lastTokenType !== "space" && lastTokenType !== "comment") break;
3575
+ spaces = tokens.pop()[1] + spaces;
3576
+ }
3577
+ return spaces;
3578
+ }
3579
+ spacesAndCommentsFromStart(tokens) {
3580
+ let next;
3581
+ let spaces = "";
3582
+ while (tokens.length) {
3583
+ next = tokens[0][0];
3584
+ if (next !== "space" && next !== "comment") break;
3585
+ spaces += tokens.shift()[1];
3586
+ }
3587
+ return spaces;
3588
+ }
3589
+ spacesFromEnd(tokens) {
3590
+ let lastTokenType;
3591
+ let spaces = "";
3592
+ while (tokens.length) {
3593
+ lastTokenType = tokens[tokens.length - 1][0];
3594
+ if (lastTokenType !== "space") break;
3595
+ spaces = tokens.pop()[1] + spaces;
3596
+ }
3597
+ return spaces;
3598
+ }
3599
+ stringFrom(tokens, from) {
3600
+ let result2 = "";
3601
+ for (let i = from; i < tokens.length; i++) result2 += tokens[i][1];
3602
+ tokens.splice(from, tokens.length - from);
3603
+ return result2;
3604
+ }
3605
+ unclosedBlock() {
3606
+ let pos = this.current.source.start;
3607
+ throw this.input.error("Unclosed block", pos.line, pos.column);
3608
+ }
3609
+ unclosedBracket(bracket) {
3610
+ throw this.input.error("Unclosed bracket", { offset: bracket[2] }, { offset: bracket[2] + 1 });
3611
+ }
3612
+ unexpectedClose(token) {
3613
+ throw this.input.error("Unexpected }", { offset: token[2] }, { offset: token[2] + 1 });
3614
+ }
3615
+ unknownWord(tokens) {
3616
+ throw this.input.error("Unknown word", { offset: tokens[0][2] }, { offset: tokens[0][2] + tokens[0][1].length });
3617
+ }
3618
+ unnamedAtrule(node2, token) {
3619
+ throw this.input.error("At-rule without name", { offset: token[2] }, { offset: token[2] + token[1].length });
3620
+ }
3621
+ }
3622
+ parser = Parser;
3623
+ return parser;
3624
+ }
3625
+ var parse_1;
3626
+ var hasRequiredParse;
3627
+ function requireParse() {
3628
+ if (hasRequiredParse) return parse_1;
3629
+ hasRequiredParse = 1;
3630
+ let Container = requireContainer();
3631
+ let Parser = requireParser();
3632
+ let Input = requireInput();
3633
+ function parse(css, opts) {
3634
+ let parser2 = new Parser(new Input(css, opts));
3635
+ try {
3636
+ parser2.parse();
3637
+ } catch (e) {
3638
+ throw e;
3639
+ }
3640
+ return parser2.root;
3641
+ }
3642
+ parse_1 = parse;
3643
+ parse.default = parse;
3644
+ Container.registerParse(parse);
3645
+ return parse_1;
3646
+ }
3647
+ var lazyResult;
3648
+ var hasRequiredLazyResult;
3649
+ function requireLazyResult() {
3650
+ if (hasRequiredLazyResult) return lazyResult;
3651
+ hasRequiredLazyResult = 1;
3652
+ let { isClean, my } = requireSymbols();
3653
+ let MapGenerator = requireMapGenerator();
3654
+ let stringify = requireStringify();
3655
+ let Container = requireContainer();
3656
+ let Document = requireDocument();
3657
+ requireWarnOnce();
3658
+ let Result = requireResult();
3659
+ let parse = requireParse();
3660
+ let Root = requireRoot();
3661
+ const TYPE_TO_CLASS_NAME = {
3662
+ atrule: "AtRule",
3663
+ comment: "Comment",
3664
+ decl: "Declaration",
3665
+ document: "Document",
3666
+ root: "Root",
3667
+ rule: "Rule"
3668
+ };
3669
+ const PLUGIN_PROPS = {
3670
+ AtRule: true,
3671
+ AtRuleExit: true,
3672
+ Comment: true,
3673
+ CommentExit: true,
3674
+ Declaration: true,
3675
+ DeclarationExit: true,
3676
+ Document: true,
3677
+ DocumentExit: true,
3678
+ Once: true,
3679
+ OnceExit: true,
3680
+ postcssPlugin: true,
3681
+ prepare: true,
3682
+ Root: true,
3683
+ RootExit: true,
3684
+ Rule: true,
3685
+ RuleExit: true
3686
+ };
3687
+ const NOT_VISITORS = {
3688
+ Once: true,
3689
+ postcssPlugin: true,
3690
+ prepare: true
3691
+ };
3692
+ const CHILDREN = 0;
3693
+ function isPromise(obj) {
3694
+ return typeof obj === "object" && typeof obj.then === "function";
3695
+ }
3696
+ function getEvents(node2) {
3697
+ let key = false;
3698
+ let type = TYPE_TO_CLASS_NAME[node2.type];
3699
+ if (node2.type === "decl") key = node2.prop.toLowerCase();
3700
+ else if (node2.type === "atrule") key = node2.name.toLowerCase();
3701
+ if (key && node2.append) return [
3702
+ type,
3703
+ type + "-" + key,
3704
+ CHILDREN,
3705
+ type + "Exit",
3706
+ type + "Exit-" + key
3707
+ ];
3708
+ else if (key) return [
3709
+ type,
3710
+ type + "-" + key,
3711
+ type + "Exit",
3712
+ type + "Exit-" + key
3713
+ ];
3714
+ else if (node2.append) return [
3715
+ type,
3716
+ CHILDREN,
3717
+ type + "Exit"
3718
+ ];
3719
+ else return [type, type + "Exit"];
3720
+ }
3721
+ function toStack(node2) {
3722
+ let events;
3723
+ if (node2.type === "document") events = [
3724
+ "Document",
3725
+ CHILDREN,
3726
+ "DocumentExit"
3727
+ ];
3728
+ else if (node2.type === "root") events = [
3729
+ "Root",
3730
+ CHILDREN,
3731
+ "RootExit"
3732
+ ];
3733
+ else events = getEvents(node2);
3734
+ return {
3735
+ eventIndex: 0,
3736
+ events,
3737
+ iterator: 0,
3738
+ node: node2,
3739
+ visitorIndex: 0,
3740
+ visitors: []
3741
+ };
3742
+ }
3743
+ function cleanMarks(node2) {
3744
+ node2[isClean] = false;
3745
+ if (node2.nodes) node2.nodes.forEach((i) => cleanMarks(i));
3746
+ return node2;
3747
+ }
3748
+ let postcss2 = {};
3749
+ class LazyResult {
3750
+ constructor(processor2, css, opts) {
3751
+ this.stringified = false;
3752
+ this.processed = false;
3753
+ let root2;
3754
+ if (typeof css === "object" && css !== null && (css.type === "root" || css.type === "document")) root2 = cleanMarks(css);
3755
+ else if (css instanceof LazyResult || css instanceof Result) {
3756
+ root2 = cleanMarks(css.root);
3757
+ if (css.map) {
3758
+ if (typeof opts.map === "undefined") opts.map = {};
3759
+ if (!opts.map.inline) opts.map.inline = false;
3760
+ opts.map.prev = css.map;
3761
+ }
3762
+ } else {
3763
+ let parser2 = parse;
3764
+ if (opts.syntax) parser2 = opts.syntax.parse;
3765
+ if (opts.parser) parser2 = opts.parser;
3766
+ if (parser2.parse) parser2 = parser2.parse;
3767
+ try {
3768
+ root2 = parser2(css, opts);
3769
+ } catch (error) {
3770
+ this.processed = true;
3771
+ this.error = error;
3772
+ }
3773
+ if (root2 && !root2[my]) Container.rebuild(root2);
3774
+ }
3775
+ this.result = new Result(processor2, root2, opts);
3776
+ this.helpers = {
3777
+ ...postcss2,
3778
+ postcss: postcss2,
3779
+ result: this.result
3780
+ };
3781
+ this.plugins = this.processor.plugins.map((plugin) => {
3782
+ if (typeof plugin === "object" && plugin.prepare) return {
3783
+ ...plugin,
3784
+ ...plugin.prepare(this.result)
3785
+ };
3786
+ else return plugin;
3787
+ });
3788
+ }
3789
+ async() {
3790
+ if (this.error) return Promise.reject(this.error);
3791
+ if (this.processed) return Promise.resolve(this.result);
3792
+ if (!this.processing) this.processing = this.runAsync();
3793
+ return this.processing;
3794
+ }
3795
+ catch(onRejected) {
3796
+ return this.async().catch(onRejected);
3797
+ }
3798
+ finally(onFinally) {
3799
+ return this.async().then(onFinally, onFinally);
3800
+ }
3801
+ getAsyncError() {
3802
+ throw new Error("Use process(css).then(cb) to work with async plugins");
3803
+ }
3804
+ handleError(error, node2) {
3805
+ let plugin = this.result.lastPlugin;
3806
+ try {
3807
+ if (node2) node2.addToError(error);
3808
+ this.error = error;
3809
+ if (error.name === "CssSyntaxError" && !error.plugin) {
3810
+ error.plugin = plugin.postcssPlugin;
3811
+ error.setMessage();
3812
+ } else if (plugin.postcssVersion) {}
3813
+ } catch (err) {
3814
+ if (console && console.error) console.error(err);
3815
+ }
3816
+ return error;
3817
+ }
3818
+ prepareVisitors() {
3819
+ this.listeners = {};
3820
+ let add = (plugin, type, cb) => {
3821
+ if (!this.listeners[type]) this.listeners[type] = [];
3822
+ this.listeners[type].push([plugin, cb]);
3823
+ };
3824
+ for (let plugin of this.plugins) if (typeof plugin === "object") for (let event in plugin) {
3825
+ if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) throw new Error(`Unknown event ${event} in ${plugin.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);
3826
+ if (!NOT_VISITORS[event]) {
3827
+ if (typeof plugin[event] === "object") for (let filter in plugin[event]) if (filter === "*") add(plugin, event, plugin[event][filter]);
3828
+ else add(plugin, event + "-" + filter.toLowerCase(), plugin[event][filter]);
3829
+ else if (typeof plugin[event] === "function") add(plugin, event, plugin[event]);
3830
+ }
3831
+ }
3832
+ this.hasListener = Object.keys(this.listeners).length > 0;
3833
+ }
3834
+ async runAsync() {
3835
+ this.plugin = 0;
3836
+ for (let i = 0; i < this.plugins.length; i++) {
3837
+ let plugin = this.plugins[i];
3838
+ let promise = this.runOnRoot(plugin);
3839
+ if (isPromise(promise)) try {
3840
+ await promise;
3841
+ } catch (error) {
3842
+ throw this.handleError(error);
3843
+ }
3844
+ }
3845
+ this.prepareVisitors();
3846
+ if (this.hasListener) {
3847
+ let root2 = this.result.root;
3848
+ while (!root2[isClean]) {
3849
+ root2[isClean] = true;
3850
+ let stack = [toStack(root2)];
3851
+ while (stack.length > 0) {
3852
+ let promise = this.visitTick(stack);
3853
+ if (isPromise(promise)) try {
3854
+ await promise;
3855
+ } catch (e) {
3856
+ let node2 = stack[stack.length - 1].node;
3857
+ throw this.handleError(e, node2);
3858
+ }
3859
+ }
3860
+ }
3861
+ if (this.listeners.OnceExit) for (let [plugin, visitor] of this.listeners.OnceExit) {
3862
+ this.result.lastPlugin = plugin;
3863
+ try {
3864
+ if (root2.type === "document") {
3865
+ let roots = root2.nodes.map((subRoot) => visitor(subRoot, this.helpers));
3866
+ await Promise.all(roots);
3867
+ } else await visitor(root2, this.helpers);
3868
+ } catch (e) {
3869
+ throw this.handleError(e);
3870
+ }
3871
+ }
3872
+ }
3873
+ this.processed = true;
3874
+ return this.stringify();
3875
+ }
3876
+ runOnRoot(plugin) {
3877
+ this.result.lastPlugin = plugin;
3878
+ try {
3879
+ if (typeof plugin === "object" && plugin.Once) {
3880
+ if (this.result.root.type === "document") {
3881
+ let roots = this.result.root.nodes.map((root2) => plugin.Once(root2, this.helpers));
3882
+ if (isPromise(roots[0])) return Promise.all(roots);
3883
+ return roots;
3884
+ }
3885
+ return plugin.Once(this.result.root, this.helpers);
3886
+ } else if (typeof plugin === "function") return plugin(this.result.root, this.result);
3887
+ } catch (error) {
3888
+ throw this.handleError(error);
3889
+ }
3890
+ }
3891
+ stringify() {
3892
+ if (this.error) throw this.error;
3893
+ if (this.stringified) return this.result;
3894
+ this.stringified = true;
3895
+ this.sync();
3896
+ let opts = this.result.opts;
3897
+ let str = stringify;
3898
+ if (opts.syntax) str = opts.syntax.stringify;
3899
+ if (opts.stringifier) str = opts.stringifier;
3900
+ if (str.stringify) str = str.stringify;
3901
+ let data = new MapGenerator(str, this.result.root, this.result.opts).generate();
3902
+ this.result.css = data[0];
3903
+ this.result.map = data[1];
3904
+ return this.result;
3905
+ }
3906
+ sync() {
3907
+ if (this.error) throw this.error;
3908
+ if (this.processed) return this.result;
3909
+ this.processed = true;
3910
+ if (this.processing) throw this.getAsyncError();
3911
+ for (let plugin of this.plugins) if (isPromise(this.runOnRoot(plugin))) throw this.getAsyncError();
3912
+ this.prepareVisitors();
3913
+ if (this.hasListener) {
3914
+ let root2 = this.result.root;
3915
+ while (!root2[isClean]) {
3916
+ root2[isClean] = true;
3917
+ this.walkSync(root2);
3918
+ }
3919
+ if (this.listeners.OnceExit) if (root2.type === "document") for (let subRoot of root2.nodes) this.visitSync(this.listeners.OnceExit, subRoot);
3920
+ else this.visitSync(this.listeners.OnceExit, root2);
3921
+ }
3922
+ return this.result;
3923
+ }
3924
+ then(onFulfilled, onRejected) {
3925
+ return this.async().then(onFulfilled, onRejected);
3926
+ }
3927
+ toString() {
3928
+ return this.css;
3929
+ }
3930
+ visitSync(visitors, node2) {
3931
+ for (let [plugin, visitor] of visitors) {
3932
+ this.result.lastPlugin = plugin;
3933
+ let promise;
3934
+ try {
3935
+ promise = visitor(node2, this.helpers);
3936
+ } catch (e) {
3937
+ throw this.handleError(e, node2.proxyOf);
3938
+ }
3939
+ if (node2.type !== "root" && node2.type !== "document" && !node2.parent) return true;
3940
+ if (isPromise(promise)) throw this.getAsyncError();
3941
+ }
3942
+ }
3943
+ visitTick(stack) {
3944
+ let visit2 = stack[stack.length - 1];
3945
+ let { node: node2, visitors } = visit2;
3946
+ if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
3947
+ stack.pop();
3948
+ return;
3949
+ }
3950
+ if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
3951
+ let [plugin, visitor] = visitors[visit2.visitorIndex];
3952
+ visit2.visitorIndex += 1;
3953
+ if (visit2.visitorIndex === visitors.length) {
3954
+ visit2.visitors = [];
3955
+ visit2.visitorIndex = 0;
3956
+ }
3957
+ this.result.lastPlugin = plugin;
3958
+ try {
3959
+ return visitor(node2.toProxy(), this.helpers);
3960
+ } catch (e) {
3961
+ throw this.handleError(e, node2);
3962
+ }
3963
+ }
3964
+ if (visit2.iterator !== 0) {
3965
+ let iterator = visit2.iterator;
3966
+ let child;
3967
+ while (child = node2.nodes[node2.indexes[iterator]]) {
3968
+ node2.indexes[iterator] += 1;
3969
+ if (!child[isClean]) {
3970
+ child[isClean] = true;
3971
+ stack.push(toStack(child));
3972
+ return;
3973
+ }
3974
+ }
3975
+ visit2.iterator = 0;
3976
+ delete node2.indexes[iterator];
3977
+ }
3978
+ let events = visit2.events;
3979
+ while (visit2.eventIndex < events.length) {
3980
+ let event = events[visit2.eventIndex];
3981
+ visit2.eventIndex += 1;
3982
+ if (event === CHILDREN) {
3983
+ if (node2.nodes && node2.nodes.length) {
3984
+ node2[isClean] = true;
3985
+ visit2.iterator = node2.getIterator();
3986
+ }
3987
+ return;
3988
+ } else if (this.listeners[event]) {
3989
+ visit2.visitors = this.listeners[event];
3990
+ return;
3991
+ }
3992
+ }
3993
+ stack.pop();
3994
+ }
3995
+ walkSync(node2) {
3996
+ node2[isClean] = true;
3997
+ let events = getEvents(node2);
3998
+ for (let event of events) if (event === CHILDREN) {
3999
+ if (node2.nodes) node2.each((child) => {
4000
+ if (!child[isClean]) this.walkSync(child);
4001
+ });
4002
+ } else {
4003
+ let visitors = this.listeners[event];
4004
+ if (visitors) {
4005
+ if (this.visitSync(visitors, node2.toProxy())) return;
4006
+ }
4007
+ }
4008
+ }
4009
+ warnings() {
4010
+ return this.sync().warnings();
4011
+ }
4012
+ get content() {
4013
+ return this.stringify().content;
4014
+ }
4015
+ get css() {
4016
+ return this.stringify().css;
4017
+ }
4018
+ get map() {
4019
+ return this.stringify().map;
4020
+ }
4021
+ get messages() {
4022
+ return this.sync().messages;
4023
+ }
4024
+ get opts() {
4025
+ return this.result.opts;
4026
+ }
4027
+ get processor() {
4028
+ return this.result.processor;
4029
+ }
4030
+ get root() {
4031
+ return this.sync().root;
4032
+ }
4033
+ get [Symbol.toStringTag]() {
4034
+ return "LazyResult";
4035
+ }
4036
+ }
4037
+ LazyResult.registerPostcss = (dependant) => {
4038
+ postcss2 = dependant;
4039
+ };
4040
+ lazyResult = LazyResult;
4041
+ LazyResult.default = LazyResult;
4042
+ Root.registerLazyResult(LazyResult);
4043
+ Document.registerLazyResult(LazyResult);
4044
+ return lazyResult;
4045
+ }
4046
+ var noWorkResult;
4047
+ var hasRequiredNoWorkResult;
4048
+ function requireNoWorkResult() {
4049
+ if (hasRequiredNoWorkResult) return noWorkResult;
4050
+ hasRequiredNoWorkResult = 1;
4051
+ let MapGenerator = requireMapGenerator();
4052
+ let stringify = requireStringify();
4053
+ requireWarnOnce();
4054
+ let parse = requireParse();
4055
+ const Result = requireResult();
4056
+ class NoWorkResult {
4057
+ constructor(processor2, css, opts) {
4058
+ css = css.toString();
4059
+ this.stringified = false;
4060
+ this._processor = processor2;
4061
+ this._css = css;
4062
+ this._opts = opts;
4063
+ this._map = void 0;
4064
+ let root2;
4065
+ let str = stringify;
4066
+ this.result = new Result(this._processor, root2, this._opts);
4067
+ this.result.css = css;
4068
+ let self = this;
4069
+ Object.defineProperty(this.result, "root", { get() {
4070
+ return self.root;
4071
+ } });
4072
+ let map = new MapGenerator(str, root2, this._opts, css);
4073
+ if (map.isMap()) {
4074
+ let [generatedCSS, generatedMap] = map.generate();
4075
+ if (generatedCSS) this.result.css = generatedCSS;
4076
+ if (generatedMap) this.result.map = generatedMap;
4077
+ } else {
4078
+ map.clearAnnotation();
4079
+ this.result.css = map.css;
4080
+ }
4081
+ }
4082
+ async() {
4083
+ if (this.error) return Promise.reject(this.error);
4084
+ return Promise.resolve(this.result);
4085
+ }
4086
+ catch(onRejected) {
4087
+ return this.async().catch(onRejected);
4088
+ }
4089
+ finally(onFinally) {
4090
+ return this.async().then(onFinally, onFinally);
4091
+ }
4092
+ sync() {
4093
+ if (this.error) throw this.error;
4094
+ return this.result;
4095
+ }
4096
+ then(onFulfilled, onRejected) {
4097
+ return this.async().then(onFulfilled, onRejected);
4098
+ }
4099
+ toString() {
4100
+ return this._css;
4101
+ }
4102
+ warnings() {
4103
+ return [];
4104
+ }
4105
+ get content() {
4106
+ return this.result.css;
4107
+ }
4108
+ get css() {
4109
+ return this.result.css;
4110
+ }
4111
+ get map() {
4112
+ return this.result.map;
4113
+ }
4114
+ get messages() {
4115
+ return [];
4116
+ }
4117
+ get opts() {
4118
+ return this.result.opts;
4119
+ }
4120
+ get processor() {
4121
+ return this.result.processor;
4122
+ }
4123
+ get root() {
4124
+ if (this._root) return this._root;
4125
+ let root2;
4126
+ let parser2 = parse;
4127
+ try {
4128
+ root2 = parser2(this._css, this._opts);
4129
+ } catch (error) {
4130
+ this.error = error;
4131
+ }
4132
+ if (this.error) throw this.error;
4133
+ else {
4134
+ this._root = root2;
4135
+ return root2;
4136
+ }
4137
+ }
4138
+ get [Symbol.toStringTag]() {
4139
+ return "NoWorkResult";
4140
+ }
4141
+ }
4142
+ noWorkResult = NoWorkResult;
4143
+ NoWorkResult.default = NoWorkResult;
4144
+ return noWorkResult;
4145
+ }
4146
+ var processor;
4147
+ var hasRequiredProcessor;
4148
+ function requireProcessor() {
4149
+ if (hasRequiredProcessor) return processor;
4150
+ hasRequiredProcessor = 1;
4151
+ let NoWorkResult = requireNoWorkResult();
4152
+ let LazyResult = requireLazyResult();
4153
+ let Document = requireDocument();
4154
+ let Root = requireRoot();
4155
+ class Processor {
4156
+ constructor(plugins = []) {
4157
+ this.version = "8.4.38";
4158
+ this.plugins = this.normalize(plugins);
4159
+ }
4160
+ normalize(plugins) {
4161
+ let normalized = [];
4162
+ for (let i of plugins) {
4163
+ if (i.postcss === true) i = i();
4164
+ else if (i.postcss) i = i.postcss;
4165
+ if (typeof i === "object" && Array.isArray(i.plugins)) normalized = normalized.concat(i.plugins);
4166
+ else if (typeof i === "object" && i.postcssPlugin) normalized.push(i);
4167
+ else if (typeof i === "function") normalized.push(i);
4168
+ else if (typeof i === "object" && (i.parse || i.stringify)) {} else throw new Error(i + " is not a PostCSS plugin");
4169
+ }
4170
+ return normalized;
4171
+ }
4172
+ process(css, opts = {}) {
4173
+ if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) return new NoWorkResult(this, css, opts);
4174
+ else return new LazyResult(this, css, opts);
4175
+ }
4176
+ use(plugin) {
4177
+ this.plugins = this.plugins.concat(this.normalize([plugin]));
4178
+ return this;
4179
+ }
4180
+ }
4181
+ processor = Processor;
4182
+ Processor.default = Processor;
4183
+ Root.registerProcessor(Processor);
4184
+ Document.registerProcessor(Processor);
4185
+ return processor;
4186
+ }
4187
+ var fromJSON_1;
4188
+ var hasRequiredFromJSON;
4189
+ function requireFromJSON() {
4190
+ if (hasRequiredFromJSON) return fromJSON_1;
4191
+ hasRequiredFromJSON = 1;
4192
+ let Declaration = requireDeclaration();
4193
+ let PreviousMap = requirePreviousMap();
4194
+ let Comment = requireComment();
4195
+ let AtRule = requireAtRule();
4196
+ let Input = requireInput();
4197
+ let Root = requireRoot();
4198
+ let Rule = requireRule();
4199
+ function fromJSON(json, inputs) {
4200
+ if (Array.isArray(json)) return json.map((n) => fromJSON(n));
4201
+ let { inputs: ownInputs, ...defaults } = json;
4202
+ if (ownInputs) {
4203
+ inputs = [];
4204
+ for (let input2 of ownInputs) {
4205
+ let inputHydrated = {
4206
+ ...input2,
4207
+ __proto__: Input.prototype
4208
+ };
4209
+ if (inputHydrated.map) inputHydrated.map = {
4210
+ ...inputHydrated.map,
4211
+ __proto__: PreviousMap.prototype
4212
+ };
4213
+ inputs.push(inputHydrated);
4214
+ }
4215
+ }
4216
+ if (defaults.nodes) defaults.nodes = json.nodes.map((n) => fromJSON(n, inputs));
4217
+ if (defaults.source) {
4218
+ let { inputId, ...source } = defaults.source;
4219
+ defaults.source = source;
4220
+ if (inputId != null) defaults.source.input = inputs[inputId];
4221
+ }
4222
+ if (defaults.type === "root") return new Root(defaults);
4223
+ else if (defaults.type === "decl") return new Declaration(defaults);
4224
+ else if (defaults.type === "rule") return new Rule(defaults);
4225
+ else if (defaults.type === "comment") return new Comment(defaults);
4226
+ else if (defaults.type === "atrule") return new AtRule(defaults);
4227
+ else throw new Error("Unknown node type: " + json.type);
4228
+ }
4229
+ fromJSON_1 = fromJSON;
4230
+ fromJSON.default = fromJSON;
4231
+ return fromJSON_1;
4232
+ }
4233
+ var postcss_1;
4234
+ var hasRequiredPostcss;
4235
+ function requirePostcss() {
4236
+ if (hasRequiredPostcss) return postcss_1;
4237
+ hasRequiredPostcss = 1;
4238
+ let CssSyntaxError = requireCssSyntaxError();
4239
+ let Declaration = requireDeclaration();
4240
+ let LazyResult = requireLazyResult();
4241
+ let Container = requireContainer();
4242
+ let Processor = requireProcessor();
4243
+ let stringify = requireStringify();
4244
+ let fromJSON = requireFromJSON();
4245
+ let Document = requireDocument();
4246
+ let Warning = requireWarning();
4247
+ let Comment = requireComment();
4248
+ let AtRule = requireAtRule();
4249
+ let Result = requireResult();
4250
+ let Input = requireInput();
4251
+ let parse = requireParse();
4252
+ let list = requireList();
4253
+ let Rule = requireRule();
4254
+ let Root = requireRoot();
4255
+ let Node = requireNode();
4256
+ function postcss2(...plugins) {
4257
+ if (plugins.length === 1 && Array.isArray(plugins[0])) plugins = plugins[0];
4258
+ return new Processor(plugins);
4259
+ }
4260
+ postcss2.plugin = function plugin(name, initializer) {
4261
+ let warningPrinted = false;
4262
+ function creator(...args) {
4263
+ if (console && console.warn && !warningPrinted) {
4264
+ warningPrinted = true;
4265
+ console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
4266
+ if ({}.LANG && {}.LANG.startsWith("cn")) console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
4267
+ }
4268
+ let transformer = initializer(...args);
4269
+ transformer.postcssPlugin = name;
4270
+ transformer.postcssVersion = new Processor().version;
4271
+ return transformer;
4272
+ }
4273
+ let cache;
4274
+ Object.defineProperty(creator, "postcss", { get() {
4275
+ if (!cache) cache = creator();
4276
+ return cache;
4277
+ } });
4278
+ creator.process = function(css, processOpts, pluginOpts) {
4279
+ return postcss2([creator(pluginOpts)]).process(css, processOpts);
4280
+ };
4281
+ return creator;
4282
+ };
4283
+ postcss2.stringify = stringify;
4284
+ postcss2.parse = parse;
4285
+ postcss2.fromJSON = fromJSON;
4286
+ postcss2.list = list;
4287
+ postcss2.comment = (defaults) => new Comment(defaults);
4288
+ postcss2.atRule = (defaults) => new AtRule(defaults);
4289
+ postcss2.decl = (defaults) => new Declaration(defaults);
4290
+ postcss2.rule = (defaults) => new Rule(defaults);
4291
+ postcss2.root = (defaults) => new Root(defaults);
4292
+ postcss2.document = (defaults) => new Document(defaults);
4293
+ postcss2.CssSyntaxError = CssSyntaxError;
4294
+ postcss2.Declaration = Declaration;
4295
+ postcss2.Container = Container;
4296
+ postcss2.Processor = Processor;
4297
+ postcss2.Document = Document;
4298
+ postcss2.Comment = Comment;
4299
+ postcss2.Warning = Warning;
4300
+ postcss2.AtRule = AtRule;
4301
+ postcss2.Result = Result;
4302
+ postcss2.Input = Input;
4303
+ postcss2.Rule = Rule;
4304
+ postcss2.Root = Root;
4305
+ postcss2.Node = Node;
4306
+ LazyResult.registerPostcss(postcss2);
4307
+ postcss_1 = postcss2;
4308
+ postcss2.default = postcss2;
4309
+ return postcss_1;
4310
+ }
4311
+ var postcss = /* @__PURE__ */ getDefaultExportFromCjs(requirePostcss());
4312
+ postcss.stringify;
4313
+ postcss.fromJSON;
4314
+ postcss.plugin;
4315
+ postcss.parse;
4316
+ postcss.list;
4317
+ postcss.document;
4318
+ postcss.comment;
4319
+ postcss.atRule;
4320
+ postcss.rule;
4321
+ postcss.decl;
4322
+ postcss.root;
4323
+ postcss.CssSyntaxError;
4324
+ postcss.Declaration;
4325
+ postcss.Container;
4326
+ postcss.Processor;
4327
+ postcss.Document;
4328
+ postcss.Comment;
4329
+ postcss.Warning;
4330
+ postcss.AtRule;
4331
+ postcss.Result;
4332
+ postcss.Input;
4333
+ postcss.Rule;
4334
+ postcss.Root;
4335
+ postcss.Node;
4336
+ var tagMap = {
4337
+ script: "noscript",
4338
+ altglyph: "altGlyph",
4339
+ altglyphdef: "altGlyphDef",
4340
+ altglyphitem: "altGlyphItem",
4341
+ animatecolor: "animateColor",
4342
+ animatemotion: "animateMotion",
4343
+ animatetransform: "animateTransform",
4344
+ clippath: "clipPath",
4345
+ feblend: "feBlend",
4346
+ fecolormatrix: "feColorMatrix",
4347
+ fecomponenttransfer: "feComponentTransfer",
4348
+ fecomposite: "feComposite",
4349
+ feconvolvematrix: "feConvolveMatrix",
4350
+ fediffuselighting: "feDiffuseLighting",
4351
+ fedisplacementmap: "feDisplacementMap",
4352
+ fedistantlight: "feDistantLight",
4353
+ fedropshadow: "feDropShadow",
4354
+ feflood: "feFlood",
4355
+ fefunca: "feFuncA",
4356
+ fefuncb: "feFuncB",
4357
+ fefuncg: "feFuncG",
4358
+ fefuncr: "feFuncR",
4359
+ fegaussianblur: "feGaussianBlur",
4360
+ feimage: "feImage",
4361
+ femerge: "feMerge",
4362
+ femergenode: "feMergeNode",
4363
+ femorphology: "feMorphology",
4364
+ feoffset: "feOffset",
4365
+ fepointlight: "fePointLight",
4366
+ fespecularlighting: "feSpecularLighting",
4367
+ fespotlight: "feSpotLight",
4368
+ fetile: "feTile",
4369
+ feturbulence: "feTurbulence",
4370
+ foreignobject: "foreignObject",
4371
+ glyphref: "glyphRef",
4372
+ lineargradient: "linearGradient",
4373
+ radialgradient: "radialGradient"
4374
+ };
4375
+ function getTagName(n) {
4376
+ let tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;
4377
+ if (tagName === "link" && n.attributes._cssText) tagName = "style";
4378
+ return tagName;
4379
+ }
4380
+ function adaptCssForReplay(cssText, cache) {
4381
+ const cachedStyle = cache == null ? void 0 : cache.stylesWithHoverClass.get(cssText);
4382
+ if (cachedStyle) return cachedStyle;
4383
+ let result2 = cssText;
4384
+ try {
4385
+ result2 = postcss([mediaSelectorPlugin, pseudoClassPlugin]).process(cssText).css;
4386
+ } catch (error) {
4387
+ console.warn("Failed to adapt css for replay", error);
4388
+ }
4389
+ cache == null || cache.stylesWithHoverClass.set(cssText, result2);
4390
+ return result2;
4391
+ }
4392
+ function createCache() {
4393
+ return { stylesWithHoverClass: /* @__PURE__ */ new Map() };
4394
+ }
4395
+ var REBUILD_TARGET_ERROR = "rrweb-snapshot.rebuild() cannot rebuild into an unprotected browser document. Use rebuildIntoSandboxedIframe() or set UNSAFE_allowUnprotectedRebuild: true only when you accept the script-execution risk.";
4396
+ var SANDBOXED_IFRAME_ROOT_ERROR = "rrweb-snapshot.createSandboxedIframe() requires root to be connected to a document before creating a sandboxed iframe.";
4397
+ var sandboxedRebuildDocuments = /* @__PURE__ */ new WeakSet();
4398
+ function isSupportedSandboxedIframe(frameElement) {
4399
+ if (!frameElement || frameElement.tagName !== "IFRAME") return false;
4400
+ if (!("sandbox" in frameElement)) return false;
4401
+ const sandboxTokens = Array.from(frameElement.sandbox);
4402
+ return sandboxTokens.length === 1 && sandboxTokens[0] === "allow-same-origin";
4403
+ }
4404
+ function assertRebuildTargetAllowed(options) {
4405
+ if (options.UNSAFE_allowUnprotectedRebuild) return;
4406
+ const win = options.doc.defaultView;
4407
+ if (!win) return;
4408
+ if (sandboxedRebuildDocuments.has(options.doc) && isSupportedSandboxedIframe(win.frameElement)) return;
4409
+ throw new Error(REBUILD_TARGET_ERROR);
4410
+ }
4411
+ function applyCssSplits(n, cssText, hackCss, cache) {
4412
+ const childTextNodes = [];
4413
+ for (const scn of n.childNodes) if (scn.type === NodeType.Text) childTextNodes.push(scn);
4414
+ const cssTextSplits = cssText.split("/* rr_split */");
4415
+ while (cssTextSplits.length > 1 && cssTextSplits.length > childTextNodes.length) cssTextSplits.splice(-2, 2, cssTextSplits.slice(-2).join(""));
4416
+ let adaptedCss = "";
4417
+ if (hackCss) adaptedCss = adaptCssForReplay(cssTextSplits.join(""), cache);
4418
+ let startIndex = 0;
4419
+ for (let i = 0; i < childTextNodes.length; i++) {
4420
+ if (i === cssTextSplits.length) break;
4421
+ const childTextNode = childTextNodes[i];
4422
+ if (!hackCss) childTextNode.textContent = cssTextSplits[i];
4423
+ else if (i < cssTextSplits.length - 1) {
4424
+ let endIndex = startIndex;
4425
+ let endSearch = cssTextSplits[i + 1].length;
4426
+ endSearch = Math.min(endSearch, 30);
4427
+ let found = false;
4428
+ for (; endSearch > 2; endSearch--) {
4429
+ const searchBit = cssTextSplits[i + 1].substring(0, endSearch);
4430
+ const searchIndex = adaptedCss.substring(startIndex).indexOf(searchBit);
4431
+ found = searchIndex !== -1;
4432
+ if (found) {
4433
+ endIndex += searchIndex;
4434
+ break;
4435
+ }
4436
+ }
4437
+ if (!found) endIndex += cssTextSplits[i].length;
4438
+ childTextNode.textContent = adaptedCss.substring(startIndex, endIndex);
4439
+ startIndex = endIndex;
4440
+ } else childTextNode.textContent = adaptedCss.substring(startIndex);
4441
+ }
4442
+ }
4443
+ function buildStyleNode(n, styleEl, cssText, options) {
4444
+ const { doc, hackCss, cache } = options;
4445
+ if (n.childNodes.length) applyCssSplits(n, cssText, hackCss, cache);
4446
+ else {
4447
+ if (hackCss) cssText = adaptCssForReplay(cssText, cache);
4448
+ styleEl.appendChild(doc.createTextNode(cssText));
4449
+ }
4450
+ }
4451
+ function buildNode(n, options) {
4452
+ var _a;
4453
+ const { doc, hackCss, cache } = options;
4454
+ switch (n.type) {
4455
+ case NodeType.Document: return doc.implementation.createDocument(null, "", null);
4456
+ case NodeType.DocumentType: return doc.implementation.createDocumentType(n.name || "html", n.publicId, n.systemId);
4457
+ case NodeType.Element: {
4458
+ const tagName = getTagName(n);
4459
+ let node2;
4460
+ if (n.isSVG) node2 = doc.createElementNS("http://www.w3.org/2000/svg", tagName);
4461
+ else {
4462
+ if (n.isCustom && ((_a = doc.defaultView) == null ? void 0 : _a.customElements) && !doc.defaultView.customElements.get(n.tagName)) doc.defaultView.customElements.define(n.tagName, class extends doc.defaultView.HTMLElement {});
4463
+ node2 = doc.createElement(tagName);
4464
+ }
4465
+ const specialAttributes = {};
4466
+ for (const name in n.attributes) {
4467
+ if (!Object.prototype.hasOwnProperty.call(n.attributes, name)) continue;
4468
+ let value = n.attributes[name];
4469
+ if (tagName === "option" && name === "selected" && value === false) continue;
4470
+ if (value === null) continue;
4471
+ if (value === true) value = "";
4472
+ if (name.startsWith("rr_")) {
4473
+ specialAttributes[name] = value;
4474
+ continue;
4475
+ }
4476
+ if (typeof value !== "string");
4477
+ else if (tagName === "style" && name === "_cssText") {
4478
+ buildStyleNode(n, node2, value, options);
4479
+ continue;
4480
+ } else if (tagName === "textarea" && name === "value") {
4481
+ node2.appendChild(doc.createTextNode(value));
4482
+ n.childNodes = [];
4483
+ continue;
4484
+ }
4485
+ try {
4486
+ if (n.isSVG && name === "xlink:href") node2.setAttributeNS("http://www.w3.org/1999/xlink", name, value.toString());
4487
+ else if (name === "onload" || name === "onclick" || name.substring(0, 7) === "onmouse") node2.setAttribute("_" + name, value.toString());
4488
+ else if (tagName === "meta" && n.attributes["http-equiv"] === "Content-Security-Policy" && name === "content") {
4489
+ node2.setAttribute("csp-content", value.toString());
4490
+ continue;
4491
+ } else if (tagName === "link" && (n.attributes.rel === "preload" && n.attributes.as === "script" || n.attributes.rel === "modulepreload")) {} else if (tagName === "link" && n.attributes.rel === "prefetch" && typeof n.attributes.href === "string" && extractFileExtension(n.attributes.href) === "js") {} else if (tagName === "img" && n.attributes.srcset && n.attributes.rr_dataURL) node2.setAttribute("rrweb-original-srcset", n.attributes.srcset);
4492
+ else node2.setAttribute(name, value.toString());
4493
+ } catch (error) {}
4494
+ }
4495
+ for (const name in specialAttributes) {
4496
+ const value = specialAttributes[name];
4497
+ if (tagName === "canvas" && name === "rr_dataURL") {
4498
+ const image = doc.createElement("img");
4499
+ image.onload = () => {
4500
+ const ctx = node2.getContext("2d");
4501
+ if (ctx) ctx.drawImage(image, 0, 0, image.width, image.height);
4502
+ };
4503
+ image.src = value.toString();
4504
+ if (node2.RRNodeType) node2.rr_dataURL = value.toString();
4505
+ } else if (tagName === "img" && name === "rr_dataURL") {
4506
+ const image = node2;
4507
+ if (!image.currentSrc.startsWith("data:")) {
4508
+ image.setAttribute("rrweb-original-src", n.attributes.src);
4509
+ image.src = value.toString();
4510
+ }
4511
+ }
4512
+ if (name === "rr_width") node2.style.setProperty("width", value.toString());
4513
+ else if (name === "rr_height") node2.style.setProperty("height", value.toString());
4514
+ else if (name === "rr_mediaCurrentTime" && typeof value === "number") node2.currentTime = value;
4515
+ else if (name === "rr_mediaState") switch (value) {
4516
+ case "played":
4517
+ node2.play().catch((e) => console.warn("media playback error", e));
4518
+ break;
4519
+ case "paused":
4520
+ node2.pause();
4521
+ break;
4522
+ }
4523
+ else if (name === "rr_mediaPlaybackRate" && typeof value === "number") node2.playbackRate = value;
4524
+ else if (name === "rr_mediaMuted" && typeof value === "boolean") node2.muted = value;
4525
+ else if (name === "rr_mediaLoop" && typeof value === "boolean") node2.loop = value;
4526
+ else if (name === "rr_mediaVolume" && typeof value === "number") node2.volume = value;
4527
+ else if (name === "rr_open_mode") node2.setAttribute("rr_open_mode", value);
4528
+ }
4529
+ if (n.isShadowHost) if (!node2.shadowRoot) node2.attachShadow({ mode: "open" });
4530
+ else while (node2.shadowRoot.firstChild) node2.shadowRoot.removeChild(node2.shadowRoot.firstChild);
4531
+ return node2;
4532
+ }
4533
+ case NodeType.Text:
4534
+ if (n.isStyle && hackCss) return doc.createTextNode(adaptCssForReplay(n.textContent, cache));
4535
+ return doc.createTextNode(n.textContent);
4536
+ case NodeType.CDATA: return doc.createCDATASection(n.textContent);
4537
+ case NodeType.Comment: return doc.createComment(n.textContent);
4538
+ default: return null;
4539
+ }
4540
+ }
4541
+ function buildNodeWithSN(n, options) {
4542
+ const { doc, mirror, skipChild = false, hackCss = true, afterAppend, cache } = options;
4543
+ if (mirror.has(n.id)) {
4544
+ const nodeInMirror = mirror.getNode(n.id);
4545
+ if (isNodeMetaEqual(mirror.getMeta(nodeInMirror), n)) return mirror.getNode(n.id);
4546
+ }
4547
+ let node2 = buildNode(n, {
4548
+ doc,
4549
+ hackCss,
4550
+ cache
4551
+ });
4552
+ if (!node2) return null;
4553
+ if (n.rootId && mirror.getNode(n.rootId) !== doc) mirror.replace(n.rootId, doc);
4554
+ if (n.type === NodeType.Document) {
4555
+ doc.close();
4556
+ doc.open();
4557
+ if (n.compatMode === "BackCompat" && n.childNodes && n.childNodes[0].type !== NodeType.DocumentType) if (n.childNodes[0].type === NodeType.Element && "xmlns" in n.childNodes[0].attributes && n.childNodes[0].attributes.xmlns === "http://www.w3.org/1999/xhtml") doc.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"\">");
4558
+ else doc.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"\">");
4559
+ node2 = doc;
4560
+ }
4561
+ mirror.add(node2, n);
4562
+ if ((n.type === NodeType.Document || n.type === NodeType.Element) && !skipChild) for (const childN of n.childNodes) {
4563
+ const childNode = buildNodeWithSN(childN, {
4564
+ doc,
4565
+ mirror,
4566
+ skipChild: false,
4567
+ hackCss,
4568
+ afterAppend,
4569
+ cache
4570
+ });
4571
+ if (!childNode) {
4572
+ console.warn("Failed to rebuild", childN);
4573
+ continue;
4574
+ }
4575
+ if (childN.isShadow && isElement(node2) && node2.shadowRoot) node2.shadowRoot.appendChild(childNode);
4576
+ else if (n.type === NodeType.Document && childN.type == NodeType.Element) {
4577
+ const htmlElement = childNode;
4578
+ let body = null;
4579
+ htmlElement.childNodes.forEach((child) => {
4580
+ if (child.nodeName === "BODY") body = child;
4581
+ });
4582
+ if (body) {
4583
+ htmlElement.removeChild(body);
4584
+ node2.appendChild(childNode);
4585
+ htmlElement.appendChild(body);
4586
+ } else node2.appendChild(childNode);
4587
+ } else node2.appendChild(childNode);
4588
+ if (afterAppend) afterAppend(childNode, childN.id);
4589
+ }
4590
+ return node2;
4591
+ }
4592
+ function visit(mirror, onVisit) {
4593
+ function walk(node2) {
4594
+ onVisit(node2);
4595
+ }
4596
+ for (const id of mirror.getIds()) if (mirror.has(id)) walk(mirror.getNode(id));
4597
+ }
4598
+ function handleScroll(node2, mirror) {
4599
+ const n = mirror.getMeta(node2);
4600
+ if ((n == null ? void 0 : n.type) !== NodeType.Element) return;
4601
+ const el = node2;
4602
+ for (const name in n.attributes) {
4603
+ if (!(Object.prototype.hasOwnProperty.call(n.attributes, name) && name.startsWith("rr_"))) continue;
4604
+ const value = n.attributes[name];
4605
+ if (name === "rr_scrollLeft") el.scrollLeft = value;
4606
+ if (name === "rr_scrollTop") el.scrollTop = value;
4607
+ }
4608
+ }
4609
+ function rebuild(n, options) {
4610
+ assertRebuildTargetAllowed(options);
4611
+ const { doc, onVisit, hackCss = true, afterAppend, cache, mirror = new Mirror() } = options;
4612
+ const node2 = buildNodeWithSN(n, {
4613
+ doc,
4614
+ mirror,
4615
+ skipChild: false,
4616
+ hackCss,
4617
+ afterAppend,
4618
+ cache
4619
+ });
4620
+ visit(mirror, (visitedNode) => {
4621
+ if (onVisit) onVisit(visitedNode);
4622
+ handleScroll(visitedNode, mirror);
4623
+ });
4624
+ return node2;
4625
+ }
4626
+ function createSandboxedIframe(options) {
4627
+ var _a;
4628
+ if (!options.root.isConnected) throw new Error(SANDBOXED_IFRAME_ROOT_ERROR);
4629
+ const iframe = options.root.ownerDocument.createElement("iframe");
4630
+ for (const [name, value] of Object.entries(options.iframeAttributes || {})) {
4631
+ if (name === "sandbox") continue;
4632
+ iframe.setAttribute(name, value);
4633
+ }
4634
+ iframe.setAttribute("sandbox", "allow-same-origin");
4635
+ options.root.appendChild(iframe);
4636
+ const doc = iframe.contentDocument;
4637
+ if (!doc || !iframe.contentWindow) {
4638
+ (_a = iframe.parentNode) == null || _a.removeChild(iframe);
4639
+ throw new Error(SANDBOXED_IFRAME_ROOT_ERROR);
4640
+ }
4641
+ sandboxedRebuildDocuments.add(doc);
4642
+ return iframe;
4643
+ }
4644
+ function rebuildIntoSandboxedIframe(n, options) {
4645
+ var _a;
4646
+ const iframe = createSandboxedIframe(options);
4647
+ const doc = iframe.contentDocument;
4648
+ let node2;
4649
+ try {
4650
+ node2 = rebuild(n, {
4651
+ ...options,
4652
+ doc
4653
+ });
4654
+ } catch (error) {
4655
+ (_a = iframe.parentNode) == null || _a.removeChild(iframe);
4656
+ throw error;
4657
+ }
4658
+ return {
4659
+ iframe,
4660
+ node: node2
4661
+ };
4662
+ }
4663
+
4664
+ //#endregion
4665
+ export { IGNORED_NODE, Mirror, absolutifyURLs, adaptCssForReplay, buildNodeWithSN, classMatchesRegex, cleanupSnapshot, createCache, createMirror, createSandboxedIframe, escapeImportStatement, extractFileExtension, fixSafariColons, genId, getInputType, ignoreAttribute, is2DCanvasBlank, isCSSImportRule, isCSSStyleRule, isElement, isNativeShadowDom, isNodeMetaEqual, isShadowRoot, markCssSplits, maskInputValue, needMaskingText, normalizeCssString, rebuild, rebuildIntoSandboxedIframe, serializeNodeWithId, slimDOMDefaults, snapshot, splitCssText, stringifyRule, stringifyStylesheet, toLowerCase, transformAttribute, visitSnapshot };