@lwrjs/client-modules 0.10.0-alpha.21 → 0.10.0-alpha.22

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.
@@ -39,7 +39,7 @@ const {
39
39
  const {
40
40
  toString: ObjectProtoToString$LWS
41
41
  } = ObjectProto$LWS$1;
42
- function isObject$LWS(value$LWS) {
42
+ function isObject$LWS$1(value$LWS) {
43
43
  return typeof value$LWS === 'object' && value$LWS !== null;
44
44
  }
45
45
  function isObjectLike$LWS(value$LWS) {
@@ -225,9 +225,10 @@ const WEBPACK_REQUIRE_NAME$LWS = '__webpack_require__';
225
225
  const ERR_ILLEGAL_PROPERTY_ACCESS$LWS = 'Illegal property access.';
226
226
  const ERR_INVALID_SANDBOX_KEY$LWS = 'Invalid sandbox key.';
227
227
  // Near-membrane constants.
228
- const LOCKER_NEAR_MEMBRANE_PROXY_MASKED_SYMBOL$LWS = SymbolFor$LWS$1('@@lockerNearMembraneProxyMasked');
228
+ const LOCKER_NEAR_MEMBRANE_IS_MASKED_SYMBOL$LWS = SymbolFor$LWS$1('@@lockerNearMembraneIsMasked');
229
229
  const LOCKER_NEAR_MEMBRANE_SERIALIZED_VALUE_SYMBOL$LWS = SymbolFor$LWS$1('@@lockerNearMembraneSerializedValue');
230
230
  const LOCKER_NEAR_MEMBRANE_SYMBOL$LWS = SymbolFor$LWS$1('@@lockerNearMembrane');
231
+ const LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS = SymbolFor$LWS$1('@@lockerNearMembraneUnmaskedValue');
231
232
  // Legacy symbol used by packages/locker-core-engine/src/LockerFilter.js.
232
233
  const SYMBOL_LIVE_OBJECT$LWS = SymbolFor$LWS$1('@@lockerLiveValue');
233
234
  // Object brand constants.
@@ -294,17 +295,87 @@ const {
294
295
  bind: FunctionProtoBind$LWS,
295
296
  toString: FunctionProtoToString$LWS
296
297
  } = Function.prototype;
297
- function isProxyMaskedFunction$LWS(value$LWS) {
298
+ function createUnmaskableTraps$LWS(func$LWS) {
299
+ let handshakeUnmaskFlag$LWS = false;
300
+ return {
301
+ defineProperty(target$LWS, key$LWS, desc$LWS) {
302
+ // Defining forgeries of handshake properties is not allowed.
303
+ if (key$LWS === LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS) {
304
+ throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
305
+ }
306
+ return ReflectDefineProperty$LWS$1(target$LWS, key$LWS, desc$LWS);
307
+ },
308
+ get(target$LWS, key$LWS, receiver$LWS, handshake$LWS = false) {
309
+ // Only allow accessing handshake property values if the "has"
310
+ // trap has been triggered immediately BEFORE and the property
311
+ // does NOT exist.
312
+ handshakeUnmaskFlag$LWS && (handshakeUnmaskFlag$LWS = handshake$LWS);
313
+ const isUnmaskedSymbol$LWS = key$LWS === LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS;
314
+ if (handshakeUnmaskFlag$LWS) {
315
+ // Exit without performing a [[Get]] for
316
+ // `LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL` properties
317
+ // because we know that when the
318
+ // `handshakeUnmaskFlag` is ON that
319
+ // there are NO shadowed values.
320
+ if (isUnmaskedSymbol$LWS) {
321
+ return func$LWS;
322
+ }
323
+ }
324
+ const result$LWS = ReflectGet$LWS(target$LWS, key$LWS, receiver$LWS);
325
+ // Getting forged values of `LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL`
326
+ // properties is not allowed.
327
+ if (result$LWS !== undefined && isUnmaskedSymbol$LWS) {
328
+ throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
329
+ }
330
+ return result$LWS;
331
+ },
332
+ getOwnPropertyDescriptor(target$LWS, key$LWS) {
333
+ const result$LWS = ReflectGetOwnPropertyDescriptor$LWS(target$LWS, key$LWS);
334
+ // Getting forged descriptors of handshake properties is not allowed.
335
+ if (result$LWS && key$LWS === LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS) {
336
+ throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
337
+ }
338
+ return result$LWS;
339
+ },
340
+ has(target$LWS, key$LWS) {
341
+ const result$LWS = ReflectHas$LWS(target$LWS, key$LWS);
342
+ const isUnmaskedSymbol$LWS = key$LWS === LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS;
343
+ if (result$LWS) {
344
+ handshakeUnmaskFlag$LWS = false;
345
+ // Checking the existence of forged `LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL`
346
+ // properties is not allowed.
347
+ if (isUnmaskedSymbol$LWS) {
348
+ throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
349
+ }
350
+ } else {
351
+ // The `handshakeUnmaskFlag` is ON if the
352
+ // handshake property does NOT exist on the object or its
353
+ // [[Prototype]].
354
+ handshakeUnmaskFlag$LWS = isUnmaskedSymbol$LWS;
355
+ }
356
+ return result$LWS;
357
+ },
358
+ set(target$LWS, key$LWS, value$LWS, receiver$LWS) {
359
+ // Setting forged values of handshake properties is not allowed.
360
+ if (key$LWS === LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS) {
361
+ throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
362
+ }
363
+ return ReflectSet$LWS(target$LWS, key$LWS, value$LWS, receiver$LWS);
364
+ }
365
+ };
366
+ }
367
+ function getUnmaskedFunction$LWS(func$LWS) {
368
+ const unmasked$LWS = LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS in func$LWS ? undefined : func$LWS[LOCKER_NEAR_MEMBRANE_UNMASKED_VALUE_SYMBOL$LWS];
369
+ return unmasked$LWS === undefined ? func$LWS : unmasked$LWS;
370
+ }
371
+ function isMaskedFunction$LWS(value$LWS) {
298
372
  // To extract the flag value of a blue near-membrane proxy we must perform
299
373
  // a two step handshake. First, we trigger the "has" trap for the
300
- // `LOCKER_NEAR_MEMBRANE_PROXY_MASKED_SYMBOL` property which must report
374
+ // `LOCKER_NEAR_MEMBRANE_IS_MASKED_SYMBOL` property which must report
301
375
  // `false`. Second, we trigger the "get" trap to return the flag value.
302
- return typeof value$LWS === 'function' && !(LOCKER_NEAR_MEMBRANE_PROXY_MASKED_SYMBOL$LWS in value$LWS) && value$LWS[LOCKER_NEAR_MEMBRANE_PROXY_MASKED_SYMBOL$LWS] === true;
303
- }
304
- function noop$LWS$1() {
305
- // No operation performed.
376
+ return typeof value$LWS === 'function' && !(LOCKER_NEAR_MEMBRANE_IS_MASKED_SYMBOL$LWS in value$LWS) && value$LWS[LOCKER_NEAR_MEMBRANE_IS_MASKED_SYMBOL$LWS] === true;
306
377
  }
307
- function proxyMaskFunction$LWS(func$LWS, maskFunc$LWS, trapInvokers$LWS) {
378
+ function maskFunction$LWS(func$LWS, maskFunc$LWS, trapInvokers$LWS) {
308
379
  let applyTrapInvoker$LWS = ReflectApply$LWS$1;
309
380
  let constructTrapInvoker$LWS = ReflectConstruct$LWS;
310
381
  let definePropertyTrapInvoker$LWS = ReflectDefineProperty$LWS$1;
@@ -344,7 +415,7 @@ function proxyMaskFunction$LWS(func$LWS, maskFunc$LWS, trapInvokers$LWS) {
344
415
  defineProperty(target$LWS, key$LWS, desc$LWS) {
345
416
  lastProxyTrapCalled$LWS = 4 /* ProxyHandlerTraps.DefineProperty */;
346
417
  // Defining forgeries of handshake properties is not allowed.
347
- if (key$LWS === LOCKER_NEAR_MEMBRANE_PROXY_MASKED_SYMBOL$LWS) {
418
+ if (key$LWS === LOCKER_NEAR_MEMBRANE_IS_MASKED_SYMBOL$LWS) {
348
419
  throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
349
420
  }
350
421
  return definePropertyTrapInvoker$LWS(target$LWS, key$LWS, desc$LWS);
@@ -360,10 +431,10 @@ function proxyMaskFunction$LWS(func$LWS, maskFunc$LWS, trapInvokers$LWS) {
360
431
  handshakeFlag$LWS && (handshakeFlag$LWS = lastProxyTrapCalled$LWS === 128 /* ProxyHandlerTraps.Has */);
361
432
  handshakeProxyMaskedFlag$LWS && (handshakeProxyMaskedFlag$LWS = handshakeFlag$LWS);
362
433
  lastProxyTrapCalled$LWS = 16 /* ProxyHandlerTraps.Get */;
363
- const isProxyMaskedSymbol$LWS = key$LWS === LOCKER_NEAR_MEMBRANE_PROXY_MASKED_SYMBOL$LWS;
434
+ const isProxyMaskedSymbol$LWS = key$LWS === LOCKER_NEAR_MEMBRANE_IS_MASKED_SYMBOL$LWS;
364
435
  if (handshakeProxyMaskedFlag$LWS) {
365
436
  // Exit without performing a [[Get]] for
366
- // `LOCKER_NEAR_MEMBRANE_PROXY_MASKED_SYMBOL` properties
437
+ // `LOCKER_NEAR_MEMBRANE_IS_MASKED_SYMBOL` properties
367
438
  // because we know that when the `handshakeProxyMaskedFlag`
368
439
  // is ON that there are NO shadowed values.
369
440
  if (isProxyMaskedSymbol$LWS) {
@@ -381,7 +452,7 @@ function proxyMaskFunction$LWS(func$LWS, maskFunc$LWS, trapInvokers$LWS) {
381
452
  lastProxyTrapCalled$LWS = 32 /* ProxyHandlerTraps.GetOwnPropertyDescriptor */;
382
453
  const result$LWS = getOwnPropertyDescriptorTrapInvoker$LWS(target$LWS, key$LWS);
383
454
  // Getting forged descriptors of handshake properties is not allowed.
384
- if (result$LWS && key$LWS === LOCKER_NEAR_MEMBRANE_PROXY_MASKED_SYMBOL$LWS) {
455
+ if (result$LWS && key$LWS === LOCKER_NEAR_MEMBRANE_IS_MASKED_SYMBOL$LWS) {
385
456
  throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
386
457
  }
387
458
  return result$LWS;
@@ -393,7 +464,7 @@ function proxyMaskFunction$LWS(func$LWS, maskFunc$LWS, trapInvokers$LWS) {
393
464
  has(target$LWS, key$LWS) {
394
465
  lastProxyTrapCalled$LWS = 128 /* ProxyHandlerTraps.Has */;
395
466
  const result$LWS = hasTrapInvoker$LWS(target$LWS, key$LWS);
396
- const isProxyMaskedSymbol$LWS = key$LWS === LOCKER_NEAR_MEMBRANE_PROXY_MASKED_SYMBOL$LWS;
467
+ const isProxyMaskedSymbol$LWS = key$LWS === LOCKER_NEAR_MEMBRANE_IS_MASKED_SYMBOL$LWS;
397
468
  if (result$LWS) {
398
469
  handshakeFlag$LWS = false;
399
470
  // Checking the existence of forged handshake properties is not allowed.
@@ -423,7 +494,7 @@ function proxyMaskFunction$LWS(func$LWS, maskFunc$LWS, trapInvokers$LWS) {
423
494
  set(target$LWS, key$LWS, value$LWS, receiver$LWS) {
424
495
  lastProxyTrapCalled$LWS = 2048 /* ProxyHandlerTraps.Set */;
425
496
  // Setting forged values of handshake properties is not allowed.
426
- if (key$LWS === LOCKER_NEAR_MEMBRANE_PROXY_MASKED_SYMBOL$LWS) {
497
+ if (key$LWS === LOCKER_NEAR_MEMBRANE_IS_MASKED_SYMBOL$LWS) {
427
498
  throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
428
499
  }
429
500
  return setTrapInvoker$LWS(target$LWS, key$LWS, value$LWS, receiver$LWS);
@@ -435,6 +506,9 @@ function proxyMaskFunction$LWS(func$LWS, maskFunc$LWS, trapInvokers$LWS) {
435
506
  });
436
507
  return proxy$LWS;
437
508
  }
509
+ function noop$LWS$1() {
510
+ // No operation performed.
511
+ }
438
512
  const MapCtor$LWS$1 = Map;
439
513
  const {
440
514
  prototype: MapProto$LWS$1
@@ -496,6 +570,7 @@ const {
496
570
  endsWith: StringProtoEndsWith$LWS,
497
571
  includes: StringProtoIncludes$LWS,
498
572
  indexOf: StringProtoIndexOf$LWS,
573
+ lastIndexOf: StringProtoLastIndexOf$LWS,
499
574
  match: StringProtoMatch$LWS,
500
575
  replace: StringProtoReplace$LWS,
501
576
  slice: StringProtoSlice$LWS,
@@ -601,8 +676,13 @@ const {
601
676
  test: RegExpProtoTest$LWS$1
602
677
  } = RegExpProto$LWS$1;
603
678
  const RegExpProtoSourceGetter$LWS = ObjectLookupOwnGetter$LWS$1(RegExpProto$LWS$1, 'source');
679
+ const endsWithWordCharRegExp$LWS = /\w$/;
604
680
  const specialCharRegExp$LWS = /[\\^$.*+?()[\]{}|]/g;
605
- function escapeRegExp$LWS(string$LWS) {
681
+ const startsWithWordCharRegExp$LWS = /^\w/;
682
+ function toRegExpEscapedIdentifierName$LWS(identifier$LWS) {
683
+ return (startsWithWordCharRegExp$LWS.test(identifier$LWS) ? '\\b' : '') + toRegExpEscapedString$LWS(identifier$LWS) + (endsWithWordCharRegExp$LWS.test(identifier$LWS) ? '\\b' : '');
684
+ }
685
+ function toRegExpEscapedString$LWS(string$LWS) {
606
686
  return ReflectApply$LWS$1(StringProtoReplace$LWS, string$LWS, [specialCharRegExp$LWS, '\\$&']);
607
687
  }
608
688
  const SetCtor$LWS$1 = Set;
@@ -1368,7 +1448,7 @@ const {
1368
1448
  } = PromiseCtor$LWS.prototype;
1369
1449
  const PromiseResolve$LWS = PromiseCtor$LWS.resolve.bind(PromiseCtor$LWS);
1370
1450
  const PromiseReject$LWS = PromiseCtor$LWS.reject.bind(PromiseCtor$LWS);
1371
- /*! version: 0.19.4 */
1451
+ /*! version: 0.19.10 */
1372
1452
 
1373
1453
  /*!
1374
1454
  * Copyright (C) 2019 salesforce.com, inc.
@@ -1406,6 +1486,11 @@ const rootDocument$LWS = document;
1406
1486
  const {
1407
1487
  prototype: DocumentProto$LWS$1
1408
1488
  } = Document;
1489
+ // Used by '@locker/near-membrane/dom'.
1490
+ const {
1491
+ close: DocumentProtoClose$LWS$1,
1492
+ open: DocumentProtoOpen$LWS$1
1493
+ } = DocumentProto$LWS$1;
1409
1494
  const {
1410
1495
  createComment: DocumentProtoCreateComment$LWS,
1411
1496
  createElement: DocumentProtoCreateElement$LWS$1,
@@ -1514,11 +1599,13 @@ ObjectLookupOwnGetter$LWS$1(NodeProto$LWS$1, 'lastChild');
1514
1599
  const NodeProtoNodeNameGetter$LWS = ObjectLookupOwnGetter$LWS$1(NodeProto$LWS$1, 'nodeName');
1515
1600
  const NodeProtoOwnerDocumentGetter$LWS = ObjectLookupOwnGetter$LWS$1(NodeProto$LWS$1, 'ownerDocument');
1516
1601
  ReflectGetOwnPropertyDescriptor$LWS(NodeProto$LWS$1, 'textContent');
1602
+
1603
+ // Check for the noopener feature being enabled:
1604
+ // - noopener
1605
+ // - noopener=1
1606
+ // - noopener=yes
1607
+ const noopenerRegExp$LWS = /(^|,)(\s*noopener\s*=\s*(?:yes|1)\s*)(,|$)/g;
1517
1608
  const rootWindow$LWS$1 = window;
1518
- const {
1519
- location: rootWindowLocation$LWS,
1520
- top: rootWindowTop$LWS
1521
- } = rootWindow$LWS$1;
1522
1609
  // These properties are part of the WindowOrGlobalScope mixin and not on
1523
1610
  // Window.prototype.
1524
1611
  // https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope
@@ -1530,8 +1617,9 @@ const {
1530
1617
  decodeURIComponent: WindowDecodeURIComponent$LWS,
1531
1618
  encodeURIComponent: WindowEncodeURIComponent$LWS,
1532
1619
  fetch: WindowFetch$LWS,
1620
+ location: rootWindowLocation$LWS,
1533
1621
  setInterval: WindowSetInterval$LWS,
1534
- top: topWindow$LWS
1622
+ top: rootWindowTop$LWS
1535
1623
  } = rootWindow$LWS$1;
1536
1624
  const WindowQueueMicrotask$LWS = (() => {
1537
1625
  const {
@@ -1558,6 +1646,38 @@ const WindowDocumentGetter$LWS = ObjectLookupOwnGetter$LWS$1(rootWindow$LWS$1, '
1558
1646
  const WindowFrameElementGetter$LWS = ObjectLookupOwnGetter$LWS$1(rootWindow$LWS$1, 'frameElement');
1559
1647
  const WindowLengthGetter$LWS = ObjectLookupOwnGetter$LWS$1(rootWindow$LWS$1, 'length');
1560
1648
  const WindowLocationGetter$LWS = ObjectLookupOwnGetter$LWS$1(rootWindow$LWS$1, 'location');
1649
+ function initWindowOpenChildWindow$LWS(win$LWS, url$LWS) {
1650
+ // Skip if `url` is an empty string or `undefined` as a blank page will be
1651
+ // opened into the targeted browsing context and not navigated away from.
1652
+ // https://developer.mozilla.org/en-US/docs/Web/API/Window/open#parameters
1653
+ if (typeof url$LWS === 'string' && url$LWS !== '') {
1654
+ // `WindowDocumentGetter` will throw if `win` is an opaque cross-origin
1655
+ // window.
1656
+ try {
1657
+ const doc$LWS = ReflectApply$LWS$1(WindowDocumentGetter$LWS, win$LWS, []);
1658
+ // `win.location` is a non-configurable property so can be accessed
1659
+ // directly.
1660
+ const {
1661
+ location: location$LWS
1662
+ } = win$LWS;
1663
+ // Check if the `location.href` is an intermediate value different
1664
+ // than `url`.
1665
+ // `location.href` is a non-configurable property so can be accessed
1666
+ // directly.
1667
+ if (location$LWS.href !== url$LWS) {
1668
+ // Opening and closing `doc` prevents the default browser
1669
+ // redirect behavior.
1670
+ ReflectApply$LWS$1(DocumentProtoOpen$LWS$1, doc$LWS, []);
1671
+ ReflectApply$LWS$1(DocumentProtoClose$LWS$1, doc$LWS, []);
1672
+ // `location.replace` is a non-configurable property so can be
1673
+ // accessed directly.
1674
+ location$LWS.replace(url$LWS);
1675
+ }
1676
+ // eslint-disable-next-line no-empty
1677
+ } catch (_unused$LWS) {}
1678
+ }
1679
+ return win$LWS;
1680
+ }
1561
1681
  function isWindow$LWS(value$LWS) {
1562
1682
  if (typeof value$LWS === 'object' && value$LWS !== null && ObjectHasOwn$LWS$1(value$LWS, 'window') && value$LWS.window === value$LWS) {
1563
1683
  // Slower check that must certainly detect a window object.
@@ -1573,10 +1693,54 @@ function isWindow$LWS(value$LWS) {
1573
1693
  ReflectApply$LWS$1(WindowLocationGetter$LWS, value$LWS, []);
1574
1694
  return true;
1575
1695
  // eslint-disable-next-line no-empty
1576
- } catch (_unused$LWS) {}
1696
+ } catch (_unused2$LWS) {}
1577
1697
  }
1578
1698
  return false;
1579
1699
  }
1700
+ function normalizeWindowOpenArguments$LWS(args$LWS) {
1701
+ const normalizedArgs$LWS = shallowCloneArray$LWS(args$LWS);
1702
+ const {
1703
+ length: length$LWS
1704
+ } = normalizedArgs$LWS;
1705
+ if (length$LWS) {
1706
+ const url$LWS = normalizedArgs$LWS[0];
1707
+ if (typeof url$LWS !== 'string') {
1708
+ normalizedArgs$LWS[0] = url$LWS ? `${url$LWS}` : undefined;
1709
+ }
1710
+ }
1711
+ if (length$LWS > 1) {
1712
+ const target$LWS = normalizedArgs$LWS[1];
1713
+ if (typeof target$LWS !== 'string') {
1714
+ normalizedArgs$LWS[1] = target$LWS ? `${target$LWS}` : undefined;
1715
+ }
1716
+ }
1717
+ if (length$LWS > 2) {
1718
+ let features$LWS = normalizedArgs$LWS[2];
1719
+ if (typeof features$LWS !== 'string') {
1720
+ features$LWS = features$LWS ? `${features$LWS}` : undefined;
1721
+ }
1722
+ if (features$LWS) {
1723
+ // Lowercase the features string because it is case insensitive.
1724
+ // https://html.spec.whatwg.org/multipage/window-object.html#normalizing-the-feature-name
1725
+ let loweredFeatures$LWS = ReflectApply$LWS$1(StringProtoToLowerCase$LWS, features$LWS, []);
1726
+ // RegExp.prototype[Symbol.replace] resets the lastIndex of global
1727
+ // regexp to 0.
1728
+ // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace
1729
+ if (ReflectApply$LWS$1(RegExpProtoTest$LWS$1, noopenerRegExp$LWS, [loweredFeatures$LWS])) {
1730
+ // Replacing noopener with an enabled state that is supported
1731
+ // across all browsers. Firefox Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1566619
1732
+ loweredFeatures$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, loweredFeatures$LWS, [
1733
+ // RegExp.prototype[Symbol.replace] resets the lastIndex of
1734
+ // global regexp to 0.
1735
+ // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace
1736
+ noopenerRegExp$LWS, (_match$LWS, leading$LWS, _feature$LWS, ending$LWS) => `${leading$LWS}noopener${ending$LWS}`]);
1737
+ }
1738
+ features$LWS = loweredFeatures$LWS;
1739
+ }
1740
+ normalizedArgs$LWS[2] = features$LWS;
1741
+ }
1742
+ return normalizedArgs$LWS;
1743
+ }
1580
1744
 
1581
1745
  /* eslint-disable no-underscore-dangle */
1582
1746
  class Validator$LWS {
@@ -1696,10 +1860,10 @@ item$LWS => {
1696
1860
  const brand$LWS = item$LWS == null ? void 0 : item$LWS.brand;
1697
1861
  return typeof brand$LWS === 'string' && ReflectApply$LWS$1(RegExpProtoTest$LWS$1, webKitUserAgentRegExp$LWS, [brand$LWS]);
1698
1862
  }]) !== undefined : ReflectApply$LWS$1(RegExpProtoTest$LWS$1, webKitUserAgentRegExp$LWS, [getUserAgent$LWS$1()]));
1699
- const CustomElementRegistryProto$LWS = rootWindow$LWS$1 == null ? void 0 : (_rootWindow$CustomEle$LWS = rootWindow$LWS$1.CustomElementRegistry) == null ? void 0 : _rootWindow$CustomEle$LWS.prototype;
1700
- const CustomElementRegistryProtoDefine$LWS = CustomElementRegistryProto$LWS == null ? void 0 : CustomElementRegistryProto$LWS.define;
1701
- const CustomElementRegistryProtoGet$LWS = CustomElementRegistryProto$LWS == null ? void 0 : CustomElementRegistryProto$LWS.get;
1702
- const CustomElementRegistryProtoWhenDefined$LWS = CustomElementRegistryProto$LWS == null ? void 0 : CustomElementRegistryProto$LWS.whenDefined;
1863
+ const CustomElementRegistryProto$LWS = (_rootWindow$CustomEle$LWS = rootWindow$LWS$1.CustomElementRegistry) == null ? void 0 : _rootWindow$CustomEle$LWS.prototype;
1864
+ const CustomElementRegistryProtoDefine$LWS = CustomElementRegistryProto$LWS ? getUnmaskedFunction$LWS(CustomElementRegistryProto$LWS.define) : undefined;
1865
+ const CustomElementRegistryProtoGet$LWS = CustomElementRegistryProto$LWS ? getUnmaskedFunction$LWS(CustomElementRegistryProto$LWS.get) : undefined;
1866
+ const CustomElementRegistryProtoWhenDefined$LWS = CustomElementRegistryProto$LWS ? getUnmaskedFunction$LWS(CustomElementRegistryProto$LWS.whenDefined) : undefined;
1703
1867
  const {
1704
1868
  getElementById: DocumentFragmentProtoGetElementById$LWS
1705
1869
  } = DocumentFragment.prototype;
@@ -1727,13 +1891,20 @@ const {
1727
1891
  dispatchEvent: EventTargetProtoDispatchEvent$LWS,
1728
1892
  removeEventListener: EventTargetProtoRemoveEventListener$LWS
1729
1893
  } = EventTarget.prototype;
1894
+ const {
1895
+ prototype: HTMLAnchorElementProto$LWS
1896
+ } = HTMLAnchorElement;
1897
+ const HTMLAnchorElementProtoHostnameGetter$LWS = ObjectLookupOwnGetter$LWS$1(HTMLAnchorElementProto$LWS, 'hostname');
1730
1898
  const {
1731
1899
  get: HTMLAnchorElementProtoHrefGetter$LWS,
1732
1900
  set: HTMLAnchorElementProtoHrefSetter$LWS
1733
- } = ReflectGetOwnPropertyDescriptor$LWS(HTMLAnchorElement.prototype, 'href');
1734
- const HTMLAnchorElementProtoPathnameGetter$LWS = ObjectLookupOwnGetter$LWS$1(HTMLAnchorElement.prototype, 'pathname');
1735
- const HTMLAnchorElementProtoProtocolGetter$LWS = ObjectLookupOwnGetter$LWS$1(HTMLAnchorElement.prototype, 'protocol');
1736
- const HTMLElementProto$LWS = HTMLElement.prototype;
1901
+ } = ReflectGetOwnPropertyDescriptor$LWS(HTMLAnchorElementProto$LWS, 'href');
1902
+ const HTMLAnchorElementProtoPathnameGetter$LWS = ObjectLookupOwnGetter$LWS$1(HTMLAnchorElementProto$LWS, 'pathname');
1903
+ const HTMLAnchorElementProtoProtocolGetter$LWS = ObjectLookupOwnGetter$LWS$1(HTMLAnchorElementProto$LWS, 'protocol');
1904
+ const HTMLElement$LWS = getUnmaskedFunction$LWS(rootWindow$LWS$1.HTMLElement);
1905
+ const {
1906
+ prototype: HTMLElementProto$LWS
1907
+ } = HTMLElement$LWS;
1737
1908
  // Used by '@locker/near-membrane-dom'.
1738
1909
  ObjectLookupOwnGetter$LWS$1(HTMLElementProto$LWS, 'style');
1739
1910
  const HTMLElementGlobalAttributesToPropertyName$LWS = {
@@ -1839,10 +2010,25 @@ const documentPattern$LWS = 'document';
1839
2010
  const windowPattern$LWS = 'document\\.defaultView|frames|globalThis|self|window';
1840
2011
  const webpackGlobalPattern$LWS = `${windowPattern$LWS}|global`;
1841
2012
  const webpackGlobalDocumentPattern$LWS = `${documentPattern$LWS}|global.document`;
2013
+ // While fully qualified member expression access can be unambiguously detected,
2014
+ // ie. window.location or window.top, bare-word references to location and top
2015
+ // cannot. This means that code containing the fully qualified member expressions
2016
+ // can have all occurrences replaced by transforms and given special names controlled
2017
+ // by LWS in Aura. This process will also result in the program knowing that it
2018
+ // applied a given transform, which it can then use to populate a context names
2019
+ // list to be used in the declaration assignment code injected into wrapped Aura
2020
+ // component code. Because the unqualified member expressions cannot be unambiguously
2021
+ // detected, there is no way for the program to know that, eg. location.search was
2022
+ // used in the Aura component code and subsequently transformed, which means it
2023
+ // cannot be relied upon to when populating a context names list to be used in
2024
+ // the declaration assignment code. As a result, location and top must be universally
2025
+ // and explicitly included in the context object, and universally and explicitly
2026
+ // included in the context names list.
2027
+ const UNIVERSAL_CONTEXT_NAMES$LWS = [UNCOMPILED_LOCATION_NAME$LWS, UNCOMPILED_TOP_NAME$LWS, 'location', 'top'];
1842
2028
  const locationReferencesRegExp$LWS = createPropertyReferenceRegExp$LWS(`${documentPattern$LWS}|${windowPattern$LWS}`, 'location');
1843
2029
  const locationReferencesWithWebpackRegExp$LWS = createPropertyReferenceRegExp$LWS(`${webpackGlobalDocumentPattern$LWS}|${webpackGlobalPattern$LWS}`, 'location');
1844
- const sandboxEvalContextNameRegExp$LWS = new RegExpCtor$LWS$1(`(?:^|\\W)${escapeRegExp$LWS(SANDBOX_EVAL_CONTEXT_NAME$LWS)}(?:\\W|$)`);
1845
- const webpackRequireNameRegExp$LWS = new RegExpCtor$LWS$1(`\\b${escapeRegExp$LWS(WEBPACK_REQUIRE_NAME$LWS)}\\b`);
2030
+ const sandboxEvalContextNameRegExp$LWS = new RegExpCtor$LWS$1(`(?:^|\\W)${toRegExpEscapedString$LWS(SANDBOX_EVAL_CONTEXT_NAME$LWS)}(?:\\W|$)`);
2031
+ const webpackRequireNameRegExp$LWS = new RegExpCtor$LWS$1(toRegExpEscapedIdentifierName$LWS(WEBPACK_REQUIRE_NAME$LWS));
1846
2032
  const windowTopReferencesRegExp$LWS = createPropertyReferenceRegExp$LWS(windowPattern$LWS, 'top');
1847
2033
  const windowTopReferencesWithWebpackRegExp$LWS = createPropertyReferenceRegExp$LWS(webpackGlobalPattern$LWS, 'top');
1848
2034
  function createPropertyReferenceRegExp$LWS(objectPattern$LWS, key$LWS) {
@@ -1853,18 +2039,11 @@ function createPropertyReferenceRegExp$LWS(objectPattern$LWS, key$LWS) {
1853
2039
  return new RegExpCtor$LWS$1(`\\b(?:${objectPattern$LWS})\\.${key$LWS}(\\s*(?:[?*/%&^|+-]|>>>?|<<)*=(?=[^=]))?`, 'g');
1854
2040
  }
1855
2041
  function compileSourceText$LWS(sourceText$LWS) {
1856
- const transforms$LWS = {
1857
- location: false,
1858
- windowTop: false
1859
- };
1860
2042
  // To avoid conflicts with anyone else using `SANDBOX_EVAL_CONTEXT_NAME`,
1861
2043
  // we sniff the source text to see if it is present, and in that case we
1862
2044
  // don't proceed with the string replacement.
1863
2045
  if (ReflectApply$LWS$1(RegExpProtoTest$LWS$1, sandboxEvalContextNameRegExp$LWS, [sourceText$LWS])) {
1864
- return {
1865
- code: sourceText$LWS,
1866
- transforms: transforms$LWS
1867
- };
2046
+ return sourceText$LWS;
1868
2047
  }
1869
2048
  let locationRegExp$LWS;
1870
2049
  let topRegExp$LWS;
@@ -1880,62 +2059,22 @@ function compileSourceText$LWS(sourceText$LWS) {
1880
2059
  // transforming the red `location` reference into a blue `location` reference.
1881
2060
  // The solution below emulates what our compiler does, but using a simple
1882
2061
  // string replacement.
1883
- sourceText$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, sourceText$LWS, [locationRegExp$LWS, (_match$LWS, assignmentOperator$LWS) => {
1884
- transforms$LWS.location = true;
1885
- return assignmentOperator$LWS ? `${UNCOMPILED_LOCATION_NAME$LWS}.href${assignmentOperator$LWS}` : UNCOMPILED_LOCATION_NAME$LWS;
1886
- }]);
2062
+ sourceText$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, sourceText$LWS, [locationRegExp$LWS, (_match$LWS, assignmentOperator$LWS) => assignmentOperator$LWS ? `${UNCOMPILED_LOCATION_NAME$LWS}.href${assignmentOperator$LWS}` : UNCOMPILED_LOCATION_NAME$LWS]);
1887
2063
  // In non-compiled source text `window.top` is null when evaluated in a
1888
2064
  // sandbox. We perform a naive transformation to replace references of
1889
2065
  // `window.top` to use our internal sandbox helpers.
1890
- sourceText$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, sourceText$LWS, [topRegExp$LWS, () => {
1891
- transforms$LWS.windowTop = true;
1892
- return UNCOMPILED_TOP_NAME$LWS;
1893
- }]);
1894
- return {
1895
- code: sourceText$LWS,
1896
- transforms: transforms$LWS
1897
- };
2066
+ sourceText$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, sourceText$LWS, [topRegExp$LWS, () => UNCOMPILED_TOP_NAME$LWS]);
2067
+ return sourceText$LWS;
1898
2068
  }
1899
2069
  function generateContextAssignmentCodeFromContextNames$LWS(names$LWS) {
1900
- // While fully qualified member expression access can be unambiguously detected,
1901
- // ie. window.location or window.top, bare-word references to location and top
1902
- // cannot. This means that code containing the fully qualified member expressions
1903
- // can have all occurrences replaced by transforms and given special names controlled
1904
- // by LWS in Aura. This process will also result in the program knowing that it
1905
- // applied a given transform, which it can then use to populate a context names
1906
- // list to be used in the declaration assignment code injected into wrapped Aura
1907
- // component code. Because the unqualified member expressions cannot be unambiguously
1908
- // detected, there is no way for the program to know that, eg. location.search was
1909
- // used in the Aura component code and subsequently transformed, which means it
1910
- // cannot be relied upon to when populating a context names list to be used in
1911
- // the declaration assignment code. As a result, location and top must be universally
1912
- // and explicitly included in the context object, and universally and explicitly
1913
- // included in the context names list.
1914
- //
1915
- names$LWS[names$LWS.length] = 'location';
1916
- names$LWS[names$LWS.length] = 'top';
1917
2070
  return `const {${ReflectApply$LWS$1(ArrayProtoToString$LWS$1, names$LWS, [])}}=${SANDBOX_EVAL_CONTEXT_NAME$LWS}`;
1918
2071
  }
1919
- function getContextNamesFromCompilationTransforms$LWS(transforms$LWS) {
1920
- const names$LWS = toSafeArray$LWS$1([]);
1921
- if (transforms$LWS.location) {
1922
- names$LWS[names$LWS.length] = UNCOMPILED_LOCATION_NAME$LWS;
1923
- }
1924
- if (transforms$LWS.windowTop) {
1925
- names$LWS[names$LWS.length] = UNCOMPILED_TOP_NAME$LWS;
1926
- }
1927
- return names$LWS;
1928
- }
1929
2072
  function transformSourceText$LWS(sourceText$LWS) {
1930
- const {
1931
- code: code$LWS,
1932
- transforms: transforms$LWS
1933
- } = compileSourceText$LWS(sourceText$LWS);
1934
- const contextNames$LWS = getContextNamesFromCompilationTransforms$LWS(transforms$LWS);
1935
- if (!contextNames$LWS.length) {
1936
- return code$LWS;
1937
- }
1938
- const prefix$LWS = `${generateContextAssignmentCodeFromContextNames$LWS(contextNames$LWS)};`;
2073
+ if (ReflectApply$LWS$1(RegExpProtoTest$LWS$1, sandboxEvalContextNameRegExp$LWS, [sourceText$LWS])) {
2074
+ return sourceText$LWS;
2075
+ }
2076
+ const code$LWS = compileSourceText$LWS(sourceText$LWS);
2077
+ const prefix$LWS = `${generateContextAssignmentCodeFromContextNames$LWS(UNIVERSAL_CONTEXT_NAMES$LWS)};`;
1939
2078
  const pragmaIndex$LWS = indexOfPragma$LWS(code$LWS, 'use strict');
1940
2079
  if (pragmaIndex$LWS === -1) {
1941
2080
  return prefix$LWS + code$LWS;
@@ -1973,7 +2112,7 @@ const {
1973
2112
  const XhrProtoResponseTextGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'responseText');
1974
2113
  const XhrProtoStatusGetter$LWS = ObjectLookupOwnGetter$LWS$1(XhrProto$LWS, 'status');
1975
2114
  ObjectLookupOwnSetter$LWS(XhrProto$LWS, 'withCredentials');
1976
- /*! version: 0.19.4 */
2115
+ /*! version: 0.19.10 */
1977
2116
 
1978
2117
  /*!
1979
2118
  * Copyright (C) 2019 salesforce.com, inc.
@@ -1995,6 +2134,7 @@ function isMIMETypeAllowed$LWS(mimeType$LWS) {
1995
2134
  return false;
1996
2135
  }
1997
2136
  const DISALLOWED_ENDPOINTS_LIST$LWS = ['/aura', '/webruntime'];
2137
+ const TRUSTED_DOMAINS_REG_EXP$LWS = /\.(force|salesforce|visualforce|documentforce|my\.site|salesforce-sites)\.com$/;
1998
2138
  const URL_SCHEMES_LIST$LWS = toSafeArray$LWS$1(['http:', 'https:']);
1999
2139
  const newlinesAndTabsRegExp$LWS = /[\u2028\u2029\n\r\t]/g;
2000
2140
  const normalizerAnchor$LWS = ReflectApply$LWS$1(DocumentProtoCreateElement$LWS$1, rootDocument$LWS, ['a']);
@@ -2031,7 +2171,7 @@ function sanitizeURLForElement$LWS(url$LWS) {
2031
2171
  function sanitizeURLString$LWS(urlString$LWS) {
2032
2172
  return urlString$LWS === '' ? urlString$LWS : ReflectApply$LWS$1(StringProtoReplace$LWS, urlString$LWS, [newlinesAndTabsRegExp$LWS, '']);
2033
2173
  }
2034
- /*! version: 0.19.4 */
2174
+ /*! version: 0.19.10 */
2035
2175
 
2036
2176
  /*! @license DOMPurify 3.0.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.3/LICENSE */
2037
2177
 
@@ -3656,10 +3796,72 @@ function createDOMPurify() {
3656
3796
 
3657
3797
  var purify = createDOMPurify();
3658
3798
 
3799
+ /*!
3800
+ * Copyright (C) 2023 salesforce.com, inc.
3801
+ */
3802
+ // @ts-ignore: Prevent cannot find name 'trustedTypes' error.
3803
+ const SUPPORTS_TRUSTED_TYPES = typeof trustedTypes !== 'undefined';
3804
+ function createTrustedTypesPolicy(name, options) {
3805
+ // @ts-ignore: Prevent cannot find name 'trustedTypes' error.
3806
+ return trustedTypes.createPolicy(name, options);
3807
+ }
3808
+ function createFallbackPolicy(_name, options) {
3809
+ return options;
3810
+ }
3811
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
3812
+ const createPolicy = SUPPORTS_TRUSTED_TYPES ? createTrustedTypesPolicy : createFallbackPolicy;
3813
+ const policyOptions = {
3814
+ createHTML(value) {
3815
+ return value;
3816
+ },
3817
+ createScript(value) {
3818
+ return value;
3819
+ },
3820
+ createScriptURL(value) {
3821
+ return value;
3822
+ }
3823
+ };
3824
+ // Temporarily surround in try-catch until migration to AMD run.
3825
+ try {
3826
+ createPolicy('default', {
3827
+ createHTML(dirty) {
3828
+ // Treat null & undefined separately
3829
+ if (dirty === 'null' || dirty === 'undefined') {
3830
+ return dirty;
3831
+ }
3832
+ return dirty;
3833
+ },
3834
+ // Ignore typescript type validation for this policy.
3835
+ // Returning `undefined` from a TT policy blocks usages
3836
+ // of specific DOM sinks affected by this hook.
3837
+ // We want to block eval and inline scripts.
3838
+ // @ts-ignore
3839
+ createScript(dirty) {
3840
+ // Treat null & undefined separately
3841
+ if (dirty === 'null' || dirty === 'undefined') {
3842
+ return dirty;
3843
+ }
3844
+ // Block script evaluation
3845
+ return undefined;
3846
+ },
3847
+ createScriptURL(dirty) {
3848
+ // Treat null & undefined separately
3849
+ if (dirty === 'null' || dirty === 'undefined') {
3850
+ return dirty;
3851
+ }
3852
+ return dirty;
3853
+ }
3854
+ });
3855
+ } catch (_unused) {
3856
+ // swallow
3857
+ }
3858
+ const trusted = createPolicy('trusted', policyOptions);
3859
+ /*! version: 0.19.10 */
3860
+
3659
3861
  /*!
3660
3862
  * Copyright (C) 2019 salesforce.com, inc.
3661
3863
  */
3662
- const ariaAttributes$LWS = ['aria-activedescendant', 'aria-atomic', 'aria-autocomplete', 'aria-busy', 'aria-checked', 'aria-controls', 'aria-describedby', 'aria-disabled', 'aria-readonly', 'aria-dropeffect', 'aria-expanded', 'aria-flowto', 'aria-grabbed', 'aria-haspopup', 'aria-hidden', 'aria-disabled', 'aria-invalid', 'aria-label', 'aria-labelledby', 'aria-level', 'aria-live', 'aria-multiline', 'aria-multiselectable', 'aria-orientation', 'aria-owns', 'aria-posinset', 'aria-pressed', 'aria-readonly', 'aria-relevant', 'aria-required', 'aria-selected', 'aria-setsize', 'aria-sort', 'aria-valuemax', 'aria-valuemin', 'aria-valuenow', 'aria-valuetext', 'role', 'target'];
3864
+ const additionalAttributes$LWS = ['role', 'target'];
3663
3865
  const htmlTags$LWS = ['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'caption', 'canvas', 'center', 'cite', 'code', 'col', 'colgroup', 'command', 'datalist', 'dd', 'del', 'details', 'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'fieldset', 'figure', 'figcaption', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'i', 'iframe', 'img', 'input', 'ins', 'keygen', 'kbd', 'label', 'legend', 'li', 'map', 'mark', 'menu', 'meter', 'nav', 'ol', 'optgroup', 'option', 'output', 'p', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'small', 'source', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr'];
3664
3866
  const svgTags$LWS = ['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'audio', 'canvas', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'video', 'view', 'vkern', 'use'];
3665
3867
  const allTags$LWS = ArrayConcat$LWS(htmlTags$LWS, svgTags$LWS);
@@ -3674,29 +3876,35 @@ const CUSTOM_ELEMENT_HANDLING$LWS = {
3674
3876
  // A generic config in which the sanitizer attempts in place sanitization and
3675
3877
  // returns node.
3676
3878
  const NODE_ALL_IN_PLACE$LWS = {
3677
- ADD_ATTR: shallowCloneArray$LWS(ariaAttributes$LWS),
3879
+ ADD_ATTR: shallowCloneArray$LWS(additionalAttributes$LWS),
3678
3880
  // Add '#document-fragment' to ALLOWED_TAGS to avoid a forbidden root node
3679
3881
  // exception.
3680
3882
  // https://github.com/cure53/DOMPurify/issues/664
3681
3883
  ALLOWED_TAGS: ArrayConcat$LWS(allTags$LWS, '#document-fragment'),
3682
3884
  CUSTOM_ELEMENT_HANDLING: ObjectAssign$LWS$1({}, CUSTOM_ELEMENT_HANDLING$LWS),
3683
- IN_PLACE: true
3885
+ IN_PLACE: true,
3886
+ // @ts-ignore this type is on DOMPurifyConfig
3887
+ TRUSTED_TYPES_POLICY: trusted
3684
3888
  };
3685
3889
  // A config to use only svg tags in which the sanitizer returns a document
3686
3890
  // fragment.
3687
3891
  const NODE_SVG$LWS = {
3688
- ADD_ATTR: shallowCloneArray$LWS(ariaAttributes$LWS),
3892
+ ADD_ATTR: shallowCloneArray$LWS(additionalAttributes$LWS),
3689
3893
  ALLOWED_TAGS: shallowCloneArray$LWS(svgTags$LWS),
3690
3894
  CUSTOM_ELEMENT_HANDLING: ObjectAssign$LWS$1({}, CUSTOM_ELEMENT_HANDLING$LWS),
3691
3895
  RETURN_DOM_FRAGMENT: true,
3692
- SANITIZE_DOM: false
3896
+ SANITIZE_DOM: false,
3897
+ // @ts-ignore this type is on DOMPurifyConfig
3898
+ TRUSTED_TYPES_POLICY: trusted
3693
3899
  };
3694
3900
  // A config to use only tags allowed for blob and file.
3695
3901
  const STRING_BLOB_HTML$LWS = {
3696
- ADD_ATTR: shallowCloneArray$LWS(ariaAttributes$LWS),
3902
+ ADD_ATTR: shallowCloneArray$LWS(additionalAttributes$LWS),
3697
3903
  ALLOWED_TAGS: ReflectApply$LWS$1(ArrayProtoFilter$LWS$1, allTags$LWS, [tag$LWS => tag$LWS !== 'iframe']),
3698
3904
  CUSTOM_ELEMENT_HANDLING: ObjectAssign$LWS$1({}, CUSTOM_ELEMENT_HANDLING$LWS),
3699
- SANITIZE_DOM: false
3905
+ SANITIZE_DOM: false,
3906
+ // @ts-ignore this type is on DOMPurifyConfig
3907
+ TRUSTED_TYPES_POLICY: trusted
3700
3908
  };
3701
3909
  var CONFIG$LWS = /*#__PURE__*/Object.freeze({
3702
3910
  __proto__: null,
@@ -3709,7 +3917,7 @@ const instancesBySandboxKeyRegistry$LWS = {
3709
3917
  };
3710
3918
  const SANITIZE_ATTRIBUTES_LIST$LWS = toSafeArray$LWS$1(['href', 'xlink:href']);
3711
3919
  const SHARED_SVG_SANITIZER_KEY$LWS = 'SHARED_SVG_SANITIZER_KEY';
3712
- const htmlTemplate$LWS$1 = ReflectApply$LWS$1(DocumentProtoCreateElement$LWS$1, document, ['template']);
3920
+ ReflectApply$LWS$1(DocumentProtoCreateElement$LWS$1, document, ['template']);
3713
3921
  // Queue for managing pending XHR requests.
3714
3922
  const queue$LWS = toSafeSet$LWS(new SetCtor$LWS$1());
3715
3923
  // A regexp to find all non lowercase alphanumeric.
@@ -3897,76 +4105,7 @@ function blobSanitizer$LWS(sandboxKey$LWS) {
3897
4105
  }
3898
4106
  return getSanitizerForConfig$LWS(sandboxKey$LWS, 'STRING_BLOB_HTML');
3899
4107
  }
3900
- function sanitize$LWS(dirty$LWS, sandboxKey$LWS) {
3901
- if (typeof sandboxKey$LWS !== 'string') {
3902
- throw new LockerSecurityError$LWS(ERR_INVALID_SANDBOX_KEY$LWS);
3903
- }
3904
- ReflectApply$LWS$1(ElementProtoInnerHTMLSetter$LWS, htmlTemplate$LWS$1, [dirty$LWS]);
3905
- const content$LWS = ReflectApply$LWS$1(HTMLTemplateElementProtoContentGetter$LWS, htmlTemplate$LWS$1, []);
3906
- const sanitizer$LWS = getSanitizerForConfig$LWS(sandboxKey$LWS, 'NODE_ALL_IN_PLACE');
3907
- sanitizer$LWS.sanitize(content$LWS);
3908
- return ReflectApply$LWS$1(ElementProtoInnerHTMLGetter$LWS, htmlTemplate$LWS$1, []);
3909
- }
3910
- function sanitizeDocument$LWS(doc$LWS, sandboxKey$LWS) {
3911
- const docEl$LWS = ReflectApply$LWS$1(DocumentProtoDocumentElementGetter$LWS, doc$LWS, []);
3912
- const content$LWS = ReflectApply$LWS$1(ElementProtoOuterHTMLGetter$LWS, docEl$LWS, []);
3913
- const docImpl$LWS = ReflectApply$LWS$1(DocumentProtoImplementationGetter$LWS, doc$LWS, []);
3914
- const newDoc$LWS = ReflectApply$LWS$1(DOMImplementationProtoCreateDocument$LWS, docImpl$LWS, [NAMESPACE_XHTML$LWS, 'html']);
3915
- const newDocEl$LWS = ReflectApply$LWS$1(DocumentProtoDocumentElementGetter$LWS, newDoc$LWS, []);
3916
- ReflectApply$LWS$1(ElementProtoInnerHTMLSetter$LWS, newDocEl$LWS, [sanitize$LWS(content$LWS, sandboxKey$LWS)]);
3917
- return newDoc$LWS;
3918
- }
3919
- function createSvgContainer$LWS(ownerDoc$LWS) {
3920
- return ReflectApply$LWS$1(DocumentProtoCreateElementNS$LWS, ownerDoc$LWS, [NAMESPACE_SVG$LWS, 'svg']);
3921
- }
3922
- function sanitizeSvgInnerHtml$LWS(stringOrSvg$LWS, dirty$LWS = '') {
3923
- const ownerDoc$LWS = typeof stringOrSvg$LWS === 'string' ? document : ReflectApply$LWS$1(NodeProtoOwnerDocumentGetter$LWS, stringOrSvg$LWS, []);
3924
- let container$LWS;
3925
- if (typeof stringOrSvg$LWS === 'string') {
3926
- dirty$LWS = stringOrSvg$LWS;
3927
- container$LWS = createSvgContainer$LWS(ownerDoc$LWS);
3928
- } else {
3929
- const closestSvg$LWS = ReflectApply$LWS$1(ElementProtoClosest$LWS, stringOrSvg$LWS, ['svg']);
3930
- container$LWS = closestSvg$LWS ? ReflectApply$LWS$1(NodeProtoCloneNode$LWS, closestSvg$LWS, [false]) : createSvgContainer$LWS(ownerDoc$LWS);
3931
- }
3932
- const comment$LWS = ReflectApply$LWS$1(DocumentProtoCreateComment$LWS, ownerDoc$LWS, ['']);
3933
- ReflectApply$LWS$1(NodeProtoAppendChild$LWS$1, container$LWS, [comment$LWS]);
3934
- const outerHTML$LWS = ReflectApply$LWS$1(ElementProtoOuterHTMLGetter$LWS, container$LWS, []);
3935
- const replacedOuterHTML$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, outerHTML$LWS, ['<!---->', dirty$LWS]);
3936
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
3937
- const fragment$LWS = sanitizeSvgTextReturnDOM$LWS(replacedOuterHTML$LWS);
3938
- const firstChild$LWS = ReflectApply$LWS$1(NodeProtoFirstChildGetter$LWS, fragment$LWS, []);
3939
- return ReflectApply$LWS$1(ElementProtoInnerHTMLGetter$LWS, firstChild$LWS, []);
3940
- }
3941
- /*! version: 0.19.4 */
3942
-
3943
- /*!
3944
- * Copyright (C) 2023 salesforce.com, inc.
3945
- */
3946
- // @ts-ignore: Prevent cannot find name 'trustedTypes' error.
3947
- const SUPPORTS_TRUSTED_TYPES = typeof trustedTypes !== 'undefined';
3948
- function createTrustedTypesPolicy(name, options) {
3949
- // @ts-ignore: Prevent cannot find name 'trustedTypes' error.
3950
- return trustedTypes.createPolicy(name, options);
3951
- }
3952
- function createFallbackPolicy(_name, options) {
3953
- return options;
3954
- }
3955
- // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
3956
- const createPolicy = SUPPORTS_TRUSTED_TYPES ? createTrustedTypesPolicy : createFallbackPolicy;
3957
- const policyOptions = {
3958
- createHTML(value) {
3959
- return value;
3960
- },
3961
- createScript(value) {
3962
- return value;
3963
- },
3964
- createScriptURL(value) {
3965
- return value;
3966
- }
3967
- };
3968
- const trusted = createPolicy('trusted', policyOptions);
3969
- /*! version: 0.19.4 */
4108
+ /*! version: 0.19.10 */
3970
4109
 
3971
4110
  /*!
3972
4111
  * Copyright (C) 2023 salesforce.com, inc.
@@ -3975,12 +4114,29 @@ const inflightRequests$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
3975
4114
  async function getSourceText$LWS(resourceURL$LWS, targetElement$LWS) {
3976
4115
  abortInFlightRequest$LWS(targetElement$LWS);
3977
4116
  const controller$LWS = new AbortControllerCtor$LWS();
3978
- const signal$LWS = ReflectApply$LWS$1(AbortControllerProtoSignalGetter$LWS, controller$LWS, []);
3979
4117
  inflightRequests$LWS.set(targetElement$LWS, controller$LWS);
4118
+ // The error "The value of the 'Access-Control-Allow-Origin' header in the
4119
+ // response must not be the wildcard '*' when the request's credentials mode
4120
+ // is 'include'" occurs when the Access-Control-Allow-Credentials header is
4121
+ // set to true and the Access-Control-Allow-Origin header is set to an asterisk *.
4122
+ //
4123
+ // The error may be resolved in one of two ways:
4124
+ // 1) Set the Access-Control-Allow-Credentials header to 'false' and keep
4125
+ // the Access-Control-Allow-Origin header as an asterisk * to allow all
4126
+ // origins to access your server.
4127
+ // 2) Set the Access-Control-Allow-Origin header to a specific origin,
4128
+ // e.g. 'http://localhost:3000' or a list of allowlisted origins that
4129
+ // are allowed to access your server. Note that the origin must specify
4130
+ // the protocol, domain and port.
4131
+ const hostname$LWS = ReflectApply$LWS$1(HTMLAnchorElementProtoHostnameGetter$LWS, normalizerAnchor$LWS, []);
4132
+ // To avoid the CORS error above without burdening users with header adjustments
4133
+ // we limit credentials mode of 'include' to "trusted" domains.
4134
+ const credentials$LWS = ReflectApply$LWS$1(RegExpProtoTest$LWS$1, TRUSTED_DOMAINS_REG_EXP$LWS, [hostname$LWS]) ? 'include' : 'same-origin';
4135
+ const signal$LWS = ReflectApply$LWS$1(AbortControllerProtoSignalGetter$LWS, controller$LWS, []);
3980
4136
  const response$LWS = await WindowFetch$LWS(resourceURL$LWS, {
3981
4137
  __proto__: null,
3982
4138
  method: 'GET',
3983
- credentials: 'include',
4139
+ credentials: credentials$LWS,
3984
4140
  signal: signal$LWS
3985
4141
  });
3986
4142
  inflightRequests$LWS.delete(targetElement$LWS);
@@ -3998,6 +4154,14 @@ function abortInFlightRequest$LWS(element$LWS) {
3998
4154
  }
3999
4155
  const EVALUATOR_PROPERTY_KEY$LWS = '$evaluator$';
4000
4156
  const BLOB_SCRIPT_SOURCE$LWS = `document.currentScript['${EVALUATOR_PROPERTY_KEY$LWS}']`;
4157
+
4158
+ // eslint-disable-next-line no-shadow
4159
+ var ContentType$LWS;
4160
+ (function (ContentType$LWS) {
4161
+ ContentType$LWS[ContentType$LWS["HTML"] = 0] = "HTML";
4162
+ ContentType$LWS[ContentType$LWS["SVG"] = 1] = "SVG";
4163
+ ContentType$LWS[ContentType$LWS["XML"] = 2] = "XML";
4164
+ })(ContentType$LWS || (ContentType$LWS = {}));
4001
4165
  const evaluatedScripts$LWS = toSafeWeakSet$LWS$1(new WeakSetCtor$LWS$1());
4002
4166
  const scriptURLsCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
4003
4167
  const htmlTemplate$LWS = ReflectApply$LWS$1(DocumentProtoCreateElement$LWS$1, document, ['template']);
@@ -4010,7 +4174,7 @@ const policyOptions$LWS = {
4010
4174
  throw new LockerSecurityError$LWS(ERR_INVALID_SANDBOX_KEY$LWS);
4011
4175
  }
4012
4176
  switch (contentType$LWS) {
4013
- case 0 /* ContentType.HTML */:
4177
+ case ContentType$LWS.HTML:
4014
4178
  {
4015
4179
  ReflectApply$LWS$1(ElementProtoInnerHTMLSetter$LWS, htmlTemplate$LWS, [trusted.createHTML(dirty$LWS)]);
4016
4180
  const content$LWS = ReflectApply$LWS$1(HTMLTemplateElementProtoContentGetter$LWS, htmlTemplate$LWS, []);
@@ -4018,9 +4182,17 @@ const policyOptions$LWS = {
4018
4182
  sanitizer$LWS.sanitize(content$LWS);
4019
4183
  return ReflectApply$LWS$1(ElementProtoInnerHTMLGetter$LWS, htmlTemplate$LWS, []);
4020
4184
  }
4021
- case 1 /* ContentType.SVG */:
4022
- return '';
4023
- case 2 /* ContentType.XML */:
4185
+ case ContentType$LWS.SVG:
4186
+ {
4187
+ const tplElement$LWS = ReflectApply$LWS$1(DocumentProtoCreateElement$LWS$1, document, ['template']);
4188
+ ReflectApply$LWS$1(ElementProtoInnerHTMLSetter$LWS, tplElement$LWS, [trusted.createHTML(dirty$LWS)]);
4189
+ const wrappedDirty$LWS = ReflectApply$LWS$1(DocumentProtoCreateElementNS$LWS, document, [NAMESPACE_SVG$LWS, 'svg']);
4190
+ ReflectApply$LWS$1(ElementProtoInnerHTMLSetter$LWS, wrappedDirty$LWS, [trusted.createHTML(dirty$LWS)]);
4191
+ const sanitized$LWS = getSanitizerForConfig$LWS('SHARED_SVG_SANITIZER_KEY', 'NODE_SVG').sanitize(wrappedDirty$LWS);
4192
+ const firstChild$LWS = ReflectApply$LWS$1(NodeProtoFirstChildGetter$LWS, sanitized$LWS, []);
4193
+ return ReflectApply$LWS$1(ElementProtoInnerHTMLGetter$LWS, firstChild$LWS, []);
4194
+ }
4195
+ case ContentType$LWS.XML:
4024
4196
  return dirty$LWS;
4025
4197
  default:
4026
4198
  return '';
@@ -4129,32 +4301,30 @@ function encloseSrcSetter$LWS(targetElement$LWS) {
4129
4301
  ReflectApply$LWS$1(ElementProtoSetAttributeNS$LWS, targetElement$LWS, [attributeNamespaceURI$LWS, attributeName$LWS, src$LWS]);
4130
4302
  };
4131
4303
  }
4132
- /*! version: 0.19.4 */
4304
+ /*! version: 0.19.10 */
4133
4305
 
4134
4306
  /*!
4135
4307
  * Copyright (C) 2019 salesforce.com, inc.
4136
4308
  */
4137
- const ERR_ILLEGAL_CONSTRUCTOR$LWS = 'Illegal constructor.';
4309
+ const ERR_ILLEGAL_CONSTRUCTOR$LWS = 'Illegal constructor';
4138
4310
  const ERR_ILLEGAL_INVOCATION$LWS = 'Illegal invocation.';
4139
4311
  const ERR_NO_NEW_OP_HTML_ELEMENT$LWS = "Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function.";
4140
- const LOCKER_ORIGINAL_HTML_ELEMENT_CTOR_SYMBOL$LWS = SymbolFor$LWS$1('@@lockerOriginalHTMLElementCtor');
4141
4312
  let currentRegistry$LWS;
4142
4313
  let currentUpgradingInstance$LWS;
4143
4314
  const definitionCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
4144
- const originalHTMLElementCtorCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
4145
4315
  const globalRegistryCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
4146
4316
  const pivotCtorCache$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
4147
4317
  const sandboxRegistryCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
4148
4318
  /* eslint-disable no-underscore-dangle */
4149
4319
  class VirtualRegistry$LWS {
4150
- constructor(document$LWS) {
4320
+ constructor(document$LWS, originalHTMLElementCtor$LWS = getUnmaskedFunction$LWS(ReflectApply$LWS$1(DocumentProtoDefaultViewGetter$LWS, document$LWS, []).HTMLElement)) {
4151
4321
  this._awaitingUpgrade = toSafeMap$LWS$1(new MapCtor$LWS$1());
4152
4322
  this._definedCtors = toSafeSet$LWS(new SetCtor$LWS$1());
4153
4323
  this._definitionByElement = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
4154
4324
  this._definitionByTag = toSafeMap$LWS$1(new MapCtor$LWS$1());
4155
4325
  this._pendingRegistryByElement = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
4156
4326
  this._document = document$LWS;
4157
- this._HTMLElement = originalHTMLElementCtorCache$LWS.get(document$LWS);
4327
+ this._originalHTMLElementCtor = originalHTMLElementCtor$LWS;
4158
4328
  }
4159
4329
  applyDefine(cer$LWS, args$LWS) {
4160
4330
  const {
@@ -4174,7 +4344,7 @@ class VirtualRegistry$LWS {
4174
4344
  const definition$LWS = getDefinitionForConstructor$LWS(LocalCtor$LWS);
4175
4345
  let PivotCtor$LWS = pivotCtorCache$LWS.get(tagName$LWS);
4176
4346
  if (PivotCtor$LWS === undefined) {
4177
- PivotCtor$LWS = createPivotingClass$LWS(this._document, this._HTMLElement, definition$LWS, tagName$LWS);
4347
+ PivotCtor$LWS = createPivotingClass$LWS(this._document, this._originalHTMLElementCtor, definition$LWS, tagName$LWS);
4178
4348
  // Register a pivoting class which will handle global registry initializations.
4179
4349
  ReflectApply$LWS$1(CustomElementRegistryProtoDefine$LWS, cer$LWS, [tagName$LWS, PivotCtor$LWS]);
4180
4350
  }
@@ -4232,7 +4402,7 @@ class VirtualRegistry$LWS {
4232
4402
  getDefinition(instance$LWS) {
4233
4403
  return this._definitionByElement.get(instance$LWS);
4234
4404
  }
4235
- newCtor(instance$LWS) {
4405
+ newCtor(instance$LWS, newTarget$LWS, originalHTMLElementCtor$LWS) {
4236
4406
  // Upgrading case: the pivoting class constructor was run by the
4237
4407
  // browser's native custom elements and we're in the process of running
4238
4408
  // the "constructor call trick" on the natively constructed instance,
@@ -4242,6 +4412,10 @@ class VirtualRegistry$LWS {
4242
4412
  currentUpgradingInstance$LWS = undefined;
4243
4413
  return pendingUpgrade$LWS;
4244
4414
  }
4415
+ // NOTE: This precaution is necessary because custom elements created outside
4416
+ // of the sandbox are not discoverable, which would result in a failure.
4417
+ // In case the custom element is not found, the code will automatically
4418
+ // resort to using the global custom element registry.
4245
4419
  // Construction case: We need to construct the pivoting instance and
4246
4420
  // return it. This is possible when the user instantiate it via
4247
4421
  // `new LocalCtor()`.
@@ -4250,24 +4424,18 @@ class VirtualRegistry$LWS {
4250
4424
  } = instance$LWS;
4251
4425
  const definition$LWS = definitionCache$LWS.get(LocalCtor$LWS);
4252
4426
  if (definition$LWS === undefined || typeof definition$LWS.PivotCtor !== 'function') {
4253
- let tagName$LWS;
4254
- // If we can get a tagName without triggering "Illegal invocation", then
4427
+ // If we can get the tag name without triggering "Illegal invocation", then
4255
4428
  // it's plausible that this is an instance of a registered custom element
4256
- // that was defined _before_ LWS was run.. Attempting to invoke the tagName
4257
- // getter on an instance that wasn't constructed from a registered definition
4429
+ // that was defined _before_ LWS was run. Attempting to invoke the getter
4430
+ // on an instance that wasn't constructed from a registered definition
4258
4431
  // will not have the Element prototype in its chain and will fail with
4259
4432
  // an "Illegal invocation" exception.
4260
4433
  try {
4261
- tagName$LWS = ReflectApply$LWS$1(ElementProtoTagNameGetter$LWS, instance$LWS, []);
4262
- // eslint-disable-next-line no-empty
4263
- } catch (_unused$LWS) {}
4264
- // If we successfully got the tagName, we can return this instance
4265
- if (tagName$LWS) {
4434
+ ReflectApply$LWS$1(ElementProtoTagNameGetter$LWS, this, []);
4266
4435
  return instance$LWS;
4436
+ } catch (_unused$LWS) {
4437
+ return ReflectConstruct$LWS(originalHTMLElementCtor$LWS, [], newTarget$LWS);
4267
4438
  }
4268
- // ...Otherwise, this is a bogus instantiation and we need to match
4269
- // native behavior.
4270
- throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_CONSTRUCTOR$LWS);
4271
4439
  }
4272
4440
  // This constructor is ONLY invoked when it is the user instantiating
4273
4441
  // an element via `new LocalCtor(`) while `LocalCtor` is a locally
@@ -4306,7 +4474,7 @@ class VirtualRegistry$LWS {
4306
4474
  // this instance works like a regular element without a registered
4307
4475
  // definition. `this.instanceRegistry.upgrade()` will eventually
4308
4476
  // install the full custom element prototype.
4309
- ReflectSetPrototypeOf$LWS$1(instance$LWS, this._HTMLElement.prototype);
4477
+ ReflectSetPrototypeOf$LWS$1(instance$LWS, this._originalHTMLElementCtor.prototype);
4310
4478
  }
4311
4479
  }
4312
4480
  setDefinition(instance$LWS, pivotDefinition$LWS) {
@@ -4376,11 +4544,11 @@ function createDefinitionRecord$LWS(LocalCtor$LWS) {
4376
4544
  }
4377
4545
  // Helper to create stand-in element for each tagName registered that delegates out to the
4378
4546
  // registry for the given element.
4379
- function createPivotingClass$LWS(document$LWS, CustomElementBaseClass$LWS,
4547
+ function createPivotingClass$LWS(document$LWS, originalHTMLElementCtor$LWS,
4380
4548
  // This is the definition that user code provided to customElements.define(tagName, definition)
4381
4549
  originalDefinition$LWS, tagName$LWS) {
4382
4550
  var _a$LWS;
4383
- return _a$LWS = class PivotCtor$LWS extends CustomElementBaseClass$LWS {
4551
+ return _a$LWS = class PivotCtor$LWS extends originalHTMLElementCtor$LWS {
4384
4552
  constructor(localRegistry$LWS, definition$LWS) {
4385
4553
  // This constructor can only be invoked by:
4386
4554
  // a) The browser instantiating an element from parsing or via
@@ -4402,7 +4570,7 @@ originalDefinition$LWS, tagName$LWS) {
4402
4570
  // prior to element creation.
4403
4571
  getCurrentRegistry$LWS() ||
4404
4572
  // Global stuff.
4405
- getGlobalCustomElementRegistry$LWS(document$LWS);
4573
+ getGlobalCustomElementRegistry$LWS(document$LWS, originalHTMLElementCtor$LWS);
4406
4574
  this.instanceRegistry.scheduleOrUpgrade(this, tagName$LWS, originalDefinition$LWS);
4407
4575
  }
4408
4576
  }
@@ -4473,7 +4641,7 @@ function getCurrentRegistry$LWS() {
4473
4641
  }
4474
4642
  function getDefinitionForConstructor$LWS(LocalCtor$LWS) {
4475
4643
  const proto$LWS = typeof LocalCtor$LWS === 'function' ? LocalCtor$LWS.prototype : undefined;
4476
- if (!isObject$LWS(proto$LWS)) {
4644
+ if (!isObject$LWS$1(proto$LWS)) {
4477
4645
  throw new TypeErrorCtor$LWS$1('Invalid custom element constructor.');
4478
4646
  }
4479
4647
  let definition$LWS = definitionCache$LWS.get(LocalCtor$LWS);
@@ -4483,12 +4651,12 @@ function getDefinitionForConstructor$LWS(LocalCtor$LWS) {
4483
4651
  }
4484
4652
  return definition$LWS;
4485
4653
  }
4486
- function getGlobalCustomElementRegistry$LWS(document$LWS) {
4654
+ function getGlobalCustomElementRegistry$LWS(document$LWS, originalHTMLElementCtor$LWS) {
4487
4655
  let registry$LWS = globalRegistryCache$LWS.get(document$LWS);
4488
4656
  if (registry$LWS) {
4489
4657
  return registry$LWS;
4490
4658
  }
4491
- registry$LWS = new VirtualRegistry$LWS(document$LWS);
4659
+ registry$LWS = new VirtualRegistry$LWS(document$LWS, originalHTMLElementCtor$LWS);
4492
4660
  globalRegistryCache$LWS.set(document$LWS, registry$LWS);
4493
4661
  return registry$LWS;
4494
4662
  }
@@ -4541,7 +4709,7 @@ function patchAttributes$LWS(instance$LWS, originalDefinition$LWS, pivotDefiniti
4541
4709
  if (!observedAttributesList$LWS.size) {
4542
4710
  return;
4543
4711
  }
4544
- instance$LWS.removeAttribute = proxyMaskFunction$LWS(function removeAttribute$LWS(name$LWS) {
4712
+ instance$LWS.removeAttribute = maskFunction$LWS(function removeAttribute$LWS(name$LWS) {
4545
4713
  const args$LWS = [name$LWS];
4546
4714
  // `observedAttributesList` is a safe Set.
4547
4715
  if (observedAttributesList$LWS.has(name$LWS)) {
@@ -4554,7 +4722,7 @@ function patchAttributes$LWS(instance$LWS, originalDefinition$LWS, pivotDefiniti
4554
4722
  ReflectApply$LWS$1(ElementProtoRemoveAttribute$LWS, this, args$LWS);
4555
4723
  }
4556
4724
  }, ElementProtoRemoveAttribute$LWS);
4557
- instance$LWS.setAttribute = proxyMaskFunction$LWS(function setAttribute$LWS(name$LWS, value$LWS) {
4725
+ instance$LWS.setAttribute = maskFunction$LWS(function setAttribute$LWS(name$LWS, value$LWS) {
4558
4726
  const args$LWS = [name$LWS];
4559
4727
  const stringifiedValue$LWS = toString$LWS(value$LWS);
4560
4728
  const setAttributeArgs$LWS = [name$LWS, stringifiedValue$LWS];
@@ -4569,7 +4737,7 @@ function patchAttributes$LWS(instance$LWS, originalDefinition$LWS, pivotDefiniti
4569
4737
  ReflectApply$LWS$1(ElementProtoSetAttribute$LWS$1, this, setAttributeArgs$LWS);
4570
4738
  }
4571
4739
  }, ElementProtoSetAttribute$LWS$1);
4572
- instance$LWS.toggleAttribute = proxyMaskFunction$LWS(function toggleAttribute$LWS(name$LWS) {
4740
+ instance$LWS.toggleAttribute = maskFunction$LWS(function toggleAttribute$LWS(name$LWS) {
4573
4741
  const args$LWS = [name$LWS];
4574
4742
  let returnValue$LWS;
4575
4743
  // `observedAttributesList` is a safe Set.
@@ -4642,7 +4810,12 @@ function patchCustomElementRegistry$LWS(globalObject$LWS, registry$LWS) {
4642
4810
  },
4643
4811
  customElements: customElements$LWS
4644
4812
  } = globalObject$LWS;
4645
- CustomElementRegistryProto$LWS.get = proxyMaskFunction$LWS(function get$LWS(...args$LWS) {
4813
+ const {
4814
+ define: originalDefine$LWS,
4815
+ get: originalGet$LWS,
4816
+ whenDefined: originalWhenDefined$LWS
4817
+ } = CustomElementRegistryProto$LWS;
4818
+ CustomElementRegistryProto$LWS.get = maskFunction$LWS(function get$LWS(...args$LWS) {
4646
4819
  if (this !== customElements$LWS) {
4647
4820
  // This is more restricted than native behavior because
4648
4821
  // in native this is going to leak constructors from
@@ -4653,8 +4826,8 @@ function patchCustomElementRegistry$LWS(globalObject$LWS, registry$LWS) {
4653
4826
  throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_INVOCATION$LWS);
4654
4827
  }
4655
4828
  return registry$LWS.applyGet(this, args$LWS);
4656
- }, CustomElementRegistryProto$LWS.get);
4657
- CustomElementRegistryProto$LWS.define = proxyMaskFunction$LWS(function define$LWS(...args$LWS) {
4829
+ }, originalGet$LWS, createUnmaskableTraps$LWS(originalGet$LWS));
4830
+ CustomElementRegistryProto$LWS.define = maskFunction$LWS(function define$LWS(...args$LWS) {
4658
4831
  if (this !== customElements$LWS) {
4659
4832
  // This is more restricted than native behavior because
4660
4833
  // in native this is normally a runtime error when
@@ -4665,8 +4838,8 @@ function patchCustomElementRegistry$LWS(globalObject$LWS, registry$LWS) {
4665
4838
  throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_INVOCATION$LWS);
4666
4839
  }
4667
4840
  return registry$LWS.applyDefine(this, args$LWS);
4668
- }, CustomElementRegistryProto$LWS.define);
4669
- CustomElementRegistryProto$LWS.whenDefined = proxyMaskFunction$LWS(function whenDefined$LWS(...args$LWS) {
4841
+ }, originalDefine$LWS, createUnmaskableTraps$LWS(originalDefine$LWS));
4842
+ CustomElementRegistryProto$LWS.whenDefined = maskFunction$LWS(function whenDefined$LWS(...args$LWS) {
4670
4843
  if (this !== customElements$LWS) {
4671
4844
  // This is more restricted than native behavior because in native
4672
4845
  // this is going to leak constructors from another windows when
@@ -4676,87 +4849,21 @@ function patchCustomElementRegistry$LWS(globalObject$LWS, registry$LWS) {
4676
4849
  return PromiseReject$LWS(new TypeErrorCtor$LWS$1(ERR_ILLEGAL_INVOCATION$LWS));
4677
4850
  }
4678
4851
  return registry$LWS.applyWhenDefined(this, args$LWS);
4679
- }, CustomElementRegistryProto$LWS.whenDefined);
4852
+ }, originalWhenDefined$LWS, createUnmaskableTraps$LWS(originalWhenDefined$LWS));
4680
4853
  }
4681
4854
  function patchHTMLElement$LWS(globalObject$LWS, registry$LWS) {
4682
- let handshakeOriginalHTMLElementCtorFlag$LWS = false;
4683
4855
  const {
4684
4856
  HTMLElement: originalHTMLElementCtor$LWS
4685
4857
  } = globalObject$LWS;
4686
- globalObject$LWS.HTMLElement = proxyMaskFunction$LWS(function HTMLElement$LWS() {
4858
+ globalObject$LWS.HTMLElement = maskFunction$LWS(function HTMLElement$LWS() {
4687
4859
  if (new.target === undefined) {
4688
4860
  throw new TypeErrorCtor$LWS$1(ERR_NO_NEW_OP_HTML_ELEMENT$LWS);
4689
4861
  }
4690
4862
  if (new.target === HTMLElement$LWS) {
4691
4863
  throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_CONSTRUCTOR$LWS);
4692
4864
  }
4693
- return registry$LWS.newCtor(this);
4694
- }, originalHTMLElementCtor$LWS, {
4695
- defineProperty(target$LWS, key$LWS, desc$LWS) {
4696
- // Defining forgeries of handshake properties is not allowed.
4697
- if (key$LWS === LOCKER_ORIGINAL_HTML_ELEMENT_CTOR_SYMBOL$LWS) {
4698
- throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
4699
- }
4700
- return ReflectDefineProperty$LWS$1(target$LWS, key$LWS, desc$LWS);
4701
- },
4702
- get(target$LWS, key$LWS, receiver$LWS, handshake$LWS = false) {
4703
- // Only allow accessing handshake property values if the "has"
4704
- // trap has been triggered immediately BEFORE and the property
4705
- // does NOT exist.
4706
- handshakeOriginalHTMLElementCtorFlag$LWS && (handshakeOriginalHTMLElementCtorFlag$LWS = handshake$LWS);
4707
- const isOriginalHTMLElementCtorSymbol$LWS = key$LWS === LOCKER_ORIGINAL_HTML_ELEMENT_CTOR_SYMBOL$LWS;
4708
- if (handshakeOriginalHTMLElementCtorFlag$LWS) {
4709
- // Exit without performing a [[Get]] for
4710
- // `LOCKER_ORIGINAL_HTML_ELEMENT_CTOR_SYMBOL` properties
4711
- // because we know that when the
4712
- // `handshakeOriginalHTMLElementCtorFlag` is ON that
4713
- // there are NO shadowed values.
4714
- if (isOriginalHTMLElementCtorSymbol$LWS) {
4715
- return originalHTMLElementCtor$LWS;
4716
- }
4717
- }
4718
- const result$LWS = ReflectGet$LWS(target$LWS, key$LWS, receiver$LWS);
4719
- // Getting forged values of `LOCKER_ORIGINAL_HTML_ELEMENT_CTOR_SYMBOL`
4720
- // properties is not allowed.
4721
- if (result$LWS !== undefined && isOriginalHTMLElementCtorSymbol$LWS) {
4722
- throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
4723
- }
4724
- return result$LWS;
4725
- },
4726
- getOwnPropertyDescriptor(target$LWS, key$LWS) {
4727
- const result$LWS = ReflectGetOwnPropertyDescriptor$LWS(target$LWS, key$LWS);
4728
- // Getting forged descriptors of handshake properties is not allowed.
4729
- if (result$LWS && key$LWS === LOCKER_ORIGINAL_HTML_ELEMENT_CTOR_SYMBOL$LWS) {
4730
- throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
4731
- }
4732
- return result$LWS;
4733
- },
4734
- has(target$LWS, key$LWS) {
4735
- const result$LWS = ReflectHas$LWS(target$LWS, key$LWS);
4736
- const isOriginalHTMLElementCtorSymbol$LWS = key$LWS === LOCKER_ORIGINAL_HTML_ELEMENT_CTOR_SYMBOL$LWS;
4737
- if (result$LWS) {
4738
- handshakeOriginalHTMLElementCtorFlag$LWS = false;
4739
- // Checking the existence of forged `LOCKER_ORIGINAL_HTML_ELEMENT_CTOR_SYMBOL`
4740
- // properties is not allowed.
4741
- if (isOriginalHTMLElementCtorSymbol$LWS) {
4742
- throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
4743
- }
4744
- } else {
4745
- // The `handshakeOriginalHTMLElementCtorFlag` is ON if the
4746
- // handshake property does NOT exist on the object or its
4747
- // [[Prototype]].
4748
- handshakeOriginalHTMLElementCtorFlag$LWS = isOriginalHTMLElementCtorSymbol$LWS;
4749
- }
4750
- return result$LWS;
4751
- },
4752
- set(target$LWS, key$LWS, value$LWS, receiver$LWS) {
4753
- // Setting forged values of handshake properties is not allowed.
4754
- if (key$LWS === LOCKER_ORIGINAL_HTML_ELEMENT_CTOR_SYMBOL$LWS) {
4755
- throw new TypeErrorCtor$LWS$1(ERR_ILLEGAL_PROPERTY_ACCESS$LWS);
4756
- }
4757
- return ReflectSet$LWS(target$LWS, key$LWS, value$LWS, receiver$LWS);
4758
- }
4759
- });
4865
+ return registry$LWS.newCtor(this, new.target, originalHTMLElementCtor$LWS);
4866
+ }, originalHTMLElementCtor$LWS, createUnmaskableTraps$LWS(originalHTMLElementCtor$LWS));
4760
4867
  }
4761
4868
  function triggerAttributeChangedCallbackDuringUpgrade$LWS(instance$LWS, originalDefinition$LWS) {
4762
4869
  // The below case patches observed attributes for the case where the HTML
@@ -4777,9 +4884,6 @@ function triggerAttributeChangedCallbackDuringUpgrade$LWS(instance$LWS, original
4777
4884
  });
4778
4885
  }
4779
4886
  }
4780
- function getOriginalHTMLElementCtor$LWS(patchedHTMLElementCtor$LWS) {
4781
- return LOCKER_ORIGINAL_HTML_ELEMENT_CTOR_SYMBOL$LWS in patchedHTMLElementCtor$LWS ? undefined : patchedHTMLElementCtor$LWS[LOCKER_ORIGINAL_HTML_ELEMENT_CTOR_SYMBOL$LWS];
4782
- }
4783
4887
  function getSandboxCustomElementRegistry$LWS(document$LWS, key$LWS) {
4784
4888
  let registries$LWS = sandboxRegistryCache$LWS.get(document$LWS);
4785
4889
  if (registries$LWS === undefined) {
@@ -4794,32 +4898,13 @@ function getSandboxCustomElementRegistry$LWS(document$LWS, key$LWS) {
4794
4898
  registries$LWS.set(key$LWS, registry$LWS);
4795
4899
  return registry$LWS;
4796
4900
  }
4797
- function patchGlobalObject$LWS(document$LWS, globalObject$LWS) {
4798
- let {
4799
- HTMLElement: originalHTMLElementCtor$LWS
4800
- } = globalObject$LWS;
4901
+ function patchGlobalObject$LWS(globalObject$LWS, document$LWS = globalObject$LWS.document) {
4801
4902
  const {
4802
- CustomElementRegistry: {
4803
- prototype: {
4804
- get: originalGet$LWS
4805
- }
4806
- }
4903
+ HTMLElement: HTMLElementCtor$LWS
4807
4904
  } = globalObject$LWS;
4808
- const isHTMLElementCtorPatched$LWS = isProxyMaskedFunction$LWS(originalHTMLElementCtor$LWS);
4809
- const isCustomElementRegistryPatched$LWS = isProxyMaskedFunction$LWS(originalGet$LWS);
4810
- // `originalHTMLElementCtorCache` must be set BEFORE
4811
- // `getGlobalCustomElementRegistry()` is called.
4812
- if (isHTMLElementCtorPatched$LWS) {
4813
- originalHTMLElementCtor$LWS = getOriginalHTMLElementCtor$LWS(originalHTMLElementCtor$LWS);
4814
- // istanbul ignore if: currently unreachable via tests
4815
- if (typeof originalHTMLElementCtor$LWS !== 'function') {
4816
- throw new TypeErrorCtor$LWS$1('Invalid HTMLElement constructor.');
4817
- }
4818
- originalHTMLElementCtorCache$LWS.set(document$LWS, originalHTMLElementCtor$LWS);
4819
- } else {
4820
- originalHTMLElementCtorCache$LWS.set(document$LWS, originalHTMLElementCtor$LWS);
4821
- }
4822
- const registry$LWS = !isHTMLElementCtorPatched$LWS || !isCustomElementRegistryPatched$LWS ? getGlobalCustomElementRegistry$LWS(document$LWS) : undefined;
4905
+ const isHTMLElementCtorPatched$LWS = isMaskedFunction$LWS(HTMLElementCtor$LWS);
4906
+ const isCustomElementRegistryPatched$LWS = isMaskedFunction$LWS(globalObject$LWS.CustomElementRegistry.prototype.get);
4907
+ const registry$LWS = !isHTMLElementCtorPatched$LWS || !isCustomElementRegistryPatched$LWS ? getGlobalCustomElementRegistry$LWS(document$LWS, getUnmaskedFunction$LWS(HTMLElementCtor$LWS)) : undefined;
4823
4908
  if (!isHTMLElementCtorPatched$LWS) {
4824
4909
  patchHTMLElement$LWS(globalObject$LWS, registry$LWS);
4825
4910
  }
@@ -5685,11 +5770,10 @@ function initDistortionDocumentExecCommand$LWS({
5685
5770
  // for association to this sandbox.
5686
5771
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
5687
5772
  args$LWS[0] = command$LWS;
5688
- args$LWS[2] = lwsInternalPolicy$LWS.createHTML(unsanitizedValue$LWS, key$LWS, 0 /* ContentType.HTML */);
5773
+ args$LWS[2] = lwsInternalPolicy$LWS.createHTML(unsanitizedValue$LWS, key$LWS, ContentType$LWS.HTML);
5689
5774
  }
5690
5775
  }
5691
5776
  }
5692
-
5693
5777
  return ReflectApply$LWS$1(originalExecCommand$LWS, this, args$LWS);
5694
5778
  }];
5695
5779
  };
@@ -5704,35 +5788,6 @@ function initDistortionDocumentOnsecuritypolicyviolation$LWS({
5704
5788
  }) {
5705
5789
  return createEventDistortionFactory$LWS(DocumentProto$LWS, HTMLDocument$LWS, 'securitypolicyviolation');
5706
5790
  }
5707
-
5708
- // Check for the noopener feature being enabled:
5709
- // - noopener
5710
- // - noopener=1
5711
- // - noopener=yes
5712
- const noopenerRegExp$LWS = /(^|,)(\s*noopener\s*=\s*(?:yes|1)\s*)(,|$)/g;
5713
- function sanitizeWindowOpenArguments$LWS(args$LWS) {
5714
- const sanitizedArgs$LWS = shallowCloneArray$LWS(args$LWS);
5715
- if (sanitizedArgs$LWS.length > 2) {
5716
- // Lowercase the features string because it is case insensitive.
5717
- // https://html.spec.whatwg.org/multipage/window-object.html#normalizing-the-feature-name
5718
- const windowFeatures$LWS = toString$LWS(sanitizedArgs$LWS[2]);
5719
- let loweredWindowFeatures$LWS = ReflectApply$LWS$1(StringProtoToLowerCase$LWS, windowFeatures$LWS, []);
5720
- // RegExp.prototype[Symbol.replace] resets the lastIndex of global
5721
- // regexp to 0.
5722
- // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace
5723
- if (ReflectApply$LWS$1(RegExpProtoTest$LWS$1, noopenerRegExp$LWS, [windowFeatures$LWS])) {
5724
- // Replacing noopener with an enabled state that is supported
5725
- // across all browsers. Firefox Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1566619
5726
- loweredWindowFeatures$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, loweredWindowFeatures$LWS, [
5727
- // RegExp.prototype[Symbol.replace] resets the lastIndex of
5728
- // global regexp to 0.
5729
- // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace
5730
- noopenerRegExp$LWS, (_match$LWS, leading$LWS, _feature$LWS, ending$LWS) => `${leading$LWS}noopener${ending$LWS}`]);
5731
- }
5732
- sanitizedArgs$LWS[2] = loweredWindowFeatures$LWS;
5733
- }
5734
- return sanitizedArgs$LWS;
5735
- }
5736
5791
  function initDistortionDocumentOpen$LWS({
5737
5792
  globalObject: {
5738
5793
  Document: {
@@ -5755,8 +5810,12 @@ function initDistortionDocumentOpen$LWS({
5755
5810
  // Distort three-argument document.open calls which is an alias
5756
5811
  // for window.open
5757
5812
  // https://developer.mozilla.org/en-US/docs/Web/API/Document/open#three-argument_document.open
5758
- const sanitizedArgs$LWS = sanitizeWindowOpenArguments$LWS(args$LWS);
5759
- return ReflectApply$LWS$1(originalDocumentOpen$LWS, this, sanitizedArgs$LWS);
5813
+ const normalizedArgs$LWS = normalizeWindowOpenArguments$LWS(args$LWS);
5814
+ const childWindow$LWS = ReflectApply$LWS$1(originalDocumentOpen$LWS, this, normalizedArgs$LWS);
5815
+ if (childWindow$LWS) {
5816
+ initWindowOpenChildWindow$LWS(childWindow$LWS, normalizedArgs$LWS[0]);
5817
+ }
5818
+ return childWindow$LWS;
5760
5819
  }
5761
5820
  // istanbul ignore next: needs default platform behavior test
5762
5821
  return ReflectApply$LWS$1(originalDocumentOpen$LWS, this, args$LWS);
@@ -5815,16 +5874,21 @@ function initDistortionDOMParserParseFromString$LWS({
5815
5874
  // MAY CONTAIN a custom element, which must be marked for
5816
5875
  // association to this sandbox.
5817
5876
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
5818
- args$LWS[0] =
5819
- // If the provided mimeType indicates that the first
5820
- // argument is an svg, use the svg sanitizer instead of
5821
- // the default sanitizer.
5822
- mimeType$LWS === 'image/svg+xml' ? sanitizeSvgInnerHtml$LWS(string$LWS) :
5823
- // If the provided mimeType indicates that the
5824
- // first argument is xml, there's nothing to do.
5825
- mimeType$LWS === 'application/xhtml+xml' || mimeType$LWS === 'application/xml' || mimeType$LWS === 'text/xml' ? lwsInternalPolicy$LWS.createHTML(string$LWS, key$LWS, 2 /* ContentType.XML */) : lwsInternalPolicy$LWS.createHTML(string$LWS, key$LWS, 0 /* ContentType.HTML */);
5877
+ let contentType$LWS;
5878
+ switch (mimeType$LWS) {
5879
+ case 'application/xhtml+xml':
5880
+ case 'application/xml':
5881
+ case 'text/xml':
5882
+ contentType$LWS = ContentType$LWS.XML;
5883
+ break;
5884
+ case 'image/svg+xml':
5885
+ contentType$LWS = ContentType$LWS.SVG;
5886
+ break;
5887
+ default:
5888
+ contentType$LWS = ContentType$LWS.HTML;
5889
+ }
5890
+ args$LWS[0] = lwsInternalPolicy$LWS.createHTML(string$LWS, key$LWS, contentType$LWS);
5826
5891
  }
5827
-
5828
5892
  return ReflectApply$LWS$1(originalParseFromString$LWS, this, args$LWS);
5829
5893
  }];
5830
5894
  };
@@ -6050,7 +6114,8 @@ function initDistortionElementGetInnerHTML$LWS({
6050
6114
  return distortionEntry$LWS;
6051
6115
  };
6052
6116
  }
6053
- function scriptPropertySetters$LWS(incomingThis$LWS, property$LWS, valueAsString$LWS, originalScriptPropertyGetter$LWS, originalScriptPropertySetter$LWS, distortions$LWS, sandboxEvaluator$LWS) {
6117
+ function scriptPropertySetters$LWS(incomingThis$LWS, property$LWS, valueAsTrustedString$LWS, originalScriptPropertyGetter$LWS, originalScriptPropertySetter$LWS, distortions$LWS, sandboxEvaluator$LWS, signedScriptHookSourceText$LWS) {
6118
+ const valueAsString$LWS = toString$LWS(valueAsTrustedString$LWS);
6054
6119
  if (!isScriptPropertyEvaluatorHookDefined$LWS(incomingThis$LWS)) {
6055
6120
  const distortedScriptPropertyGetter$LWS = distortions$LWS.get(originalScriptPropertyGetter$LWS);
6056
6121
  defineScriptAccessorProperty$LWS(incomingThis$LWS, property$LWS, distortedScriptPropertyGetter$LWS, originalScriptPropertySetter$LWS);
@@ -6066,14 +6131,14 @@ function scriptPropertySetters$LWS(incomingThis$LWS, property$LWS, valueAsString
6066
6131
  // Set the script property immediately
6067
6132
  // after the evaluator hook fires to overwrite
6068
6133
  // the evaluator hook source text.
6069
- ReflectApply$LWS$1(originalScriptPropertySetter$LWS, incomingThis$LWS, [valueAsString$LWS]);
6134
+ ReflectApply$LWS$1(originalScriptPropertySetter$LWS, incomingThis$LWS, [valueAsTrustedString$LWS]);
6070
6135
  sandboxEvaluator$LWS(transformSourceText$LWS(valueAsString$LWS), context$LWS, defaultView$LWS, ownerDoc$LWS);
6071
6136
  });
6072
6137
  // Set the script property to the evaluator
6073
6138
  // hook which will run once the node is inserted
6074
6139
  // into a document. Subsequent changes to script
6075
6140
  // property are not evaluated.
6076
- ReflectApply$LWS$1(originalScriptPropertySetter$LWS, incomingThis$LWS, [SCRIPT_HOOK_SOURCE_TEXT$LWS]);
6141
+ ReflectApply$LWS$1(originalScriptPropertySetter$LWS, incomingThis$LWS, [signedScriptHookSourceText$LWS]);
6077
6142
  }
6078
6143
  return true;
6079
6144
  }
@@ -6110,8 +6175,8 @@ function initDistortionElementInnerHTMLSetter$LWS({
6110
6175
  throw new LockerSecurityError$LWS(`Cannot set innerHTML of ${ReflectApply$LWS$1(NodeProtoNodeNameGetter$LWS, this, [])}.`);
6111
6176
  }
6112
6177
  if (this instanceof HTMLScriptElement$LWS || this instanceof SVGScriptElement) {
6113
- const doesReturnEarly$LWS = scriptPropertySetters$LWS(this, 'innerHTML', toString$LWS(value$LWS), originalInnerHTMLGetter$LWS, originalInnerHTMLSetter$LWS, distortions$LWS, sandboxEvaluator$LWS);
6114
- if (doesReturnEarly$LWS) {
6178
+ const scriptWasNotEvaluatedInScriptPropertySetter$LWS = scriptPropertySetters$LWS(this, 'innerHTML', trusted.createScript(value$LWS), originalInnerHTMLGetter$LWS, originalInnerHTMLSetter$LWS, distortions$LWS, sandboxEvaluator$LWS, trusted.createScript(SCRIPT_HOOK_SOURCE_TEXT$LWS));
6179
+ if (scriptWasNotEvaluatedInScriptPropertySetter$LWS) {
6115
6180
  return;
6116
6181
  }
6117
6182
  }
@@ -6120,9 +6185,9 @@ function initDistortionElementInnerHTMLSetter$LWS({
6120
6185
  // MAY CONTAIN a custom element, which must be marked for
6121
6186
  // association to this sandbox.
6122
6187
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
6123
- value$LWS = this instanceof SVGElement$LWS ? sanitizeSvgInnerHtml$LWS(this, value$LWS) : lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, 0 /* ContentType.HTML */);
6188
+ const contentType$LWS = this instanceof SVGElement$LWS ? ContentType$LWS.SVG : ContentType$LWS.HTML;
6189
+ value$LWS = lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, contentType$LWS);
6124
6190
  }
6125
-
6126
6191
  ReflectApply$LWS$1(originalInnerHTMLSetter$LWS, this, [value$LWS]);
6127
6192
  }];
6128
6193
  };
@@ -6184,9 +6249,8 @@ function initDistortionElementInsertAdjacentHTML$LWS({
6184
6249
  // MAY CONTAIN a custom element, which must be marked for
6185
6250
  // association to this sandbox.
6186
6251
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
6187
- args$LWS[1] = lwsInternalPolicy$LWS.createHTML(args$LWS[1], key$LWS, 0 /* ContentType.HTML */);
6252
+ args$LWS[1] = lwsInternalPolicy$LWS.createHTML(args$LWS[1], key$LWS, ContentType$LWS.HTML);
6188
6253
  }
6189
-
6190
6254
  ReflectApply$LWS$1(originalInsertAdjacentHTML$LWS, this, args$LWS);
6191
6255
  }];
6192
6256
  };
@@ -6214,11 +6278,10 @@ function initDistortionElementOuterHTMLSetter$LWS({
6214
6278
  // MAY CONTAIN a custom element, which must be marked for
6215
6279
  // association to this sandbox.
6216
6280
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
6217
- ReflectApply$LWS$1(originalOuterHTMLSetter$LWS, this, [lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, 0 /* ContentType.HTML */)]);
6281
+ ReflectApply$LWS$1(originalOuterHTMLSetter$LWS, this, [lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, ContentType$LWS.HTML)]);
6218
6282
  }];
6219
6283
  };
6220
6284
  }
6221
-
6222
6285
  const {
6223
6286
  isSharedElement: isSharedElement$e$LWS,
6224
6287
  isAllowedSharedElementChild: isAllowedSharedElementChild$2$LWS
@@ -6339,7 +6402,7 @@ function initDistortionElementSetAttribute$LWS({
6339
6402
  return function distortionElementSetAttribute$LWS(record$LWS) {
6340
6403
  return [originalSetAttribute$LWS, function setAttribute$LWS(...args$LWS) {
6341
6404
  if (args$LWS.length > 1) {
6342
- const attrName$LWS = toString$LWS(args$LWS[0]);
6405
+ const attrName$LWS = normalizeNamespacedAttributeName$LWS(toString$LWS(args$LWS[0]));
6343
6406
  const attrValue$LWS = toString$LWS(args$LWS[1]);
6344
6407
  const distortion$LWS = getAttributeDistortion$LWS(record$LWS, this, attrName$LWS);
6345
6408
  if (distortion$LWS) {
@@ -6560,9 +6623,9 @@ function initDistortionElementSetHTML$LWS({
6560
6623
  // If options not specified, the default Sanitizer object is used.
6561
6624
  // This will be in addition to the sanitization we have.
6562
6625
  const value$LWS = args$LWS[0];
6563
- args$LWS[0] = this instanceof SVGElement$LWS ? sanitizeSvgInnerHtml$LWS(this, value$LWS) : lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, 0 /* ContentType.HTML */);
6626
+ const contentType$LWS = this instanceof SVGElement$LWS ? ContentType$LWS.SVG : ContentType$LWS.HTML;
6627
+ args$LWS[0] = lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, contentType$LWS);
6564
6628
  }
6565
-
6566
6629
  ReflectApply$LWS$1(originalSetHTML$LWS, this, args$LWS);
6567
6630
  }];
6568
6631
  };
@@ -6623,6 +6686,18 @@ function initDistortionElementToggleAttribute$LWS({
6623
6686
  }];
6624
6687
  };
6625
6688
  }
6689
+ function initDistortionEval$LWS({
6690
+ UNCOMPILED_CONTEXT: UNCOMPILED_CONTEXT$LWS,
6691
+ globalObject: {
6692
+ eval: originalEval$LWS
6693
+ }
6694
+ }) {
6695
+ return function distortionEval$LWS({
6696
+ sandboxEvaluator: sandboxEvaluator$LWS
6697
+ }) {
6698
+ return [originalEval$LWS, sourceText$LWS => sandboxEvaluator$LWS(transformSourceText$LWS(toString$LWS(sourceText$LWS)), UNCOMPILED_CONTEXT$LWS)];
6699
+ };
6700
+ }
6626
6701
  function composedPath$LWS() {
6627
6702
  return createDistortedComposedPath$LWS(this);
6628
6703
  }
@@ -6715,22 +6790,35 @@ function initDistortionFunction$LWS({
6715
6790
  Function: originalFunction$LWS
6716
6791
  }
6717
6792
  }) {
6793
+ const funcFooterRegExp$LWS = /\n?}[^}]*$/;
6718
6794
  return function distortionFunction$LWS({
6719
6795
  sandboxEvaluator: sandboxEvaluator$LWS
6720
6796
  }) {
6721
6797
  return [originalFunction$LWS, function Function$LWS(...args$LWS) {
6798
+ // The `arguments` object has `Symbol.iterator` as an own
6799
+ // property, not inherited, so it avoids prototype pollution
6800
+ // attacks.
6801
+ const sandboxFuncCtor$LWS = sandboxEvaluator$LWS('(function() {return Function(...arguments)})');
6722
6802
  const {
6723
6803
  length: length$LWS
6724
6804
  } = args$LWS;
6725
- if (length$LWS) {
6726
- const lastIndex$LWS = length$LWS - 1;
6727
- args$LWS[lastIndex$LWS] = transformSourceText$LWS(toString$LWS(args$LWS[lastIndex$LWS]));
6728
- }
6729
- // NOTE: Function constructor and eval are controlled by the same CSP rules,
6730
- // which means we can rely on eval to fulfill the behavior of the Function
6731
- // constructor.
6732
- const fn$LWS = sandboxEvaluator$LWS(`(...args) => Function(...args)`, UNCOMPILED_CONTEXT$LWS);
6733
- return ReflectApply$LWS$1(fn$LWS, this, args$LWS);
6805
+ if (!length$LWS) {
6806
+ return ReflectApply$LWS$1(sandboxFuncCtor$LWS, this, []);
6807
+ }
6808
+ const lastIndex$LWS = length$LWS - 1;
6809
+ const funcBody$LWS = toString$LWS(args$LWS[lastIndex$LWS]);
6810
+ // Validate parsing the function body.
6811
+ ReflectApply$LWS$1(sandboxFuncCtor$LWS, this, [funcBody$LWS]);
6812
+ // Make function body empty to create the wire-frame.
6813
+ args$LWS[lastIndex$LWS] = '';
6814
+ const wireFunc$LWS = ReflectApply$LWS$1(sandboxFuncCtor$LWS, this, args$LWS);
6815
+ const prefix$LWS = `${generateContextAssignmentCodeFromContextNames$LWS(UNIVERSAL_CONTEXT_NAMES$LWS)};`;
6816
+ const header$LWS = ReflectApply$LWS$1(StringProtoReplace$LWS, `${wireFunc$LWS}`, [funcFooterRegExp$LWS, '']);
6817
+ const code$LWS = compileSourceText$LWS(funcBody$LWS);
6818
+ // NOTE: Function constructor and eval are controlled by the
6819
+ // same CSP rules, which means we can rely on eval to fulfill
6820
+ // the behavior of the Function constructor.
6821
+ return sandboxEvaluator$LWS(`${prefix$LWS}(${header$LWS}${code$LWS}\n})`, UNCOMPILED_CONTEXT$LWS);
6734
6822
  }];
6735
6823
  };
6736
6824
  }
@@ -6750,7 +6838,7 @@ function initDistortionHistoryPushState$LWS({
6750
6838
  } catch (error) {
6751
6839
  if (args$LWS.length && error instanceof DOMException$LWS) {
6752
6840
  const state$LWS = args$LWS[0];
6753
- if (isObject$LWS(state$LWS)) {
6841
+ if (isObject$LWS$1(state$LWS)) {
6754
6842
  args$LWS[0] = partialStructuredClone$LWS(state$LWS);
6755
6843
  return ReflectApply$LWS$1(originalPushState$LWS, this, args$LWS);
6756
6844
  }
@@ -6778,7 +6866,7 @@ function initDistortionHistoryReplaceState$LWS({
6778
6866
  } catch (error) {
6779
6867
  if (args$LWS.length && error instanceof DOMException$LWS) {
6780
6868
  const state$LWS = args$LWS[0];
6781
- if (isObject$LWS(state$LWS)) {
6869
+ if (isObject$LWS$1(state$LWS)) {
6782
6870
  args$LWS[0] = partialStructuredClone$LWS(state$LWS);
6783
6871
  return ReflectApply$LWS$1(originalReplaceState$LWS, this, args$LWS);
6784
6872
  }
@@ -6833,7 +6921,7 @@ function initDistortionHTMLElementCtor$LWS({
6833
6921
  if (registry$LWS === undefined) {
6834
6922
  registry$LWS = getSandboxCustomElementRegistry$LWS(document$LWS, key$LWS);
6835
6923
  }
6836
- return registry$LWS.newCtor(this);
6924
+ return registry$LWS.newCtor(this, new.target, originalHTMLElementCtor$LWS);
6837
6925
  }];
6838
6926
  };
6839
6927
  }
@@ -7041,7 +7129,7 @@ function initDistortionHTMLObjectElementDataSetter$LWS({
7041
7129
  if (!isValidURL$LWS(parsedURL$LWS)) {
7042
7130
  throw new LockerSecurityError$LWS(`Cannot request disallowed endpoint: ${parsedURL$LWS.normalizedURL}`);
7043
7131
  }
7044
- ReflectApply$LWS$1(originalDataSetter$LWS, this, [urlString$LWS]);
7132
+ ReflectApply$LWS$1(originalDataSetter$LWS, this, [trusted.createScriptURL(urlString$LWS)]);
7045
7133
  }
7046
7134
  const distortionEntry$LWS = [originalDataSetter$LWS, data$LWS];
7047
7135
  return function distortionHTMLObjectElementDataSetter$LWS(record$LWS) {
@@ -7267,8 +7355,8 @@ function initDistortionHTMLScriptElementTextSetter$LWS({
7267
7355
  }) {
7268
7356
  return [originalTextSetter$LWS, function text$LWS(value$LWS) {
7269
7357
  if (this instanceof HTMLScriptElement$LWS) {
7270
- const doesReturnEarly$LWS = scriptPropertySetters$LWS(this, 'text', toString$LWS(value$LWS), originalTextGetter$LWS, originalTextSetter$LWS, distortions$LWS, sandboxEvaluator$LWS);
7271
- if (doesReturnEarly$LWS) {
7358
+ const scriptWasNotEvaluatedInScriptPropertySetter$LWS = scriptPropertySetters$LWS(this, 'text', trusted.createScript(value$LWS), originalTextGetter$LWS, originalTextSetter$LWS, distortions$LWS, sandboxEvaluator$LWS, trusted.createScript(SCRIPT_HOOK_SOURCE_TEXT$LWS));
7359
+ if (scriptWasNotEvaluatedInScriptPropertySetter$LWS) {
7272
7360
  return;
7273
7361
  }
7274
7362
  }
@@ -7292,7 +7380,7 @@ function initDistortionIDBObjectStoreAdd$LWS({
7292
7380
  } catch (error) {
7293
7381
  if (args$LWS.length && error instanceof DOMException$LWS) {
7294
7382
  const value$LWS = args$LWS[0];
7295
- if (isObject$LWS(value$LWS)) {
7383
+ if (isObject$LWS$1(value$LWS)) {
7296
7384
  args$LWS[0] = partialStructuredClone$LWS(value$LWS);
7297
7385
  return ReflectApply$LWS$1(originalAdd$LWS, this, args$LWS);
7298
7386
  }
@@ -7320,7 +7408,7 @@ function initDistortionIDBObjectStorePut$LWS({
7320
7408
  } catch (error) {
7321
7409
  if (args$LWS.length && error instanceof DOMException$LWS) {
7322
7410
  const value$LWS = args$LWS[0];
7323
- if (isObject$LWS(value$LWS)) {
7411
+ if (isObject$LWS$1(value$LWS)) {
7324
7412
  args$LWS[0] = partialStructuredClone$LWS(value$LWS);
7325
7413
  return ReflectApply$LWS$1(originalPut$LWS, this, args$LWS);
7326
7414
  }
@@ -7350,7 +7438,7 @@ function initDistortionMessagePortPostMessage$LWS({
7350
7438
  } = args$LWS;
7351
7439
  if (length$LWS && error instanceof DOMException$LWS) {
7352
7440
  const message$LWS = args$LWS[0];
7353
- if (isObject$LWS(message$LWS)) {
7441
+ if (isObject$LWS$1(message$LWS)) {
7354
7442
  if (length$LWS > 1) {
7355
7443
  // MDN document providing a transfer list array
7356
7444
  // while the WHATWG documents providing an options
@@ -7638,7 +7726,7 @@ function initDistortionNodeTextContentSetter$LWS({
7638
7726
  sandboxEvaluator: sandboxEvaluator$LWS
7639
7727
  } = record$LWS;
7640
7728
  return [originalTextContentSetter$LWS, function textContent$LWS(value$LWS) {
7641
- const valueAsString$LWS = toString$LWS(value$LWS);
7729
+ const valueAsString$LWS = trusted.createScript(value$LWS);
7642
7730
  // There are two existence of the attribute textContent, one on
7643
7731
  // Attr and one on Node. This first if statement is checking to
7644
7732
  // figure out which distortion should be applied. The instanceof
@@ -7666,8 +7754,8 @@ function initDistortionNodeTextContentSetter$LWS({
7666
7754
  return;
7667
7755
  }
7668
7756
  } else if (this instanceof HTMLScriptElement$LWS || this instanceof SVGScriptElement$LWS) {
7669
- const doesReturnEarly$LWS = scriptPropertySetters$LWS(this, 'textContent', valueAsString$LWS, originalTextContentGetter$LWS, originalTextContentSetter$LWS, distortions$LWS, sandboxEvaluator$LWS);
7670
- if (doesReturnEarly$LWS) {
7757
+ const scriptWasNotEvaluatedInScriptPropertySetter$LWS = scriptPropertySetters$LWS(this, 'textContent', valueAsString$LWS, originalTextContentGetter$LWS, originalTextContentSetter$LWS, distortions$LWS, sandboxEvaluator$LWS, trusted.createScript(SCRIPT_HOOK_SOURCE_TEXT$LWS));
7758
+ if (scriptWasNotEvaluatedInScriptPropertySetter$LWS) {
7671
7759
  return;
7672
7760
  }
7673
7761
  }
@@ -7699,7 +7787,7 @@ function initDistortionNotificationCtor$LWS({
7699
7787
  const {
7700
7788
  data: data$LWS
7701
7789
  } = providedOptions$LWS;
7702
- if (isObject$LWS(data$LWS)) {
7790
+ if (isObject$LWS$1(data$LWS)) {
7703
7791
  args$LWS[1] = {
7704
7792
  // The Notification constructor accepts
7705
7793
  // inherited options property values.
@@ -7742,10 +7830,9 @@ function initDistortionRangeCreateContextualFragment$LWS({
7742
7830
  // MAY CONTAIN a custom element, which must be marked
7743
7831
  // for association to this sandbox.
7744
7832
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
7745
- args$LWS[0] = lwsInternalPolicy$LWS.createHTML(tagString$LWS, key$LWS, 0 /* ContentType.HTML */);
7833
+ args$LWS[0] = lwsInternalPolicy$LWS.createHTML(tagString$LWS, key$LWS, ContentType$LWS.HTML);
7746
7834
  }
7747
7835
  }
7748
-
7749
7836
  return ReflectApply$LWS$1(originalCreateContextualFragment$LWS, this, args$LWS);
7750
7837
  }];
7751
7838
  };
@@ -7942,11 +8029,10 @@ function initDistortionShadowRootInnerHTMLSetter$LWS({
7942
8029
  // MAY CONTAIN a custom element, which must be marked for
7943
8030
  // association to this sandbox.
7944
8031
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
7945
- ReflectApply$LWS$1(originalInnerHTMLSetter$LWS, this, [lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, 0 /* ContentType.HTML */)]);
8032
+ ReflectApply$LWS$1(originalInnerHTMLSetter$LWS, this, [lwsInternalPolicy$LWS.createHTML(value$LWS, key$LWS, ContentType$LWS.HTML)]);
7946
8033
  }];
7947
8034
  };
7948
8035
  }
7949
-
7950
8036
  function mode$LWS() {
7951
8037
  return 'closed';
7952
8038
  }
@@ -8245,7 +8331,7 @@ function createDistortionStorageFactoryInitializer$LWS(storageName$LWS) {
8245
8331
  // eslint-disable-next-line no-empty
8246
8332
  } catch (_unused2$LWS) {}
8247
8333
  // istanbul ignore if: currently unreachable via tests
8248
- if (!isObject$LWS(originalStorageObject$LWS)) {
8334
+ if (!isObject$LWS$1(originalStorageObject$LWS)) {
8249
8335
  return noop$LWS$1;
8250
8336
  }
8251
8337
  return function distortionStorageFactory$LWS({
@@ -8476,16 +8562,25 @@ function initDistortionSVGElementStyleGetter$LWS({
8476
8562
  return distortionEntry$LWS;
8477
8563
  };
8478
8564
  }
8565
+ const script$LWS = ReflectApply$LWS$1(DocumentProtoCreateElementNS$LWS, document, [NAMESPACE_SVG$LWS, 'script']);
8479
8566
  function initDistortionSVGScriptElementHrefGetter$LWS({
8480
8567
  globalObject: {
8568
+ Element: {
8569
+ prototype: {
8570
+ setAttribute: originalSetAttribute$LWS
8571
+ }
8572
+ },
8481
8573
  SVGScriptElement: SVGScriptElement$LWS
8482
8574
  }
8483
8575
  }) {
8484
8576
  const originalHrefGetter$LWS = ObjectLookupOwnGetter$LWS$1(SVGScriptElement$LWS.prototype, 'href');
8485
8577
  const distortionEntry$LWS = [originalHrefGetter$LWS, function href$LWS() {
8486
- var _getScriptURL2$LWS;
8487
- // istanbul ignore next: optional chaining and nullish coalescing results in an expansion that contains unreachable branches
8488
- return (_getScriptURL2$LWS = getScriptURL$LWS(this)) != null ? _getScriptURL2$LWS : ReflectApply$LWS$1(originalHrefGetter$LWS, this, []);
8578
+ const url$LWS = getScriptURL$LWS(this);
8579
+ if (typeof url$LWS === 'string') {
8580
+ ReflectApply$LWS$1(originalSetAttribute$LWS, script$LWS, ['href', trusted.createScriptURL(url$LWS)]);
8581
+ return ReflectApply$LWS$1(originalHrefGetter$LWS, script$LWS, []);
8582
+ }
8583
+ return ReflectApply$LWS$1(originalHrefGetter$LWS, this, []);
8489
8584
  }];
8490
8585
  return function distortionSVGScriptElementHrefGetter$LWS() {
8491
8586
  return distortionEntry$LWS;
@@ -8499,6 +8594,8 @@ function initDistortionSVGScriptElementHrefSetter$LWS({
8499
8594
  return function distortionSVGScriptElementHrefSetter$LWS(record$LWS) {
8500
8595
  registerAttributeDistortion$LWS(record$LWS, SVGScriptElement$LWS, 'href', NAMESPACE_XLINK$LWS, createScriptDistortion$LWS(record$LWS, 'href'));
8501
8596
  registerAttributeDistortion$LWS(record$LWS, SVGScriptElement$LWS, 'xlink:href', NAMESPACE_XLINK$LWS, createScriptDistortion$LWS(record$LWS, 'xlink:href'));
8597
+ registerAttributeDistortion$LWS(record$LWS, SVGScriptElement$LWS, 'href', NAMESPACE_DEFAULT$LWS, createScriptDistortion$LWS(record$LWS, 'href'));
8598
+ registerAttributeDistortion$LWS(record$LWS, SVGScriptElement$LWS, 'xlink:href', NAMESPACE_DEFAULT$LWS, createScriptDistortion$LWS(record$LWS, 'xlink:href'));
8502
8599
  };
8503
8600
  }
8504
8601
  function initDistortionSVGSetElementAttributeNameAttribute$LWS({
@@ -8672,7 +8769,7 @@ function initDistortionURLCreateObjectURL$LWS({
8672
8769
  }
8673
8770
  const responseText$LWS = ReflectApply$LWS$1(XhrProtoResponseTextGetter$LWS, xhr$LWS, []);
8674
8771
  const sanitized$LWS = sanitizer$LWS.sanitize(responseText$LWS);
8675
- if (!isEqualDomString$LWS(responseText$LWS, sanitized$LWS)) {
8772
+ if (!isEqualDomString$LWS(trusted.createHTML(responseText$LWS), trusted.createHTML(sanitized$LWS))) {
8676
8773
  URLRevokeObjectURL$LWS(outURL$LWS);
8677
8774
  throw new LockerSecurityError$LWS(`Cannot 'createObjectURL' using an unsecure ${toSafeTemplateStringValue$LWS(blobObject$LWS)}.`);
8678
8775
  }
@@ -8987,8 +9084,12 @@ function initDistortionWindowOpen$LWS({
8987
9084
  }
8988
9085
  }) {
8989
9086
  const distortionEntry$LWS = [originalWindowOpen$LWS, function open$LWS(...args$LWS) {
8990
- const sanitizedArgs$LWS = sanitizeWindowOpenArguments$LWS(args$LWS);
8991
- return ReflectApply$LWS$1(originalWindowOpen$LWS, this, sanitizedArgs$LWS);
9087
+ const normalizedArgs$LWS = normalizeWindowOpenArguments$LWS(args$LWS);
9088
+ const childWindow$LWS = ReflectApply$LWS$1(originalWindowOpen$LWS, this, normalizedArgs$LWS);
9089
+ if (childWindow$LWS && normalizedArgs$LWS.length) {
9090
+ initWindowOpenChildWindow$LWS(childWindow$LWS, normalizedArgs$LWS[0]);
9091
+ }
9092
+ return childWindow$LWS;
8992
9093
  }];
8993
9094
  return function distortionWindowOpen$LWS() {
8994
9095
  return distortionEntry$LWS;
@@ -9011,7 +9112,7 @@ function initDistortionWindowPostMessage$LWS({
9011
9112
  } = args$LWS;
9012
9113
  if (length$LWS) {
9013
9114
  const message$LWS = args$LWS[0];
9014
- if (isObject$LWS(message$LWS)) {
9115
+ if (isObject$LWS$1(message$LWS)) {
9015
9116
  // Calling `window.postMessage(message, target, transfer)`
9016
9117
  // is equivalent to `window.postMessage(message, { targetOrigin, transfer })`.
9017
9118
  const providedOptions$LWS = length$LWS > 1 ? args$LWS[1] : undefined;
@@ -9123,7 +9224,7 @@ function initDistortionWindowStructuredClone$LWS({
9123
9224
  } = args$LWS;
9124
9225
  if (length$LWS && error instanceof DOMException$LWS) {
9125
9226
  const message$LWS = args$LWS[0];
9126
- if (isObject$LWS(message$LWS)) {
9227
+ if (isObject$LWS$1(message$LWS)) {
9127
9228
  const providedOptions$LWS = length$LWS > 1 ? args$LWS[1] : undefined;
9128
9229
  if (isObjectLike$LWS(providedOptions$LWS)) {
9129
9230
  const {
@@ -9202,6 +9303,13 @@ function initDistortionXMLHttpRequestOpen$LWS({
9202
9303
  return distortionEntry$LWS;
9203
9304
  };
9204
9305
  }
9306
+ function replaceDocumentContent$LWS(doc$LWS, content$LWS) {
9307
+ const docImpl$LWS = ReflectApply$LWS$1(DocumentProtoImplementationGetter$LWS, doc$LWS, []);
9308
+ const newDoc$LWS = ReflectApply$LWS$1(DOMImplementationProtoCreateDocument$LWS, docImpl$LWS, [NAMESPACE_XHTML$LWS, 'html']);
9309
+ const newDocEl$LWS = ReflectApply$LWS$1(DocumentProtoDocumentElementGetter$LWS, newDoc$LWS, []);
9310
+ ReflectApply$LWS$1(ElementProtoInnerHTMLSetter$LWS, newDocEl$LWS, [content$LWS]);
9311
+ return newDoc$LWS;
9312
+ }
9205
9313
  function initDistortionXMLHttpRequestResponseGetter$LWS({
9206
9314
  document: document$LWS,
9207
9315
  globalObject: {
@@ -9220,7 +9328,12 @@ function initDistortionXMLHttpRequestResponseGetter$LWS({
9220
9328
  // MAY CONTAIN a custom element, which must be marked for
9221
9329
  // association to this sandbox.
9222
9330
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
9223
- return rawResponse$LWS instanceof Document$LWS ? sanitizeDocument$LWS(rawResponse$LWS, key$LWS) : /* istanbul ignore next: needs default platform behavior test */rawResponse$LWS;
9331
+ if (rawResponse$LWS instanceof Document$LWS) {
9332
+ const docEl$LWS = ReflectApply$LWS$1(DocumentProtoDocumentElementGetter$LWS, rawResponse$LWS, []);
9333
+ const content$LWS = ReflectApply$LWS$1(ElementProtoOuterHTMLGetter$LWS, docEl$LWS, []);
9334
+ return replaceDocumentContent$LWS(rawResponse$LWS, lwsInternalPolicy$LWS.createHTML(content$LWS, key$LWS, ContentType$LWS.HTML));
9335
+ }
9336
+ return rawResponse$LWS;
9224
9337
  }];
9225
9338
  };
9226
9339
  }
@@ -9241,7 +9354,9 @@ function initDistortionXMLHttpRequestResponseXMLGetter$LWS({
9241
9354
  // MAY CONTAIN a custom element, which must be marked for
9242
9355
  // association to this sandbox.
9243
9356
  setCustomElementsRegistry$LWS(document$LWS, key$LWS);
9244
- return sanitizeDocument$LWS(rawResponseXML$LWS, key$LWS);
9357
+ const docEl$LWS = ReflectApply$LWS$1(DocumentProtoDocumentElementGetter$LWS, rawResponseXML$LWS, []);
9358
+ const content$LWS = ReflectApply$LWS$1(ElementProtoOuterHTMLGetter$LWS, docEl$LWS, []);
9359
+ return replaceDocumentContent$LWS(rawResponseXML$LWS, lwsInternalPolicy$LWS.createHTML(content$LWS, key$LWS, ContentType$LWS.HTML));
9245
9360
  }];
9246
9361
  };
9247
9362
  }
@@ -9320,14 +9435,16 @@ initDistortionAuraUtilGlobalEval$LWS,
9320
9435
  initDistortionCacheStorageDelete$LWS, initDistortionCacheStorageHas$LWS, initDistortionCacheStorageKeys$LWS, initDistortionCacheStorageMatch$LWS, initDistortionCacheStorageOpen$LWS,
9321
9436
  // CookieStore
9322
9437
  initDistortionCookieStoreDelete$LWS, initDistortionCookieStoreGet$LWS, initDistortionCookieStoreGetAll$LWS, initDistortionCookieStoreOnChange$LWS, initDistortionCookieStoreSet$LWS,
9438
+ // CustomElementRegistry
9439
+ initDistortionCustomElementRegistryDefine$LWS, initDistortionCustomElementRegistryGet$LWS, initDistortionCustomElementRegistryWhenDefined$LWS,
9323
9440
  // Document
9324
9441
  initDistortionDocumentCookieGetter$LWS, initDistortionDocumentCookieSetter$LWS, initDistortionDocumentCreateElement$LWS, initDistortionDocumentCreateElementNS$LWS, initDistortionDocumentExecCommand$LWS, initDistortionDocumentReplaceChildren$LWS,
9325
9442
  // DOMParser
9326
9443
  initDistortionDOMParserParseFromString$LWS,
9327
- // CustomElementRegistry
9328
- initDistortionCustomElementRegistryDefine$LWS, initDistortionCustomElementRegistryGet$LWS, initDistortionCustomElementRegistryWhenDefined$LWS,
9329
9444
  // Element
9330
9445
  initDistortionElementInnerHTMLSetter$LWS, initDistortionElementInsertAdjacentHTML$LWS, initDistortionElementOuterHTMLSetter$LWS, initDistortionElementSetAttribute$LWS, initDistortionElementSetAttributeNode$LWS, initDistortionElementSetAttributeNodeNS$LWS, initDistortionElementSetAttributeNS$LWS, initDistortionElementSetHTML$LWS, initDistortionElementToggleAttribute$LWS,
9446
+ // Eval
9447
+ initDistortionEval$LWS,
9331
9448
  // Event
9332
9449
  initDistortionEventComposedPath$LWS, initDistortionEventPathGetter$LWS,
9333
9450
  // EventTarget
@@ -9373,18 +9490,6 @@ initDistortionNodeInsertBefore$LWS]);
9373
9490
  const externalKeyedDistortionFactoryInitializers$LWS = internalKeyedDistortionFactoryInitializers$LWS;
9374
9491
  const DocumentBlockedProperties$LWS = ['createProcessingInstruction', 'exitFullscreen', 'fullscreen', 'fullscreenElement', 'fullscreenEnabled', 'getSelection', 'mozCancelFullScreen', 'mozFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'onfullscreenchange', 'onfullscreenerror', 'onmozfullscreenchange', 'onmozfullscreenerror', 'onrejectionhandled', 'onunhandledrejection', 'releaseCapture', 'releaseEvents', 'webkitFullScreenKeyboardInputAllowed', 'write', 'writeln'];
9375
9492
  const ElementBlockedProperties$LWS = ['mozRequestFullScreen', 'onfullscreenchange', 'onfullscreenerror', 'requestFullscreen', 'webkitRequestFullScreen', 'webkitRequestFullscreen'];
9376
- function initDistortionEval$LWS({
9377
- UNCOMPILED_CONTEXT: UNCOMPILED_CONTEXT$LWS,
9378
- globalObject: {
9379
- eval: originalEval$LWS
9380
- }
9381
- }) {
9382
- return function distortionEval$LWS({
9383
- sandboxEvaluator: sandboxEvaluator$LWS
9384
- }) {
9385
- return [originalEval$LWS, sourceText$LWS => sandboxEvaluator$LWS(transformSourceText$LWS(toString$LWS(sourceText$LWS)), UNCOMPILED_CONTEXT$LWS)];
9386
- };
9387
- }
9388
9493
  const EventBlockedProperties$LWS = ['originalTarget', 'explicitOriginalTarget'];
9389
9494
  const HTMLElementBlockedAttributes$LWS = ['nonce'];
9390
9495
  const HTMLElementBlockedProperties$LWS = ['nonce', 'onrejectionhandled', 'onunhandledrejection'];
@@ -9401,13 +9506,12 @@ const SVGElementBlockedProperties$LWS = ['nonce'];
9401
9506
  const UIEventBlockedProperties$LWS = ['rangeParent'];
9402
9507
  const WindowBlockedProperties$LWS = ['find', 'getSelection'];
9403
9508
  const XSLTProcessorBlockedProperties$LWS = ['transformToDocument', 'transformToFragment'];
9404
- /*! version: 0.19.4 */
9509
+ /*! version: 0.19.10 */
9405
9510
 
9406
9511
  /*!
9407
9512
  * Copyright (C) 2019 salesforce.com, inc.
9408
9513
  */
9409
9514
  const distortionFactoriesCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
9410
- const evalDistortionFactoryCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
9411
9515
  const opaqueWindowPostMessageDistortionFactoryCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
9412
9516
  // WebKit based browsers have a bug that prematurely removes distortion entries
9413
9517
  // from the distortions weak map.
@@ -9482,7 +9586,7 @@ function getDistortionFactories$LWS(record$LWS) {
9482
9586
  if (typeof XSLTProcessor$LWS === 'function') {
9483
9587
  addBlockedPropertyDistortionFactoryInitializers$LWS(record$LWS, XSLTProcessor$LWS.prototype, XSLTProcessorBlockedProperties$LWS, initializers$LWS);
9484
9588
  }
9485
- patchGlobalObject$LWS(document$LWS, globalObject$LWS);
9589
+ patchGlobalObject$LWS(globalObject$LWS, document$LWS);
9486
9590
  // Reuse the `initializers` array as the `factories` array.
9487
9591
  factories$LWS = initializers$LWS;
9488
9592
  for (let i$LWS = 0, {
@@ -9496,18 +9600,6 @@ function getDistortionFactories$LWS(record$LWS) {
9496
9600
  distortionFactoriesCache$LWS.set(document$LWS, factories$LWS);
9497
9601
  return factories$LWS;
9498
9602
  }
9499
- function getEvalDistortionFactory$LWS(record$LWS) {
9500
- const {
9501
- document: document$LWS
9502
- } = record$LWS;
9503
- let evalDistortionFactory$LWS = evalDistortionFactoryCache$LWS.get(document$LWS);
9504
- if (evalDistortionFactory$LWS) {
9505
- return evalDistortionFactory$LWS;
9506
- }
9507
- evalDistortionFactory$LWS = initDistortionEval$LWS(record$LWS);
9508
- evalDistortionFactoryCache$LWS.set(document$LWS, evalDistortionFactory$LWS);
9509
- return evalDistortionFactory$LWS;
9510
- }
9511
9603
  function getOpaqueWindowPostMessageDistortionFactory$LWS(record$LWS) {
9512
9604
  const {
9513
9605
  globalObject: globalObject$LWS
@@ -9538,7 +9630,7 @@ function proxyMaskFunctionDistortion$LWS({
9538
9630
  } = distortionFactory$LWS;
9539
9631
  activityName$LWS = factoryName$LWS ? ReflectApply$LWS$1(StringProtoReplace$LWS, factoryName$LWS, [LOCKER_IDENTIFIER_MARKER$LWS, '']) : '<unknown>';
9540
9632
  }
9541
- return proxyMaskFunction$LWS(distortionFunc$LWS, maskFunc$LWS, {
9633
+ return maskFunction$LWS(distortionFunc$LWS, maskFunc$LWS, {
9542
9634
  apply: function (target$LWS, thisArg$LWS, args$LWS) {
9543
9635
  let activity$LWS;
9544
9636
  // istanbul ignore if: this is a safety precaution that is unreachable via tests
@@ -9626,7 +9718,14 @@ const EMPTY_DISTORTIONS_MAP$LWS = createDistortionMap$LWS();
9626
9718
  const EMPTY_OBJECT$LWS = {};
9627
9719
  const ROOT_UNCOMPILED_CONTEXT$LWS = {
9628
9720
  [UNCOMPILED_LOCATION_NAME$LWS]: rootWindowLocation$LWS,
9629
- [UNCOMPILED_TOP_NAME$LWS]: topWindow$LWS
9721
+ [UNCOMPILED_TOP_NAME$LWS]: rootWindowTop$LWS,
9722
+ // The following context entries are explicitly added because the
9723
+ // UNCOMPILED_*_NAME entries will only be added to the contextNames
9724
+ // via transforms when the fully qualified member expression is detected
9725
+ // in the code, eg. window.location, or window.top.
9726
+ // See complete explanation in packages/@locker/shared-dom/src/source-transformations.ts.
9727
+ location: rootWindowLocation$LWS,
9728
+ top: rootWindowTop$LWS
9630
9729
  };
9631
9730
  const {
9632
9731
  apply: ReflectApply$LWS,
@@ -9655,6 +9754,9 @@ const ObjectHasOwn$LWS = typeof OriginalObjectHasOwn$LWS === 'function' ? Origin
9655
9754
  function ObjectHasOwn$LWS(object$LWS, key$LWS) {
9656
9755
  return ReflectApply$LWS(ObjectProtoHasOwnProperty$LWS, object$LWS, [key$LWS]);
9657
9756
  };
9757
+ function isObject$LWS(value$LWS) {
9758
+ return typeof value$LWS === 'object' && value$LWS !== null;
9759
+ }
9658
9760
  function ObjectLookupOwnGetter$LWS(object$LWS, key$LWS) {
9659
9761
  return object$LWS === null || object$LWS === undefined || !ObjectHasOwn$LWS(object$LWS, key$LWS) ? undefined : ReflectApply$LWS(ObjectProtoLookupGetter$LWS, object$LWS, [key$LWS]);
9660
9762
  }
@@ -14077,7 +14179,8 @@ function getCachedGlobalObjectReferences$LWS(globalObject$LWS) {
14077
14179
  WindowProto: ReflectGetPrototypeOf$LWS(window$LWS),
14078
14180
  WindowPropertiesProto: ReflectGetPrototypeOf$LWS(WindowProto$LWS),
14079
14181
  EventTargetProto: EventTargetProto$LWS,
14080
- EventTargetProtoOwnKeys: ReflectOwnKeys$LWS(EventTargetProto$LWS)
14182
+ // Some simulated browser environments, e.g. those using JSDOM, may lack an EventTargetProto.
14183
+ EventTargetProtoOwnKeys: EventTargetProto$LWS ? ReflectOwnKeys$LWS(EventTargetProto$LWS) : []
14081
14184
  };
14082
14185
  blueDocumentToRecordMap$LWS.set(document$LWS, record$LWS);
14083
14186
  return record$LWS;
@@ -14172,6 +14275,7 @@ function createIframeVirtualEnvironment$LWS(globalObject$LWS, providedOptions$LW
14172
14275
  }
14173
14276
  const {
14174
14277
  distortionCallback: distortionCallback$LWS,
14278
+ defaultPolicy: defaultPolicy$LWS,
14175
14279
  endowments: endowments$LWS,
14176
14280
  globalObjectShape: globalObjectShape$LWS,
14177
14281
  instrumentation: instrumentation$LWS,
@@ -14191,6 +14295,12 @@ function createIframeVirtualEnvironment$LWS(globalObject$LWS, providedOptions$LW
14191
14295
  if (blueConnector$LWS === undefined) {
14192
14296
  blueConnector$LWS = createBlueConnector$LWS(globalObject$LWS);
14193
14297
  blueCreateHooksCallbackCache$LWS.set(blueRefs$LWS.document, blueConnector$LWS);
14298
+ } // Install default TrustedTypes policy in the virtual environment.
14299
+ // @ts-ignore trustedTypes does not exist on GlobalObject
14300
+
14301
+ if (typeof redWindow$LWS.trustedTypes !== 'undefined' && isObject$LWS(defaultPolicy$LWS)) {
14302
+ // @ts-ignore trustedTypes does not exist on GlobalObject
14303
+ redWindow$LWS.trustedTypes.createPolicy('default', defaultPolicy$LWS);
14194
14304
  }
14195
14305
  const {
14196
14306
  eval: redIndirectEval$LWS
@@ -14393,6 +14503,7 @@ function createEvalHelpersFactoryArgs$LWS(record$LWS) {
14393
14503
  },
14394
14504
  distortions: distortions$LWS,
14395
14505
  globalObject: {
14506
+ HTMLScriptElement: HTMLScriptElement$LWS,
14396
14507
  HTMLScriptElement: {
14397
14508
  prototype: HTMLScriptElementProto$LWS
14398
14509
  }
@@ -14435,6 +14546,13 @@ function createEvalHelpersFactoryArgs$LWS(record$LWS) {
14435
14546
  ReflectApply$LWS$1(EventTargetProtoRemoveEventListener$LWS, element$LWS, ['error', onerror$LWS]);
14436
14547
  ReflectApply$LWS$1(EventTargetProtoRemoveEventListener$LWS, element$LWS, ['load', onload$LWS]);
14437
14548
  resourceStatusCache$LWS.set(element$LWS, 3 /* ResourceLoaderStatus.Loaded */);
14549
+ // platformResourceLoader and ltng:require have to be synchronized in terms of
14550
+ // creating and loading scripts. This expando is used by ltng:require to know if a
14551
+ // script has been loaded by it or not. See W-13034908.
14552
+ if (element$LWS instanceof HTMLScriptElement$LWS) {
14553
+ // eslint-disable-next-line no-underscore-dangle
14554
+ element$LWS._ltngRequireLoaded = true;
14555
+ }
14438
14556
  resolve$LWS(undefined);
14439
14557
  }
14440
14558
  ReflectApply$LWS$1(EventTargetProtoAddEventListener$LWS, element$LWS, ['error', onerror$LWS]);
@@ -14509,9 +14627,9 @@ function createEvalHelpersFactoryArgs$LWS(record$LWS) {
14509
14627
  // istanbul ignore next: this is a safety precaution, not reachable via any normal execution
14510
14628
  return undefined;
14511
14629
  },
14512
- // Functionality based on https://sfdc.co/7FuDU but adjusted for multiple
14513
- // sandboxes. loadScript will create one <script> element in the DOM per
14514
- // url per sandbox.
14630
+ // Functionality based on platformResourceLoader#loadScript (https://sfdc.co/7FuDU) but
14631
+ // adjusted for multiple sandboxes. This loadScript will create one <script> element in the
14632
+ // DOM per url per sandbox.
14515
14633
  function loadScript$LWS(_thisArg$LWS, url$LWS) {
14516
14634
  const urlAsString$LWS = toString$LWS(url$LWS);
14517
14635
  const resolvedURL$LWS = resolveURL$LWS(urlAsString$LWS);
@@ -14538,12 +14656,17 @@ function createEvalHelpersFactoryArgs$LWS(record$LWS) {
14538
14656
  }
14539
14657
  const script$LWS = ReflectApply$LWS$1(DocumentProtoCreateElement$LWS$1, document$LWS, ['script']);
14540
14658
  script$LWS.type = 'text/javascript';
14659
+ // platformResourceLoader and ltng:require have to be synchronized in terms of creating
14660
+ // and loading scripts. This expando is used by ltng:require to know if a script
14661
+ // has been created by it or not. See W-13034908.
14662
+ // eslint-disable-next-line no-underscore-dangle
14663
+ script$LWS._ltngRequireCreated = true;
14541
14664
  ReflectApply$LWS$1(scriptSrcSetterDistortion$LWS, script$LWS, [urlAsString$LWS]);
14542
14665
  return loadPromise$LWS(script$LWS, urlAsString$LWS);
14543
14666
  },
14544
- // Functionality based on http://sfdc.co/bIpMYB but adjusted for multiple
14545
- // sandboxes. loadStyle will create one <link> element in the DOM per url
14546
- // for all the sandboxes.
14667
+ // Functionality based on platformResourceLoader#loadStyle (http://sfdc.co/bIpMYB) but
14668
+ // adjusted for multiple sandboxes. This loadStyle will create one <link> element in the DOM
14669
+ // per url for all the sandboxes.
14547
14670
  function loadStyle$LWS(_thisArg$LWS, url$LWS) {
14548
14671
  const urlAsString$LWS = toString$LWS(url$LWS);
14549
14672
  let link$LWS = ReflectApply$LWS$1(ElementProtoQuerySelector$LWS, head$LWS, [`link[href=${enquote$LWS(urlAsString$LWS)}]`]);
@@ -14621,7 +14744,6 @@ const IFRAME_KEEP_ALIVE_FLAG$LWS = LOCKER_UNMINIFIED_FLAG$LWS && !false;
14621
14744
  // virtual environment distortion callback by seeding them in the root window's
14622
14745
  // created distortion map.
14623
14746
  const rootDistortionMapSeedEntries$LWS = [[rootDocument$LWS, rootDocument$LWS], [rootWindowLocation$LWS, rootWindowLocation$LWS], [rootWindow$LWS$1, rootWindow$LWS$1]];
14624
- const rendererFactoryToRendererCache$LWS = toSafeWeakMap$LWS$1(new WeakMapCtor$LWS$1());
14625
14747
  const seenGlobalObjects$LWS = toSafeWeakSet$LWS$1(new WeakSetCtor$LWS$1());
14626
14748
  function createGetVirtualEnvironment$LWS(record$LWS) {
14627
14749
  let virtualEnvironment$LWS;
@@ -14675,7 +14797,7 @@ function createSandboxEvaluator$LWS({
14675
14797
  key: key$LWS,
14676
14798
  type: type$LWS
14677
14799
  }) {
14678
- return (sourceText$LWS, evalContext$LWS, evalGlobalObject$LWS = globalObject$LWS, evalDocument$LWS = document$LWS) => internalEvaluateInSandbox$LWS({
14800
+ return (sourceText$LWS, evalContext$LWS = EMPTY_OBJECT$LWS, evalGlobalObject$LWS = globalObject$LWS, evalDocument$LWS = document$LWS) => internalEvaluateInSandbox$LWS({
14679
14801
  context: evalContext$LWS,
14680
14802
  document: evalDocument$LWS,
14681
14803
  endowments: EMPTY_OBJECT$LWS,
@@ -14691,7 +14813,6 @@ function createSandboxEvaluator$LWS({
14691
14813
  function createVirtualEnvironment$LWS(record$LWS) {
14692
14814
  const {
14693
14815
  LOCKER_VERBOSE_INSTRUMENTATION_FLAG: verboseInstrumentation$LWS,
14694
- distortions: overrideDistortions$LWS,
14695
14816
  endowments: endowments$LWS,
14696
14817
  globalObject: globalObject$LWS,
14697
14818
  instrumentation: instrumentation$LWS,
@@ -14702,12 +14823,14 @@ function createVirtualEnvironment$LWS(record$LWS) {
14702
14823
  },
14703
14824
  type: type$LWS
14704
14825
  } = record$LWS;
14705
- const isRootRecord$LWS = record$LWS === root$LWS;
14706
14826
  return createIframeVirtualEnvironment$LWS(globalObject$LWS, {
14827
+ defaultPolicy: {
14828
+ createScript: dirty$LWS => dirty$LWS
14829
+ },
14707
14830
  distortionCallback(originalTarget$LWS) {
14708
14831
  const distortedTarget$LWS = distortions$LWS.get(originalTarget$LWS);
14709
14832
  if (distortedTarget$LWS) {
14710
- return isRootRecord$LWS ? distortedTarget$LWS : overrideDistortions$LWS.get(originalTarget$LWS) || distortedTarget$LWS;
14833
+ return distortedTarget$LWS;
14711
14834
  }
14712
14835
  if (typeof originalTarget$LWS === 'function') {
14713
14836
  return originalTarget$LWS;
@@ -14734,8 +14857,8 @@ function createVirtualEnvironment$LWS(record$LWS) {
14734
14857
  if (ObjectHasOwn$LWS$1(originalTarget$LWS, 'window') && originalTarget$LWS.window === originalTarget$LWS) {
14735
14858
  // Slower check to detect a window object.
14736
14859
  try {
14737
- // This will throw if `originalTarget` is not a window
14738
- // object, or if it is an opaque cross-origin window.
14860
+ // `WindowDocumentGetter` will throw if `originalTarget` is
14861
+ // not a window object, or if it is an opaque cross-origin window.
14739
14862
  originalTargetDocument$LWS = ReflectApply$LWS$1(WindowDocumentGetter$LWS, originalTarget$LWS, []);
14740
14863
  originalTargetWindow$LWS = originalTarget$LWS;
14741
14864
  } catch (_unused37$LWS) {
@@ -14936,20 +15059,27 @@ function createSecondaryWindowSandboxRecord$LWS({
14936
15059
  instrumentation: instrumentation$LWS
14937
15060
  } = root$LWS;
14938
15061
  const {
14939
- location: location$LWS
15062
+ location: location$LWS,
15063
+ top: top$LWS
14940
15064
  } = globalObject$LWS;
14941
- const overrideDistortions$LWS = createDistortionMap$LWS();
14942
15065
  record$LWS = {
14943
15066
  BASIC_INSTRUMENTATION_DATA: BASIC_INSTRUMENTATION_DATA$LWS,
14944
15067
  LOCKER_INSTRUMENTATION_FLAG: LOCKER_INSTRUMENTATION_FLAG$LWS,
14945
15068
  LOCKER_VERBOSE_INSTRUMENTATION_FLAG: LOCKER_VERBOSE_INSTRUMENTATION_FLAG$LWS,
14946
15069
  UNCOMPILED_CONTEXT: {
14947
15070
  [UNCOMPILED_LOCATION_NAME$LWS]: location$LWS,
14948
- [UNCOMPILED_TOP_NAME$LWS]: globalObject$LWS.top
15071
+ [UNCOMPILED_TOP_NAME$LWS]: top$LWS,
15072
+ // The following context entries are explicitly added because the
15073
+ // UNCOMPILED_*_NAME entries will only be added to the contextNames
15074
+ // via transforms when the fully qualified member expression is detected
15075
+ // in the code, eg. window.location, or window.top.
15076
+ // See complete explanation in packages/@locker/shared-dom/src/source-transformations.ts.
15077
+ location: location$LWS,
15078
+ top: top$LWS
14949
15079
  },
14950
15080
  context: context$LWS,
14951
15081
  document: document$LWS,
14952
- distortions: overrideDistortions$LWS,
15082
+ distortions: EMPTY_DISTORTIONS_MAP$LWS,
14953
15083
  endowments: EMPTY_OBJECT$LWS,
14954
15084
  globalObject: globalObject$LWS,
14955
15085
  helpers: EMPTY_EVAL_HELPERS$LWS,
@@ -14986,15 +15116,6 @@ function createSecondaryWindowSandboxRecord$LWS({
14986
15116
  // Add distortion to the root window's distortion map.
14987
15117
  distortions$LWS.set(entryKey$LWS, entryValue$LWS);
14988
15118
  }
14989
- // Add child window eval distortion to the root window's distortion map.
14990
- const evalDistortionFactory$LWS = getEvalDistortionFactory$LWS(record$LWS);
14991
- const evalDistortionEntry$LWS = evalDistortionFactory$LWS(record$LWS);
14992
- const originalEval$LWS = evalDistortionEntry$LWS[0];
14993
- distortions$LWS.set(originalEval$LWS, proxyMaskFunctionDistortion$LWS(record$LWS, evalDistortionFactory$LWS, evalDistortionEntry$LWS[1], originalEval$LWS));
14994
- // Add `originalEval` to the child window's distortion map so that the
14995
- // undistorted `eval` is used in the child window's sandbox instead of the
14996
- // distorted `eval`.
14997
- overrideDistortions$LWS.set(originalEval$LWS, originalEval$LWS);
14998
15119
  sandboxRegistry$LWS[key$LWS] = record$LWS;
14999
15120
  if (seenGlobalObject$LWS) {
15000
15121
  return record$LWS;
@@ -15051,10 +15172,11 @@ function createSecondaryWindowSandboxRecord$LWS({
15051
15172
  const {
15052
15173
  document: newDocument$LWS
15053
15174
  } = globalObject$LWS;
15054
- if (document$LWS !== newDocument$LWS) {
15055
- ReflectApply$LWS$1(EventTargetProtoAddEventListener$LWS, globalObject$LWS, ['DOMContentLoaded', onDOMContentLoadedOrWindowLoad$LWS, true]);
15056
- ReflectApply$LWS$1(EventTargetProtoAddEventListener$LWS, globalObject$LWS, ['unload', onWindowUnload$LWS, true]);
15175
+ if (document$LWS === newDocument$LWS) {
15176
+ return;
15057
15177
  }
15178
+ ReflectApply$LWS$1(EventTargetProtoAddEventListener$LWS, globalObject$LWS, ['DOMContentLoaded', onDOMContentLoadedOrWindowLoad$LWS, true]);
15179
+ ReflectApply$LWS$1(EventTargetProtoAddEventListener$LWS, globalObject$LWS, ['unload', onWindowUnload$LWS, true]);
15058
15180
  } catch (_unused41$LWS) {
15059
15181
  // istanbul ignore next: this is a safety precaution that is unreachable via tests
15060
15182
  createOpaqueSecondaryWindowSandboxRecord$LWS({
@@ -15108,21 +15230,6 @@ function internalEvaluateInSandbox$LWS(evaluateOptions$LWS) {
15108
15230
  // Setting the context before evaluating the sourceText so compiled code
15109
15231
  // can wire up import/exports from both sides of the membrane.
15110
15232
  if (context$LWS !== EMPTY_OBJECT$LWS) {
15111
- // @TODO: Leave this in till LWC is upgraded with deleted @locker/compiler work
15112
- if (ObjectHasOwn$LWS$1(context$LWS, 'renderer') && ObjectHasOwn$LWS$1(context$LWS, 'rendererFactory')) {
15113
- const {
15114
- rendererFactory: rendererFactory$LWS
15115
- } = context$LWS;
15116
- let sandboxedRenderer$LWS = rendererFactoryToRendererCache$LWS.get(rendererFactory$LWS);
15117
- // istanbul ignore else: conditions for this to evaluate as false ARE tested (see integration-karma/test/sandboxes/lwc-renderer.spec.js, "produces same outcome when processed more than once"), however this path appears to _ALWAYS_ be taken. Needs further investigation
15118
- if (sandboxedRenderer$LWS === undefined) {
15119
- sandboxedRenderer$LWS = virtualEnvironmentEvaluator$LWS(`'use strict';
15120
- (${ReflectApply$LWS$1(FunctionProtoToString$LWS, rendererFactory$LWS, [])})`)(context$LWS.renderer);
15121
- rendererFactoryToRendererCache$LWS.set(rendererFactory$LWS, sandboxedRenderer$LWS);
15122
- }
15123
- context$LWS.renderer = sandboxedRenderer$LWS;
15124
- ReflectDeleteProperty$LWS$1(context$LWS, 'rendererFactory');
15125
- }
15126
15233
  setEvalContext$LWS(context$LWS);
15127
15234
  }
15128
15235
  if (helpers$LWS !== EMPTY_EVAL_HELPERS$LWS) {
@@ -15159,19 +15266,29 @@ function internalEvaluateInSandbox$LWS(evaluateOptions$LWS) {
15159
15266
  }
15160
15267
  return result$LWS;
15161
15268
  }
15162
- function evaluateInSandbox$LWS(key$LWS, source$LWS, context$LWS = EMPTY_OBJECT$LWS, endowments$LWS = EMPTY_OBJECT$LWS, instrumentation$LWS = EMPTY_OBJECT$LWS, verboseInstrumentation$LWS = false) {
15269
+ function evaluateFunction$LWS(key$LWS, fn$LWS, scope$LWS = EMPTY_OBJECT$LWS, sourceURL$LWS = '', endowments$LWS = EMPTY_OBJECT$LWS, instrumentation$LWS = EMPTY_OBJECT$LWS, verboseInstrumentation$LWS = false) {
15270
+ const argValues$LWS = toSafeArray$LWS$1([rootWindow$LWS$1.location, rootWindow$LWS$1.top]);
15271
+ const argNames$LWS = toSafeArray$LWS$1(['location', 'top']);
15272
+ const providedScopeNames$LWS = ObjectKeys$LWS$1(scope$LWS);
15273
+ for (let i$LWS = 0, {
15274
+ length: length$LWS
15275
+ } = providedScopeNames$LWS; i$LWS < length$LWS; i$LWS++) {
15276
+ const name$LWS = providedScopeNames$LWS[i$LWS];
15277
+ argNames$LWS.push(name$LWS);
15278
+ argValues$LWS.push(scope$LWS[name$LWS]);
15279
+ }
15163
15280
  return internalEvaluateInSandbox$LWS({
15164
- context: context$LWS,
15281
+ context: EMPTY_OBJECT$LWS,
15165
15282
  document: rootDocument$LWS,
15166
15283
  endowments: endowments$LWS,
15167
15284
  globalObject: rootWindow$LWS$1,
15168
15285
  instrumentation: instrumentation$LWS,
15169
15286
  key: key$LWS,
15170
- source: source$LWS,
15287
+ source: `((${argNames$LWS.join(',')}) => ${fn$LWS})\n${sourceURL$LWS}`,
15171
15288
  sourceType: 1 /* SourceType.Module */,
15172
15289
  type: 0 /* SandboxType.External */,
15173
15290
  verboseInstrumentation: verboseInstrumentation$LWS
15174
- });
15291
+ })(...argValues$LWS);
15175
15292
  }
15176
15293
  const sandboxDependencies$LWS = toSafeMap$LWS$1(new MapCtor$LWS$1());
15177
15294
  function wrapDependency$LWS(dep$LWS, depName$LWS, key$LWS) {
@@ -15213,16 +15330,23 @@ function wrapLWC$LWS(dep$LWS, key$LWS) {
15213
15330
  return attrValue$LWS;
15214
15331
  }
15215
15332
  });
15216
- const sandboxRecord$LWS = createRootWindowSandboxRecord$LWS({
15217
- key: key$LWS
15218
- });
15219
15333
  ReflectDefineProperty$LWS$1(secureDep$LWS, 'renderer', {
15220
15334
  __proto__: null,
15221
15335
  enumerable: true,
15222
15336
  configurable: true,
15223
- writable: true,
15224
- value: sandboxRecord$LWS.virtualEnvironmentEvaluator(`'use strict';
15225
- (${ReflectApply$LWS$1(FunctionProtoToString$LWS, dep$LWS.rendererFactory, [])})`)(dep$LWS.renderer)
15337
+ get: function () {
15338
+ let renderer$LWS;
15339
+ return function () {
15340
+ if (renderer$LWS === undefined) {
15341
+ renderer$LWS = createRootWindowSandboxRecord$LWS({
15342
+ key: key$LWS
15343
+ }).virtualEnvironmentEvaluator(`'use strict';
15344
+ (${ReflectApply$LWS$1(FunctionProtoToString$LWS, dep$LWS.rendererFactory, [])})`)(dep$LWS.renderer);
15345
+ }
15346
+ return renderer$LWS;
15347
+ };
15348
+ }(),
15349
+ set(_value$LWS) {}
15226
15350
  });
15227
15351
  depRegistry$LWS.set(dep$LWS, secureDep$LWS);
15228
15352
  return secureDep$LWS;
@@ -15243,21 +15367,18 @@ function wrapPlatformResourceLoader$LWS(dep$LWS, key$LWS) {
15243
15367
  if (secureDep$LWS) {
15244
15368
  return secureDep$LWS;
15245
15369
  }
15246
- const sandboxRecord$LWS = createRootWindowSandboxRecord$LWS({
15247
- key: key$LWS
15248
- });
15249
- const {
15250
- loadScript: loadScript$LWS,
15251
- loadStyle: loadStyle$LWS
15252
- } = sandboxRecord$LWS.helpers;
15253
15370
  secureDep$LWS = {
15254
- loadScript: loadScript$LWS,
15255
- loadStyle: loadStyle$LWS
15371
+ loadScript: (thisArg$LWS, url$LWS) => createRootWindowSandboxRecord$LWS({
15372
+ key: key$LWS
15373
+ }).helpers.loadScript(thisArg$LWS, url$LWS),
15374
+ loadStyle: (thisArg$LWS, url$LWS) => createRootWindowSandboxRecord$LWS({
15375
+ key: key$LWS
15376
+ }).helpers.loadStyle(thisArg$LWS, url$LWS)
15256
15377
  };
15257
15378
  depRegistry$LWS.set(dep$LWS, secureDep$LWS);
15258
15379
  return secureDep$LWS;
15259
15380
  }
15260
- /*! version: 0.19.4 */
15381
+ /*! version: 0.19.10 */
15261
15382
 
15262
15383
  const loaderDefine = globalThis.LWR.define;
15263
15384
 
@@ -15275,16 +15396,7 @@ function markLiveObject(object) {
15275
15396
  * Evaluate the given exporter in a sandbox of the given namespace
15276
15397
  */
15277
15398
  function vNextEvaluateModule(namespace, specifier, exporter) {
15278
- let out;
15279
-
15280
- // first, stringify the exporter, wrapping it with Locker context
15281
- // note: sourceMap does not work for now
15282
- const src = `"use strict";$lockerEvalContext$(${exporter.toString()});\n//# sourceURL=modules/${specifier}.js\n`;
15283
-
15284
- evaluateInSandbox$LWS(namespace, src, (def) => {
15285
- out = def;
15286
- });
15287
- return out;
15399
+ return evaluateFunction$LWS(namespace, exporter, undefined, '//# sourceURL=modules/${specifier}.js\n');
15288
15400
  }
15289
15401
 
15290
15402
  /**