@visactor/vtable 1.26.8 → 1.26.9-alpha.1

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.
Files changed (107) hide show
  1. package/cjs/body-helper/body-helper.js +1 -2
  2. package/cjs/components/index.js +2 -1
  3. package/cjs/components/menu/dom/logic/MenuElement.js +17 -17
  4. package/cjs/components/menu/dom/logic/MenuElement.js.map +1 -1
  5. package/cjs/components/menu/dom/logic/menu-icon.d.ts +1 -0
  6. package/cjs/components/menu/dom/logic/menu-icon.js +41 -0
  7. package/cjs/components/menu/dom/logic/menu-icon.js.map +1 -0
  8. package/cjs/core/BaseTable.js +2 -2
  9. package/cjs/core/BaseTable.js.map +1 -1
  10. package/cjs/core/tableHelper.js +1 -2
  11. package/cjs/data/DataSource.js +2 -1
  12. package/cjs/event/event.js +3 -3
  13. package/cjs/event/event.js.map +1 -1
  14. package/cjs/event/sparkline-event.js +2 -1
  15. package/cjs/header-helper/header-helper.js +1 -2
  16. package/cjs/layout/pivot-header-layout.js +2 -1
  17. package/cjs/layout/pivot-header-layout.js.map +1 -1
  18. package/cjs/plugins/custom-cell-style.d.ts +17 -2
  19. package/cjs/plugins/custom-cell-style.js +120 -30
  20. package/cjs/plugins/custom-cell-style.js.map +1 -1
  21. package/cjs/scenegraph/component/table-component.d.ts +2 -0
  22. package/cjs/scenegraph/component/table-component.js +22 -6
  23. package/cjs/scenegraph/component/table-component.js.map +1 -1
  24. package/cjs/scenegraph/group-creater/column-helper.js +1 -1
  25. package/cjs/scenegraph/group-creater/column-helper.js.map +1 -1
  26. package/cjs/scenegraph/layout/frozen.js +3 -0
  27. package/cjs/scenegraph/layout/frozen.js.map +1 -1
  28. package/cjs/scenegraph/scenegraph.d.ts +1 -0
  29. package/cjs/scenegraph/scenegraph.js +8 -1
  30. package/cjs/scenegraph/scenegraph.js.map +1 -1
  31. package/cjs/scenegraph/select/create-select-border.d.ts +1 -0
  32. package/cjs/scenegraph/select/create-select-border.js +8 -3
  33. package/cjs/scenegraph/select/create-select-border.js.map +1 -1
  34. package/cjs/scenegraph/select/delete-select-border.d.ts +2 -0
  35. package/cjs/scenegraph/select/delete-select-border.js +16 -5
  36. package/cjs/scenegraph/select/delete-select-border.js.map +1 -1
  37. package/cjs/scenegraph/select/move-select-border.js +2 -2
  38. package/cjs/scenegraph/select/move-select-border.js.map +1 -1
  39. package/cjs/state/select/auto-merge-ranges.d.ts +9 -0
  40. package/cjs/state/select/auto-merge-ranges.js +164 -0
  41. package/cjs/state/select/auto-merge-ranges.js.map +1 -0
  42. package/cjs/state/select/update-position.js +7 -3
  43. package/cjs/state/select/update-position.js.map +1 -1
  44. package/cjs/state/state.d.ts +3 -1
  45. package/cjs/state/state.js +18 -9
  46. package/cjs/state/state.js.map +1 -1
  47. package/cjs/themes/theme-define.js.map +1 -1
  48. package/cjs/ts-types/base-table.d.ts +1 -0
  49. package/cjs/ts-types/base-table.js.map +1 -1
  50. package/cjs/ts-types/menu.js.map +1 -1
  51. package/cjs/ts-types/theme.d.ts +1 -1
  52. package/cjs/ts-types/theme.js.map +1 -1
  53. package/dist/vtable.js +2410 -104
  54. package/dist/vtable.min.js +5 -1
  55. package/es/body-helper/body-helper.js +1 -2
  56. package/es/components/index.js +2 -1
  57. package/es/components/menu/dom/logic/MenuElement.js +16 -17
  58. package/es/components/menu/dom/logic/MenuElement.js.map +1 -1
  59. package/es/components/menu/dom/logic/menu-icon.d.ts +1 -0
  60. package/es/components/menu/dom/logic/menu-icon.js +29 -0
  61. package/es/components/menu/dom/logic/menu-icon.js.map +1 -0
  62. package/es/core/BaseTable.js +2 -2
  63. package/es/core/BaseTable.js.map +1 -1
  64. package/es/core/tableHelper.js +1 -2
  65. package/es/data/DataSource.js +2 -1
  66. package/es/event/event.js +4 -2
  67. package/es/event/event.js.map +1 -1
  68. package/es/event/sparkline-event.js +2 -1
  69. package/es/header-helper/header-helper.js +1 -2
  70. package/es/layout/pivot-header-layout.js +2 -1
  71. package/es/layout/pivot-header-layout.js.map +1 -1
  72. package/es/plugins/custom-cell-style.d.ts +17 -2
  73. package/es/plugins/custom-cell-style.js +120 -28
  74. package/es/plugins/custom-cell-style.js.map +1 -1
  75. package/es/scenegraph/component/table-component.d.ts +2 -0
  76. package/es/scenegraph/component/table-component.js +21 -6
  77. package/es/scenegraph/component/table-component.js.map +1 -1
  78. package/es/scenegraph/group-creater/column-helper.js +1 -1
  79. package/es/scenegraph/group-creater/column-helper.js.map +1 -1
  80. package/es/scenegraph/layout/frozen.js +3 -0
  81. package/es/scenegraph/layout/frozen.js.map +1 -1
  82. package/es/scenegraph/scenegraph.d.ts +1 -0
  83. package/es/scenegraph/scenegraph.js +9 -2
  84. package/es/scenegraph/scenegraph.js.map +1 -1
  85. package/es/scenegraph/select/create-select-border.d.ts +1 -0
  86. package/es/scenegraph/select/create-select-border.js +5 -1
  87. package/es/scenegraph/select/create-select-border.js.map +1 -1
  88. package/es/scenegraph/select/delete-select-border.d.ts +2 -0
  89. package/es/scenegraph/select/delete-select-border.js +9 -0
  90. package/es/scenegraph/select/delete-select-border.js.map +1 -1
  91. package/es/scenegraph/select/move-select-border.js +2 -2
  92. package/es/scenegraph/select/move-select-border.js.map +1 -1
  93. package/es/state/select/auto-merge-ranges.d.ts +9 -0
  94. package/es/state/select/auto-merge-ranges.js +155 -0
  95. package/es/state/select/auto-merge-ranges.js.map +1 -0
  96. package/es/state/select/update-position.js +7 -1
  97. package/es/state/select/update-position.js.map +1 -1
  98. package/es/state/state.d.ts +3 -1
  99. package/es/state/state.js +19 -8
  100. package/es/state/state.js.map +1 -1
  101. package/es/themes/theme-define.js.map +1 -1
  102. package/es/ts-types/base-table.d.ts +1 -0
  103. package/es/ts-types/base-table.js.map +1 -1
  104. package/es/ts-types/menu.js.map +1 -1
  105. package/es/ts-types/theme.d.ts +1 -1
  106. package/es/ts-types/theme.js.map +1 -1
  107. package/package.json +9 -4
package/dist/vtable.js CHANGED
@@ -13384,9 +13384,9 @@
13384
13384
  }
13385
13385
  }
13386
13386
 
13387
- let text, richText;
13387
+ let text$1, richText;
13388
13388
  function getTextBounds(params) {
13389
- return text || (text = createGraphic$1("text", {})), text.initAttributes(params), text.AABBBounds;
13389
+ return text$1 || (text$1 = createGraphic$1("text", {})), text$1.initAttributes(params), text$1.AABBBounds;
13390
13390
  }
13391
13391
  function getRichTextBounds(params) {
13392
13392
  return richText || (richText = createGraphic$1("richtext", {})), richText.setAttributes(params), richText.AABBBounds;
@@ -53641,14 +53641,14 @@
53641
53641
  * @param {*} value The value to convert.
53642
53642
  * @returns {string} Returns the converted string.
53643
53643
  */
53644
- function objectToString$1(value) {
53644
+ function objectToString$2(value) {
53645
53645
  return nativeObjectToString.call(value);
53646
53646
  }
53647
- var _objectToString = objectToString$1;
53647
+ var _objectToString = objectToString$2;
53648
53648
 
53649
53649
  var Symbol$2 = _Symbol,
53650
53650
  getRawTag = _getRawTag,
53651
- objectToString = _objectToString;
53651
+ objectToString$1 = _objectToString;
53652
53652
 
53653
53653
  /** `Object#toString` result references. */
53654
53654
  var nullTag = '[object Null]',
@@ -53668,7 +53668,7 @@
53668
53668
  if (value == null) {
53669
53669
  return value === undefined ? undefinedTag : nullTag;
53670
53670
  }
53671
- return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
53671
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString$1(value);
53672
53672
  }
53673
53673
  var _baseGetTag = baseGetTag$2;
53674
53674
 
@@ -54603,7 +54603,7 @@
54603
54603
 
54604
54604
  /** Used to convert symbols to primitives and strings. */
54605
54605
  var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
54606
- symbolToString = symbolProto ? symbolProto.toString : undefined;
54606
+ symbolToString$1 = symbolProto ? symbolProto.toString : undefined;
54607
54607
 
54608
54608
  /**
54609
54609
  * The base implementation of `_.toString` which doesn't convert nullish
@@ -54623,7 +54623,7 @@
54623
54623
  return arrayMap(value, baseToString$1) + '';
54624
54624
  }
54625
54625
  if (isSymbol$1(value)) {
54626
- return symbolToString ? symbolToString.call(value) : '';
54626
+ return symbolToString$1 ? symbolToString$1.call(value) : '';
54627
54627
  }
54628
54628
  var result = value + '';
54629
54629
  return result == '0' && 1 / value == -INFINITY$1 ? '-0' : result;
@@ -61979,6 +61979,10 @@
61979
61979
  this.table.stateManager.setFrozenColsScrollLeft(oldFrozenHorizontalBarPos, false);
61980
61980
  this.table.stateManager.setRightFrozenColsScrollLeft(oldRightFrozenHorizontalBarPos, false);
61981
61981
  this.table.stateManager.setScrollTop(oldVerticalBarPos);
61982
+ if (this.table.theme.frozenColumnLine?.shadow?.visible === 'overflow') {
61983
+ this.setFrozenColumnShadow(this.table.frozenColCount - 1);
61984
+ this.setRightFrozenColumnShadow(this.table.colCount - this.table.rightFrozenColCount);
61985
+ }
61982
61986
  }
61983
61987
  hideResizeCol() {
61984
61988
  this.columnResizeLine.setAttribute('visible', false);
@@ -62109,7 +62113,7 @@
62109
62113
  const colX = !isRightFrozen && col === this.table.frozenColCount - 1 && (this.table.getFrozenColsOffset?.() ?? 0) > 0
62110
62114
  ? this.table.getFrozenColsWidth()
62111
62115
  : getColX(col, this.table, isRightFrozen);
62112
- if (col < 0 || this.table.theme.frozenColumnLine?.shadow?.visible !== 'always') {
62116
+ if (col < 0 || !this.isFrozenColumnShadowVisible(false)) {
62113
62117
  this.frozenShadowLine.setAttributes({
62114
62118
  visible: false,
62115
62119
  x: colX,
@@ -62129,7 +62133,7 @@
62129
62133
  const colX = shouldFixViewport
62130
62134
  ? this.table.tableNoFrameWidth - this.table.getRightFrozenColsWidth()
62131
62135
  : getColX(col, this.table, true);
62132
- if (col >= this.table.colCount || this.table.theme.frozenColumnLine?.shadow?.visible !== 'always') {
62136
+ if (col >= this.table.colCount || !this.isFrozenColumnShadowVisible(true)) {
62133
62137
  this.rightFrozenShadowLine.setAttributes({
62134
62138
  visible: false,
62135
62139
  x: colX - this.rightFrozenShadowLine.attribute.width,
@@ -62144,6 +62148,29 @@
62144
62148
  });
62145
62149
  }
62146
62150
  }
62151
+ isFrozenColumnShadowVisible(right) {
62152
+ const visible = this.table.theme.frozenColumnLine?.shadow?.visible;
62153
+ if (visible !== 'overflow') {
62154
+ return visible === 'always';
62155
+ }
62156
+ const frozenCount = right ? this.table.rightFrozenColCount : this.table.frozenColCount;
62157
+ const sizeTolerance = this.table.options.customConfig?._disableColumnAndRowSizeRound ? 1 : 0;
62158
+ const scrollRange = Math.max(0, Math.ceil(getBodyHorizontalScrollRange(this.table) - sizeTolerance));
62159
+ return (frozenCount > 0 && scrollRange > 0 && (right ? this.table.scrollLeft < scrollRange : this.table.scrollLeft > 0));
62160
+ }
62161
+ updateFrozenColumnShadowVisibility() {
62162
+ if (this.table.theme.frozenColumnLine?.shadow?.visible !== 'overflow') {
62163
+ return;
62164
+ }
62165
+ const leftVisible = this.isFrozenColumnShadowVisible(false);
62166
+ const rightVisible = this.isFrozenColumnShadowVisible(true);
62167
+ if (this.frozenShadowLine.attribute.visible !== leftVisible) {
62168
+ this.frozenShadowLine.setAttribute('visible', leftVisible);
62169
+ }
62170
+ if (this.rightFrozenShadowLine.attribute.visible !== rightVisible) {
62171
+ this.rightFrozenShadowLine.setAttribute('visible', rightVisible);
62172
+ }
62173
+ }
62147
62174
  hideFrozenColumnShadow() {
62148
62175
  const visible1 = this.table.theme.frozenColumnLine?.shadow?.visible;
62149
62176
  const visible = this.table.theme.frozenColumnLine?.shadow?.visible ?? visible1;
@@ -63366,8 +63393,8 @@
63366
63393
  else if (columnGroup.colHeight) {
63367
63394
  y = columnGroup.colHeight;
63368
63395
  }
63369
- else if (rowStart >= table.columnHeaderLevelCount && rowStart < table.rowCount - table.bottomFrozenRowCount) {
63370
- y = table.getRowsHeight(table.columnHeaderLevelCount, rowStart - 1);
63396
+ else if (rowStart >= table.frozenRowCount && rowStart < table.rowCount - table.bottomFrozenRowCount) {
63397
+ y = table.scenegraph.getCellGroupY(rowStart);
63371
63398
  }
63372
63399
  for (let j = rowStart; j <= rowEnd; j++) {
63373
63400
  const row = j;
@@ -65806,6 +65833,9 @@
65806
65833
  });
65807
65834
  }
65808
65835
 
65836
+ function getCellSelectBorderKey(startCol, startRow, endCol, endRow, selectId = `${startCol}${startRow}${endCol}${endRow}`) {
65837
+ return `${startCol}-${startRow}-${endCol}-${endRow}-${selectId}`;
65838
+ }
65809
65839
  function createCellSelectBorder(scene, start_Col, start_Row, end_Col, end_Row, selectRangeType, selectId, strokes) {
65810
65840
  let isHasFillHandleRect = !!scene.table.options.excelOptions?.fillHandle;
65811
65841
  if (scene.table.stateManager.select.ranges?.length > 1) {
@@ -65867,7 +65897,7 @@
65867
65897
  });
65868
65898
  }
65869
65899
  scene.lastSelectId = selectId;
65870
- scene.selectingRangeComponents.set(`${startCol}-${startRow}-${endCol}-${endRow}-${selectId}`, {
65900
+ scene.selectingRangeComponents.set(getCellSelectBorderKey(startCol, startRow, endCol, endRow, selectId), {
65871
65901
  rect,
65872
65902
  fillhandle,
65873
65903
  role: selectRangeType
@@ -65914,9 +65944,10 @@
65914
65944
 
65915
65945
  function moveSelectingRangeComponentsToSelectedRangeComponents(scene) {
65916
65946
  scene.selectingRangeComponents.forEach((rangeComponent, key) => {
65917
- if (scene.selectedRangeComponents.get(key)) {
65918
- scene.selectingRangeComponents.get(key).rect.delete();
65919
- scene.selectingRangeComponents.get(key).fillhandle?.delete();
65947
+ const previous = scene.selectedRangeComponents.get(key);
65948
+ if (previous) {
65949
+ previous.rect.delete();
65950
+ previous.fillhandle?.delete();
65920
65951
  }
65921
65952
  scene.selectedRangeComponents.set(key, rangeComponent);
65922
65953
  });
@@ -65924,6 +65955,13 @@
65924
65955
  scene.updateNextFrame();
65925
65956
  }
65926
65957
 
65958
+ function deleteSelectedBodyRangeComponent(scene, range) {
65959
+ const key = getCellSelectBorderKey(Math.min(range.start.col, range.end.col), Math.min(range.start.row, range.end.row), Math.max(range.start.col, range.end.col), Math.max(range.start.row, range.end.row));
65960
+ const component = scene.selectedRangeComponents.get(key);
65961
+ component?.rect.delete();
65962
+ component?.fillhandle?.delete();
65963
+ scene.selectedRangeComponents.delete(key);
65964
+ }
65927
65965
  function deleteLastSelectedRangeComponents(scene) {
65928
65966
  scene.selectedRangeComponents.forEach((selectComp, key) => {
65929
65967
  const lastSelectId = key.split('-')[4];
@@ -66897,6 +66935,9 @@
66897
66935
  if (distBottomFrozenRow > currentBottomFrozenRow) {
66898
66936
  for (let col = 0; col < table.frozenColCount; col++) {
66899
66937
  const bottomFrozenColumnGroup = scene.getColGroupInLeftBottomCorner(col);
66938
+ if (!bottomFrozenColumnGroup) {
66939
+ continue;
66940
+ }
66900
66941
  for (let row = table.rowCount - currentBottomFrozenRow - 1; row >= table.rowCount - distBottomFrozenRow; row--) {
66901
66942
  const cellGroup = scene.getCell(col, row, true);
66902
66943
  insertBefore(bottomFrozenColumnGroup, cellGroup, bottomFrozenColumnGroup.firstChild);
@@ -66909,6 +66950,9 @@
66909
66950
  }
66910
66951
  for (let col = proxy.colStart; col <= proxy.colEnd; col++) {
66911
66952
  const bottomFrozenColumnGroup = scene.getColGroupInBottom(col);
66953
+ if (!bottomFrozenColumnGroup) {
66954
+ continue;
66955
+ }
66912
66956
  for (let row = table.rowCount - currentBottomFrozenRow - 1; row >= table.rowCount - distBottomFrozenRow; row--) {
66913
66957
  const cellGroup = scene.getCell(col, row, true);
66914
66958
  insertBefore(bottomFrozenColumnGroup, cellGroup, bottomFrozenColumnGroup.firstChild);
@@ -66922,6 +66966,9 @@
66922
66966
  if (table.rightFrozenColCount > 0) {
66923
66967
  for (let col = table.colCount - table.rightFrozenColCount; col < table.colCount; col++) {
66924
66968
  const bottomFrozenColumnGroup = scene.getColGroupInRightBottomCorner(col);
66969
+ if (!bottomFrozenColumnGroup) {
66970
+ continue;
66971
+ }
66925
66972
  for (let row = table.rowCount - currentBottomFrozenRow - 1; row >= table.rowCount - distBottomFrozenRow; row--) {
66926
66973
  const cellGroup = scene.getCell(col, row, true);
66927
66974
  insertBefore(bottomFrozenColumnGroup, cellGroup, bottomFrozenColumnGroup.firstChild);
@@ -68957,6 +69004,27 @@
68957
69004
  moveSelectingRangeComponentsToSelectedRangeComponents(this);
68958
69005
  });
68959
69006
  }
69007
+ updateMergedBodySelectRangeComponents(previousRanges) {
69008
+ const ranges = this.table.stateManager.select.ranges;
69009
+ const current = new Set(ranges);
69010
+ const previous = new Set(previousRanges);
69011
+ const lastSelectId = this.lastSelectId;
69012
+ const lastUnchanged = ranges[ranges.length - 1] === previousRanges[previousRanges.length - 1];
69013
+ for (const range of previousRanges) {
69014
+ if (!current.has(range)) {
69015
+ deleteSelectedBodyRangeComponent(this, range);
69016
+ }
69017
+ }
69018
+ for (const range of ranges) {
69019
+ if (!previous.has(range)) {
69020
+ this.updateCellSelectBorder(range);
69021
+ this.moveSelectingRangeComponentsToSelectedRangeComponents();
69022
+ }
69023
+ }
69024
+ if (lastUnchanged) {
69025
+ this.lastSelectId = lastSelectId;
69026
+ }
69027
+ }
68960
69028
  updateColWidth(col, detaX, skipUpdateContainer, skipTableWidthMap, pendingCornerCustomMergeRanges) {
68961
69029
  updateColWidth(this, col, Math.round(detaX), skipTableWidthMap, pendingCornerCustomMergeRanges);
68962
69030
  if (!skipUpdateContainer) {
@@ -70275,7 +70343,7 @@
70275
70343
  return this.table.getRowsHeight(0, row - 1);
70276
70344
  }
70277
70345
  else if (row < this.table.rowCount - this.table.bottomFrozenRowCount) {
70278
- return this.table.getRowsHeight(this.table.columnHeaderLevelCount, row - 1);
70346
+ return this.table.getRowsHeight(this.table.frozenRowCount, row - 1);
70279
70347
  }
70280
70348
  else if (row < this.table.rowCount) {
70281
70349
  return this.table.getRowsHeight(this.table.rowCount - this.table.bottomFrozenRowCount, row - 1);
@@ -70593,10 +70661,227 @@
70593
70661
  return table._getLayoutCellId(col, row) === table._getLayoutCellId(range1Col, range1Row);
70594
70662
  }
70595
70663
 
70664
+ const headerSelectRanges = new WeakSet();
70665
+ const mergedRangeAnchors = new WeakMap();
70666
+ function markHeaderSelectRange(range) {
70667
+ headerSelectRanges.add(range);
70668
+ mergedRangeAnchors.delete(range);
70669
+ }
70670
+ function restoreMergedRangeAnchor(range) {
70671
+ const anchor = mergedRangeAnchors.get(range);
70672
+ if (anchor) {
70673
+ range.start = { ...anchor };
70674
+ mergedRangeAnchors.delete(range);
70675
+ }
70676
+ }
70677
+ function autoMergeCellRanges(ranges, table) {
70678
+ if (!table.options.select?.autoMergeRanges || ranges.length < 2) {
70679
+ return ranges;
70680
+ }
70681
+ const indexedRanges = ranges.map((range, index) => ({
70682
+ index,
70683
+ range,
70684
+ normalizedRange: normalizeRange(range),
70685
+ visited: false
70686
+ }));
70687
+ const eligibleRanges = indexedRanges.filter(range => !headerSelectRanges.has(range.range) && isMainBodyRange(range.normalizedRange, table));
70688
+ if (eligibleRanges.length < 2) {
70689
+ return ranges;
70690
+ }
70691
+ const tree = buildRangeTree(eligibleRanges);
70692
+ const mergedComponents = new Map();
70693
+ const removedIndexes = new Set();
70694
+ for (let i = 0; i < eligibleRanges.length; i++) {
70695
+ const componentSeed = eligibleRanges[i];
70696
+ if (componentSeed.visited) {
70697
+ continue;
70698
+ }
70699
+ const component = [];
70700
+ collectConnectedRanges(tree, componentSeed.normalizedRange, component);
70701
+ for (let cursor = 0; cursor < component.length; cursor++) {
70702
+ collectConnectedRanges(tree, component[cursor].normalizedRange, component);
70703
+ }
70704
+ if (component.length < 2) {
70705
+ continue;
70706
+ }
70707
+ const boundingRange = getBoundingRange(component);
70708
+ const boundingArea = getRangeArea(boundingRange);
70709
+ const unionArea = getUnionArea(component.map(item => item.normalizedRange));
70710
+ if (unionArea !== boundingArea) {
70711
+ continue;
70712
+ }
70713
+ const componentIndexes = component.map(item => item.index).sort((a, b) => a - b);
70714
+ const targetIndex = componentIndexes[componentIndexes.length - 1];
70715
+ const mergedRange = {
70716
+ start: { ...boundingRange.start },
70717
+ end: { ...boundingRange.end },
70718
+ ...(component.every(item => item.range.skipBodyMerge) ? { skipBodyMerge: true } : {})
70719
+ };
70720
+ const lastRange = ranges[targetIndex];
70721
+ mergedRangeAnchors.set(mergedRange, { ...(mergedRangeAnchors.get(lastRange) ?? lastRange.start) });
70722
+ mergedComponents.set(targetIndex, mergedRange);
70723
+ componentIndexes
70724
+ .filter(index => index !== targetIndex)
70725
+ .forEach(index => {
70726
+ removedIndexes.add(index);
70727
+ });
70728
+ }
70729
+ if (!mergedComponents.size) {
70730
+ return ranges;
70731
+ }
70732
+ return ranges.reduce((result, range, index) => {
70733
+ if (removedIndexes.has(index)) {
70734
+ return result;
70735
+ }
70736
+ result.push(mergedComponents.get(index) ?? range);
70737
+ return result;
70738
+ }, []);
70739
+ }
70740
+ function buildRangeTree(ranges, depth = 0) {
70741
+ if (ranges.length === 1) {
70742
+ return { bounds: ranges[0].normalizedRange, item: ranges[0], empty: false };
70743
+ }
70744
+ const axis = depth % 2 ? 'row' : 'col';
70745
+ ranges.sort((left, right) => left.normalizedRange.start[axis] - right.normalizedRange.start[axis]);
70746
+ const middle = Math.floor(ranges.length / 2);
70747
+ const left = buildRangeTree(ranges.slice(0, middle), depth + 1);
70748
+ const right = buildRangeTree(ranges.slice(middle), depth + 1);
70749
+ return {
70750
+ left,
70751
+ right,
70752
+ empty: false,
70753
+ bounds: {
70754
+ start: {
70755
+ col: Math.min(left.bounds.start.col, right.bounds.start.col),
70756
+ row: Math.min(left.bounds.start.row, right.bounds.start.row)
70757
+ },
70758
+ end: {
70759
+ col: Math.max(left.bounds.end.col, right.bounds.end.col),
70760
+ row: Math.max(left.bounds.end.row, right.bounds.end.row)
70761
+ }
70762
+ }
70763
+ };
70764
+ }
70765
+ function collectConnectedRanges(node, range, result) {
70766
+ if (node.empty || !isConnectedRange(node.bounds, range)) {
70767
+ return;
70768
+ }
70769
+ if ('item' in node) {
70770
+ node.empty = true;
70771
+ node.item.visited = true;
70772
+ result.push(node.item);
70773
+ return;
70774
+ }
70775
+ collectConnectedRanges(node.left, range, result);
70776
+ collectConnectedRanges(node.right, range, result);
70777
+ node.empty = node.left.empty && node.right.empty;
70778
+ }
70779
+ function normalizeRange(range) {
70780
+ return {
70781
+ start: {
70782
+ col: Math.min(range.start.col, range.end.col),
70783
+ row: Math.min(range.start.row, range.end.row)
70784
+ },
70785
+ end: {
70786
+ col: Math.max(range.start.col, range.end.col),
70787
+ row: Math.max(range.start.row, range.end.row)
70788
+ }
70789
+ };
70790
+ }
70791
+ function isMainBodyRange(range, table) {
70792
+ const startCol = Math.max(table.rowHeaderLevelCount + table.leftRowSeriesNumberCount, table.frozenColCount);
70793
+ const startRow = Math.max(table.columnHeaderLevelCount, table.frozenRowCount);
70794
+ const endCol = table.colCount - table.rightFrozenColCount - 1;
70795
+ const endRow = table.rowCount - table.bottomFrozenRowCount - 1;
70796
+ if (startCol > endCol || startRow > endRow) {
70797
+ return false;
70798
+ }
70799
+ return (range.start.col >= startCol &&
70800
+ range.end.col <= endCol &&
70801
+ range.start.row >= startRow &&
70802
+ range.end.row <= endRow &&
70803
+ table.getCellLocation(range.start.col, range.start.row) === 'body' &&
70804
+ table.getCellLocation(range.end.col, range.end.row) === 'body');
70805
+ }
70806
+ function isConnectedRange(left, right) {
70807
+ const rowOverlap = left.start.row <= right.end.row && right.start.row <= left.end.row;
70808
+ const colOverlap = left.start.col <= right.end.col && right.start.col <= left.end.col;
70809
+ if (rowOverlap && colOverlap) {
70810
+ return true;
70811
+ }
70812
+ const horizontalTouch = rowOverlap && (left.end.col + 1 === right.start.col || right.end.col + 1 === left.start.col);
70813
+ if (horizontalTouch) {
70814
+ return true;
70815
+ }
70816
+ return colOverlap && (left.end.row + 1 === right.start.row || right.end.row + 1 === left.start.row);
70817
+ }
70818
+ function getBoundingRange(ranges) {
70819
+ return ranges.reduce((boundingRange, item) => ({
70820
+ start: {
70821
+ col: Math.min(boundingRange.start.col, item.normalizedRange.start.col),
70822
+ row: Math.min(boundingRange.start.row, item.normalizedRange.start.row)
70823
+ },
70824
+ end: {
70825
+ col: Math.max(boundingRange.end.col, item.normalizedRange.end.col),
70826
+ row: Math.max(boundingRange.end.row, item.normalizedRange.end.row)
70827
+ }
70828
+ }), {
70829
+ start: { ...ranges[0].normalizedRange.start },
70830
+ end: { ...ranges[0].normalizedRange.end }
70831
+ });
70832
+ }
70833
+ function getRangeArea(range) {
70834
+ return (range.end.col - range.start.col + 1) * (range.end.row - range.start.row + 1);
70835
+ }
70836
+ function getUnionArea(ranges) {
70837
+ const rows = Array.from(new Set(ranges.flatMap(range => [range.start.row, range.end.row + 1]))).sort((a, b) => a - b);
70838
+ const rowIndexes = new Map(rows.map((row, index) => [row, index]));
70839
+ const events = ranges
70840
+ .flatMap(range => {
70841
+ const start = rowIndexes.get(range.start.row);
70842
+ const end = rowIndexes.get(range.end.row + 1);
70843
+ return [
70844
+ { col: range.start.col, start, end, delta: 1 },
70845
+ { col: range.end.col + 1, start, end, delta: -1 }
70846
+ ];
70847
+ })
70848
+ .sort((a, b) => a.col - b.col);
70849
+ const covers = new Int32Array(rows.length * 4);
70850
+ const lengths = new Float64Array(rows.length * 4);
70851
+ function update(node, left, right, start, end, delta) {
70852
+ if (start <= left && right <= end) {
70853
+ covers[node] += delta;
70854
+ }
70855
+ else {
70856
+ const middle = Math.floor((left + right) / 2);
70857
+ if (start < middle) {
70858
+ update(node * 2, left, middle, start, end, delta);
70859
+ }
70860
+ if (end > middle) {
70861
+ update(node * 2 + 1, middle, right, start, end, delta);
70862
+ }
70863
+ }
70864
+ lengths[node] = covers[node]
70865
+ ? rows[right] - rows[left]
70866
+ : right - left === 1
70867
+ ? 0
70868
+ : lengths[node * 2] + lengths[node * 2 + 1];
70869
+ }
70870
+ let area = 0;
70871
+ let previous = events[0].col;
70872
+ for (const event of events) {
70873
+ area += (event.col - previous) * lengths[1];
70874
+ update(1, 0, rows.length - 1, event.start, event.end, event.delta);
70875
+ previous = event.col;
70876
+ }
70877
+ return area;
70878
+ }
70879
+
70596
70880
  function updateSelectPosition(state, col, row, enableShiftSelectMode, enableCtrlSelectMode, isSelectAll, makeSelectCellVisible = true, skipBodyMerge = false) {
70597
70881
  const { table, interactionState } = state;
70598
70882
  const { scenegraph } = table;
70599
70883
  const { cellPos } = state.select;
70884
+ let selectedRange;
70600
70885
  state.select.isSelectAll = isSelectAll;
70601
70886
  if (col !== -1 && row !== -1 && makeSelectCellVisible) {
70602
70887
  table._makeVisibleCell(col, row);
@@ -70696,6 +70981,7 @@
70696
70981
  }
70697
70982
  }
70698
70983
  else {
70984
+ restoreMergedRangeAnchor(currentRange);
70699
70985
  currentRange.end = { col, row };
70700
70986
  }
70701
70987
  if (!enableShiftSelectMode) {
@@ -70872,6 +71158,7 @@
70872
71158
  scenegraph.updateCellSelectBorder(currentRange, extendSelectRange);
70873
71159
  }
70874
71160
  }
71161
+ selectedRange = state.select.ranges[state.select.ranges.length - 1];
70875
71162
  }
70876
71163
  else if ((interactionState === InteractionState.grabing || table.eventManager.isDraging) &&
70877
71164
  !table.stateManager.isResizeCol()) {
@@ -71019,6 +71306,10 @@
71019
71306
  scenegraph.updateCellSelectBorder(currentRange, extendSelectRange);
71020
71307
  }
71021
71308
  }
71309
+ selectedRange = currentRange;
71310
+ }
71311
+ if (selectedRange && (table.isHeader(col, row) || table.isSeriesNumber(col, row))) {
71312
+ markHeaderSelectRange(selectedRange);
71022
71313
  }
71023
71314
  scenegraph.updateNextFrame();
71024
71315
  }
@@ -72880,6 +73171,7 @@
72880
73171
  _clearVerticalScrollBar;
72881
73172
  _clearHorizontalScrollBar;
72882
73173
  _frozenObserver;
73174
+ _frozenObserverCheckTimer;
72883
73175
  fastScrolling = false;
72884
73176
  checkedState = new Map();
72885
73177
  headerCheckedState = {};
@@ -73318,7 +73610,7 @@
73318
73610
  isSelecting() {
73319
73611
  return this.select.selecting;
73320
73612
  }
73321
- endSelectCells(fireListener = true, fireClear = true) {
73613
+ endSelectCells(fireListener = true, fireClear = true, mergeRanges = true) {
73322
73614
  if (this.select.selecting) {
73323
73615
  this.select.selecting = false;
73324
73616
  if (this.select.ranges.length === 0) {
@@ -73350,8 +73642,15 @@
73350
73642
  else {
73351
73643
  selectEnd(this.table.scenegraph);
73352
73644
  }
73353
- const lastCol = this.select.ranges[this.select.ranges.length - 1].end.col;
73354
- const lastRow = this.select.ranges[this.select.ranges.length - 1].end.row;
73645
+ const { col: lastCol, row: lastRow } = this.select.ranges[this.select.ranges.length - 1].end;
73646
+ if (mergeRanges) {
73647
+ const previousRanges = this.select.ranges;
73648
+ const mergedRanges = autoMergeCellRanges(previousRanges, this.table);
73649
+ if (mergedRanges !== previousRanges) {
73650
+ this.select.ranges = mergedRanges;
73651
+ this.table.scenegraph.updateMergedBodySelectRangeComponents(previousRanges);
73652
+ }
73653
+ }
73355
73654
  fireListener &&
73356
73655
  this.table.fireListeners(TABLE_EVENT_TYPE.SELECTED_CELL, {
73357
73656
  ranges: this.select.ranges,
@@ -73461,12 +73760,18 @@
73461
73760
  return;
73462
73761
  }
73463
73762
  this._frozenObserver = new ResizeObserver(entries => {
73763
+ if (this.table.isReleased) {
73764
+ return;
73765
+ }
73464
73766
  for (const entry of entries) {
73465
73767
  if (entry.contentRect.width > 0) {
73466
73768
  this.clearFrozenObserver();
73467
73769
  this.table.resize();
73468
- setTimeout(() => {
73469
- this.checkFrozen();
73770
+ this._frozenObserverCheckTimer = setTimeout(() => {
73771
+ this._frozenObserverCheckTimer = undefined;
73772
+ if (!this.table.isReleased) {
73773
+ this.checkFrozen();
73774
+ }
73470
73775
  }, 0);
73471
73776
  return;
73472
73777
  }
@@ -73567,6 +73872,11 @@
73567
73872
  this._frozenObserver = null;
73568
73873
  }
73569
73874
  }
73875
+ release() {
73876
+ this.clearFrozenObserver();
73877
+ clearTimeout(this._frozenObserverCheckTimer);
73878
+ this._frozenObserverCheckTimer = undefined;
73879
+ }
73570
73880
  setFrozenCol(col) {
73571
73881
  if (col !== this.frozen.col) {
73572
73882
  this.frozen.col = col;
@@ -73688,6 +73998,7 @@
73688
73998
  this.table.scenegraph.setX(-this.scroll.horizontalBarPos, xRatio === 1);
73689
73999
  this.scroll.horizontalBarPos -= this.table.scenegraph.proxy.deltaX;
73690
74000
  this.table.scenegraph.proxy.deltaX = 0;
74001
+ this.table.scenegraph.component.updateFrozenColumnShadowVisibility();
73691
74002
  this.updateHoverPos(-1, -1);
73692
74003
  this.table.fireListeners(TABLE_EVENT_TYPE.SCROLL, {
73693
74004
  event: undefined,
@@ -73811,6 +74122,7 @@
73811
74122
  }
73812
74123
  this.table.scenegraph.setX(-left);
73813
74124
  this.table.scenegraph.component.updateHorizontalScrollBarPos(xRatio);
74125
+ this.table.scenegraph.component.updateFrozenColumnShadowVisibility();
73814
74126
  const dx = this.scroll.horizontalBarPos - oldHorizontalBarPos;
73815
74127
  this.table.fireListeners(TABLE_EVENT_TYPE.SCROLL, {
73816
74128
  event: event?.nativeEvent,
@@ -77378,6 +77690,7 @@
77378
77690
  });
77379
77691
  }
77380
77692
 
77693
+ const FILL_HANDLE_HIT_TARGET_SIZE = 24;
77381
77694
  class EventManager {
77382
77695
  table;
77383
77696
  isTouchdown;
@@ -77707,9 +78020,8 @@
77707
78020
  lastCellBoundTargetY = lastCellBound.y2;
77708
78021
  }
77709
78022
  const distanceY = Math.abs(eventArgsSet.abstractPos.y - lastCellBoundTargetY);
77710
- const squareSize = 6 * 3;
77711
78023
  if (this.table.stateManager.fillHandle?.isFilling ||
77712
- (distanceX <= squareSize / 2 && distanceY <= squareSize / 2)) {
78024
+ (distanceX <= FILL_HANDLE_HIT_TARGET_SIZE / 2 && distanceY <= FILL_HANDLE_HIT_TARGET_SIZE / 2)) {
77713
78025
  if (update) {
77714
78026
  this.table.stateManager.startFillSelect(eventArgsSet.abstractPos.x, eventArgsSet.abstractPos.y);
77715
78027
  }
@@ -79436,6 +79748,1903 @@
79436
79748
  document.head.appendChild(styleElement);
79437
79749
  }
79438
79750
 
79751
+ /*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */
79752
+ function _arrayLikeToArray(r, a) {
79753
+ (null == a || a > r.length) && (a = r.length);
79754
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
79755
+ return n;
79756
+ }
79757
+ function _arrayWithHoles(r) {
79758
+ if (Array.isArray(r)) return r;
79759
+ }
79760
+ function _iterableToArrayLimit(r, l) {
79761
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
79762
+ if (null != t) {
79763
+ var e,
79764
+ n,
79765
+ i,
79766
+ u,
79767
+ a = [],
79768
+ f = !0,
79769
+ o = !1;
79770
+ try {
79771
+ if (i = (t = t.call(r)).next, 0 === l) {
79772
+ if (Object(t) !== t) return;
79773
+ f = !1;
79774
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
79775
+ } catch (r) {
79776
+ o = !0, n = r;
79777
+ } finally {
79778
+ try {
79779
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
79780
+ } finally {
79781
+ if (o) throw n;
79782
+ }
79783
+ }
79784
+ return a;
79785
+ }
79786
+ }
79787
+ function _nonIterableRest() {
79788
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
79789
+ }
79790
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
79791
+ function _slicedToArray(r, e) {
79792
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
79793
+ }
79794
+ function _unsupportedIterableToArray(r, a) {
79795
+ if (r) {
79796
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
79797
+ var t = {}.toString.call(r).slice(8, -1);
79798
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
79799
+ }
79800
+ }
79801
+ const entries = Object.entries;
79802
+ const setPrototypeOf = Object.setPrototypeOf;
79803
+ const isFrozen = Object.isFrozen;
79804
+ const getPrototypeOf = Object.getPrototypeOf;
79805
+ const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
79806
+ let freeze = Object.freeze;
79807
+ let seal = Object.seal;
79808
+ let create = Object.create;
79809
+ let _ref = typeof Reflect !== "undefined" && Reflect;
79810
+ let apply = _ref.apply;
79811
+ let construct = _ref.construct;
79812
+ if (!freeze) freeze = function freeze(x) {
79813
+ return x;
79814
+ };
79815
+ if (!seal) seal = function seal(x) {
79816
+ return x;
79817
+ };
79818
+ if (!apply) apply = function apply(func, thisArg) {
79819
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
79820
+ return func.apply(thisArg, args);
79821
+ };
79822
+ if (!construct) construct = function construct(Func) {
79823
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) args[_key2 - 1] = arguments[_key2];
79824
+ return new Func(...args);
79825
+ };
79826
+ const arrayForEach = unapply(Array.prototype.forEach);
79827
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
79828
+ const arrayPop = unapply(Array.prototype.pop);
79829
+ const arrayPush = unapply(Array.prototype.push);
79830
+ const arraySlice = unapply(Array.prototype.slice);
79831
+ const arraySplice = unapply(Array.prototype.splice);
79832
+ const arrayIsArray = Array.isArray;
79833
+ const setCreate = unconstruct(Set);
79834
+ const setAdd = unapply(Set.prototype.add);
79835
+ const setHas = unapply(Set.prototype.has);
79836
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
79837
+ const stringToString = unapply(String.prototype.toString);
79838
+ const stringMatch = unapply(String.prototype.match);
79839
+ const stringReplace = unapply(String.prototype.replace);
79840
+ const stringIndexOf = unapply(String.prototype.indexOf);
79841
+ const stringTrim = unapply(String.prototype.trim);
79842
+ const numberToString = unapply(Number.prototype.toString);
79843
+ const booleanToString = unapply(Boolean.prototype.toString);
79844
+ const bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
79845
+ const symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
79846
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
79847
+ const objectToString = unapply(Object.prototype.toString);
79848
+ const regExpTest = unapply(RegExp.prototype.test);
79849
+ const typeErrorCreate = unconstruct(TypeError);
79850
+ /**
79851
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
79852
+ *
79853
+ * @param func - The function to be wrapped and called.
79854
+ * @returns A new function that calls the given function with a specified thisArg and arguments.
79855
+ */
79856
+ function unapply(func) {
79857
+ return function (thisArg) {
79858
+ if (thisArg instanceof RegExp) thisArg.lastIndex = 0;
79859
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) args[_key3 - 1] = arguments[_key3];
79860
+ return apply(func, thisArg, args);
79861
+ };
79862
+ }
79863
+ /**
79864
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
79865
+ *
79866
+ * @param func - The constructor function to be wrapped and called.
79867
+ * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
79868
+ */
79869
+ function unconstruct(Func) {
79870
+ return function () {
79871
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) args[_key4] = arguments[_key4];
79872
+ return construct(Func, args);
79873
+ };
79874
+ }
79875
+ /**
79876
+ * Add properties to a lookup table
79877
+ *
79878
+ * @param set - The set to which elements will be added.
79879
+ * @param array - The array containing elements to be added to the set.
79880
+ * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
79881
+ * @returns The modified set with added elements.
79882
+ */
79883
+ function addToSet(set, array) {
79884
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
79885
+ if (setPrototypeOf) setPrototypeOf(set, null);
79886
+ if (!arrayIsArray(array)) return set;
79887
+ let l = array.length;
79888
+ while (l--) {
79889
+ let element = array[l];
79890
+ if (typeof element === "string") {
79891
+ const lcElement = transformCaseFunc(element);
79892
+ if (lcElement !== element) {
79893
+ if (!isFrozen(array)) array[l] = lcElement;
79894
+ element = lcElement;
79895
+ }
79896
+ }
79897
+ set[element] = true;
79898
+ }
79899
+ return set;
79900
+ }
79901
+ /**
79902
+ * Clean up an array to harden against CSPP
79903
+ *
79904
+ * @param array - The array to be cleaned.
79905
+ * @returns The cleaned version of the array
79906
+ */
79907
+ function cleanArray(array) {
79908
+ for (let index = 0; index < array.length; index++) if (!objectHasOwnProperty(array, index)) array[index] = null;
79909
+ return array;
79910
+ }
79911
+ /**
79912
+ * Shallow clone an object
79913
+ *
79914
+ * @param object - The object to be cloned.
79915
+ * @returns A new object that copies the original.
79916
+ */
79917
+ function clone(object) {
79918
+ const newObject = create(null);
79919
+ for (const _ref2 of entries(object)) {
79920
+ var _ref3 = _slicedToArray(_ref2, 2);
79921
+ const property = _ref3[0];
79922
+ const value = _ref3[1];
79923
+ if (objectHasOwnProperty(object, property)) {
79924
+ if (arrayIsArray(value)) newObject[property] = cleanArray(value);else if (value && typeof value === "object" && value.constructor === Object) newObject[property] = clone(value);else newObject[property] = value;
79925
+ }
79926
+ }
79927
+ return newObject;
79928
+ }
79929
+ /**
79930
+ * Convert non-node values into strings without depending on direct property access.
79931
+ *
79932
+ * @param value - The value to stringify.
79933
+ * @returns A string representation of the provided value.
79934
+ */
79935
+ function stringifyValue(value) {
79936
+ switch (typeof value) {
79937
+ case "string":
79938
+ return value;
79939
+ case "number":
79940
+ return numberToString(value);
79941
+ case "boolean":
79942
+ return booleanToString(value);
79943
+ case "bigint":
79944
+ return bigintToString ? bigintToString(value) : "0";
79945
+ case "symbol":
79946
+ return symbolToString ? symbolToString(value) : "Symbol()";
79947
+ case "undefined":
79948
+ return objectToString(value);
79949
+ case "function":
79950
+ case "object":
79951
+ {
79952
+ if (value === null) return objectToString(value);
79953
+ const valueAsRecord = value;
79954
+ const valueToString = lookupGetter(valueAsRecord, "toString");
79955
+ if (typeof valueToString === "function") {
79956
+ const stringified = valueToString(valueAsRecord);
79957
+ return typeof stringified === "string" ? stringified : objectToString(stringified);
79958
+ }
79959
+ return objectToString(value);
79960
+ }
79961
+ default:
79962
+ return objectToString(value);
79963
+ }
79964
+ }
79965
+ /**
79966
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
79967
+ *
79968
+ * @param object - The object to look up the getter function in its prototype chain.
79969
+ * @param prop - The property name for which to find the getter function.
79970
+ * @returns The getter function found in the prototype chain or a fallback function.
79971
+ */
79972
+ function lookupGetter(object, prop) {
79973
+ while (object !== null) {
79974
+ const desc = getOwnPropertyDescriptor(object, prop);
79975
+ if (desc) {
79976
+ if (desc.get) return unapply(desc.get);
79977
+ if (typeof desc.value === "function") return unapply(desc.value);
79978
+ }
79979
+ object = getPrototypeOf(object);
79980
+ }
79981
+ function fallbackValue() {
79982
+ return null;
79983
+ }
79984
+ return fallbackValue;
79985
+ }
79986
+ /**
79987
+ * Like lookupGetter, but for accessor properties only, and returns null
79988
+ * instead of a null-returning fallback when no getter exists on the chain.
79989
+ * Lets a caller fall back to a direct property read in environments that
79990
+ * lack the getter, where a fallback returning null would be indistinguishable
79991
+ * from a legitimate null value (e.g. namespaceURI of a no-namespace element).
79992
+ *
79993
+ * @param object - The object (usually a prototype) to start the lookup at.
79994
+ * @param prop - The accessor property name.
79995
+ * @returns The unapplied getter, or null if none was found.
79996
+ */
79997
+ function lookupAccessor(object, prop) {
79998
+ while (object !== null) {
79999
+ const desc = getOwnPropertyDescriptor(object, prop);
80000
+ if (desc) return desc.get ? unapply(desc.get) : null;
80001
+ object = getPrototypeOf(object);
80002
+ }
80003
+ return null;
80004
+ }
80005
+ function isRegex(value) {
80006
+ try {
80007
+ regExpTest(value, "");
80008
+ return true;
80009
+ } catch (_unused) {
80010
+ return false;
80011
+ }
80012
+ }
80013
+ const html$1 = freeze(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]);
80014
+ const svg$1 = freeze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]);
80015
+ const svgFilters = freeze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]);
80016
+ const svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]);
80017
+ const mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]);
80018
+ const mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
80019
+ const text = freeze(["#text"]);
80020
+ const html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "command", "commandfor", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns"]);
80021
+ const svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dominant-baseline", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "pointer-events", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-orientation", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "vector-effect", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
80022
+ const mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
80023
+ const xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
80024
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
80025
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
80026
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
80027
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
80028
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
80029
+ const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i);
80030
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
80031
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g);
80032
+ const DOCTYPE_NAME = seal(/^html$/i);
80033
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
80034
+ const ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
80035
+ const COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
80036
+ const FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
80037
+ const SELF_CLOSING_TAG = seal(/\/>/i);
80038
+ const NODE_TYPE = {
80039
+ element: 1,
80040
+ attribute: 2,
80041
+ text: 3,
80042
+ cdataSection: 4,
80043
+ entityReference: 5,
80044
+ entityNode: 6,
80045
+ processingInstruction: 7,
80046
+ comment: 8,
80047
+ document: 9,
80048
+ documentType: 10,
80049
+ documentFragment: 11,
80050
+ notation: 12
80051
+ };
80052
+ const LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, ["style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript"]));
80053
+ const getGlobal = function getGlobal() {
80054
+ return typeof window === "undefined" ? null : window;
80055
+ };
80056
+ /**
80057
+ * Creates a no-op policy for internal use only.
80058
+ * Don't export this function outside this module!
80059
+ * @param trustedTypes The policy factory.
80060
+ * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
80061
+ * @return The policy created (or null, if Trusted Types
80062
+ * are not supported or creating the policy failed).
80063
+ */
80064
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
80065
+ if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") return null;
80066
+ let suffix = null;
80067
+ const ATTR_NAME = "data-tt-policy-suffix";
80068
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) suffix = purifyHostElement.getAttribute(ATTR_NAME);
80069
+ const policyName = "dompurify" + (suffix ? "#" + suffix : "");
80070
+ try {
80071
+ return trustedTypes.createPolicy(policyName, {
80072
+ createHTML(html) {
80073
+ return html;
80074
+ },
80075
+ createScriptURL(scriptUrl) {
80076
+ return scriptUrl;
80077
+ }
80078
+ });
80079
+ } catch (_) {
80080
+ console.warn("TrustedTypes policy " + policyName + " could not be created.");
80081
+ return null;
80082
+ }
80083
+ };
80084
+ const _createHooksMap = function _createHooksMap() {
80085
+ return {
80086
+ afterSanitizeAttributes: [],
80087
+ afterSanitizeElements: [],
80088
+ afterSanitizeShadowDOM: [],
80089
+ beforeSanitizeAttributes: [],
80090
+ beforeSanitizeElements: [],
80091
+ beforeSanitizeShadowDOM: [],
80092
+ uponSanitizeAttribute: [],
80093
+ uponSanitizeElement: [],
80094
+ uponSanitizeShadowNode: []
80095
+ };
80096
+ };
80097
+ /**
80098
+ * Resolve a set-valued configuration option: a fresh set built from
80099
+ * cfg[key] when it is an own array property (seeded with a clone of
80100
+ * options.base when given, case-normalized via options.transform),
80101
+ * the fallback set otherwise.
80102
+ *
80103
+ * @param cfg the cloned, prototype-free configuration object
80104
+ * @param key the configuration property to read
80105
+ * @param fallback the set to use when the option is absent or not an array
80106
+ * @param options transform and optional base set to merge into
80107
+ * @returns the resolved set
80108
+ */
80109
+ const _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
80110
+ return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
80111
+ };
80112
+ /**
80113
+ * Resolve an object-valued configuration option: a prototype-free clone
80114
+ * of cfg[key] when it is an own, truthy object property, else a fresh
80115
+ * fallback built by makeFallback (fresh on every parse, so a previous
80116
+ * parse can never leak state into the next one).
80117
+ *
80118
+ * @param cfg the cloned, prototype-free configuration object
80119
+ * @param key the configuration property to read
80120
+ * @param makeFallback builds the fallback value when the option is absent
80121
+ * @returns the resolved object
80122
+ */
80123
+ const _resolveObjectOption = function _resolveObjectOption(cfg, key, makeFallback) {
80124
+ const value = objectHasOwnProperty(cfg, key) ? cfg[key] : void 0;
80125
+ return value && typeof value === "object" ? clone(value) : makeFallback();
80126
+ };
80127
+ function createDOMPurify() {
80128
+ let window = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
80129
+ const DOMPurify = root => createDOMPurify(root);
80130
+ DOMPurify.version = "3.4.17";
80131
+ DOMPurify.removed = [];
80132
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
80133
+ DOMPurify.isSupported = false;
80134
+ return DOMPurify;
80135
+ }
80136
+ let document = window.document;
80137
+ const originalDocument = document;
80138
+ const currentScript = originalDocument.currentScript;
80139
+ window.DocumentFragment;
80140
+ const HTMLTemplateElement = window.HTMLTemplateElement,
80141
+ Node = window.Node,
80142
+ Element = window.Element,
80143
+ NodeFilter = window.NodeFilter;
80144
+ window.NamedNodeMap === void 0 && (window.NamedNodeMap || window.MozNamedAttrMap);
80145
+ window.HTMLFormElement;
80146
+ const DOMParser = window.DOMParser,
80147
+ trustedTypes = window.trustedTypes;
80148
+ const ElementPrototype = Element.prototype;
80149
+ const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
80150
+ const remove = lookupGetter(ElementPrototype, "remove");
80151
+ const removeAttributeNode = lookupGetter(ElementPrototype, "removeAttributeNode");
80152
+ const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
80153
+ const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
80154
+ const getParentNode = lookupGetter(ElementPrototype, "parentNode");
80155
+ const getShadowRoot = lookupGetter(ElementPrototype, "shadowRoot");
80156
+ const getAttributes = lookupGetter(ElementPrototype, "attributes");
80157
+ const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeType") : null;
80158
+ const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeName") : null;
80159
+ const getOwnerDocument = Node && Node.prototype ? lookupGetter(Node.prototype, "ownerDocument") : null;
80160
+ const _readNodeType = function _readNodeType(node) {
80161
+ return getNodeType ? getNodeType(node) : node.nodeType;
80162
+ };
80163
+ const _readNodeName = function _readNodeName(node) {
80164
+ return getNodeName ? getNodeName(node) : node.nodeName;
80165
+ };
80166
+ const getNamespaceURI = lookupAccessor(ElementPrototype, "namespaceURI");
80167
+ const _readNamespaceURI = function _readNamespaceURI(element) {
80168
+ return getNamespaceURI ? getNamespaceURI(element) : element.namespaceURI;
80169
+ };
80170
+ if (typeof HTMLTemplateElement === "function") {
80171
+ const template = document.createElement("template");
80172
+ if (template.content && template.content.ownerDocument) document = template.content.ownerDocument;
80173
+ }
80174
+ let trustedTypesPolicy;
80175
+ let emptyHTML = "";
80176
+ let defaultTrustedTypesPolicy;
80177
+ let defaultTrustedTypesPolicyResolved = false;
80178
+ let IN_TRUSTED_TYPES_POLICY = 0;
80179
+ const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
80180
+ if (IN_TRUSTED_TYPES_POLICY > 0) throw typeErrorCreate("A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the \"DOMPurify and Trusted Types\" section of the README.");
80181
+ };
80182
+ const _createTrustedHTML = function _createTrustedHTML(html) {
80183
+ _assertNotInTrustedTypesPolicy();
80184
+ IN_TRUSTED_TYPES_POLICY++;
80185
+ try {
80186
+ return trustedTypesPolicy.createHTML(html);
80187
+ } finally {
80188
+ IN_TRUSTED_TYPES_POLICY--;
80189
+ }
80190
+ };
80191
+ const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
80192
+ _assertNotInTrustedTypesPolicy();
80193
+ IN_TRUSTED_TYPES_POLICY++;
80194
+ try {
80195
+ return trustedTypesPolicy.createScriptURL(scriptUrl);
80196
+ } finally {
80197
+ IN_TRUSTED_TYPES_POLICY--;
80198
+ }
80199
+ };
80200
+ const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
80201
+ if (!defaultTrustedTypesPolicyResolved) {
80202
+ defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
80203
+ defaultTrustedTypesPolicyResolved = true;
80204
+ }
80205
+ return defaultTrustedTypesPolicy;
80206
+ };
80207
+ const _document = document,
80208
+ implementation = _document.implementation,
80209
+ createNodeIterator = _document.createNodeIterator,
80210
+ createDocumentFragment = _document.createDocumentFragment,
80211
+ getElementsByTagName = _document.getElementsByTagName;
80212
+ const importNode = originalDocument.importNode;
80213
+ let hooks = _createHooksMap();
80214
+ /**
80215
+ * Expose whether this browser supports running the full DOMPurify.
80216
+ */
80217
+ DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
80218
+ const MUSTACHE_EXPR$1 = MUSTACHE_EXPR,
80219
+ ERB_EXPR$1 = ERB_EXPR,
80220
+ TMPLIT_EXPR$1 = TMPLIT_EXPR,
80221
+ DATA_ATTR$1 = DATA_ATTR,
80222
+ ARIA_ATTR$1 = ARIA_ATTR,
80223
+ IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
80224
+ ATTR_WHITESPACE$1 = ATTR_WHITESPACE,
80225
+ CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
80226
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
80227
+ /**
80228
+ * We consider the elements and attributes below to be safe. Ideally
80229
+ * don't add any new ones but feel free to remove unwanted ones.
80230
+ */
80231
+ let ALLOWED_TAGS = null;
80232
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
80233
+ let ALLOWED_ATTR = null;
80234
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
80235
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
80236
+ tagNameCheck: {
80237
+ writable: true,
80238
+ configurable: false,
80239
+ enumerable: true,
80240
+ value: null
80241
+ },
80242
+ attributeNameCheck: {
80243
+ writable: true,
80244
+ configurable: false,
80245
+ enumerable: true,
80246
+ value: null
80247
+ },
80248
+ allowCustomizedBuiltInElements: {
80249
+ writable: true,
80250
+ configurable: false,
80251
+ enumerable: true,
80252
+ value: false
80253
+ }
80254
+ }));
80255
+ let FORBID_TAGS = null;
80256
+ let FORBID_ATTR = null;
80257
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
80258
+ tagCheck: {
80259
+ writable: true,
80260
+ configurable: false,
80261
+ enumerable: true,
80262
+ value: null
80263
+ },
80264
+ attributeCheck: {
80265
+ writable: true,
80266
+ configurable: false,
80267
+ enumerable: true,
80268
+ value: null
80269
+ }
80270
+ }));
80271
+ let ALLOW_ARIA_ATTR = true;
80272
+ let ALLOW_DATA_ATTR = true;
80273
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
80274
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
80275
+ let SAFE_FOR_TEMPLATES = false;
80276
+ let SAFE_FOR_XML = true;
80277
+ let WHOLE_DOCUMENT = false;
80278
+ let SET_CONFIG = false;
80279
+ let SET_CONFIG_ALLOWED_TAGS = null;
80280
+ let SET_CONFIG_ALLOWED_ATTR = null;
80281
+ let FORCE_BODY = false;
80282
+ let RETURN_DOM = false;
80283
+ let RETURN_DOM_FRAGMENT = false;
80284
+ let RETURN_TRUSTED_TYPE = false;
80285
+ let SANITIZE_DOM = true;
80286
+ let SANITIZE_NAMED_PROPS = false;
80287
+ const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
80288
+ let KEEP_CONTENT = true;
80289
+ let IN_PLACE = false;
80290
+ let IN_PLACE_VISITED = null;
80291
+ let USE_PROFILES = {};
80292
+ let FORBID_CONTENTS = null;
80293
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "selectedcontent", "style", "svg", "template", "thead", "title", "video", "xmp"]);
80294
+ let DATA_URI_TAGS = null;
80295
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
80296
+ let URI_SAFE_ATTRIBUTES = null;
80297
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
80298
+ const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
80299
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
80300
+ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
80301
+ let NAMESPACE = HTML_NAMESPACE;
80302
+ let IS_EMPTY_INPUT = false;
80303
+ let ALLOWED_NAMESPACES = null;
80304
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
80305
+ const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(["mi", "mo", "mn", "ms", "mtext"]);
80306
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
80307
+ const DEFAULT_HTML_INTEGRATION_POINTS = freeze(["annotation-xml"]);
80308
+ let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
80309
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
80310
+ let PARSER_MEDIA_TYPE = null;
80311
+ const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
80312
+ const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
80313
+ let transformCaseFunc = null;
80314
+ let CONFIG = null;
80315
+ const formElement = document.createElement("form");
80316
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
80317
+ return testValue instanceof RegExp || testValue instanceof Function;
80318
+ };
80319
+ /**
80320
+ * _parseConfig
80321
+ *
80322
+ * @param cfg optional config literal
80323
+ */
80324
+ const _parseConfig = function _parseConfig() {
80325
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
80326
+ if (CONFIG && CONFIG === cfg) return;
80327
+ if (!cfg || typeof cfg !== "object") cfg = {};
80328
+ cfg = clone(cfg);
80329
+ PARSER_MEDIA_TYPE = SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
80330
+ transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
80331
+ ALLOWED_TAGS = _resolveSetOption(cfg, "ALLOWED_TAGS", DEFAULT_ALLOWED_TAGS, {
80332
+ transform: transformCaseFunc
80333
+ });
80334
+ ALLOWED_ATTR = _resolveSetOption(cfg, "ALLOWED_ATTR", DEFAULT_ALLOWED_ATTR, {
80335
+ transform: transformCaseFunc
80336
+ });
80337
+ ALLOWED_NAMESPACES = _resolveSetOption(cfg, "ALLOWED_NAMESPACES", DEFAULT_ALLOWED_NAMESPACES, {
80338
+ transform: stringToString
80339
+ });
80340
+ URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, "ADD_URI_SAFE_ATTR", DEFAULT_URI_SAFE_ATTRIBUTES, {
80341
+ transform: transformCaseFunc,
80342
+ base: DEFAULT_URI_SAFE_ATTRIBUTES
80343
+ });
80344
+ DATA_URI_TAGS = _resolveSetOption(cfg, "ADD_DATA_URI_TAGS", DEFAULT_DATA_URI_TAGS, {
80345
+ transform: transformCaseFunc,
80346
+ base: DEFAULT_DATA_URI_TAGS
80347
+ });
80348
+ FORBID_CONTENTS = _resolveSetOption(cfg, "FORBID_CONTENTS", DEFAULT_FORBID_CONTENTS, {
80349
+ transform: transformCaseFunc
80350
+ });
80351
+ FORBID_TAGS = _resolveSetOption(cfg, "FORBID_TAGS", clone({}), {
80352
+ transform: transformCaseFunc
80353
+ });
80354
+ FORBID_ATTR = _resolveSetOption(cfg, "FORBID_ATTR", clone({}), {
80355
+ transform: transformCaseFunc
80356
+ });
80357
+ USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
80358
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
80359
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
80360
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
80361
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
80362
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
80363
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
80364
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
80365
+ RETURN_DOM = cfg.RETURN_DOM || false;
80366
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
80367
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
80368
+ FORCE_BODY = cfg.FORCE_BODY || false;
80369
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
80370
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
80371
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
80372
+ IN_PLACE = cfg.IN_PLACE || false;
80373
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
80374
+ NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
80375
+ MATHML_TEXT_INTEGRATION_POINTS = _resolveObjectOption(cfg, "MATHML_TEXT_INTEGRATION_POINTS", () => addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS));
80376
+ HTML_INTEGRATION_POINTS = _resolveObjectOption(cfg, "HTML_INTEGRATION_POINTS", () => addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS));
80377
+ const customElementHandling = _resolveObjectOption(cfg, "CUSTOM_ELEMENT_HANDLING", () => create(null));
80378
+ CUSTOM_ELEMENT_HANDLING = create(null);
80379
+ if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
80380
+ if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
80381
+ if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
80382
+ seal(CUSTOM_ELEMENT_HANDLING);
80383
+ if (SAFE_FOR_TEMPLATES) ALLOW_DATA_ATTR = false;
80384
+ if (RETURN_DOM_FRAGMENT) RETURN_DOM = true;
80385
+ if (USE_PROFILES) {
80386
+ ALLOWED_TAGS = addToSet({}, text);
80387
+ ALLOWED_ATTR = create(null);
80388
+ if (USE_PROFILES.html === true) {
80389
+ addToSet(ALLOWED_TAGS, html$1);
80390
+ addToSet(ALLOWED_ATTR, html);
80391
+ }
80392
+ if (USE_PROFILES.svg === true) {
80393
+ addToSet(ALLOWED_TAGS, svg$1);
80394
+ addToSet(ALLOWED_ATTR, svg);
80395
+ addToSet(ALLOWED_ATTR, xml);
80396
+ }
80397
+ if (USE_PROFILES.svgFilters === true) {
80398
+ addToSet(ALLOWED_TAGS, svgFilters);
80399
+ addToSet(ALLOWED_ATTR, svg);
80400
+ addToSet(ALLOWED_ATTR, xml);
80401
+ }
80402
+ if (USE_PROFILES.mathMl === true) {
80403
+ addToSet(ALLOWED_TAGS, mathMl$1);
80404
+ addToSet(ALLOWED_ATTR, mathMl);
80405
+ addToSet(ALLOWED_ATTR, xml);
80406
+ }
80407
+ }
80408
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
80409
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
80410
+ if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
80411
+ if (typeof cfg.ADD_TAGS === "function") EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;else if (arrayIsArray(cfg.ADD_TAGS)) {
80412
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) ALLOWED_TAGS = clone(ALLOWED_TAGS);
80413
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
80414
+ }
80415
+ }
80416
+ if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
80417
+ if (typeof cfg.ADD_ATTR === "function") EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;else if (arrayIsArray(cfg.ADD_ATTR)) {
80418
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) ALLOWED_ATTR = clone(ALLOWED_ATTR);
80419
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
80420
+ }
80421
+ }
80422
+ if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
80423
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) FORBID_CONTENTS = clone(FORBID_CONTENTS);
80424
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
80425
+ }
80426
+ if (KEEP_CONTENT) ALLOWED_TAGS["#text"] = true;
80427
+ if (WHOLE_DOCUMENT) addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
80428
+ if (ALLOWED_TAGS.table) {
80429
+ addToSet(ALLOWED_TAGS, ["tbody"]);
80430
+ delete FORBID_TAGS.tbody;
80431
+ }
80432
+ if (cfg.TRUSTED_TYPES_POLICY) {
80433
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") throw typeErrorCreate("TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.");
80434
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") throw typeErrorCreate("TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.");
80435
+ const previousTrustedTypesPolicy = trustedTypesPolicy;
80436
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
80437
+ try {
80438
+ emptyHTML = _createTrustedHTML("");
80439
+ } catch (error) {
80440
+ trustedTypesPolicy = previousTrustedTypesPolicy;
80441
+ throw error;
80442
+ }
80443
+ } else if (cfg.TRUSTED_TYPES_POLICY === null) {
80444
+ trustedTypesPolicy = void 0;
80445
+ emptyHTML = "";
80446
+ } else {
80447
+ if (trustedTypesPolicy === void 0) trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
80448
+ if (trustedTypesPolicy && typeof emptyHTML === "string") emptyHTML = _createTrustedHTML("");
80449
+ }
80450
+ if (freeze) freeze(cfg);
80451
+ CONFIG = cfg;
80452
+ };
80453
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
80454
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
80455
+ /**
80456
+ * Namespace rules for an element in the SVG namespace.
80457
+ *
80458
+ * @param tagName the element's lowercase tag name
80459
+ * @param parent the (possibly simulated) parent node
80460
+ * @param parentTagName the parent's lowercase tag name
80461
+ * @returns true if a spec-compliant parser could produce this element
80462
+ */
80463
+ const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {
80464
+ if (parent.namespaceURI === HTML_NAMESPACE) return tagName === "svg";
80465
+ if (parent.namespaceURI === MATHML_NAMESPACE) return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
80466
+ return Boolean(ALL_SVG_TAGS[tagName]);
80467
+ };
80468
+ /**
80469
+ * Namespace rules for an element in the MathML namespace.
80470
+ *
80471
+ * @param tagName the element's lowercase tag name
80472
+ * @param parent the (possibly simulated) parent node
80473
+ * @param parentTagName the parent's lowercase tag name
80474
+ * @returns true if a spec-compliant parser could produce this element
80475
+ */
80476
+ const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {
80477
+ if (parent.namespaceURI === HTML_NAMESPACE) return tagName === "math";
80478
+ if (parent.namespaceURI === SVG_NAMESPACE) return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
80479
+ return Boolean(ALL_MATHML_TAGS[tagName]);
80480
+ };
80481
+ /**
80482
+ * Namespace rules for an element in the HTML namespace.
80483
+ *
80484
+ * @param tagName the element's lowercase tag name
80485
+ * @param parent the (possibly simulated) parent node
80486
+ * @param parentTagName the parent's lowercase tag name
80487
+ * @returns true if a spec-compliant parser could produce this element
80488
+ */
80489
+ const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {
80490
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) return false;
80491
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) return false;
80492
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
80493
+ };
80494
+ /**
80495
+ * @param element a DOM element whose namespace is being checked
80496
+ * @returns Return false if the element has a
80497
+ * namespace that a spec-compliant parser would never
80498
+ * return. Return true otherwise.
80499
+ */
80500
+ const _checkValidNamespace = function _checkValidNamespace(element) {
80501
+ const elementNamespace = _readNamespaceURI(element);
80502
+ const tagName = stringToLowerCase(_readNodeName(element));
80503
+ const parentNode = getParentNode(element);
80504
+ let parent;
80505
+ let parentTagName;
80506
+ if (parentNode && _readNodeType(parentNode) === NODE_TYPE.element) {
80507
+ parent = {
80508
+ namespaceURI: _readNamespaceURI(parentNode)
80509
+ };
80510
+ parentTagName = stringToLowerCase(_readNodeName(parentNode));
80511
+ } else {
80512
+ parent = {
80513
+ namespaceURI: NAMESPACE
80514
+ };
80515
+ parentTagName = "template";
80516
+ }
80517
+ if (!ALLOWED_NAMESPACES[elementNamespace]) return false;
80518
+ if (elementNamespace === SVG_NAMESPACE) return _checkSvgNamespace(tagName, parent, parentTagName);
80519
+ if (elementNamespace === MATHML_NAMESPACE) return _checkMathMlNamespace(tagName, parent, parentTagName);
80520
+ if (elementNamespace === HTML_NAMESPACE) return _checkHtmlNamespace(tagName, parent, parentTagName);
80521
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[elementNamespace]) return true;
80522
+ return false;
80523
+ };
80524
+ /**
80525
+ * _forceRemove
80526
+ *
80527
+ * @param node a DOM node
80528
+ */
80529
+ const _forceRemove = function _forceRemove(node) {
80530
+ arrayPush(DOMPurify.removed, {
80531
+ element: node
80532
+ });
80533
+ try {
80534
+ getParentNode(node).removeChild(node);
80535
+ } catch (_) {
80536
+ remove(node);
80537
+ if (!getParentNode(node)) throw typeErrorCreate("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
80538
+ }
80539
+ };
80540
+ /**
80541
+ * _stripAttributeNode
80542
+ *
80543
+ * Remove a single Attr node case/namespace-exactly on an attribute-teardown
80544
+ * path. Name-based removeAttribute() ASCII-lowercases its lookup key for an
80545
+ * HTML element in an HTML document and so silently misses a case-preserved
80546
+ * handler (e.g. `ONERROR` off an XML/XHTML import) - the same defect
80547
+ * _removeAttribute() was fixed for, which a name-based call would reintroduce
80548
+ * on these IN_PLACE teardown paths. Unlike _removeAttribute this does not
80549
+ * record into DOMPurify.removed: the neutralize passes intentionally do not
80550
+ * book-keep. A clobbered/detached node falls back to best-effort name-based
80551
+ * removal.
80552
+ *
80553
+ * @param element the element to strip the attribute from
80554
+ * @param attribute the Attr node to remove
80555
+ * @param name the attribute's name, for the fallback path
80556
+ */
80557
+ const _stripAttributeNode = function _stripAttributeNode(element, attribute, name) {
80558
+ try {
80559
+ removeAttributeNode(element, attribute);
80560
+ } catch (_) {
80561
+ try {
80562
+ element.removeAttribute(name);
80563
+ } catch (_) {}
80564
+ }
80565
+ };
80566
+ /**
80567
+ * Fail-closed teardown of an in-place root: strip every disallowed attribute
80568
+ * in the subtree first, so nothing armed is left behind, then remove all
80569
+ * children and the root's own attributes.
80570
+ *
80571
+ * @param root the in-place root to empty
80572
+ */
80573
+ const _neutralizeRoot = function _neutralizeRoot(root) {
80574
+ _neutralizeSubtree(root);
80575
+ const childNodes = getChildNodes(root);
80576
+ if (childNodes) arrayForEach(arraySlice(childNodes), child => {
80577
+ try {
80578
+ remove(child);
80579
+ } catch (_) {}
80580
+ });
80581
+ const attributes = _readNodeType(root) === NODE_TYPE.element ? getAttributes(root) : null;
80582
+ if (attributes) for (let i = attributes.length - 1; i >= 0; --i) {
80583
+ const attribute = attributes[i];
80584
+ const name = attribute && attribute.name;
80585
+ if (typeof name === "string") _stripAttributeNode(root, attribute, name);
80586
+ }
80587
+ };
80588
+ /**
80589
+ * Removes an attribute, preferably as its exact Attr node: name-based
80590
+ * removal lowercases the name in HTML documents and misses case-preserved
80591
+ * names, e.g. from imported XHTML.
80592
+ *
80593
+ * @param name an Attribute name
80594
+ * @param element a DOM node
80595
+ * @param attr the exact Attr node to remove, when the caller has it
80596
+ */
80597
+ const _removeAttribute = function _removeAttribute(name, element, attr) {
80598
+ if (!attr) try {
80599
+ attr = element.getAttributeNode(name);
80600
+ } catch (_) {
80601
+ attr = null;
80602
+ }
80603
+ arrayPush(DOMPurify.removed, {
80604
+ attribute: attr || null,
80605
+ from: element
80606
+ });
80607
+ try {
80608
+ if (attr) removeAttributeNode(element, attr);else element.removeAttribute(name);
80609
+ } catch (_) {
80610
+ try {
80611
+ element.removeAttribute(name);
80612
+ } catch (_) {}
80613
+ }
80614
+ if (name === "is") {
80615
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) try {
80616
+ _forceRemove(element);
80617
+ } catch (_) {} else try {
80618
+ element.setAttribute(name, "");
80619
+ } catch (_) {}
80620
+ }
80621
+ };
80622
+ /**
80623
+ * Removes every attribute the configuration does not allow. Used to
80624
+ * neutralize nodes discarded from an in-place tree.
80625
+ *
80626
+ * @param element the element to strip
80627
+ */
80628
+ const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
80629
+ const attributes = getAttributes(element);
80630
+ if (!attributes) return;
80631
+ for (let i = attributes.length - 1; i >= 0; --i) {
80632
+ const attribute = attributes[i];
80633
+ const name = attribute && attribute.name;
80634
+ if (typeof name !== "string" || ALLOWED_ATTR[transformCaseFunc(name)]) continue;
80635
+ _stripAttributeNode(element, attribute, name);
80636
+ }
80637
+ };
80638
+ /**
80639
+ * Iterative depth-first walk, so deep trees cannot overflow the call stack,
80640
+ * reading through the cached getters, so clobbering cannot hide children.
80641
+ * When `visit` returns false, the node's children are skipped. With
80642
+ * `intoShadow`, open shadow roots are walked after their host's children.
80643
+ *
80644
+ * @param root where to start
80645
+ * @param visit called for every node
80646
+ * @param intoShadow whether to enter open shadow roots
80647
+ */
80648
+ const _walkTree = function _walkTree(root, visit) {
80649
+ let intoShadow = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
80650
+ const stack = [root];
80651
+ while (stack.length > 0) {
80652
+ const node = stack.pop();
80653
+ if (visit(node) === false) continue;
80654
+ if (intoShadow && _readNodeType(node) === NODE_TYPE.element) {
80655
+ const shadowRoot = getShadowRoot(node);
80656
+ if (_isDocumentFragment(shadowRoot)) stack.push(shadowRoot);
80657
+ }
80658
+ const childNodes = getChildNodes(node);
80659
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
80660
+ }
80661
+ };
80662
+ /**
80663
+ * Strips disallowed attributes from every element of a discarded subtree,
80664
+ * so a handler that is already queued (a loading image) cannot fire.
80665
+ *
80666
+ * @param root the root of a removed subtree
80667
+ */
80668
+ const _neutralizeSubtree = function _neutralizeSubtree(root) {
80669
+ _walkTree(root, node => {
80670
+ if (_readNodeType(node) === NODE_TYPE.element) _stripDisallowedAttributes(node);
80671
+ });
80672
+ };
80673
+ /**
80674
+ * All nodes under `root`, root first, including open shadow roots. Template
80675
+ * content is not entered, it is inert.
80676
+ *
80677
+ * @param root the in-place root
80678
+ * @return the nodes
80679
+ */
80680
+ const _collectLiveNodes = function _collectLiveNodes(root) {
80681
+ const nodes = [];
80682
+ _walkTree(root, node => {
80683
+ nodes.push(node);
80684
+ }, true);
80685
+ return nodes;
80686
+ };
80687
+ /**
80688
+ * Strips disallowed attributes from every element that was under the
80689
+ * in-place root when the call started and no longer is, whatever removed
80690
+ * or moved it.
80691
+ *
80692
+ * @param root the in-place root
80693
+ * @param before the root's nodes, collected before the walk
80694
+ */
80695
+ const _neutralizeEscapedElements = function _neutralizeEscapedElements(root, before) {
80696
+ const reachable = setCreate();
80697
+ arrayForEach(_collectLiveNodes(root), node => {
80698
+ if (_readNodeType(node) === NODE_TYPE.element) setAdd(reachable, node);
80699
+ });
80700
+ arrayForEach(before, node => {
80701
+ if (_readNodeType(node) === NODE_TYPE.element && !setHas(reachable, node)) _stripDisallowedAttributes(node);
80702
+ });
80703
+ };
80704
+ /**
80705
+ * Neutralizes everything that left the in-place tree during the call: what
80706
+ * DOMPurify removed, and what hooks or custom elements removed or moved out.
80707
+ *
80708
+ * @param root the in-place root
80709
+ * @param before the root's nodes, collected before the walk
80710
+ * @return true if the root itself was removed
80711
+ */
80712
+ const _neutralizeDiscarded = function _neutralizeDiscarded(root, before) {
80713
+ let rootRemoved = false;
80714
+ arrayForEach(DOMPurify.removed, entry => {
80715
+ if (entry.element) {
80716
+ rootRemoved = rootRemoved || entry.element === root;
80717
+ _neutralizeSubtree(entry.element);
80718
+ }
80719
+ });
80720
+ _neutralizeEscapedElements(root, before);
80721
+ return rootRemoved;
80722
+ };
80723
+ const MAX_UNVISITED_ROUNDS = 8;
80724
+ /**
80725
+ * The walk only moves forward, so a node moved to a position it already
80726
+ * passed is never visited. Give every original node that is still in the
80727
+ * tree but unvisited the normal treatment, hooks included. Nodes created
80728
+ * during the call are left alone. Fails closed if the tree keeps changing.
80729
+ *
80730
+ * @param root the in-place root
80731
+ * @param before the root's nodes, collected before the walk
80732
+ */
80733
+ const _sanitizeUnvisitedNodes = function _sanitizeUnvisitedNodes(root, before) {
80734
+ const visited = IN_PLACE_VISITED;
80735
+ let original = null;
80736
+ const getOriginal = () => {
80737
+ if (!original) {
80738
+ original = setCreate();
80739
+ arrayForEach(before, beforeNode => {
80740
+ setAdd(original, beforeNode);
80741
+ });
80742
+ }
80743
+ return original;
80744
+ };
80745
+ for (let round = 0;; round++) {
80746
+ const live = _collectLiveNodes(root);
80747
+ const containers = [root];
80748
+ let pending = false;
80749
+ arrayForEach(live, node => {
80750
+ if (_readNodeType(node) === NODE_TYPE.documentFragment) arrayPush(containers, node);else if (!pending && !setHas(visited, node)) pending = setHas(getOriginal(), node);
80751
+ });
80752
+ if (!pending) return;
80753
+ if (round >= MAX_UNVISITED_ROUNDS) throw typeErrorCreate("the tree kept changing during in-place sanitization; refusing to return it");
80754
+ arrayForEach(containers, (container, index) => {
80755
+ _sanitizeUnvisitedIn(container, index > 0, root, getOriginal());
80756
+ });
80757
+ }
80758
+ };
80759
+ /**
80760
+ * One _sanitizeUnvisitedNodes pass over the root or an open shadow root.
80761
+ *
80762
+ * @param container the root or an open shadow root
80763
+ * @param inShadow whether container is a shadow root
80764
+ * @param root the in-place root
80765
+ * @param original the root's nodes collected before the walk, as a set
80766
+ */
80767
+ const _sanitizeUnvisitedIn = function _sanitizeUnvisitedIn(container, inShadow, root, original) {
80768
+ const iterator = _createNodeIterator(container);
80769
+ let node;
80770
+ while (node = iterator.nextNode()) {
80771
+ if (!setHas(original, node) || setHas(IN_PLACE_VISITED, node)) continue;
80772
+ if (inShadow) _executeHooks(hooks.uponSanitizeShadowNode, node, null);
80773
+ _sanitizeElements(node, root);
80774
+ _sanitizeAttributes(node, root);
80775
+ if (_isDocumentFragment(node.content)) _sanitizeShadowDOM2(node.content);
80776
+ }
80777
+ };
80778
+ /**
80779
+ * Records that _sanitizeElements processed `node`. No-op outside IN_PLACE.
80780
+ *
80781
+ * @param node the node being processed
80782
+ */
80783
+ const _markVisited = function _markVisited(node) {
80784
+ if (IN_PLACE_VISITED) setAdd(IN_PLACE_VISITED, node);
80785
+ };
80786
+ /**
80787
+ * Patch-linkage attributes (declarative partial updates): `patchsrc`
80788
+ * always, `for` everywhere except on <label> and <output>. Gated on
80789
+ * SAFE_FOR_XML. Shared by the IN_PLACE pre-pass and _isValidAttribute.
80790
+ *
80791
+ * @param lcName the transformCaseFunc'd attribute name
80792
+ * @param lcTag the transformCaseFunc'd tag name of the carrying element
80793
+ * @return true if the attribute is patch linkage and must be dropped
80794
+ */
80795
+ const _isPatchLinkageAttribute = function _isPatchLinkageAttribute(lcName, lcTag) {
80796
+ if (!SAFE_FOR_XML) return false;
80797
+ if (lcName === "patchsrc") return true;
80798
+ return lcName === "for" && lcTag !== "label" && lcTag !== "output";
80799
+ };
80800
+ /**
80801
+ * IN_PLACE pre-pass: sever all patch linkage before the walk, so no patch
80802
+ * can fire mid-walk into a part of the tree the walker already passed.
80803
+ * Removes range markers (processing instructions, comments with markup)
80804
+ * and strips linkage attributes. It cannot undo a patch that already fired.
80805
+ *
80806
+ * TODO: if the shipped feature can patch through `for` on <label>/<output>,
80807
+ * drop that pair here too (see test/declarative-patch-probe.html).
80808
+ *
80809
+ * @param root the in-place root to sweep
80810
+ */
80811
+ const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
80812
+ if (!SAFE_FOR_XML) return;
80813
+ _walkTree(root, node => {
80814
+ const nodeType = _readNodeType(node);
80815
+ if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
80816
+ try {
80817
+ remove(node);
80818
+ } catch (_) {}
80819
+ return false;
80820
+ }
80821
+ if (nodeType === NODE_TYPE.element) {
80822
+ const element = node;
80823
+ const lcTag = transformCaseFunc(_readNodeName(node));
80824
+ try {
80825
+ if (element.hasAttribute && element.hasAttribute("patchsrc")) element.removeAttribute("patchsrc");
80826
+ if (element.hasAttribute && element.hasAttribute("for") && _isPatchLinkageAttribute("for", lcTag)) element.removeAttribute("for");
80827
+ } catch (_) {}
80828
+ }
80829
+ return true;
80830
+ });
80831
+ };
80832
+ /**
80833
+ * _initDocument
80834
+ *
80835
+ * @param dirty - a string of dirty markup
80836
+ * @return a DOM, filled with the dirty markup
80837
+ */
80838
+ const _initDocument = function _initDocument(dirty) {
80839
+ let doc = null;
80840
+ let leadingWhitespace = null;
80841
+ if (FORCE_BODY) dirty = "<remove></remove>" + dirty;else {
80842
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
80843
+ leadingWhitespace = matches && matches[0];
80844
+ }
80845
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) dirty = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>" + dirty + "</body></html>";
80846
+ const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
80847
+ if (NAMESPACE === HTML_NAMESPACE) try {
80848
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
80849
+ } catch (_) {}
80850
+ if (!doc || !doc.documentElement) {
80851
+ doc = implementation.createDocument(NAMESPACE, "template", null);
80852
+ try {
80853
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
80854
+ } catch (_) {}
80855
+ }
80856
+ const body = doc.body || doc.documentElement;
80857
+ if (dirty && leadingWhitespace) body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
80858
+ if (NAMESPACE === HTML_NAMESPACE) return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
80859
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
80860
+ };
80861
+ /**
80862
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
80863
+ *
80864
+ * @param root The root element or node to start traversing on.
80865
+ * @return The created NodeIterator
80866
+ */
80867
+ const _createNodeIterator = function _createNodeIterator(root) {
80868
+ const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
80869
+ return createNodeIterator.call(doc || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
80870
+ };
80871
+ /**
80872
+ * Replace template expression syntax (mustache, ERB, template
80873
+ * literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub
80874
+ * sites. Order matters: mustache, then ERB, then template literal.
80875
+ *
80876
+ * @param value the string to scrub
80877
+ * @returns the scrubbed string
80878
+ */
80879
+ const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
80880
+ value = stringReplace(value, MUSTACHE_EXPR$1, " ");
80881
+ value = stringReplace(value, ERB_EXPR$1, " ");
80882
+ value = stringReplace(value, TMPLIT_EXPR$1, " ");
80883
+ return value;
80884
+ };
80885
+ /**
80886
+ * Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
80887
+ * character data of an element subtree. Used as the final safety net for
80888
+ * SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
80889
+ * which only form after text-node normalization (e.g. fragments split across
80890
+ * stripped elements) cannot survive into a template-evaluating framework.
80891
+ *
80892
+ * Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
80893
+ * in place rather than round-tripping through innerHTML. This preserves
80894
+ * descendant node references (important for IN_PLACE callers), avoids a
80895
+ * serialize/reparse cycle, and reads literal character data — which means
80896
+ * `<%...%>` in text content matches the ERB regex against its real bytes
80897
+ * instead of the HTML-entity-escaped form innerHTML would produce.
80898
+ *
80899
+ * Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
80900
+ * attributes is performed during the per-node `_sanitizeAttributes` pass.
80901
+ *
80902
+ * @param node The root element whose character data should be scrubbed.
80903
+ */
80904
+ const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
80905
+ var _node$querySelectorAl;
80906
+ _scrubOwnCharacterData(node);
80907
+ const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
80908
+ if (templates) arrayForEach(templates, tmpl => {
80909
+ if (_isDocumentFragment(tmpl.content)) _scrubTemplateExpressions2(tmpl.content);
80910
+ });
80911
+ };
80912
+ /**
80913
+ * _scrubOwnCharacterData
80914
+ *
80915
+ * Non-recursive core of _scrubTemplateExpressions: normalize `node` and
80916
+ * strip template expressions from its own character data only. Does not
80917
+ * enter <template>.content or attached shadow roots (NodeIterator never
80918
+ * does). Used by _sanitizeShadowDOM, where every nested template content
80919
+ * and shadow root is already walked - and therefore scrubbed - by its own
80920
+ * recursive _sanitizeShadowDOM call; recursing here as well would rescrub
80921
+ * each nested fragment once per ancestor, which is quadratic in nesting
80922
+ * depth.
80923
+ *
80924
+ * @param node The root whose own character data should be scrubbed.
80925
+ */
80926
+ const _scrubOwnCharacterData = function _scrubOwnCharacterData(node) {
80927
+ node.normalize();
80928
+ const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
80929
+ const walker = createNodeIterator.call(doc || node, node, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
80930
+ let currentNode = walker.nextNode();
80931
+ while (currentNode) {
80932
+ currentNode.data = _stripTemplateExpressions(currentNode.data);
80933
+ currentNode = walker.nextNode();
80934
+ }
80935
+ };
80936
+ /**
80937
+ * _isClobbered
80938
+ *
80939
+ * Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
80940
+ * interface with [LegacyOverrideBuiltIns]; a descendant element with a
80941
+ * `name` attribute matching a prototype property shadows that property
80942
+ * on direct reads. We use this check at the IN_PLACE entry-point and
80943
+ * during attribute sanitization to refuse clobbered forms.
80944
+ *
80945
+ * @param element element to check for clobbering attacks
80946
+ * @return true if clobbered, false if safe
80947
+ */
80948
+ const _isClobbered = function _isClobbered(element) {
80949
+ const realTagName = getNodeName ? getNodeName(element) : null;
80950
+ if (typeof realTagName !== "string") return false;
80951
+ if (transformCaseFunc(realTagName) !== "form") return false;
80952
+ return typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || typeof element.removeAttributeNode !== "function" || typeof element.getAttributeNode !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || element.nodeType !== getNodeType(element) || element.childNodes !== getChildNodes(element);
80953
+ };
80954
+ /**
80955
+ * Checks whether the given value is a DocumentFragment from any realm.
80956
+ *
80957
+ * The realm-independent replacement reads `nodeType` through the cached
80958
+ * Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
80959
+ * constant (11). nodeType is a numeric value resolved from the node's
80960
+ * internal slot, identical across realms for the same kind of node.
80961
+ *
80962
+ * @param value object to check
80963
+ * @return true if value is a DocumentFragment-shaped node from any realm
80964
+ */
80965
+ const _isDocumentFragment = function _isDocumentFragment(value) {
80966
+ if (!getNodeType || typeof value !== "object" || value === null) return false;
80967
+ try {
80968
+ return getNodeType(value) === NODE_TYPE.documentFragment;
80969
+ } catch (_) {
80970
+ return false;
80971
+ }
80972
+ };
80973
+ /**
80974
+ * Checks whether the given object is a DOM node, including nodes that
80975
+ * originate from a different window/realm (e.g. an iframe's
80976
+ * contentDocument). The previous `value instanceof Node` check was
80977
+ * realm-bound: nodes from a different window failed it, causing
80978
+ * sanitize() to silently stringify them and reset IN_PLACE to false,
80979
+ * returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
80980
+ *
80981
+ * @param value object to check whether it's a DOM node
80982
+ * @return true if value is a DOM node from any realm
80983
+ */
80984
+ const _isNode = function _isNode(value) {
80985
+ if (!getNodeType || typeof value !== "object" || value === null) return false;
80986
+ try {
80987
+ return typeof getNodeType(value) === "number";
80988
+ } catch (_) {
80989
+ return false;
80990
+ }
80991
+ };
80992
+ function _executeHooks(hooks, currentNode, data) {
80993
+ if (hooks.length === 0) return;
80994
+ arrayForEach(hooks, hook => {
80995
+ hook.call(DOMPurify, currentNode, data, CONFIG);
80996
+ });
80997
+ }
80998
+ /**
80999
+ * Structural-threat checks that condemn a node regardless of the
81000
+ * allowlists: mXSS via namespace confusion, risky CSS construction,
81001
+ * processing instructions, markup-bearing comments. Pure predicate;
81002
+ * the caller removes. Check order is load-bearing.
81003
+ *
81004
+ * @param currentNode the node to inspect
81005
+ * @param tagName the node's transformCaseFunc'd tag name
81006
+ * @return true if the node must be removed
81007
+ */
81008
+ const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
81009
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) return true;
81010
+ if (SAFE_FOR_XML && LITERAL_TEXT_ELEMENTS[tagName] && _readNodeType(currentNode) === NODE_TYPE.element && _readNamespaceURI(currentNode) === HTML_NAMESPACE && (_isNode(currentNode.firstElementChild) || typeof currentNode.textContent === "string" && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent))) return true;
81011
+ if (currentNode.nodeType === NODE_TYPE.processingInstruction) return true;
81012
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) return true;
81013
+ return false;
81014
+ };
81015
+ /**
81016
+ * Evaluate a CUSTOM_ELEMENT_HANDLING check (a RegExp or a predicate
81017
+ * function, per the validation in _parseConfig) against a name.
81018
+ * Additional arguments are forwarded to predicate functions - the
81019
+ * attributeNameCheck predicate receives the tag name as its second
81020
+ * argument. A null/absent check never matches.
81021
+ *
81022
+ * @param check the configured tagNameCheck / attributeNameCheck value
81023
+ * @param name the name to test
81024
+ * @param args extra arguments forwarded to a predicate function
81025
+ * @return true if the check matches the name
81026
+ */
81027
+ const _matchesNameCheck = function _matchesNameCheck(check, name) {
81028
+ if (check instanceof RegExp) return regExpTest(check, name);
81029
+ if (check instanceof Function) {
81030
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
81031
+ return Boolean(check(name, ...args));
81032
+ }
81033
+ return false;
81034
+ };
81035
+ /**
81036
+ * Handle a node whose tag is forbidden or not allowlisted: keep
81037
+ * allowed custom elements (false return exits _sanitizeElements
81038
+ * early - the namespace and fallback-tag removal checks are
81039
+ * intentionally skipped for kept custom elements), else hoist
81040
+ * content per KEEP_CONTENT and remove.
81041
+ *
81042
+ * A kept custom element is the ONLY case in which this function
81043
+ * returns false, so the caller uses that return value to run the
81044
+ * afterSanitizeElements hook on the kept element and keep the
81045
+ * element-hook lifecycle consistent with normal allowlisted
81046
+ * elements (GHSA-c2j3-45gr-mqc4).
81047
+ *
81048
+ * @param currentNode the disallowed node
81049
+ * @param tagName the node's transformCaseFunc'd tag name
81050
+ * @return true if the node was removed, false if kept
81051
+ */
81052
+ const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName, root) {
81053
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
81054
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName] && !FORBID_CONTENTS[stringToLowerCase(tagName)]) {
81055
+ const parentNode = getParentNode(currentNode);
81056
+ const childNodes = getChildNodes(currentNode);
81057
+ if (childNodes && parentNode) {
81058
+ const childCount = childNodes.length;
81059
+ for (let i = childCount - 1; i >= 0; --i) {
81060
+ const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
81061
+ parentNode.insertBefore(hoisted, getNextSibling(currentNode));
81062
+ }
81063
+ }
81064
+ }
81065
+ _forceRemove(currentNode);
81066
+ return true;
81067
+ };
81068
+ /**
81069
+ * Fork a hook-mutable allowlist off its shared binding the first time a
81070
+ * (possibly lazily-installed) uponSanitize* hook is about to see it, so the
81071
+ * hook cannot widen the per-instance default or the setConfig binding by
81072
+ * reference and leak past the call. Returns the set unchanged once it is
81073
+ * already call-local, so repeated calls across elements are idempotent.
81074
+ *
81075
+ * @param hookList the uponSanitize* hook array for this event
81076
+ * @param set the current ALLOWED_TAGS / ALLOWED_ATTR binding
81077
+ * @param defaultSet the per-instance DEFAULT_ALLOWED_* constant
81078
+ * @param setConfigSet the captured setConfig() binding, or null
81079
+ * @return a call-local clone if a hook is present and set is still shared,
81080
+ * else set unchanged
81081
+ */
81082
+ const _forkSharedAllowlist = function _forkSharedAllowlist(hookList, set, defaultSet, setConfigSet) {
81083
+ if (hookList.length === 0) return set;
81084
+ return set === defaultSet || set === setConfigSet ? clone(set) : set;
81085
+ };
81086
+ /**
81087
+ * A hook may have detached the node it was called for. If so, treat it as
81088
+ * removed and stop processing it; the walk root is exempt. On the IN_PLACE
81089
+ * path the detached subtree is neutralized right away.
81090
+ *
81091
+ * @param currentNode the node a hook may have detached
81092
+ * @param root the current walk root
81093
+ * @return true if the node was detached
81094
+ */
81095
+ const _handleHookDetachedNode = function _handleHookDetachedNode(currentNode, root) {
81096
+ if (currentNode === root || getParentNode(currentNode) !== null) return false;
81097
+ if (IN_PLACE) _neutralizeSubtree(currentNode);
81098
+ return true;
81099
+ };
81100
+ /**
81101
+ * _sanitizeElements
81102
+ *
81103
+ * @protect nodeName
81104
+ * @protect textContent
81105
+ * @protect removeChild
81106
+ * @param currentNode to check for permission to exist
81107
+ * @return true if node was killed, false if left alive
81108
+ */
81109
+ const _sanitizeElements = function _sanitizeElements(currentNode, root) {
81110
+ _markVisited(currentNode);
81111
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
81112
+ if (_handleHookDetachedNode(currentNode, root)) return true;
81113
+ if (_isClobbered(currentNode)) {
81114
+ _forceRemove(currentNode);
81115
+ return true;
81116
+ }
81117
+ const tagName = transformCaseFunc(_readNodeName(currentNode));
81118
+ ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
81119
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
81120
+ tagName,
81121
+ allowedTags: ALLOWED_TAGS
81122
+ });
81123
+ if (_handleHookDetachedNode(currentNode, root)) return true;
81124
+ if (_isUnsafeNode(currentNode, tagName)) {
81125
+ _forceRemove(currentNode);
81126
+ return true;
81127
+ }
81128
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
81129
+ const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
81130
+ if (removed === false) {
81131
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
81132
+ if (_handleHookDetachedNode(currentNode, root)) return true;
81133
+ }
81134
+ return removed;
81135
+ }
81136
+ if (_readNodeType(currentNode) === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
81137
+ _forceRemove(currentNode);
81138
+ return true;
81139
+ }
81140
+ if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
81141
+ _forceRemove(currentNode);
81142
+ return true;
81143
+ }
81144
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
81145
+ const content = _stripTemplateExpressions(currentNode.textContent);
81146
+ if (currentNode.textContent !== content) {
81147
+ arrayPush(DOMPurify.removed, {
81148
+ element: currentNode.cloneNode()
81149
+ });
81150
+ currentNode.textContent = content;
81151
+ }
81152
+ }
81153
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
81154
+ return _handleHookDetachedNode(currentNode, root);
81155
+ };
81156
+ /**
81157
+ * _isValidAttribute
81158
+ *
81159
+ * @param lcTag Lowercase tag name of containing element.
81160
+ * @param lcName Lowercase attribute name.
81161
+ * @param value Attribute value.
81162
+ * @return Returns true if `value` is valid, otherwise false.
81163
+ */
81164
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
81165
+ if (FORBID_ATTR[lcName]) return false;
81166
+ if (_isPatchLinkageAttribute(lcName, lcTag)) return false;
81167
+ if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document || value in formElement)) return false;
81168
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
81169
+ if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) return true;
81170
+ if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) return true;
81171
+ if (!nameIsPermitted) return _isBasicCustomElement(lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName, lcTag) || lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value);
81172
+ if (URI_SAFE_ATTRIBUTES[lcName]) return true;
81173
+ if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
81174
+ if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) return true;
81175
+ if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
81176
+ return !value;
81177
+ };
81178
+ const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]);
81179
+ /**
81180
+ * _isBasicCustomElement
81181
+ * checks if at least one dash is included in tagName, and it's not the first char
81182
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
81183
+ *
81184
+ * @param tagName name of the tag of the node to sanitize
81185
+ * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
81186
+ */
81187
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
81188
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
81189
+ };
81190
+ /**
81191
+ * Wrap an attribute value in the matching Trusted Types object when
81192
+ * the active policy requires it. Namespaced attributes pass through
81193
+ * unchanged (no TT support yet, see
81194
+ * https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).
81195
+ *
81196
+ * @param lcTag lowercase tag name of the containing element
81197
+ * @param lcName lowercase attribute name
81198
+ * @param namespaceURI the attribute's namespace, if any
81199
+ * @param value the attribute value to wrap
81200
+ * @return the value, wrapped when Trusted Types demand it
81201
+ */
81202
+ const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
81203
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI) switch (trustedTypes.getAttributeType(lcTag, lcName)) {
81204
+ case "TrustedHTML":
81205
+ return _createTrustedHTML(value);
81206
+ case "TrustedScriptURL":
81207
+ return _createTrustedScriptURL(value);
81208
+ }
81209
+ return value;
81210
+ };
81211
+ /**
81212
+ * Write a modified attribute value back onto the element. On
81213
+ * success, re-probe for clobbering introduced by the new value and
81214
+ * remove the element when found; otherwise, when this writeback is the
81215
+ * recreate half of the SANITIZE_NAMED_PROPS remove-and-recreate, pop the
81216
+ * removal entry that path recorded so it does not show as removed. On
81217
+ * failure, remove the attribute instead.
81218
+ *
81219
+ * Returns true only on a clean write (the value was set and the new value
81220
+ * introduced no clobbering). The caller uses that, together with its own
81221
+ * knowledge of whether this attribute pushed a DOMPurify.removed record, to
81222
+ * decide whether to pop that record. The pop must happen ONLY for the
81223
+ * named-prop remove-and-recreate; popping on any other value change (trim,
81224
+ * template scrubbing, Trusted Types) would consume an unrelated _forceRemove
81225
+ * subtree-cleanup record and let that detached subtree keep a live event
81226
+ * handler through the IN_PLACE neutralization pass (SO-001).
81227
+ *
81228
+ * @param currentNode the element carrying the attribute
81229
+ * @param name the attribute name as present on the element
81230
+ * @param namespaceURI the attribute's namespace, if any
81231
+ * @param value the new attribute value
81232
+ * @return true if the value was written without introducing clobbering
81233
+ */
81234
+ const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
81235
+ try {
81236
+ if (namespaceURI) currentNode.setAttributeNS(namespaceURI, name, value);else currentNode.setAttribute(name, value);
81237
+ if (_isClobbered(currentNode)) {
81238
+ _forceRemove(currentNode);
81239
+ return false;
81240
+ }
81241
+ return true;
81242
+ } catch (_) {
81243
+ _removeAttribute(name, currentNode);
81244
+ return false;
81245
+ }
81246
+ };
81247
+ /**
81248
+ * _isUnsafeAttributeValue
81249
+ *
81250
+ * Value-based attribute checks that the attribute walk applies before any
81251
+ * hook can force-keep an attribute, shared with the public
81252
+ * isValidAttribute() so that it never approves a value sanitize() would
81253
+ * strip.
81254
+ *
81255
+ * @param name the attribute name as found on the node (case preserved)
81256
+ * @param value the attribute value
81257
+ * @returns true if the attribute must be removed because of its value
81258
+ */
81259
+ const _isUnsafeAttributeValue = function _isUnsafeAttributeValue(name, value) {
81260
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) return true;
81261
+ return stringToLowerCase(name) === "attributename" && stringMatch(value, "href") !== null;
81262
+ };
81263
+ /**
81264
+ * _sanitizeAttributes
81265
+ *
81266
+ * @protect attributes
81267
+ * @protect nodeName
81268
+ * @protect removeAttribute
81269
+ * @protect setAttribute
81270
+ *
81271
+ * @param currentNode to sanitize
81272
+ * @param root the current walk root
81273
+ */
81274
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode, root) {
81275
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
81276
+ if (_handleHookDetachedNode(currentNode, root)) return;
81277
+ const attributes = currentNode.attributes;
81278
+ if (!attributes || _isClobbered(currentNode)) return;
81279
+ ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
81280
+ const hookEvent = {
81281
+ attrName: "",
81282
+ attrValue: "",
81283
+ keepAttr: true,
81284
+ allowedAttributes: ALLOWED_ATTR,
81285
+ forceKeepAttr: void 0
81286
+ };
81287
+ let l = attributes.length;
81288
+ const lcTag = transformCaseFunc(currentNode.nodeName);
81289
+ while (l--) {
81290
+ const attr = attributes[l];
81291
+ const name = attr.name,
81292
+ namespaceURI = attr.namespaceURI,
81293
+ attrValue = attr.value;
81294
+ const lcName = transformCaseFunc(name);
81295
+ const initValue = attrValue;
81296
+ let value = name === "value" ? initValue : stringTrim(initValue);
81297
+ let recreatedNamedProp = false;
81298
+ hookEvent.attrName = lcName;
81299
+ hookEvent.attrValue = value;
81300
+ hookEvent.keepAttr = true;
81301
+ hookEvent.forceKeepAttr = void 0;
81302
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
81303
+ value = hookEvent.attrValue;
81304
+ if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
81305
+ _removeAttribute(name, currentNode, attr);
81306
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
81307
+ recreatedNamedProp = true;
81308
+ }
81309
+ if (_isUnsafeAttributeValue(name, value)) {
81310
+ _removeAttribute(name, currentNode, attr);
81311
+ continue;
81312
+ }
81313
+ if (hookEvent.forceKeepAttr) continue;
81314
+ if (!hookEvent.keepAttr) {
81315
+ _removeAttribute(name, currentNode, attr);
81316
+ continue;
81317
+ }
81318
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
81319
+ _removeAttribute(name, currentNode, attr);
81320
+ continue;
81321
+ }
81322
+ if (SAFE_FOR_TEMPLATES) value = _stripTemplateExpressions(value);
81323
+ if (!_isValidAttribute(lcTag, lcName, value)) {
81324
+ _removeAttribute(name, currentNode, attr);
81325
+ continue;
81326
+ }
81327
+ value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
81328
+ if (value !== initValue) {
81329
+ if (_setAttributeValue(currentNode, name, namespaceURI, value) && recreatedNamedProp) arrayPop(DOMPurify.removed);
81330
+ }
81331
+ }
81332
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
81333
+ _handleHookDetachedNode(currentNode, root);
81334
+ };
81335
+ /**
81336
+ * _sanitizeShadowDOM
81337
+ *
81338
+ * @param fragment to iterate over recursively
81339
+ */
81340
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
81341
+ let shadowNode = null;
81342
+ const shadowIterator = _createNodeIterator(fragment);
81343
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
81344
+ while (shadowNode = shadowIterator.nextNode()) {
81345
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
81346
+ _sanitizeElements(shadowNode, fragment);
81347
+ _sanitizeAttributes(shadowNode, fragment);
81348
+ if (_isDocumentFragment(shadowNode.content)) _sanitizeShadowDOM2(shadowNode.content);
81349
+ if (_readNodeType(shadowNode) === NODE_TYPE.element) {
81350
+ const innerSr = getShadowRoot(shadowNode);
81351
+ if (_isDocumentFragment(innerSr)) {
81352
+ _sanitizeAttachedShadowRoots(innerSr);
81353
+ _sanitizeShadowDOM2(innerSr);
81354
+ }
81355
+ }
81356
+ }
81357
+ if (SAFE_FOR_TEMPLATES) _scrubOwnCharacterData(fragment);
81358
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
81359
+ };
81360
+ /**
81361
+ * Sanitizes every attached shadow root under `root`, since the node
81362
+ * iterator does not enter shadow trees. Needed for IN_PLACE input and for
81363
+ * DOM input whose clonable shadow roots were copied by importNode().
81364
+ *
81365
+ * @param root the subtree root to walk for attached shadow roots
81366
+ */
81367
+ const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
81368
+ const stack = [{
81369
+ node: root,
81370
+ shadow: null
81371
+ }];
81372
+ while (stack.length > 0) {
81373
+ const item = stack.pop();
81374
+ if (item.shadow) {
81375
+ _sanitizeShadowDOM2(item.shadow);
81376
+ continue;
81377
+ }
81378
+ const node = item.node;
81379
+ const isElement = _readNodeType(node) === NODE_TYPE.element;
81380
+ const childNodes = getChildNodes(node);
81381
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push({
81382
+ node: childNodes[i],
81383
+ shadow: null
81384
+ });
81385
+ if (isElement) {
81386
+ const rootName = getNodeName ? getNodeName(node) : null;
81387
+ if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
81388
+ const content = node.content;
81389
+ if (_isDocumentFragment(content)) stack.push({
81390
+ node: content,
81391
+ shadow: null
81392
+ });
81393
+ }
81394
+ }
81395
+ if (isElement) {
81396
+ const sr = getShadowRoot(node);
81397
+ if (_isDocumentFragment(sr)) stack.push({
81398
+ node: null,
81399
+ shadow: sr
81400
+ }, {
81401
+ node: sr,
81402
+ shadow: null
81403
+ });
81404
+ }
81405
+ }
81406
+ };
81407
+ DOMPurify.sanitize = function (dirty) {
81408
+ let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
81409
+ let body = null;
81410
+ let importedNode = null;
81411
+ let currentNode = null;
81412
+ let returnNode = null;
81413
+ IS_EMPTY_INPUT = !dirty;
81414
+ if (IS_EMPTY_INPUT) dirty = "<!-->";
81415
+ if (typeof dirty !== "string" && !_isNode(dirty)) {
81416
+ dirty = stringifyValue(dirty);
81417
+ if (typeof dirty !== "string") throw typeErrorCreate("dirty is not a string, aborting");
81418
+ }
81419
+ if (!DOMPurify.isSupported) return dirty;
81420
+ if (SET_CONFIG) {
81421
+ ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
81422
+ ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
81423
+ } else _parseConfig(cfg);
81424
+ if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) ALLOWED_TAGS = clone(ALLOWED_TAGS);
81425
+ if (hooks.uponSanitizeAttribute.length > 0) ALLOWED_ATTR = clone(ALLOWED_ATTR);
81426
+ DOMPurify.removed = [];
81427
+ const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
81428
+ let inPlaceNodes = [];
81429
+ const outerVisited = IN_PLACE_VISITED;
81430
+ if (inPlace) {
81431
+ _neutralizePatchLinkage(dirty);
81432
+ const nn = _readNodeName(dirty);
81433
+ if (typeof nn === "string") {
81434
+ const tagName = transformCaseFunc(nn);
81435
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
81436
+ _neutralizeRoot(dirty);
81437
+ throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
81438
+ }
81439
+ }
81440
+ if (_isClobbered(dirty)) {
81441
+ _neutralizeRoot(dirty);
81442
+ throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
81443
+ }
81444
+ inPlaceNodes = _collectLiveNodes(dirty);
81445
+ IN_PLACE_VISITED = setCreate();
81446
+ } else if (_isNode(dirty)) {
81447
+ body = _initDocument("<!---->");
81448
+ importedNode = body.ownerDocument.importNode(dirty, true);
81449
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") body = importedNode;else if (importedNode.nodeName === "HTML") body = importedNode;else body.appendChild(importedNode);
81450
+ _sanitizeAttachedShadowRoots(body);
81451
+ } else {
81452
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf("<") === -1) return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
81453
+ body = _initDocument(dirty);
81454
+ if (!body) return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
81455
+ }
81456
+ if (body && FORCE_BODY) _forceRemove(body.firstChild);
81457
+ const walkRoot = inPlace ? dirty : body;
81458
+ try {
81459
+ if (inPlace) _sanitizeAttachedShadowRoots(dirty);
81460
+ const nodeIterator = _createNodeIterator(walkRoot);
81461
+ while (currentNode = nodeIterator.nextNode()) {
81462
+ _sanitizeElements(currentNode, walkRoot);
81463
+ _sanitizeAttributes(currentNode, walkRoot);
81464
+ if (_isDocumentFragment(currentNode.content)) _sanitizeShadowDOM2(currentNode.content);
81465
+ }
81466
+ if (inPlace) _sanitizeUnvisitedNodes(dirty, inPlaceNodes);
81467
+ } catch (error) {
81468
+ if (inPlace) {
81469
+ _neutralizeRoot(dirty);
81470
+ _neutralizeDiscarded(dirty, inPlaceNodes);
81471
+ }
81472
+ throw error;
81473
+ } finally {
81474
+ IN_PLACE_VISITED = outerVisited;
81475
+ }
81476
+ if (inPlace) {
81477
+ if (_neutralizeDiscarded(dirty, inPlaceNodes)) throw typeErrorCreate("a node selected for removal could not be safely returned; refusing to sanitize in place");
81478
+ if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(dirty);
81479
+ return dirty;
81480
+ }
81481
+ if (RETURN_DOM) {
81482
+ if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(body);
81483
+ if (RETURN_DOM_FRAGMENT) {
81484
+ returnNode = createDocumentFragment.call(body.ownerDocument);
81485
+ while (body.firstChild) returnNode.appendChild(body.firstChild);
81486
+ } else returnNode = body;
81487
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) returnNode = importNode.call(originalDocument, returnNode, true);
81488
+ return returnNode;
81489
+ }
81490
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
81491
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
81492
+ if (SAFE_FOR_TEMPLATES) serializedHTML = _stripTemplateExpressions(serializedHTML);
81493
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
81494
+ };
81495
+ DOMPurify.setConfig = function () {
81496
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
81497
+ _parseConfig(cfg);
81498
+ SET_CONFIG = true;
81499
+ SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
81500
+ SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
81501
+ };
81502
+ DOMPurify.clearConfig = function () {
81503
+ CONFIG = null;
81504
+ SET_CONFIG = false;
81505
+ SET_CONFIG_ALLOWED_TAGS = null;
81506
+ SET_CONFIG_ALLOWED_ATTR = null;
81507
+ trustedTypesPolicy = defaultTrustedTypesPolicy;
81508
+ emptyHTML = "";
81509
+ };
81510
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
81511
+ if (!CONFIG) _parseConfig({});
81512
+ const lcTag = transformCaseFunc(tag);
81513
+ const lcName = transformCaseFunc(attr);
81514
+ if (typeof value === "string" && (_isUnsafeAttributeValue(attr, value) || !ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value))) return false;
81515
+ return _isValidAttribute(lcTag, lcName, value);
81516
+ };
81517
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
81518
+ if (typeof hookFunction !== "function") return;
81519
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
81520
+ arrayPush(hooks[entryPoint], hookFunction);
81521
+ };
81522
+ DOMPurify.removeHook = function (entryPoint, hookFunction) {
81523
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
81524
+ if (hookFunction !== void 0) {
81525
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
81526
+ return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
81527
+ }
81528
+ return arrayPop(hooks[entryPoint]);
81529
+ };
81530
+ DOMPurify.removeHooks = function (entryPoint) {
81531
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
81532
+ hooks[entryPoint] = [];
81533
+ };
81534
+ DOMPurify.removeAllHooks = function () {
81535
+ hooks = _createHooksMap();
81536
+ };
81537
+ return DOMPurify;
81538
+ }
81539
+ var purify_default = createDOMPurify();
81540
+
81541
+ const purifier = purify_default();
81542
+ function createMenuIcon(source) {
81543
+ if (!source.trimStart().startsWith('<')) {
81544
+ try {
81545
+ const url = new URL(source);
81546
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') {
81547
+ return null;
81548
+ }
81549
+ const image = new Image();
81550
+ image.src = url.href;
81551
+ return image;
81552
+ }
81553
+ catch {
81554
+ return null;
81555
+ }
81556
+ }
81557
+ if (!purifier.isSupported) {
81558
+ return null;
81559
+ }
81560
+ const fragment = purifier.sanitize(source, {
81561
+ ALLOWED_TAGS: [
81562
+ 'svg',
81563
+ 'g',
81564
+ 'path',
81565
+ 'rect',
81566
+ 'circle',
81567
+ 'ellipse',
81568
+ 'line',
81569
+ 'polyline',
81570
+ 'polygon',
81571
+ 'defs',
81572
+ 'linearGradient',
81573
+ 'radialGradient',
81574
+ 'stop',
81575
+ 'clipPath',
81576
+ 'mask',
81577
+ 'title',
81578
+ 'desc'
81579
+ ],
81580
+ ALLOWED_ATTR: [
81581
+ 'xmlns',
81582
+ 'viewBox',
81583
+ 'width',
81584
+ 'height',
81585
+ 'x',
81586
+ 'y',
81587
+ 'x1',
81588
+ 'x2',
81589
+ 'y1',
81590
+ 'y2',
81591
+ 'cx',
81592
+ 'cy',
81593
+ 'r',
81594
+ 'rx',
81595
+ 'ry',
81596
+ 'd',
81597
+ 'points',
81598
+ 'fill',
81599
+ 'fill-rule',
81600
+ 'fill-opacity',
81601
+ 'stroke',
81602
+ 'stroke-width',
81603
+ 'stroke-linecap',
81604
+ 'stroke-linejoin',
81605
+ 'stroke-miterlimit',
81606
+ 'stroke-dasharray',
81607
+ 'stroke-dashoffset',
81608
+ 'stroke-opacity',
81609
+ 'opacity',
81610
+ 'transform',
81611
+ 'id',
81612
+ 'clip-path',
81613
+ 'clip-rule',
81614
+ 'mask',
81615
+ 'gradientUnits',
81616
+ 'gradientTransform',
81617
+ 'spreadMethod',
81618
+ 'offset',
81619
+ 'stop-color',
81620
+ 'stop-opacity',
81621
+ 'fx',
81622
+ 'fy',
81623
+ 'fr',
81624
+ 'maskUnits',
81625
+ 'maskContentUnits',
81626
+ 'clipPathUnits',
81627
+ 'preserveAspectRatio'
81628
+ ],
81629
+ ALLOW_DATA_ATTR: false,
81630
+ ALLOW_ARIA_ATTR: false,
81631
+ RETURN_DOM_FRAGMENT: true
81632
+ });
81633
+ const svg = fragment.firstElementChild;
81634
+ if (svg?.localName !== 'svg' || svg.namespaceURI !== 'http://www.w3.org/2000/svg') {
81635
+ return null;
81636
+ }
81637
+ for (const element of [svg, ...Array.from(svg.querySelectorAll('*'))]) {
81638
+ for (const name of ['fill', 'stroke', 'clip-path', 'mask', 'stop-color']) {
81639
+ const value = element.getAttribute(name);
81640
+ if (value && /url\s*\(|var\s*\(|\\|\/\*/i.test(value) && !/^url\(#[\w.-]+\)$/.test(value)) {
81641
+ element.removeAttribute(name);
81642
+ }
81643
+ }
81644
+ }
81645
+ return svg;
81646
+ }
81647
+
79439
81648
  importStyle$1();
79440
81649
  const CLASSNAME$1 = 'vtable__menu-element';
79441
81650
  const ITEM_CLASSNAME = `${CLASSNAME$1}__item`;
@@ -79867,7 +82076,7 @@
79867
82076
  secondElement.style.left = `0px`;
79868
82077
  const maxWidth = containerWidth * 0.8;
79869
82078
  secondElement.style.maxWidth = `${maxWidth}px`;
79870
- const secondElementWidth = secondElement.clientWidth;
82079
+ const secondElementWidth = secondElement.offsetWidth;
79871
82080
  const secondElementHeight = secondElement.clientHeight;
79872
82081
  const secondElementTop = y - 4 - containerTop;
79873
82082
  const secondElementLeft = x - containerLeft;
@@ -79878,12 +82087,13 @@
79878
82087
  }
79879
82088
  secondElement.style.top = `${topStyle}px`;
79880
82089
  let leftStyle = secondElementLeft;
79881
- if (leftStyle + secondElementWidth > containerWidth) {
82090
+ if (leftStyle + secondElementWidth + 4 > containerWidth) {
79882
82091
  leftStyle = leftStyle - secondElementWidth - rootWidth;
79883
82092
  }
79884
82093
  else {
79885
82094
  leftStyle += 4;
79886
82095
  }
82096
+ leftStyle = Math.max(0, Math.min(leftStyle, containerWidth - secondElementWidth));
79887
82097
  secondElement.style.left = `${leftStyle}px`;
79888
82098
  return true;
79889
82099
  }
@@ -79918,7 +82128,7 @@
79918
82128
  }
79919
82129
  if (typeof info === 'string') {
79920
82130
  const item = createElement('span', [CONTENT_CLASSNAME, NOEVENT_CLASSNAME, ITEMTEXT_CLASSNAME]);
79921
- item.innerHTML = info;
82131
+ item.textContent = info;
79922
82132
  itemContainer.appendChild(item);
79923
82133
  }
79924
82134
  else if (typeof info === 'object') {
@@ -79928,34 +82138,23 @@
79928
82138
  return itemContainer;
79929
82139
  }
79930
82140
  if (info?.icon?.svg) {
79931
- if (regUrl.test(info.icon.svg)) {
79932
- const image = new Image();
79933
- if (info.icon.width) {
79934
- image.style.width = info.icon.width.toString() + 'px';
79935
- }
79936
- else {
79937
- image.style.width = '16px';
79938
- }
79939
- if (info.icon.height) {
79940
- image.style.height = info.icon.height.toString() + 'px';
79941
- }
79942
- else {
79943
- image.style.height = '16px';
79944
- }
79945
- image.src = info.icon.svg;
79946
- itemContainer.appendChild(image);
82141
+ const source = isHighlight && info.selectedIcon?.svg ? info.selectedIcon.svg : info.icon.svg;
82142
+ const icon = createMenuIcon(source);
82143
+ if (icon?.localName === 'img') {
82144
+ icon.style.width = `${info.icon.width || 16}px`;
82145
+ icon.style.height = `${info.icon.height || 16}px`;
82146
+ itemContainer.appendChild(icon);
79947
82147
  }
79948
- else {
79949
- const svg = createElement('span', [ICOM_CLASSNAME, NOEVENT_CLASSNAME]);
79950
- svg.innerHTML =
79951
- isHighlight && info.selectedIcon && info.selectedIcon.svg ? info.selectedIcon.svg : info.icon.svg;
79952
- info.icon.width && svg.children[0].setAttribute('width', info.icon.width.toString());
79953
- info.icon.height && svg.children[0].setAttribute('height', info.icon.height.toString());
79954
- itemContainer.appendChild(svg);
82148
+ else if (icon) {
82149
+ const wrapper = createElement('span', [ICOM_CLASSNAME, NOEVENT_CLASSNAME]);
82150
+ info.icon.width && icon.setAttribute('width', info.icon.width.toString());
82151
+ info.icon.height && icon.setAttribute('height', info.icon.height.toString());
82152
+ wrapper.appendChild(icon);
82153
+ itemContainer.appendChild(wrapper);
79955
82154
  }
79956
82155
  }
79957
82156
  const item = createElement('span', [CONTENT_CLASSNAME, NOEVENT_CLASSNAME, ITEMTEXT_CLASSNAME]);
79958
- item.innerHTML = info.text;
82157
+ item.textContent = info.text ?? '';
79959
82158
  itemContainer.appendChild(item);
79960
82159
  if (type === 'title') {
79961
82160
  itemContainer?.classList.add(NOEVENT_CLASSNAME, TITLE_CLASSNAME);
@@ -82347,12 +84546,15 @@
82347
84546
  customCellStyleArrangement;
82348
84547
  _customCellStyleArrangementIndex;
82349
84548
  _customCellStyleArrangementTombstoneCount;
84549
+ _customCellStyleOverlays;
84550
+ _customCellStyleIdsCache;
82350
84551
  constructor(table, customCellStyle, customCellStyleArrangement) {
82351
84552
  this.table = table;
82352
84553
  this.customCellStyle = customCellStyle;
82353
84554
  this.customCellStyleArrangement = customCellStyleArrangement;
82354
84555
  this._customCellStyleArrangementIndex = new Map();
82355
84556
  this._customCellStyleArrangementTombstoneCount = 0;
84557
+ this._customCellStyleOverlays = new Map();
82356
84558
  this._rebuildCustomCellStyleArrangementIndex();
82357
84559
  }
82358
84560
  _getCustomCellStyleArrangementKey(cellPos) {
@@ -82369,11 +84571,12 @@
82369
84571
  this._customCellStyleArrangementIndex.clear();
82370
84572
  this._customCellStyleArrangementTombstoneCount = 0;
82371
84573
  for (let i = 0; i < this.customCellStyleArrangement.length; i++) {
82372
- if (!isValid$1(this.customCellStyleArrangement[i].customStyleId)) {
84574
+ const arrangement = this.customCellStyleArrangement[i];
84575
+ if (!isValid$1(arrangement.customStyleId)) {
82373
84576
  this._customCellStyleArrangementTombstoneCount++;
82374
84577
  continue;
82375
84578
  }
82376
- const key = this._getCustomCellStyleArrangementKey(this.customCellStyleArrangement[i].cellPosition);
84579
+ const key = this._getCustomCellStyleArrangementKey(arrangement.cellPosition);
82377
84580
  if (key) {
82378
84581
  this._customCellStyleArrangementIndex.set(key, i);
82379
84582
  }
@@ -82398,6 +84601,7 @@
82398
84601
  }
82399
84602
  clearCustomCellStyleArrangement() {
82400
84603
  this.customCellStyleArrangement = [];
84604
+ this._rebuildCustomCellStyleArrangementIndex();
82401
84605
  }
82402
84606
  addCustomCellStyleArrangement(cellPosition, customStyleId) {
82403
84607
  this.customCellStyleArrangement.push({
@@ -82405,6 +84609,56 @@
82405
84609
  customStyleId
82406
84610
  });
82407
84611
  }
84612
+ setCustomCellStyleOverlay(sourceId, cellPosition, customStyleId) {
84613
+ const positionKey = this._getCustomCellStyleArrangementKey(cellPosition);
84614
+ if (!positionKey) {
84615
+ return;
84616
+ }
84617
+ let overlay = this._customCellStyleOverlays.get(sourceId);
84618
+ if (!overlay) {
84619
+ overlay = {
84620
+ positions: new Map(),
84621
+ cells: new Map()
84622
+ };
84623
+ this._customCellStyleOverlays.set(sourceId, overlay);
84624
+ }
84625
+ const previousCellKeys = overlay.positions.get(positionKey) ?? [];
84626
+ if (!customStyleId) {
84627
+ previousCellKeys.forEach(cellKey => {
84628
+ const cellStyles = overlay?.cells.get(cellKey);
84629
+ cellStyles?.delete(positionKey);
84630
+ if (cellStyles?.size === 0) {
84631
+ overlay?.cells.delete(cellKey);
84632
+ }
84633
+ });
84634
+ overlay.positions.delete(positionKey);
84635
+ if (overlay.positions.size === 0) {
84636
+ this._customCellStyleOverlays.delete(sourceId);
84637
+ }
84638
+ return;
84639
+ }
84640
+ const range = cellPosition.range ?? {
84641
+ start: { col: cellPosition.col, row: cellPosition.row },
84642
+ end: { col: cellPosition.col, row: cellPosition.row }
84643
+ };
84644
+ const cellKeys = [];
84645
+ for (let col = range.start.col; col <= range.end.col; col++) {
84646
+ for (let row = range.start.row; row <= range.end.row; row++) {
84647
+ const cellKey = `${col}:${row}`;
84648
+ cellKeys.push(cellKey);
84649
+ let cellStyles = overlay.cells.get(cellKey);
84650
+ if (!cellStyles) {
84651
+ cellStyles = new Map();
84652
+ overlay.cells.set(cellKey, cellStyles);
84653
+ }
84654
+ cellStyles.set(positionKey, customStyleId);
84655
+ }
84656
+ }
84657
+ overlay.positions.set(positionKey, cellKeys);
84658
+ }
84659
+ clearCustomCellStyleOverlay(sourceId) {
84660
+ this._customCellStyleOverlays.delete(sourceId);
84661
+ }
82408
84662
  getCustomCellStyle(col, row) {
82409
84663
  const customStyleIds = this.getCustomCellStyleIds(col, row);
82410
84664
  if (customStyleIds.length) {
@@ -82434,12 +84688,24 @@
82434
84688
  return undefined;
82435
84689
  }
82436
84690
  getCustomCellStyleIds(col, row) {
82437
- const customStyleIds = [];
82438
84691
  const range = this.table.getCellRange(col, row);
84692
+ const rangeKey = `${range.start.col}:${range.start.row}:${range.end.col}:${range.end.row}`;
84693
+ const cachedStyleIds = this._customCellStyleIdsCache?.get(rangeKey);
84694
+ if (cachedStyleIds) {
84695
+ return cachedStyleIds;
84696
+ }
84697
+ const customStyleIds = this._collectCustomCellStyleIds(range);
84698
+ this._customCellStyleIdsCache?.set(rangeKey, customStyleIds);
84699
+ return customStyleIds;
84700
+ }
84701
+ _collectCustomCellStyleIds(range) {
84702
+ const customStyleIds = [];
84703
+ const seenArrangements = new Set();
84704
+ const seenOverlayPositions = new Set();
82439
84705
  for (let c = range.start.col; c <= range.end.col; c++) {
82440
84706
  for (let r = range.start.row; r <= range.end.row; r++) {
82441
- this.customCellStyleArrangement.forEach(style => {
82442
- if (!isValid$1(style.customStyleId)) {
84707
+ this.customCellStyleArrangement.forEach((style, index) => {
84708
+ if (seenArrangements.has(index) || !isValid$1(style.customStyleId)) {
82443
84709
  return;
82444
84710
  }
82445
84711
  if (style.cellPosition.range) {
@@ -82447,17 +84713,49 @@
82447
84713
  style.cellPosition.range.end.col >= c &&
82448
84714
  style.cellPosition.range.start.row <= r &&
82449
84715
  style.cellPosition.range.end.row >= r) {
84716
+ seenArrangements.add(index);
82450
84717
  customStyleIds.push(style.customStyleId);
82451
84718
  }
82452
84719
  }
82453
84720
  else if (style.cellPosition.col === c && style.cellPosition.row === r) {
84721
+ seenArrangements.add(index);
82454
84722
  customStyleIds.push(style.customStyleId);
82455
84723
  }
82456
84724
  });
84725
+ for (const [sourceId, overlay] of this._customCellStyleOverlays) {
84726
+ const overlayStyles = overlay.cells.get(`${c}:${r}`);
84727
+ if (overlayStyles) {
84728
+ for (const [positionKey, customStyleId] of overlayStyles) {
84729
+ const overlayPositionKey = `${sourceId}:${positionKey}`;
84730
+ if (!seenOverlayPositions.has(overlayPositionKey)) {
84731
+ seenOverlayPositions.add(overlayPositionKey);
84732
+ customStyleIds.push(customStyleId);
84733
+ }
84734
+ }
84735
+ }
84736
+ }
82457
84737
  }
82458
84738
  }
82459
84739
  return customStyleIds;
82460
84740
  }
84741
+ refreshCustomCellStyleRange(cellPosition, forceFastUpdate = false) {
84742
+ const range = cellPosition.range ?? {
84743
+ start: { col: cellPosition.col, row: cellPosition.row },
84744
+ end: { col: cellPosition.col, row: cellPosition.row }
84745
+ };
84746
+ const previousCache = this._customCellStyleIdsCache;
84747
+ this._customCellStyleIdsCache = new Map();
84748
+ try {
84749
+ for (let col = Math.max(0, range.start.col); col <= Math.min(this.table.colCount - 1, range.end.col); col++) {
84750
+ for (let row = Math.max(0, range.start.row); row <= Math.min(this.table.rowCount - 1, range.end.row); row++) {
84751
+ this.table.scenegraph.updateCellContent(col, row, forceFastUpdate);
84752
+ }
84753
+ }
84754
+ }
84755
+ finally {
84756
+ this._customCellStyleIdsCache = previousCache;
84757
+ }
84758
+ }
82461
84759
  getCustomCellStyleOption(customStyleId) {
82462
84760
  return this.customCellStyle.find(style => style.id === customStyleId);
82463
84761
  }
@@ -82494,39 +84792,8 @@
82494
84792
  }
82495
84793
  arrangeCustomCellStyle(cellPos, customStyleId, forceFastUpdate) {
82496
84794
  const inputKey = this._getCustomCellStyleArrangementKey(cellPos);
82497
- let index = inputKey ? this._customCellStyleArrangementIndex.get(inputKey) ?? -1 : -1;
82498
- if (inputKey && index !== -1) {
82499
- const item = this.customCellStyleArrangement[index];
82500
- const itemKey = item ? this._getCustomCellStyleArrangementKey(item.cellPosition) : undefined;
82501
- if (!item || !isValid$1(item.customStyleId) || itemKey !== inputKey) {
82502
- index = this.customCellStyleArrangement.findIndex(style => {
82503
- if (!isValid$1(style.customStyleId)) {
82504
- return false;
82505
- }
82506
- return this._getCustomCellStyleArrangementKey(style.cellPosition) === inputKey;
82507
- });
82508
- if (index !== -1) {
82509
- this._customCellStyleArrangementIndex.set(inputKey, index);
82510
- }
82511
- else {
82512
- this._customCellStyleArrangementIndex.delete(inputKey);
82513
- }
82514
- }
82515
- }
82516
- if (index === -1 && !inputKey) {
82517
- index = this.customCellStyleArrangement.findIndex(style => {
82518
- if (!isValid$1(style.customStyleId)) {
82519
- return false;
82520
- }
82521
- if (style.cellPosition.range && cellPos.range) {
82522
- return (style.cellPosition.range.start.col === cellPos.range.start.col &&
82523
- style.cellPosition.range.start.row === cellPos.range.start.row &&
82524
- style.cellPosition.range.end.col === cellPos.range.end.col &&
82525
- style.cellPosition.range.end.row === cellPos.range.end.row);
82526
- }
82527
- return style.cellPosition.col === cellPos.col && style.cellPosition.row === cellPos.row;
82528
- });
82529
- }
84795
+ this._rebuildCustomCellStyleArrangementIndex();
84796
+ const index = inputKey ? this._customCellStyleArrangementIndex.get(inputKey) ?? -1 : -1;
82530
84797
  if (index === -1 && !customStyleId) {
82531
84798
  return;
82532
84799
  }
@@ -82552,14 +84819,8 @@
82552
84819
  this.customCellStyleArrangement[index].customStyleId = customStyleId;
82553
84820
  }
82554
84821
  else {
82555
- const existedKey = this._getCustomCellStyleArrangementKey(this.customCellStyleArrangement[index].cellPosition);
82556
- if (isValid$1(this.customCellStyleArrangement[index].customStyleId)) {
82557
- this._customCellStyleArrangementTombstoneCount++;
82558
- }
82559
84822
  this.customCellStyleArrangement[index].customStyleId = null;
82560
- if (existedKey) {
82561
- this._customCellStyleArrangementIndex.delete(existedKey);
82562
- }
84823
+ this._rebuildCustomCellStyleArrangementIndex();
82563
84824
  this._compactCustomCellStyleArrangementIfNeeded();
82564
84825
  }
82565
84826
  const style = customStyleId ? this.getCustomCellStyleOption(customStyleId)?.style : undefined;
@@ -82590,16 +84851,59 @@
82590
84851
  this.table.scenegraph.updateNextFrame();
82591
84852
  }
82592
84853
  updateCustomCell(customCellStyle, customCellStyleArrangement) {
84854
+ const positionsToRefresh = new Map();
84855
+ this.customCellStyleArrangement.forEach(arrangement => {
84856
+ const key = this._getCustomCellStyleArrangementKey(arrangement.cellPosition);
84857
+ if (key) {
84858
+ positionsToRefresh.set(key, arrangement.cellPosition);
84859
+ }
84860
+ });
82593
84861
  this.customCellStyle.length = 0;
82594
- this.customCellStyleArrangement.length = 0;
82595
- this._customCellStyleArrangementIndex.clear();
82596
- this._customCellStyleArrangementTombstoneCount = 0;
82597
- customCellStyle.forEach((cellStyle) => {
82598
- this.registerCustomCellStyle(cellStyle.id, cellStyle.style);
84862
+ const styleIndexes = new Map();
84863
+ customCellStyle.forEach(cellStyle => {
84864
+ const index = styleIndexes.get(cellStyle.id);
84865
+ const nextCellStyle = {
84866
+ id: cellStyle.id,
84867
+ style: cellStyle.style
84868
+ };
84869
+ if (index === undefined) {
84870
+ styleIndexes.set(cellStyle.id, this.customCellStyle.length);
84871
+ this.customCellStyle.push(nextCellStyle);
84872
+ }
84873
+ else {
84874
+ this.customCellStyle[index] = nextCellStyle;
84875
+ }
82599
84876
  });
82600
- customCellStyleArrangement.forEach((cellStyle) => {
82601
- this.arrangeCustomCellStyle(cellStyle.cellPosition, cellStyle.customStyleId);
84877
+ this.customCellStyleArrangement.length = 0;
84878
+ const arrangementIndexes = new Map();
84879
+ customCellStyleArrangement.forEach(arrangement => {
84880
+ const nextArrangement = {
84881
+ cellPosition: {
84882
+ col: arrangement.cellPosition.col,
84883
+ row: arrangement.cellPosition.row,
84884
+ range: arrangement.cellPosition.range
84885
+ },
84886
+ customStyleId: arrangement.customStyleId
84887
+ };
84888
+ const key = this._getCustomCellStyleArrangementKey(arrangement.cellPosition);
84889
+ if (key) {
84890
+ const index = arrangementIndexes.get(key);
84891
+ if (index === undefined) {
84892
+ arrangementIndexes.set(key, this.customCellStyleArrangement.length);
84893
+ this.customCellStyleArrangement.push(nextArrangement);
84894
+ }
84895
+ else {
84896
+ this.customCellStyleArrangement[index] = nextArrangement;
84897
+ }
84898
+ positionsToRefresh.set(key, arrangement.cellPosition);
84899
+ }
84900
+ else {
84901
+ this.customCellStyleArrangement.push(nextArrangement);
84902
+ }
82602
84903
  });
84904
+ this._rebuildCustomCellStyleArrangementIndex();
84905
+ positionsToRefresh.forEach(position => this.refreshCustomCellStyleRange(position));
84906
+ this.table.scenegraph.updateNextFrame();
82603
84907
  }
82604
84908
  hasCustomCellStyle(customStyleId) {
82605
84909
  return this.customCellStyle.some(style => style.id === customStyleId);
@@ -84687,6 +86991,7 @@
84687
86991
  this.pluginManager.release();
84688
86992
  internalProps.handler?.release?.();
84689
86993
  this.eventManager.release();
86994
+ this.stateManager.release();
84690
86995
  internalProps.focusControl?.release?.();
84691
86996
  internalProps.legends?.forEach(legend => {
84692
86997
  legend?.release();
@@ -85076,7 +87381,7 @@
85076
87381
  this.stateManager.updateInteractionState(InteractionState.grabing);
85077
87382
  this.stateManager.updateSelectPos(endCol, endRow, false, index >= 1, false, this.options.select?.makeSelectCellVisible ?? true, true);
85078
87383
  }
85079
- this.stateManager.endSelectCells(false, false);
87384
+ this.stateManager.endSelectCells(false, false, index === cellRanges.length - 1);
85080
87385
  this.stateManager.updateInteractionState(InteractionState.default);
85081
87386
  });
85082
87387
  this.setScrollTop(scrollTop);
@@ -101433,6 +103738,7 @@
101433
103738
  });
101434
103739
  if (findedCellIdPath) {
101435
103740
  row = this._rowHeaderCellIds.indexOf(findedCellIdPath) + this.columnHeaderLevelCount;
103741
+ defaultCol = findedCellIdPath.length - 1 + this.leftRowSeriesNumberColumnCount;
101436
103742
  }
101437
103743
  }
101438
103744
  else {