@touchvue/chat 1.0.0-beta.5 → 1.0.0-beta.51

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 (443) hide show
  1. package/README.md +25 -25
  2. package/es/_virtual/_plugin-vue_export-helper.mjs +10 -0
  3. package/es/_virtual/_plugin-vue_export-helper.mjs.map +1 -0
  4. package/es/index.mjs.map +1 -1
  5. package/es/node_modules/.pnpm/@touchvue_a2ui@1.0.0-beta.46/node_modules/@touchvue/a2ui/dist/index.mjs +4816 -0
  6. package/es/node_modules/.pnpm/@touchvue_a2ui@1.0.0-beta.46/node_modules/@touchvue/a2ui/dist/index.mjs.map +1 -0
  7. package/es/node_modules/.pnpm/dompurify@3.4.3/node_modules/dompurify/dist/purify.es.mjs +1536 -0
  8. package/es/node_modules/.pnpm/dompurify@3.4.3/node_modules/dompurify/dist/purify.es.mjs.map +1 -0
  9. package/es/node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.mjs +7824 -0
  10. package/es/node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.mjs.map +1 -0
  11. package/es/package.json.css +1 -1
  12. package/es/package.json.mjs +2 -2
  13. package/es/packages/components/index.mjs +1 -1
  14. package/es/packages/components/resolver.mjs.map +1 -1
  15. package/es/packages/components/touchchat/component/AiRobot/HelloChat.vue.mjs +3 -2
  16. package/es/packages/components/touchchat/component/AiRobot/HelloChat.vue.mjs.map +1 -1
  17. package/es/packages/components/touchchat/component/AiRobot/HelloChat.vue2.mjs +219 -159
  18. package/es/packages/components/touchchat/component/AiRobot/HelloChat.vue2.mjs.map +1 -1
  19. package/es/packages/components/touchchat/component/AiRobot/face.vue.mjs +3 -2
  20. package/es/packages/components/touchchat/component/AiRobot/face.vue.mjs.map +1 -1
  21. package/es/packages/components/touchchat/component/AiRobot/face.vue2.mjs +27 -13
  22. package/es/packages/components/touchchat/component/AiRobot/face.vue2.mjs.map +1 -1
  23. package/es/packages/components/touchchat/component/AiRobot/letter.vue.mjs +3 -2
  24. package/es/packages/components/touchchat/component/AiRobot/letter.vue.mjs.map +1 -1
  25. package/es/packages/components/touchchat/component/AiRobot/letter.vue2.mjs +182 -41
  26. package/es/packages/components/touchchat/component/AiRobot/letter.vue2.mjs.map +1 -1
  27. package/es/packages/components/touchchat/component/AiRobot/meterialPrepare.vue.mjs +3 -2
  28. package/es/packages/components/touchchat/component/AiRobot/meterialPrepare.vue.mjs.map +1 -1
  29. package/es/packages/components/touchchat/component/AiRobot/meterialPrepare.vue2.mjs +15 -10
  30. package/es/packages/components/touchchat/component/AiRobot/meterialPrepare.vue2.mjs.map +1 -1
  31. package/es/packages/components/touchchat/component/AiRobot/start.vue.mjs +3 -2
  32. package/es/packages/components/touchchat/component/AiRobot/start.vue.mjs.map +1 -1
  33. package/es/packages/components/touchchat/component/AiRobot/start.vue2.mjs +18 -11
  34. package/es/packages/components/touchchat/component/AiRobot/start.vue2.mjs.map +1 -1
  35. package/es/packages/components/touchchat/component/CardView.vue.mjs +3 -2
  36. package/es/packages/components/touchchat/component/CardView.vue.mjs.map +1 -1
  37. package/es/packages/components/touchchat/component/CardView.vue2.mjs +66 -42
  38. package/es/packages/components/touchchat/component/CardView.vue2.mjs.map +1 -1
  39. package/es/packages/components/touchchat/component/FileContent.vue.mjs +7 -0
  40. package/es/packages/components/touchchat/component/FileContent.vue.mjs.map +1 -0
  41. package/es/packages/components/touchchat/component/FileContent.vue2.mjs +206 -0
  42. package/es/packages/components/touchchat/component/FileContent.vue2.mjs.map +1 -0
  43. package/es/packages/components/touchchat/component/FileView.vue.mjs +3 -2
  44. package/es/packages/components/touchchat/component/FileView.vue.mjs.map +1 -1
  45. package/es/packages/components/touchchat/component/FileView.vue2.mjs +17 -4
  46. package/es/packages/components/touchchat/component/FileView.vue2.mjs.map +1 -1
  47. package/es/packages/components/touchchat/component/HelloChat.vue.mjs +3 -2
  48. package/es/packages/components/touchchat/component/HelloChat.vue.mjs.map +1 -1
  49. package/es/packages/components/touchchat/component/HelloChat.vue2.mjs +26 -14
  50. package/es/packages/components/touchchat/component/HelloChat.vue2.mjs.map +1 -1
  51. package/es/packages/components/touchchat/component/ImageFile.vue.mjs +7 -0
  52. package/es/packages/components/touchchat/component/ImageFile.vue.mjs.map +1 -0
  53. package/es/packages/components/touchchat/component/ImageFile.vue2.mjs +162 -0
  54. package/es/packages/components/touchchat/component/ImageFile.vue2.mjs.map +1 -0
  55. package/es/packages/components/touchchat/component/ImageView.vue.mjs +3 -2
  56. package/es/packages/components/touchchat/component/ImageView.vue.mjs.map +1 -1
  57. package/es/packages/components/touchchat/component/ImageView.vue2.mjs +1 -1
  58. package/es/packages/components/touchchat/component/ImageView.vue2.mjs.map +1 -1
  59. package/es/packages/components/touchchat/component/LinkView.vue.mjs +3 -2
  60. package/es/packages/components/touchchat/component/LinkView.vue.mjs.map +1 -1
  61. package/es/packages/components/touchchat/component/LinkView.vue2.mjs +19 -5
  62. package/es/packages/components/touchchat/component/LinkView.vue2.mjs.map +1 -1
  63. package/es/packages/components/touchchat/component/MarkLayer.vue.mjs +7 -0
  64. package/es/packages/components/touchchat/component/MarkLayer.vue.mjs.map +1 -0
  65. package/es/packages/components/touchchat/component/MarkLayer.vue2.mjs +56 -0
  66. package/es/packages/components/touchchat/component/MarkLayer.vue2.mjs.map +1 -0
  67. package/es/packages/components/touchchat/component/ModuleSelect.vue.mjs +7 -0
  68. package/es/packages/components/touchchat/component/ModuleSelect.vue.mjs.map +1 -0
  69. package/es/packages/components/touchchat/component/ModuleSelect.vue2.mjs +121 -0
  70. package/es/packages/components/touchchat/component/ModuleSelect.vue2.mjs.map +1 -0
  71. package/es/packages/components/touchchat/component/PDFFile.vue.mjs +7 -0
  72. package/es/packages/components/touchchat/component/PDFFile.vue.mjs.map +1 -0
  73. package/es/packages/components/touchchat/component/PDFFile.vue2.mjs +211 -0
  74. package/es/packages/components/touchchat/component/PDFFile.vue2.mjs.map +1 -0
  75. package/es/packages/components/touchchat/component/QuoteContent.vue.mjs +7 -0
  76. package/es/packages/components/touchchat/component/QuoteContent.vue.mjs.map +1 -0
  77. package/es/packages/components/touchchat/component/QuoteContent.vue2.mjs +40 -0
  78. package/es/packages/components/touchchat/component/QuoteContent.vue2.mjs.map +1 -0
  79. package/es/packages/components/touchchat/component/RealtimeVoice.vue.mjs +7 -0
  80. package/es/packages/components/touchchat/component/RealtimeVoice.vue.mjs.map +1 -0
  81. package/es/packages/components/touchchat/component/RealtimeVoice.vue2.mjs +160 -0
  82. package/es/packages/components/touchchat/component/RealtimeVoice.vue2.mjs.map +1 -0
  83. package/es/packages/components/touchchat/component/Screenshot.vue.mjs +7 -0
  84. package/es/packages/components/touchchat/component/Screenshot.vue.mjs.map +1 -0
  85. package/es/packages/components/touchchat/component/Screenshot.vue2.mjs +208 -0
  86. package/es/packages/components/touchchat/component/Screenshot.vue2.mjs.map +1 -0
  87. package/es/packages/components/touchchat/component/ThoughtChain.vue.mjs +7 -0
  88. package/es/packages/components/touchchat/component/ThoughtChain.vue.mjs.map +1 -0
  89. package/es/packages/components/touchchat/component/ThoughtChain.vue2.mjs +69 -0
  90. package/es/packages/components/touchchat/component/ThoughtChain.vue2.mjs.map +1 -0
  91. package/es/packages/components/touchchat/component/UploadView.vue.mjs +7 -0
  92. package/es/packages/components/touchchat/component/UploadView.vue.mjs.map +1 -0
  93. package/es/packages/components/touchchat/component/UploadView.vue2.mjs +186 -0
  94. package/es/packages/components/touchchat/component/UploadView.vue2.mjs.map +1 -0
  95. package/es/packages/components/touchchat/component/UploadView_api.vue.mjs +7 -0
  96. package/es/packages/components/touchchat/component/UploadView_api.vue.mjs.map +1 -0
  97. package/es/packages/components/touchchat/component/UploadView_api.vue2.mjs +166 -0
  98. package/es/packages/components/touchchat/component/UploadView_api.vue2.mjs.map +1 -0
  99. package/es/packages/components/touchchat/component/VideoFile.vue.mjs +7 -0
  100. package/es/packages/components/touchchat/component/VideoFile.vue.mjs.map +1 -0
  101. package/es/packages/components/touchchat/component/VideoFile.vue2.mjs +33 -0
  102. package/es/packages/components/touchchat/component/VideoFile.vue2.mjs.map +1 -0
  103. package/es/packages/components/touchchat/component/VoiceView.vue.mjs +7 -0
  104. package/es/packages/components/touchchat/component/VoiceView.vue.mjs.map +1 -0
  105. package/es/packages/components/touchchat/component/VoiceView.vue2.mjs +165 -0
  106. package/es/packages/components/touchchat/component/VoiceView.vue2.mjs.map +1 -0
  107. package/es/packages/components/touchchat/img/file/doc.png.mjs +4 -0
  108. package/es/packages/components/touchchat/img/file/doc.png.mjs.map +1 -0
  109. package/es/packages/components/touchchat/img/file/docx.png.mjs +4 -0
  110. package/es/packages/components/touchchat/img/file/docx.png.mjs.map +1 -0
  111. package/es/packages/components/touchchat/img/file/gif.png.mjs +4 -0
  112. package/es/packages/components/touchchat/img/file/gif.png.mjs.map +1 -0
  113. package/es/packages/components/touchchat/img/file/html.png.mjs +4 -0
  114. package/es/packages/components/touchchat/img/file/html.png.mjs.map +1 -0
  115. package/es/packages/components/touchchat/img/file/jpg.png.mjs +4 -0
  116. package/es/packages/components/touchchat/img/file/jpg.png.mjs.map +1 -0
  117. package/es/packages/components/touchchat/img/file/mp3.png.mjs +4 -0
  118. package/es/packages/components/touchchat/img/file/mp3.png.mjs.map +1 -0
  119. package/es/packages/components/touchchat/img/file/mp4.png.mjs +4 -0
  120. package/es/packages/components/touchchat/img/file/mp4.png.mjs.map +1 -0
  121. package/es/packages/components/touchchat/img/file/music.png.mjs +4 -0
  122. package/es/packages/components/touchchat/img/file/music.png.mjs.map +1 -0
  123. package/es/packages/components/touchchat/img/file/pdf.png.mjs +4 -0
  124. package/es/packages/components/touchchat/img/file/pdf.png.mjs.map +1 -0
  125. package/es/packages/components/touchchat/img/file/png.png.mjs +4 -0
  126. package/es/packages/components/touchchat/img/file/png.png.mjs.map +1 -0
  127. package/es/packages/components/touchchat/img/file/ppt.png.mjs +4 -0
  128. package/es/packages/components/touchchat/img/file/ppt.png.mjs.map +1 -0
  129. package/es/packages/components/touchchat/img/file/pptx.png.mjs +4 -0
  130. package/es/packages/components/touchchat/img/file/pptx.png.mjs.map +1 -0
  131. package/es/packages/components/touchchat/img/file/txt.png.mjs +4 -0
  132. package/es/packages/components/touchchat/img/file/txt.png.mjs.map +1 -0
  133. package/es/packages/components/touchchat/img/file/xls.png.mjs +4 -0
  134. package/es/packages/components/touchchat/img/file/xls.png.mjs.map +1 -0
  135. package/es/packages/components/touchchat/img/file/xlsx.png.mjs +4 -0
  136. package/es/packages/components/touchchat/img/file/xlsx.png.mjs.map +1 -0
  137. package/es/packages/components/touchchat/img/svg/reset.svg.mjs +4 -0
  138. package/es/packages/components/touchchat/img/svg/reset.svg.mjs.map +1 -0
  139. package/es/packages/components/touchchat/index.mjs +5 -5
  140. package/es/packages/components/touchchat/index.mjs.map +1 -1
  141. package/es/packages/components/touchchat/src/AiChat/AgentsView.vue.mjs +7 -0
  142. package/es/packages/components/touchchat/src/AiChat/AgentsView.vue.mjs.map +1 -0
  143. package/es/packages/components/touchchat/src/AiChat/AgentsView.vue2.mjs +59 -0
  144. package/es/packages/components/touchchat/src/AiChat/AgentsView.vue2.mjs.map +1 -0
  145. package/es/packages/components/touchchat/src/AiChat/AiMessage.vue.mjs +3 -2
  146. package/es/packages/components/touchchat/src/AiChat/AiMessage.vue.mjs.map +1 -1
  147. package/es/packages/components/touchchat/src/AiChat/AiMessage.vue2.mjs +319 -139
  148. package/es/packages/components/touchchat/src/AiChat/AiMessage.vue2.mjs.map +1 -1
  149. package/es/packages/components/touchchat/src/AiChat/Chat/TouchChat.mjs +18 -0
  150. package/es/packages/components/touchchat/src/AiChat/Chat/TouchChat.mjs.map +1 -0
  151. package/es/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.mjs +145 -0
  152. package/es/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.mjs.map +1 -0
  153. package/es/packages/components/touchchat/src/AiChat/Chat/types.mjs +19 -0
  154. package/es/packages/components/touchchat/src/AiChat/Chat/types.mjs.map +1 -0
  155. package/es/packages/components/touchchat/src/AiChat/Chat/useChat.mjs +693 -0
  156. package/es/packages/components/touchchat/src/AiChat/Chat/useChat.mjs.map +1 -0
  157. package/es/packages/components/touchchat/src/AiChat/Chat/useCopy.mjs +55 -0
  158. package/es/packages/components/touchchat/src/AiChat/Chat/useCopy.mjs.map +1 -0
  159. package/es/packages/components/touchchat/src/AiChat/Chat/useMessageRender.mjs +155 -0
  160. package/es/packages/components/touchchat/src/AiChat/Chat/useMessageRender.mjs.map +1 -0
  161. package/es/packages/components/touchchat/src/AiChat/Chat/useSSE.mjs +345 -0
  162. package/es/packages/components/touchchat/src/AiChat/Chat/useSSE.mjs.map +1 -0
  163. package/es/packages/components/touchchat/src/AiChat/Chat/useScroll.mjs +74 -0
  164. package/es/packages/components/touchchat/src/AiChat/Chat/useScroll.mjs.map +1 -0
  165. package/es/packages/components/touchchat/src/AiChat/ChatInput.vue.mjs +3 -2
  166. package/es/packages/components/touchchat/src/AiChat/ChatInput.vue.mjs.map +1 -1
  167. package/es/packages/components/touchchat/src/AiChat/ChatInput.vue2.mjs +473 -44
  168. package/es/packages/components/touchchat/src/AiChat/ChatInput.vue2.mjs.map +1 -1
  169. package/es/packages/components/touchchat/src/AiChat/HistoryList.vue.mjs +3 -2
  170. package/es/packages/components/touchchat/src/AiChat/HistoryList.vue.mjs.map +1 -1
  171. package/es/packages/components/touchchat/src/AiChat/HistoryList.vue2.mjs +180 -98
  172. package/es/packages/components/touchchat/src/AiChat/HistoryList.vue2.mjs.map +1 -1
  173. package/es/packages/components/touchchat/src/AiChat/HistorySidebar.vue.mjs +3 -2
  174. package/es/packages/components/touchchat/src/AiChat/HistorySidebar.vue.mjs.map +1 -1
  175. package/es/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.mjs +29 -12
  176. package/es/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.mjs.map +1 -1
  177. package/es/packages/components/touchchat/src/AiChat/MessageActions.vue.mjs +3 -2
  178. package/es/packages/components/touchchat/src/AiChat/MessageActions.vue.mjs.map +1 -1
  179. package/es/packages/components/touchchat/src/AiChat/MessageActions.vue2.mjs +175 -62
  180. package/es/packages/components/touchchat/src/AiChat/MessageActions.vue2.mjs.map +1 -1
  181. package/es/packages/components/touchchat/src/AiChat/SiderBarView.vue.mjs +3 -2
  182. package/es/packages/components/touchchat/src/AiChat/SiderBarView.vue.mjs.map +1 -1
  183. package/es/packages/components/touchchat/src/AiChat/SiderBarView.vue2.mjs +14 -8
  184. package/es/packages/components/touchchat/src/AiChat/SiderBarView.vue2.mjs.map +1 -1
  185. package/es/packages/components/touchchat/src/AiChat/TouchAgent.vue.mjs +7 -0
  186. package/es/packages/components/touchchat/src/AiChat/TouchAgent.vue.mjs.map +1 -0
  187. package/es/packages/components/touchchat/src/AiChat/TouchAgent.vue2.mjs +1034 -0
  188. package/es/packages/components/touchchat/src/AiChat/TouchAgent.vue2.mjs.map +1 -0
  189. package/es/packages/components/touchchat/src/AiChat/TouchChat.vue.mjs +3 -2
  190. package/es/packages/components/touchchat/src/AiChat/TouchChat.vue.mjs.map +1 -1
  191. package/es/packages/components/touchchat/src/AiChat/TouchChat.vue2.mjs +276 -1004
  192. package/es/packages/components/touchchat/src/AiChat/TouchChat.vue2.mjs.map +1 -1
  193. package/es/packages/components/touchchat/src/AiChat/TouchHistory.vue.mjs +3 -2
  194. package/es/packages/components/touchchat/src/AiChat/TouchHistory.vue.mjs.map +1 -1
  195. package/es/packages/components/touchchat/src/AiChat/TouchHistory.vue2.mjs +346 -122
  196. package/es/packages/components/touchchat/src/AiChat/TouchHistory.vue2.mjs.map +1 -1
  197. package/es/packages/components/touchchat/src/AiChat/UserMessage.vue.mjs +3 -2
  198. package/es/packages/components/touchchat/src/AiChat/UserMessage.vue.mjs.map +1 -1
  199. package/es/packages/components/touchchat/src/AiChat/UserMessage.vue2.mjs +143 -64
  200. package/es/packages/components/touchchat/src/AiChat/UserMessage.vue2.mjs.map +1 -1
  201. package/es/packages/components/touchchat/src/index.vue.mjs +3 -2
  202. package/es/packages/components/touchchat/src/index.vue.mjs.map +1 -1
  203. package/es/packages/components/touchchat/src/index.vue2.mjs +252 -143
  204. package/es/packages/components/touchchat/src/index.vue2.mjs.map +1 -1
  205. package/es/packages/components/touchchat/src/types/a2a.mjs +11 -0
  206. package/es/packages/components/touchchat/src/types/a2a.mjs.map +1 -0
  207. package/es/packages/components/touchchat/utils/a2aService.mjs +316 -0
  208. package/es/packages/components/touchchat/utils/a2aService.mjs.map +1 -0
  209. package/es/packages/components/touchchat/utils/fetchStream.mjs +8 -2
  210. package/es/packages/components/touchchat/utils/fetchStream.mjs.map +1 -1
  211. package/es/packages/components/touchchat/utils/markdown.mjs +31 -13
  212. package/es/packages/components/touchchat/utils/markdown.mjs.map +1 -1
  213. package/es/packages/utils/config.mjs.map +1 -1
  214. package/es/packages/utils/types.mjs.map +1 -1
  215. package/global.d.ts +2 -2
  216. package/lib/_virtual/_plugin-vue_export-helper.js +14 -0
  217. package/lib/_virtual/_plugin-vue_export-helper.js.map +1 -0
  218. package/lib/index.js.map +1 -1
  219. package/lib/node_modules/.pnpm/@touchvue_a2ui@1.0.0-beta.46/node_modules/@touchvue/a2ui/dist/index.js +4819 -0
  220. package/lib/node_modules/.pnpm/@touchvue_a2ui@1.0.0-beta.46/node_modules/@touchvue/a2ui/dist/index.js.map +1 -0
  221. package/lib/node_modules/.pnpm/dompurify@3.4.3/node_modules/dompurify/dist/purify.es.js +1540 -0
  222. package/lib/node_modules/.pnpm/dompurify@3.4.3/node_modules/dompurify/dist/purify.es.js.map +1 -0
  223. package/lib/node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.js +7828 -0
  224. package/lib/node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.js.map +1 -0
  225. package/lib/package.json.css +1 -1
  226. package/lib/package.json.js +2 -2
  227. package/lib/packages/components/index.js +2 -2
  228. package/lib/packages/components/resolver.js.map +1 -1
  229. package/lib/packages/components/touchchat/component/AiRobot/HelloChat.vue.js +3 -2
  230. package/lib/packages/components/touchchat/component/AiRobot/HelloChat.vue.js.map +1 -1
  231. package/lib/packages/components/touchchat/component/AiRobot/HelloChat.vue2.js +219 -159
  232. package/lib/packages/components/touchchat/component/AiRobot/HelloChat.vue2.js.map +1 -1
  233. package/lib/packages/components/touchchat/component/AiRobot/face.vue.js +3 -2
  234. package/lib/packages/components/touchchat/component/AiRobot/face.vue.js.map +1 -1
  235. package/lib/packages/components/touchchat/component/AiRobot/face.vue2.js +26 -12
  236. package/lib/packages/components/touchchat/component/AiRobot/face.vue2.js.map +1 -1
  237. package/lib/packages/components/touchchat/component/AiRobot/letter.vue.js +3 -2
  238. package/lib/packages/components/touchchat/component/AiRobot/letter.vue.js.map +1 -1
  239. package/lib/packages/components/touchchat/component/AiRobot/letter.vue2.js +181 -40
  240. package/lib/packages/components/touchchat/component/AiRobot/letter.vue2.js.map +1 -1
  241. package/lib/packages/components/touchchat/component/AiRobot/meterialPrepare.vue.js +3 -2
  242. package/lib/packages/components/touchchat/component/AiRobot/meterialPrepare.vue.js.map +1 -1
  243. package/lib/packages/components/touchchat/component/AiRobot/meterialPrepare.vue2.js +15 -10
  244. package/lib/packages/components/touchchat/component/AiRobot/meterialPrepare.vue2.js.map +1 -1
  245. package/lib/packages/components/touchchat/component/AiRobot/start.vue.js +3 -2
  246. package/lib/packages/components/touchchat/component/AiRobot/start.vue.js.map +1 -1
  247. package/lib/packages/components/touchchat/component/AiRobot/start.vue2.js +17 -10
  248. package/lib/packages/components/touchchat/component/AiRobot/start.vue2.js.map +1 -1
  249. package/lib/packages/components/touchchat/component/CardView.vue.js +3 -2
  250. package/lib/packages/components/touchchat/component/CardView.vue.js.map +1 -1
  251. package/lib/packages/components/touchchat/component/CardView.vue2.js +66 -42
  252. package/lib/packages/components/touchchat/component/CardView.vue2.js.map +1 -1
  253. package/lib/packages/components/touchchat/component/FileContent.vue.js +11 -0
  254. package/lib/packages/components/touchchat/component/FileContent.vue.js.map +1 -0
  255. package/lib/packages/components/touchchat/component/FileContent.vue2.js +210 -0
  256. package/lib/packages/components/touchchat/component/FileContent.vue2.js.map +1 -0
  257. package/lib/packages/components/touchchat/component/FileView.vue.js +3 -2
  258. package/lib/packages/components/touchchat/component/FileView.vue.js.map +1 -1
  259. package/lib/packages/components/touchchat/component/FileView.vue2.js +16 -3
  260. package/lib/packages/components/touchchat/component/FileView.vue2.js.map +1 -1
  261. package/lib/packages/components/touchchat/component/HelloChat.vue.js +3 -2
  262. package/lib/packages/components/touchchat/component/HelloChat.vue.js.map +1 -1
  263. package/lib/packages/components/touchchat/component/HelloChat.vue2.js +26 -14
  264. package/lib/packages/components/touchchat/component/HelloChat.vue2.js.map +1 -1
  265. package/lib/packages/components/touchchat/component/ImageFile.vue.js +11 -0
  266. package/lib/packages/components/touchchat/component/ImageFile.vue.js.map +1 -0
  267. package/lib/packages/components/touchchat/component/ImageFile.vue2.js +166 -0
  268. package/lib/packages/components/touchchat/component/ImageFile.vue2.js.map +1 -0
  269. package/lib/packages/components/touchchat/component/ImageView.vue.js +3 -2
  270. package/lib/packages/components/touchchat/component/ImageView.vue.js.map +1 -1
  271. package/lib/packages/components/touchchat/component/ImageView.vue2.js +1 -1
  272. package/lib/packages/components/touchchat/component/ImageView.vue2.js.map +1 -1
  273. package/lib/packages/components/touchchat/component/LinkView.vue.js +3 -2
  274. package/lib/packages/components/touchchat/component/LinkView.vue.js.map +1 -1
  275. package/lib/packages/components/touchchat/component/LinkView.vue2.js +18 -4
  276. package/lib/packages/components/touchchat/component/LinkView.vue2.js.map +1 -1
  277. package/lib/packages/components/touchchat/component/MarkLayer.vue.js +11 -0
  278. package/lib/packages/components/touchchat/component/MarkLayer.vue.js.map +1 -0
  279. package/lib/packages/components/touchchat/component/MarkLayer.vue2.js +60 -0
  280. package/lib/packages/components/touchchat/component/MarkLayer.vue2.js.map +1 -0
  281. package/lib/packages/components/touchchat/component/ModuleSelect.vue.js +11 -0
  282. package/lib/packages/components/touchchat/component/ModuleSelect.vue.js.map +1 -0
  283. package/lib/packages/components/touchchat/component/ModuleSelect.vue2.js +125 -0
  284. package/lib/packages/components/touchchat/component/ModuleSelect.vue2.js.map +1 -0
  285. package/lib/packages/components/touchchat/component/PDFFile.vue.js +11 -0
  286. package/lib/packages/components/touchchat/component/PDFFile.vue.js.map +1 -0
  287. package/lib/packages/components/touchchat/component/PDFFile.vue2.js +215 -0
  288. package/lib/packages/components/touchchat/component/PDFFile.vue2.js.map +1 -0
  289. package/lib/packages/components/touchchat/component/QuoteContent.vue.js +11 -0
  290. package/lib/packages/components/touchchat/component/QuoteContent.vue.js.map +1 -0
  291. package/lib/packages/components/touchchat/component/QuoteContent.vue2.js +44 -0
  292. package/lib/packages/components/touchchat/component/QuoteContent.vue2.js.map +1 -0
  293. package/lib/packages/components/touchchat/component/RealtimeVoice.vue.js +11 -0
  294. package/lib/packages/components/touchchat/component/RealtimeVoice.vue.js.map +1 -0
  295. package/lib/packages/components/touchchat/component/RealtimeVoice.vue2.js +164 -0
  296. package/lib/packages/components/touchchat/component/RealtimeVoice.vue2.js.map +1 -0
  297. package/lib/packages/components/touchchat/component/Screenshot.vue.js +11 -0
  298. package/lib/packages/components/touchchat/component/Screenshot.vue.js.map +1 -0
  299. package/lib/packages/components/touchchat/component/Screenshot.vue2.js +212 -0
  300. package/lib/packages/components/touchchat/component/Screenshot.vue2.js.map +1 -0
  301. package/lib/packages/components/touchchat/component/ThoughtChain.vue.js +11 -0
  302. package/lib/packages/components/touchchat/component/ThoughtChain.vue.js.map +1 -0
  303. package/lib/packages/components/touchchat/component/ThoughtChain.vue2.js +73 -0
  304. package/lib/packages/components/touchchat/component/ThoughtChain.vue2.js.map +1 -0
  305. package/lib/packages/components/touchchat/component/UploadView.vue.js +11 -0
  306. package/lib/packages/components/touchchat/component/UploadView.vue.js.map +1 -0
  307. package/lib/packages/components/touchchat/component/UploadView.vue2.js +190 -0
  308. package/lib/packages/components/touchchat/component/UploadView.vue2.js.map +1 -0
  309. package/lib/packages/components/touchchat/component/UploadView_api.vue.js +11 -0
  310. package/lib/packages/components/touchchat/component/UploadView_api.vue.js.map +1 -0
  311. package/lib/packages/components/touchchat/component/UploadView_api.vue2.js +170 -0
  312. package/lib/packages/components/touchchat/component/UploadView_api.vue2.js.map +1 -0
  313. package/lib/packages/components/touchchat/component/VideoFile.vue.js +11 -0
  314. package/lib/packages/components/touchchat/component/VideoFile.vue.js.map +1 -0
  315. package/lib/packages/components/touchchat/component/VideoFile.vue2.js +37 -0
  316. package/lib/packages/components/touchchat/component/VideoFile.vue2.js.map +1 -0
  317. package/lib/packages/components/touchchat/component/VoiceView.vue.js +11 -0
  318. package/lib/packages/components/touchchat/component/VoiceView.vue.js.map +1 -0
  319. package/lib/packages/components/touchchat/component/VoiceView.vue2.js +169 -0
  320. package/lib/packages/components/touchchat/component/VoiceView.vue2.js.map +1 -0
  321. package/lib/packages/components/touchchat/img/file/doc.png.js +8 -0
  322. package/lib/packages/components/touchchat/img/file/doc.png.js.map +1 -0
  323. package/lib/packages/components/touchchat/img/file/docx.png.js +8 -0
  324. package/lib/packages/components/touchchat/img/file/docx.png.js.map +1 -0
  325. package/lib/packages/components/touchchat/img/file/gif.png.js +8 -0
  326. package/lib/packages/components/touchchat/img/file/gif.png.js.map +1 -0
  327. package/lib/packages/components/touchchat/img/file/html.png.js +8 -0
  328. package/lib/packages/components/touchchat/img/file/html.png.js.map +1 -0
  329. package/lib/packages/components/touchchat/img/file/jpg.png.js +8 -0
  330. package/lib/packages/components/touchchat/img/file/jpg.png.js.map +1 -0
  331. package/lib/packages/components/touchchat/img/file/mp3.png.js +8 -0
  332. package/lib/packages/components/touchchat/img/file/mp3.png.js.map +1 -0
  333. package/lib/packages/components/touchchat/img/file/mp4.png.js +8 -0
  334. package/lib/packages/components/touchchat/img/file/mp4.png.js.map +1 -0
  335. package/lib/packages/components/touchchat/img/file/music.png.js +8 -0
  336. package/lib/packages/components/touchchat/img/file/music.png.js.map +1 -0
  337. package/lib/packages/components/touchchat/img/file/pdf.png.js +8 -0
  338. package/lib/packages/components/touchchat/img/file/pdf.png.js.map +1 -0
  339. package/lib/packages/components/touchchat/img/file/png.png.js +8 -0
  340. package/lib/packages/components/touchchat/img/file/png.png.js.map +1 -0
  341. package/lib/packages/components/touchchat/img/file/ppt.png.js +8 -0
  342. package/lib/packages/components/touchchat/img/file/ppt.png.js.map +1 -0
  343. package/lib/packages/components/touchchat/img/file/pptx.png.js +8 -0
  344. package/lib/packages/components/touchchat/img/file/pptx.png.js.map +1 -0
  345. package/lib/packages/components/touchchat/img/file/txt.png.js +8 -0
  346. package/lib/packages/components/touchchat/img/file/txt.png.js.map +1 -0
  347. package/lib/packages/components/touchchat/img/file/xls.png.js +8 -0
  348. package/lib/packages/components/touchchat/img/file/xls.png.js.map +1 -0
  349. package/lib/packages/components/touchchat/img/file/xlsx.png.js +8 -0
  350. package/lib/packages/components/touchchat/img/file/xlsx.png.js.map +1 -0
  351. package/lib/packages/components/touchchat/img/svg/reset.svg.js +8 -0
  352. package/lib/packages/components/touchchat/img/svg/reset.svg.js.map +1 -0
  353. package/lib/packages/components/touchchat/index.js +6 -6
  354. package/lib/packages/components/touchchat/index.js.map +1 -1
  355. package/lib/packages/components/touchchat/src/AiChat/AgentsView.vue.js +11 -0
  356. package/lib/packages/components/touchchat/src/AiChat/AgentsView.vue.js.map +1 -0
  357. package/lib/packages/components/touchchat/src/AiChat/AgentsView.vue2.js +63 -0
  358. package/lib/packages/components/touchchat/src/AiChat/AgentsView.vue2.js.map +1 -0
  359. package/lib/packages/components/touchchat/src/AiChat/AiMessage.vue.js +3 -2
  360. package/lib/packages/components/touchchat/src/AiChat/AiMessage.vue.js.map +1 -1
  361. package/lib/packages/components/touchchat/src/AiChat/AiMessage.vue2.js +318 -138
  362. package/lib/packages/components/touchchat/src/AiChat/AiMessage.vue2.js.map +1 -1
  363. package/lib/packages/components/touchchat/src/AiChat/Chat/TouchChat.js +21 -0
  364. package/lib/packages/components/touchchat/src/AiChat/Chat/TouchChat.js.map +1 -0
  365. package/lib/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.js +147 -0
  366. package/lib/packages/components/touchchat/src/AiChat/Chat/scriptMatcher.js.map +1 -0
  367. package/lib/packages/components/touchchat/src/AiChat/Chat/types.js +22 -0
  368. package/lib/packages/components/touchchat/src/AiChat/Chat/types.js.map +1 -0
  369. package/lib/packages/components/touchchat/src/AiChat/Chat/useChat.js +695 -0
  370. package/lib/packages/components/touchchat/src/AiChat/Chat/useChat.js.map +1 -0
  371. package/lib/packages/components/touchchat/src/AiChat/Chat/useCopy.js +57 -0
  372. package/lib/packages/components/touchchat/src/AiChat/Chat/useCopy.js.map +1 -0
  373. package/lib/packages/components/touchchat/src/AiChat/Chat/useMessageRender.js +157 -0
  374. package/lib/packages/components/touchchat/src/AiChat/Chat/useMessageRender.js.map +1 -0
  375. package/lib/packages/components/touchchat/src/AiChat/Chat/useSSE.js +347 -0
  376. package/lib/packages/components/touchchat/src/AiChat/Chat/useSSE.js.map +1 -0
  377. package/lib/packages/components/touchchat/src/AiChat/Chat/useScroll.js +76 -0
  378. package/lib/packages/components/touchchat/src/AiChat/Chat/useScroll.js.map +1 -0
  379. package/lib/packages/components/touchchat/src/AiChat/ChatInput.vue.js +3 -2
  380. package/lib/packages/components/touchchat/src/AiChat/ChatInput.vue.js.map +1 -1
  381. package/lib/packages/components/touchchat/src/AiChat/ChatInput.vue2.js +472 -43
  382. package/lib/packages/components/touchchat/src/AiChat/ChatInput.vue2.js.map +1 -1
  383. package/lib/packages/components/touchchat/src/AiChat/HistoryList.vue.js +3 -2
  384. package/lib/packages/components/touchchat/src/AiChat/HistoryList.vue.js.map +1 -1
  385. package/lib/packages/components/touchchat/src/AiChat/HistoryList.vue2.js +179 -97
  386. package/lib/packages/components/touchchat/src/AiChat/HistoryList.vue2.js.map +1 -1
  387. package/lib/packages/components/touchchat/src/AiChat/HistorySidebar.vue.js +3 -2
  388. package/lib/packages/components/touchchat/src/AiChat/HistorySidebar.vue.js.map +1 -1
  389. package/lib/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.js +28 -11
  390. package/lib/packages/components/touchchat/src/AiChat/HistorySidebar.vue2.js.map +1 -1
  391. package/lib/packages/components/touchchat/src/AiChat/MessageActions.vue.js +3 -2
  392. package/lib/packages/components/touchchat/src/AiChat/MessageActions.vue.js.map +1 -1
  393. package/lib/packages/components/touchchat/src/AiChat/MessageActions.vue2.js +174 -61
  394. package/lib/packages/components/touchchat/src/AiChat/MessageActions.vue2.js.map +1 -1
  395. package/lib/packages/components/touchchat/src/AiChat/SiderBarView.vue.js +3 -2
  396. package/lib/packages/components/touchchat/src/AiChat/SiderBarView.vue.js.map +1 -1
  397. package/lib/packages/components/touchchat/src/AiChat/SiderBarView.vue2.js +14 -8
  398. package/lib/packages/components/touchchat/src/AiChat/SiderBarView.vue2.js.map +1 -1
  399. package/lib/packages/components/touchchat/src/AiChat/TouchAgent.vue.js +11 -0
  400. package/lib/packages/components/touchchat/src/AiChat/TouchAgent.vue.js.map +1 -0
  401. package/lib/packages/components/touchchat/src/AiChat/TouchAgent.vue2.js +1038 -0
  402. package/lib/packages/components/touchchat/src/AiChat/TouchAgent.vue2.js.map +1 -0
  403. package/lib/packages/components/touchchat/src/AiChat/TouchChat.vue.js +3 -2
  404. package/lib/packages/components/touchchat/src/AiChat/TouchChat.vue.js.map +1 -1
  405. package/lib/packages/components/touchchat/src/AiChat/TouchChat.vue2.js +275 -1003
  406. package/lib/packages/components/touchchat/src/AiChat/TouchChat.vue2.js.map +1 -1
  407. package/lib/packages/components/touchchat/src/AiChat/TouchHistory.vue.js +3 -2
  408. package/lib/packages/components/touchchat/src/AiChat/TouchHistory.vue.js.map +1 -1
  409. package/lib/packages/components/touchchat/src/AiChat/TouchHistory.vue2.js +345 -121
  410. package/lib/packages/components/touchchat/src/AiChat/TouchHistory.vue2.js.map +1 -1
  411. package/lib/packages/components/touchchat/src/AiChat/UserMessage.vue.js +3 -2
  412. package/lib/packages/components/touchchat/src/AiChat/UserMessage.vue.js.map +1 -1
  413. package/lib/packages/components/touchchat/src/AiChat/UserMessage.vue2.js +142 -63
  414. package/lib/packages/components/touchchat/src/AiChat/UserMessage.vue2.js.map +1 -1
  415. package/lib/packages/components/touchchat/src/index.vue.js +3 -2
  416. package/lib/packages/components/touchchat/src/index.vue.js.map +1 -1
  417. package/lib/packages/components/touchchat/src/index.vue2.js +251 -142
  418. package/lib/packages/components/touchchat/src/index.vue2.js.map +1 -1
  419. package/lib/packages/components/touchchat/src/types/a2a.js +13 -0
  420. package/lib/packages/components/touchchat/src/types/a2a.js.map +1 -0
  421. package/lib/packages/components/touchchat/utils/a2aService.js +319 -0
  422. package/lib/packages/components/touchchat/utils/a2aService.js.map +1 -0
  423. package/lib/packages/components/touchchat/utils/fetchStream.js +8 -2
  424. package/lib/packages/components/touchchat/utils/fetchStream.js.map +1 -1
  425. package/lib/packages/components/touchchat/utils/markdown.js +31 -13
  426. package/lib/packages/components/touchchat/utils/markdown.js.map +1 -1
  427. package/lib/packages/utils/config.js.map +1 -1
  428. package/lib/packages/utils/types.js.map +1 -1
  429. package/package.json +83 -83
  430. package/theme/components/index.css +969 -43
  431. package/theme/font/iconfont.woff +0 -0
  432. package/theme/font/iconfont.woff2 +0 -0
  433. package/theme/index.css +969 -43
  434. package/theme/skin/default.css +969 -43
  435. package/types/global.d.ts +2 -2
  436. package/es/packages/components/touchchat/src/AiChat/Scene.vue.mjs +0 -6
  437. package/es/packages/components/touchchat/src/AiChat/Scene.vue.mjs.map +0 -1
  438. package/es/packages/components/touchchat/src/AiChat/Scene.vue2.mjs +0 -42
  439. package/es/packages/components/touchchat/src/AiChat/Scene.vue2.mjs.map +0 -1
  440. package/lib/packages/components/touchchat/src/AiChat/Scene.vue.js +0 -10
  441. package/lib/packages/components/touchchat/src/AiChat/Scene.vue.js.map +0 -1
  442. package/lib/packages/components/touchchat/src/AiChat/Scene.vue2.js +0 -46
  443. package/lib/packages/components/touchchat/src/AiChat/Scene.vue2.js.map +0 -1
@@ -0,0 +1,1536 @@
1
+ /*! @license DOMPurify 3.4.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.3/LICENSE */
2
+
3
+ function _arrayLikeToArray(r, a) {
4
+ (null == a || a > r.length) && (a = r.length);
5
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
6
+ return n;
7
+ }
8
+ function _arrayWithHoles(r) {
9
+ if (Array.isArray(r)) return r;
10
+ }
11
+ function _iterableToArrayLimit(r, l) {
12
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
13
+ if (null != t) {
14
+ var e,
15
+ n,
16
+ i,
17
+ u,
18
+ a = [],
19
+ f = true,
20
+ o = false;
21
+ try {
22
+ 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 = !0);
23
+ } catch (r) {
24
+ o = true, n = r;
25
+ } finally {
26
+ try {
27
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
28
+ } finally {
29
+ if (o) throw n;
30
+ }
31
+ }
32
+ return a;
33
+ }
34
+ }
35
+ function _nonIterableRest() {
36
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
37
+ }
38
+ function _slicedToArray(r, e) {
39
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
40
+ }
41
+ function _unsupportedIterableToArray(r, a) {
42
+ if (r) {
43
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
44
+ var t = {}.toString.call(r).slice(8, -1);
45
+ 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;
46
+ }
47
+ }
48
+
49
+ const entries = Object.entries,
50
+ setPrototypeOf = Object.setPrototypeOf,
51
+ isFrozen = Object.isFrozen,
52
+ getPrototypeOf = Object.getPrototypeOf,
53
+ getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
54
+ let freeze = Object.freeze,
55
+ seal = Object.seal,
56
+ create = Object.create; // eslint-disable-line import/no-mutable-exports
57
+ let _ref = typeof Reflect !== 'undefined' && Reflect,
58
+ apply = _ref.apply,
59
+ construct = _ref.construct;
60
+ if (!freeze) {
61
+ freeze = function freeze(x) {
62
+ return x;
63
+ };
64
+ }
65
+ if (!seal) {
66
+ seal = function seal(x) {
67
+ return x;
68
+ };
69
+ }
70
+ if (!apply) {
71
+ apply = function apply(func, thisArg) {
72
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
73
+ args[_key - 2] = arguments[_key];
74
+ }
75
+ return func.apply(thisArg, args);
76
+ };
77
+ }
78
+ if (!construct) {
79
+ construct = function construct(Func) {
80
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
81
+ args[_key2 - 1] = arguments[_key2];
82
+ }
83
+ return new Func(...args);
84
+ };
85
+ }
86
+ const arrayForEach = unapply(Array.prototype.forEach);
87
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
88
+ const arrayPop = unapply(Array.prototype.pop);
89
+ const arrayPush = unapply(Array.prototype.push);
90
+ const arraySplice = unapply(Array.prototype.splice);
91
+ const arrayIsArray = Array.isArray;
92
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
93
+ const stringToString = unapply(String.prototype.toString);
94
+ const stringMatch = unapply(String.prototype.match);
95
+ const stringReplace = unapply(String.prototype.replace);
96
+ const stringIndexOf = unapply(String.prototype.indexOf);
97
+ const stringTrim = unapply(String.prototype.trim);
98
+ const numberToString = unapply(Number.prototype.toString);
99
+ const booleanToString = unapply(Boolean.prototype.toString);
100
+ const bigintToString = typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);
101
+ const symbolToString = typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);
102
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
103
+ const objectToString = unapply(Object.prototype.toString);
104
+ const regExpTest = unapply(RegExp.prototype.test);
105
+ const typeErrorCreate = unconstruct(TypeError);
106
+ /**
107
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
108
+ *
109
+ * @param func - The function to be wrapped and called.
110
+ * @returns A new function that calls the given function with a specified thisArg and arguments.
111
+ */
112
+ function unapply(func) {
113
+ return function (thisArg) {
114
+ if (thisArg instanceof RegExp) {
115
+ thisArg.lastIndex = 0;
116
+ }
117
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
118
+ args[_key3 - 1] = arguments[_key3];
119
+ }
120
+ return apply(func, thisArg, args);
121
+ };
122
+ }
123
+ /**
124
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
125
+ *
126
+ * @param func - The constructor function to be wrapped and called.
127
+ * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
128
+ */
129
+ function unconstruct(Func) {
130
+ return function () {
131
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
132
+ args[_key4] = arguments[_key4];
133
+ }
134
+ return construct(Func, args);
135
+ };
136
+ }
137
+ /**
138
+ * Add properties to a lookup table
139
+ *
140
+ * @param set - The set to which elements will be added.
141
+ * @param array - The array containing elements to be added to the set.
142
+ * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
143
+ * @returns The modified set with added elements.
144
+ */
145
+ function addToSet(set, array) {
146
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
147
+ if (setPrototypeOf) {
148
+ // Make 'in' and truthy checks like Boolean(set.constructor)
149
+ // independent of any properties defined on Object.prototype.
150
+ // Prevent prototype setters from intercepting set as a this value.
151
+ setPrototypeOf(set, null);
152
+ }
153
+ if (!arrayIsArray(array)) {
154
+ return set;
155
+ }
156
+ let l = array.length;
157
+ while (l--) {
158
+ let element = array[l];
159
+ if (typeof element === 'string') {
160
+ const lcElement = transformCaseFunc(element);
161
+ if (lcElement !== element) {
162
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
163
+ if (!isFrozen(array)) {
164
+ array[l] = lcElement;
165
+ }
166
+ element = lcElement;
167
+ }
168
+ }
169
+ set[element] = true;
170
+ }
171
+ return set;
172
+ }
173
+ /**
174
+ * Clean up an array to harden against CSPP
175
+ *
176
+ * @param array - The array to be cleaned.
177
+ * @returns The cleaned version of the array
178
+ */
179
+ function cleanArray(array) {
180
+ for (let index = 0; index < array.length; index++) {
181
+ const isPropertyExist = objectHasOwnProperty(array, index);
182
+ if (!isPropertyExist) {
183
+ array[index] = null;
184
+ }
185
+ }
186
+ return array;
187
+ }
188
+ /**
189
+ * Shallow clone an object
190
+ *
191
+ * @param object - The object to be cloned.
192
+ * @returns A new object that copies the original.
193
+ */
194
+ function clone(object) {
195
+ const newObject = create(null);
196
+ for (const _ref2 of entries(object)) {
197
+ var _ref3 = _slicedToArray(_ref2, 2);
198
+ const property = _ref3[0];
199
+ const value = _ref3[1];
200
+ const isPropertyExist = objectHasOwnProperty(object, property);
201
+ if (isPropertyExist) {
202
+ if (arrayIsArray(value)) {
203
+ newObject[property] = cleanArray(value);
204
+ } else if (value && typeof value === 'object' && value.constructor === Object) {
205
+ newObject[property] = clone(value);
206
+ } else {
207
+ newObject[property] = value;
208
+ }
209
+ }
210
+ }
211
+ return newObject;
212
+ }
213
+ /**
214
+ * Convert non-node values into strings without depending on direct property access.
215
+ *
216
+ * @param value - The value to stringify.
217
+ * @returns A string representation of the provided value.
218
+ */
219
+ function stringifyValue(value) {
220
+ switch (typeof value) {
221
+ case 'string':
222
+ {
223
+ return value;
224
+ }
225
+ case 'number':
226
+ {
227
+ return numberToString(value);
228
+ }
229
+ case 'boolean':
230
+ {
231
+ return booleanToString(value);
232
+ }
233
+ case 'bigint':
234
+ {
235
+ return bigintToString ? bigintToString(value) : '0';
236
+ }
237
+ case 'symbol':
238
+ {
239
+ return symbolToString ? symbolToString(value) : 'Symbol()';
240
+ }
241
+ case 'undefined':
242
+ {
243
+ return objectToString(value);
244
+ }
245
+ case 'function':
246
+ case 'object':
247
+ {
248
+ if (value === null) {
249
+ return objectToString(value);
250
+ }
251
+ const valueAsRecord = value;
252
+ const valueToString = lookupGetter(valueAsRecord, 'toString');
253
+ if (typeof valueToString === 'function') {
254
+ const stringified = valueToString(valueAsRecord);
255
+ return typeof stringified === 'string' ? stringified : objectToString(stringified);
256
+ }
257
+ return objectToString(value);
258
+ }
259
+ default:
260
+ {
261
+ return objectToString(value);
262
+ }
263
+ }
264
+ }
265
+ /**
266
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
267
+ *
268
+ * @param object - The object to look up the getter function in its prototype chain.
269
+ * @param prop - The property name for which to find the getter function.
270
+ * @returns The getter function found in the prototype chain or a fallback function.
271
+ */
272
+ function lookupGetter(object, prop) {
273
+ while (object !== null) {
274
+ const desc = getOwnPropertyDescriptor(object, prop);
275
+ if (desc) {
276
+ if (desc.get) {
277
+ return unapply(desc.get);
278
+ }
279
+ if (typeof desc.value === 'function') {
280
+ return unapply(desc.value);
281
+ }
282
+ }
283
+ object = getPrototypeOf(object);
284
+ }
285
+ function fallbackValue() {
286
+ return null;
287
+ }
288
+ return fallbackValue;
289
+ }
290
+ function isRegex(value) {
291
+ try {
292
+ regExpTest(value, '');
293
+ return true;
294
+ } catch (_unused) {
295
+ return false;
296
+ }
297
+ }
298
+
299
+ 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']);
300
+ 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']);
301
+ 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']);
302
+ // List of SVG elements that are disallowed by default.
303
+ // We still need to know them so that we can do namespace
304
+ // checks properly in case one wants to add them to
305
+ // allow-list.
306
+ 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']);
307
+ 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']);
308
+ // Similarly to SVG, we want to know all MathML elements,
309
+ // even those that we disallow by default.
310
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
311
+ const text = freeze(['#text']);
312
+
313
+ const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', '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']);
314
+ 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']);
315
+ 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']);
316
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
317
+
318
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
319
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
320
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
321
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
322
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
323
+ 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
324
+ );
325
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
326
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
327
+ );
328
+ const DOCTYPE_NAME = seal(/^html$/i);
329
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
330
+
331
+ /* eslint-disable @typescript-eslint/indent */
332
+ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
333
+ const NODE_TYPE = {
334
+ element: 1,
335
+ text: 3,
336
+ // Deprecated
337
+ progressingInstruction: 7,
338
+ comment: 8,
339
+ document: 9};
340
+ const getGlobal = function getGlobal() {
341
+ return typeof window === 'undefined' ? null : window;
342
+ };
343
+ /**
344
+ * Creates a no-op policy for internal use only.
345
+ * Don't export this function outside this module!
346
+ * @param trustedTypes The policy factory.
347
+ * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
348
+ * @return The policy created (or null, if Trusted Types
349
+ * are not supported or creating the policy failed).
350
+ */
351
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
352
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
353
+ return null;
354
+ }
355
+ // Allow the callers to control the unique policy name
356
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
357
+ // Policy creation with duplicate names throws in Trusted Types.
358
+ let suffix = null;
359
+ const ATTR_NAME = 'data-tt-policy-suffix';
360
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
361
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
362
+ }
363
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
364
+ try {
365
+ return trustedTypes.createPolicy(policyName, {
366
+ createHTML(html) {
367
+ return html;
368
+ },
369
+ createScriptURL(scriptUrl) {
370
+ return scriptUrl;
371
+ }
372
+ });
373
+ } catch (_) {
374
+ // Policy creation failed (most likely another DOMPurify script has
375
+ // already run). Skip creating the policy, as this will only cause errors
376
+ // if TT are enforced.
377
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
378
+ return null;
379
+ }
380
+ };
381
+ const _createHooksMap = function _createHooksMap() {
382
+ return {
383
+ afterSanitizeAttributes: [],
384
+ afterSanitizeElements: [],
385
+ afterSanitizeShadowDOM: [],
386
+ beforeSanitizeAttributes: [],
387
+ beforeSanitizeElements: [],
388
+ beforeSanitizeShadowDOM: [],
389
+ uponSanitizeAttribute: [],
390
+ uponSanitizeElement: [],
391
+ uponSanitizeShadowNode: []
392
+ };
393
+ };
394
+ function createDOMPurify() {
395
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
396
+ const DOMPurify = root => createDOMPurify(root);
397
+ DOMPurify.version = '3.4.3';
398
+ DOMPurify.removed = [];
399
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
400
+ // Not running in a browser, provide a factory function
401
+ // so that you can pass your own Window
402
+ DOMPurify.isSupported = false;
403
+ return DOMPurify;
404
+ }
405
+ let document = window.document;
406
+ const originalDocument = document;
407
+ const currentScript = originalDocument.currentScript;
408
+ const DocumentFragment = window.DocumentFragment,
409
+ HTMLTemplateElement = window.HTMLTemplateElement,
410
+ Node = window.Node,
411
+ Element = window.Element,
412
+ NodeFilter = window.NodeFilter,
413
+ _window$NamedNodeMap = window.NamedNodeMap,
414
+ NamedNodeMap = _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap,
415
+ HTMLFormElement = window.HTMLFormElement,
416
+ DOMParser = window.DOMParser,
417
+ trustedTypes = window.trustedTypes;
418
+ const ElementPrototype = Element.prototype;
419
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
420
+ const remove = lookupGetter(ElementPrototype, 'remove');
421
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
422
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
423
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
424
+ // As per issue #47, the web-components registry is inherited by a
425
+ // new document created via createHTMLDocument. As per the spec
426
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
427
+ // a new empty registry is used when creating a template contents owner
428
+ // document, so we use that as our parent document to ensure nothing
429
+ // is inherited.
430
+ if (typeof HTMLTemplateElement === 'function') {
431
+ const template = document.createElement('template');
432
+ if (template.content && template.content.ownerDocument) {
433
+ document = template.content.ownerDocument;
434
+ }
435
+ }
436
+ let trustedTypesPolicy;
437
+ let emptyHTML = '';
438
+ const _document = document,
439
+ implementation = _document.implementation,
440
+ createNodeIterator = _document.createNodeIterator,
441
+ createDocumentFragment = _document.createDocumentFragment,
442
+ getElementsByTagName = _document.getElementsByTagName;
443
+ const importNode = originalDocument.importNode;
444
+ let hooks = _createHooksMap();
445
+ /**
446
+ * Expose whether this browser supports running the full DOMPurify.
447
+ */
448
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
449
+ const MUSTACHE_EXPR$1 = MUSTACHE_EXPR,
450
+ ERB_EXPR$1 = ERB_EXPR,
451
+ TMPLIT_EXPR$1 = TMPLIT_EXPR,
452
+ DATA_ATTR$1 = DATA_ATTR,
453
+ ARIA_ATTR$1 = ARIA_ATTR,
454
+ IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
455
+ ATTR_WHITESPACE$1 = ATTR_WHITESPACE,
456
+ CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
457
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
458
+ /**
459
+ * We consider the elements and attributes below to be safe. Ideally
460
+ * don't add any new ones but feel free to remove unwanted ones.
461
+ */
462
+ /* allowed element names */
463
+ let ALLOWED_TAGS = null;
464
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
465
+ /* Allowed attribute names */
466
+ let ALLOWED_ATTR = null;
467
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
468
+ /*
469
+ * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
470
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
471
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
472
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
473
+ */
474
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
475
+ tagNameCheck: {
476
+ writable: true,
477
+ configurable: false,
478
+ enumerable: true,
479
+ value: null
480
+ },
481
+ attributeNameCheck: {
482
+ writable: true,
483
+ configurable: false,
484
+ enumerable: true,
485
+ value: null
486
+ },
487
+ allowCustomizedBuiltInElements: {
488
+ writable: true,
489
+ configurable: false,
490
+ enumerable: true,
491
+ value: false
492
+ }
493
+ }));
494
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
495
+ let FORBID_TAGS = null;
496
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
497
+ let FORBID_ATTR = null;
498
+ /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */
499
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
500
+ tagCheck: {
501
+ writable: true,
502
+ configurable: false,
503
+ enumerable: true,
504
+ value: null
505
+ },
506
+ attributeCheck: {
507
+ writable: true,
508
+ configurable: false,
509
+ enumerable: true,
510
+ value: null
511
+ }
512
+ }));
513
+ /* Decide if ARIA attributes are okay */
514
+ let ALLOW_ARIA_ATTR = true;
515
+ /* Decide if custom data attributes are okay */
516
+ let ALLOW_DATA_ATTR = true;
517
+ /* Decide if unknown protocols are okay */
518
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
519
+ /* Decide if self-closing tags in attributes are allowed.
520
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
521
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
522
+ /* Output should be safe for common template engines.
523
+ * This means, DOMPurify removes data attributes, mustaches and ERB
524
+ */
525
+ let SAFE_FOR_TEMPLATES = false;
526
+ /* Output should be safe even for XML used within HTML and alike.
527
+ * This means, DOMPurify removes comments when containing risky content.
528
+ */
529
+ let SAFE_FOR_XML = true;
530
+ /* Decide if document with <html>... should be returned */
531
+ let WHOLE_DOCUMENT = false;
532
+ /* Track whether config is already set on this instance of DOMPurify. */
533
+ let SET_CONFIG = false;
534
+ /* Decide if all elements (e.g. style, script) must be children of
535
+ * document.body. By default, browsers might move them to document.head */
536
+ let FORCE_BODY = false;
537
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
538
+ * string (or a TrustedHTML object if Trusted Types are supported).
539
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
540
+ */
541
+ let RETURN_DOM = false;
542
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
543
+ * string (or a TrustedHTML object if Trusted Types are supported) */
544
+ let RETURN_DOM_FRAGMENT = false;
545
+ /* Try to return a Trusted Type object instead of a string, return a string in
546
+ * case Trusted Types are not supported */
547
+ let RETURN_TRUSTED_TYPE = false;
548
+ /* Output should be free from DOM clobbering attacks?
549
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
550
+ */
551
+ let SANITIZE_DOM = true;
552
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
553
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
554
+ *
555
+ * HTML/DOM spec rules that enable DOM Clobbering:
556
+ * - Named Access on Window (§7.3.3)
557
+ * - DOM Tree Accessors (§3.1.5)
558
+ * - Form Element Parent-Child Relations (§4.10.3)
559
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
560
+ * - HTMLCollection (§4.2.10.2)
561
+ *
562
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
563
+ * with a constant string, i.e., `user-content-`
564
+ */
565
+ let SANITIZE_NAMED_PROPS = false;
566
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
567
+ /* Keep element content when removing element? */
568
+ let KEEP_CONTENT = true;
569
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
570
+ * of importing it into a new Document and returning a sanitized copy */
571
+ let IN_PLACE = false;
572
+ /* Allow usage of profiles like html, svg and mathMl */
573
+ let USE_PROFILES = {};
574
+ /* Tags to ignore content of when KEEP_CONTENT is true */
575
+ let FORBID_CONTENTS = null;
576
+ 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']);
577
+ /* Tags that are safe for data: URIs */
578
+ let DATA_URI_TAGS = null;
579
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
580
+ /* Attributes safe for values like "javascript:" */
581
+ let URI_SAFE_ATTRIBUTES = null;
582
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
583
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
584
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
585
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
586
+ /* Document namespace */
587
+ let NAMESPACE = HTML_NAMESPACE;
588
+ let IS_EMPTY_INPUT = false;
589
+ /* Allowed XHTML+XML namespaces */
590
+ let ALLOWED_NAMESPACES = null;
591
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
592
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
593
+ let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);
594
+ // Certain elements are allowed in both SVG and HTML
595
+ // namespace. We need to specify them explicitly
596
+ // so that they don't get erroneously deleted from
597
+ // HTML namespace.
598
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
599
+ /* Parsing of strict XHTML documents */
600
+ let PARSER_MEDIA_TYPE = null;
601
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
602
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
603
+ let transformCaseFunc = null;
604
+ /* Keep a reference to config to pass to hooks */
605
+ let CONFIG = null;
606
+ /* Ideally, do not touch anything below this line */
607
+ /* ______________________________________________ */
608
+ const formElement = document.createElement('form');
609
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
610
+ return testValue instanceof RegExp || testValue instanceof Function;
611
+ };
612
+ /**
613
+ * _parseConfig
614
+ *
615
+ * @param cfg optional config literal
616
+ */
617
+ // eslint-disable-next-line complexity
618
+ const _parseConfig = function _parseConfig() {
619
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
620
+ if (CONFIG && CONFIG === cfg) {
621
+ return;
622
+ }
623
+ /* Shield configuration object from tampering */
624
+ if (!cfg || typeof cfg !== 'object') {
625
+ cfg = {};
626
+ }
627
+ /* Shield configuration object from prototype pollution */
628
+ cfg = clone(cfg);
629
+ PARSER_MEDIA_TYPE =
630
+ // eslint-disable-next-line unicorn/prefer-includes
631
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
632
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
633
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
634
+ /* Set configuration parameters */
635
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
636
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
637
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
638
+ 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;
639
+ 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;
640
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
641
+ FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
642
+ FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
643
+ USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
644
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
645
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
646
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
647
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
648
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
649
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
650
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
651
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
652
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
653
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
654
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
655
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
656
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
657
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
658
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
659
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp
660
+ NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace
661
+ 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
662
+ 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
663
+ const customElementHandling = objectHasOwnProperty(cfg, 'CUSTOM_ELEMENT_HANDLING') && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === 'object' ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
664
+ CUSTOM_ELEMENT_HANDLING = create(null);
665
+ if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {
666
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck; // Default undefined
667
+ }
668
+ if (objectHasOwnProperty(customElementHandling, 'attributeNameCheck') && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
669
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck; // Default undefined
670
+ }
671
+ if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {
672
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined
673
+ }
674
+ if (SAFE_FOR_TEMPLATES) {
675
+ ALLOW_DATA_ATTR = false;
676
+ }
677
+ if (RETURN_DOM_FRAGMENT) {
678
+ RETURN_DOM = true;
679
+ }
680
+ /* Parse profile info */
681
+ if (USE_PROFILES) {
682
+ ALLOWED_TAGS = addToSet({}, text);
683
+ ALLOWED_ATTR = create(null);
684
+ if (USE_PROFILES.html === true) {
685
+ addToSet(ALLOWED_TAGS, html$1);
686
+ addToSet(ALLOWED_ATTR, html);
687
+ }
688
+ if (USE_PROFILES.svg === true) {
689
+ addToSet(ALLOWED_TAGS, svg$1);
690
+ addToSet(ALLOWED_ATTR, svg);
691
+ addToSet(ALLOWED_ATTR, xml);
692
+ }
693
+ if (USE_PROFILES.svgFilters === true) {
694
+ addToSet(ALLOWED_TAGS, svgFilters);
695
+ addToSet(ALLOWED_ATTR, svg);
696
+ addToSet(ALLOWED_ATTR, xml);
697
+ }
698
+ if (USE_PROFILES.mathMl === true) {
699
+ addToSet(ALLOWED_TAGS, mathMl$1);
700
+ addToSet(ALLOWED_ATTR, mathMl);
701
+ addToSet(ALLOWED_ATTR, xml);
702
+ }
703
+ }
704
+ /* Always reset function-based ADD_TAGS / ADD_ATTR checks to prevent
705
+ * leaking across calls when switching from function to array config */
706
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
707
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
708
+ /* Merge configuration parameters */
709
+ if (objectHasOwnProperty(cfg, 'ADD_TAGS')) {
710
+ if (typeof cfg.ADD_TAGS === 'function') {
711
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
712
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
713
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
714
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
715
+ }
716
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
717
+ }
718
+ }
719
+ if (objectHasOwnProperty(cfg, 'ADD_ATTR')) {
720
+ if (typeof cfg.ADD_ATTR === 'function') {
721
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
722
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
723
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
724
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
725
+ }
726
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
727
+ }
728
+ }
729
+ if (objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
730
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
731
+ }
732
+ if (objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS)) {
733
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
734
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
735
+ }
736
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
737
+ }
738
+ if (objectHasOwnProperty(cfg, 'ADD_FORBID_CONTENTS') && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
739
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
740
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
741
+ }
742
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
743
+ }
744
+ /* Add #text in case KEEP_CONTENT is set to true */
745
+ if (KEEP_CONTENT) {
746
+ ALLOWED_TAGS['#text'] = true;
747
+ }
748
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
749
+ if (WHOLE_DOCUMENT) {
750
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
751
+ }
752
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
753
+ if (ALLOWED_TAGS.table) {
754
+ addToSet(ALLOWED_TAGS, ['tbody']);
755
+ delete FORBID_TAGS.tbody;
756
+ }
757
+ if (cfg.TRUSTED_TYPES_POLICY) {
758
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
759
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
760
+ }
761
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
762
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
763
+ }
764
+ // Overwrite existing TrustedTypes policy.
765
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
766
+ // Sign local variables required by `sanitize`.
767
+ emptyHTML = trustedTypesPolicy.createHTML('');
768
+ } else {
769
+ // Uninitialized policy, attempt to initialize the internal dompurify policy.
770
+ if (trustedTypesPolicy === undefined) {
771
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
772
+ }
773
+ // If creating the internal policy succeeded sign internal variables.
774
+ if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
775
+ emptyHTML = trustedTypesPolicy.createHTML('');
776
+ }
777
+ }
778
+ // Prevent further manipulation of configuration.
779
+ // Not available in IE8, Safari 5, etc.
780
+ if (freeze) {
781
+ freeze(cfg);
782
+ }
783
+ CONFIG = cfg;
784
+ };
785
+ /* Keep track of all possible SVG and MathML tags
786
+ * so that we can perform the namespace checks
787
+ * correctly. */
788
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
789
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
790
+ /**
791
+ * @param element a DOM element whose namespace is being checked
792
+ * @returns Return false if the element has a
793
+ * namespace that a spec-compliant parser would never
794
+ * return. Return true otherwise.
795
+ */
796
+ const _checkValidNamespace = function _checkValidNamespace(element) {
797
+ let parent = getParentNode(element);
798
+ // In JSDOM, if we're inside shadow DOM, then parentNode
799
+ // can be null. We just simulate parent in this case.
800
+ if (!parent || !parent.tagName) {
801
+ parent = {
802
+ namespaceURI: NAMESPACE,
803
+ tagName: 'template'
804
+ };
805
+ }
806
+ const tagName = stringToLowerCase(element.tagName);
807
+ const parentTagName = stringToLowerCase(parent.tagName);
808
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
809
+ return false;
810
+ }
811
+ if (element.namespaceURI === SVG_NAMESPACE) {
812
+ // The only way to switch from HTML namespace to SVG
813
+ // is via <svg>. If it happens via any other tag, then
814
+ // it should be killed.
815
+ if (parent.namespaceURI === HTML_NAMESPACE) {
816
+ return tagName === 'svg';
817
+ }
818
+ // The only way to switch from MathML to SVG is via`
819
+ // svg if parent is either <annotation-xml> or MathML
820
+ // text integration points.
821
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
822
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
823
+ }
824
+ // We only allow elements that are defined in SVG
825
+ // spec. All others are disallowed in SVG namespace.
826
+ return Boolean(ALL_SVG_TAGS[tagName]);
827
+ }
828
+ if (element.namespaceURI === MATHML_NAMESPACE) {
829
+ // The only way to switch from HTML namespace to MathML
830
+ // is via <math>. If it happens via any other tag, then
831
+ // it should be killed.
832
+ if (parent.namespaceURI === HTML_NAMESPACE) {
833
+ return tagName === 'math';
834
+ }
835
+ // The only way to switch from SVG to MathML is via
836
+ // <math> and HTML integration points
837
+ if (parent.namespaceURI === SVG_NAMESPACE) {
838
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
839
+ }
840
+ // We only allow elements that are defined in MathML
841
+ // spec. All others are disallowed in MathML namespace.
842
+ return Boolean(ALL_MATHML_TAGS[tagName]);
843
+ }
844
+ if (element.namespaceURI === HTML_NAMESPACE) {
845
+ // The only way to switch from SVG to HTML is via
846
+ // HTML integration points, and from MathML to HTML
847
+ // is via MathML text integration points
848
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
849
+ return false;
850
+ }
851
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
852
+ return false;
853
+ }
854
+ // We disallow tags that are specific for MathML
855
+ // or SVG and should never appear in HTML namespace
856
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
857
+ }
858
+ // For XHTML and XML documents that support custom namespaces
859
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
860
+ return true;
861
+ }
862
+ // The code should never reach this place (this means
863
+ // that the element somehow got namespace that is not
864
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
865
+ // Return false just in case.
866
+ return false;
867
+ };
868
+ /**
869
+ * _forceRemove
870
+ *
871
+ * @param node a DOM node
872
+ */
873
+ const _forceRemove = function _forceRemove(node) {
874
+ arrayPush(DOMPurify.removed, {
875
+ element: node
876
+ });
877
+ try {
878
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
879
+ getParentNode(node).removeChild(node);
880
+ } catch (_) {
881
+ remove(node);
882
+ }
883
+ };
884
+ /**
885
+ * _removeAttribute
886
+ *
887
+ * @param name an Attribute name
888
+ * @param element a DOM node
889
+ */
890
+ const _removeAttribute = function _removeAttribute(name, element) {
891
+ try {
892
+ arrayPush(DOMPurify.removed, {
893
+ attribute: element.getAttributeNode(name),
894
+ from: element
895
+ });
896
+ } catch (_) {
897
+ arrayPush(DOMPurify.removed, {
898
+ attribute: null,
899
+ from: element
900
+ });
901
+ }
902
+ element.removeAttribute(name);
903
+ // We void attribute values for unremovable "is" attributes
904
+ if (name === 'is') {
905
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
906
+ try {
907
+ _forceRemove(element);
908
+ } catch (_) {}
909
+ } else {
910
+ try {
911
+ element.setAttribute(name, '');
912
+ } catch (_) {}
913
+ }
914
+ }
915
+ };
916
+ /**
917
+ * _initDocument
918
+ *
919
+ * @param dirty - a string of dirty markup
920
+ * @return a DOM, filled with the dirty markup
921
+ */
922
+ const _initDocument = function _initDocument(dirty) {
923
+ /* Create a HTML document */
924
+ let doc = null;
925
+ let leadingWhitespace = null;
926
+ if (FORCE_BODY) {
927
+ dirty = '<remove></remove>' + dirty;
928
+ } else {
929
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
930
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
931
+ leadingWhitespace = matches && matches[0];
932
+ }
933
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
934
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
935
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
936
+ }
937
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
938
+ /*
939
+ * Use the DOMParser API by default, fallback later if needs be
940
+ * DOMParser not work for svg when has multiple root element.
941
+ */
942
+ if (NAMESPACE === HTML_NAMESPACE) {
943
+ try {
944
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
945
+ } catch (_) {}
946
+ }
947
+ /* Use createHTMLDocument in case DOMParser is not available */
948
+ if (!doc || !doc.documentElement) {
949
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
950
+ try {
951
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
952
+ } catch (_) {
953
+ // Syntax error if dirtyPayload is invalid xml
954
+ }
955
+ }
956
+ const body = doc.body || doc.documentElement;
957
+ if (dirty && leadingWhitespace) {
958
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
959
+ }
960
+ /* Work on whole document or just its body */
961
+ if (NAMESPACE === HTML_NAMESPACE) {
962
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
963
+ }
964
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
965
+ };
966
+ /**
967
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
968
+ *
969
+ * @param root The root element or node to start traversing on.
970
+ * @return The created NodeIterator
971
+ */
972
+ const _createNodeIterator = function _createNodeIterator(root) {
973
+ return createNodeIterator.call(root.ownerDocument || root, root,
974
+ // eslint-disable-next-line no-bitwise
975
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
976
+ };
977
+ /**
978
+ * _isClobbered
979
+ *
980
+ * @param element element to check for clobbering attacks
981
+ * @return true if clobbered, false if safe
982
+ */
983
+ const _isClobbered = function _isClobbered(element) {
984
+ return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function');
985
+ };
986
+ /**
987
+ * Checks whether the given object is a DOM node.
988
+ *
989
+ * @param value object to check whether it's a DOM node
990
+ * @return true is object is a DOM node
991
+ */
992
+ const _isNode = function _isNode(value) {
993
+ return typeof Node === 'function' && value instanceof Node;
994
+ };
995
+ function _executeHooks(hooks, currentNode, data) {
996
+ arrayForEach(hooks, hook => {
997
+ hook.call(DOMPurify, currentNode, data, CONFIG);
998
+ });
999
+ }
1000
+ /**
1001
+ * _sanitizeElements
1002
+ *
1003
+ * @protect nodeName
1004
+ * @protect textContent
1005
+ * @protect removeChild
1006
+ * @param currentNode to check for permission to exist
1007
+ * @return true if node was killed, false if left alive
1008
+ */
1009
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
1010
+ let content = null;
1011
+ /* Execute a hook if present */
1012
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
1013
+ /* Check if element is clobbered or can clobber */
1014
+ if (_isClobbered(currentNode)) {
1015
+ _forceRemove(currentNode);
1016
+ return true;
1017
+ }
1018
+ /* Now let's check the element's type and name */
1019
+ const tagName = transformCaseFunc(currentNode.nodeName);
1020
+ /* Execute a hook if present */
1021
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
1022
+ tagName,
1023
+ allowedTags: ALLOWED_TAGS
1024
+ });
1025
+ /* Detect mXSS attempts abusing namespace confusion */
1026
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
1027
+ _forceRemove(currentNode);
1028
+ return true;
1029
+ }
1030
+ /* Remove risky CSS construction leading to mXSS */
1031
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
1032
+ _forceRemove(currentNode);
1033
+ return true;
1034
+ }
1035
+ /* Remove any occurrence of processing instructions */
1036
+ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
1037
+ _forceRemove(currentNode);
1038
+ return true;
1039
+ }
1040
+ /* Remove any kind of possibly harmful comments */
1041
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
1042
+ _forceRemove(currentNode);
1043
+ return true;
1044
+ }
1045
+ /* Remove element if anything forbids its presence */
1046
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
1047
+ /* Check if we have a custom element to handle */
1048
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
1049
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
1050
+ return false;
1051
+ }
1052
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
1053
+ return false;
1054
+ }
1055
+ }
1056
+ /* Keep content except for bad-listed elements */
1057
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1058
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
1059
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
1060
+ if (childNodes && parentNode) {
1061
+ const childCount = childNodes.length;
1062
+ for (let i = childCount - 1; i >= 0; --i) {
1063
+ const childClone = cloneNode(childNodes[i], true);
1064
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
1065
+ }
1066
+ }
1067
+ }
1068
+ _forceRemove(currentNode);
1069
+ return true;
1070
+ }
1071
+ /* Check whether element has a valid namespace */
1072
+ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
1073
+ _forceRemove(currentNode);
1074
+ return true;
1075
+ }
1076
+ /* Make sure that older browsers don't get fallback-tag mXSS */
1077
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
1078
+ _forceRemove(currentNode);
1079
+ return true;
1080
+ }
1081
+ /* Sanitize element content to be template-safe */
1082
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
1083
+ /* Get the element's text content */
1084
+ content = currentNode.textContent;
1085
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1086
+ content = stringReplace(content, expr, ' ');
1087
+ });
1088
+ if (currentNode.textContent !== content) {
1089
+ arrayPush(DOMPurify.removed, {
1090
+ element: currentNode.cloneNode()
1091
+ });
1092
+ currentNode.textContent = content;
1093
+ }
1094
+ }
1095
+ /* Execute a hook if present */
1096
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
1097
+ return false;
1098
+ };
1099
+ /**
1100
+ * _isValidAttribute
1101
+ *
1102
+ * @param lcTag Lowercase tag name of containing element.
1103
+ * @param lcName Lowercase attribute name.
1104
+ * @param value Attribute value.
1105
+ * @return Returns true if `value` is valid, otherwise false.
1106
+ */
1107
+ // eslint-disable-next-line complexity
1108
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1109
+ /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
1110
+ if (FORBID_ATTR[lcName]) {
1111
+ return false;
1112
+ }
1113
+ /* Make sure attribute cannot clobber */
1114
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1115
+ return false;
1116
+ }
1117
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
1118
+ /* Allow valid data-* attributes: At least one character after "-"
1119
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
1120
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
1121
+ We don't need to check the value; it's always URI safe. */
1122
+ 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]) {
1123
+ if (
1124
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1125
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1126
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1127
+ _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)) ||
1128
+ // Alternative, second condition checks if it's an `is`-attribute, AND
1129
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1130
+ 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 {
1131
+ return false;
1132
+ }
1133
+ /* Check value is safe. First, is attr inert? If so, is safe */
1134
+ } 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) {
1135
+ return false;
1136
+ } else ;
1137
+ return true;
1138
+ };
1139
+ /* Names the HTML spec reserves from valid-custom-element-name; these must
1140
+ * never be treated as basic custom elements even when a permissive
1141
+ * CUSTOM_ELEMENT_HANDLING.tagNameCheck is configured. */
1142
+ 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']);
1143
+ /**
1144
+ * _isBasicCustomElement
1145
+ * checks if at least one dash is included in tagName, and it's not the first char
1146
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
1147
+ *
1148
+ * @param tagName name of the tag of the node to sanitize
1149
+ * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
1150
+ */
1151
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
1152
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
1153
+ };
1154
+ /**
1155
+ * _sanitizeAttributes
1156
+ *
1157
+ * @protect attributes
1158
+ * @protect nodeName
1159
+ * @protect removeAttribute
1160
+ * @protect setAttribute
1161
+ *
1162
+ * @param currentNode to sanitize
1163
+ */
1164
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
1165
+ /* Execute a hook if present */
1166
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
1167
+ const attributes = currentNode.attributes;
1168
+ /* Check if we have attributes; if not we might have a text node */
1169
+ if (!attributes || _isClobbered(currentNode)) {
1170
+ return;
1171
+ }
1172
+ const hookEvent = {
1173
+ attrName: '',
1174
+ attrValue: '',
1175
+ keepAttr: true,
1176
+ allowedAttributes: ALLOWED_ATTR,
1177
+ forceKeepAttr: undefined
1178
+ };
1179
+ let l = attributes.length;
1180
+ /* Go backwards over all attributes; safely remove bad ones */
1181
+ while (l--) {
1182
+ const attr = attributes[l];
1183
+ const name = attr.name,
1184
+ namespaceURI = attr.namespaceURI,
1185
+ attrValue = attr.value;
1186
+ const lcName = transformCaseFunc(name);
1187
+ const initValue = attrValue;
1188
+ let value = name === 'value' ? initValue : stringTrim(initValue);
1189
+ /* Execute a hook if present */
1190
+ hookEvent.attrName = lcName;
1191
+ hookEvent.attrValue = value;
1192
+ hookEvent.keepAttr = true;
1193
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1194
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
1195
+ value = hookEvent.attrValue;
1196
+ /* Full DOM Clobbering protection via namespace isolation,
1197
+ * Prefix id and name attributes with `user-content-`
1198
+ */
1199
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name') && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
1200
+ // Remove the attribute with this value
1201
+ _removeAttribute(name, currentNode);
1202
+ // Prefix the value and later re-create the attribute with the sanitized value
1203
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
1204
+ }
1205
+ // Else: already prefixed, leave the attribute alone — the prefix is
1206
+ // itself the clobbering protection, and re-applying it is incorrect.
1207
+ /* Work around a security issue with comments inside attributes */
1208
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
1209
+ _removeAttribute(name, currentNode);
1210
+ continue;
1211
+ }
1212
+ /* Make sure we cannot easily use animated hrefs, even if animations are allowed */
1213
+ if (lcName === 'attributename' && stringMatch(value, 'href')) {
1214
+ _removeAttribute(name, currentNode);
1215
+ continue;
1216
+ }
1217
+ /* Did the hooks approve of the attribute? */
1218
+ if (hookEvent.forceKeepAttr) {
1219
+ continue;
1220
+ }
1221
+ /* Did the hooks approve of the attribute? */
1222
+ if (!hookEvent.keepAttr) {
1223
+ _removeAttribute(name, currentNode);
1224
+ continue;
1225
+ }
1226
+ /* Work around a security issue in jQuery 3.0 */
1227
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
1228
+ _removeAttribute(name, currentNode);
1229
+ continue;
1230
+ }
1231
+ /* Sanitize attribute content to be template-safe */
1232
+ if (SAFE_FOR_TEMPLATES) {
1233
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1234
+ value = stringReplace(value, expr, ' ');
1235
+ });
1236
+ }
1237
+ /* Is `value` valid for this attribute? */
1238
+ const lcTag = transformCaseFunc(currentNode.nodeName);
1239
+ if (!_isValidAttribute(lcTag, lcName, value)) {
1240
+ _removeAttribute(name, currentNode);
1241
+ continue;
1242
+ }
1243
+ /* Handle attributes that require Trusted Types */
1244
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
1245
+ if (namespaceURI) ; else {
1246
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
1247
+ case 'TrustedHTML':
1248
+ {
1249
+ value = trustedTypesPolicy.createHTML(value);
1250
+ break;
1251
+ }
1252
+ case 'TrustedScriptURL':
1253
+ {
1254
+ value = trustedTypesPolicy.createScriptURL(value);
1255
+ break;
1256
+ }
1257
+ }
1258
+ }
1259
+ }
1260
+ /* Handle invalid data-* attribute set by try-catching it */
1261
+ if (value !== initValue) {
1262
+ try {
1263
+ if (namespaceURI) {
1264
+ currentNode.setAttributeNS(namespaceURI, name, value);
1265
+ } else {
1266
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1267
+ currentNode.setAttribute(name, value);
1268
+ }
1269
+ if (_isClobbered(currentNode)) {
1270
+ _forceRemove(currentNode);
1271
+ } else {
1272
+ arrayPop(DOMPurify.removed);
1273
+ }
1274
+ } catch (_) {
1275
+ _removeAttribute(name, currentNode);
1276
+ }
1277
+ }
1278
+ }
1279
+ /* Execute a hook if present */
1280
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
1281
+ };
1282
+ /**
1283
+ * _sanitizeShadowDOM
1284
+ *
1285
+ * @param fragment to iterate over recursively
1286
+ */
1287
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
1288
+ let shadowNode = null;
1289
+ const shadowIterator = _createNodeIterator(fragment);
1290
+ /* Execute a hook if present */
1291
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
1292
+ while (shadowNode = shadowIterator.nextNode()) {
1293
+ /* Execute a hook if present */
1294
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
1295
+ /* Sanitize tags and elements */
1296
+ _sanitizeElements(shadowNode);
1297
+ /* Check attributes next */
1298
+ _sanitizeAttributes(shadowNode);
1299
+ /* Deep shadow DOM detected */
1300
+ if (shadowNode.content instanceof DocumentFragment) {
1301
+ _sanitizeShadowDOM2(shadowNode.content);
1302
+ }
1303
+ }
1304
+ /* Execute a hook if present */
1305
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
1306
+ };
1307
+ /**
1308
+ * _sanitizeAttachedShadowRoots
1309
+ *
1310
+ * Walks `root` and feeds every attached shadow root we encounter into
1311
+ * the existing _sanitizeShadowDOM pipeline. The default node iterator
1312
+ * does not descend into shadow trees, so nodes inside an attached
1313
+ * shadow root would otherwise be skipped entirely.
1314
+ *
1315
+ * Two real input paths put attached shadow roots in front of us:
1316
+ * 1. IN_PLACE on a DOM node that already has shadow roots attached.
1317
+ * 2. DOM-node input where importNode(dirty, true) deep-clones the
1318
+ * shadow root because it was created with `clonable: true`.
1319
+ *
1320
+ * This pass runs once, up front, so the main iteration loop (and the
1321
+ * existing _sanitizeShadowDOM template-content recursion) stay
1322
+ * untouched — string-input paths are not affected.
1323
+ *
1324
+ * @param root the subtree root to walk for attached shadow roots
1325
+ */
1326
+ const _sanitizeAttachedShadowRoots2 = function _sanitizeAttachedShadowRoots(root) {
1327
+ if (root.nodeType === NODE_TYPE.element && root.shadowRoot instanceof DocumentFragment) {
1328
+ const sr = root.shadowRoot;
1329
+ // Recurse first so that nested shadow roots are reached even if
1330
+ // _sanitizeShadowDOM removes hosts at this level.
1331
+ _sanitizeAttachedShadowRoots2(sr);
1332
+ _sanitizeShadowDOM2(sr);
1333
+ }
1334
+ // Snapshot children before recursing. Sanitization of one subtree
1335
+ // (e.g. via an uponSanitizeShadowNode hook) may detach siblings,
1336
+ // and naive nextSibling traversal would silently skip the rest of
1337
+ // the list once a node is detached.
1338
+ const childNodes = root.childNodes;
1339
+ if (!childNodes) {
1340
+ return;
1341
+ }
1342
+ const snapshot = [];
1343
+ arrayForEach(childNodes, child => {
1344
+ arrayPush(snapshot, child);
1345
+ });
1346
+ for (const child of snapshot) {
1347
+ _sanitizeAttachedShadowRoots2(child);
1348
+ }
1349
+ };
1350
+ // eslint-disable-next-line complexity
1351
+ DOMPurify.sanitize = function (dirty) {
1352
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1353
+ let body = null;
1354
+ let importedNode = null;
1355
+ let currentNode = null;
1356
+ let returnNode = null;
1357
+ /* Make sure we have a string to sanitize.
1358
+ DO NOT return early, as this will return the wrong type if
1359
+ the user has requested a DOM object rather than a string */
1360
+ IS_EMPTY_INPUT = !dirty;
1361
+ if (IS_EMPTY_INPUT) {
1362
+ dirty = '<!-->';
1363
+ }
1364
+ /* Stringify, in case dirty is an object */
1365
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
1366
+ dirty = stringifyValue(dirty);
1367
+ if (typeof dirty !== 'string') {
1368
+ throw typeErrorCreate('dirty is not a string, aborting');
1369
+ }
1370
+ }
1371
+ /* Return dirty HTML if DOMPurify cannot run */
1372
+ if (!DOMPurify.isSupported) {
1373
+ return dirty;
1374
+ }
1375
+ /* Assign config vars */
1376
+ if (!SET_CONFIG) {
1377
+ _parseConfig(cfg);
1378
+ }
1379
+ /* Clean up removed elements */
1380
+ DOMPurify.removed = [];
1381
+ /* Check if dirty is correctly typed for IN_PLACE */
1382
+ if (typeof dirty === 'string') {
1383
+ IN_PLACE = false;
1384
+ }
1385
+ if (IN_PLACE) {
1386
+ /* Do some early pre-sanitization to avoid unsafe root nodes */
1387
+ const nn = dirty.nodeName;
1388
+ if (typeof nn === 'string') {
1389
+ const tagName = transformCaseFunc(nn);
1390
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1391
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
1392
+ }
1393
+ }
1394
+ /* Sanitize attached shadow roots before the main iterator runs.
1395
+ The iterator does not descend into shadow trees. */
1396
+ _sanitizeAttachedShadowRoots2(dirty);
1397
+ } else if (dirty instanceof Node) {
1398
+ /* If dirty is a DOM element, append to an empty document to avoid
1399
+ elements being stripped by the parser */
1400
+ body = _initDocument('<!---->');
1401
+ importedNode = body.ownerDocument.importNode(dirty, true);
1402
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
1403
+ /* Node is already a body, use as is */
1404
+ body = importedNode;
1405
+ } else if (importedNode.nodeName === 'HTML') {
1406
+ body = importedNode;
1407
+ } else {
1408
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1409
+ body.appendChild(importedNode);
1410
+ }
1411
+ /* Clonable shadow roots are deep-cloned by importNode(); sanitize
1412
+ them before the main iterator runs, since the iterator does not
1413
+ descend into shadow trees. */
1414
+ _sanitizeAttachedShadowRoots2(importedNode);
1415
+ } else {
1416
+ /* Exit directly if we have nothing to do */
1417
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
1418
+ // eslint-disable-next-line unicorn/prefer-includes
1419
+ dirty.indexOf('<') === -1) {
1420
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
1421
+ }
1422
+ /* Initialize the document to work on */
1423
+ body = _initDocument(dirty);
1424
+ /* Check we have a DOM node from the data */
1425
+ if (!body) {
1426
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
1427
+ }
1428
+ }
1429
+ /* Remove first element node (ours) if FORCE_BODY is set */
1430
+ if (body && FORCE_BODY) {
1431
+ _forceRemove(body.firstChild);
1432
+ }
1433
+ /* Get node iterator */
1434
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
1435
+ /* Now start iterating over the created document */
1436
+ while (currentNode = nodeIterator.nextNode()) {
1437
+ /* Sanitize tags and elements */
1438
+ _sanitizeElements(currentNode);
1439
+ /* Check attributes next */
1440
+ _sanitizeAttributes(currentNode);
1441
+ /* Shadow DOM detected, sanitize it */
1442
+ if (currentNode.content instanceof DocumentFragment) {
1443
+ _sanitizeShadowDOM2(currentNode.content);
1444
+ }
1445
+ }
1446
+ /* If we sanitized `dirty` in-place, return it. */
1447
+ if (IN_PLACE) {
1448
+ return dirty;
1449
+ }
1450
+ /* Return sanitized string or DOM */
1451
+ if (RETURN_DOM) {
1452
+ if (SAFE_FOR_TEMPLATES) {
1453
+ body.normalize();
1454
+ let html = body.innerHTML;
1455
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1456
+ html = stringReplace(html, expr, ' ');
1457
+ });
1458
+ body.innerHTML = html;
1459
+ }
1460
+ if (RETURN_DOM_FRAGMENT) {
1461
+ returnNode = createDocumentFragment.call(body.ownerDocument);
1462
+ while (body.firstChild) {
1463
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1464
+ returnNode.appendChild(body.firstChild);
1465
+ }
1466
+ } else {
1467
+ returnNode = body;
1468
+ }
1469
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
1470
+ /*
1471
+ AdoptNode() is not used because internal state is not reset
1472
+ (e.g. the past names map of a HTMLFormElement), this is safe
1473
+ in theory but we would rather not risk another attack vector.
1474
+ The state that is cloned by importNode() is explicitly defined
1475
+ by the specs.
1476
+ */
1477
+ returnNode = importNode.call(originalDocument, returnNode, true);
1478
+ }
1479
+ return returnNode;
1480
+ }
1481
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
1482
+ /* Serialize doctype if allowed */
1483
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
1484
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
1485
+ }
1486
+ /* Sanitize final string template-safe */
1487
+ if (SAFE_FOR_TEMPLATES) {
1488
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], expr => {
1489
+ serializedHTML = stringReplace(serializedHTML, expr, ' ');
1490
+ });
1491
+ }
1492
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
1493
+ };
1494
+ DOMPurify.setConfig = function () {
1495
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1496
+ _parseConfig(cfg);
1497
+ SET_CONFIG = true;
1498
+ };
1499
+ DOMPurify.clearConfig = function () {
1500
+ CONFIG = null;
1501
+ SET_CONFIG = false;
1502
+ };
1503
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
1504
+ /* Initialize shared config vars if necessary. */
1505
+ if (!CONFIG) {
1506
+ _parseConfig({});
1507
+ }
1508
+ const lcTag = transformCaseFunc(tag);
1509
+ const lcName = transformCaseFunc(attr);
1510
+ return _isValidAttribute(lcTag, lcName, value);
1511
+ };
1512
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
1513
+ if (typeof hookFunction !== 'function') {
1514
+ return;
1515
+ }
1516
+ arrayPush(hooks[entryPoint], hookFunction);
1517
+ };
1518
+ DOMPurify.removeHook = function (entryPoint, hookFunction) {
1519
+ if (hookFunction !== undefined) {
1520
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
1521
+ return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
1522
+ }
1523
+ return arrayPop(hooks[entryPoint]);
1524
+ };
1525
+ DOMPurify.removeHooks = function (entryPoint) {
1526
+ hooks[entryPoint] = [];
1527
+ };
1528
+ DOMPurify.removeAllHooks = function () {
1529
+ hooks = _createHooksMap();
1530
+ };
1531
+ return DOMPurify;
1532
+ }
1533
+ var purify = createDOMPurify();
1534
+
1535
+ export { purify as default };
1536
+ //# sourceMappingURL=purify.es.mjs.map