@glimt/record 0.0.48 → 0.0.50

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.
package/dist/record.cjs CHANGED
@@ -427,6 +427,9 @@ const index = {
427
427
  mutationObserver: mutationObserverCtor,
428
428
  patch
429
429
  };
430
+ const shouldTryAnonymousFetchingOnCorsError$1 = () => {
431
+ return !("_rrweb_skip_re_fetching_to_suppress_cors_errors" in window && window._rrweb_skip_re_fetching_to_suppress_cors_errors === true);
432
+ };
430
433
  function isElement(n2) {
431
434
  return n2.nodeType === n2.ELEMENT_NODE;
432
435
  }
@@ -443,7 +446,7 @@ function isShadowRoot(n2) {
443
446
  function isNativeShadowDom(shadowRoot2) {
444
447
  return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
445
448
  }
446
- function fixBrowserCompatibilityIssuesInCSS(cssText) {
449
+ function fixBrowserCompatibilityIssuesInCSS$1(cssText) {
447
450
  if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
448
451
  cssText = cssText.replace(
449
452
  /\sbackground-clip:\s*text;/g,
@@ -452,7 +455,7 @@ function fixBrowserCompatibilityIssuesInCSS(cssText) {
452
455
  }
453
456
  return cssText;
454
457
  }
455
- function escapeImportStatement(rule2) {
458
+ function escapeImportStatement$1(rule2) {
456
459
  const { cssText } = rule2;
457
460
  if (cssText.split('"').length < 3) return cssText;
458
461
  const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
@@ -469,7 +472,7 @@ function escapeImportStatement(rule2) {
469
472
  }
470
473
  return statement.join(" ") + ";";
471
474
  }
472
- function stringifyStylesheet(s2) {
475
+ function stringifyStylesheet$1(s2) {
473
476
  try {
474
477
  const rules2 = s2.rules || s2.cssRules;
475
478
  if (!rules2) {
@@ -481,47 +484,47 @@ function stringifyStylesheet(s2) {
481
484
  }
482
485
  const stringifiedRules = Array.from(
483
486
  rules2,
484
- (rule2) => stringifyRule(rule2, sheetHref)
487
+ (rule2) => stringifyRule$1(rule2, sheetHref)
485
488
  ).join("");
486
- return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
489
+ return fixBrowserCompatibilityIssuesInCSS$1(stringifiedRules);
487
490
  } catch (error) {
488
491
  return null;
489
492
  }
490
493
  }
491
- function stringifyRule(rule2, sheetHref) {
492
- if (isCSSImportRule(rule2)) {
494
+ function stringifyRule$1(rule2, sheetHref) {
495
+ if (isCSSImportRule$1(rule2)) {
493
496
  let importStringified;
494
497
  try {
495
498
  importStringified = // for same-origin stylesheets,
496
499
  // we can access the imported stylesheet rules directly
497
- stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
498
- escapeImportStatement(rule2);
500
+ stringifyStylesheet$1(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
501
+ escapeImportStatement$1(rule2);
499
502
  } catch (error) {
500
503
  importStringified = rule2.cssText;
501
504
  }
502
505
  if (rule2.styleSheet.href) {
503
- return absolutifyURLs(importStringified, rule2.styleSheet.href);
506
+ return absolutifyURLs$1(importStringified, rule2.styleSheet.href);
504
507
  }
505
508
  return importStringified;
506
509
  } else {
507
510
  let ruleStringified = rule2.cssText;
508
- if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
509
- ruleStringified = fixSafariColons(ruleStringified);
511
+ if (isCSSStyleRule$1(rule2) && rule2.selectorText.includes(":")) {
512
+ ruleStringified = fixSafariColons$1(ruleStringified);
510
513
  }
511
514
  if (sheetHref) {
512
- return absolutifyURLs(ruleStringified, sheetHref);
515
+ return absolutifyURLs$1(ruleStringified, sheetHref);
513
516
  }
514
517
  return ruleStringified;
515
518
  }
516
519
  }
517
- function fixSafariColons(cssStringified) {
520
+ function fixSafariColons$1(cssStringified) {
518
521
  const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
519
522
  return cssStringified.replace(regex, "$1\\$2");
520
523
  }
521
- function isCSSImportRule(rule2) {
524
+ function isCSSImportRule$1(rule2) {
522
525
  return "styleSheet" in rule2;
523
526
  }
524
- function isCSSStyleRule(rule2) {
527
+ function isCSSStyleRule$1(rule2) {
525
528
  return "selectorText" in rule2;
526
529
  }
527
530
  class Mirror {
@@ -658,7 +661,7 @@ function extractFileExtension(path, baseURL) {
658
661
  const match = url.pathname.match(regex);
659
662
  return (match == null ? void 0 : match[1]) ?? null;
660
663
  }
661
- function extractOrigin(url) {
664
+ function extractOrigin$1(url) {
662
665
  let origin = "";
663
666
  if (url.indexOf("//") > -1) {
664
667
  origin = url.split("/").slice(0, 3).join("/");
@@ -668,27 +671,27 @@ function extractOrigin(url) {
668
671
  origin = origin.split("?")[0];
669
672
  return origin;
670
673
  }
671
- const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
672
- const URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
673
- const URL_WWW_MATCH = /^www\..*/i;
674
- const DATA_URI = /^(data:)([^,]*),(.*)/i;
675
- function absolutifyURLs(cssText, href) {
674
+ const URL_IN_CSS_REF$1 = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
675
+ const URL_PROTOCOL_MATCH$1 = /^(?:[a-z+]+:)?\/\//i;
676
+ const URL_WWW_MATCH$1 = /^www\..*/i;
677
+ const DATA_URI$1 = /^(data:)([^,]*),(.*)/i;
678
+ function absolutifyURLs$1(cssText, href) {
676
679
  return (cssText || "").replace(
677
- URL_IN_CSS_REF,
680
+ URL_IN_CSS_REF$1,
678
681
  (origin, quote1, path1, quote2, path2, path3) => {
679
682
  const filePath = path1 || path2 || path3;
680
683
  const maybeQuote = quote1 || quote2 || "";
681
684
  if (!filePath) {
682
685
  return origin;
683
686
  }
684
- if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
687
+ if (URL_PROTOCOL_MATCH$1.test(filePath) || URL_WWW_MATCH$1.test(filePath)) {
685
688
  return `url(${maybeQuote}${filePath}${maybeQuote})`;
686
689
  }
687
- if (DATA_URI.test(filePath)) {
690
+ if (DATA_URI$1.test(filePath)) {
688
691
  return `url(${maybeQuote}${filePath}${maybeQuote})`;
689
692
  }
690
693
  if (filePath[0] === "/") {
691
- return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
694
+ return `url(${maybeQuote}${extractOrigin$1(href) + filePath}${maybeQuote})`;
692
695
  }
693
696
  const stack = href.split("/");
694
697
  const parts = filePath.split("/");
@@ -811,6 +814,190 @@ function splitCssText(cssText, style, _testNoPxNorm = false) {
811
814
  function markCssSplits(cssText, style) {
812
815
  return splitCssText(cssText, style).join("/* rr_split */");
813
816
  }
817
+ const CLEANUP_DEBOUNCE_TIME$1 = 1e3 * 30;
818
+ const DATA_ATTRIBUTE_CLONED_NAME$1 = "data-rrweb-link-cloned";
819
+ const DISALLOWED_EXTENSIONS$1 = [
820
+ // Fonts
821
+ "woff",
822
+ "woff2",
823
+ "ttf",
824
+ "otf",
825
+ // Embedded OpenType font
826
+ "eot",
827
+ // Images
828
+ "png",
829
+ "jpg",
830
+ "jpeg",
831
+ "gif",
832
+ "svg",
833
+ "webp",
834
+ "ico",
835
+ // Scripts
836
+ "js",
837
+ "mjs",
838
+ "ts",
839
+ "jsx",
840
+ "tsx",
841
+ // Data files
842
+ "json",
843
+ "map",
844
+ // Media
845
+ "mp4",
846
+ "webm",
847
+ "ogg",
848
+ "mp3",
849
+ "wav",
850
+ // Archives
851
+ "zip",
852
+ "rar",
853
+ "7z",
854
+ "tar",
855
+ "gz",
856
+ // Documents
857
+ "pdf",
858
+ "doc",
859
+ "docx",
860
+ "xls",
861
+ "xlsx"
862
+ ];
863
+ const _AsyncStylesheetManager$1 = class _AsyncStylesheetManager {
864
+ constructor() {
865
+ __publicField$1(this, "currentHref", null);
866
+ __publicField$1(this, "clones", {});
867
+ __publicField$1(this, "cleanTimeout", null);
868
+ if (_AsyncStylesheetManager.instance) return _AsyncStylesheetManager.instance;
869
+ _AsyncStylesheetManager.instance = this;
870
+ }
871
+ removeCloneNode(href) {
872
+ var _a2;
873
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
874
+ const clone = document.querySelector(
875
+ `link[${DATA_ATTRIBUTE_CLONED_NAME$1}="${this.clones[href].cloneNodeAttrId}"]`
876
+ );
877
+ if (!clone) return;
878
+ (_a2 = clone.parentNode) == null ? void 0 : _a2.removeChild(clone);
879
+ }
880
+ onLoad(href) {
881
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
882
+ const styleSheets2 = Array.from(document.styleSheets);
883
+ let clonedStyleSheet = null;
884
+ for (let i2 = styleSheets2.length - 1; i2 >= 0; i2--) {
885
+ if (styleSheets2[i2].href === href) {
886
+ clonedStyleSheet = styleSheets2[i2];
887
+ break;
888
+ }
889
+ }
890
+ if (!clonedStyleSheet) return this.removeCloneNode(href);
891
+ const newCssText = stringifyStylesheet$1(clonedStyleSheet);
892
+ this.removeCloneNode(href);
893
+ if (!newCssText) return;
894
+ this.clones[href].cssText = newCssText;
895
+ this.clones[href].loaded = true;
896
+ const original = document.querySelector(
897
+ `link[${DATA_ATTRIBUTE_CLONED_NAME$1}="source-${this.clones[href].cloneNodeAttrId}"]`
898
+ );
899
+ if (original) {
900
+ original.setAttribute("data-rrweb-mutation", Date.now().toString());
901
+ original.removeAttribute(DATA_ATTRIBUTE_CLONED_NAME$1);
902
+ } else {
903
+ this.clones[href].original.setAttribute(
904
+ "data-rrweb-mutation",
905
+ Date.now().toString()
906
+ );
907
+ this.clones[href].original.removeAttribute(DATA_ATTRIBUTE_CLONED_NAME$1);
908
+ }
909
+ window.dispatchEvent(
910
+ new CustomEvent("__rrweb_custom_event__", {
911
+ detail: {
912
+ type: 5,
913
+ timestamp: Date.now(),
914
+ data: {
915
+ tag: "async-css-resolution",
916
+ requestCssId: this.clones[href].requestCssId,
917
+ cssText: this.clones[href].cssText
918
+ }
919
+ }
920
+ })
921
+ );
922
+ }
923
+ onLoadError(href) {
924
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
925
+ this.removeCloneNode(href);
926
+ }
927
+ removeAllCloneElements() {
928
+ for (const href of Object.keys(this.clones)) {
929
+ this.removeCloneNode(href);
930
+ }
931
+ }
932
+ onCleanTimeout() {
933
+ asyncStylesheetManager$1.cleanTimeout = null;
934
+ asyncStylesheetManager$1.removeAllCloneElements();
935
+ }
936
+ blowCache() {
937
+ this.removeAllCloneElements();
938
+ this.clones = {};
939
+ }
940
+ requestClone({
941
+ forElement,
942
+ requestCssId
943
+ }) {
944
+ if (!shouldTryAnonymousFetchingOnCorsError$1()) return;
945
+ if (this.currentHref != null && document.location.href !== this.currentHref)
946
+ this.blowCache();
947
+ this.currentHref = document.location.href;
948
+ const href = forElement.href;
949
+ if (!href) return;
950
+ if (href in this.clones && this.clones[href] !== void 0) return;
951
+ if (forElement.getAttribute("crossorigin") === "anonymous") return;
952
+ if (forElement.rel !== "stylesheet") {
953
+ const last = href.split("/").pop();
954
+ if (last && last.includes(".")) {
955
+ const [filename] = last.split("?");
956
+ const ext = filename.split(".").pop();
957
+ if (ext) {
958
+ if (DISALLOWED_EXTENSIONS$1.includes(ext.trim().toLowerCase())) return;
959
+ }
960
+ }
961
+ }
962
+ const clone = forElement.cloneNode();
963
+ const cloneNodeAttrId = Math.random().toString(36).slice(2);
964
+ clone.setAttribute("crossorigin", "anonymous");
965
+ clone.setAttribute(DATA_ATTRIBUTE_CLONED_NAME$1, cloneNodeAttrId);
966
+ forElement.setAttribute(
967
+ DATA_ATTRIBUTE_CLONED_NAME$1,
968
+ `source-${cloneNodeAttrId}`
969
+ );
970
+ document.head.appendChild(clone);
971
+ this.clones[href] = {
972
+ original: forElement,
973
+ clone,
974
+ loaded: false,
975
+ cssText: null,
976
+ cloneNodeAttrId,
977
+ requestCssId
978
+ };
979
+ clone.onload = () => {
980
+ this.onLoad(href);
981
+ };
982
+ clone.onerror = () => {
983
+ this.onLoadError(href);
984
+ };
985
+ if (this.cleanTimeout) clearTimeout(this.cleanTimeout);
986
+ this.cleanTimeout = setTimeout(
987
+ asyncStylesheetManager$1.onCleanTimeout,
988
+ CLEANUP_DEBOUNCE_TIME$1
989
+ );
990
+ }
991
+ getClonedCssTextIfAvailable(href) {
992
+ if (href in this.clones && this.clones[href] !== void 0 && this.clones[href].loaded === true) {
993
+ return this.clones[href].cssText;
994
+ }
995
+ return null;
996
+ }
997
+ };
998
+ __publicField$1(_AsyncStylesheetManager$1, "instance");
999
+ let AsyncStylesheetManager$1 = _AsyncStylesheetManager$1;
1000
+ const asyncStylesheetManager$1 = new AsyncStylesheetManager$1();
814
1001
  let _id = 1;
815
1002
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
816
1003
  const IGNORED_NODE = -2;
@@ -922,7 +1109,7 @@ function transformAttribute(doc, tagName, name, value) {
922
1109
  } else if (name === "srcset") {
923
1110
  return getAbsoluteSrcsetString(doc, value);
924
1111
  } else if (name === "style") {
925
- return absolutifyURLs(value, getHref(doc));
1112
+ return absolutifyURLs$1(value, getHref(doc));
926
1113
  } else if (tagName === "object" && name === "data") {
927
1114
  return absoluteToDoc(doc, value);
928
1115
  }
@@ -1159,7 +1346,7 @@ function serializeTextNode(n2, options) {
1159
1346
  } else if (!cssCaptured) {
1160
1347
  textContent2 = index.textContent(n2);
1161
1348
  if (isStyle && textContent2) {
1162
- textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
1349
+ textContent2 = absolutifyURLs$1(textContent2, getHref(options.doc));
1163
1350
  }
1164
1351
  }
1165
1352
  if (!isStyle && !isScript && textContent2 && needsMask) {
@@ -1202,21 +1389,38 @@ function serializeElementNode(n2, options) {
1202
1389
  }
1203
1390
  }
1204
1391
  if (tagName === "link" && inlineStylesheet) {
1205
- const stylesheet = Array.from(doc.styleSheets).find((s2) => {
1206
- return s2.href === n2.href;
1207
- });
1392
+ const styleSheets2 = Array.from(doc.styleSheets);
1393
+ let stylesheet = null;
1394
+ for (let i2 = 0; i2 < styleSheets2.length; i2++) {
1395
+ if (styleSheets2[i2].href === n2.href) {
1396
+ stylesheet = styleSheets2[i2];
1397
+ break;
1398
+ }
1399
+ }
1208
1400
  let cssText = null;
1209
1401
  if (stylesheet) {
1210
- cssText = stringifyStylesheet(stylesheet);
1402
+ cssText = stringifyStylesheet$1(stylesheet);
1403
+ }
1404
+ if (!cssText) {
1405
+ cssText = asyncStylesheetManager$1.getClonedCssTextIfAvailable(
1406
+ n2.href
1407
+ );
1211
1408
  }
1212
1409
  if (cssText) {
1213
1410
  delete attributes.rel;
1214
1411
  delete attributes.href;
1215
1412
  attributes._cssText = cssText;
1413
+ } else {
1414
+ const requestCssId = `css-request-${Math.random().toString(36).slice(2)}`;
1415
+ asyncStylesheetManager$1.requestClone({
1416
+ forElement: n2,
1417
+ requestCssId
1418
+ });
1419
+ attributes._requestCssId = requestCssId;
1216
1420
  }
1217
1421
  }
1218
1422
  if (tagName === "style" && n2.sheet) {
1219
- let cssText = stringifyStylesheet(
1423
+ let cssText = stringifyStylesheet$1(
1220
1424
  n2.sheet
1221
1425
  );
1222
1426
  if (cssText) {
@@ -1293,7 +1497,9 @@ function serializeElementNode(n2, options) {
1293
1497
  const imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
1294
1498
  const imageHeight = image.naturalHeight;
1295
1499
  const imageWidth = image.naturalWidth;
1500
+ let hasRetried = false;
1296
1501
  const inlineImageCleanup = () => {
1502
+ if (!hasRetried) return;
1297
1503
  image = null;
1298
1504
  };
1299
1505
  const recordInlineImage = () => {
@@ -1308,18 +1514,21 @@ function serializeElementNode(n2, options) {
1308
1514
  );
1309
1515
  } catch (err) {
1310
1516
  if (image.crossOrigin !== "anonymous") {
1311
- image = new Image();
1312
- image.src = imageSrc;
1313
- image.crossOrigin = "anonymous";
1314
- image.height = imageHeight;
1315
- image.width = imageWidth;
1316
- if (image.complete && image.naturalWidth !== 0) {
1317
- recordInlineImage();
1318
- } else {
1319
- image.addEventListener("load", recordInlineImage, { once: true });
1320
- image.addEventListener("error", onImageLoadError, { once: true });
1517
+ if (shouldTryAnonymousFetchingOnCorsError$1()) {
1518
+ image = new Image();
1519
+ hasRetried = true;
1520
+ image.src = imageSrc;
1521
+ image.crossOrigin = "anonymous";
1522
+ image.height = imageHeight;
1523
+ image.width = imageWidth;
1524
+ if (image.complete && image.naturalWidth !== 0) {
1525
+ recordInlineImage();
1526
+ } else {
1527
+ image.addEventListener("load", recordInlineImage, { once: true });
1528
+ image.addEventListener("error", onImageLoadError, { once: true });
1529
+ }
1530
+ return;
1321
1531
  }
1322
- return;
1323
1532
  } else {
1324
1533
  console.warn(
1325
1534
  `Cannot inline img src=${imageSrc}! Error: ${err}`
@@ -2348,7 +2557,7 @@ let Node$4$1 = class Node2 {
2348
2557
  let index2 = this.parent.index(this);
2349
2558
  return this.parent.nodes[index2 + 1];
2350
2559
  }
2351
- positionBy(opts) {
2560
+ positionBy(opts = {}) {
2352
2561
  let pos = this.source.start;
2353
2562
  if (opts.index) {
2354
2563
  pos = this.positionInside(opts.index);
@@ -2377,27 +2586,38 @@ let Node$4$1 = class Node2 {
2377
2586
  column += 1;
2378
2587
  }
2379
2588
  }
2380
- return { column, line };
2589
+ return { column, line, offset: end };
2381
2590
  }
2382
2591
  prev() {
2383
2592
  if (!this.parent) return void 0;
2384
2593
  let index2 = this.parent.index(this);
2385
2594
  return this.parent.nodes[index2 - 1];
2386
2595
  }
2387
- rangeBy(opts) {
2596
+ rangeBy(opts = {}) {
2597
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
2388
2598
  let start = {
2389
2599
  column: this.source.start.column,
2390
- line: this.source.start.line
2600
+ line: this.source.start.line,
2601
+ offset: sourceOffset$1(inputString, this.source.start)
2391
2602
  };
2392
2603
  let end = this.source.end ? {
2393
2604
  column: this.source.end.column + 1,
2394
- line: this.source.end.line
2605
+ line: this.source.end.line,
2606
+ offset: typeof this.source.end.offset === "number" ? (
2607
+ // `source.end.offset` is exclusive, so we don't need to add 1
2608
+ this.source.end.offset
2609
+ ) : (
2610
+ // Since line/column in this.source.end is inclusive,
2611
+ // the `sourceOffset(... , this.source.end)` returns an inclusive offset.
2612
+ // So, we add 1 to convert it to exclusive.
2613
+ sourceOffset$1(inputString, this.source.end) + 1
2614
+ )
2395
2615
  } : {
2396
2616
  column: start.column + 1,
2397
- line: start.line
2617
+ line: start.line,
2618
+ offset: start.offset + 1
2398
2619
  };
2399
2620
  if (opts.word) {
2400
- let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
2401
2621
  let stringRepresentation = inputString.slice(
2402
2622
  sourceOffset$1(inputString, this.source.start),
2403
2623
  sourceOffset$1(inputString, this.source.end)
@@ -2405,15 +2625,14 @@ let Node$4$1 = class Node2 {
2405
2625
  let index2 = stringRepresentation.indexOf(opts.word);
2406
2626
  if (index2 !== -1) {
2407
2627
  start = this.positionInside(index2);
2408
- end = this.positionInside(
2409
- index2 + opts.word.length
2410
- );
2628
+ end = this.positionInside(index2 + opts.word.length);
2411
2629
  }
2412
2630
  } else {
2413
2631
  if (opts.start) {
2414
2632
  start = {
2415
2633
  column: opts.start.column,
2416
- line: opts.start.line
2634
+ line: opts.start.line,
2635
+ offset: sourceOffset$1(inputString, opts.start)
2417
2636
  };
2418
2637
  } else if (opts.index) {
2419
2638
  start = this.positionInside(opts.index);
@@ -2421,7 +2640,8 @@ let Node$4$1 = class Node2 {
2421
2640
  if (opts.end) {
2422
2641
  end = {
2423
2642
  column: opts.end.column,
2424
- line: opts.end.line
2643
+ line: opts.end.line,
2644
+ offset: sourceOffset$1(inputString, opts.end)
2425
2645
  };
2426
2646
  } else if (typeof opts.endIndex === "number") {
2427
2647
  end = this.positionInside(opts.endIndex);
@@ -2430,7 +2650,11 @@ let Node$4$1 = class Node2 {
2430
2650
  }
2431
2651
  }
2432
2652
  if (end.line < start.line || end.line === start.line && end.column <= start.column) {
2433
- end = { column: start.column + 1, line: start.line };
2653
+ end = {
2654
+ column: start.column + 1,
2655
+ line: start.line,
2656
+ offset: start.offset + 1
2657
+ };
2434
2658
  }
2435
2659
  return { end, start };
2436
2660
  }
@@ -2494,6 +2718,7 @@ let Node$4$1 = class Node2 {
2494
2718
  } else if (typeof value === "object" && value.toJSON) {
2495
2719
  fixed[name] = value.toJSON(null, inputs);
2496
2720
  } else if (name === "source") {
2721
+ if (value == null) continue;
2497
2722
  let inputId = inputs.get(value.input);
2498
2723
  if (inputId == null) {
2499
2724
  inputId = inputsNextIndex;
@@ -2528,7 +2753,7 @@ let Node$4$1 = class Node2 {
2528
2753
  });
2529
2754
  return result2;
2530
2755
  }
2531
- warn(result2, text, opts) {
2756
+ warn(result2, text, opts = {}) {
2532
2757
  let data = { node: this };
2533
2758
  for (let i2 in opts) data[i2] = opts[i2];
2534
2759
  return result2.warn(text, data);
@@ -3105,9 +3330,21 @@ let { fileURLToPath: fileURLToPath$1, pathToFileURL: pathToFileURL$1$1 } = requi
3105
3330
  let CssSyntaxError$1$1 = cssSyntaxError$1;
3106
3331
  let PreviousMap$1$1 = previousMap$1;
3107
3332
  let terminalHighlight$2 = require$$2$1;
3108
- let fromOffsetCache$1 = Symbol("fromOffsetCache");
3333
+ let lineToIndexCache$1 = Symbol("lineToIndexCache");
3109
3334
  let sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1);
3110
3335
  let pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1);
3336
+ function getLineToIndex$1(input2) {
3337
+ if (input2[lineToIndexCache$1]) return input2[lineToIndexCache$1];
3338
+ let lines = input2.css.split("\n");
3339
+ let lineToIndex = new Array(lines.length);
3340
+ let prevIndex = 0;
3341
+ for (let i2 = 0, l2 = lines.length; i2 < l2; i2++) {
3342
+ lineToIndex[i2] = prevIndex;
3343
+ prevIndex += lines[i2].length + 1;
3344
+ }
3345
+ input2[lineToIndexCache$1] = lineToIndex;
3346
+ return lineToIndex;
3347
+ }
3111
3348
  let Input$4$1 = class Input {
3112
3349
  get from() {
3113
3350
  return this.file || this.id;
@@ -3146,30 +3383,37 @@ let Input$4$1 = class Input {
3146
3383
  if (this.map) this.map.file = this.from;
3147
3384
  }
3148
3385
  error(message, line, column, opts = {}) {
3149
- let endColumn, endLine, result2;
3386
+ let endColumn, endLine, endOffset, offset, result2;
3150
3387
  if (line && typeof line === "object") {
3151
3388
  let start = line;
3152
3389
  let end = column;
3153
3390
  if (typeof start.offset === "number") {
3154
- let pos = this.fromOffset(start.offset);
3391
+ offset = start.offset;
3392
+ let pos = this.fromOffset(offset);
3155
3393
  line = pos.line;
3156
3394
  column = pos.col;
3157
3395
  } else {
3158
3396
  line = start.line;
3159
3397
  column = start.column;
3398
+ offset = this.fromLineAndColumn(line, column);
3160
3399
  }
3161
3400
  if (typeof end.offset === "number") {
3162
- let pos = this.fromOffset(end.offset);
3401
+ endOffset = end.offset;
3402
+ let pos = this.fromOffset(endOffset);
3163
3403
  endLine = pos.line;
3164
3404
  endColumn = pos.col;
3165
3405
  } else {
3166
3406
  endLine = end.line;
3167
3407
  endColumn = end.column;
3408
+ endOffset = this.fromLineAndColumn(end.line, end.column);
3168
3409
  }
3169
3410
  } else if (!column) {
3170
- let pos = this.fromOffset(line);
3411
+ offset = line;
3412
+ let pos = this.fromOffset(offset);
3171
3413
  line = pos.line;
3172
3414
  column = pos.col;
3415
+ } else {
3416
+ offset = this.fromLineAndColumn(line, column);
3173
3417
  }
3174
3418
  let origin = this.origin(line, column, endLine, endColumn);
3175
3419
  if (origin) {
@@ -3191,7 +3435,7 @@ let Input$4$1 = class Input {
3191
3435
  opts.plugin
3192
3436
  );
3193
3437
  }
3194
- result2.input = { column, endColumn, endLine, line, source: this.css };
3438
+ result2.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css };
3195
3439
  if (this.file) {
3196
3440
  if (pathToFileURL$1$1) {
3197
3441
  result2.input.url = pathToFileURL$1$1(this.file).toString();
@@ -3200,21 +3444,14 @@ let Input$4$1 = class Input {
3200
3444
  }
3201
3445
  return result2;
3202
3446
  }
3447
+ fromLineAndColumn(line, column) {
3448
+ let lineToIndex = getLineToIndex$1(this);
3449
+ let index2 = lineToIndex[line - 1];
3450
+ return index2 + column - 1;
3451
+ }
3203
3452
  fromOffset(offset) {
3204
- let lastLine, lineToIndex;
3205
- if (!this[fromOffsetCache$1]) {
3206
- let lines = this.css.split("\n");
3207
- lineToIndex = new Array(lines.length);
3208
- let prevIndex = 0;
3209
- for (let i2 = 0, l2 = lines.length; i2 < l2; i2++) {
3210
- lineToIndex[i2] = prevIndex;
3211
- prevIndex += lines[i2].length + 1;
3212
- }
3213
- this[fromOffsetCache$1] = lineToIndex;
3214
- } else {
3215
- lineToIndex = this[fromOffsetCache$1];
3216
- }
3217
- lastLine = lineToIndex[lineToIndex.length - 1];
3453
+ let lineToIndex = getLineToIndex$1(this);
3454
+ let lastLine = lineToIndex[lineToIndex.length - 1];
3218
3455
  let min = 0;
3219
3456
  if (offset >= lastLine) {
3220
3457
  min = lineToIndex.length - 1;
@@ -4576,7 +4813,7 @@ let Result$3$1 = class Result {
4576
4813
  this.messages = [];
4577
4814
  this.root = root2;
4578
4815
  this.opts = opts;
4579
- this.css = void 0;
4816
+ this.css = "";
4580
4817
  this.map = void 0;
4581
4818
  }
4582
4819
  toString() {
@@ -5188,7 +5425,7 @@ let NoWorkResult2$1 = noWorkResult$1;
5188
5425
  let Root$1$1 = root$1;
5189
5426
  let Processor$1$1 = class Processor {
5190
5427
  constructor(plugins = []) {
5191
- this.version = "8.5.3";
5428
+ this.version = "8.5.4";
5192
5429
  this.plugins = this.normalize(plugins);
5193
5430
  }
5194
5431
  normalize(plugins) {
@@ -5342,6 +5579,325 @@ postcss$1$1.Node;
5342
5579
  var __defProp2 = Object.defineProperty;
5343
5580
  var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5344
5581
  var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
5582
+ var __defProp22 = Object.defineProperty;
5583
+ var __defNormalProp22 = (obj, key, value) => key in obj ? __defProp22(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5584
+ var __publicField22 = (obj, key, value) => __defNormalProp22(obj, typeof key !== "symbol" ? key + "" : key, value);
5585
+ const shouldTryAnonymousFetchingOnCorsError = () => {
5586
+ return !("_rrweb_skip_re_fetching_to_suppress_cors_errors" in window && window._rrweb_skip_re_fetching_to_suppress_cors_errors === true);
5587
+ };
5588
+ function fixBrowserCompatibilityIssuesInCSS(cssText) {
5589
+ if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
5590
+ cssText = cssText.replace(
5591
+ /\sbackground-clip:\s*text;/g,
5592
+ " -webkit-background-clip: text; background-clip: text;"
5593
+ );
5594
+ }
5595
+ return cssText;
5596
+ }
5597
+ function escapeImportStatement(rule2) {
5598
+ const { cssText } = rule2;
5599
+ if (cssText.split('"').length < 3) return cssText;
5600
+ const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
5601
+ if (rule2.layerName === "") {
5602
+ statement.push(`layer`);
5603
+ } else if (rule2.layerName) {
5604
+ statement.push(`layer(${rule2.layerName})`);
5605
+ }
5606
+ if (rule2.supportsText) {
5607
+ statement.push(`supports(${rule2.supportsText})`);
5608
+ }
5609
+ if (rule2.media.length) {
5610
+ statement.push(rule2.media.mediaText);
5611
+ }
5612
+ return statement.join(" ") + ";";
5613
+ }
5614
+ function stringifyStylesheet(s2) {
5615
+ try {
5616
+ const rules2 = s2.rules || s2.cssRules;
5617
+ if (!rules2) {
5618
+ return null;
5619
+ }
5620
+ let sheetHref = s2.href;
5621
+ if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
5622
+ sheetHref = s2.ownerNode.ownerDocument.location.href;
5623
+ }
5624
+ const stringifiedRules = Array.from(
5625
+ rules2,
5626
+ (rule2) => stringifyRule(rule2, sheetHref)
5627
+ ).join("");
5628
+ return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
5629
+ } catch (error) {
5630
+ return null;
5631
+ }
5632
+ }
5633
+ function stringifyRule(rule2, sheetHref) {
5634
+ if (isCSSImportRule(rule2)) {
5635
+ let importStringified;
5636
+ try {
5637
+ importStringified = // for same-origin stylesheets,
5638
+ // we can access the imported stylesheet rules directly
5639
+ stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
5640
+ escapeImportStatement(rule2);
5641
+ } catch (error) {
5642
+ importStringified = rule2.cssText;
5643
+ }
5644
+ if (rule2.styleSheet.href) {
5645
+ return absolutifyURLs(importStringified, rule2.styleSheet.href);
5646
+ }
5647
+ return importStringified;
5648
+ } else {
5649
+ let ruleStringified = rule2.cssText;
5650
+ if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
5651
+ ruleStringified = fixSafariColons(ruleStringified);
5652
+ }
5653
+ if (sheetHref) {
5654
+ return absolutifyURLs(ruleStringified, sheetHref);
5655
+ }
5656
+ return ruleStringified;
5657
+ }
5658
+ }
5659
+ function fixSafariColons(cssStringified) {
5660
+ const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
5661
+ return cssStringified.replace(regex, "$1\\$2");
5662
+ }
5663
+ function isCSSImportRule(rule2) {
5664
+ return "styleSheet" in rule2;
5665
+ }
5666
+ function isCSSStyleRule(rule2) {
5667
+ return "selectorText" in rule2;
5668
+ }
5669
+ function extractOrigin(url) {
5670
+ let origin = "";
5671
+ if (url.indexOf("//") > -1) {
5672
+ origin = url.split("/").slice(0, 3).join("/");
5673
+ } else {
5674
+ origin = url.split("/")[0];
5675
+ }
5676
+ origin = origin.split("?")[0];
5677
+ return origin;
5678
+ }
5679
+ const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
5680
+ const URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
5681
+ const URL_WWW_MATCH = /^www\..*/i;
5682
+ const DATA_URI = /^(data:)([^,]*),(.*)/i;
5683
+ function absolutifyURLs(cssText, href) {
5684
+ return (cssText || "").replace(
5685
+ URL_IN_CSS_REF,
5686
+ (origin, quote1, path1, quote2, path2, path3) => {
5687
+ const filePath = path1 || path2 || path3;
5688
+ const maybeQuote = quote1 || quote2 || "";
5689
+ if (!filePath) {
5690
+ return origin;
5691
+ }
5692
+ if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
5693
+ return `url(${maybeQuote}${filePath}${maybeQuote})`;
5694
+ }
5695
+ if (DATA_URI.test(filePath)) {
5696
+ return `url(${maybeQuote}${filePath}${maybeQuote})`;
5697
+ }
5698
+ if (filePath[0] === "/") {
5699
+ return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
5700
+ }
5701
+ const stack = href.split("/");
5702
+ const parts = filePath.split("/");
5703
+ stack.pop();
5704
+ for (const part of parts) {
5705
+ if (part === ".") {
5706
+ continue;
5707
+ } else if (part === "..") {
5708
+ stack.pop();
5709
+ } else {
5710
+ stack.push(part);
5711
+ }
5712
+ }
5713
+ return `url(${maybeQuote}${stack.join("/")}${maybeQuote})`;
5714
+ }
5715
+ );
5716
+ }
5717
+ const CLEANUP_DEBOUNCE_TIME = 1e3 * 30;
5718
+ const DATA_ATTRIBUTE_CLONED_NAME = "data-rrweb-link-cloned";
5719
+ const DISALLOWED_EXTENSIONS = [
5720
+ // Fonts
5721
+ "woff",
5722
+ "woff2",
5723
+ "ttf",
5724
+ "otf",
5725
+ // Embedded OpenType font
5726
+ "eot",
5727
+ // Images
5728
+ "png",
5729
+ "jpg",
5730
+ "jpeg",
5731
+ "gif",
5732
+ "svg",
5733
+ "webp",
5734
+ "ico",
5735
+ // Scripts
5736
+ "js",
5737
+ "mjs",
5738
+ "ts",
5739
+ "jsx",
5740
+ "tsx",
5741
+ // Data files
5742
+ "json",
5743
+ "map",
5744
+ // Media
5745
+ "mp4",
5746
+ "webm",
5747
+ "ogg",
5748
+ "mp3",
5749
+ "wav",
5750
+ // Archives
5751
+ "zip",
5752
+ "rar",
5753
+ "7z",
5754
+ "tar",
5755
+ "gz",
5756
+ // Documents
5757
+ "pdf",
5758
+ "doc",
5759
+ "docx",
5760
+ "xls",
5761
+ "xlsx"
5762
+ ];
5763
+ const _AsyncStylesheetManager2 = class _AsyncStylesheetManager22 {
5764
+ constructor() {
5765
+ __publicField22(this, "currentHref", null);
5766
+ __publicField22(this, "clones", {});
5767
+ __publicField22(this, "cleanTimeout", null);
5768
+ if (_AsyncStylesheetManager22.instance) return _AsyncStylesheetManager22.instance;
5769
+ _AsyncStylesheetManager22.instance = this;
5770
+ }
5771
+ removeCloneNode(href) {
5772
+ var _a2;
5773
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
5774
+ const clone = document.querySelector(
5775
+ `link[${DATA_ATTRIBUTE_CLONED_NAME}="${this.clones[href].cloneNodeAttrId}"]`
5776
+ );
5777
+ if (!clone) return;
5778
+ (_a2 = clone.parentNode) == null ? void 0 : _a2.removeChild(clone);
5779
+ }
5780
+ onLoad(href) {
5781
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
5782
+ const styleSheets2 = Array.from(document.styleSheets);
5783
+ let clonedStyleSheet = null;
5784
+ for (let i2 = styleSheets2.length - 1; i2 >= 0; i2--) {
5785
+ if (styleSheets2[i2].href === href) {
5786
+ clonedStyleSheet = styleSheets2[i2];
5787
+ break;
5788
+ }
5789
+ }
5790
+ if (!clonedStyleSheet) return this.removeCloneNode(href);
5791
+ const newCssText = stringifyStylesheet(clonedStyleSheet);
5792
+ this.removeCloneNode(href);
5793
+ if (!newCssText) return;
5794
+ this.clones[href].cssText = newCssText;
5795
+ this.clones[href].loaded = true;
5796
+ const original = document.querySelector(
5797
+ `link[${DATA_ATTRIBUTE_CLONED_NAME}="source-${this.clones[href].cloneNodeAttrId}"]`
5798
+ );
5799
+ if (original) {
5800
+ original.setAttribute("data-rrweb-mutation", Date.now().toString());
5801
+ original.removeAttribute(DATA_ATTRIBUTE_CLONED_NAME);
5802
+ } else {
5803
+ this.clones[href].original.setAttribute(
5804
+ "data-rrweb-mutation",
5805
+ Date.now().toString()
5806
+ );
5807
+ this.clones[href].original.removeAttribute(DATA_ATTRIBUTE_CLONED_NAME);
5808
+ }
5809
+ window.dispatchEvent(
5810
+ new CustomEvent("__rrweb_custom_event__", {
5811
+ detail: {
5812
+ type: 5,
5813
+ timestamp: Date.now(),
5814
+ data: {
5815
+ tag: "async-css-resolution",
5816
+ requestCssId: this.clones[href].requestCssId,
5817
+ cssText: this.clones[href].cssText
5818
+ }
5819
+ }
5820
+ })
5821
+ );
5822
+ }
5823
+ onLoadError(href) {
5824
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
5825
+ this.removeCloneNode(href);
5826
+ }
5827
+ removeAllCloneElements() {
5828
+ for (const href of Object.keys(this.clones)) {
5829
+ this.removeCloneNode(href);
5830
+ }
5831
+ }
5832
+ onCleanTimeout() {
5833
+ asyncStylesheetManager.cleanTimeout = null;
5834
+ asyncStylesheetManager.removeAllCloneElements();
5835
+ }
5836
+ blowCache() {
5837
+ this.removeAllCloneElements();
5838
+ this.clones = {};
5839
+ }
5840
+ requestClone({
5841
+ forElement,
5842
+ requestCssId
5843
+ }) {
5844
+ if (!shouldTryAnonymousFetchingOnCorsError()) return;
5845
+ if (this.currentHref != null && document.location.href !== this.currentHref)
5846
+ this.blowCache();
5847
+ this.currentHref = document.location.href;
5848
+ const href = forElement.href;
5849
+ if (!href) return;
5850
+ if (href in this.clones && this.clones[href] !== void 0) return;
5851
+ if (forElement.getAttribute("crossorigin") === "anonymous") return;
5852
+ if (forElement.rel !== "stylesheet") {
5853
+ const last = href.split("/").pop();
5854
+ if (last && last.includes(".")) {
5855
+ const [filename] = last.split("?");
5856
+ const ext = filename.split(".").pop();
5857
+ if (ext) {
5858
+ if (DISALLOWED_EXTENSIONS.includes(ext.trim().toLowerCase())) return;
5859
+ }
5860
+ }
5861
+ }
5862
+ const clone = forElement.cloneNode();
5863
+ const cloneNodeAttrId = Math.random().toString(36).slice(2);
5864
+ clone.setAttribute("crossorigin", "anonymous");
5865
+ clone.setAttribute(DATA_ATTRIBUTE_CLONED_NAME, cloneNodeAttrId);
5866
+ forElement.setAttribute(
5867
+ DATA_ATTRIBUTE_CLONED_NAME,
5868
+ `source-${cloneNodeAttrId}`
5869
+ );
5870
+ document.head.appendChild(clone);
5871
+ this.clones[href] = {
5872
+ original: forElement,
5873
+ clone,
5874
+ loaded: false,
5875
+ cssText: null,
5876
+ cloneNodeAttrId,
5877
+ requestCssId
5878
+ };
5879
+ clone.onload = () => {
5880
+ this.onLoad(href);
5881
+ };
5882
+ clone.onerror = () => {
5883
+ this.onLoadError(href);
5884
+ };
5885
+ if (this.cleanTimeout) clearTimeout(this.cleanTimeout);
5886
+ this.cleanTimeout = setTimeout(
5887
+ asyncStylesheetManager.onCleanTimeout,
5888
+ CLEANUP_DEBOUNCE_TIME
5889
+ );
5890
+ }
5891
+ getClonedCssTextIfAvailable(href) {
5892
+ if (href in this.clones && this.clones[href] !== void 0 && this.clones[href].loaded === true) {
5893
+ return this.clones[href].cssText;
5894
+ }
5895
+ return null;
5896
+ }
5897
+ };
5898
+ __publicField22(_AsyncStylesheetManager2, "instance");
5899
+ let AsyncStylesheetManager = _AsyncStylesheetManager2;
5900
+ const asyncStylesheetManager = new AsyncStylesheetManager();
5345
5901
  function getDefaultExportFromCjs(x2) {
5346
5902
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
5347
5903
  }
@@ -5949,7 +6505,7 @@ let Node$4 = class Node3 {
5949
6505
  let index2 = this.parent.index(this);
5950
6506
  return this.parent.nodes[index2 + 1];
5951
6507
  }
5952
- positionBy(opts) {
6508
+ positionBy(opts = {}) {
5953
6509
  let pos = this.source.start;
5954
6510
  if (opts.index) {
5955
6511
  pos = this.positionInside(opts.index);
@@ -5978,27 +6534,38 @@ let Node$4 = class Node3 {
5978
6534
  column += 1;
5979
6535
  }
5980
6536
  }
5981
- return { column, line };
6537
+ return { column, line, offset: end };
5982
6538
  }
5983
6539
  prev() {
5984
6540
  if (!this.parent) return void 0;
5985
6541
  let index2 = this.parent.index(this);
5986
6542
  return this.parent.nodes[index2 - 1];
5987
6543
  }
5988
- rangeBy(opts) {
6544
+ rangeBy(opts = {}) {
6545
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
5989
6546
  let start = {
5990
6547
  column: this.source.start.column,
5991
- line: this.source.start.line
6548
+ line: this.source.start.line,
6549
+ offset: sourceOffset(inputString, this.source.start)
5992
6550
  };
5993
6551
  let end = this.source.end ? {
5994
6552
  column: this.source.end.column + 1,
5995
- line: this.source.end.line
6553
+ line: this.source.end.line,
6554
+ offset: typeof this.source.end.offset === "number" ? (
6555
+ // `source.end.offset` is exclusive, so we don't need to add 1
6556
+ this.source.end.offset
6557
+ ) : (
6558
+ // Since line/column in this.source.end is inclusive,
6559
+ // the `sourceOffset(... , this.source.end)` returns an inclusive offset.
6560
+ // So, we add 1 to convert it to exclusive.
6561
+ sourceOffset(inputString, this.source.end) + 1
6562
+ )
5996
6563
  } : {
5997
6564
  column: start.column + 1,
5998
- line: start.line
6565
+ line: start.line,
6566
+ offset: start.offset + 1
5999
6567
  };
6000
6568
  if (opts.word) {
6001
- let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
6002
6569
  let stringRepresentation = inputString.slice(
6003
6570
  sourceOffset(inputString, this.source.start),
6004
6571
  sourceOffset(inputString, this.source.end)
@@ -6006,15 +6573,14 @@ let Node$4 = class Node3 {
6006
6573
  let index2 = stringRepresentation.indexOf(opts.word);
6007
6574
  if (index2 !== -1) {
6008
6575
  start = this.positionInside(index2);
6009
- end = this.positionInside(
6010
- index2 + opts.word.length
6011
- );
6576
+ end = this.positionInside(index2 + opts.word.length);
6012
6577
  }
6013
6578
  } else {
6014
6579
  if (opts.start) {
6015
6580
  start = {
6016
6581
  column: opts.start.column,
6017
- line: opts.start.line
6582
+ line: opts.start.line,
6583
+ offset: sourceOffset(inputString, opts.start)
6018
6584
  };
6019
6585
  } else if (opts.index) {
6020
6586
  start = this.positionInside(opts.index);
@@ -6022,7 +6588,8 @@ let Node$4 = class Node3 {
6022
6588
  if (opts.end) {
6023
6589
  end = {
6024
6590
  column: opts.end.column,
6025
- line: opts.end.line
6591
+ line: opts.end.line,
6592
+ offset: sourceOffset(inputString, opts.end)
6026
6593
  };
6027
6594
  } else if (typeof opts.endIndex === "number") {
6028
6595
  end = this.positionInside(opts.endIndex);
@@ -6031,7 +6598,11 @@ let Node$4 = class Node3 {
6031
6598
  }
6032
6599
  }
6033
6600
  if (end.line < start.line || end.line === start.line && end.column <= start.column) {
6034
- end = { column: start.column + 1, line: start.line };
6601
+ end = {
6602
+ column: start.column + 1,
6603
+ line: start.line,
6604
+ offset: start.offset + 1
6605
+ };
6035
6606
  }
6036
6607
  return { end, start };
6037
6608
  }
@@ -6095,6 +6666,7 @@ let Node$4 = class Node3 {
6095
6666
  } else if (typeof value === "object" && value.toJSON) {
6096
6667
  fixed[name] = value.toJSON(null, inputs);
6097
6668
  } else if (name === "source") {
6669
+ if (value == null) continue;
6098
6670
  let inputId = inputs.get(value.input);
6099
6671
  if (inputId == null) {
6100
6672
  inputId = inputsNextIndex;
@@ -6129,7 +6701,7 @@ let Node$4 = class Node3 {
6129
6701
  });
6130
6702
  return result2;
6131
6703
  }
6132
- warn(result2, text, opts) {
6704
+ warn(result2, text, opts = {}) {
6133
6705
  let data = { node: this };
6134
6706
  for (let i2 in opts) data[i2] = opts[i2];
6135
6707
  return result2.warn(text, data);
@@ -6706,9 +7278,21 @@ let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
6706
7278
  let CssSyntaxError$1 = cssSyntaxError;
6707
7279
  let PreviousMap$1 = previousMap;
6708
7280
  let terminalHighlight = require$$2;
6709
- let fromOffsetCache = Symbol("fromOffsetCache");
7281
+ let lineToIndexCache = Symbol("lineToIndexCache");
6710
7282
  let sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
6711
7283
  let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
7284
+ function getLineToIndex(input2) {
7285
+ if (input2[lineToIndexCache]) return input2[lineToIndexCache];
7286
+ let lines = input2.css.split("\n");
7287
+ let lineToIndex = new Array(lines.length);
7288
+ let prevIndex = 0;
7289
+ for (let i2 = 0, l2 = lines.length; i2 < l2; i2++) {
7290
+ lineToIndex[i2] = prevIndex;
7291
+ prevIndex += lines[i2].length + 1;
7292
+ }
7293
+ input2[lineToIndexCache] = lineToIndex;
7294
+ return lineToIndex;
7295
+ }
6712
7296
  let Input$4 = class Input2 {
6713
7297
  get from() {
6714
7298
  return this.file || this.id;
@@ -6747,30 +7331,37 @@ let Input$4 = class Input2 {
6747
7331
  if (this.map) this.map.file = this.from;
6748
7332
  }
6749
7333
  error(message, line, column, opts = {}) {
6750
- let endColumn, endLine, result2;
7334
+ let endColumn, endLine, endOffset, offset, result2;
6751
7335
  if (line && typeof line === "object") {
6752
7336
  let start = line;
6753
7337
  let end = column;
6754
7338
  if (typeof start.offset === "number") {
6755
- let pos = this.fromOffset(start.offset);
7339
+ offset = start.offset;
7340
+ let pos = this.fromOffset(offset);
6756
7341
  line = pos.line;
6757
7342
  column = pos.col;
6758
7343
  } else {
6759
7344
  line = start.line;
6760
7345
  column = start.column;
7346
+ offset = this.fromLineAndColumn(line, column);
6761
7347
  }
6762
7348
  if (typeof end.offset === "number") {
6763
- let pos = this.fromOffset(end.offset);
7349
+ endOffset = end.offset;
7350
+ let pos = this.fromOffset(endOffset);
6764
7351
  endLine = pos.line;
6765
7352
  endColumn = pos.col;
6766
7353
  } else {
6767
7354
  endLine = end.line;
6768
7355
  endColumn = end.column;
7356
+ endOffset = this.fromLineAndColumn(end.line, end.column);
6769
7357
  }
6770
7358
  } else if (!column) {
6771
- let pos = this.fromOffset(line);
7359
+ offset = line;
7360
+ let pos = this.fromOffset(offset);
6772
7361
  line = pos.line;
6773
7362
  column = pos.col;
7363
+ } else {
7364
+ offset = this.fromLineAndColumn(line, column);
6774
7365
  }
6775
7366
  let origin = this.origin(line, column, endLine, endColumn);
6776
7367
  if (origin) {
@@ -6792,7 +7383,7 @@ let Input$4 = class Input2 {
6792
7383
  opts.plugin
6793
7384
  );
6794
7385
  }
6795
- result2.input = { column, endColumn, endLine, line, source: this.css };
7386
+ result2.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css };
6796
7387
  if (this.file) {
6797
7388
  if (pathToFileURL$1) {
6798
7389
  result2.input.url = pathToFileURL$1(this.file).toString();
@@ -6801,21 +7392,14 @@ let Input$4 = class Input2 {
6801
7392
  }
6802
7393
  return result2;
6803
7394
  }
7395
+ fromLineAndColumn(line, column) {
7396
+ let lineToIndex = getLineToIndex(this);
7397
+ let index2 = lineToIndex[line - 1];
7398
+ return index2 + column - 1;
7399
+ }
6804
7400
  fromOffset(offset) {
6805
- let lastLine, lineToIndex;
6806
- if (!this[fromOffsetCache]) {
6807
- let lines = this.css.split("\n");
6808
- lineToIndex = new Array(lines.length);
6809
- let prevIndex = 0;
6810
- for (let i2 = 0, l2 = lines.length; i2 < l2; i2++) {
6811
- lineToIndex[i2] = prevIndex;
6812
- prevIndex += lines[i2].length + 1;
6813
- }
6814
- this[fromOffsetCache] = lineToIndex;
6815
- } else {
6816
- lineToIndex = this[fromOffsetCache];
6817
- }
6818
- lastLine = lineToIndex[lineToIndex.length - 1];
7401
+ let lineToIndex = getLineToIndex(this);
7402
+ let lastLine = lineToIndex[lineToIndex.length - 1];
6819
7403
  let min = 0;
6820
7404
  if (offset >= lastLine) {
6821
7405
  min = lineToIndex.length - 1;
@@ -8177,7 +8761,7 @@ let Result$3 = class Result2 {
8177
8761
  this.messages = [];
8178
8762
  this.root = root2;
8179
8763
  this.opts = opts;
8180
- this.css = void 0;
8764
+ this.css = "";
8181
8765
  this.map = void 0;
8182
8766
  }
8183
8767
  toString() {
@@ -8789,7 +9373,7 @@ let NoWorkResult22 = noWorkResult;
8789
9373
  let Root$1 = root;
8790
9374
  let Processor$1 = class Processor2 {
8791
9375
  constructor(plugins = []) {
8792
- this.version = "8.5.3";
9376
+ this.version = "8.5.4";
8793
9377
  this.plugins = this.normalize(plugins);
8794
9378
  }
8795
9379
  normalize(plugins) {
@@ -12068,7 +12652,7 @@ class StylesheetManager {
12068
12652
  styles.push({
12069
12653
  styleId,
12070
12654
  rules: Array.from(sheet.rules || CSSRule, (r2, index2) => ({
12071
- rule: stringifyRule(r2, sheet.href),
12655
+ rule: stringifyRule$1(r2, sheet.href),
12072
12656
  index: index2
12073
12657
  }))
12074
12658
  });
@@ -12528,12 +13112,26 @@ function record(options = {}) {
12528
13112
  console.warn(error);
12529
13113
  }
12530
13114
  });
13115
+ let initedAt = null;
12531
13116
  const init = () => {
13117
+ initedAt = Date.now();
12532
13118
  takeFullSnapshot$1();
12533
13119
  handlers.push(observe(document));
12534
13120
  recording = true;
12535
13121
  };
13122
+ const customOnLoad = () => {
13123
+ window.removeEventListener("load", customOnLoad);
13124
+ if (!recording || initedAt == null) return;
13125
+ if (Date.now() - initedAt <= 10) {
13126
+ return;
13127
+ }
13128
+ takeFullSnapshot$1();
13129
+ };
13130
+ window.addEventListener("load", customOnLoad);
12536
13131
  if (document.readyState === "interactive" || document.readyState === "complete") {
13132
+ if (document.readyState === "complete") {
13133
+ window.removeEventListener("load", customOnLoad);
13134
+ }
12537
13135
  init();
12538
13136
  } else {
12539
13137
  handlers.push(
@@ -12542,7 +13140,9 @@ function record(options = {}) {
12542
13140
  type: EventType.DomContentLoaded,
12543
13141
  data: {}
12544
13142
  });
12545
- if (recordAfter === "DOMContentLoaded") init();
13143
+ if (recordAfter === "DOMContentLoaded") {
13144
+ init();
13145
+ }
12546
13146
  })
12547
13147
  );
12548
13148
  handlers.push(
@@ -12553,7 +13153,9 @@ function record(options = {}) {
12553
13153
  type: EventType.Load,
12554
13154
  data: {}
12555
13155
  });
12556
- if (recordAfter === "load") init();
13156
+ if (recordAfter === "load") {
13157
+ init();
13158
+ }
12557
13159
  },
12558
13160
  window
12559
13161
  )