@prolibu-suite/cobalt-core 0.1.2 → 0.2.0

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 (555) hide show
  1. package/custom-elements.json +15359 -5571
  2. package/dist/cjs/co-accordion.cjs.entry.js +19 -4
  3. package/dist/cjs/co-app-shell.cjs.entry.js +1 -1
  4. package/dist/cjs/co-autocomplete.cjs.entry.js +51 -6
  5. package/dist/cjs/co-avatar.cjs.entry.js +40 -7
  6. package/dist/cjs/co-badge.cjs.entry.js +1 -1
  7. package/dist/cjs/co-button-group.cjs.entry.js +1 -1
  8. package/dist/cjs/co-button.cjs.entry.js +10 -5
  9. package/dist/cjs/co-calendar_3.cjs.entry.js +692 -0
  10. package/dist/cjs/co-card.cjs.entry.js +21 -4
  11. package/dist/cjs/co-checkbox-group.cjs.entry.js +7 -5
  12. package/dist/cjs/co-checkbox.cjs.entry.js +4 -4
  13. package/dist/cjs/co-chip.cjs.entry.js +3 -3
  14. package/dist/cjs/co-color-picker.cjs.entry.js +109 -0
  15. package/dist/cjs/co-column-picker.cjs.entry.js +443 -0
  16. package/dist/cjs/co-combobox.cjs.entry.js +51 -15
  17. package/dist/cjs/co-command-search.cjs.entry.js +14 -7
  18. package/dist/cjs/co-data-table-pagination.cjs.entry.js +5 -5
  19. package/dist/cjs/co-data-table.cjs.entry.js +17 -5
  20. package/dist/cjs/co-date-picker.cjs.entry.js +177 -0
  21. package/dist/cjs/co-date-range-picker.cjs.entry.js +378 -0
  22. package/dist/cjs/co-date-range.cjs.entry.js +13 -259
  23. package/dist/cjs/co-empty-state.cjs.entry.js +2 -2
  24. package/dist/cjs/co-fab.cjs.entry.js +3 -3
  25. package/dist/cjs/co-file-field.cjs.entry.js +498 -0
  26. package/dist/cjs/co-helper-text.cjs.entry.js +3 -3
  27. package/dist/cjs/co-icon-button.cjs.entry.js +4 -4
  28. package/dist/cjs/co-icon.cjs.entry.js +7 -4
  29. package/dist/cjs/co-input.cjs.entry.js +13 -8
  30. package/dist/cjs/co-json-field.cjs.entry.js +109 -0
  31. package/dist/cjs/co-lightbox.cjs.entry.js +344 -0
  32. package/dist/cjs/co-list-item.cjs.entry.js +14 -4
  33. package/dist/cjs/co-loader.cjs.entry.js +1 -1
  34. package/dist/cjs/co-menu-divider.cjs.entry.js +2 -2
  35. package/dist/cjs/co-menu-item.cjs.entry.js +1 -1
  36. package/dist/cjs/co-menu.cjs.entry.js +2 -2
  37. package/dist/cjs/co-modal.cjs.entry.js +13 -3
  38. package/dist/cjs/co-navbar.cjs.entry.js +4 -4
  39. package/dist/cjs/co-number-field.cjs.entry.js +47 -11
  40. package/dist/cjs/co-overlay.cjs.entry.js +2 -2
  41. package/dist/cjs/co-page-header.cjs.entry.js +2 -2
  42. package/dist/cjs/co-phone-field.cjs.entry.js +376 -0
  43. package/dist/cjs/co-popover.cjs.entry.js +4 -4
  44. package/dist/cjs/co-progress-bar.cjs.entry.js +3 -3
  45. package/dist/cjs/co-progress-circle.cjs.entry.js +38 -0
  46. package/dist/cjs/co-radio-group.cjs.entry.js +7 -5
  47. package/dist/cjs/co-radio.cjs.entry.js +4 -4
  48. package/dist/cjs/co-rating.cjs.entry.js +4 -4
  49. package/dist/cjs/co-ref-field.cjs.entry.js +191 -21
  50. package/dist/cjs/co-rich-text-editor.cjs.entry.js +235 -0
  51. package/dist/cjs/co-rich-text-toolbar.cjs.entry.js +184 -0
  52. package/dist/cjs/co-rich-text-viewer.cjs.entry.js +82 -0
  53. package/dist/cjs/co-row.cjs.entry.js +3 -3
  54. package/dist/cjs/co-select.cjs.entry.js +119 -18
  55. package/dist/cjs/co-separator.cjs.entry.js +2 -2
  56. package/dist/cjs/co-sidebar-nav.cjs.entry.js +30 -5
  57. package/dist/cjs/co-sidebar.cjs.entry.js +3 -3
  58. package/dist/cjs/co-slider.cjs.entry.js +3 -3
  59. package/dist/cjs/co-switch.cjs.entry.js +9 -6
  60. package/dist/cjs/co-tab-group.cjs.entry.js +2 -2
  61. package/dist/cjs/co-tab.cjs.entry.js +3 -3
  62. package/dist/cjs/co-tags-field.cjs.entry.js +205 -0
  63. package/dist/cjs/co-textarea.cjs.entry.js +92 -0
  64. package/dist/cjs/co-toast.cjs.entry.js +2 -2
  65. package/dist/cjs/co-toggle-button-group.cjs.entry.js +7 -4
  66. package/dist/cjs/co-toggle-button.cjs.entry.js +4 -4
  67. package/dist/cjs/co-tooltip.cjs.entry.js +12 -6
  68. package/dist/cjs/co-transfer-list.cjs.entry.js +20 -6
  69. package/dist/cjs/cobalt.cjs.js +2 -2
  70. package/dist/cjs/dateI18n-BdiNAl0_.js +106 -0
  71. package/dist/cjs/dates-D8D-aS5d.js +432 -0
  72. package/dist/cjs/index-CaEJnpZe.js +27213 -0
  73. package/dist/cjs/{index-BEovErzl.js → index-DoFnrUVH.js} +79 -11
  74. package/dist/cjs/loader.cjs.js +2 -2
  75. package/dist/cjs/normalizeText-B-v-XPKf.js +96 -0
  76. package/dist/cjs/overlayScroll-ifzDNeyb.js +25 -0
  77. package/dist/cjs/overlayscrollbars-BlBHo2Xx.js +2842 -0
  78. package/dist/cjs/{positioning-DozpXyBd.js → positioning-DwHW399W.js} +40 -25
  79. package/dist/cjs/requiredMark-DA6y-4rp.js +16 -0
  80. package/dist/cjs/sanitizer-CjHZAkOm.js +1883 -0
  81. package/dist/cobalt/cobalt.css +1 -1
  82. package/dist/cobalt/cobalt.esm.js +1 -1
  83. package/dist/cobalt/{p-1021f612.entry.js → p-01fc77c4.entry.js} +1 -1
  84. package/dist/cobalt/p-0a6d8061.entry.js +1 -0
  85. package/dist/cobalt/{p-ff6a647c.entry.js → p-0bf288cd.entry.js} +1 -1
  86. package/dist/cobalt/p-136bdbd2.entry.js +1 -0
  87. package/dist/cobalt/{p-1b7d6808.entry.js → p-15708d32.entry.js} +1 -1
  88. package/dist/cobalt/{p-cc93ab05.entry.js → p-1578b019.entry.js} +1 -1
  89. package/dist/cobalt/{p-1b5c723a.entry.js → p-1e0282b8.entry.js} +1 -1
  90. package/dist/cobalt/p-23d48581.entry.js +1 -0
  91. package/dist/cobalt/p-2718ff27.entry.js +1 -0
  92. package/dist/cobalt/p-273afd93.entry.js +1 -0
  93. package/dist/cobalt/{p-c9b0e73f.entry.js → p-2b4d8535.entry.js} +1 -1
  94. package/dist/cobalt/p-3190d715.entry.js +1 -0
  95. package/dist/cobalt/p-3f9b3fcb.entry.js +1 -0
  96. package/dist/cobalt/p-41228dce.entry.js +1 -0
  97. package/dist/cobalt/{p-5a13e3a0.entry.js → p-44672953.entry.js} +1 -1
  98. package/dist/cobalt/{p-4cf6d1f4.entry.js → p-522fcdb7.entry.js} +1 -1
  99. package/dist/cobalt/p-53ce9023.entry.js +1 -0
  100. package/dist/cobalt/{p-4d8ff00a.entry.js → p-54f26e95.entry.js} +1 -1
  101. package/dist/cobalt/p-5d01bd4d.entry.js +1 -0
  102. package/dist/cobalt/p-5e7141aa.entry.js +1 -0
  103. package/dist/cobalt/p-5f905739.entry.js +1 -0
  104. package/dist/cobalt/{p-fb047df8.entry.js → p-6404bd21.entry.js} +1 -1
  105. package/dist/cobalt/p-654bbc2a.entry.js +1 -0
  106. package/dist/cobalt/p-6678ac0a.entry.js +1 -0
  107. package/dist/cobalt/{p-e808916c.entry.js → p-66a912dd.entry.js} +1 -1
  108. package/dist/cobalt/p-6759ee1c.entry.js +1 -0
  109. package/dist/cobalt/p-69a40bfd.entry.js +1 -0
  110. package/dist/cobalt/p-6a6a62cb.entry.js +1 -0
  111. package/dist/cobalt/p-6d43b6cd.entry.js +1 -0
  112. package/dist/cobalt/p-759c3dd0.entry.js +1 -0
  113. package/dist/cobalt/p-782f729f.entry.js +1 -0
  114. package/dist/cobalt/{p-ebd1555e.entry.js → p-7ef766c6.entry.js} +1 -1
  115. package/dist/cobalt/p-7f818368.entry.js +1 -0
  116. package/dist/cobalt/p-83b89bf8.entry.js +1 -0
  117. package/dist/cobalt/p-88dc561a.entry.js +1 -0
  118. package/dist/cobalt/{p-4905b51d.entry.js → p-8c27aff7.entry.js} +1 -1
  119. package/dist/cobalt/{p-a7fa4484.entry.js → p-95d14878.entry.js} +1 -1
  120. package/dist/cobalt/{p-1d7da33f.entry.js → p-97c20011.entry.js} +1 -1
  121. package/dist/cobalt/p-996179f7.entry.js +1 -0
  122. package/dist/cobalt/p-9c533830.entry.js +1 -0
  123. package/dist/cobalt/p-9d89bf47.entry.js +1 -0
  124. package/dist/cobalt/p-BKmfyPZK.js +2 -0
  125. package/dist/cobalt/p-BchB6Hdr.js +1 -0
  126. package/dist/cobalt/p-C1DCLOEl.js +1 -0
  127. package/dist/cobalt/p-C2mZ7x_Y.js +1 -0
  128. package/dist/cobalt/p-CQY6Ul7q.js +1 -0
  129. package/dist/cobalt/p-CyYF8IJE.js +1 -0
  130. package/dist/cobalt/p-DcK0GGZC.js +2 -0
  131. package/dist/cobalt/p-DqyWGweA.js +1 -0
  132. package/dist/cobalt/p-Qqq8fysz.js +1 -0
  133. package/dist/cobalt/p-aa17c70b.entry.js +1 -0
  134. package/dist/cobalt/{p-416bb5ae.entry.js → p-aa63812a.entry.js} +1 -1
  135. package/dist/cobalt/p-ad4c1b41.entry.js +1 -0
  136. package/dist/cobalt/p-ae4d3207.entry.js +1 -0
  137. package/dist/cobalt/p-af64da37.entry.js +1 -0
  138. package/dist/cobalt/p-b758c2e6.entry.js +1 -0
  139. package/dist/cobalt/p-bb07da22.entry.js +1 -0
  140. package/dist/cobalt/p-beb9c11d.entry.js +1 -0
  141. package/dist/cobalt/p-c6a242e4.entry.js +1 -0
  142. package/dist/cobalt/p-c87285b6.entry.js +1 -0
  143. package/dist/cobalt/p-cd57e8b4.entry.js +1 -0
  144. package/dist/cobalt/{p-4ffba5a3.entry.js → p-ce3a535f.entry.js} +1 -1
  145. package/dist/cobalt/p-d17e1444.entry.js +1 -0
  146. package/dist/cobalt/p-d958566a.entry.js +1 -0
  147. package/dist/cobalt/p-dd873bf8.entry.js +1 -0
  148. package/dist/cobalt/p-def448e4.entry.js +1 -0
  149. package/dist/cobalt/p-e4de8865.entry.js +1 -0
  150. package/dist/cobalt/{p-3b2f7959.entry.js → p-e8b58332.entry.js} +1 -1
  151. package/dist/cobalt/p-eba0bf7f.entry.js +1 -0
  152. package/dist/cobalt/p-f0e8fa7d.entry.js +1 -0
  153. package/dist/cobalt/{p-e50c4c6f.entry.js → p-f2c5cb74.entry.js} +1 -1
  154. package/dist/cobalt/p-f8728b21.entry.js +1 -0
  155. package/dist/cobalt/{p-697df797.entry.js → p-f97ad9ad.entry.js} +1 -1
  156. package/dist/cobalt/p-fad3605d.entry.js +1 -0
  157. package/dist/cobalt/{p-319937c3.entry.js → p-fe9e85b6.entry.js} +1 -1
  158. package/dist/cobalt/p-ff2690e5.entry.js +1 -0
  159. package/dist/cobalt/p-ox7HzCZn.js +10 -0
  160. package/dist/collection/collection-manifest.json +17 -1
  161. package/dist/collection/components/co-accordion/co-accordion.css +19 -1
  162. package/dist/collection/components/co-accordion/co-accordion.js +46 -4
  163. package/dist/collection/components/co-autocomplete/co-autocomplete.css +725 -7
  164. package/dist/collection/components/co-autocomplete/co-autocomplete.js +88 -4
  165. package/dist/collection/components/co-avatar/co-avatar.css +7 -0
  166. package/dist/collection/components/co-avatar/co-avatar.js +35 -6
  167. package/dist/collection/components/co-button/co-button.css +8 -5
  168. package/dist/collection/components/co-button/co-button.js +46 -3
  169. package/dist/collection/components/co-calendar/co-calendar.css +236 -0
  170. package/dist/collection/components/co-calendar/co-calendar.js +728 -0
  171. package/dist/collection/components/co-card/co-card.css +28 -5
  172. package/dist/collection/components/co-card/co-card.js +47 -4
  173. package/dist/collection/components/co-checkbox/co-checkbox.js +3 -3
  174. package/dist/collection/components/co-checkbox-group/co-checkbox-group.css +26 -0
  175. package/dist/collection/components/co-checkbox-group/co-checkbox-group.js +25 -3
  176. package/dist/collection/components/co-chip/co-chip.js +2 -2
  177. package/dist/collection/components/co-color-picker/co-color-picker.css +224 -0
  178. package/dist/collection/components/co-color-picker/co-color-picker.js +333 -0
  179. package/dist/collection/components/co-color-picker/presets.js +19 -0
  180. package/dist/collection/components/co-column-picker/co-column-picker.css +490 -0
  181. package/dist/collection/components/co-column-picker/co-column-picker.js +675 -0
  182. package/dist/collection/components/co-column-picker/column-picker-node.js +34 -0
  183. package/dist/collection/components/co-column-picker/utils/column-picker-tree.js +221 -0
  184. package/dist/collection/components/co-combobox/co-combobox.css +788 -21
  185. package/dist/collection/components/co-combobox/co-combobox.js +130 -15
  186. package/dist/collection/components/co-command-search/co-command-search.css +4 -0
  187. package/dist/collection/components/co-command-search/co-command-search.js +12 -5
  188. package/dist/collection/components/co-data-table/co-data-table.css +1 -1
  189. package/dist/collection/components/co-data-table/co-data-table.js +15 -3
  190. package/dist/collection/components/co-data-table-pagination/co-data-table-pagination.js +4 -4
  191. package/dist/collection/components/co-date-field/co-date-field.css +239 -0
  192. package/dist/collection/components/co-date-field/co-date-field.js +746 -0
  193. package/dist/collection/components/co-date-picker/co-date-picker.css +112 -0
  194. package/dist/collection/components/co-date-picker/co-date-picker.js +801 -0
  195. package/dist/collection/components/co-date-range/co-date-range.css +3 -254
  196. package/dist/collection/components/co-date-range/co-date-range.js +29 -433
  197. package/dist/collection/components/co-date-range-picker/co-date-range-picker.css +251 -0
  198. package/dist/collection/components/co-date-range-picker/co-date-range-picker.js +1142 -0
  199. package/dist/collection/components/co-drawer/co-drawer.css +19 -0
  200. package/dist/collection/components/co-drawer/co-drawer.js +46 -2
  201. package/dist/collection/components/co-empty-state/co-empty-state.js +1 -1
  202. package/dist/collection/components/co-fab/co-fab.js +2 -2
  203. package/dist/collection/components/co-file-field/co-file-field.css +389 -0
  204. package/dist/collection/components/co-file-field/co-file-field.js +841 -0
  205. package/dist/collection/components/co-file-field/co-file-field.utils.js +47 -0
  206. package/dist/collection/components/co-helper-text/co-helper-text.js +2 -2
  207. package/dist/collection/components/co-icon/co-icon.js +6 -3
  208. package/dist/collection/components/co-icon-button/co-icon-button.css +10 -0
  209. package/dist/collection/components/co-icon-button/co-icon-button.js +4 -4
  210. package/dist/collection/components/co-input/co-input.css +56 -10
  211. package/dist/collection/components/co-input/co-input.js +34 -9
  212. package/dist/collection/components/co-json-field/co-json-field.css +169 -0
  213. package/dist/collection/components/co-json-field/co-json-field.js +453 -0
  214. package/dist/collection/components/co-lightbox/co-lightbox.css +164 -0
  215. package/dist/collection/components/co-lightbox/co-lightbox.js +451 -0
  216. package/dist/collection/components/co-list-item/co-list-item.css +5 -0
  217. package/dist/collection/components/co-list-item/co-list-item.js +12 -2
  218. package/dist/collection/components/co-menu/co-menu.js +1 -1
  219. package/dist/collection/components/co-menu-divider/co-menu-divider.js +1 -1
  220. package/dist/collection/components/co-modal/co-modal.css +17 -3
  221. package/dist/collection/components/co-modal/co-modal.js +51 -1
  222. package/dist/collection/components/co-navbar/co-navbar.css +1 -1
  223. package/dist/collection/components/co-navbar/co-navbar.js +2 -2
  224. package/dist/collection/components/co-number-field/co-number-field.css +70 -0
  225. package/dist/collection/components/co-number-field/co-number-field.js +143 -13
  226. package/dist/collection/components/co-overlay/co-overlay.js +1 -1
  227. package/dist/collection/components/co-page-header/co-page-header.js +1 -1
  228. package/dist/collection/components/co-phone-field/co-phone-field.css +265 -0
  229. package/dist/collection/components/co-phone-field/co-phone-field.js +392 -0
  230. package/dist/collection/components/co-phone-field/dial-codes.js +208 -0
  231. package/dist/collection/components/co-popover/co-popover.js +2 -2
  232. package/dist/collection/components/co-progress-bar/co-progress-bar.js +2 -2
  233. package/dist/collection/components/co-progress-circle/co-progress-circle.css +50 -0
  234. package/dist/collection/components/co-progress-circle/co-progress-circle.js +148 -0
  235. package/dist/collection/components/co-radio/co-radio.js +3 -3
  236. package/dist/collection/components/co-radio-group/co-radio-group.css +26 -0
  237. package/dist/collection/components/co-radio-group/co-radio-group.js +25 -3
  238. package/dist/collection/components/co-rating/co-rating.js +3 -3
  239. package/dist/collection/components/co-ref-field/co-ref-field.css +816 -54
  240. package/dist/collection/components/co-ref-field/co-ref-field.js +0 -0
  241. package/dist/collection/components/co-rich-text-editor/co-rich-text-editor.css +238 -0
  242. package/dist/collection/components/co-rich-text-editor/co-rich-text-editor.js +868 -0
  243. package/dist/collection/components/co-rich-text-toolbar/co-rich-text-toolbar.css +55 -0
  244. package/dist/collection/components/co-rich-text-toolbar/co-rich-text-toolbar.js +289 -0
  245. package/dist/collection/components/co-rich-text-viewer/co-rich-text-viewer.css +78 -0
  246. package/dist/collection/components/co-rich-text-viewer/co-rich-text-viewer.js +232 -0
  247. package/dist/collection/components/co-row/co-row.js +2 -2
  248. package/dist/collection/components/co-select/co-select.css +845 -7
  249. package/dist/collection/components/co-select/co-select.js +240 -17
  250. package/dist/collection/components/co-separator/co-separator.js +1 -1
  251. package/dist/collection/components/co-sidebar/co-sidebar.js +2 -2
  252. package/dist/collection/components/co-sidebar-nav/co-sidebar-nav.js +29 -4
  253. package/dist/collection/components/co-slider/co-slider.js +2 -2
  254. package/dist/collection/components/co-switch/co-switch.css +17 -0
  255. package/dist/collection/components/co-switch/co-switch.js +27 -4
  256. package/dist/collection/components/co-tab/co-tab.js +2 -2
  257. package/dist/collection/components/co-tab-group/co-tab-group.js +1 -1
  258. package/dist/collection/components/co-tags-field/co-tags-field.css +272 -0
  259. package/dist/collection/components/co-tags-field/co-tags-field.js +590 -0
  260. package/dist/collection/components/co-textarea/co-textarea.css +261 -0
  261. package/dist/collection/components/co-textarea/co-textarea.js +484 -0
  262. package/dist/collection/components/co-toast/co-toast.js +1 -1
  263. package/dist/collection/components/co-toggle-button/co-toggle-button.css +6 -4
  264. package/dist/collection/components/co-toggle-button/co-toggle-button.js +2 -2
  265. package/dist/collection/components/co-toggle-button-group/co-toggle-button-group.css +16 -0
  266. package/dist/collection/components/co-toggle-button-group/co-toggle-button-group.js +25 -2
  267. package/dist/collection/components/co-tooltip/co-tooltip.css +16 -0
  268. package/dist/collection/components/co-tooltip/co-tooltip.js +9 -3
  269. package/dist/collection/components/co-transfer-list/co-transfer-list.css +683 -7
  270. package/dist/collection/components/co-transfer-list/co-transfer-list.js +17 -4
  271. package/dist/collection/utils/dateI18n.js +101 -0
  272. package/dist/collection/utils/fileI18n.js +76 -0
  273. package/dist/collection/utils/icon-config.js +22 -0
  274. package/dist/collection/utils/lightboxI18n.js +42 -0
  275. package/dist/collection/utils/normalizeText.js +94 -0
  276. package/dist/collection/utils/overlayScroll.js +20 -0
  277. package/dist/collection/utils/positioning.js +40 -25
  278. package/dist/collection/utils/requiredMark.js +11 -0
  279. package/dist/components/co-accordion.js +1 -1
  280. package/dist/components/co-autocomplete.js +1 -1
  281. package/dist/components/co-avatar.js +1 -1
  282. package/dist/components/co-button.js +1 -1
  283. package/dist/components/co-calendar.d.ts +11 -0
  284. package/dist/components/co-calendar.js +1 -0
  285. package/dist/components/co-card.js +1 -1
  286. package/dist/components/co-checkbox-group.js +1 -1
  287. package/dist/components/co-checkbox.js +1 -1
  288. package/dist/components/co-chip.js +1 -1
  289. package/dist/components/co-color-picker.d.ts +11 -0
  290. package/dist/components/co-color-picker.js +1 -0
  291. package/dist/components/co-column-picker.d.ts +11 -0
  292. package/dist/components/co-column-picker.js +1 -0
  293. package/dist/components/co-combobox.js +1 -1
  294. package/dist/components/co-command-search.js +1 -1
  295. package/dist/components/co-data-table-pagination.js +1 -1
  296. package/dist/components/co-data-table.js +1 -1
  297. package/dist/components/co-date-field.d.ts +11 -0
  298. package/dist/components/co-date-field.js +1 -0
  299. package/dist/components/co-date-picker.d.ts +11 -0
  300. package/dist/components/co-date-picker.js +1 -0
  301. package/dist/components/co-date-range-picker.d.ts +11 -0
  302. package/dist/components/co-date-range-picker.js +1 -0
  303. package/dist/components/co-date-range.js +1 -1
  304. package/dist/components/co-drawer.js +1 -1
  305. package/dist/components/co-empty-state.js +1 -1
  306. package/dist/components/co-fab.js +1 -1
  307. package/dist/components/co-file-field.d.ts +11 -0
  308. package/dist/components/co-file-field.js +1 -0
  309. package/dist/components/co-helper-text.js +1 -1
  310. package/dist/components/co-icon-button.js +1 -1
  311. package/dist/components/co-icon.js +1 -1
  312. package/dist/components/co-input.js +1 -1
  313. package/dist/components/co-json-field.d.ts +11 -0
  314. package/dist/components/co-json-field.js +1 -0
  315. package/dist/components/co-lightbox.d.ts +11 -0
  316. package/dist/components/co-lightbox.js +1 -0
  317. package/dist/components/co-list-item.js +1 -1
  318. package/dist/components/co-menu-divider.js +1 -1
  319. package/dist/components/co-menu-item.js +1 -1
  320. package/dist/components/co-menu.js +1 -1
  321. package/dist/components/co-modal.js +1 -1
  322. package/dist/components/co-navbar.js +1 -1
  323. package/dist/components/co-number-field.js +1 -1
  324. package/dist/components/co-overlay.js +1 -1
  325. package/dist/components/co-page-header.js +1 -1
  326. package/dist/components/co-phone-field.d.ts +11 -0
  327. package/dist/components/co-phone-field.js +1 -0
  328. package/dist/components/co-popover.js +1 -1
  329. package/dist/components/co-progress-bar.js +1 -1
  330. package/dist/components/co-progress-circle.d.ts +11 -0
  331. package/dist/components/co-progress-circle.js +1 -0
  332. package/dist/components/co-radio-group.js +1 -1
  333. package/dist/components/co-radio.js +1 -1
  334. package/dist/components/co-rating.js +1 -1
  335. package/dist/components/co-ref-field.js +1 -1
  336. package/dist/components/co-rich-text-editor.d.ts +11 -0
  337. package/dist/components/co-rich-text-editor.js +1 -0
  338. package/dist/components/co-rich-text-toolbar.d.ts +11 -0
  339. package/dist/components/co-rich-text-toolbar.js +1 -0
  340. package/dist/components/co-rich-text-viewer.d.ts +11 -0
  341. package/dist/components/co-rich-text-viewer.js +1 -0
  342. package/dist/components/co-row.js +1 -1
  343. package/dist/components/co-select.js +1 -1
  344. package/dist/components/co-separator.js +1 -1
  345. package/dist/components/co-sidebar-nav.js +1 -1
  346. package/dist/components/co-sidebar.js +1 -1
  347. package/dist/components/co-slider.js +1 -1
  348. package/dist/components/co-switch.js +1 -1
  349. package/dist/components/co-tab-group.js +1 -1
  350. package/dist/components/co-tab.js +1 -1
  351. package/dist/components/co-tags-field.d.ts +11 -0
  352. package/dist/components/co-tags-field.js +1 -0
  353. package/dist/components/co-textarea.d.ts +11 -0
  354. package/dist/components/co-textarea.js +1 -0
  355. package/dist/components/co-toast.js +1 -1
  356. package/dist/components/co-toggle-button-group.js +1 -1
  357. package/dist/components/co-toggle-button.js +1 -1
  358. package/dist/components/co-tooltip.js +1 -1
  359. package/dist/components/co-transfer-list.js +1 -1
  360. package/dist/components/index.js +1 -1
  361. package/dist/components/{p-FBICWTuN.js → p-BXdfh__-.js} +1 -1
  362. package/dist/components/p-BchB6Hdr.js +1 -0
  363. package/dist/components/p-BeWXpX8I.js +1 -0
  364. package/dist/components/p-BiW0ubLs.js +1 -0
  365. package/dist/components/p-C1DCLOEl.js +1 -0
  366. package/dist/components/p-C2mZ7x_Y.js +1 -0
  367. package/dist/components/p-C9tHLXKS.js +1 -0
  368. package/dist/components/p-CQY6Ul7q.js +1 -0
  369. package/dist/components/p-CWneqh4n.js +1 -0
  370. package/dist/components/{p-B18FTYLq.js → p-CaMgu2_g.js} +1 -1
  371. package/dist/components/p-CyYF8IJE.js +1 -0
  372. package/dist/components/p-DBhNS7JD.js +1 -0
  373. package/dist/components/p-DObrQi5F.js +1 -0
  374. package/dist/components/p-DPi_U-Kl.js +1 -0
  375. package/dist/components/p-DcK0GGZC.js +2 -0
  376. package/dist/components/p-DqyWGweA.js +1 -0
  377. package/dist/components/{p-cpdUXBiS.js → p-MiSJXuBx.js} +1 -1
  378. package/dist/components/p-Sgn-2g8m.js +1 -0
  379. package/dist/components/{p-Cr8Yc0zj.js → p-jDjfGZJp.js} +1 -1
  380. package/dist/components/p-o8hrDIKe.js +1 -0
  381. package/dist/components/p-ox7HzCZn.js +10 -0
  382. package/dist/esm/co-accordion.entry.js +19 -4
  383. package/dist/esm/co-app-shell.entry.js +1 -1
  384. package/dist/esm/co-autocomplete.entry.js +51 -6
  385. package/dist/esm/co-avatar.entry.js +39 -6
  386. package/dist/esm/co-badge.entry.js +1 -1
  387. package/dist/esm/co-button-group.entry.js +1 -1
  388. package/dist/esm/co-button.entry.js +10 -5
  389. package/dist/esm/co-calendar_3.entry.js +688 -0
  390. package/dist/esm/co-card.entry.js +21 -4
  391. package/dist/esm/co-checkbox-group.entry.js +7 -5
  392. package/dist/esm/co-checkbox.entry.js +4 -4
  393. package/dist/esm/co-chip.entry.js +3 -3
  394. package/dist/esm/co-color-picker.entry.js +107 -0
  395. package/dist/esm/co-column-picker.entry.js +441 -0
  396. package/dist/esm/co-combobox.entry.js +51 -15
  397. package/dist/esm/co-command-search.entry.js +14 -7
  398. package/dist/esm/co-data-table-pagination.entry.js +5 -5
  399. package/dist/esm/co-data-table.entry.js +17 -5
  400. package/dist/esm/co-date-picker.entry.js +175 -0
  401. package/dist/esm/co-date-range-picker.entry.js +376 -0
  402. package/dist/esm/co-date-range.entry.js +13 -259
  403. package/dist/esm/co-empty-state.entry.js +2 -2
  404. package/dist/esm/co-fab.entry.js +3 -3
  405. package/dist/esm/co-file-field.entry.js +496 -0
  406. package/dist/esm/co-helper-text.entry.js +3 -3
  407. package/dist/esm/co-icon-button.entry.js +4 -4
  408. package/dist/esm/co-icon.entry.js +7 -4
  409. package/dist/esm/co-input.entry.js +13 -8
  410. package/dist/esm/co-json-field.entry.js +107 -0
  411. package/dist/esm/co-lightbox.entry.js +342 -0
  412. package/dist/esm/co-list-item.entry.js +14 -4
  413. package/dist/esm/co-loader.entry.js +1 -1
  414. package/dist/esm/co-menu-divider.entry.js +2 -2
  415. package/dist/esm/co-menu-item.entry.js +1 -1
  416. package/dist/esm/co-menu.entry.js +2 -2
  417. package/dist/esm/co-modal.entry.js +13 -3
  418. package/dist/esm/co-navbar.entry.js +4 -4
  419. package/dist/esm/co-number-field.entry.js +47 -11
  420. package/dist/esm/co-overlay.entry.js +2 -2
  421. package/dist/esm/co-page-header.entry.js +2 -2
  422. package/dist/esm/co-phone-field.entry.js +374 -0
  423. package/dist/esm/co-popover.entry.js +4 -4
  424. package/dist/esm/co-progress-bar.entry.js +3 -3
  425. package/dist/esm/co-progress-circle.entry.js +36 -0
  426. package/dist/esm/co-radio-group.entry.js +7 -5
  427. package/dist/esm/co-radio.entry.js +4 -4
  428. package/dist/esm/co-rating.entry.js +4 -4
  429. package/dist/esm/co-ref-field.entry.js +191 -21
  430. package/dist/esm/co-rich-text-editor.entry.js +233 -0
  431. package/dist/esm/co-rich-text-toolbar.entry.js +182 -0
  432. package/dist/esm/co-rich-text-viewer.entry.js +80 -0
  433. package/dist/esm/co-row.entry.js +3 -3
  434. package/dist/esm/co-select.entry.js +119 -18
  435. package/dist/esm/co-separator.entry.js +2 -2
  436. package/dist/esm/co-sidebar-nav.entry.js +30 -5
  437. package/dist/esm/co-sidebar.entry.js +3 -3
  438. package/dist/esm/co-slider.entry.js +3 -3
  439. package/dist/esm/co-switch.entry.js +9 -6
  440. package/dist/esm/co-tab-group.entry.js +2 -2
  441. package/dist/esm/co-tab.entry.js +3 -3
  442. package/dist/esm/co-tags-field.entry.js +203 -0
  443. package/dist/esm/co-textarea.entry.js +90 -0
  444. package/dist/esm/co-toast.entry.js +2 -2
  445. package/dist/esm/co-toggle-button-group.entry.js +7 -4
  446. package/dist/esm/co-toggle-button.entry.js +4 -4
  447. package/dist/esm/co-tooltip.entry.js +12 -6
  448. package/dist/esm/co-transfer-list.entry.js +20 -6
  449. package/dist/esm/cobalt.js +3 -3
  450. package/dist/esm/dateI18n-C1DCLOEl.js +103 -0
  451. package/dist/esm/dates-CyYF8IJE.js +416 -0
  452. package/dist/esm/{index-B0lqrhFo.js → index-BKmfyPZK.js} +79 -11
  453. package/dist/esm/index-BjAqSidM.js +27200 -0
  454. package/dist/esm/loader.js +3 -3
  455. package/dist/esm/normalizeText-CQY6Ul7q.js +92 -0
  456. package/dist/esm/overlayScroll-Bpv882_z.js +23 -0
  457. package/dist/esm/overlayscrollbars-ox7HzCZn.js +2840 -0
  458. package/dist/esm/{positioning-Am-OlB8h.js → positioning-C2mZ7x_Y.js} +40 -25
  459. package/dist/esm/requiredMark-DFvtYtkE.js +14 -0
  460. package/dist/esm/sanitizer-DcK0GGZC.js +1880 -0
  461. package/dist/types/components/co-accordion/co-accordion.d.ts +12 -2
  462. package/dist/types/components/co-autocomplete/co-autocomplete.d.ts +11 -0
  463. package/dist/types/components/co-avatar/co-avatar.d.ts +6 -2
  464. package/dist/types/components/co-button/co-button.d.ts +4 -0
  465. package/dist/types/components/co-calendar/co-calendar.d.ts +108 -0
  466. package/dist/types/components/co-card/co-card.d.ts +10 -2
  467. package/dist/types/components/co-checkbox-group/co-checkbox-group.d.ts +2 -0
  468. package/dist/types/components/co-color-picker/co-color-picker.d.ts +48 -0
  469. package/dist/types/components/co-color-picker/presets.d.ts +10 -0
  470. package/dist/types/components/co-column-picker/co-column-picker.d.ts +60 -0
  471. package/dist/types/components/co-column-picker/column-picker-node.d.ts +18 -0
  472. package/dist/types/components/co-column-picker/utils/column-picker-tree.d.ts +37 -0
  473. package/dist/types/components/co-combobox/co-combobox.d.ts +14 -1
  474. package/dist/types/components/co-command-search/co-command-search.d.ts +2 -0
  475. package/dist/types/components/co-data-table/co-data-table.d.ts +1 -0
  476. package/dist/types/components/co-date-field/co-date-field.d.ts +96 -0
  477. package/dist/types/components/co-date-picker/co-date-picker.d.ts +92 -0
  478. package/dist/types/components/co-date-range/co-date-range.d.ts +12 -50
  479. package/dist/types/components/co-date-range-picker/co-date-range-picker.d.ts +112 -0
  480. package/dist/types/components/co-drawer/co-drawer.d.ts +4 -0
  481. package/dist/types/components/co-file-field/co-file-field.d.ts +146 -0
  482. package/dist/types/components/co-file-field/co-file-field.utils.d.ts +18 -0
  483. package/dist/types/components/co-icon-button/co-icon-button.d.ts +1 -1
  484. package/dist/types/components/co-input/co-input.d.ts +4 -1
  485. package/dist/types/components/co-json-field/co-json-field.d.ts +66 -0
  486. package/dist/types/components/co-lightbox/co-lightbox.d.ts +95 -0
  487. package/dist/types/components/co-list-item/co-list-item.d.ts +1 -0
  488. package/dist/types/components/co-modal/co-modal.d.ts +4 -0
  489. package/dist/types/components/co-number-field/co-number-field.d.ts +16 -2
  490. package/dist/types/components/co-phone-field/co-phone-field.d.ts +56 -0
  491. package/dist/types/components/co-phone-field/dial-codes.d.ts +14 -0
  492. package/dist/types/components/co-progress-circle/co-progress-circle.d.ts +16 -0
  493. package/dist/types/components/co-radio-group/co-radio-group.d.ts +2 -0
  494. package/dist/types/components/co-ref-field/co-ref-field.d.ts +54 -1
  495. package/dist/types/components/co-rich-text-editor/co-rich-text-editor.d.ts +94 -0
  496. package/dist/types/components/co-rich-text-toolbar/co-rich-text-toolbar.d.ts +42 -0
  497. package/dist/types/components/co-rich-text-viewer/co-rich-text-viewer.d.ts +32 -0
  498. package/dist/types/components/co-select/co-select.d.ts +31 -1
  499. package/dist/types/components/co-switch/co-switch.d.ts +2 -0
  500. package/dist/types/components/co-tags-field/co-tags-field.d.ts +82 -0
  501. package/dist/types/components/co-textarea/co-textarea.d.ts +65 -0
  502. package/dist/types/components/co-toggle-button-group/co-toggle-button-group.d.ts +2 -0
  503. package/dist/types/components/co-transfer-list/co-transfer-list.d.ts +4 -0
  504. package/dist/types/components.d.ts +3796 -422
  505. package/dist/types/utils/dateI18n.d.ts +39 -0
  506. package/dist/types/utils/fileI18n.d.ts +34 -0
  507. package/dist/types/utils/icon-config.d.ts +20 -0
  508. package/dist/types/utils/lightboxI18n.d.ts +12 -0
  509. package/dist/types/utils/normalizeText.d.ts +41 -0
  510. package/dist/types/utils/overlayScroll.d.ts +17 -0
  511. package/dist/types/utils/positioning.d.ts +7 -14
  512. package/dist/types/utils/requiredMark.d.ts +13 -0
  513. package/package.json +9 -1
  514. package/dist/cjs/co-drawer.cjs.entry.js +0 -75
  515. package/dist/cjs/color-YhUkm10t.js +0 -32
  516. package/dist/cobalt/p-08afdc51.entry.js +0 -1
  517. package/dist/cobalt/p-1d3338b6.entry.js +0 -1
  518. package/dist/cobalt/p-1d91ec93.entry.js +0 -1
  519. package/dist/cobalt/p-230a23f3.entry.js +0 -1
  520. package/dist/cobalt/p-31bc842d.entry.js +0 -1
  521. package/dist/cobalt/p-37c1f700.entry.js +0 -1
  522. package/dist/cobalt/p-4dd7499c.entry.js +0 -1
  523. package/dist/cobalt/p-4e7ce8ee.entry.js +0 -1
  524. package/dist/cobalt/p-6793c51e.entry.js +0 -1
  525. package/dist/cobalt/p-689e38b3.entry.js +0 -1
  526. package/dist/cobalt/p-7028880b.entry.js +0 -1
  527. package/dist/cobalt/p-72113ec2.entry.js +0 -1
  528. package/dist/cobalt/p-8e54e74d.entry.js +0 -1
  529. package/dist/cobalt/p-92c39eed.entry.js +0 -1
  530. package/dist/cobalt/p-9887b828.entry.js +0 -1
  531. package/dist/cobalt/p-9a5c6600.entry.js +0 -1
  532. package/dist/cobalt/p-Am-OlB8h.js +0 -1
  533. package/dist/cobalt/p-B0lqrhFo.js +0 -2
  534. package/dist/cobalt/p-BG4WRR22.js +0 -1
  535. package/dist/cobalt/p-a1b248ad.entry.js +0 -1
  536. package/dist/cobalt/p-a470b764.entry.js +0 -1
  537. package/dist/cobalt/p-a4d55b1a.entry.js +0 -1
  538. package/dist/cobalt/p-b6840df4.entry.js +0 -1
  539. package/dist/cobalt/p-b89d54d9.entry.js +0 -1
  540. package/dist/cobalt/p-ba84631a.entry.js +0 -1
  541. package/dist/cobalt/p-c7517f86.entry.js +0 -1
  542. package/dist/cobalt/p-ca41eec2.entry.js +0 -1
  543. package/dist/cobalt/p-d29c77cb.entry.js +0 -1
  544. package/dist/cobalt/p-d9d8b10e.entry.js +0 -1
  545. package/dist/cobalt/p-da55678f.entry.js +0 -1
  546. package/dist/cobalt/p-dc5598d1.entry.js +0 -1
  547. package/dist/cobalt/p-e2c9cb00.entry.js +0 -1
  548. package/dist/cobalt/p-ebd68f56.entry.js +0 -1
  549. package/dist/cobalt/p-f051f44d.entry.js +0 -1
  550. package/dist/cobalt/p-fe1447a3.entry.js +0 -1
  551. package/dist/components/p-Am-OlB8h.js +0 -1
  552. package/dist/components/p-BG4WRR22.js +0 -1
  553. package/dist/components/p-wwWquAtm.js +0 -1
  554. package/dist/esm/co-drawer.entry.js +0 -73
  555. package/dist/esm/color-BG4WRR22.js +0 -30
@@ -0,0 +1,1883 @@
1
+ 'use strict';
2
+
3
+ /*! @license DOMPurify 3.4.8 | (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.8/LICENSE */
4
+
5
+ function _arrayLikeToArray(r, a) {
6
+ (null == a || a > r.length) && (a = r.length);
7
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
8
+ return n;
9
+ }
10
+ function _arrayWithHoles(r) {
11
+ if (Array.isArray(r)) return r;
12
+ }
13
+ function _iterableToArrayLimit(r, l) {
14
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
15
+ if (null != t) {
16
+ var e,
17
+ n,
18
+ i,
19
+ u,
20
+ a = [],
21
+ f = true,
22
+ o = false;
23
+ try {
24
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true);
25
+ } catch (r) {
26
+ o = true, n = r;
27
+ } finally {
28
+ try {
29
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
30
+ } finally {
31
+ if (o) throw n;
32
+ }
33
+ }
34
+ return a;
35
+ }
36
+ }
37
+ function _nonIterableRest() {
38
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
39
+ }
40
+ function _slicedToArray(r, e) {
41
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
42
+ }
43
+ function _unsupportedIterableToArray(r, a) {
44
+ if (r) {
45
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
46
+ var t = {}.toString.call(r).slice(8, -1);
47
+ 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;
48
+ }
49
+ }
50
+
51
+ const entries = Object.entries,
52
+ setPrototypeOf = Object.setPrototypeOf,
53
+ isFrozen = Object.isFrozen,
54
+ getPrototypeOf = Object.getPrototypeOf,
55
+ getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
56
+ let freeze = Object.freeze,
57
+ seal = Object.seal,
58
+ create = Object.create; // eslint-disable-line import/no-mutable-exports
59
+ let _ref = typeof Reflect !== 'undefined' && Reflect,
60
+ apply = _ref.apply,
61
+ construct = _ref.construct;
62
+ if (!freeze) {
63
+ freeze = function freeze(x) {
64
+ return x;
65
+ };
66
+ }
67
+ if (!seal) {
68
+ seal = function seal(x) {
69
+ return x;
70
+ };
71
+ }
72
+ if (!apply) {
73
+ apply = function apply(func, thisArg) {
74
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
75
+ args[_key - 2] = arguments[_key];
76
+ }
77
+ return func.apply(thisArg, args);
78
+ };
79
+ }
80
+ if (!construct) {
81
+ construct = function construct(Func) {
82
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
83
+ args[_key2 - 1] = arguments[_key2];
84
+ }
85
+ return new Func(...args);
86
+ };
87
+ }
88
+ const arrayForEach = unapply(Array.prototype.forEach);
89
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
90
+ const arrayPop = unapply(Array.prototype.pop);
91
+ const arrayPush = unapply(Array.prototype.push);
92
+ const arraySplice = unapply(Array.prototype.splice);
93
+ const arrayIsArray = Array.isArray;
94
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
95
+ const stringToString = unapply(String.prototype.toString);
96
+ const stringMatch = unapply(String.prototype.match);
97
+ const stringReplace = unapply(String.prototype.replace);
98
+ const stringIndexOf = unapply(String.prototype.indexOf);
99
+ const stringTrim = unapply(String.prototype.trim);
100
+ const numberToString = unapply(Number.prototype.toString);
101
+ const booleanToString = unapply(Boolean.prototype.toString);
102
+ const bigintToString = typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);
103
+ const symbolToString = typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);
104
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
105
+ const objectToString = unapply(Object.prototype.toString);
106
+ const regExpTest = unapply(RegExp.prototype.test);
107
+ const typeErrorCreate = unconstruct(TypeError);
108
+ /**
109
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
110
+ *
111
+ * @param func - The function to be wrapped and called.
112
+ * @returns A new function that calls the given function with a specified thisArg and arguments.
113
+ */
114
+ function unapply(func) {
115
+ return function (thisArg) {
116
+ if (thisArg instanceof RegExp) {
117
+ thisArg.lastIndex = 0;
118
+ }
119
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
120
+ args[_key3 - 1] = arguments[_key3];
121
+ }
122
+ return apply(func, thisArg, args);
123
+ };
124
+ }
125
+ /**
126
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
127
+ *
128
+ * @param func - The constructor function to be wrapped and called.
129
+ * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
130
+ */
131
+ function unconstruct(Func) {
132
+ return function () {
133
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
134
+ args[_key4] = arguments[_key4];
135
+ }
136
+ return construct(Func, args);
137
+ };
138
+ }
139
+ /**
140
+ * Add properties to a lookup table
141
+ *
142
+ * @param set - The set to which elements will be added.
143
+ * @param array - The array containing elements to be added to the set.
144
+ * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
145
+ * @returns The modified set with added elements.
146
+ */
147
+ function addToSet(set, array) {
148
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
149
+ if (setPrototypeOf) {
150
+ // Make 'in' and truthy checks like Boolean(set.constructor)
151
+ // independent of any properties defined on Object.prototype.
152
+ // Prevent prototype setters from intercepting set as a this value.
153
+ setPrototypeOf(set, null);
154
+ }
155
+ if (!arrayIsArray(array)) {
156
+ return set;
157
+ }
158
+ let l = array.length;
159
+ while (l--) {
160
+ let element = array[l];
161
+ if (typeof element === 'string') {
162
+ const lcElement = transformCaseFunc(element);
163
+ if (lcElement !== element) {
164
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
165
+ if (!isFrozen(array)) {
166
+ array[l] = lcElement;
167
+ }
168
+ element = lcElement;
169
+ }
170
+ }
171
+ set[element] = true;
172
+ }
173
+ return set;
174
+ }
175
+ /**
176
+ * Clean up an array to harden against CSPP
177
+ *
178
+ * @param array - The array to be cleaned.
179
+ * @returns The cleaned version of the array
180
+ */
181
+ function cleanArray(array) {
182
+ for (let index = 0; index < array.length; index++) {
183
+ const isPropertyExist = objectHasOwnProperty(array, index);
184
+ if (!isPropertyExist) {
185
+ array[index] = null;
186
+ }
187
+ }
188
+ return array;
189
+ }
190
+ /**
191
+ * Shallow clone an object
192
+ *
193
+ * @param object - The object to be cloned.
194
+ * @returns A new object that copies the original.
195
+ */
196
+ function clone(object) {
197
+ const newObject = create(null);
198
+ for (const _ref2 of entries(object)) {
199
+ var _ref3 = _slicedToArray(_ref2, 2);
200
+ const property = _ref3[0];
201
+ const value = _ref3[1];
202
+ const isPropertyExist = objectHasOwnProperty(object, property);
203
+ if (isPropertyExist) {
204
+ if (arrayIsArray(value)) {
205
+ newObject[property] = cleanArray(value);
206
+ } else if (value && typeof value === 'object' && value.constructor === Object) {
207
+ newObject[property] = clone(value);
208
+ } else {
209
+ newObject[property] = value;
210
+ }
211
+ }
212
+ }
213
+ return newObject;
214
+ }
215
+ /**
216
+ * Convert non-node values into strings without depending on direct property access.
217
+ *
218
+ * @param value - The value to stringify.
219
+ * @returns A string representation of the provided value.
220
+ */
221
+ function stringifyValue(value) {
222
+ switch (typeof value) {
223
+ case 'string':
224
+ {
225
+ return value;
226
+ }
227
+ case 'number':
228
+ {
229
+ return numberToString(value);
230
+ }
231
+ case 'boolean':
232
+ {
233
+ return booleanToString(value);
234
+ }
235
+ case 'bigint':
236
+ {
237
+ return bigintToString ? bigintToString(value) : '0';
238
+ }
239
+ case 'symbol':
240
+ {
241
+ return symbolToString ? symbolToString(value) : 'Symbol()';
242
+ }
243
+ case 'undefined':
244
+ {
245
+ return objectToString(value);
246
+ }
247
+ case 'function':
248
+ case 'object':
249
+ {
250
+ if (value === null) {
251
+ return objectToString(value);
252
+ }
253
+ const valueAsRecord = value;
254
+ const valueToString = lookupGetter(valueAsRecord, 'toString');
255
+ if (typeof valueToString === 'function') {
256
+ const stringified = valueToString(valueAsRecord);
257
+ return typeof stringified === 'string' ? stringified : objectToString(stringified);
258
+ }
259
+ return objectToString(value);
260
+ }
261
+ default:
262
+ {
263
+ return objectToString(value);
264
+ }
265
+ }
266
+ }
267
+ /**
268
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
269
+ *
270
+ * @param object - The object to look up the getter function in its prototype chain.
271
+ * @param prop - The property name for which to find the getter function.
272
+ * @returns The getter function found in the prototype chain or a fallback function.
273
+ */
274
+ function lookupGetter(object, prop) {
275
+ while (object !== null) {
276
+ const desc = getOwnPropertyDescriptor(object, prop);
277
+ if (desc) {
278
+ if (desc.get) {
279
+ return unapply(desc.get);
280
+ }
281
+ if (typeof desc.value === 'function') {
282
+ return unapply(desc.value);
283
+ }
284
+ }
285
+ object = getPrototypeOf(object);
286
+ }
287
+ function fallbackValue() {
288
+ return null;
289
+ }
290
+ return fallbackValue;
291
+ }
292
+ function isRegex(value) {
293
+ try {
294
+ regExpTest(value, '');
295
+ return true;
296
+ } catch (_unused) {
297
+ return false;
298
+ }
299
+ }
300
+
301
+ 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']);
302
+ 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']);
303
+ 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']);
304
+ // List of SVG elements that are disallowed by default.
305
+ // We still need to know them so that we can do namespace
306
+ // checks properly in case one wants to add them to
307
+ // allow-list.
308
+ 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']);
309
+ 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']);
310
+ // Similarly to SVG, we want to know all MathML elements,
311
+ // even those that we disallow by default.
312
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
313
+ const text = freeze(['#text']);
314
+
315
+ 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']);
316
+ 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', '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', '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-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', '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']);
317
+ 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']);
318
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
319
+
320
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
321
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
322
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
323
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
324
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
325
+ const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
326
+ );
327
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
328
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
329
+ );
330
+ const DOCTYPE_NAME = seal(/^html$/i);
331
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
332
+
333
+ /* eslint-disable @typescript-eslint/indent */
334
+ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
335
+ const NODE_TYPE = {
336
+ element: 1,
337
+ text: 3,
338
+ // Deprecated
339
+ progressingInstruction: 7,
340
+ comment: 8,
341
+ document: 9,
342
+ documentFragment: 11};
343
+ const getGlobal = function getGlobal() {
344
+ return typeof window === 'undefined' ? null : window;
345
+ };
346
+ /**
347
+ * Creates a no-op policy for internal use only.
348
+ * Don't export this function outside this module!
349
+ * @param trustedTypes The policy factory.
350
+ * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
351
+ * @return The policy created (or null, if Trusted Types
352
+ * are not supported or creating the policy failed).
353
+ */
354
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
355
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
356
+ return null;
357
+ }
358
+ // Allow the callers to control the unique policy name
359
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
360
+ // Policy creation with duplicate names throws in Trusted Types.
361
+ let suffix = null;
362
+ const ATTR_NAME = 'data-tt-policy-suffix';
363
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
364
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
365
+ }
366
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
367
+ try {
368
+ return trustedTypes.createPolicy(policyName, {
369
+ createHTML(html) {
370
+ return html;
371
+ },
372
+ createScriptURL(scriptUrl) {
373
+ return scriptUrl;
374
+ }
375
+ });
376
+ } catch (_) {
377
+ // Policy creation failed (most likely another DOMPurify script has
378
+ // already run). Skip creating the policy, as this will only cause errors
379
+ // if TT are enforced.
380
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
381
+ return null;
382
+ }
383
+ };
384
+ const _createHooksMap = function _createHooksMap() {
385
+ return {
386
+ afterSanitizeAttributes: [],
387
+ afterSanitizeElements: [],
388
+ afterSanitizeShadowDOM: [],
389
+ beforeSanitizeAttributes: [],
390
+ beforeSanitizeElements: [],
391
+ beforeSanitizeShadowDOM: [],
392
+ uponSanitizeAttribute: [],
393
+ uponSanitizeElement: [],
394
+ uponSanitizeShadowNode: []
395
+ };
396
+ };
397
+ function createDOMPurify() {
398
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
399
+ const DOMPurify = root => createDOMPurify(root);
400
+ DOMPurify.version = '3.4.8';
401
+ DOMPurify.removed = [];
402
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
403
+ // Not running in a browser, provide a factory function
404
+ // so that you can pass your own Window
405
+ DOMPurify.isSupported = false;
406
+ return DOMPurify;
407
+ }
408
+ let document = window.document;
409
+ const originalDocument = document;
410
+ const currentScript = originalDocument.currentScript;
411
+ const HTMLTemplateElement = window.HTMLTemplateElement,
412
+ Node = window.Node,
413
+ Element = window.Element,
414
+ NodeFilter = window.NodeFilter;
415
+ const DOMParser = window.DOMParser,
416
+ trustedTypes = window.trustedTypes;
417
+ const ElementPrototype = Element.prototype;
418
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
419
+ const remove = lookupGetter(ElementPrototype, 'remove');
420
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
421
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
422
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
423
+ const getShadowRoot = lookupGetter(ElementPrototype, 'shadowRoot');
424
+ const getAttributes = lookupGetter(ElementPrototype, 'attributes');
425
+ const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeType') : null;
426
+ const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeName') : null;
427
+ // As per issue #47, the web-components registry is inherited by a
428
+ // new document created via createHTMLDocument. As per the spec
429
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
430
+ // a new empty registry is used when creating a template contents owner
431
+ // document, so we use that as our parent document to ensure nothing
432
+ // is inherited.
433
+ if (typeof HTMLTemplateElement === 'function') {
434
+ const template = document.createElement('template');
435
+ if (template.content && template.content.ownerDocument) {
436
+ document = template.content.ownerDocument;
437
+ }
438
+ }
439
+ let trustedTypesPolicy;
440
+ let emptyHTML = '';
441
+ // Tracks whether we are already inside a call to the configured Trusted Types
442
+ // policy's `createHTML`. If the supplied `TRUSTED_TYPES_POLICY.createHTML`
443
+ // itself calls `DOMPurify.sanitize` (the cause of #1422), `sanitize` would
444
+ // re-enter the policy and recurse until the stack overflows. We detect that
445
+ // re-entry and throw a clear, actionable error instead.
446
+ let IN_POLICY_CREATE_HTML = 0;
447
+ const _createTrustedHTML = function _createTrustedHTML(html) {
448
+ if (IN_POLICY_CREATE_HTML > 0) {
449
+ throw typeErrorCreate('The configured TRUSTED_TYPES_POLICY.createHTML must not call ' + 'DOMPurify.sanitize, as that causes infinite recursion. Do not pass ' + 'a policy whose createHTML wraps DOMPurify as TRUSTED_TYPES_POLICY; ' + 'see the "DOMPurify and Trusted Types" section of the README.');
450
+ }
451
+ IN_POLICY_CREATE_HTML++;
452
+ try {
453
+ return trustedTypesPolicy.createHTML(html);
454
+ } finally {
455
+ IN_POLICY_CREATE_HTML--;
456
+ }
457
+ };
458
+ const _document = document,
459
+ implementation = _document.implementation,
460
+ createNodeIterator = _document.createNodeIterator,
461
+ createDocumentFragment = _document.createDocumentFragment,
462
+ getElementsByTagName = _document.getElementsByTagName;
463
+ const importNode = originalDocument.importNode;
464
+ let hooks = _createHooksMap();
465
+ /**
466
+ * Expose whether this browser supports running the full DOMPurify.
467
+ */
468
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
469
+ const MUSTACHE_EXPR$1 = MUSTACHE_EXPR,
470
+ ERB_EXPR$1 = ERB_EXPR,
471
+ TMPLIT_EXPR$1 = TMPLIT_EXPR,
472
+ DATA_ATTR$1 = DATA_ATTR,
473
+ ARIA_ATTR$1 = ARIA_ATTR,
474
+ IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
475
+ ATTR_WHITESPACE$1 = ATTR_WHITESPACE,
476
+ CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
477
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
478
+ /**
479
+ * We consider the elements and attributes below to be safe. Ideally
480
+ * don't add any new ones but feel free to remove unwanted ones.
481
+ */
482
+ /* allowed element names */
483
+ let ALLOWED_TAGS = null;
484
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
485
+ /* Allowed attribute names */
486
+ let ALLOWED_ATTR = null;
487
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
488
+ /*
489
+ * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
490
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
491
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
492
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
493
+ */
494
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
495
+ tagNameCheck: {
496
+ writable: true,
497
+ configurable: false,
498
+ enumerable: true,
499
+ value: null
500
+ },
501
+ attributeNameCheck: {
502
+ writable: true,
503
+ configurable: false,
504
+ enumerable: true,
505
+ value: null
506
+ },
507
+ allowCustomizedBuiltInElements: {
508
+ writable: true,
509
+ configurable: false,
510
+ enumerable: true,
511
+ value: false
512
+ }
513
+ }));
514
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
515
+ let FORBID_TAGS = null;
516
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
517
+ let FORBID_ATTR = null;
518
+ /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */
519
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
520
+ tagCheck: {
521
+ writable: true,
522
+ configurable: false,
523
+ enumerable: true,
524
+ value: null
525
+ },
526
+ attributeCheck: {
527
+ writable: true,
528
+ configurable: false,
529
+ enumerable: true,
530
+ value: null
531
+ }
532
+ }));
533
+ /* Decide if ARIA attributes are okay */
534
+ let ALLOW_ARIA_ATTR = true;
535
+ /* Decide if custom data attributes are okay */
536
+ let ALLOW_DATA_ATTR = true;
537
+ /* Decide if unknown protocols are okay */
538
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
539
+ /* Decide if self-closing tags in attributes are allowed.
540
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
541
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
542
+ /* Output should be safe for common template engines.
543
+ * This means, DOMPurify removes data attributes, mustaches and ERB
544
+ */
545
+ let SAFE_FOR_TEMPLATES = false;
546
+ /* Output should be safe even for XML used within HTML and alike.
547
+ * This means, DOMPurify removes comments when containing risky content.
548
+ */
549
+ let SAFE_FOR_XML = true;
550
+ /* Decide if document with <html>... should be returned */
551
+ let WHOLE_DOCUMENT = false;
552
+ /* Track whether config is already set on this instance of DOMPurify. */
553
+ let SET_CONFIG = false;
554
+ /* Decide if all elements (e.g. style, script) must be children of
555
+ * document.body. By default, browsers might move them to document.head */
556
+ let FORCE_BODY = false;
557
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
558
+ * string (or a TrustedHTML object if Trusted Types are supported).
559
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
560
+ */
561
+ let RETURN_DOM = false;
562
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
563
+ * string (or a TrustedHTML object if Trusted Types are supported) */
564
+ let RETURN_DOM_FRAGMENT = false;
565
+ /* Try to return a Trusted Type object instead of a string, return a string in
566
+ * case Trusted Types are not supported */
567
+ let RETURN_TRUSTED_TYPE = false;
568
+ /* Output should be free from DOM clobbering attacks?
569
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
570
+ */
571
+ let SANITIZE_DOM = true;
572
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
573
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
574
+ *
575
+ * HTML/DOM spec rules that enable DOM Clobbering:
576
+ * - Named Access on Window (§7.3.3)
577
+ * - DOM Tree Accessors (§3.1.5)
578
+ * - Form Element Parent-Child Relations (§4.10.3)
579
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
580
+ * - HTMLCollection (§4.2.10.2)
581
+ *
582
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
583
+ * with a constant string, i.e., `user-content-`
584
+ */
585
+ let SANITIZE_NAMED_PROPS = false;
586
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
587
+ /* Keep element content when removing element? */
588
+ let KEEP_CONTENT = true;
589
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
590
+ * of importing it into a new Document and returning a sanitized copy */
591
+ let IN_PLACE = false;
592
+ /* Allow usage of profiles like html, svg and mathMl */
593
+ let USE_PROFILES = {};
594
+ /* Tags to ignore content of when KEEP_CONTENT is true */
595
+ let FORBID_CONTENTS = null;
596
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
597
+ /* Tags that are safe for data: URIs */
598
+ let DATA_URI_TAGS = null;
599
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
600
+ /* Attributes safe for values like "javascript:" */
601
+ let URI_SAFE_ATTRIBUTES = null;
602
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
603
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
604
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
605
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
606
+ /* Document namespace */
607
+ let NAMESPACE = HTML_NAMESPACE;
608
+ let IS_EMPTY_INPUT = false;
609
+ /* Allowed XHTML+XML namespaces */
610
+ let ALLOWED_NAMESPACES = null;
611
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
612
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
613
+ let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);
614
+ // Certain elements are allowed in both SVG and HTML
615
+ // namespace. We need to specify them explicitly
616
+ // so that they don't get erroneously deleted from
617
+ // HTML namespace.
618
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
619
+ /* Parsing of strict XHTML documents */
620
+ let PARSER_MEDIA_TYPE = null;
621
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
622
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
623
+ let transformCaseFunc = null;
624
+ /* Keep a reference to config to pass to hooks */
625
+ let CONFIG = null;
626
+ /* Ideally, do not touch anything below this line */
627
+ /* ______________________________________________ */
628
+ const formElement = document.createElement('form');
629
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
630
+ return testValue instanceof RegExp || testValue instanceof Function;
631
+ };
632
+ /**
633
+ * _parseConfig
634
+ *
635
+ * @param cfg optional config literal
636
+ */
637
+ // eslint-disable-next-line complexity
638
+ const _parseConfig = function _parseConfig() {
639
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
640
+ if (CONFIG && CONFIG === cfg) {
641
+ return;
642
+ }
643
+ /* Shield configuration object from tampering */
644
+ if (!cfg || typeof cfg !== 'object') {
645
+ cfg = {};
646
+ }
647
+ /* Shield configuration object from prototype pollution */
648
+ cfg = clone(cfg);
649
+ PARSER_MEDIA_TYPE =
650
+ // eslint-disable-next-line unicorn/prefer-includes
651
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
652
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
653
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
654
+ /* Set configuration parameters */
655
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
656
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
657
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
658
+ URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR) ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
659
+ DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') && arrayIsArray(cfg.ADD_DATA_URI_TAGS) ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
660
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
661
+ FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
662
+ FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
663
+ USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
664
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
665
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
666
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
667
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
668
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
669
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
670
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
671
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
672
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
673
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
674
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
675
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
676
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
677
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
678
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
679
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp
680
+ NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace
681
+ MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'MATHML_TEXT_INTEGRATION_POINTS') && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === 'object' ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); // Default built-in map
682
+ HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'HTML_INTEGRATION_POINTS') && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === 'object' ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, ['annotation-xml']); // Default built-in map
683
+ const customElementHandling = objectHasOwnProperty(cfg, 'CUSTOM_ELEMENT_HANDLING') && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === 'object' ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
684
+ CUSTOM_ELEMENT_HANDLING = create(null);
685
+ if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {
686
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck; // Default undefined
687
+ }
688
+ if (objectHasOwnProperty(customElementHandling, 'attributeNameCheck') && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
689
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck; // Default undefined
690
+ }
691
+ if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {
692
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined
693
+ }
694
+ if (SAFE_FOR_TEMPLATES) {
695
+ ALLOW_DATA_ATTR = false;
696
+ }
697
+ if (RETURN_DOM_FRAGMENT) {
698
+ RETURN_DOM = true;
699
+ }
700
+ /* Parse profile info */
701
+ if (USE_PROFILES) {
702
+ ALLOWED_TAGS = addToSet({}, text);
703
+ ALLOWED_ATTR = create(null);
704
+ if (USE_PROFILES.html === true) {
705
+ addToSet(ALLOWED_TAGS, html$1);
706
+ addToSet(ALLOWED_ATTR, html);
707
+ }
708
+ if (USE_PROFILES.svg === true) {
709
+ addToSet(ALLOWED_TAGS, svg$1);
710
+ addToSet(ALLOWED_ATTR, svg);
711
+ addToSet(ALLOWED_ATTR, xml);
712
+ }
713
+ if (USE_PROFILES.svgFilters === true) {
714
+ addToSet(ALLOWED_TAGS, svgFilters);
715
+ addToSet(ALLOWED_ATTR, svg);
716
+ addToSet(ALLOWED_ATTR, xml);
717
+ }
718
+ if (USE_PROFILES.mathMl === true) {
719
+ addToSet(ALLOWED_TAGS, mathMl$1);
720
+ addToSet(ALLOWED_ATTR, mathMl);
721
+ addToSet(ALLOWED_ATTR, xml);
722
+ }
723
+ }
724
+ /* Always reset function-based ADD_TAGS / ADD_ATTR checks to prevent
725
+ * leaking across calls when switching from function to array config */
726
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
727
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
728
+ /* Merge configuration parameters */
729
+ if (objectHasOwnProperty(cfg, 'ADD_TAGS')) {
730
+ if (typeof cfg.ADD_TAGS === 'function') {
731
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
732
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
733
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
734
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
735
+ }
736
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
737
+ }
738
+ }
739
+ if (objectHasOwnProperty(cfg, 'ADD_ATTR')) {
740
+ if (typeof cfg.ADD_ATTR === 'function') {
741
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
742
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
743
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
744
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
745
+ }
746
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
747
+ }
748
+ }
749
+ if (objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
750
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
751
+ }
752
+ if (objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS)) {
753
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
754
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
755
+ }
756
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
757
+ }
758
+ if (objectHasOwnProperty(cfg, 'ADD_FORBID_CONTENTS') && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
759
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
760
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
761
+ }
762
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
763
+ }
764
+ /* Add #text in case KEEP_CONTENT is set to true */
765
+ if (KEEP_CONTENT) {
766
+ ALLOWED_TAGS['#text'] = true;
767
+ }
768
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
769
+ if (WHOLE_DOCUMENT) {
770
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
771
+ }
772
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
773
+ if (ALLOWED_TAGS.table) {
774
+ addToSet(ALLOWED_TAGS, ['tbody']);
775
+ delete FORBID_TAGS.tbody;
776
+ }
777
+ if (cfg.TRUSTED_TYPES_POLICY) {
778
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
779
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
780
+ }
781
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
782
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
783
+ }
784
+ // Overwrite existing TrustedTypes policy.
785
+ const previousTrustedTypesPolicy = trustedTypesPolicy;
786
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
787
+ // Sign local variables required by `sanitize`. If the supplied policy's
788
+ // `createHTML` is circular (i.e. it calls `DOMPurify.sanitize`), this
789
+ // throws via the re-entrancy guard. Restore the previous policy first so
790
+ // the instance is not left in a poisoned state. See #1422.
791
+ try {
792
+ emptyHTML = _createTrustedHTML('');
793
+ } catch (error) {
794
+ trustedTypesPolicy = previousTrustedTypesPolicy;
795
+ throw error;
796
+ }
797
+ } else {
798
+ // Uninitialized policy, attempt to initialize the internal dompurify policy.
799
+ if (trustedTypesPolicy === undefined && cfg.TRUSTED_TYPES_POLICY !== null) {
800
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
801
+ }
802
+ // If creating the internal policy succeeded sign internal variables.
803
+ // Note: a falsy `trustedTypesPolicy` (null when policy creation failed or
804
+ // was skipped via `TRUSTED_TYPES_POLICY: null`, or undefined when no
805
+ // policy has been initialized yet) must be excluded here, otherwise we
806
+ // would call `.createHTML` on a non-policy and throw. See #1422.
807
+ if (trustedTypesPolicy && typeof emptyHTML === 'string') {
808
+ emptyHTML = _createTrustedHTML('');
809
+ }
810
+ }
811
+ /*
812
+ * Mirror the clone-before-mutate pattern already applied above for
813
+ * cfg.ADD_TAGS / cfg.ADD_ATTR: if any uponSanitize* hook is
814
+ * registered AND the set still points at the default constant,
815
+ * clone it. The hook then mutates the clone (in-call widening
816
+ * still works exactly as documented) and the next default-cfg
817
+ * call rebinds to the untouched original via the reassignment at
818
+ * the top of this function.
819
+ */
820
+ if ((hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) && ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
821
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
822
+ }
823
+ if (hooks.uponSanitizeAttribute.length > 0 && ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
824
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
825
+ }
826
+ // Prevent further manipulation of configuration.
827
+ // Not available in IE8, Safari 5, etc.
828
+ if (freeze) {
829
+ freeze(cfg);
830
+ }
831
+ CONFIG = cfg;
832
+ };
833
+ /* Keep track of all possible SVG and MathML tags
834
+ * so that we can perform the namespace checks
835
+ * correctly. */
836
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
837
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
838
+ /**
839
+ * @param element a DOM element whose namespace is being checked
840
+ * @returns Return false if the element has a
841
+ * namespace that a spec-compliant parser would never
842
+ * return. Return true otherwise.
843
+ */
844
+ const _checkValidNamespace = function _checkValidNamespace(element) {
845
+ let parent = getParentNode(element);
846
+ // In JSDOM, if we're inside shadow DOM, then parentNode
847
+ // can be null. We just simulate parent in this case.
848
+ if (!parent || !parent.tagName) {
849
+ parent = {
850
+ namespaceURI: NAMESPACE,
851
+ tagName: 'template'
852
+ };
853
+ }
854
+ const tagName = stringToLowerCase(element.tagName);
855
+ const parentTagName = stringToLowerCase(parent.tagName);
856
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
857
+ return false;
858
+ }
859
+ if (element.namespaceURI === SVG_NAMESPACE) {
860
+ // The only way to switch from HTML namespace to SVG
861
+ // is via <svg>. If it happens via any other tag, then
862
+ // it should be killed.
863
+ if (parent.namespaceURI === HTML_NAMESPACE) {
864
+ return tagName === 'svg';
865
+ }
866
+ // The only way to switch from MathML to SVG is via`
867
+ // svg if parent is either <annotation-xml> or MathML
868
+ // text integration points.
869
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
870
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
871
+ }
872
+ // We only allow elements that are defined in SVG
873
+ // spec. All others are disallowed in SVG namespace.
874
+ return Boolean(ALL_SVG_TAGS[tagName]);
875
+ }
876
+ if (element.namespaceURI === MATHML_NAMESPACE) {
877
+ // The only way to switch from HTML namespace to MathML
878
+ // is via <math>. If it happens via any other tag, then
879
+ // it should be killed.
880
+ if (parent.namespaceURI === HTML_NAMESPACE) {
881
+ return tagName === 'math';
882
+ }
883
+ // The only way to switch from SVG to MathML is via
884
+ // <math> and HTML integration points
885
+ if (parent.namespaceURI === SVG_NAMESPACE) {
886
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
887
+ }
888
+ // We only allow elements that are defined in MathML
889
+ // spec. All others are disallowed in MathML namespace.
890
+ return Boolean(ALL_MATHML_TAGS[tagName]);
891
+ }
892
+ if (element.namespaceURI === HTML_NAMESPACE) {
893
+ // The only way to switch from SVG to HTML is via
894
+ // HTML integration points, and from MathML to HTML
895
+ // is via MathML text integration points
896
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
897
+ return false;
898
+ }
899
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
900
+ return false;
901
+ }
902
+ // We disallow tags that are specific for MathML
903
+ // or SVG and should never appear in HTML namespace
904
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
905
+ }
906
+ // For XHTML and XML documents that support custom namespaces
907
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
908
+ return true;
909
+ }
910
+ // The code should never reach this place (this means
911
+ // that the element somehow got namespace that is not
912
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
913
+ // Return false just in case.
914
+ return false;
915
+ };
916
+ /**
917
+ * _forceRemove
918
+ *
919
+ * @param node a DOM node
920
+ */
921
+ const _forceRemove = function _forceRemove(node) {
922
+ arrayPush(DOMPurify.removed, {
923
+ element: node
924
+ });
925
+ try {
926
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
927
+ getParentNode(node).removeChild(node);
928
+ } catch (_) {
929
+ remove(node);
930
+ }
931
+ };
932
+ /**
933
+ * _removeAttribute
934
+ *
935
+ * @param name an Attribute name
936
+ * @param element a DOM node
937
+ */
938
+ const _removeAttribute = function _removeAttribute(name, element) {
939
+ try {
940
+ arrayPush(DOMPurify.removed, {
941
+ attribute: element.getAttributeNode(name),
942
+ from: element
943
+ });
944
+ } catch (_) {
945
+ arrayPush(DOMPurify.removed, {
946
+ attribute: null,
947
+ from: element
948
+ });
949
+ }
950
+ element.removeAttribute(name);
951
+ // We void attribute values for unremovable "is" attributes
952
+ if (name === 'is') {
953
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
954
+ try {
955
+ _forceRemove(element);
956
+ } catch (_) {}
957
+ } else {
958
+ try {
959
+ element.setAttribute(name, '');
960
+ } catch (_) {}
961
+ }
962
+ }
963
+ };
964
+ /**
965
+ * _initDocument
966
+ *
967
+ * @param dirty - a string of dirty markup
968
+ * @return a DOM, filled with the dirty markup
969
+ */
970
+ const _initDocument = function _initDocument(dirty) {
971
+ /* Create a HTML document */
972
+ let doc = null;
973
+ let leadingWhitespace = null;
974
+ if (FORCE_BODY) {
975
+ dirty = '<remove></remove>' + dirty;
976
+ } else {
977
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
978
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
979
+ leadingWhitespace = matches && matches[0];
980
+ }
981
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
982
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
983
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
984
+ }
985
+ const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
986
+ /*
987
+ * Use the DOMParser API by default, fallback later if needs be
988
+ * DOMParser not work for svg when has multiple root element.
989
+ */
990
+ if (NAMESPACE === HTML_NAMESPACE) {
991
+ try {
992
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
993
+ } catch (_) {}
994
+ }
995
+ /* Use createHTMLDocument in case DOMParser is not available */
996
+ if (!doc || !doc.documentElement) {
997
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
998
+ try {
999
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
1000
+ } catch (_) {
1001
+ // Syntax error if dirtyPayload is invalid xml
1002
+ }
1003
+ }
1004
+ const body = doc.body || doc.documentElement;
1005
+ if (dirty && leadingWhitespace) {
1006
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
1007
+ }
1008
+ /* Work on whole document or just its body */
1009
+ if (NAMESPACE === HTML_NAMESPACE) {
1010
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
1011
+ }
1012
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
1013
+ };
1014
+ /**
1015
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
1016
+ *
1017
+ * @param root The root element or node to start traversing on.
1018
+ * @return The created NodeIterator
1019
+ */
1020
+ const _createNodeIterator = function _createNodeIterator(root) {
1021
+ return createNodeIterator.call(root.ownerDocument || root, root,
1022
+ // eslint-disable-next-line no-bitwise
1023
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
1024
+ };
1025
+ /**
1026
+ * Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
1027
+ * character data of an element subtree. Used as the final safety net for
1028
+ * SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
1029
+ * which only form after text-node normalization (e.g. fragments split across
1030
+ * stripped elements) cannot survive into a template-evaluating framework.
1031
+ *
1032
+ * Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
1033
+ * in place rather than round-tripping through innerHTML. This preserves
1034
+ * descendant node references (important for IN_PLACE callers), avoids a
1035
+ * serialize/reparse cycle, and reads literal character data — which means
1036
+ * `<%...%>` in text content matches the ERB regex against its real bytes
1037
+ * instead of the HTML-entity-escaped form innerHTML would produce.
1038
+ *
1039
+ * Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
1040
+ * attributes is performed during the per-node `_sanitizeAttributes` pass.
1041
+ *
1042
+ * @param node The root element whose character data should be scrubbed.
1043
+ */
1044
+ const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
1045
+ var _node$querySelectorAl, _node$querySelectorAl2;
1046
+ node.normalize();
1047
+ const walker = createNodeIterator.call(node.ownerDocument || node, node,
1048
+ // eslint-disable-next-line no-bitwise
1049
+ NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
1050
+ let currentNode = walker.nextNode();
1051
+ while (currentNode) {
1052
+ let data = currentNode.data;
1053
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1054
+ data = stringReplace(data, expr, ' ');
1055
+ });
1056
+ currentNode.data = data;
1057
+ currentNode = walker.nextNode();
1058
+ }
1059
+ // NodeIterator does not descend into <template>.content per the DOM spec,
1060
+ // so we must explicitly recurse into each template's content fragment,
1061
+ // mirroring the approach used by _sanitizeShadowDOM.
1062
+ const templates = (_node$querySelectorAl = (_node$querySelectorAl2 = node.querySelectorAll) === null || _node$querySelectorAl2 === void 0 ? void 0 : _node$querySelectorAl2.call(node, 'template')) !== null && _node$querySelectorAl !== void 0 ? _node$querySelectorAl : [];
1063
+ arrayForEach(Array.from(templates), tmpl => {
1064
+ if (_isDocumentFragment(tmpl.content)) {
1065
+ _scrubTemplateExpressions2(tmpl.content);
1066
+ }
1067
+ });
1068
+ };
1069
+ /**
1070
+ * _isClobbered
1071
+ *
1072
+ * Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
1073
+ * interface with [LegacyOverrideBuiltIns]; a descendant element with a
1074
+ * `name` attribute matching a prototype property shadows that property
1075
+ * on direct reads. We use this check at the IN_PLACE entry-point and
1076
+ * during attribute sanitization to refuse clobbered forms.
1077
+ *
1078
+ * @param element element to check for clobbering attacks
1079
+ * @return true if clobbered, false if safe
1080
+ */
1081
+ const _isClobbered = function _isClobbered(element) {
1082
+ // Realm-independent tag-name probe. If we can't determine the tag
1083
+ // name at all, we can't reason about clobbering — return false
1084
+ // (the caller's other defences still apply).
1085
+ const realTagName = getNodeName ? getNodeName(element) : null;
1086
+ if (typeof realTagName !== 'string') {
1087
+ return false;
1088
+ }
1089
+ if (transformCaseFunc(realTagName) !== 'form') {
1090
+ return false;
1091
+ }
1092
+ return typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' ||
1093
+ // Realm-safe NamedNodeMap detection: equality against the cached
1094
+ // prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
1095
+ // makes the direct read diverge from the cached read; a clean form
1096
+ // (same-realm OR foreign-realm) has both reads pointing at the same
1097
+ // canonical NamedNodeMap.
1098
+ element.attributes !== getAttributes(element) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function' ||
1099
+ // NodeType clobbering probe. Cached Node.prototype.nodeType getter
1100
+ // returns the integer 1 for any Element regardless of realm; direct
1101
+ // read on a clobbered form (e.g. <input name="nodeType">) returns
1102
+ // the named child element. Cheap addition — nodeType is read from
1103
+ // an internal slot, no serialization cost — and removes a residual
1104
+ // clobbering surface used by several mXSS / PI / comment branches
1105
+ // in _sanitizeElements that compare currentNode.nodeType directly.
1106
+ element.nodeType !== getNodeType(element) ||
1107
+ // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
1108
+ // "childNodes" shadows the prototype getter. Direct reads of
1109
+ // form.childNodes from a clobbered form return the named child
1110
+ // instead of the real NodeList, so any walk that reads it directly
1111
+ // skips the form's real children. Compare the direct read to the
1112
+ // cached Node.prototype getter — when the form's named-property
1113
+ // getter intercepts the read, the two values differ and we flag
1114
+ // the form. This catches every clobbering child type (input,
1115
+ // select, etc.) regardless of whether the named child happens to
1116
+ // carry a numeric .length, which a typeof-based probe would miss
1117
+ // (e.g. HTMLSelectElement.length is a defined unsigned-long).
1118
+ element.childNodes !== getChildNodes(element);
1119
+ };
1120
+ /**
1121
+ * Checks whether the given value is a DocumentFragment from any realm.
1122
+ *
1123
+ * The realm-independent replacement reads `nodeType` through the cached
1124
+ * Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
1125
+ * constant (11). nodeType is a numeric value resolved from the node's
1126
+ * internal slot, identical across realms for the same kind of node.
1127
+ *
1128
+ * @param value object to check
1129
+ * @return true if value is a DocumentFragment-shaped node from any realm
1130
+ */
1131
+ const _isDocumentFragment = function _isDocumentFragment(value) {
1132
+ if (!getNodeType || typeof value !== 'object' || value === null) {
1133
+ return false;
1134
+ }
1135
+ try {
1136
+ return getNodeType(value) === NODE_TYPE.documentFragment;
1137
+ } catch (_) {
1138
+ return false;
1139
+ }
1140
+ };
1141
+ /**
1142
+ * Checks whether the given object is a DOM node, including nodes that
1143
+ * originate from a different window/realm (e.g. an iframe's
1144
+ * contentDocument). The previous `value instanceof Node` check was
1145
+ * realm-bound: nodes from a different window failed it, causing
1146
+ * sanitize() to silently stringify them and reset IN_PLACE to false,
1147
+ * returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
1148
+ *
1149
+ * @param value object to check whether it's a DOM node
1150
+ * @return true if value is a DOM node from any realm
1151
+ */
1152
+ const _isNode = function _isNode(value) {
1153
+ if (!getNodeType || typeof value !== 'object' || value === null) {
1154
+ return false;
1155
+ }
1156
+ try {
1157
+ return typeof getNodeType(value) === 'number';
1158
+ } catch (_) {
1159
+ return false;
1160
+ }
1161
+ };
1162
+ function _executeHooks(hooks, currentNode, data) {
1163
+ arrayForEach(hooks, hook => {
1164
+ hook.call(DOMPurify, currentNode, data, CONFIG);
1165
+ });
1166
+ }
1167
+ /**
1168
+ * _sanitizeElements
1169
+ *
1170
+ * @protect nodeName
1171
+ * @protect textContent
1172
+ * @protect removeChild
1173
+ * @param currentNode to check for permission to exist
1174
+ * @return true if node was killed, false if left alive
1175
+ */
1176
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
1177
+ let content = null;
1178
+ /* Execute a hook if present */
1179
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
1180
+ /* Check if element is clobbered or can clobber */
1181
+ if (_isClobbered(currentNode)) {
1182
+ _forceRemove(currentNode);
1183
+ return true;
1184
+ }
1185
+ /* Now let's check the element's type and name */
1186
+ const tagName = transformCaseFunc(getNodeName ? getNodeName(currentNode) : currentNode.nodeName);
1187
+ /* Execute a hook if present */
1188
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
1189
+ tagName,
1190
+ allowedTags: ALLOWED_TAGS
1191
+ });
1192
+ /* Detect mXSS attempts abusing namespace confusion */
1193
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
1194
+ _forceRemove(currentNode);
1195
+ return true;
1196
+ }
1197
+ /* Remove risky CSS construction leading to mXSS */
1198
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
1199
+ _forceRemove(currentNode);
1200
+ return true;
1201
+ }
1202
+ /* Remove any occurrence of processing instructions */
1203
+ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
1204
+ _forceRemove(currentNode);
1205
+ return true;
1206
+ }
1207
+ /* Remove any kind of possibly harmful comments */
1208
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
1209
+ _forceRemove(currentNode);
1210
+ return true;
1211
+ }
1212
+ /* Remove element if anything forbids its presence */
1213
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
1214
+ /* Check if we have a custom element to handle */
1215
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
1216
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
1217
+ return false;
1218
+ }
1219
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
1220
+ return false;
1221
+ }
1222
+ }
1223
+ /* Keep content except for bad-listed elements.
1224
+ Use the cached prototype getters exclusively — the previous code
1225
+ had `|| currentNode.parentNode` / `|| currentNode.childNodes`
1226
+ fallbacks, but the cached getters always return the canonical
1227
+ value (or null for a real parent-less node), so the fallback
1228
+ path was dead in safe cases and a clobbering surface in unsafe
1229
+ ones. Falsy cached results stay falsy; the `if (childNodes &&
1230
+ parentNode)` check already gates correctly. */
1231
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1232
+ const parentNode = getParentNode(currentNode);
1233
+ const childNodes = getChildNodes(currentNode);
1234
+ if (childNodes && parentNode) {
1235
+ const childCount = childNodes.length;
1236
+ for (let i = childCount - 1; i >= 0; --i) {
1237
+ const childClone = cloneNode(childNodes[i], true);
1238
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
1239
+ }
1240
+ }
1241
+ }
1242
+ _forceRemove(currentNode);
1243
+ return true;
1244
+ }
1245
+ /* Check whether element has a valid namespace.
1246
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): use the cached Node.prototype
1247
+ nodeType getter rather than `instanceof Element`, which is realm-
1248
+ bound and short-circuits to false for any node minted in a different
1249
+ realm — letting a foreign-realm element with a forbidden namespace
1250
+ slip past the namespace check entirely. */
1251
+ const nt = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
1252
+ if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
1253
+ _forceRemove(currentNode);
1254
+ return true;
1255
+ }
1256
+ /* Make sure that older browsers don't get fallback-tag mXSS */
1257
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
1258
+ _forceRemove(currentNode);
1259
+ return true;
1260
+ }
1261
+ /* Sanitize element content to be template-safe */
1262
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
1263
+ /* Get the element's text content */
1264
+ content = currentNode.textContent;
1265
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1266
+ content = stringReplace(content, expr, ' ');
1267
+ });
1268
+ if (currentNode.textContent !== content) {
1269
+ arrayPush(DOMPurify.removed, {
1270
+ element: currentNode.cloneNode()
1271
+ });
1272
+ currentNode.textContent = content;
1273
+ }
1274
+ }
1275
+ /* Execute a hook if present */
1276
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
1277
+ return false;
1278
+ };
1279
+ /**
1280
+ * _isValidAttribute
1281
+ *
1282
+ * @param lcTag Lowercase tag name of containing element.
1283
+ * @param lcName Lowercase attribute name.
1284
+ * @param value Attribute value.
1285
+ * @return Returns true if `value` is valid, otherwise false.
1286
+ */
1287
+ // eslint-disable-next-line complexity
1288
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1289
+ /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
1290
+ if (FORBID_ATTR[lcName]) {
1291
+ return false;
1292
+ }
1293
+ /* Make sure attribute cannot clobber */
1294
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1295
+ return false;
1296
+ }
1297
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
1298
+ /* Allow valid data-* attributes: At least one character after "-"
1299
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
1300
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
1301
+ We don't need to check the value; it's always URI safe. */
1302
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ; else if (!nameIsPermitted || FORBID_ATTR[lcName]) {
1303
+ if (
1304
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1305
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1306
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1307
+ _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) ||
1308
+ // Alternative, second condition checks if it's an `is`-attribute, AND
1309
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1310
+ lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
1311
+ return false;
1312
+ }
1313
+ /* Check value is safe. First, is attr inert? If so, is safe */
1314
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if (value) {
1315
+ return false;
1316
+ } else ;
1317
+ return true;
1318
+ };
1319
+ /* Names the HTML spec reserves from valid-custom-element-name; these must
1320
+ * never be treated as basic custom elements even when a permissive
1321
+ * CUSTOM_ELEMENT_HANDLING.tagNameCheck is configured. */
1322
+ 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']);
1323
+ /**
1324
+ * _isBasicCustomElement
1325
+ * checks if at least one dash is included in tagName, and it's not the first char
1326
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
1327
+ *
1328
+ * @param tagName name of the tag of the node to sanitize
1329
+ * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
1330
+ */
1331
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
1332
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
1333
+ };
1334
+ /**
1335
+ * _sanitizeAttributes
1336
+ *
1337
+ * @protect attributes
1338
+ * @protect nodeName
1339
+ * @protect removeAttribute
1340
+ * @protect setAttribute
1341
+ *
1342
+ * @param currentNode to sanitize
1343
+ */
1344
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
1345
+ /* Execute a hook if present */
1346
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
1347
+ const attributes = currentNode.attributes;
1348
+ /* Check if we have attributes; if not we might have a text node */
1349
+ if (!attributes || _isClobbered(currentNode)) {
1350
+ return;
1351
+ }
1352
+ const hookEvent = {
1353
+ attrName: '',
1354
+ attrValue: '',
1355
+ keepAttr: true,
1356
+ allowedAttributes: ALLOWED_ATTR,
1357
+ forceKeepAttr: undefined
1358
+ };
1359
+ let l = attributes.length;
1360
+ /* Go backwards over all attributes; safely remove bad ones */
1361
+ while (l--) {
1362
+ const attr = attributes[l];
1363
+ const name = attr.name,
1364
+ namespaceURI = attr.namespaceURI,
1365
+ attrValue = attr.value;
1366
+ const lcName = transformCaseFunc(name);
1367
+ const initValue = attrValue;
1368
+ let value = name === 'value' ? initValue : stringTrim(initValue);
1369
+ /* Execute a hook if present */
1370
+ hookEvent.attrName = lcName;
1371
+ hookEvent.attrValue = value;
1372
+ hookEvent.keepAttr = true;
1373
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1374
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
1375
+ value = hookEvent.attrValue;
1376
+ /* Full DOM Clobbering protection via namespace isolation,
1377
+ * Prefix id and name attributes with `user-content-`
1378
+ */
1379
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name') && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
1380
+ // Remove the attribute with this value
1381
+ _removeAttribute(name, currentNode);
1382
+ // Prefix the value and later re-create the attribute with the sanitized value
1383
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
1384
+ }
1385
+ // Else: already prefixed, leave the attribute alone — the prefix is
1386
+ // itself the clobbering protection, and re-applying it is incorrect.
1387
+ /* Work around a security issue with comments inside attributes */
1388
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
1389
+ _removeAttribute(name, currentNode);
1390
+ continue;
1391
+ }
1392
+ /* Make sure we cannot easily use animated hrefs, even if animations are allowed */
1393
+ if (lcName === 'attributename' && stringMatch(value, 'href')) {
1394
+ _removeAttribute(name, currentNode);
1395
+ continue;
1396
+ }
1397
+ /* Did the hooks approve of the attribute? */
1398
+ if (hookEvent.forceKeepAttr) {
1399
+ continue;
1400
+ }
1401
+ /* Did the hooks approve of the attribute? */
1402
+ if (!hookEvent.keepAttr) {
1403
+ _removeAttribute(name, currentNode);
1404
+ continue;
1405
+ }
1406
+ /* Work around a security issue in jQuery 3.0 */
1407
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
1408
+ _removeAttribute(name, currentNode);
1409
+ continue;
1410
+ }
1411
+ /* Sanitize attribute content to be template-safe */
1412
+ if (SAFE_FOR_TEMPLATES) {
1413
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1414
+ value = stringReplace(value, expr, ' ');
1415
+ });
1416
+ }
1417
+ /* Is `value` valid for this attribute? */
1418
+ const lcTag = transformCaseFunc(currentNode.nodeName);
1419
+ if (!_isValidAttribute(lcTag, lcName, value)) {
1420
+ _removeAttribute(name, currentNode);
1421
+ continue;
1422
+ }
1423
+ /* Handle attributes that require Trusted Types */
1424
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
1425
+ if (namespaceURI) ; else {
1426
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
1427
+ case 'TrustedHTML':
1428
+ {
1429
+ value = _createTrustedHTML(value);
1430
+ break;
1431
+ }
1432
+ case 'TrustedScriptURL':
1433
+ {
1434
+ value = trustedTypesPolicy.createScriptURL(value);
1435
+ break;
1436
+ }
1437
+ }
1438
+ }
1439
+ }
1440
+ /* Handle invalid data-* attribute set by try-catching it */
1441
+ if (value !== initValue) {
1442
+ try {
1443
+ if (namespaceURI) {
1444
+ currentNode.setAttributeNS(namespaceURI, name, value);
1445
+ } else {
1446
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1447
+ currentNode.setAttribute(name, value);
1448
+ }
1449
+ if (_isClobbered(currentNode)) {
1450
+ _forceRemove(currentNode);
1451
+ } else {
1452
+ arrayPop(DOMPurify.removed);
1453
+ }
1454
+ } catch (_) {
1455
+ _removeAttribute(name, currentNode);
1456
+ }
1457
+ }
1458
+ }
1459
+ /* Execute a hook if present */
1460
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
1461
+ };
1462
+ /**
1463
+ * _sanitizeShadowDOM
1464
+ *
1465
+ * @param fragment to iterate over recursively
1466
+ */
1467
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
1468
+ let shadowNode = null;
1469
+ const shadowIterator = _createNodeIterator(fragment);
1470
+ /* Execute a hook if present */
1471
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
1472
+ while (shadowNode = shadowIterator.nextNode()) {
1473
+ /* Execute a hook if present */
1474
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
1475
+ /* Sanitize tags and elements */
1476
+ _sanitizeElements(shadowNode);
1477
+ /* Check attributes next */
1478
+ _sanitizeAttributes(shadowNode);
1479
+ /* Deep shadow DOM detected.
1480
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType against the
1481
+ DOCUMENT_FRAGMENT_NODE constant rather than instanceof, so we
1482
+ recurse into <template>.content from foreign realms too. */
1483
+ if (_isDocumentFragment(shadowNode.content)) {
1484
+ _sanitizeShadowDOM2(shadowNode.content);
1485
+ }
1486
+ /* An element iterated here may itself host an attached
1487
+ shadow root. The default NodeIterator does not enter shadow
1488
+ trees, so a shadow root nested inside template.content was
1489
+ previously reached by no walk at all (the pre-pass at
1490
+ _sanitizeAttachedShadowRoots descends via childNodes, which
1491
+ doesn't enter template.content; the template-content recursion
1492
+ above iterates the content but never inspected shadowRoot).
1493
+ Walk it explicitly. The nodeType guard avoids reading
1494
+ shadowRoot off text / comment / CDATA / PI nodes that the
1495
+ iterator also surfaces. */
1496
+ const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
1497
+ if (shadowNodeType === NODE_TYPE.element) {
1498
+ const innerSr = getShadowRoot ? getShadowRoot(shadowNode) : shadowNode.shadowRoot;
1499
+ if (_isDocumentFragment(innerSr)) {
1500
+ _sanitizeAttachedShadowRoots2(innerSr);
1501
+ _sanitizeShadowDOM2(innerSr);
1502
+ }
1503
+ }
1504
+ }
1505
+ /* Execute a hook if present */
1506
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
1507
+ };
1508
+ /**
1509
+ * _sanitizeAttachedShadowRoots
1510
+ *
1511
+ * Walks `root` and feeds every attached shadow root we encounter into
1512
+ * the existing _sanitizeShadowDOM pipeline. The default node iterator
1513
+ * does not descend into shadow trees, so nodes inside an attached
1514
+ * shadow root would otherwise be skipped entirely.
1515
+ *
1516
+ * Two real input paths put attached shadow roots in front of us:
1517
+ * 1. IN_PLACE on a DOM node that already has shadow roots attached.
1518
+ * 2. DOM-node input where importNode(dirty, true) deep-clones the
1519
+ * shadow root because it was created with `clonable: true`.
1520
+ *
1521
+ * This pass runs once, up front, so the main iteration loop (and the
1522
+ * existing _sanitizeShadowDOM template-content recursion) stay
1523
+ * untouched — string-input paths are not affected.
1524
+ *
1525
+ * @param root the subtree root to walk for attached shadow roots
1526
+ */
1527
+ const _sanitizeAttachedShadowRoots2 = function _sanitizeAttachedShadowRoots(root) {
1528
+ const nodeType = getNodeType ? getNodeType(root) : root.nodeType;
1529
+ if (nodeType === NODE_TYPE.element) {
1530
+ const sr = getShadowRoot ? getShadowRoot(root) : root.shadowRoot;
1531
+ // Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType-based
1532
+ // detection rather than `instanceof DocumentFragment`, which is
1533
+ // realm-bound and silently skipped shadow roots whose host element
1534
+ // belonged to a foreign realm (e.g. iframe.contentDocument
1535
+ // attachShadow). A foreign-realm ShadowRoot extends the foreign
1536
+ // realm's DocumentFragment, not ours, so the old instanceof check
1537
+ // returned false and the shadow subtree was never walked.
1538
+ if (_isDocumentFragment(sr)) {
1539
+ // Recurse first so that nested shadow roots are reached even if
1540
+ // _sanitizeShadowDOM removes hosts at this level.
1541
+ _sanitizeAttachedShadowRoots2(sr);
1542
+ _sanitizeShadowDOM2(sr);
1543
+ }
1544
+ }
1545
+ // Snapshot children before recursing. Sanitization of one subtree
1546
+ // (e.g. via an uponSanitizeShadowNode hook) may detach siblings,
1547
+ // and naive nextSibling traversal would silently skip the rest of
1548
+ // the list once a node is detached.
1549
+ const childNodes = getChildNodes ? getChildNodes(root) : root.childNodes;
1550
+ if (!childNodes) {
1551
+ return;
1552
+ }
1553
+ const snapshot = [];
1554
+ arrayForEach(childNodes, child => {
1555
+ arrayPush(snapshot, child);
1556
+ });
1557
+ for (const child of snapshot) {
1558
+ _sanitizeAttachedShadowRoots2(child);
1559
+ }
1560
+ /* When the root is a <template>, also descend into root.content */
1561
+ if (nodeType === NODE_TYPE.element) {
1562
+ const rootName = getNodeName ? getNodeName(root) : null;
1563
+ if (typeof rootName === 'string' && transformCaseFunc(rootName) === 'template') {
1564
+ const content = root.content;
1565
+ if (_isDocumentFragment(content)) {
1566
+ _sanitizeAttachedShadowRoots2(content);
1567
+ }
1568
+ }
1569
+ }
1570
+ };
1571
+ // eslint-disable-next-line complexity
1572
+ DOMPurify.sanitize = function (dirty) {
1573
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1574
+ let body = null;
1575
+ let importedNode = null;
1576
+ let currentNode = null;
1577
+ let returnNode = null;
1578
+ /* Make sure we have a string to sanitize.
1579
+ DO NOT return early, as this will return the wrong type if
1580
+ the user has requested a DOM object rather than a string */
1581
+ IS_EMPTY_INPUT = !dirty;
1582
+ if (IS_EMPTY_INPUT) {
1583
+ dirty = '<!-->';
1584
+ }
1585
+ /* Stringify, in case dirty is an object */
1586
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
1587
+ dirty = stringifyValue(dirty);
1588
+ if (typeof dirty !== 'string') {
1589
+ throw typeErrorCreate('dirty is not a string, aborting');
1590
+ }
1591
+ }
1592
+ /* Return dirty HTML if DOMPurify cannot run */
1593
+ if (!DOMPurify.isSupported) {
1594
+ return dirty;
1595
+ }
1596
+ /* Assign config vars */
1597
+ if (!SET_CONFIG) {
1598
+ _parseConfig(cfg);
1599
+ }
1600
+ /* Clean up removed elements */
1601
+ DOMPurify.removed = [];
1602
+ /* Check if dirty is correctly typed for IN_PLACE */
1603
+ if (typeof dirty === 'string') {
1604
+ IN_PLACE = false;
1605
+ }
1606
+ if (IN_PLACE) {
1607
+ /* Do some early pre-sanitization to avoid unsafe root nodes.
1608
+ Read nodeName through the cached prototype getter — a clobbering
1609
+ child named "nodeName" on the form root would otherwise shadow
1610
+ the property and let this check skip the root-allowlist
1611
+ validation entirely. */
1612
+ const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
1613
+ if (typeof nn === 'string') {
1614
+ const tagName = transformCaseFunc(nn);
1615
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1616
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
1617
+ }
1618
+ }
1619
+ /* Pre-flight the root through _isClobbered. The iterator-driven
1620
+ removal path can not detach a parent-less root: _forceRemove
1621
+ falls through to Element.prototype.remove(), which per spec
1622
+ is a no-op on a node with no parent. A clobbered root would
1623
+ then survive the main loop with its attributes uninspected,
1624
+ because _sanitizeAttributes early-returns on _isClobbered. The
1625
+ result would be an attacker-controlled form, complete with any
1626
+ event-handler attributes the caller passed in, handed back to
1627
+ the application unsanitized. Refuse to sanitize such a root
1628
+ the same way we refuse a forbidden tag. GHSA-r47g-fvhr-h676. */
1629
+ if (_isClobbered(dirty)) {
1630
+ throw typeErrorCreate('root node is clobbered and cannot be sanitized in-place');
1631
+ }
1632
+ /* Sanitize attached shadow roots before the main iterator runs.
1633
+ The iterator does not descend into shadow trees. */
1634
+ _sanitizeAttachedShadowRoots2(dirty);
1635
+ } else if (_isNode(dirty)) {
1636
+ /* If dirty is a DOM element, append to an empty document to avoid
1637
+ elements being stripped by the parser */
1638
+ body = _initDocument('<!---->');
1639
+ importedNode = body.ownerDocument.importNode(dirty, true);
1640
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
1641
+ /* Node is already a body, use as is */
1642
+ body = importedNode;
1643
+ } else if (importedNode.nodeName === 'HTML') {
1644
+ body = importedNode;
1645
+ } else {
1646
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1647
+ body.appendChild(importedNode);
1648
+ }
1649
+ /* Clonable shadow roots are deep-cloned by importNode(); sanitize
1650
+ them before the main iterator runs, since the iterator does not
1651
+ descend into shadow trees. The walk routes every read through a
1652
+ cached prototype getter so clobbering descendants on a form root
1653
+ cannot hide a shadow host from this pass. */
1654
+ _sanitizeAttachedShadowRoots2(importedNode);
1655
+ } else {
1656
+ /* Exit directly if we have nothing to do */
1657
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
1658
+ // eslint-disable-next-line unicorn/prefer-includes
1659
+ dirty.indexOf('<') === -1) {
1660
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
1661
+ }
1662
+ /* Initialize the document to work on */
1663
+ body = _initDocument(dirty);
1664
+ /* Check we have a DOM node from the data */
1665
+ if (!body) {
1666
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
1667
+ }
1668
+ }
1669
+ /* Remove first element node (ours) if FORCE_BODY is set */
1670
+ if (body && FORCE_BODY) {
1671
+ _forceRemove(body.firstChild);
1672
+ }
1673
+ /* Get node iterator */
1674
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
1675
+ /* Now start iterating over the created document */
1676
+ while (currentNode = nodeIterator.nextNode()) {
1677
+ /* Sanitize tags and elements */
1678
+ _sanitizeElements(currentNode);
1679
+ /* Check attributes next */
1680
+ _sanitizeAttributes(currentNode);
1681
+ /* Shadow DOM detected, sanitize it.
1682
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
1683
+ instead of instanceof, so foreign-realm <template>.content is
1684
+ walked correctly. */
1685
+ if (_isDocumentFragment(currentNode.content)) {
1686
+ _sanitizeShadowDOM2(currentNode.content);
1687
+ }
1688
+ }
1689
+ /* If we sanitized `dirty` in-place, return it. */
1690
+ if (IN_PLACE) {
1691
+ if (SAFE_FOR_TEMPLATES) {
1692
+ _scrubTemplateExpressions2(dirty);
1693
+ }
1694
+ return dirty;
1695
+ }
1696
+ /* Return sanitized string or DOM */
1697
+ if (RETURN_DOM) {
1698
+ if (SAFE_FOR_TEMPLATES) {
1699
+ _scrubTemplateExpressions2(body);
1700
+ }
1701
+ if (RETURN_DOM_FRAGMENT) {
1702
+ returnNode = createDocumentFragment.call(body.ownerDocument);
1703
+ while (body.firstChild) {
1704
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1705
+ returnNode.appendChild(body.firstChild);
1706
+ }
1707
+ } else {
1708
+ returnNode = body;
1709
+ }
1710
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
1711
+ /*
1712
+ AdoptNode() is not used because internal state is not reset
1713
+ (e.g. the past names map of a HTMLFormElement), this is safe
1714
+ in theory but we would rather not risk another attack vector.
1715
+ The state that is cloned by importNode() is explicitly defined
1716
+ by the specs.
1717
+ */
1718
+ returnNode = importNode.call(originalDocument, returnNode, true);
1719
+ }
1720
+ return returnNode;
1721
+ }
1722
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
1723
+ /* Serialize doctype if allowed */
1724
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
1725
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
1726
+ }
1727
+ /* Sanitize final string template-safe */
1728
+ if (SAFE_FOR_TEMPLATES) {
1729
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1730
+ serializedHTML = stringReplace(serializedHTML, expr, ' ');
1731
+ });
1732
+ }
1733
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
1734
+ };
1735
+ DOMPurify.setConfig = function () {
1736
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1737
+ _parseConfig(cfg);
1738
+ SET_CONFIG = true;
1739
+ };
1740
+ DOMPurify.clearConfig = function () {
1741
+ CONFIG = null;
1742
+ SET_CONFIG = false;
1743
+ };
1744
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
1745
+ /* Initialize shared config vars if necessary. */
1746
+ if (!CONFIG) {
1747
+ _parseConfig({});
1748
+ }
1749
+ const lcTag = transformCaseFunc(tag);
1750
+ const lcName = transformCaseFunc(attr);
1751
+ return _isValidAttribute(lcTag, lcName, value);
1752
+ };
1753
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
1754
+ if (typeof hookFunction !== 'function') {
1755
+ return;
1756
+ }
1757
+ arrayPush(hooks[entryPoint], hookFunction);
1758
+ };
1759
+ DOMPurify.removeHook = function (entryPoint, hookFunction) {
1760
+ if (hookFunction !== undefined) {
1761
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
1762
+ return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
1763
+ }
1764
+ return arrayPop(hooks[entryPoint]);
1765
+ };
1766
+ DOMPurify.removeHooks = function (entryPoint) {
1767
+ hooks[entryPoint] = [];
1768
+ };
1769
+ DOMPurify.removeAllHooks = function () {
1770
+ hooks = _createHooksMap();
1771
+ };
1772
+ return DOMPurify;
1773
+ }
1774
+ var purify = createDOMPurify();
1775
+
1776
+ const BASE_INLINE = ['p', 'br', 'strong', 'em', 'a', 'span'];
1777
+ const BASE_ATTR = ['href', 'target', 'rel', 'data-mention-id', 'data-mention-label'];
1778
+ const SANITIZE_CONFIGS = {
1779
+ comment: {
1780
+ ALLOWED_TAGS: [...BASE_INLINE],
1781
+ ALLOWED_ATTR: [...BASE_ATTR],
1782
+ ALLOW_DATA_ATTR: false,
1783
+ },
1784
+ task: {
1785
+ ALLOWED_TAGS: [...BASE_INLINE, 'u', 's', 'code', 'ul', 'ol', 'li', 'blockquote'],
1786
+ ALLOWED_ATTR: [...BASE_ATTR],
1787
+ ALLOW_DATA_ATTR: false,
1788
+ },
1789
+ email: {
1790
+ ALLOWED_TAGS: [
1791
+ ...BASE_INLINE, 'u', 's', 'code', 'ul', 'ol', 'li', 'blockquote',
1792
+ 'h2', 'h3', 'div', 'img',
1793
+ ],
1794
+ ALLOWED_ATTR: [...BASE_ATTR, 'style', 'data-variable', 'src', 'alt', 'width', 'height'],
1795
+ ALLOW_DATA_ATTR: false,
1796
+ },
1797
+ document: {
1798
+ ALLOWED_TAGS: [
1799
+ ...BASE_INLINE, 'u', 's', 'code', 'ul', 'ol', 'li', 'blockquote',
1800
+ 'h1', 'h2', 'h3', 'h4', 'hr', 'div', 'mark', 'img',
1801
+ 'table', 'thead', 'tbody', 'tr', 'th', 'td',
1802
+ ],
1803
+ ALLOWED_ATTR: [...BASE_ATTR, 'style', 'data-variable', 'colspan', 'rowspan', 'src', 'alt', 'width', 'height'],
1804
+ ALLOW_DATA_ATTR: false,
1805
+ },
1806
+ };
1807
+ /** Tags forbidden in every preset, regardless of the allow-list. */
1808
+ const FORBID_TAGS = ['script', 'iframe', 'object', 'embed', 'form', 'input', 'textarea', 'style'];
1809
+ /** Attributes forbidden in every preset (event handlers handled by DOMPurify itself). */
1810
+ const FORBID_ATTR = ['onerror', 'onload', 'onclick'];
1811
+ /**
1812
+ * Resolve the effective config for a preset + feature overrides. Features can
1813
+ * only ADD capabilities (mirroring `getExtensions`, where they register extra
1814
+ * nodes); they never narrow a preset's base whitelist.
1815
+ */
1816
+ function configFor(preset, features) {
1817
+ const cfg = SANITIZE_CONFIGS[preset] ?? SANITIZE_CONFIGS.task;
1818
+ if (!features)
1819
+ return cfg;
1820
+ const tags = new Set(cfg.ALLOWED_TAGS);
1821
+ const attr = new Set(cfg.ALLOWED_ATTR);
1822
+ if (features.image) {
1823
+ tags.add('img');
1824
+ ['src', 'alt', 'width', 'height'].forEach((a) => attr.add(a));
1825
+ }
1826
+ if (features.variables)
1827
+ attr.add('data-variable');
1828
+ // mentions: data-mention-id/label are already in BASE_ATTR for every preset.
1829
+ return { ...cfg, ALLOWED_TAGS: [...tags], ALLOWED_ATTR: [...attr] };
1830
+ }
1831
+ /**
1832
+ * `style` is only allowed in email/document, and even there we cap it to the
1833
+ * properties our extensions actually emit (TextStyle/Color). Everything else —
1834
+ * position, background-image url(), etc. — is UI-redressing/tracking surface.
1835
+ */
1836
+ const STYLE_ALLOWED_PROPS = new Set(['color', 'background-color', 'text-align']);
1837
+ let styleHookInstalled = false;
1838
+ function ensureStyleHook() {
1839
+ if (styleHookInstalled)
1840
+ return;
1841
+ styleHookInstalled = true;
1842
+ purify.addHook('uponSanitizeAttribute', (_node, data) => {
1843
+ if (data.attrName !== 'style')
1844
+ return;
1845
+ const safe = data.attrValue
1846
+ .split(';')
1847
+ .map((d) => d.trim())
1848
+ .filter((d) => {
1849
+ const colon = d.indexOf(':');
1850
+ if (colon <= 0)
1851
+ return false;
1852
+ const prop = d.slice(0, colon).trim().toLowerCase();
1853
+ return STYLE_ALLOWED_PROPS.has(prop) && !/url\s*\(|expression\s*\(/i.test(d);
1854
+ });
1855
+ data.attrValue = safe.join('; ');
1856
+ if (!data.attrValue)
1857
+ data.keepAttr = false;
1858
+ });
1859
+ }
1860
+ /**
1861
+ * Sanitize an HTML string for the given preset (+ feature overrides — pass the
1862
+ * same `features` you gave `getExtensions`/`createEditor` so the whitelist
1863
+ * stays in lock-step with the schema). Always strips script/iframe/style-tag/
1864
+ * form/event-handlers and `javascript:` URLs (DOMPurify default).
1865
+ */
1866
+ function sanitize(html, preset = 'task', features) {
1867
+ if (!html)
1868
+ return '';
1869
+ ensureStyleHook();
1870
+ const cfg = configFor(preset, features);
1871
+ return purify.sanitize(html, {
1872
+ ALLOWED_TAGS: cfg.ALLOWED_TAGS,
1873
+ ALLOWED_ATTR: cfg.ALLOWED_ATTR,
1874
+ ALLOW_DATA_ATTR: cfg.ALLOW_DATA_ATTR ?? false,
1875
+ FORBID_TAGS,
1876
+ FORBID_ATTR,
1877
+ // Keep relative/safe links only; DOMPurify drops javascript: by default.
1878
+ ADD_ATTR: ['target'],
1879
+ });
1880
+ }
1881
+
1882
+ exports.SANITIZE_CONFIGS = SANITIZE_CONFIGS;
1883
+ exports.sanitize = sanitize;