@vitest/browser 2.1.4 → 2.1.6

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.
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { a as getConfig, g as getBrowserState, e as executor, b as getWorkerState } from "./utils-CUwLt_eT.js";
4
+ import { a as getConfig, g as getBrowserState, b as resolve, e as executor, c as getWorkerState } from "./utils-Owv5OOOf.js";
5
5
  import { globalChannel, client, onCancel, channel } from "@vitest/browser/client";
6
6
  import { userEvent, page } from "@vitest/browser/context";
7
7
  import { loadDiffConfig, loadSnapshotSerializers, takeCoverageInsideWorker, setupCommonEnv, startCoverageInsideWorker, startTests, collectTests, stopCoverageInsideWorker, SpyModule } from "vitest/browser";
@@ -11313,6 +11313,7 @@ async function setupExpectDom() {
11313
11313
  if (elementOrLocator instanceof Element || elementOrLocator == null) {
11314
11314
  return elementOrLocator;
11315
11315
  }
11316
+ chai.util.flag(this, "_poll.element", true);
11316
11317
  const isNot = chai.util.flag(this, "negate");
11317
11318
  const name = chai.util.flag(this, "_name");
11318
11319
  if (isNot && name === "toBeInTheDocument") {
@@ -11403,7 +11404,8 @@ function setupConsoleLogSpy() {
11403
11404
  trace(...args);
11404
11405
  const content = processLog(args);
11405
11406
  const error2 = new Error("$$Trace");
11406
- const stack = (error2.stack || "").split("\n").slice(((_a = error2.stack) == null ? void 0 : _a.includes("$$Trace")) ? 2 : 1).join("\n");
11407
+ const processor = ((_a = globalThis.__vitest_worker__) == null ? void 0 : _a.onFilterStackTrace) || ((s) => s || "");
11408
+ const stack = processor(error2.stack || "");
11407
11409
  sendLog("stderr", `${content}
11408
11410
  ${stack}`, true);
11409
11411
  };
@@ -12276,6 +12278,1245 @@ function createModuleMockerInterceptor() {
12276
12278
  }
12277
12279
  });
12278
12280
  }
12281
+ var traceMapping_umd = { exports: {} };
12282
+ var sourcemapCodec_umd = { exports: {} };
12283
+ var hasRequiredSourcemapCodec_umd;
12284
+ function requireSourcemapCodec_umd() {
12285
+ if (hasRequiredSourcemapCodec_umd) return sourcemapCodec_umd.exports;
12286
+ hasRequiredSourcemapCodec_umd = 1;
12287
+ (function(module, exports) {
12288
+ (function(global2, factory) {
12289
+ factory(exports);
12290
+ })(commonjsGlobal, function(exports2) {
12291
+ const comma = ",".charCodeAt(0);
12292
+ const semicolon = ";".charCodeAt(0);
12293
+ const chars2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
12294
+ const intToChar2 = new Uint8Array(64);
12295
+ const charToInt2 = new Uint8Array(128);
12296
+ for (let i = 0; i < chars2.length; i++) {
12297
+ const c = chars2.charCodeAt(i);
12298
+ intToChar2[i] = c;
12299
+ charToInt2[c] = i;
12300
+ }
12301
+ function decodeInteger(reader, relative) {
12302
+ let value = 0;
12303
+ let shift = 0;
12304
+ let integer = 0;
12305
+ do {
12306
+ const c = reader.next();
12307
+ integer = charToInt2[c];
12308
+ value |= (integer & 31) << shift;
12309
+ shift += 5;
12310
+ } while (integer & 32);
12311
+ const shouldNegate = value & 1;
12312
+ value >>>= 1;
12313
+ if (shouldNegate) {
12314
+ value = -2147483648 | -value;
12315
+ }
12316
+ return relative + value;
12317
+ }
12318
+ function encodeInteger(builder, num, relative) {
12319
+ let delta = num - relative;
12320
+ delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
12321
+ do {
12322
+ let clamped = delta & 31;
12323
+ delta >>>= 5;
12324
+ if (delta > 0)
12325
+ clamped |= 32;
12326
+ builder.write(intToChar2[clamped]);
12327
+ } while (delta > 0);
12328
+ return num;
12329
+ }
12330
+ function hasMoreVlq(reader, max) {
12331
+ if (reader.pos >= max)
12332
+ return false;
12333
+ return reader.peek() !== comma;
12334
+ }
12335
+ const bufLength = 1024 * 16;
12336
+ const td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
12337
+ decode(buf) {
12338
+ const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
12339
+ return out.toString();
12340
+ }
12341
+ } : {
12342
+ decode(buf) {
12343
+ let out = "";
12344
+ for (let i = 0; i < buf.length; i++) {
12345
+ out += String.fromCharCode(buf[i]);
12346
+ }
12347
+ return out;
12348
+ }
12349
+ };
12350
+ class StringWriter {
12351
+ constructor() {
12352
+ this.pos = 0;
12353
+ this.out = "";
12354
+ this.buffer = new Uint8Array(bufLength);
12355
+ }
12356
+ write(v) {
12357
+ const { buffer } = this;
12358
+ buffer[this.pos++] = v;
12359
+ if (this.pos === bufLength) {
12360
+ this.out += td.decode(buffer);
12361
+ this.pos = 0;
12362
+ }
12363
+ }
12364
+ flush() {
12365
+ const { buffer, out, pos } = this;
12366
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
12367
+ }
12368
+ }
12369
+ class StringReader {
12370
+ constructor(buffer) {
12371
+ this.pos = 0;
12372
+ this.buffer = buffer;
12373
+ }
12374
+ next() {
12375
+ return this.buffer.charCodeAt(this.pos++);
12376
+ }
12377
+ peek() {
12378
+ return this.buffer.charCodeAt(this.pos);
12379
+ }
12380
+ indexOf(char) {
12381
+ const { buffer, pos } = this;
12382
+ const idx = buffer.indexOf(char, pos);
12383
+ return idx === -1 ? buffer.length : idx;
12384
+ }
12385
+ }
12386
+ const EMPTY = [];
12387
+ function decodeOriginalScopes(input) {
12388
+ const { length } = input;
12389
+ const reader = new StringReader(input);
12390
+ const scopes = [];
12391
+ const stack = [];
12392
+ let line = 0;
12393
+ for (; reader.pos < length; reader.pos++) {
12394
+ line = decodeInteger(reader, line);
12395
+ const column = decodeInteger(reader, 0);
12396
+ if (!hasMoreVlq(reader, length)) {
12397
+ const last = stack.pop();
12398
+ last[2] = line;
12399
+ last[3] = column;
12400
+ continue;
12401
+ }
12402
+ const kind = decodeInteger(reader, 0);
12403
+ const fields = decodeInteger(reader, 0);
12404
+ const hasName = fields & 1;
12405
+ const scope = hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind];
12406
+ let vars = EMPTY;
12407
+ if (hasMoreVlq(reader, length)) {
12408
+ vars = [];
12409
+ do {
12410
+ const varsIndex = decodeInteger(reader, 0);
12411
+ vars.push(varsIndex);
12412
+ } while (hasMoreVlq(reader, length));
12413
+ }
12414
+ scope.vars = vars;
12415
+ scopes.push(scope);
12416
+ stack.push(scope);
12417
+ }
12418
+ return scopes;
12419
+ }
12420
+ function encodeOriginalScopes(scopes) {
12421
+ const writer = new StringWriter();
12422
+ for (let i = 0; i < scopes.length; ) {
12423
+ i = _encodeOriginalScopes(scopes, i, writer, [0]);
12424
+ }
12425
+ return writer.flush();
12426
+ }
12427
+ function _encodeOriginalScopes(scopes, index, writer, state) {
12428
+ const scope = scopes[index];
12429
+ const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope;
12430
+ if (index > 0)
12431
+ writer.write(comma);
12432
+ state[0] = encodeInteger(writer, startLine, state[0]);
12433
+ encodeInteger(writer, startColumn, 0);
12434
+ encodeInteger(writer, kind, 0);
12435
+ const fields = scope.length === 6 ? 1 : 0;
12436
+ encodeInteger(writer, fields, 0);
12437
+ if (scope.length === 6)
12438
+ encodeInteger(writer, scope[5], 0);
12439
+ for (const v of vars) {
12440
+ encodeInteger(writer, v, 0);
12441
+ }
12442
+ for (index++; index < scopes.length; ) {
12443
+ const next = scopes[index];
12444
+ const { 0: l, 1: c } = next;
12445
+ if (l > endLine || l === endLine && c >= endColumn) {
12446
+ break;
12447
+ }
12448
+ index = _encodeOriginalScopes(scopes, index, writer, state);
12449
+ }
12450
+ writer.write(comma);
12451
+ state[0] = encodeInteger(writer, endLine, state[0]);
12452
+ encodeInteger(writer, endColumn, 0);
12453
+ return index;
12454
+ }
12455
+ function decodeGeneratedRanges(input) {
12456
+ const { length } = input;
12457
+ const reader = new StringReader(input);
12458
+ const ranges = [];
12459
+ const stack = [];
12460
+ let genLine = 0;
12461
+ let definitionSourcesIndex = 0;
12462
+ let definitionScopeIndex = 0;
12463
+ let callsiteSourcesIndex = 0;
12464
+ let callsiteLine = 0;
12465
+ let callsiteColumn = 0;
12466
+ let bindingLine = 0;
12467
+ let bindingColumn = 0;
12468
+ do {
12469
+ const semi = reader.indexOf(";");
12470
+ let genColumn = 0;
12471
+ for (; reader.pos < semi; reader.pos++) {
12472
+ genColumn = decodeInteger(reader, genColumn);
12473
+ if (!hasMoreVlq(reader, semi)) {
12474
+ const last = stack.pop();
12475
+ last[2] = genLine;
12476
+ last[3] = genColumn;
12477
+ continue;
12478
+ }
12479
+ const fields = decodeInteger(reader, 0);
12480
+ const hasDefinition = fields & 1;
12481
+ const hasCallsite = fields & 2;
12482
+ const hasScope = fields & 4;
12483
+ let callsite = null;
12484
+ let bindings = EMPTY;
12485
+ let range;
12486
+ if (hasDefinition) {
12487
+ const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
12488
+ definitionScopeIndex = decodeInteger(reader, definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0);
12489
+ definitionSourcesIndex = defSourcesIndex;
12490
+ range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex];
12491
+ } else {
12492
+ range = [genLine, genColumn, 0, 0];
12493
+ }
12494
+ range.isScope = !!hasScope;
12495
+ if (hasCallsite) {
12496
+ const prevCsi = callsiteSourcesIndex;
12497
+ const prevLine = callsiteLine;
12498
+ callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex);
12499
+ const sameSource = prevCsi === callsiteSourcesIndex;
12500
+ callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0);
12501
+ callsiteColumn = decodeInteger(reader, sameSource && prevLine === callsiteLine ? callsiteColumn : 0);
12502
+ callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn];
12503
+ }
12504
+ range.callsite = callsite;
12505
+ if (hasMoreVlq(reader, semi)) {
12506
+ bindings = [];
12507
+ do {
12508
+ bindingLine = genLine;
12509
+ bindingColumn = genColumn;
12510
+ const expressionsCount = decodeInteger(reader, 0);
12511
+ let expressionRanges;
12512
+ if (expressionsCount < -1) {
12513
+ expressionRanges = [[decodeInteger(reader, 0)]];
12514
+ for (let i = -1; i > expressionsCount; i--) {
12515
+ const prevBl = bindingLine;
12516
+ bindingLine = decodeInteger(reader, bindingLine);
12517
+ bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0);
12518
+ const expression = decodeInteger(reader, 0);
12519
+ expressionRanges.push([expression, bindingLine, bindingColumn]);
12520
+ }
12521
+ } else {
12522
+ expressionRanges = [[expressionsCount]];
12523
+ }
12524
+ bindings.push(expressionRanges);
12525
+ } while (hasMoreVlq(reader, semi));
12526
+ }
12527
+ range.bindings = bindings;
12528
+ ranges.push(range);
12529
+ stack.push(range);
12530
+ }
12531
+ genLine++;
12532
+ reader.pos = semi + 1;
12533
+ } while (reader.pos < length);
12534
+ return ranges;
12535
+ }
12536
+ function encodeGeneratedRanges(ranges) {
12537
+ if (ranges.length === 0)
12538
+ return "";
12539
+ const writer = new StringWriter();
12540
+ for (let i = 0; i < ranges.length; ) {
12541
+ i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]);
12542
+ }
12543
+ return writer.flush();
12544
+ }
12545
+ function _encodeGeneratedRanges(ranges, index, writer, state) {
12546
+ const range = ranges[index];
12547
+ const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, isScope, callsite, bindings } = range;
12548
+ if (state[0] < startLine) {
12549
+ catchupLine(writer, state[0], startLine);
12550
+ state[0] = startLine;
12551
+ state[1] = 0;
12552
+ } else if (index > 0) {
12553
+ writer.write(comma);
12554
+ }
12555
+ state[1] = encodeInteger(writer, range[1], state[1]);
12556
+ const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0);
12557
+ encodeInteger(writer, fields, 0);
12558
+ if (range.length === 6) {
12559
+ const { 4: sourcesIndex, 5: scopesIndex } = range;
12560
+ if (sourcesIndex !== state[2]) {
12561
+ state[3] = 0;
12562
+ }
12563
+ state[2] = encodeInteger(writer, sourcesIndex, state[2]);
12564
+ state[3] = encodeInteger(writer, scopesIndex, state[3]);
12565
+ }
12566
+ if (callsite) {
12567
+ const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite;
12568
+ if (sourcesIndex !== state[4]) {
12569
+ state[5] = 0;
12570
+ state[6] = 0;
12571
+ } else if (callLine !== state[5]) {
12572
+ state[6] = 0;
12573
+ }
12574
+ state[4] = encodeInteger(writer, sourcesIndex, state[4]);
12575
+ state[5] = encodeInteger(writer, callLine, state[5]);
12576
+ state[6] = encodeInteger(writer, callColumn, state[6]);
12577
+ }
12578
+ if (bindings) {
12579
+ for (const binding of bindings) {
12580
+ if (binding.length > 1)
12581
+ encodeInteger(writer, -binding.length, 0);
12582
+ const expression = binding[0][0];
12583
+ encodeInteger(writer, expression, 0);
12584
+ let bindingStartLine = startLine;
12585
+ let bindingStartColumn = startColumn;
12586
+ for (let i = 1; i < binding.length; i++) {
12587
+ const expRange = binding[i];
12588
+ bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine);
12589
+ bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn);
12590
+ encodeInteger(writer, expRange[0], 0);
12591
+ }
12592
+ }
12593
+ }
12594
+ for (index++; index < ranges.length; ) {
12595
+ const next = ranges[index];
12596
+ const { 0: l, 1: c } = next;
12597
+ if (l > endLine || l === endLine && c >= endColumn) {
12598
+ break;
12599
+ }
12600
+ index = _encodeGeneratedRanges(ranges, index, writer, state);
12601
+ }
12602
+ if (state[0] < endLine) {
12603
+ catchupLine(writer, state[0], endLine);
12604
+ state[0] = endLine;
12605
+ state[1] = 0;
12606
+ } else {
12607
+ writer.write(comma);
12608
+ }
12609
+ state[1] = encodeInteger(writer, endColumn, state[1]);
12610
+ return index;
12611
+ }
12612
+ function catchupLine(writer, lastLine, line) {
12613
+ do {
12614
+ writer.write(semicolon);
12615
+ } while (++lastLine < line);
12616
+ }
12617
+ function decode(mappings) {
12618
+ const { length } = mappings;
12619
+ const reader = new StringReader(mappings);
12620
+ const decoded = [];
12621
+ let genColumn = 0;
12622
+ let sourcesIndex = 0;
12623
+ let sourceLine = 0;
12624
+ let sourceColumn = 0;
12625
+ let namesIndex = 0;
12626
+ do {
12627
+ const semi = reader.indexOf(";");
12628
+ const line = [];
12629
+ let sorted = true;
12630
+ let lastCol = 0;
12631
+ genColumn = 0;
12632
+ while (reader.pos < semi) {
12633
+ let seg;
12634
+ genColumn = decodeInteger(reader, genColumn);
12635
+ if (genColumn < lastCol)
12636
+ sorted = false;
12637
+ lastCol = genColumn;
12638
+ if (hasMoreVlq(reader, semi)) {
12639
+ sourcesIndex = decodeInteger(reader, sourcesIndex);
12640
+ sourceLine = decodeInteger(reader, sourceLine);
12641
+ sourceColumn = decodeInteger(reader, sourceColumn);
12642
+ if (hasMoreVlq(reader, semi)) {
12643
+ namesIndex = decodeInteger(reader, namesIndex);
12644
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
12645
+ } else {
12646
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
12647
+ }
12648
+ } else {
12649
+ seg = [genColumn];
12650
+ }
12651
+ line.push(seg);
12652
+ reader.pos++;
12653
+ }
12654
+ if (!sorted)
12655
+ sort(line);
12656
+ decoded.push(line);
12657
+ reader.pos = semi + 1;
12658
+ } while (reader.pos <= length);
12659
+ return decoded;
12660
+ }
12661
+ function sort(line) {
12662
+ line.sort(sortComparator);
12663
+ }
12664
+ function sortComparator(a, b) {
12665
+ return a[0] - b[0];
12666
+ }
12667
+ function encode(decoded) {
12668
+ const writer = new StringWriter();
12669
+ let sourcesIndex = 0;
12670
+ let sourceLine = 0;
12671
+ let sourceColumn = 0;
12672
+ let namesIndex = 0;
12673
+ for (let i = 0; i < decoded.length; i++) {
12674
+ const line = decoded[i];
12675
+ if (i > 0)
12676
+ writer.write(semicolon);
12677
+ if (line.length === 0)
12678
+ continue;
12679
+ let genColumn = 0;
12680
+ for (let j = 0; j < line.length; j++) {
12681
+ const segment = line[j];
12682
+ if (j > 0)
12683
+ writer.write(comma);
12684
+ genColumn = encodeInteger(writer, segment[0], genColumn);
12685
+ if (segment.length === 1)
12686
+ continue;
12687
+ sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
12688
+ sourceLine = encodeInteger(writer, segment[2], sourceLine);
12689
+ sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
12690
+ if (segment.length === 4)
12691
+ continue;
12692
+ namesIndex = encodeInteger(writer, segment[4], namesIndex);
12693
+ }
12694
+ }
12695
+ return writer.flush();
12696
+ }
12697
+ exports2.decode = decode;
12698
+ exports2.decodeGeneratedRanges = decodeGeneratedRanges;
12699
+ exports2.decodeOriginalScopes = decodeOriginalScopes;
12700
+ exports2.encode = encode;
12701
+ exports2.encodeGeneratedRanges = encodeGeneratedRanges;
12702
+ exports2.encodeOriginalScopes = encodeOriginalScopes;
12703
+ Object.defineProperty(exports2, "__esModule", { value: true });
12704
+ });
12705
+ })(sourcemapCodec_umd, sourcemapCodec_umd.exports);
12706
+ return sourcemapCodec_umd.exports;
12707
+ }
12708
+ var resolveUri_umd = { exports: {} };
12709
+ var hasRequiredResolveUri_umd;
12710
+ function requireResolveUri_umd() {
12711
+ if (hasRequiredResolveUri_umd) return resolveUri_umd.exports;
12712
+ hasRequiredResolveUri_umd = 1;
12713
+ (function(module, exports) {
12714
+ (function(global2, factory) {
12715
+ module.exports = factory();
12716
+ })(commonjsGlobal, function() {
12717
+ const schemeRegex = /^[\w+.-]+:\/\//;
12718
+ const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
12719
+ const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
12720
+ var UrlType2;
12721
+ (function(UrlType3) {
12722
+ UrlType3[UrlType3["Empty"] = 1] = "Empty";
12723
+ UrlType3[UrlType3["Hash"] = 2] = "Hash";
12724
+ UrlType3[UrlType3["Query"] = 3] = "Query";
12725
+ UrlType3[UrlType3["RelativePath"] = 4] = "RelativePath";
12726
+ UrlType3[UrlType3["AbsolutePath"] = 5] = "AbsolutePath";
12727
+ UrlType3[UrlType3["SchemeRelative"] = 6] = "SchemeRelative";
12728
+ UrlType3[UrlType3["Absolute"] = 7] = "Absolute";
12729
+ })(UrlType2 || (UrlType2 = {}));
12730
+ function isAbsoluteUrl(input) {
12731
+ return schemeRegex.test(input);
12732
+ }
12733
+ function isSchemeRelativeUrl(input) {
12734
+ return input.startsWith("//");
12735
+ }
12736
+ function isAbsolutePath(input) {
12737
+ return input.startsWith("/");
12738
+ }
12739
+ function isFileUrl(input) {
12740
+ return input.startsWith("file:");
12741
+ }
12742
+ function isRelative(input) {
12743
+ return /^[.?#]/.test(input);
12744
+ }
12745
+ function parseAbsoluteUrl(input) {
12746
+ const match = urlRegex.exec(input);
12747
+ return makeUrl(match[1], match[2] || "", match[3], match[4] || "", match[5] || "/", match[6] || "", match[7] || "");
12748
+ }
12749
+ function parseFileUrl(input) {
12750
+ const match = fileRegex.exec(input);
12751
+ const path = match[2];
12752
+ return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path) ? path : "/" + path, match[3] || "", match[4] || "");
12753
+ }
12754
+ function makeUrl(scheme, user, host, port, path, query, hash) {
12755
+ return {
12756
+ scheme,
12757
+ user,
12758
+ host,
12759
+ port,
12760
+ path,
12761
+ query,
12762
+ hash,
12763
+ type: UrlType2.Absolute
12764
+ };
12765
+ }
12766
+ function parseUrl(input) {
12767
+ if (isSchemeRelativeUrl(input)) {
12768
+ const url3 = parseAbsoluteUrl("http:" + input);
12769
+ url3.scheme = "";
12770
+ url3.type = UrlType2.SchemeRelative;
12771
+ return url3;
12772
+ }
12773
+ if (isAbsolutePath(input)) {
12774
+ const url3 = parseAbsoluteUrl("http://foo.com" + input);
12775
+ url3.scheme = "";
12776
+ url3.host = "";
12777
+ url3.type = UrlType2.AbsolutePath;
12778
+ return url3;
12779
+ }
12780
+ if (isFileUrl(input))
12781
+ return parseFileUrl(input);
12782
+ if (isAbsoluteUrl(input))
12783
+ return parseAbsoluteUrl(input);
12784
+ const url2 = parseAbsoluteUrl("http://foo.com/" + input);
12785
+ url2.scheme = "";
12786
+ url2.host = "";
12787
+ url2.type = input ? input.startsWith("?") ? UrlType2.Query : input.startsWith("#") ? UrlType2.Hash : UrlType2.RelativePath : UrlType2.Empty;
12788
+ return url2;
12789
+ }
12790
+ function stripPathFilename(path) {
12791
+ if (path.endsWith("/.."))
12792
+ return path;
12793
+ const index = path.lastIndexOf("/");
12794
+ return path.slice(0, index + 1);
12795
+ }
12796
+ function mergePaths(url2, base) {
12797
+ normalizePath(base, base.type);
12798
+ if (url2.path === "/") {
12799
+ url2.path = base.path;
12800
+ } else {
12801
+ url2.path = stripPathFilename(base.path) + url2.path;
12802
+ }
12803
+ }
12804
+ function normalizePath(url2, type) {
12805
+ const rel = type <= UrlType2.RelativePath;
12806
+ const pieces = url2.path.split("/");
12807
+ let pointer = 1;
12808
+ let positive = 0;
12809
+ let addTrailingSlash = false;
12810
+ for (let i = 1; i < pieces.length; i++) {
12811
+ const piece = pieces[i];
12812
+ if (!piece) {
12813
+ addTrailingSlash = true;
12814
+ continue;
12815
+ }
12816
+ addTrailingSlash = false;
12817
+ if (piece === ".")
12818
+ continue;
12819
+ if (piece === "..") {
12820
+ if (positive) {
12821
+ addTrailingSlash = true;
12822
+ positive--;
12823
+ pointer--;
12824
+ } else if (rel) {
12825
+ pieces[pointer++] = piece;
12826
+ }
12827
+ continue;
12828
+ }
12829
+ pieces[pointer++] = piece;
12830
+ positive++;
12831
+ }
12832
+ let path = "";
12833
+ for (let i = 1; i < pointer; i++) {
12834
+ path += "/" + pieces[i];
12835
+ }
12836
+ if (!path || addTrailingSlash && !path.endsWith("/..")) {
12837
+ path += "/";
12838
+ }
12839
+ url2.path = path;
12840
+ }
12841
+ function resolve2(input, base) {
12842
+ if (!input && !base)
12843
+ return "";
12844
+ const url2 = parseUrl(input);
12845
+ let inputType = url2.type;
12846
+ if (base && inputType !== UrlType2.Absolute) {
12847
+ const baseUrl = parseUrl(base);
12848
+ const baseType = baseUrl.type;
12849
+ switch (inputType) {
12850
+ case UrlType2.Empty:
12851
+ url2.hash = baseUrl.hash;
12852
+ case UrlType2.Hash:
12853
+ url2.query = baseUrl.query;
12854
+ case UrlType2.Query:
12855
+ case UrlType2.RelativePath:
12856
+ mergePaths(url2, baseUrl);
12857
+ case UrlType2.AbsolutePath:
12858
+ url2.user = baseUrl.user;
12859
+ url2.host = baseUrl.host;
12860
+ url2.port = baseUrl.port;
12861
+ case UrlType2.SchemeRelative:
12862
+ url2.scheme = baseUrl.scheme;
12863
+ }
12864
+ if (baseType > inputType)
12865
+ inputType = baseType;
12866
+ }
12867
+ normalizePath(url2, inputType);
12868
+ const queryHash = url2.query + url2.hash;
12869
+ switch (inputType) {
12870
+ case UrlType2.Hash:
12871
+ case UrlType2.Query:
12872
+ return queryHash;
12873
+ case UrlType2.RelativePath: {
12874
+ const path = url2.path.slice(1);
12875
+ if (!path)
12876
+ return queryHash || ".";
12877
+ if (isRelative(base || input) && !isRelative(path)) {
12878
+ return "./" + path + queryHash;
12879
+ }
12880
+ return path + queryHash;
12881
+ }
12882
+ case UrlType2.AbsolutePath:
12883
+ return url2.path + queryHash;
12884
+ default:
12885
+ return url2.scheme + "//" + url2.user + url2.host + url2.port + url2.path + queryHash;
12886
+ }
12887
+ }
12888
+ return resolve2;
12889
+ });
12890
+ })(resolveUri_umd);
12891
+ return resolveUri_umd.exports;
12892
+ }
12893
+ (function(module, exports) {
12894
+ (function(global2, factory) {
12895
+ factory(exports, requireSourcemapCodec_umd(), requireResolveUri_umd());
12896
+ })(commonjsGlobal, function(exports2, sourcemapCodec, resolveUri) {
12897
+ function resolve2(input, base) {
12898
+ if (base && !base.endsWith("/"))
12899
+ base += "/";
12900
+ return resolveUri(input, base);
12901
+ }
12902
+ function stripFilename(path) {
12903
+ if (!path)
12904
+ return "";
12905
+ const index = path.lastIndexOf("/");
12906
+ return path.slice(0, index + 1);
12907
+ }
12908
+ const COLUMN = 0;
12909
+ const SOURCES_INDEX = 1;
12910
+ const SOURCE_LINE = 2;
12911
+ const SOURCE_COLUMN = 3;
12912
+ const NAMES_INDEX = 4;
12913
+ const REV_GENERATED_LINE = 1;
12914
+ const REV_GENERATED_COLUMN = 2;
12915
+ function maybeSort(mappings, owned) {
12916
+ const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
12917
+ if (unsortedIndex === mappings.length)
12918
+ return mappings;
12919
+ if (!owned)
12920
+ mappings = mappings.slice();
12921
+ for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
12922
+ mappings[i] = sortSegments(mappings[i], owned);
12923
+ }
12924
+ return mappings;
12925
+ }
12926
+ function nextUnsortedSegmentLine(mappings, start) {
12927
+ for (let i = start; i < mappings.length; i++) {
12928
+ if (!isSorted(mappings[i]))
12929
+ return i;
12930
+ }
12931
+ return mappings.length;
12932
+ }
12933
+ function isSorted(line) {
12934
+ for (let j = 1; j < line.length; j++) {
12935
+ if (line[j][COLUMN] < line[j - 1][COLUMN]) {
12936
+ return false;
12937
+ }
12938
+ }
12939
+ return true;
12940
+ }
12941
+ function sortSegments(line, owned) {
12942
+ if (!owned)
12943
+ line = line.slice();
12944
+ return line.sort(sortComparator);
12945
+ }
12946
+ function sortComparator(a, b) {
12947
+ return a[COLUMN] - b[COLUMN];
12948
+ }
12949
+ let found = false;
12950
+ function binarySearch(haystack, needle, low, high) {
12951
+ while (low <= high) {
12952
+ const mid = low + (high - low >> 1);
12953
+ const cmp = haystack[mid][COLUMN] - needle;
12954
+ if (cmp === 0) {
12955
+ found = true;
12956
+ return mid;
12957
+ }
12958
+ if (cmp < 0) {
12959
+ low = mid + 1;
12960
+ } else {
12961
+ high = mid - 1;
12962
+ }
12963
+ }
12964
+ found = false;
12965
+ return low - 1;
12966
+ }
12967
+ function upperBound(haystack, needle, index) {
12968
+ for (let i = index + 1; i < haystack.length; index = i++) {
12969
+ if (haystack[i][COLUMN] !== needle)
12970
+ break;
12971
+ }
12972
+ return index;
12973
+ }
12974
+ function lowerBound(haystack, needle, index) {
12975
+ for (let i = index - 1; i >= 0; index = i--) {
12976
+ if (haystack[i][COLUMN] !== needle)
12977
+ break;
12978
+ }
12979
+ return index;
12980
+ }
12981
+ function memoizedState() {
12982
+ return {
12983
+ lastKey: -1,
12984
+ lastNeedle: -1,
12985
+ lastIndex: -1
12986
+ };
12987
+ }
12988
+ function memoizedBinarySearch(haystack, needle, state, key) {
12989
+ const { lastKey, lastNeedle, lastIndex } = state;
12990
+ let low = 0;
12991
+ let high = haystack.length - 1;
12992
+ if (key === lastKey) {
12993
+ if (needle === lastNeedle) {
12994
+ found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
12995
+ return lastIndex;
12996
+ }
12997
+ if (needle >= lastNeedle) {
12998
+ low = lastIndex === -1 ? 0 : lastIndex;
12999
+ } else {
13000
+ high = lastIndex;
13001
+ }
13002
+ }
13003
+ state.lastKey = key;
13004
+ state.lastNeedle = needle;
13005
+ return state.lastIndex = binarySearch(haystack, needle, low, high);
13006
+ }
13007
+ function buildBySources(decoded, memos) {
13008
+ const sources = memos.map(buildNullArray);
13009
+ for (let i = 0; i < decoded.length; i++) {
13010
+ const line = decoded[i];
13011
+ for (let j = 0; j < line.length; j++) {
13012
+ const seg = line[j];
13013
+ if (seg.length === 1)
13014
+ continue;
13015
+ const sourceIndex2 = seg[SOURCES_INDEX];
13016
+ const sourceLine = seg[SOURCE_LINE];
13017
+ const sourceColumn = seg[SOURCE_COLUMN];
13018
+ const originalSource = sources[sourceIndex2];
13019
+ const originalLine = originalSource[sourceLine] || (originalSource[sourceLine] = []);
13020
+ const memo = memos[sourceIndex2];
13021
+ let index = upperBound(originalLine, sourceColumn, memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine));
13022
+ memo.lastIndex = ++index;
13023
+ insert(originalLine, index, [sourceColumn, i, seg[COLUMN]]);
13024
+ }
13025
+ }
13026
+ return sources;
13027
+ }
13028
+ function insert(array, index, value) {
13029
+ for (let i = array.length; i > index; i--) {
13030
+ array[i] = array[i - 1];
13031
+ }
13032
+ array[index] = value;
13033
+ }
13034
+ function buildNullArray() {
13035
+ return { __proto__: null };
13036
+ }
13037
+ const AnyMap = function(map, mapUrl) {
13038
+ const parsed = parse(map);
13039
+ if (!("sections" in parsed)) {
13040
+ return new TraceMap2(parsed, mapUrl);
13041
+ }
13042
+ const mappings = [];
13043
+ const sources = [];
13044
+ const sourcesContent = [];
13045
+ const names = [];
13046
+ const ignoreList = [];
13047
+ recurse(parsed, mapUrl, mappings, sources, sourcesContent, names, ignoreList, 0, 0, Infinity, Infinity);
13048
+ const joined = {
13049
+ version: 3,
13050
+ file: parsed.file,
13051
+ names,
13052
+ sources,
13053
+ sourcesContent,
13054
+ mappings,
13055
+ ignoreList
13056
+ };
13057
+ return presortedDecodedMap(joined);
13058
+ };
13059
+ function parse(map) {
13060
+ return typeof map === "string" ? JSON.parse(map) : map;
13061
+ }
13062
+ function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
13063
+ const { sections } = input;
13064
+ for (let i = 0; i < sections.length; i++) {
13065
+ const { map, offset } = sections[i];
13066
+ let sl = stopLine;
13067
+ let sc = stopColumn;
13068
+ if (i + 1 < sections.length) {
13069
+ const nextOffset = sections[i + 1].offset;
13070
+ sl = Math.min(stopLine, lineOffset + nextOffset.line);
13071
+ if (sl === stopLine) {
13072
+ sc = Math.min(stopColumn, columnOffset + nextOffset.column);
13073
+ } else if (sl < stopLine) {
13074
+ sc = columnOffset + nextOffset.column;
13075
+ }
13076
+ }
13077
+ addSection(map, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset + offset.line, columnOffset + offset.column, sl, sc);
13078
+ }
13079
+ }
13080
+ function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
13081
+ const parsed = parse(input);
13082
+ if ("sections" in parsed)
13083
+ return recurse(...arguments);
13084
+ const map = new TraceMap2(parsed, mapUrl);
13085
+ const sourcesOffset = sources.length;
13086
+ const namesOffset = names.length;
13087
+ const decoded = decodedMappings(map);
13088
+ const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map;
13089
+ append(sources, resolvedSources);
13090
+ append(names, map.names);
13091
+ if (contents)
13092
+ append(sourcesContent, contents);
13093
+ else
13094
+ for (let i = 0; i < resolvedSources.length; i++)
13095
+ sourcesContent.push(null);
13096
+ if (ignores)
13097
+ for (let i = 0; i < ignores.length; i++)
13098
+ ignoreList.push(ignores[i] + sourcesOffset);
13099
+ for (let i = 0; i < decoded.length; i++) {
13100
+ const lineI = lineOffset + i;
13101
+ if (lineI > stopLine)
13102
+ return;
13103
+ const out = getLine(mappings, lineI);
13104
+ const cOffset = i === 0 ? columnOffset : 0;
13105
+ const line = decoded[i];
13106
+ for (let j = 0; j < line.length; j++) {
13107
+ const seg = line[j];
13108
+ const column = cOffset + seg[COLUMN];
13109
+ if (lineI === stopLine && column >= stopColumn)
13110
+ return;
13111
+ if (seg.length === 1) {
13112
+ out.push([column]);
13113
+ continue;
13114
+ }
13115
+ const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX];
13116
+ const sourceLine = seg[SOURCE_LINE];
13117
+ const sourceColumn = seg[SOURCE_COLUMN];
13118
+ out.push(seg.length === 4 ? [column, sourcesIndex, sourceLine, sourceColumn] : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]]);
13119
+ }
13120
+ }
13121
+ }
13122
+ function append(arr, other) {
13123
+ for (let i = 0; i < other.length; i++)
13124
+ arr.push(other[i]);
13125
+ }
13126
+ function getLine(arr, index) {
13127
+ for (let i = arr.length; i <= index; i++)
13128
+ arr[i] = [];
13129
+ return arr[index];
13130
+ }
13131
+ const LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
13132
+ const COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
13133
+ const LEAST_UPPER_BOUND = -1;
13134
+ const GREATEST_LOWER_BOUND = 1;
13135
+ class TraceMap2 {
13136
+ constructor(map, mapUrl) {
13137
+ const isString = typeof map === "string";
13138
+ if (!isString && map._decodedMemo)
13139
+ return map;
13140
+ const parsed = isString ? JSON.parse(map) : map;
13141
+ const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
13142
+ this.version = version;
13143
+ this.file = file;
13144
+ this.names = names || [];
13145
+ this.sourceRoot = sourceRoot;
13146
+ this.sources = sources;
13147
+ this.sourcesContent = sourcesContent;
13148
+ this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
13149
+ const from = resolve2(sourceRoot || "", stripFilename(mapUrl));
13150
+ this.resolvedSources = sources.map((s) => resolve2(s || "", from));
13151
+ const { mappings } = parsed;
13152
+ if (typeof mappings === "string") {
13153
+ this._encoded = mappings;
13154
+ this._decoded = void 0;
13155
+ } else {
13156
+ this._encoded = void 0;
13157
+ this._decoded = maybeSort(mappings, isString);
13158
+ }
13159
+ this._decodedMemo = memoizedState();
13160
+ this._bySources = void 0;
13161
+ this._bySourceMemos = void 0;
13162
+ }
13163
+ }
13164
+ function cast(map) {
13165
+ return map;
13166
+ }
13167
+ function encodedMappings(map) {
13168
+ var _a;
13169
+ var _b;
13170
+ return (_a = (_b = cast(map))._encoded) !== null && _a !== void 0 ? _a : _b._encoded = sourcemapCodec.encode(cast(map)._decoded);
13171
+ }
13172
+ function decodedMappings(map) {
13173
+ var _a;
13174
+ return (_a = cast(map))._decoded || (_a._decoded = sourcemapCodec.decode(cast(map)._encoded));
13175
+ }
13176
+ function traceSegment(map, line, column) {
13177
+ const decoded = decodedMappings(map);
13178
+ if (line >= decoded.length)
13179
+ return null;
13180
+ const segments = decoded[line];
13181
+ const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, GREATEST_LOWER_BOUND);
13182
+ return index === -1 ? null : segments[index];
13183
+ }
13184
+ function originalPositionFor2(map, needle) {
13185
+ let { line, column, bias } = needle;
13186
+ line--;
13187
+ if (line < 0)
13188
+ throw new Error(LINE_GTR_ZERO);
13189
+ if (column < 0)
13190
+ throw new Error(COL_GTR_EQ_ZERO);
13191
+ const decoded = decodedMappings(map);
13192
+ if (line >= decoded.length)
13193
+ return OMapping(null, null, null, null);
13194
+ const segments = decoded[line];
13195
+ const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
13196
+ if (index === -1)
13197
+ return OMapping(null, null, null, null);
13198
+ const segment = segments[index];
13199
+ if (segment.length === 1)
13200
+ return OMapping(null, null, null, null);
13201
+ const { names, resolvedSources } = map;
13202
+ return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
13203
+ }
13204
+ function generatedPositionFor(map, needle) {
13205
+ const { source: source2, line, column, bias } = needle;
13206
+ return generatedPosition(map, source2, line, column, bias || GREATEST_LOWER_BOUND, false);
13207
+ }
13208
+ function allGeneratedPositionsFor(map, needle) {
13209
+ const { source: source2, line, column, bias } = needle;
13210
+ return generatedPosition(map, source2, line, column, bias || LEAST_UPPER_BOUND, true);
13211
+ }
13212
+ function eachMapping(map, cb) {
13213
+ const decoded = decodedMappings(map);
13214
+ const { names, resolvedSources } = map;
13215
+ for (let i = 0; i < decoded.length; i++) {
13216
+ const line = decoded[i];
13217
+ for (let j = 0; j < line.length; j++) {
13218
+ const seg = line[j];
13219
+ const generatedLine = i + 1;
13220
+ const generatedColumn = seg[0];
13221
+ let source2 = null;
13222
+ let originalLine = null;
13223
+ let originalColumn = null;
13224
+ let name = null;
13225
+ if (seg.length !== 1) {
13226
+ source2 = resolvedSources[seg[1]];
13227
+ originalLine = seg[2] + 1;
13228
+ originalColumn = seg[3];
13229
+ }
13230
+ if (seg.length === 5)
13231
+ name = names[seg[4]];
13232
+ cb({
13233
+ generatedLine,
13234
+ generatedColumn,
13235
+ source: source2,
13236
+ originalLine,
13237
+ originalColumn,
13238
+ name
13239
+ });
13240
+ }
13241
+ }
13242
+ }
13243
+ function sourceIndex(map, source2) {
13244
+ const { sources, resolvedSources } = map;
13245
+ let index = sources.indexOf(source2);
13246
+ if (index === -1)
13247
+ index = resolvedSources.indexOf(source2);
13248
+ return index;
13249
+ }
13250
+ function sourceContentFor(map, source2) {
13251
+ const { sourcesContent } = map;
13252
+ if (sourcesContent == null)
13253
+ return null;
13254
+ const index = sourceIndex(map, source2);
13255
+ return index === -1 ? null : sourcesContent[index];
13256
+ }
13257
+ function isIgnored(map, source2) {
13258
+ const { ignoreList } = map;
13259
+ if (ignoreList == null)
13260
+ return false;
13261
+ const index = sourceIndex(map, source2);
13262
+ return index === -1 ? false : ignoreList.includes(index);
13263
+ }
13264
+ function presortedDecodedMap(map, mapUrl) {
13265
+ const tracer = new TraceMap2(clone(map, []), mapUrl);
13266
+ cast(tracer)._decoded = map.mappings;
13267
+ return tracer;
13268
+ }
13269
+ function decodedMap(map) {
13270
+ return clone(map, decodedMappings(map));
13271
+ }
13272
+ function encodedMap(map) {
13273
+ return clone(map, encodedMappings(map));
13274
+ }
13275
+ function clone(map, mappings) {
13276
+ return {
13277
+ version: map.version,
13278
+ file: map.file,
13279
+ names: map.names,
13280
+ sourceRoot: map.sourceRoot,
13281
+ sources: map.sources,
13282
+ sourcesContent: map.sourcesContent,
13283
+ mappings,
13284
+ ignoreList: map.ignoreList || map.x_google_ignoreList
13285
+ };
13286
+ }
13287
+ function OMapping(source2, line, column, name) {
13288
+ return { source: source2, line, column, name };
13289
+ }
13290
+ function GMapping(line, column) {
13291
+ return { line, column };
13292
+ }
13293
+ function traceSegmentInternal(segments, memo, line, column, bias) {
13294
+ let index = memoizedBinarySearch(segments, column, memo, line);
13295
+ if (found) {
13296
+ index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
13297
+ } else if (bias === LEAST_UPPER_BOUND)
13298
+ index++;
13299
+ if (index === -1 || index === segments.length)
13300
+ return -1;
13301
+ return index;
13302
+ }
13303
+ function sliceGeneratedPositions(segments, memo, line, column, bias) {
13304
+ let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND);
13305
+ if (!found && bias === LEAST_UPPER_BOUND)
13306
+ min++;
13307
+ if (min === -1 || min === segments.length)
13308
+ return [];
13309
+ const matchedColumn = found ? column : segments[min][COLUMN];
13310
+ if (!found)
13311
+ min = lowerBound(segments, matchedColumn, min);
13312
+ const max = upperBound(segments, matchedColumn, min);
13313
+ const result = [];
13314
+ for (; min <= max; min++) {
13315
+ const segment = segments[min];
13316
+ result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]));
13317
+ }
13318
+ return result;
13319
+ }
13320
+ function generatedPosition(map, source2, line, column, bias, all) {
13321
+ var _a;
13322
+ line--;
13323
+ if (line < 0)
13324
+ throw new Error(LINE_GTR_ZERO);
13325
+ if (column < 0)
13326
+ throw new Error(COL_GTR_EQ_ZERO);
13327
+ const { sources, resolvedSources } = map;
13328
+ let sourceIndex2 = sources.indexOf(source2);
13329
+ if (sourceIndex2 === -1)
13330
+ sourceIndex2 = resolvedSources.indexOf(source2);
13331
+ if (sourceIndex2 === -1)
13332
+ return all ? [] : GMapping(null, null);
13333
+ const generated = (_a = cast(map))._bySources || (_a._bySources = buildBySources(decodedMappings(map), cast(map)._bySourceMemos = sources.map(memoizedState)));
13334
+ const segments = generated[sourceIndex2][line];
13335
+ if (segments == null)
13336
+ return all ? [] : GMapping(null, null);
13337
+ const memo = cast(map)._bySourceMemos[sourceIndex2];
13338
+ if (all)
13339
+ return sliceGeneratedPositions(segments, memo, line, column, bias);
13340
+ const index = traceSegmentInternal(segments, memo, line, column, bias);
13341
+ if (index === -1)
13342
+ return GMapping(null, null);
13343
+ const segment = segments[index];
13344
+ return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
13345
+ }
13346
+ exports2.AnyMap = AnyMap;
13347
+ exports2.GREATEST_LOWER_BOUND = GREATEST_LOWER_BOUND;
13348
+ exports2.LEAST_UPPER_BOUND = LEAST_UPPER_BOUND;
13349
+ exports2.TraceMap = TraceMap2;
13350
+ exports2.allGeneratedPositionsFor = allGeneratedPositionsFor;
13351
+ exports2.decodedMap = decodedMap;
13352
+ exports2.decodedMappings = decodedMappings;
13353
+ exports2.eachMapping = eachMapping;
13354
+ exports2.encodedMap = encodedMap;
13355
+ exports2.encodedMappings = encodedMappings;
13356
+ exports2.generatedPositionFor = generatedPositionFor;
13357
+ exports2.isIgnored = isIgnored;
13358
+ exports2.originalPositionFor = originalPositionFor2;
13359
+ exports2.presortedDecodedMap = presortedDecodedMap;
13360
+ exports2.sourceContentFor = sourceContentFor;
13361
+ exports2.traceSegment = traceSegment;
13362
+ });
13363
+ })(traceMapping_umd, traceMapping_umd.exports);
13364
+ var traceMapping_umdExports = traceMapping_umd.exports;
13365
+ function notNullish(v) {
13366
+ return v != null;
13367
+ }
13368
+ const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
13369
+ const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
13370
+ const stackIgnorePatterns = [
13371
+ "node:internal",
13372
+ /\/packages\/\w+\/dist\//,
13373
+ /\/@vitest\/\w+\/dist\//,
13374
+ "/vitest/dist/",
13375
+ "/vitest/src/",
13376
+ "/vite-node/dist/",
13377
+ "/vite-node/src/",
13378
+ "/node_modules/chai/",
13379
+ "/node_modules/tinypool/",
13380
+ "/node_modules/tinyspy/",
13381
+ // browser related deps
13382
+ "/deps/chunk-",
13383
+ "/deps/@vitest",
13384
+ "/deps/loupe",
13385
+ "/deps/chai",
13386
+ /node:\w+/,
13387
+ /__vitest_test__/,
13388
+ /__vitest_browser__/,
13389
+ /\/deps\/vitest_/
13390
+ ];
13391
+ function extractLocation(urlLike) {
13392
+ if (!urlLike.includes(":")) {
13393
+ return [urlLike];
13394
+ }
13395
+ const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
13396
+ const parts = regExp.exec(urlLike.replace(/^\(|\)$/g, ""));
13397
+ if (!parts) {
13398
+ return [urlLike];
13399
+ }
13400
+ let url2 = parts[1];
13401
+ if (url2.startsWith("async ")) {
13402
+ url2 = url2.slice(6);
13403
+ }
13404
+ if (url2.startsWith("http:") || url2.startsWith("https:")) {
13405
+ const urlObj = new URL(url2);
13406
+ url2 = urlObj.pathname;
13407
+ }
13408
+ if (url2.startsWith("/@fs/")) {
13409
+ const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url2);
13410
+ url2 = url2.slice(isWindows ? 5 : 4);
13411
+ }
13412
+ return [url2, parts[2] || void 0, parts[3] || void 0];
13413
+ }
13414
+ function parseSingleFFOrSafariStack(raw) {
13415
+ let line = raw.trim();
13416
+ if (SAFARI_NATIVE_CODE_REGEXP.test(line)) {
13417
+ return null;
13418
+ }
13419
+ if (line.includes(" > eval")) {
13420
+ line = line.replace(
13421
+ / line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,
13422
+ ":$1"
13423
+ );
13424
+ }
13425
+ if (!line.includes("@") && !line.includes(":")) {
13426
+ return null;
13427
+ }
13428
+ const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(@)/;
13429
+ const matches2 = line.match(functionNameRegex);
13430
+ const functionName = matches2 && matches2[1] ? matches2[1] : void 0;
13431
+ const [url2, lineNumber, columnNumber] = extractLocation(
13432
+ line.replace(functionNameRegex, "")
13433
+ );
13434
+ if (!url2 || !lineNumber || !columnNumber) {
13435
+ return null;
13436
+ }
13437
+ return {
13438
+ file: url2,
13439
+ method: functionName || "",
13440
+ line: Number.parseInt(lineNumber),
13441
+ column: Number.parseInt(columnNumber)
13442
+ };
13443
+ }
13444
+ function parseSingleV8Stack(raw) {
13445
+ let line = raw.trim();
13446
+ if (!CHROME_IE_STACK_REGEXP.test(line)) {
13447
+ return null;
13448
+ }
13449
+ if (line.includes("(eval ")) {
13450
+ line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
13451
+ }
13452
+ let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
13453
+ const location2 = sanitizedLine.match(/ (\(.+\)$)/);
13454
+ sanitizedLine = location2 ? sanitizedLine.replace(location2[0], "") : sanitizedLine;
13455
+ const [url2, lineNumber, columnNumber] = extractLocation(
13456
+ location2 ? location2[1] : sanitizedLine
13457
+ );
13458
+ let method = location2 && sanitizedLine || "";
13459
+ let file = url2 && ["eval", "<anonymous>"].includes(url2) ? void 0 : url2;
13460
+ if (!file || !lineNumber || !columnNumber) {
13461
+ return null;
13462
+ }
13463
+ if (method.startsWith("async ")) {
13464
+ method = method.slice(6);
13465
+ }
13466
+ if (file.startsWith("file://")) {
13467
+ file = file.slice(7);
13468
+ }
13469
+ file = resolve(file);
13470
+ if (method) {
13471
+ method = method.replace(/__vite_ssr_import_\d+__\./g, "");
13472
+ }
13473
+ return {
13474
+ method,
13475
+ file,
13476
+ line: Number.parseInt(lineNumber),
13477
+ column: Number.parseInt(columnNumber)
13478
+ };
13479
+ }
13480
+ function createStackString(stacks) {
13481
+ return stacks.map((stack) => {
13482
+ const line = `${stack.file}:${stack.line}:${stack.column}`;
13483
+ if (stack.method) {
13484
+ return ` at ${stack.method}(${line})`;
13485
+ }
13486
+ return ` at ${line}`;
13487
+ }).join("\n");
13488
+ }
13489
+ function parseStacktrace(stack, options = {}) {
13490
+ const { ignoreStackEntries = stackIgnorePatterns } = options;
13491
+ let stacks = !CHROME_IE_STACK_REGEXP.test(stack) ? parseFFOrSafariStackTrace(stack) : parseV8Stacktrace(stack);
13492
+ if (ignoreStackEntries.length) {
13493
+ stacks = stacks.filter(
13494
+ (stack2) => !ignoreStackEntries.some((p) => stack2.file.match(p))
13495
+ );
13496
+ }
13497
+ return stacks.map((stack2) => {
13498
+ var _a;
13499
+ if (options.getFileName) {
13500
+ stack2.file = options.getFileName(stack2.file);
13501
+ }
13502
+ const map = (_a = options.getSourceMap) == null ? void 0 : _a.call(options, stack2.file);
13503
+ if (!map || typeof map !== "object" || !map.version) {
13504
+ return stack2;
13505
+ }
13506
+ const traceMap = new traceMapping_umdExports.TraceMap(map);
13507
+ const { line, column } = traceMapping_umdExports.originalPositionFor(traceMap, stack2);
13508
+ if (line != null && column != null) {
13509
+ return { ...stack2, line, column };
13510
+ }
13511
+ return stack2;
13512
+ });
13513
+ }
13514
+ function parseFFOrSafariStackTrace(stack) {
13515
+ return stack.split("\n").map((line) => parseSingleFFOrSafariStack(line)).filter(notNullish);
13516
+ }
13517
+ function parseV8Stacktrace(stack) {
13518
+ return stack.split("\n").map((line) => parseSingleV8Stack(line)).filter(notNullish);
13519
+ }
12279
13520
  class VitestBrowserSnapshotEnvironment {
12280
13521
  constructor() {
12281
13522
  __publicField(this, "sourceMaps", /* @__PURE__ */ new Map());
@@ -12450,6 +13691,14 @@ async function initiateRunner(state, mocker, config) {
12450
13691
  ]);
12451
13692
  runner.config.diffOptions = diffOptions;
12452
13693
  cachedRunner = runner;
13694
+ getWorkerState().onFilterStackTrace = (stack) => {
13695
+ const stacks = parseStacktrace(stack, {
13696
+ getSourceMap(file) {
13697
+ return runner.sourceMapCache.get(file);
13698
+ }
13699
+ });
13700
+ return createStackString(stacks);
13701
+ };
12453
13702
  return runner;
12454
13703
  }
12455
13704
  async function updateFilesLocations(files, sourceMaps) {