@glimt/record 0.0.48 → 0.0.49

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) {
@@ -1308,18 +1512,20 @@ function serializeElementNode(n2, options) {
1308
1512
  );
1309
1513
  } catch (err) {
1310
1514
  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 });
1515
+ if (shouldTryAnonymousFetchingOnCorsError$1()) {
1516
+ image = new Image();
1517
+ image.src = imageSrc;
1518
+ image.crossOrigin = "anonymous";
1519
+ image.height = imageHeight;
1520
+ image.width = imageWidth;
1521
+ if (image.complete && image.naturalWidth !== 0) {
1522
+ recordInlineImage();
1523
+ } else {
1524
+ image.addEventListener("load", recordInlineImage, { once: true });
1525
+ image.addEventListener("error", onImageLoadError, { once: true });
1526
+ }
1527
+ return;
1321
1528
  }
1322
- return;
1323
1529
  } else {
1324
1530
  console.warn(
1325
1531
  `Cannot inline img src=${imageSrc}! Error: ${err}`
@@ -2348,7 +2554,7 @@ let Node$4$1 = class Node2 {
2348
2554
  let index2 = this.parent.index(this);
2349
2555
  return this.parent.nodes[index2 + 1];
2350
2556
  }
2351
- positionBy(opts) {
2557
+ positionBy(opts = {}) {
2352
2558
  let pos = this.source.start;
2353
2559
  if (opts.index) {
2354
2560
  pos = this.positionInside(opts.index);
@@ -2377,27 +2583,38 @@ let Node$4$1 = class Node2 {
2377
2583
  column += 1;
2378
2584
  }
2379
2585
  }
2380
- return { column, line };
2586
+ return { column, line, offset: end };
2381
2587
  }
2382
2588
  prev() {
2383
2589
  if (!this.parent) return void 0;
2384
2590
  let index2 = this.parent.index(this);
2385
2591
  return this.parent.nodes[index2 - 1];
2386
2592
  }
2387
- rangeBy(opts) {
2593
+ rangeBy(opts = {}) {
2594
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
2388
2595
  let start = {
2389
2596
  column: this.source.start.column,
2390
- line: this.source.start.line
2597
+ line: this.source.start.line,
2598
+ offset: sourceOffset$1(inputString, this.source.start)
2391
2599
  };
2392
2600
  let end = this.source.end ? {
2393
2601
  column: this.source.end.column + 1,
2394
- line: this.source.end.line
2602
+ line: this.source.end.line,
2603
+ offset: typeof this.source.end.offset === "number" ? (
2604
+ // `source.end.offset` is exclusive, so we don't need to add 1
2605
+ this.source.end.offset
2606
+ ) : (
2607
+ // Since line/column in this.source.end is inclusive,
2608
+ // the `sourceOffset(... , this.source.end)` returns an inclusive offset.
2609
+ // So, we add 1 to convert it to exclusive.
2610
+ sourceOffset$1(inputString, this.source.end) + 1
2611
+ )
2395
2612
  } : {
2396
2613
  column: start.column + 1,
2397
- line: start.line
2614
+ line: start.line,
2615
+ offset: start.offset + 1
2398
2616
  };
2399
2617
  if (opts.word) {
2400
- let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
2401
2618
  let stringRepresentation = inputString.slice(
2402
2619
  sourceOffset$1(inputString, this.source.start),
2403
2620
  sourceOffset$1(inputString, this.source.end)
@@ -2405,15 +2622,14 @@ let Node$4$1 = class Node2 {
2405
2622
  let index2 = stringRepresentation.indexOf(opts.word);
2406
2623
  if (index2 !== -1) {
2407
2624
  start = this.positionInside(index2);
2408
- end = this.positionInside(
2409
- index2 + opts.word.length
2410
- );
2625
+ end = this.positionInside(index2 + opts.word.length);
2411
2626
  }
2412
2627
  } else {
2413
2628
  if (opts.start) {
2414
2629
  start = {
2415
2630
  column: opts.start.column,
2416
- line: opts.start.line
2631
+ line: opts.start.line,
2632
+ offset: sourceOffset$1(inputString, opts.start)
2417
2633
  };
2418
2634
  } else if (opts.index) {
2419
2635
  start = this.positionInside(opts.index);
@@ -2421,7 +2637,8 @@ let Node$4$1 = class Node2 {
2421
2637
  if (opts.end) {
2422
2638
  end = {
2423
2639
  column: opts.end.column,
2424
- line: opts.end.line
2640
+ line: opts.end.line,
2641
+ offset: sourceOffset$1(inputString, opts.end)
2425
2642
  };
2426
2643
  } else if (typeof opts.endIndex === "number") {
2427
2644
  end = this.positionInside(opts.endIndex);
@@ -2430,7 +2647,11 @@ let Node$4$1 = class Node2 {
2430
2647
  }
2431
2648
  }
2432
2649
  if (end.line < start.line || end.line === start.line && end.column <= start.column) {
2433
- end = { column: start.column + 1, line: start.line };
2650
+ end = {
2651
+ column: start.column + 1,
2652
+ line: start.line,
2653
+ offset: start.offset + 1
2654
+ };
2434
2655
  }
2435
2656
  return { end, start };
2436
2657
  }
@@ -2494,6 +2715,7 @@ let Node$4$1 = class Node2 {
2494
2715
  } else if (typeof value === "object" && value.toJSON) {
2495
2716
  fixed[name] = value.toJSON(null, inputs);
2496
2717
  } else if (name === "source") {
2718
+ if (value == null) continue;
2497
2719
  let inputId = inputs.get(value.input);
2498
2720
  if (inputId == null) {
2499
2721
  inputId = inputsNextIndex;
@@ -2528,7 +2750,7 @@ let Node$4$1 = class Node2 {
2528
2750
  });
2529
2751
  return result2;
2530
2752
  }
2531
- warn(result2, text, opts) {
2753
+ warn(result2, text, opts = {}) {
2532
2754
  let data = { node: this };
2533
2755
  for (let i2 in opts) data[i2] = opts[i2];
2534
2756
  return result2.warn(text, data);
@@ -3105,9 +3327,21 @@ let { fileURLToPath: fileURLToPath$1, pathToFileURL: pathToFileURL$1$1 } = requi
3105
3327
  let CssSyntaxError$1$1 = cssSyntaxError$1;
3106
3328
  let PreviousMap$1$1 = previousMap$1;
3107
3329
  let terminalHighlight$2 = require$$2$1;
3108
- let fromOffsetCache$1 = Symbol("fromOffsetCache");
3330
+ let lineToIndexCache$1 = Symbol("lineToIndexCache");
3109
3331
  let sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1);
3110
3332
  let pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1);
3333
+ function getLineToIndex$1(input2) {
3334
+ if (input2[lineToIndexCache$1]) return input2[lineToIndexCache$1];
3335
+ let lines = input2.css.split("\n");
3336
+ let lineToIndex = new Array(lines.length);
3337
+ let prevIndex = 0;
3338
+ for (let i2 = 0, l2 = lines.length; i2 < l2; i2++) {
3339
+ lineToIndex[i2] = prevIndex;
3340
+ prevIndex += lines[i2].length + 1;
3341
+ }
3342
+ input2[lineToIndexCache$1] = lineToIndex;
3343
+ return lineToIndex;
3344
+ }
3111
3345
  let Input$4$1 = class Input {
3112
3346
  get from() {
3113
3347
  return this.file || this.id;
@@ -3146,30 +3380,37 @@ let Input$4$1 = class Input {
3146
3380
  if (this.map) this.map.file = this.from;
3147
3381
  }
3148
3382
  error(message, line, column, opts = {}) {
3149
- let endColumn, endLine, result2;
3383
+ let endColumn, endLine, endOffset, offset, result2;
3150
3384
  if (line && typeof line === "object") {
3151
3385
  let start = line;
3152
3386
  let end = column;
3153
3387
  if (typeof start.offset === "number") {
3154
- let pos = this.fromOffset(start.offset);
3388
+ offset = start.offset;
3389
+ let pos = this.fromOffset(offset);
3155
3390
  line = pos.line;
3156
3391
  column = pos.col;
3157
3392
  } else {
3158
3393
  line = start.line;
3159
3394
  column = start.column;
3395
+ offset = this.fromLineAndColumn(line, column);
3160
3396
  }
3161
3397
  if (typeof end.offset === "number") {
3162
- let pos = this.fromOffset(end.offset);
3398
+ endOffset = end.offset;
3399
+ let pos = this.fromOffset(endOffset);
3163
3400
  endLine = pos.line;
3164
3401
  endColumn = pos.col;
3165
3402
  } else {
3166
3403
  endLine = end.line;
3167
3404
  endColumn = end.column;
3405
+ endOffset = this.fromLineAndColumn(end.line, end.column);
3168
3406
  }
3169
3407
  } else if (!column) {
3170
- let pos = this.fromOffset(line);
3408
+ offset = line;
3409
+ let pos = this.fromOffset(offset);
3171
3410
  line = pos.line;
3172
3411
  column = pos.col;
3412
+ } else {
3413
+ offset = this.fromLineAndColumn(line, column);
3173
3414
  }
3174
3415
  let origin = this.origin(line, column, endLine, endColumn);
3175
3416
  if (origin) {
@@ -3191,7 +3432,7 @@ let Input$4$1 = class Input {
3191
3432
  opts.plugin
3192
3433
  );
3193
3434
  }
3194
- result2.input = { column, endColumn, endLine, line, source: this.css };
3435
+ result2.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css };
3195
3436
  if (this.file) {
3196
3437
  if (pathToFileURL$1$1) {
3197
3438
  result2.input.url = pathToFileURL$1$1(this.file).toString();
@@ -3200,21 +3441,14 @@ let Input$4$1 = class Input {
3200
3441
  }
3201
3442
  return result2;
3202
3443
  }
3444
+ fromLineAndColumn(line, column) {
3445
+ let lineToIndex = getLineToIndex$1(this);
3446
+ let index2 = lineToIndex[line - 1];
3447
+ return index2 + column - 1;
3448
+ }
3203
3449
  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];
3450
+ let lineToIndex = getLineToIndex$1(this);
3451
+ let lastLine = lineToIndex[lineToIndex.length - 1];
3218
3452
  let min = 0;
3219
3453
  if (offset >= lastLine) {
3220
3454
  min = lineToIndex.length - 1;
@@ -4576,7 +4810,7 @@ let Result$3$1 = class Result {
4576
4810
  this.messages = [];
4577
4811
  this.root = root2;
4578
4812
  this.opts = opts;
4579
- this.css = void 0;
4813
+ this.css = "";
4580
4814
  this.map = void 0;
4581
4815
  }
4582
4816
  toString() {
@@ -5188,7 +5422,7 @@ let NoWorkResult2$1 = noWorkResult$1;
5188
5422
  let Root$1$1 = root$1;
5189
5423
  let Processor$1$1 = class Processor {
5190
5424
  constructor(plugins = []) {
5191
- this.version = "8.5.3";
5425
+ this.version = "8.5.4";
5192
5426
  this.plugins = this.normalize(plugins);
5193
5427
  }
5194
5428
  normalize(plugins) {
@@ -5342,6 +5576,325 @@ postcss$1$1.Node;
5342
5576
  var __defProp2 = Object.defineProperty;
5343
5577
  var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5344
5578
  var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
5579
+ var __defProp22 = Object.defineProperty;
5580
+ var __defNormalProp22 = (obj, key, value) => key in obj ? __defProp22(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5581
+ var __publicField22 = (obj, key, value) => __defNormalProp22(obj, typeof key !== "symbol" ? key + "" : key, value);
5582
+ const shouldTryAnonymousFetchingOnCorsError = () => {
5583
+ return !("_rrweb_skip_re_fetching_to_suppress_cors_errors" in window && window._rrweb_skip_re_fetching_to_suppress_cors_errors === true);
5584
+ };
5585
+ function fixBrowserCompatibilityIssuesInCSS(cssText) {
5586
+ if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
5587
+ cssText = cssText.replace(
5588
+ /\sbackground-clip:\s*text;/g,
5589
+ " -webkit-background-clip: text; background-clip: text;"
5590
+ );
5591
+ }
5592
+ return cssText;
5593
+ }
5594
+ function escapeImportStatement(rule2) {
5595
+ const { cssText } = rule2;
5596
+ if (cssText.split('"').length < 3) return cssText;
5597
+ const statement = ["@import", `url(${JSON.stringify(rule2.href)})`];
5598
+ if (rule2.layerName === "") {
5599
+ statement.push(`layer`);
5600
+ } else if (rule2.layerName) {
5601
+ statement.push(`layer(${rule2.layerName})`);
5602
+ }
5603
+ if (rule2.supportsText) {
5604
+ statement.push(`supports(${rule2.supportsText})`);
5605
+ }
5606
+ if (rule2.media.length) {
5607
+ statement.push(rule2.media.mediaText);
5608
+ }
5609
+ return statement.join(" ") + ";";
5610
+ }
5611
+ function stringifyStylesheet(s2) {
5612
+ try {
5613
+ const rules2 = s2.rules || s2.cssRules;
5614
+ if (!rules2) {
5615
+ return null;
5616
+ }
5617
+ let sheetHref = s2.href;
5618
+ if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
5619
+ sheetHref = s2.ownerNode.ownerDocument.location.href;
5620
+ }
5621
+ const stringifiedRules = Array.from(
5622
+ rules2,
5623
+ (rule2) => stringifyRule(rule2, sheetHref)
5624
+ ).join("");
5625
+ return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
5626
+ } catch (error) {
5627
+ return null;
5628
+ }
5629
+ }
5630
+ function stringifyRule(rule2, sheetHref) {
5631
+ if (isCSSImportRule(rule2)) {
5632
+ let importStringified;
5633
+ try {
5634
+ importStringified = // for same-origin stylesheets,
5635
+ // we can access the imported stylesheet rules directly
5636
+ stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
5637
+ escapeImportStatement(rule2);
5638
+ } catch (error) {
5639
+ importStringified = rule2.cssText;
5640
+ }
5641
+ if (rule2.styleSheet.href) {
5642
+ return absolutifyURLs(importStringified, rule2.styleSheet.href);
5643
+ }
5644
+ return importStringified;
5645
+ } else {
5646
+ let ruleStringified = rule2.cssText;
5647
+ if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
5648
+ ruleStringified = fixSafariColons(ruleStringified);
5649
+ }
5650
+ if (sheetHref) {
5651
+ return absolutifyURLs(ruleStringified, sheetHref);
5652
+ }
5653
+ return ruleStringified;
5654
+ }
5655
+ }
5656
+ function fixSafariColons(cssStringified) {
5657
+ const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
5658
+ return cssStringified.replace(regex, "$1\\$2");
5659
+ }
5660
+ function isCSSImportRule(rule2) {
5661
+ return "styleSheet" in rule2;
5662
+ }
5663
+ function isCSSStyleRule(rule2) {
5664
+ return "selectorText" in rule2;
5665
+ }
5666
+ function extractOrigin(url) {
5667
+ let origin = "";
5668
+ if (url.indexOf("//") > -1) {
5669
+ origin = url.split("/").slice(0, 3).join("/");
5670
+ } else {
5671
+ origin = url.split("/")[0];
5672
+ }
5673
+ origin = origin.split("?")[0];
5674
+ return origin;
5675
+ }
5676
+ const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
5677
+ const URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
5678
+ const URL_WWW_MATCH = /^www\..*/i;
5679
+ const DATA_URI = /^(data:)([^,]*),(.*)/i;
5680
+ function absolutifyURLs(cssText, href) {
5681
+ return (cssText || "").replace(
5682
+ URL_IN_CSS_REF,
5683
+ (origin, quote1, path1, quote2, path2, path3) => {
5684
+ const filePath = path1 || path2 || path3;
5685
+ const maybeQuote = quote1 || quote2 || "";
5686
+ if (!filePath) {
5687
+ return origin;
5688
+ }
5689
+ if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
5690
+ return `url(${maybeQuote}${filePath}${maybeQuote})`;
5691
+ }
5692
+ if (DATA_URI.test(filePath)) {
5693
+ return `url(${maybeQuote}${filePath}${maybeQuote})`;
5694
+ }
5695
+ if (filePath[0] === "/") {
5696
+ return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
5697
+ }
5698
+ const stack = href.split("/");
5699
+ const parts = filePath.split("/");
5700
+ stack.pop();
5701
+ for (const part of parts) {
5702
+ if (part === ".") {
5703
+ continue;
5704
+ } else if (part === "..") {
5705
+ stack.pop();
5706
+ } else {
5707
+ stack.push(part);
5708
+ }
5709
+ }
5710
+ return `url(${maybeQuote}${stack.join("/")}${maybeQuote})`;
5711
+ }
5712
+ );
5713
+ }
5714
+ const CLEANUP_DEBOUNCE_TIME = 1e3 * 30;
5715
+ const DATA_ATTRIBUTE_CLONED_NAME = "data-rrweb-link-cloned";
5716
+ const DISALLOWED_EXTENSIONS = [
5717
+ // Fonts
5718
+ "woff",
5719
+ "woff2",
5720
+ "ttf",
5721
+ "otf",
5722
+ // Embedded OpenType font
5723
+ "eot",
5724
+ // Images
5725
+ "png",
5726
+ "jpg",
5727
+ "jpeg",
5728
+ "gif",
5729
+ "svg",
5730
+ "webp",
5731
+ "ico",
5732
+ // Scripts
5733
+ "js",
5734
+ "mjs",
5735
+ "ts",
5736
+ "jsx",
5737
+ "tsx",
5738
+ // Data files
5739
+ "json",
5740
+ "map",
5741
+ // Media
5742
+ "mp4",
5743
+ "webm",
5744
+ "ogg",
5745
+ "mp3",
5746
+ "wav",
5747
+ // Archives
5748
+ "zip",
5749
+ "rar",
5750
+ "7z",
5751
+ "tar",
5752
+ "gz",
5753
+ // Documents
5754
+ "pdf",
5755
+ "doc",
5756
+ "docx",
5757
+ "xls",
5758
+ "xlsx"
5759
+ ];
5760
+ const _AsyncStylesheetManager2 = class _AsyncStylesheetManager22 {
5761
+ constructor() {
5762
+ __publicField22(this, "currentHref", null);
5763
+ __publicField22(this, "clones", {});
5764
+ __publicField22(this, "cleanTimeout", null);
5765
+ if (_AsyncStylesheetManager22.instance) return _AsyncStylesheetManager22.instance;
5766
+ _AsyncStylesheetManager22.instance = this;
5767
+ }
5768
+ removeCloneNode(href) {
5769
+ var _a2;
5770
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
5771
+ const clone = document.querySelector(
5772
+ `link[${DATA_ATTRIBUTE_CLONED_NAME}="${this.clones[href].cloneNodeAttrId}"]`
5773
+ );
5774
+ if (!clone) return;
5775
+ (_a2 = clone.parentNode) == null ? void 0 : _a2.removeChild(clone);
5776
+ }
5777
+ onLoad(href) {
5778
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
5779
+ const styleSheets2 = Array.from(document.styleSheets);
5780
+ let clonedStyleSheet = null;
5781
+ for (let i2 = styleSheets2.length - 1; i2 >= 0; i2--) {
5782
+ if (styleSheets2[i2].href === href) {
5783
+ clonedStyleSheet = styleSheets2[i2];
5784
+ break;
5785
+ }
5786
+ }
5787
+ if (!clonedStyleSheet) return this.removeCloneNode(href);
5788
+ const newCssText = stringifyStylesheet(clonedStyleSheet);
5789
+ this.removeCloneNode(href);
5790
+ if (!newCssText) return;
5791
+ this.clones[href].cssText = newCssText;
5792
+ this.clones[href].loaded = true;
5793
+ const original = document.querySelector(
5794
+ `link[${DATA_ATTRIBUTE_CLONED_NAME}="source-${this.clones[href].cloneNodeAttrId}"]`
5795
+ );
5796
+ if (original) {
5797
+ original.setAttribute("data-rrweb-mutation", Date.now().toString());
5798
+ original.removeAttribute(DATA_ATTRIBUTE_CLONED_NAME);
5799
+ } else {
5800
+ this.clones[href].original.setAttribute(
5801
+ "data-rrweb-mutation",
5802
+ Date.now().toString()
5803
+ );
5804
+ this.clones[href].original.removeAttribute(DATA_ATTRIBUTE_CLONED_NAME);
5805
+ }
5806
+ window.dispatchEvent(
5807
+ new CustomEvent("__rrweb_custom_event__", {
5808
+ detail: {
5809
+ type: 5,
5810
+ timestamp: Date.now(),
5811
+ data: {
5812
+ tag: "async-css-resolution",
5813
+ requestCssId: this.clones[href].requestCssId,
5814
+ cssText: this.clones[href].cssText
5815
+ }
5816
+ }
5817
+ })
5818
+ );
5819
+ }
5820
+ onLoadError(href) {
5821
+ if (!(href in this.clones) || this.clones[href] === void 0) return;
5822
+ this.removeCloneNode(href);
5823
+ }
5824
+ removeAllCloneElements() {
5825
+ for (const href of Object.keys(this.clones)) {
5826
+ this.removeCloneNode(href);
5827
+ }
5828
+ }
5829
+ onCleanTimeout() {
5830
+ asyncStylesheetManager.cleanTimeout = null;
5831
+ asyncStylesheetManager.removeAllCloneElements();
5832
+ }
5833
+ blowCache() {
5834
+ this.removeAllCloneElements();
5835
+ this.clones = {};
5836
+ }
5837
+ requestClone({
5838
+ forElement,
5839
+ requestCssId
5840
+ }) {
5841
+ if (!shouldTryAnonymousFetchingOnCorsError()) return;
5842
+ if (this.currentHref != null && document.location.href !== this.currentHref)
5843
+ this.blowCache();
5844
+ this.currentHref = document.location.href;
5845
+ const href = forElement.href;
5846
+ if (!href) return;
5847
+ if (href in this.clones && this.clones[href] !== void 0) return;
5848
+ if (forElement.getAttribute("crossorigin") === "anonymous") return;
5849
+ if (forElement.rel !== "stylesheet") {
5850
+ const last = href.split("/").pop();
5851
+ if (last && last.includes(".")) {
5852
+ const [filename] = last.split("?");
5853
+ const ext = filename.split(".").pop();
5854
+ if (ext) {
5855
+ if (DISALLOWED_EXTENSIONS.includes(ext.trim().toLowerCase())) return;
5856
+ }
5857
+ }
5858
+ }
5859
+ const clone = forElement.cloneNode();
5860
+ const cloneNodeAttrId = Math.random().toString(36).slice(2);
5861
+ clone.setAttribute("crossorigin", "anonymous");
5862
+ clone.setAttribute(DATA_ATTRIBUTE_CLONED_NAME, cloneNodeAttrId);
5863
+ forElement.setAttribute(
5864
+ DATA_ATTRIBUTE_CLONED_NAME,
5865
+ `source-${cloneNodeAttrId}`
5866
+ );
5867
+ document.head.appendChild(clone);
5868
+ this.clones[href] = {
5869
+ original: forElement,
5870
+ clone,
5871
+ loaded: false,
5872
+ cssText: null,
5873
+ cloneNodeAttrId,
5874
+ requestCssId
5875
+ };
5876
+ clone.onload = () => {
5877
+ this.onLoad(href);
5878
+ };
5879
+ clone.onerror = () => {
5880
+ this.onLoadError(href);
5881
+ };
5882
+ if (this.cleanTimeout) clearTimeout(this.cleanTimeout);
5883
+ this.cleanTimeout = setTimeout(
5884
+ asyncStylesheetManager.onCleanTimeout,
5885
+ CLEANUP_DEBOUNCE_TIME
5886
+ );
5887
+ }
5888
+ getClonedCssTextIfAvailable(href) {
5889
+ if (href in this.clones && this.clones[href] !== void 0 && this.clones[href].loaded === true) {
5890
+ return this.clones[href].cssText;
5891
+ }
5892
+ return null;
5893
+ }
5894
+ };
5895
+ __publicField22(_AsyncStylesheetManager2, "instance");
5896
+ let AsyncStylesheetManager = _AsyncStylesheetManager2;
5897
+ const asyncStylesheetManager = new AsyncStylesheetManager();
5345
5898
  function getDefaultExportFromCjs(x2) {
5346
5899
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
5347
5900
  }
@@ -5949,7 +6502,7 @@ let Node$4 = class Node3 {
5949
6502
  let index2 = this.parent.index(this);
5950
6503
  return this.parent.nodes[index2 + 1];
5951
6504
  }
5952
- positionBy(opts) {
6505
+ positionBy(opts = {}) {
5953
6506
  let pos = this.source.start;
5954
6507
  if (opts.index) {
5955
6508
  pos = this.positionInside(opts.index);
@@ -5978,27 +6531,38 @@ let Node$4 = class Node3 {
5978
6531
  column += 1;
5979
6532
  }
5980
6533
  }
5981
- return { column, line };
6534
+ return { column, line, offset: end };
5982
6535
  }
5983
6536
  prev() {
5984
6537
  if (!this.parent) return void 0;
5985
6538
  let index2 = this.parent.index(this);
5986
6539
  return this.parent.nodes[index2 - 1];
5987
6540
  }
5988
- rangeBy(opts) {
6541
+ rangeBy(opts = {}) {
6542
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
5989
6543
  let start = {
5990
6544
  column: this.source.start.column,
5991
- line: this.source.start.line
6545
+ line: this.source.start.line,
6546
+ offset: sourceOffset(inputString, this.source.start)
5992
6547
  };
5993
6548
  let end = this.source.end ? {
5994
6549
  column: this.source.end.column + 1,
5995
- line: this.source.end.line
6550
+ line: this.source.end.line,
6551
+ offset: typeof this.source.end.offset === "number" ? (
6552
+ // `source.end.offset` is exclusive, so we don't need to add 1
6553
+ this.source.end.offset
6554
+ ) : (
6555
+ // Since line/column in this.source.end is inclusive,
6556
+ // the `sourceOffset(... , this.source.end)` returns an inclusive offset.
6557
+ // So, we add 1 to convert it to exclusive.
6558
+ sourceOffset(inputString, this.source.end) + 1
6559
+ )
5996
6560
  } : {
5997
6561
  column: start.column + 1,
5998
- line: start.line
6562
+ line: start.line,
6563
+ offset: start.offset + 1
5999
6564
  };
6000
6565
  if (opts.word) {
6001
- let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
6002
6566
  let stringRepresentation = inputString.slice(
6003
6567
  sourceOffset(inputString, this.source.start),
6004
6568
  sourceOffset(inputString, this.source.end)
@@ -6006,15 +6570,14 @@ let Node$4 = class Node3 {
6006
6570
  let index2 = stringRepresentation.indexOf(opts.word);
6007
6571
  if (index2 !== -1) {
6008
6572
  start = this.positionInside(index2);
6009
- end = this.positionInside(
6010
- index2 + opts.word.length
6011
- );
6573
+ end = this.positionInside(index2 + opts.word.length);
6012
6574
  }
6013
6575
  } else {
6014
6576
  if (opts.start) {
6015
6577
  start = {
6016
6578
  column: opts.start.column,
6017
- line: opts.start.line
6579
+ line: opts.start.line,
6580
+ offset: sourceOffset(inputString, opts.start)
6018
6581
  };
6019
6582
  } else if (opts.index) {
6020
6583
  start = this.positionInside(opts.index);
@@ -6022,7 +6585,8 @@ let Node$4 = class Node3 {
6022
6585
  if (opts.end) {
6023
6586
  end = {
6024
6587
  column: opts.end.column,
6025
- line: opts.end.line
6588
+ line: opts.end.line,
6589
+ offset: sourceOffset(inputString, opts.end)
6026
6590
  };
6027
6591
  } else if (typeof opts.endIndex === "number") {
6028
6592
  end = this.positionInside(opts.endIndex);
@@ -6031,7 +6595,11 @@ let Node$4 = class Node3 {
6031
6595
  }
6032
6596
  }
6033
6597
  if (end.line < start.line || end.line === start.line && end.column <= start.column) {
6034
- end = { column: start.column + 1, line: start.line };
6598
+ end = {
6599
+ column: start.column + 1,
6600
+ line: start.line,
6601
+ offset: start.offset + 1
6602
+ };
6035
6603
  }
6036
6604
  return { end, start };
6037
6605
  }
@@ -6095,6 +6663,7 @@ let Node$4 = class Node3 {
6095
6663
  } else if (typeof value === "object" && value.toJSON) {
6096
6664
  fixed[name] = value.toJSON(null, inputs);
6097
6665
  } else if (name === "source") {
6666
+ if (value == null) continue;
6098
6667
  let inputId = inputs.get(value.input);
6099
6668
  if (inputId == null) {
6100
6669
  inputId = inputsNextIndex;
@@ -6129,7 +6698,7 @@ let Node$4 = class Node3 {
6129
6698
  });
6130
6699
  return result2;
6131
6700
  }
6132
- warn(result2, text, opts) {
6701
+ warn(result2, text, opts = {}) {
6133
6702
  let data = { node: this };
6134
6703
  for (let i2 in opts) data[i2] = opts[i2];
6135
6704
  return result2.warn(text, data);
@@ -6706,9 +7275,21 @@ let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
6706
7275
  let CssSyntaxError$1 = cssSyntaxError;
6707
7276
  let PreviousMap$1 = previousMap;
6708
7277
  let terminalHighlight = require$$2;
6709
- let fromOffsetCache = Symbol("fromOffsetCache");
7278
+ let lineToIndexCache = Symbol("lineToIndexCache");
6710
7279
  let sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
6711
7280
  let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
7281
+ function getLineToIndex(input2) {
7282
+ if (input2[lineToIndexCache]) return input2[lineToIndexCache];
7283
+ let lines = input2.css.split("\n");
7284
+ let lineToIndex = new Array(lines.length);
7285
+ let prevIndex = 0;
7286
+ for (let i2 = 0, l2 = lines.length; i2 < l2; i2++) {
7287
+ lineToIndex[i2] = prevIndex;
7288
+ prevIndex += lines[i2].length + 1;
7289
+ }
7290
+ input2[lineToIndexCache] = lineToIndex;
7291
+ return lineToIndex;
7292
+ }
6712
7293
  let Input$4 = class Input2 {
6713
7294
  get from() {
6714
7295
  return this.file || this.id;
@@ -6747,30 +7328,37 @@ let Input$4 = class Input2 {
6747
7328
  if (this.map) this.map.file = this.from;
6748
7329
  }
6749
7330
  error(message, line, column, opts = {}) {
6750
- let endColumn, endLine, result2;
7331
+ let endColumn, endLine, endOffset, offset, result2;
6751
7332
  if (line && typeof line === "object") {
6752
7333
  let start = line;
6753
7334
  let end = column;
6754
7335
  if (typeof start.offset === "number") {
6755
- let pos = this.fromOffset(start.offset);
7336
+ offset = start.offset;
7337
+ let pos = this.fromOffset(offset);
6756
7338
  line = pos.line;
6757
7339
  column = pos.col;
6758
7340
  } else {
6759
7341
  line = start.line;
6760
7342
  column = start.column;
7343
+ offset = this.fromLineAndColumn(line, column);
6761
7344
  }
6762
7345
  if (typeof end.offset === "number") {
6763
- let pos = this.fromOffset(end.offset);
7346
+ endOffset = end.offset;
7347
+ let pos = this.fromOffset(endOffset);
6764
7348
  endLine = pos.line;
6765
7349
  endColumn = pos.col;
6766
7350
  } else {
6767
7351
  endLine = end.line;
6768
7352
  endColumn = end.column;
7353
+ endOffset = this.fromLineAndColumn(end.line, end.column);
6769
7354
  }
6770
7355
  } else if (!column) {
6771
- let pos = this.fromOffset(line);
7356
+ offset = line;
7357
+ let pos = this.fromOffset(offset);
6772
7358
  line = pos.line;
6773
7359
  column = pos.col;
7360
+ } else {
7361
+ offset = this.fromLineAndColumn(line, column);
6774
7362
  }
6775
7363
  let origin = this.origin(line, column, endLine, endColumn);
6776
7364
  if (origin) {
@@ -6792,7 +7380,7 @@ let Input$4 = class Input2 {
6792
7380
  opts.plugin
6793
7381
  );
6794
7382
  }
6795
- result2.input = { column, endColumn, endLine, line, source: this.css };
7383
+ result2.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css };
6796
7384
  if (this.file) {
6797
7385
  if (pathToFileURL$1) {
6798
7386
  result2.input.url = pathToFileURL$1(this.file).toString();
@@ -6801,21 +7389,14 @@ let Input$4 = class Input2 {
6801
7389
  }
6802
7390
  return result2;
6803
7391
  }
7392
+ fromLineAndColumn(line, column) {
7393
+ let lineToIndex = getLineToIndex(this);
7394
+ let index2 = lineToIndex[line - 1];
7395
+ return index2 + column - 1;
7396
+ }
6804
7397
  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];
7398
+ let lineToIndex = getLineToIndex(this);
7399
+ let lastLine = lineToIndex[lineToIndex.length - 1];
6819
7400
  let min = 0;
6820
7401
  if (offset >= lastLine) {
6821
7402
  min = lineToIndex.length - 1;
@@ -8177,7 +8758,7 @@ let Result$3 = class Result2 {
8177
8758
  this.messages = [];
8178
8759
  this.root = root2;
8179
8760
  this.opts = opts;
8180
- this.css = void 0;
8761
+ this.css = "";
8181
8762
  this.map = void 0;
8182
8763
  }
8183
8764
  toString() {
@@ -8789,7 +9370,7 @@ let NoWorkResult22 = noWorkResult;
8789
9370
  let Root$1 = root;
8790
9371
  let Processor$1 = class Processor2 {
8791
9372
  constructor(plugins = []) {
8792
- this.version = "8.5.3";
9373
+ this.version = "8.5.4";
8793
9374
  this.plugins = this.normalize(plugins);
8794
9375
  }
8795
9376
  normalize(plugins) {
@@ -12068,7 +12649,7 @@ class StylesheetManager {
12068
12649
  styles.push({
12069
12650
  styleId,
12070
12651
  rules: Array.from(sheet.rules || CSSRule, (r2, index2) => ({
12071
- rule: stringifyRule(r2, sheet.href),
12652
+ rule: stringifyRule$1(r2, sheet.href),
12072
12653
  index: index2
12073
12654
  }))
12074
12655
  });
@@ -12528,12 +13109,26 @@ function record(options = {}) {
12528
13109
  console.warn(error);
12529
13110
  }
12530
13111
  });
13112
+ let initedAt = null;
12531
13113
  const init = () => {
13114
+ initedAt = Date.now();
12532
13115
  takeFullSnapshot$1();
12533
13116
  handlers.push(observe(document));
12534
13117
  recording = true;
12535
13118
  };
13119
+ const customOnLoad = () => {
13120
+ window.removeEventListener("load", customOnLoad);
13121
+ if (!recording || initedAt == null) return;
13122
+ if (Date.now() - initedAt <= 10) {
13123
+ return;
13124
+ }
13125
+ takeFullSnapshot$1();
13126
+ };
13127
+ window.addEventListener("load", customOnLoad);
12536
13128
  if (document.readyState === "interactive" || document.readyState === "complete") {
13129
+ if (document.readyState === "complete") {
13130
+ window.removeEventListener("load", customOnLoad);
13131
+ }
12537
13132
  init();
12538
13133
  } else {
12539
13134
  handlers.push(
@@ -12542,7 +13137,9 @@ function record(options = {}) {
12542
13137
  type: EventType.DomContentLoaded,
12543
13138
  data: {}
12544
13139
  });
12545
- if (recordAfter === "DOMContentLoaded") init();
13140
+ if (recordAfter === "DOMContentLoaded") {
13141
+ init();
13142
+ }
12546
13143
  })
12547
13144
  );
12548
13145
  handlers.push(
@@ -12553,7 +13150,9 @@ function record(options = {}) {
12553
13150
  type: EventType.Load,
12554
13151
  data: {}
12555
13152
  });
12556
- if (recordAfter === "load") init();
13153
+ if (recordAfter === "load") {
13154
+ init();
13155
+ }
12557
13156
  },
12558
13157
  window
12559
13158
  )