@nylas/web-elements 1.0.0-prealpha1

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 (879) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/_commonjsHelpers-0a7b82d9.js +23 -0
  3. package/dist/cjs/_commonjsHelpers-0a7b82d9.js.map +1 -0
  4. package/dist/cjs/app-globals-d58ac016.js +11 -0
  5. package/dist/cjs/app-globals-d58ac016.js.map +1 -0
  6. package/dist/cjs/archive-icon_7.cjs.entry.js +120 -0
  7. package/dist/cjs/archive-icon_7.cjs.entry.js.map +1 -0
  8. package/dist/cjs/arrow-icon.cjs.entry.js +24 -0
  9. package/dist/cjs/arrow-icon.cjs.entry.js.map +1 -0
  10. package/dist/cjs/bold-icon_3.cjs.entry.js +56 -0
  11. package/dist/cjs/bold-icon_3.cjs.entry.js.map +1 -0
  12. package/dist/cjs/calendar-cancel-icon.cjs.entry.js +24 -0
  13. package/dist/cjs/calendar-cancel-icon.cjs.entry.js.map +1 -0
  14. package/dist/cjs/calendar-check-icon_3.cjs.entry.js +56 -0
  15. package/dist/cjs/calendar-check-icon_3.cjs.entry.js.map +1 -0
  16. package/dist/cjs/calendar-icon.cjs.entry.js +24 -0
  17. package/dist/cjs/calendar-icon.cjs.entry.js.map +1 -0
  18. package/dist/cjs/chevron-icon.cjs.entry.js +24 -0
  19. package/dist/cjs/chevron-icon.cjs.entry.js.map +1 -0
  20. package/dist/cjs/close-icon_2.cjs.entry.js +40 -0
  21. package/dist/cjs/close-icon_2.cjs.entry.js.map +1 -0
  22. package/dist/cjs/document-refresh-icon.cjs.entry.js +24 -0
  23. package/dist/cjs/document-refresh-icon.cjs.entry.js.map +1 -0
  24. package/dist/cjs/duration-18b22d1b.js +84 -0
  25. package/dist/cjs/duration-18b22d1b.js.map +1 -0
  26. package/dist/cjs/elements-b06c817b.js +21585 -0
  27. package/dist/cjs/elements-b06c817b.js.map +1 -0
  28. package/dist/cjs/flow-d922fbd4.js +891 -0
  29. package/dist/cjs/flow-d922fbd4.js.map +1 -0
  30. package/dist/cjs/focus-visible-857fc8f9.js +327 -0
  31. package/dist/cjs/focus-visible-857fc8f9.js.map +1 -0
  32. package/dist/cjs/forward-icon_6.cjs.entry.js +2216 -0
  33. package/dist/cjs/forward-icon_6.cjs.entry.js.map +1 -0
  34. package/dist/cjs/globe-icon.cjs.entry.js +24 -0
  35. package/dist/cjs/globe-icon.cjs.entry.js.map +1 -0
  36. package/dist/cjs/index-34e64e2d.js +2173 -0
  37. package/dist/cjs/index-34e64e2d.js.map +1 -0
  38. package/dist/cjs/index-e869130c.js +198 -0
  39. package/dist/cjs/index-e869130c.js.map +1 -0
  40. package/dist/cjs/index.cjs.js +12 -0
  41. package/dist/cjs/index.cjs.js.map +1 -0
  42. package/dist/cjs/index.es-e78884f5.js +3217 -0
  43. package/dist/cjs/index.es-e78884f5.js.map +1 -0
  44. package/dist/cjs/loader.cjs.js +17 -0
  45. package/dist/cjs/loader.cjs.js.map +1 -0
  46. package/dist/cjs/loading-icon.cjs.entry.js +24 -0
  47. package/dist/cjs/loading-icon.cjs.entry.js.map +1 -0
  48. package/dist/cjs/mailbox-store-0b1636fa.js +529 -0
  49. package/dist/cjs/mailbox-store-0b1636fa.js.map +1 -0
  50. package/dist/cjs/nylas-booked-event-card_9.cjs.entry.js +8127 -0
  51. package/dist/cjs/nylas-booked-event-card_9.cjs.entry.js.map +1 -0
  52. package/dist/cjs/nylas-if-state_3.cjs.entry.js +409 -0
  53. package/dist/cjs/nylas-if-state_3.cjs.entry.js.map +1 -0
  54. package/dist/cjs/nylas-list-folders.cjs.entry.js +120 -0
  55. package/dist/cjs/nylas-list-folders.cjs.entry.js.map +1 -0
  56. package/dist/cjs/nylas-list-threads.cjs.entry.js +89 -0
  57. package/dist/cjs/nylas-list-threads.cjs.entry.js.map +1 -0
  58. package/dist/cjs/nylas-mailbox-pagination.cjs.entry.js +140 -0
  59. package/dist/cjs/nylas-mailbox-pagination.cjs.entry.js.map +1 -0
  60. package/dist/cjs/nylas-mailbox-toolbar-button.cjs.entry.js +100 -0
  61. package/dist/cjs/nylas-mailbox-toolbar-button.cjs.entry.js.map +1 -0
  62. package/dist/cjs/nylas-open-hours-picker.cjs.entry.js +333 -0
  63. package/dist/cjs/nylas-open-hours-picker.cjs.entry.js.map +1 -0
  64. package/dist/cjs/nylas-provider.cjs.entry.js +184 -0
  65. package/dist/cjs/nylas-provider.cjs.entry.js.map +1 -0
  66. package/dist/cjs/nylas-scheduler.cjs.entry.js +242 -0
  67. package/dist/cjs/nylas-scheduler.cjs.entry.js.map +1 -0
  68. package/dist/cjs/nylas-threads-refresh.cjs.entry.js +118 -0
  69. package/dist/cjs/nylas-threads-refresh.cjs.entry.js.map +1 -0
  70. package/dist/cjs/nylas-threads-search.cjs.entry.js +84 -0
  71. package/dist/cjs/nylas-threads-search.cjs.entry.js.map +1 -0
  72. package/dist/cjs/nylas-view-thread.cjs.entry.js +234 -0
  73. package/dist/cjs/nylas-view-thread.cjs.entry.js.map +1 -0
  74. package/dist/cjs/nylas-web-elements.cjs.js +27 -0
  75. package/dist/cjs/nylas-web-elements.cjs.js.map +1 -0
  76. package/dist/cjs/play-icon_2.cjs.entry.js +40 -0
  77. package/dist/cjs/play-icon_2.cjs.entry.js.map +1 -0
  78. package/dist/cjs/property-d934a711.js +47 -0
  79. package/dist/cjs/property-d934a711.js.map +1 -0
  80. package/dist/cjs/refresh-icon.cjs.entry.js +24 -0
  81. package/dist/cjs/refresh-icon.cjs.entry.js.map +1 -0
  82. package/dist/cjs/register-component-f76b61a6.js +140 -0
  83. package/dist/cjs/register-component-f76b61a6.js.map +1 -0
  84. package/dist/cjs/scheduler-store-e9822441.js +254 -0
  85. package/dist/cjs/scheduler-store-e9822441.js.map +1 -0
  86. package/dist/cjs/translate-icon.cjs.entry.js +24 -0
  87. package/dist/cjs/translate-icon.cjs.entry.js.map +1 -0
  88. package/dist/cjs/utils-f91d4c73.js +161 -0
  89. package/dist/cjs/utils-f91d4c73.js.map +1 -0
  90. package/dist/collection/assets/icons/chevron.svg +3 -0
  91. package/dist/collection/collection-manifest.json +66 -0
  92. package/dist/collection/common/abstract-provider.js +231 -0
  93. package/dist/collection/common/abstract-provider.js.map +1 -0
  94. package/dist/collection/common/component-types.js +2 -0
  95. package/dist/collection/common/component-types.js.map +1 -0
  96. package/dist/collection/common/constants.js +12 -0
  97. package/dist/collection/common/constants.js.map +1 -0
  98. package/dist/collection/common/global.js +4 -0
  99. package/dist/collection/common/global.js.map +1 -0
  100. package/dist/collection/common/icons/archive.js +63 -0
  101. package/dist/collection/common/icons/archive.js.map +1 -0
  102. package/dist/collection/common/icons/arrow.js +63 -0
  103. package/dist/collection/common/icons/arrow.js.map +1 -0
  104. package/dist/collection/common/icons/bold.js +63 -0
  105. package/dist/collection/common/icons/bold.js.map +1 -0
  106. package/dist/collection/common/icons/calendar-cancel.js +63 -0
  107. package/dist/collection/common/icons/calendar-cancel.js.map +1 -0
  108. package/dist/collection/common/icons/calendar-check.js +63 -0
  109. package/dist/collection/common/icons/calendar-check.js.map +1 -0
  110. package/dist/collection/common/icons/calendar.js +63 -0
  111. package/dist/collection/common/icons/calendar.js.map +1 -0
  112. package/dist/collection/common/icons/checkmark-circle.js +63 -0
  113. package/dist/collection/common/icons/checkmark-circle.js.map +1 -0
  114. package/dist/collection/common/icons/chevron.js +63 -0
  115. package/dist/collection/common/icons/chevron.js.map +1 -0
  116. package/dist/collection/common/icons/close.js +63 -0
  117. package/dist/collection/common/icons/close.js.map +1 -0
  118. package/dist/collection/common/icons/document-refresh.js +63 -0
  119. package/dist/collection/common/icons/document-refresh.js.map +1 -0
  120. package/dist/collection/common/icons/folder.js +63 -0
  121. package/dist/collection/common/icons/folder.js.map +1 -0
  122. package/dist/collection/common/icons/forward.js +63 -0
  123. package/dist/collection/common/icons/forward.js.map +1 -0
  124. package/dist/collection/common/icons/globe.js +63 -0
  125. package/dist/collection/common/icons/globe.js.map +1 -0
  126. package/dist/collection/common/icons/icon.css +3 -0
  127. package/dist/collection/common/icons/inbox.js +63 -0
  128. package/dist/collection/common/icons/inbox.js.map +1 -0
  129. package/dist/collection/common/icons/italic.js +63 -0
  130. package/dist/collection/common/icons/italic.js.map +1 -0
  131. package/dist/collection/common/icons/loading.css +33 -0
  132. package/dist/collection/common/icons/loading.js +63 -0
  133. package/dist/collection/common/icons/loading.js.map +1 -0
  134. package/dist/collection/common/icons/nylas-logo.js +63 -0
  135. package/dist/collection/common/icons/nylas-logo.js.map +1 -0
  136. package/dist/collection/common/icons/people.js +63 -0
  137. package/dist/collection/common/icons/people.js.map +1 -0
  138. package/dist/collection/common/icons/play.js +63 -0
  139. package/dist/collection/common/icons/play.js.map +1 -0
  140. package/dist/collection/common/icons/refresh.js +63 -0
  141. package/dist/collection/common/icons/refresh.js.map +1 -0
  142. package/dist/collection/common/icons/reply-all.js +63 -0
  143. package/dist/collection/common/icons/reply-all.js.map +1 -0
  144. package/dist/collection/common/icons/reply.js +63 -0
  145. package/dist/collection/common/icons/reply.js.map +1 -0
  146. package/dist/collection/common/icons/sent.js +63 -0
  147. package/dist/collection/common/icons/sent.js.map +1 -0
  148. package/dist/collection/common/icons/spam.js +63 -0
  149. package/dist/collection/common/icons/spam.js.map +1 -0
  150. package/dist/collection/common/icons/star.js +63 -0
  151. package/dist/collection/common/icons/star.js.map +1 -0
  152. package/dist/collection/common/icons/stop.js +63 -0
  153. package/dist/collection/common/icons/stop.js.map +1 -0
  154. package/dist/collection/common/icons/translate.js +63 -0
  155. package/dist/collection/common/icons/translate.js.map +1 -0
  156. package/dist/collection/common/icons/trash.js +63 -0
  157. package/dist/collection/common/icons/trash.js.map +1 -0
  158. package/dist/collection/common/icons/underline.js +63 -0
  159. package/dist/collection/common/icons/underline.js.map +1 -0
  160. package/dist/collection/common/icons/warning.js +63 -0
  161. package/dist/collection/common/icons/warning.js.map +1 -0
  162. package/dist/collection/common/mocks/threads.js +57 -0
  163. package/dist/collection/common/mocks/threads.js.map +1 -0
  164. package/dist/collection/common/nylas-theme/index.js +4 -0
  165. package/dist/collection/common/nylas-theme/index.js.map +1 -0
  166. package/dist/collection/common/register-component.js +134 -0
  167. package/dist/collection/common/register-component.js.map +1 -0
  168. package/dist/collection/common/types.js +2 -0
  169. package/dist/collection/common/types.js.map +1 -0
  170. package/dist/collection/components/mailbox/nylas-composer/nylas-composer.css +89 -0
  171. package/dist/collection/components/mailbox/nylas-composer/nylas-composer.js +241 -0
  172. package/dist/collection/components/mailbox/nylas-composer/nylas-composer.js.map +1 -0
  173. package/dist/collection/components/mailbox/nylas-composer/test/nylas-composer.e2e.js +10 -0
  174. package/dist/collection/components/mailbox/nylas-composer/test/nylas-composer.e2e.js.map +1 -0
  175. package/dist/collection/components/mailbox/nylas-composer/test/nylas-composer.spec-disabled.js +12 -0
  176. package/dist/collection/components/mailbox/nylas-composer/test/nylas-composer.spec-disabled.js.map +1 -0
  177. package/dist/collection/components/mailbox/nylas-list-folders/nylas-list-folders.css +37 -0
  178. package/dist/collection/components/mailbox/nylas-list-folders/nylas-list-folders.js +193 -0
  179. package/dist/collection/components/mailbox/nylas-list-folders/nylas-list-folders.js.map +1 -0
  180. package/dist/collection/components/mailbox/nylas-list-folders/test/nylas-list-folders.e2e.js +10 -0
  181. package/dist/collection/components/mailbox/nylas-list-folders/test/nylas-list-folders.e2e.js.map +1 -0
  182. package/dist/collection/components/mailbox/nylas-list-folders/test/nylas-list-folders.spec.js +12 -0
  183. package/dist/collection/components/mailbox/nylas-list-folders/test/nylas-list-folders.spec.js.map +1 -0
  184. package/dist/collection/components/mailbox/nylas-list-threads/nylas-list-threads.css +156 -0
  185. package/dist/collection/components/mailbox/nylas-list-threads/nylas-list-threads.js +218 -0
  186. package/dist/collection/components/mailbox/nylas-list-threads/nylas-list-threads.js.map +1 -0
  187. package/dist/collection/components/mailbox/nylas-list-threads/test/nylas-list-threads.e2e.js +22 -0
  188. package/dist/collection/components/mailbox/nylas-list-threads/test/nylas-list-threads.e2e.js.map +1 -0
  189. package/dist/collection/components/mailbox/nylas-list-threads/test/nylas-list-threads.spec.js +25 -0
  190. package/dist/collection/components/mailbox/nylas-list-threads/test/nylas-list-threads.spec.js.map +1 -0
  191. package/dist/collection/components/mailbox/nylas-mailbox/nylas-mailbox.css +3 -0
  192. package/dist/collection/components/mailbox/nylas-mailbox/nylas-mailbox.js +474 -0
  193. package/dist/collection/components/mailbox/nylas-mailbox/nylas-mailbox.js.map +1 -0
  194. package/dist/collection/components/mailbox/nylas-mailbox/test/nylas-mailbox.e2e.js +16 -0
  195. package/dist/collection/components/mailbox/nylas-mailbox/test/nylas-mailbox.e2e.js.map +1 -0
  196. package/dist/collection/components/mailbox/nylas-mailbox/test/nylas-mailbox.spec.js +32 -0
  197. package/dist/collection/components/mailbox/nylas-mailbox/test/nylas-mailbox.spec.js.map +1 -0
  198. package/dist/collection/components/mailbox/nylas-mailbox-pagination/nylas-mailbox-pagination.css +55 -0
  199. package/dist/collection/components/mailbox/nylas-mailbox-pagination/nylas-mailbox-pagination.js +371 -0
  200. package/dist/collection/components/mailbox/nylas-mailbox-pagination/nylas-mailbox-pagination.js.map +1 -0
  201. package/dist/collection/components/mailbox/nylas-mailbox-pagination/test/nylas-mailbox-pagination.e2e.js +10 -0
  202. package/dist/collection/components/mailbox/nylas-mailbox-pagination/test/nylas-mailbox-pagination.e2e.js.map +1 -0
  203. package/dist/collection/components/mailbox/nylas-mailbox-pagination/test/nylas-mailbox-pagination.spec.js +12 -0
  204. package/dist/collection/components/mailbox/nylas-mailbox-pagination/test/nylas-mailbox-pagination.spec.js.map +1 -0
  205. package/dist/collection/components/mailbox/nylas-mailbox-toolbar-button/nylas-mailbox-toolbar-button.css +18 -0
  206. package/dist/collection/components/mailbox/nylas-mailbox-toolbar-button/nylas-mailbox-toolbar-button.js +182 -0
  207. package/dist/collection/components/mailbox/nylas-mailbox-toolbar-button/nylas-mailbox-toolbar-button.js.map +1 -0
  208. package/dist/collection/components/mailbox/nylas-summarize-message-button/nylas-summarize-message-button.css +61 -0
  209. package/dist/collection/components/mailbox/nylas-summarize-message-button/nylas-summarize-message-button.js +329 -0
  210. package/dist/collection/components/mailbox/nylas-summarize-message-button/nylas-summarize-message-button.js.map +1 -0
  211. package/dist/collection/components/mailbox/nylas-summarize-message-button/test/nylas-summarize-message-button.e2e.js +10 -0
  212. package/dist/collection/components/mailbox/nylas-summarize-message-button/test/nylas-summarize-message-button.e2e.js.map +1 -0
  213. package/dist/collection/components/mailbox/nylas-summarize-message-button/test/nylas-summarize-message-button.spec.js +12 -0
  214. package/dist/collection/components/mailbox/nylas-summarize-message-button/test/nylas-summarize-message-button.spec.js.map +1 -0
  215. package/dist/collection/components/mailbox/nylas-threads-refresh/nylas-threads-refresh.css +53 -0
  216. package/dist/collection/components/mailbox/nylas-threads-refresh/nylas-threads-refresh.js +172 -0
  217. package/dist/collection/components/mailbox/nylas-threads-refresh/nylas-threads-refresh.js.map +1 -0
  218. package/dist/collection/components/mailbox/nylas-threads-refresh/test/nylas-threads-refresh.e2e.js +10 -0
  219. package/dist/collection/components/mailbox/nylas-threads-refresh/test/nylas-threads-refresh.e2e.js.map +1 -0
  220. package/dist/collection/components/mailbox/nylas-threads-refresh/test/nylas-threads-refresh.spec.js +12 -0
  221. package/dist/collection/components/mailbox/nylas-threads-refresh/test/nylas-threads-refresh.spec.js.map +1 -0
  222. package/dist/collection/components/mailbox/nylas-threads-search/nylas-threads-search.css +8 -0
  223. package/dist/collection/components/mailbox/nylas-threads-search/nylas-threads-search.js +130 -0
  224. package/dist/collection/components/mailbox/nylas-threads-search/nylas-threads-search.js.map +1 -0
  225. package/dist/collection/components/mailbox/nylas-threads-search/test/nylas-threads-search.e2e.js +10 -0
  226. package/dist/collection/components/mailbox/nylas-threads-search/test/nylas-threads-search.e2e.js.map +1 -0
  227. package/dist/collection/components/mailbox/nylas-threads-search/test/nylas-threads-search.spec.js +12 -0
  228. package/dist/collection/components/mailbox/nylas-threads-search/test/nylas-threads-search.spec.js.map +1 -0
  229. package/dist/collection/components/mailbox/nylas-view-email/nylas-view-email.css +43 -0
  230. package/dist/collection/components/mailbox/nylas-view-email/nylas-view-email.js +282 -0
  231. package/dist/collection/components/mailbox/nylas-view-email/nylas-view-email.js.map +1 -0
  232. package/dist/collection/components/mailbox/nylas-view-thread/nylas-view-thread.css +243 -0
  233. package/dist/collection/components/mailbox/nylas-view-thread/nylas-view-thread.js +342 -0
  234. package/dist/collection/components/mailbox/nylas-view-thread/nylas-view-thread.js.map +1 -0
  235. package/dist/collection/components/mailbox/nylas-view-thread/view-thread-message.js +25 -0
  236. package/dist/collection/components/mailbox/nylas-view-thread/view-thread-message.js.map +1 -0
  237. package/dist/collection/components/nylas-if-state/nylas-if-state.css +84 -0
  238. package/dist/collection/components/nylas-if-state/nylas-if-state.js +241 -0
  239. package/dist/collection/components/nylas-if-state/nylas-if-state.js.map +1 -0
  240. package/dist/collection/components/nylas-if-state/test/nylas-if-state.e2e.js +10 -0
  241. package/dist/collection/components/nylas-if-state/test/nylas-if-state.e2e.js.map +1 -0
  242. package/dist/collection/components/nylas-if-state/test/nylas-if-state.spec.js +12 -0
  243. package/dist/collection/components/nylas-if-state/test/nylas-if-state.spec.js.map +1 -0
  244. package/dist/collection/components/nylas-login/nylas-login.css +94 -0
  245. package/dist/collection/components/nylas-login/nylas-login.js +289 -0
  246. package/dist/collection/components/nylas-login/nylas-login.js.map +1 -0
  247. package/dist/collection/components/nylas-login/test/nylas-login.e2e.js +10 -0
  248. package/dist/collection/components/nylas-login/test/nylas-login.e2e.js.map +1 -0
  249. package/dist/collection/components/nylas-login/test/nylas-login.spec.js +12 -0
  250. package/dist/collection/components/nylas-login/test/nylas-login.spec.js.map +1 -0
  251. package/dist/collection/components/nylas-provider/nylas-provider.css +3 -0
  252. package/dist/collection/components/nylas-provider/nylas-provider.js +423 -0
  253. package/dist/collection/components/nylas-provider/nylas-provider.js.map +1 -0
  254. package/dist/collection/components/nylas-provider/test/nylas-provider.e2e.js +10 -0
  255. package/dist/collection/components/nylas-provider/test/nylas-provider.e2e.js.map +1 -0
  256. package/dist/collection/components/nylas-provider/test/nylas-provider.spec.js +32 -0
  257. package/dist/collection/components/nylas-provider/test/nylas-provider.spec.js.map +1 -0
  258. package/dist/collection/components/scheduler/nylas-booked-event-card/nylas-booked-event-card.css +155 -0
  259. package/dist/collection/components/scheduler/nylas-booked-event-card/nylas-booked-event-card.js +178 -0
  260. package/dist/collection/components/scheduler/nylas-booked-event-card/nylas-booked-event-card.js.map +1 -0
  261. package/dist/collection/components/scheduler/nylas-booking-form/nylas-booking-form.css +129 -0
  262. package/dist/collection/components/scheduler/nylas-booking-form/nylas-booking-form.js +323 -0
  263. package/dist/collection/components/scheduler/nylas-booking-form/nylas-booking-form.js.map +1 -0
  264. package/dist/collection/components/scheduler/nylas-cancelled-event-card/nylas-cancelled-event-card.css +78 -0
  265. package/dist/collection/components/scheduler/nylas-cancelled-event-card/nylas-cancelled-event-card.js +107 -0
  266. package/dist/collection/components/scheduler/nylas-cancelled-event-card/nylas-cancelled-event-card.js.map +1 -0
  267. package/dist/collection/components/scheduler/nylas-date-picker/nylas-date-picker.css +150 -0
  268. package/dist/collection/components/scheduler/nylas-date-picker/nylas-date-picker.js +213 -0
  269. package/dist/collection/components/scheduler/nylas-date-picker/nylas-date-picker.js.map +1 -0
  270. package/dist/collection/components/scheduler/nylas-locale-switch/nylas-locale-switch.css +72 -0
  271. package/dist/collection/components/scheduler/nylas-locale-switch/nylas-locale-switch.js +147 -0
  272. package/dist/collection/components/scheduler/nylas-locale-switch/nylas-locale-switch.js.map +1 -0
  273. package/dist/collection/components/scheduler/nylas-notification/nylas-notification.css +63 -0
  274. package/dist/collection/components/scheduler/nylas-notification/nylas-notification.js +132 -0
  275. package/dist/collection/components/scheduler/nylas-notification/nylas-notification.js.map +1 -0
  276. package/dist/collection/components/scheduler/nylas-open-hours-picker/nylas-open-hours-picker.css +105 -0
  277. package/dist/collection/components/scheduler/nylas-open-hours-picker/nylas-open-hours-picker.js +460 -0
  278. package/dist/collection/components/scheduler/nylas-open-hours-picker/nylas-open-hours-picker.js.map +1 -0
  279. package/dist/collection/components/scheduler/nylas-open-hours-picker/test/nylas-open-hours-picker.e2e.js +10 -0
  280. package/dist/collection/components/scheduler/nylas-open-hours-picker/test/nylas-open-hours-picker.e2e.js.map +1 -0
  281. package/dist/collection/components/scheduler/nylas-open-hours-picker/test/nylas-open-hours-picker.spec.js +12 -0
  282. package/dist/collection/components/scheduler/nylas-open-hours-picker/test/nylas-open-hours-picker.spec.js.map +1 -0
  283. package/dist/collection/components/scheduler/nylas-scheduler/nylas-scheduler.css +182 -0
  284. package/dist/collection/components/scheduler/nylas-scheduler/nylas-scheduler.js +533 -0
  285. package/dist/collection/components/scheduler/nylas-scheduler/nylas-scheduler.js.map +1 -0
  286. package/dist/collection/components/scheduler/nylas-scheduler/scheduler-view.js +6 -0
  287. package/dist/collection/components/scheduler/nylas-scheduler/scheduler-view.js.map +1 -0
  288. package/dist/collection/components/scheduler/nylas-selected-event-card/nylas-selected-event-card.css +63 -0
  289. package/dist/collection/components/scheduler/nylas-selected-event-card/nylas-selected-event-card.js +150 -0
  290. package/dist/collection/components/scheduler/nylas-selected-event-card/nylas-selected-event-card.js.map +1 -0
  291. package/dist/collection/components/scheduler/nylas-timeslot-picker/nylas-timeslot-picker.css +115 -0
  292. package/dist/collection/components/scheduler/nylas-timeslot-picker/nylas-timeslot-picker.js +311 -0
  293. package/dist/collection/components/scheduler/nylas-timeslot-picker/nylas-timeslot-picker.js.map +1 -0
  294. package/dist/collection/connector/connector-interface.js +2 -0
  295. package/dist/collection/connector/connector-interface.js.map +1 -0
  296. package/dist/collection/connector/nylas-connector/index.js +78 -0
  297. package/dist/collection/connector/nylas-connector/index.js.map +1 -0
  298. package/dist/collection/connector/nylas-mailbox-connector/index.js +62 -0
  299. package/dist/collection/connector/nylas-mailbox-connector/index.js.map +1 -0
  300. package/dist/collection/connector/nylas-scheduler-connector/index.js +43 -0
  301. package/dist/collection/connector/nylas-scheduler-connector/index.js.map +1 -0
  302. package/dist/collection/connector/shared/api/auth.js +60 -0
  303. package/dist/collection/connector/shared/api/auth.js.map +1 -0
  304. package/dist/collection/connector/shared/api/folders.js +33 -0
  305. package/dist/collection/connector/shared/api/folders.js.map +1 -0
  306. package/dist/collection/connector/shared/api/messages.js +95 -0
  307. package/dist/collection/connector/shared/api/messages.js.map +1 -0
  308. package/dist/collection/connector/shared/api/scheduler.js +203 -0
  309. package/dist/collection/connector/shared/api/scheduler.js.map +1 -0
  310. package/dist/collection/connector/shared/api/threads.js +165 -0
  311. package/dist/collection/connector/shared/api/threads.js.map +1 -0
  312. package/dist/collection/index.js +4 -0
  313. package/dist/collection/index.js.map +1 -0
  314. package/dist/collection/routers/hash-router.js +109 -0
  315. package/dist/collection/routers/hash-router.js.map +1 -0
  316. package/dist/collection/routers/router-interface.js +2 -0
  317. package/dist/collection/routers/router-interface.js.map +1 -0
  318. package/dist/collection/stores/auth-store.js +18 -0
  319. package/dist/collection/stores/auth-store.js.map +1 -0
  320. package/dist/collection/stores/mailbox-store.js +42 -0
  321. package/dist/collection/stores/mailbox-store.js.map +1 -0
  322. package/dist/collection/stores/scheduler-store.js +44 -0
  323. package/dist/collection/stores/scheduler-store.js.map +1 -0
  324. package/dist/collection/utils/color-utils.js +161 -0
  325. package/dist/collection/utils/color-utils.js.map +1 -0
  326. package/dist/collection/utils/utils.js +157 -0
  327. package/dist/collection/utils/utils.js.map +1 -0
  328. package/dist/collection/utils/utils.spec.js +16 -0
  329. package/dist/collection/utils/utils.spec.js.map +1 -0
  330. package/dist/components/_commonjsHelpers.js +20 -0
  331. package/dist/components/_commonjsHelpers.js.map +1 -0
  332. package/dist/components/archive-icon.d.ts +11 -0
  333. package/dist/components/archive-icon.js +8 -0
  334. package/dist/components/archive-icon.js.map +1 -0
  335. package/dist/components/archive.js +37 -0
  336. package/dist/components/archive.js.map +1 -0
  337. package/dist/components/arrow-icon.d.ts +11 -0
  338. package/dist/components/arrow-icon.js +8 -0
  339. package/dist/components/arrow-icon.js.map +1 -0
  340. package/dist/components/arrow.js +37 -0
  341. package/dist/components/arrow.js.map +1 -0
  342. package/dist/components/assets/chevron.svg +3 -0
  343. package/dist/components/bold-icon.d.ts +11 -0
  344. package/dist/components/bold-icon.js +8 -0
  345. package/dist/components/bold-icon.js.map +1 -0
  346. package/dist/components/bold.js +37 -0
  347. package/dist/components/bold.js.map +1 -0
  348. package/dist/components/calendar-cancel-icon.d.ts +11 -0
  349. package/dist/components/calendar-cancel-icon.js +8 -0
  350. package/dist/components/calendar-cancel-icon.js.map +1 -0
  351. package/dist/components/calendar-cancel.js +37 -0
  352. package/dist/components/calendar-cancel.js.map +1 -0
  353. package/dist/components/calendar-check-icon.d.ts +11 -0
  354. package/dist/components/calendar-check-icon.js +8 -0
  355. package/dist/components/calendar-check-icon.js.map +1 -0
  356. package/dist/components/calendar-check.js +37 -0
  357. package/dist/components/calendar-check.js.map +1 -0
  358. package/dist/components/calendar-icon.d.ts +11 -0
  359. package/dist/components/calendar-icon.js +8 -0
  360. package/dist/components/calendar-icon.js.map +1 -0
  361. package/dist/components/calendar.js +37 -0
  362. package/dist/components/calendar.js.map +1 -0
  363. package/dist/components/checkmark-circle-icon.d.ts +11 -0
  364. package/dist/components/checkmark-circle-icon.js +8 -0
  365. package/dist/components/checkmark-circle-icon.js.map +1 -0
  366. package/dist/components/checkmark-circle.js +37 -0
  367. package/dist/components/checkmark-circle.js.map +1 -0
  368. package/dist/components/chevron-icon.d.ts +11 -0
  369. package/dist/components/chevron-icon.js +8 -0
  370. package/dist/components/chevron-icon.js.map +1 -0
  371. package/dist/components/chevron.js +37 -0
  372. package/dist/components/chevron.js.map +1 -0
  373. package/dist/components/close-icon.d.ts +11 -0
  374. package/dist/components/close-icon.js +8 -0
  375. package/dist/components/close-icon.js.map +1 -0
  376. package/dist/components/close.js +37 -0
  377. package/dist/components/close.js.map +1 -0
  378. package/dist/components/constants.js +7296 -0
  379. package/dist/components/constants.js.map +1 -0
  380. package/dist/components/define-element.js +40 -0
  381. package/dist/components/define-element.js.map +1 -0
  382. package/dist/components/document-refresh-icon.d.ts +11 -0
  383. package/dist/components/document-refresh-icon.js +40 -0
  384. package/dist/components/document-refresh-icon.js.map +1 -0
  385. package/dist/components/duration.js +78 -0
  386. package/dist/components/duration.js.map +1 -0
  387. package/dist/components/elements.js +21583 -0
  388. package/dist/components/elements.js.map +1 -0
  389. package/dist/components/flow.js +888 -0
  390. package/dist/components/flow.js.map +1 -0
  391. package/dist/components/focus-visible.js +325 -0
  392. package/dist/components/focus-visible.js.map +1 -0
  393. package/dist/components/folder-icon.d.ts +11 -0
  394. package/dist/components/folder-icon.js +8 -0
  395. package/dist/components/folder-icon.js.map +1 -0
  396. package/dist/components/folder.js +37 -0
  397. package/dist/components/folder.js.map +1 -0
  398. package/dist/components/forward-icon.d.ts +11 -0
  399. package/dist/components/forward-icon.js +8 -0
  400. package/dist/components/forward-icon.js.map +1 -0
  401. package/dist/components/forward.js +37 -0
  402. package/dist/components/forward.js.map +1 -0
  403. package/dist/components/globe-icon.d.ts +11 -0
  404. package/dist/components/globe-icon.js +8 -0
  405. package/dist/components/globe-icon.js.map +1 -0
  406. package/dist/components/globe.js +37 -0
  407. package/dist/components/globe.js.map +1 -0
  408. package/dist/components/inbox-icon.d.ts +11 -0
  409. package/dist/components/inbox-icon.js +8 -0
  410. package/dist/components/inbox-icon.js.map +1 -0
  411. package/dist/components/inbox.js +37 -0
  412. package/dist/components/inbox.js.map +1 -0
  413. package/dist/components/index.d.ts +33 -0
  414. package/dist/components/index.es.js +3211 -0
  415. package/dist/components/index.es.js.map +1 -0
  416. package/dist/components/index.js +16 -0
  417. package/dist/components/index.js.map +1 -0
  418. package/dist/components/index2.js +196 -0
  419. package/dist/components/index2.js.map +1 -0
  420. package/dist/components/italic-icon.d.ts +11 -0
  421. package/dist/components/italic-icon.js +8 -0
  422. package/dist/components/italic-icon.js.map +1 -0
  423. package/dist/components/italic.js +37 -0
  424. package/dist/components/italic.js.map +1 -0
  425. package/dist/components/loading-icon.d.ts +11 -0
  426. package/dist/components/loading-icon.js +8 -0
  427. package/dist/components/loading-icon.js.map +1 -0
  428. package/dist/components/loading.js +38 -0
  429. package/dist/components/loading.js.map +1 -0
  430. package/dist/components/mailbox-store.js +521 -0
  431. package/dist/components/mailbox-store.js.map +1 -0
  432. package/dist/components/nylas-booked-event-card.d.ts +11 -0
  433. package/dist/components/nylas-booked-event-card.js +8 -0
  434. package/dist/components/nylas-booked-event-card.js.map +1 -0
  435. package/dist/components/nylas-booked-event-card2.js +121 -0
  436. package/dist/components/nylas-booked-event-card2.js.map +1 -0
  437. package/dist/components/nylas-booking-form.d.ts +11 -0
  438. package/dist/components/nylas-booking-form.js +8 -0
  439. package/dist/components/nylas-booking-form.js.map +1 -0
  440. package/dist/components/nylas-booking-form2.js +224 -0
  441. package/dist/components/nylas-booking-form2.js.map +1 -0
  442. package/dist/components/nylas-cancelled-event-card.d.ts +11 -0
  443. package/dist/components/nylas-cancelled-event-card.js +8 -0
  444. package/dist/components/nylas-cancelled-event-card.js.map +1 -0
  445. package/dist/components/nylas-cancelled-event-card2.js +85 -0
  446. package/dist/components/nylas-cancelled-event-card2.js.map +1 -0
  447. package/dist/components/nylas-composer.d.ts +11 -0
  448. package/dist/components/nylas-composer.js +8 -0
  449. package/dist/components/nylas-composer.js.map +1 -0
  450. package/dist/components/nylas-composer2.js +186 -0
  451. package/dist/components/nylas-composer2.js.map +1 -0
  452. package/dist/components/nylas-date-picker.d.ts +11 -0
  453. package/dist/components/nylas-date-picker.js +8 -0
  454. package/dist/components/nylas-date-picker.js.map +1 -0
  455. package/dist/components/nylas-date-picker2.js +150 -0
  456. package/dist/components/nylas-date-picker2.js.map +1 -0
  457. package/dist/components/nylas-if-state.d.ts +11 -0
  458. package/dist/components/nylas-if-state.js +153 -0
  459. package/dist/components/nylas-if-state.js.map +1 -0
  460. package/dist/components/nylas-list-folders.d.ts +11 -0
  461. package/dist/components/nylas-list-folders.js +183 -0
  462. package/dist/components/nylas-list-folders.js.map +1 -0
  463. package/dist/components/nylas-list-threads.d.ts +11 -0
  464. package/dist/components/nylas-list-threads.js +109 -0
  465. package/dist/components/nylas-list-threads.js.map +1 -0
  466. package/dist/components/nylas-locale-switch.d.ts +11 -0
  467. package/dist/components/nylas-locale-switch.js +8 -0
  468. package/dist/components/nylas-locale-switch.js.map +1 -0
  469. package/dist/components/nylas-locale-switch2.js +103 -0
  470. package/dist/components/nylas-locale-switch2.js.map +1 -0
  471. package/dist/components/nylas-login.d.ts +11 -0
  472. package/dist/components/nylas-login.js +127 -0
  473. package/dist/components/nylas-login.js.map +1 -0
  474. package/dist/components/nylas-logo.d.ts +11 -0
  475. package/dist/components/nylas-logo.js +8 -0
  476. package/dist/components/nylas-logo.js.map +1 -0
  477. package/dist/components/nylas-logo2.js +37 -0
  478. package/dist/components/nylas-logo2.js.map +1 -0
  479. package/dist/components/nylas-mailbox-pagination.d.ts +11 -0
  480. package/dist/components/nylas-mailbox-pagination.js +175 -0
  481. package/dist/components/nylas-mailbox-pagination.js.map +1 -0
  482. package/dist/components/nylas-mailbox-toolbar-button.d.ts +11 -0
  483. package/dist/components/nylas-mailbox-toolbar-button.js +119 -0
  484. package/dist/components/nylas-mailbox-toolbar-button.js.map +1 -0
  485. package/dist/components/nylas-mailbox.d.ts +11 -0
  486. package/dist/components/nylas-mailbox.js +219 -0
  487. package/dist/components/nylas-mailbox.js.map +1 -0
  488. package/dist/components/nylas-notification.d.ts +11 -0
  489. package/dist/components/nylas-notification.js +8 -0
  490. package/dist/components/nylas-notification.js.map +1 -0
  491. package/dist/components/nylas-notification2.js +90 -0
  492. package/dist/components/nylas-notification2.js.map +1 -0
  493. package/dist/components/nylas-open-hours-picker.d.ts +11 -0
  494. package/dist/components/nylas-open-hours-picker.js +365 -0
  495. package/dist/components/nylas-open-hours-picker.js.map +1 -0
  496. package/dist/components/nylas-provider.d.ts +11 -0
  497. package/dist/components/nylas-provider.js +206 -0
  498. package/dist/components/nylas-provider.js.map +1 -0
  499. package/dist/components/nylas-scheduler.d.ts +11 -0
  500. package/dist/components/nylas-scheduler.js +392 -0
  501. package/dist/components/nylas-scheduler.js.map +1 -0
  502. package/dist/components/nylas-selected-event-card.d.ts +11 -0
  503. package/dist/components/nylas-selected-event-card.js +8 -0
  504. package/dist/components/nylas-selected-event-card.js.map +1 -0
  505. package/dist/components/nylas-selected-event-card2.js +110 -0
  506. package/dist/components/nylas-selected-event-card2.js.map +1 -0
  507. package/dist/components/nylas-summarize-message-button.d.ts +11 -0
  508. package/dist/components/nylas-summarize-message-button.js +8 -0
  509. package/dist/components/nylas-summarize-message-button.js.map +1 -0
  510. package/dist/components/nylas-summarize-message-button2.js +233 -0
  511. package/dist/components/nylas-summarize-message-button2.js.map +1 -0
  512. package/dist/components/nylas-threads-refresh.d.ts +11 -0
  513. package/dist/components/nylas-threads-refresh.js +149 -0
  514. package/dist/components/nylas-threads-refresh.js.map +1 -0
  515. package/dist/components/nylas-threads-search.d.ts +11 -0
  516. package/dist/components/nylas-threads-search.js +103 -0
  517. package/dist/components/nylas-threads-search.js.map +1 -0
  518. package/dist/components/nylas-timeslot-picker.d.ts +11 -0
  519. package/dist/components/nylas-timeslot-picker.js +8 -0
  520. package/dist/components/nylas-timeslot-picker.js.map +1 -0
  521. package/dist/components/nylas-timeslot-picker2.js +174 -0
  522. package/dist/components/nylas-timeslot-picker2.js.map +1 -0
  523. package/dist/components/nylas-view-email.d.ts +11 -0
  524. package/dist/components/nylas-view-email.js +8 -0
  525. package/dist/components/nylas-view-email.js.map +1 -0
  526. package/dist/components/nylas-view-email2.js +1859 -0
  527. package/dist/components/nylas-view-email2.js.map +1 -0
  528. package/dist/components/nylas-view-thread.d.ts +11 -0
  529. package/dist/components/nylas-view-thread.js +338 -0
  530. package/dist/components/nylas-view-thread.js.map +1 -0
  531. package/dist/components/people-icon.d.ts +11 -0
  532. package/dist/components/people-icon.js +8 -0
  533. package/dist/components/people-icon.js.map +1 -0
  534. package/dist/components/people.js +37 -0
  535. package/dist/components/people.js.map +1 -0
  536. package/dist/components/play-icon.d.ts +11 -0
  537. package/dist/components/play-icon.js +8 -0
  538. package/dist/components/play-icon.js.map +1 -0
  539. package/dist/components/play.js +37 -0
  540. package/dist/components/play.js.map +1 -0
  541. package/dist/components/property.js +36 -0
  542. package/dist/components/property.js.map +1 -0
  543. package/dist/components/refresh-icon.d.ts +11 -0
  544. package/dist/components/refresh-icon.js +8 -0
  545. package/dist/components/refresh-icon.js.map +1 -0
  546. package/dist/components/refresh.js +37 -0
  547. package/dist/components/refresh.js.map +1 -0
  548. package/dist/components/register-component.js +138 -0
  549. package/dist/components/register-component.js.map +1 -0
  550. package/dist/components/reply-all-icon.d.ts +11 -0
  551. package/dist/components/reply-all-icon.js +8 -0
  552. package/dist/components/reply-all-icon.js.map +1 -0
  553. package/dist/components/reply-all.js +37 -0
  554. package/dist/components/reply-all.js.map +1 -0
  555. package/dist/components/reply-icon.d.ts +11 -0
  556. package/dist/components/reply-icon.js +8 -0
  557. package/dist/components/reply-icon.js.map +1 -0
  558. package/dist/components/reply.js +37 -0
  559. package/dist/components/reply.js.map +1 -0
  560. package/dist/components/scheduler-store.js +251 -0
  561. package/dist/components/scheduler-store.js.map +1 -0
  562. package/dist/components/sent-icon.d.ts +11 -0
  563. package/dist/components/sent-icon.js +8 -0
  564. package/dist/components/sent-icon.js.map +1 -0
  565. package/dist/components/sent.js +37 -0
  566. package/dist/components/sent.js.map +1 -0
  567. package/dist/components/sp-icon-chevron-left.js +23 -0
  568. package/dist/components/sp-icon-chevron-left.js.map +1 -0
  569. package/dist/components/spam-icon.d.ts +11 -0
  570. package/dist/components/spam-icon.js +8 -0
  571. package/dist/components/spam-icon.js.map +1 -0
  572. package/dist/components/spam.js +37 -0
  573. package/dist/components/spam.js.map +1 -0
  574. package/dist/components/star-icon.d.ts +11 -0
  575. package/dist/components/star-icon.js +8 -0
  576. package/dist/components/star-icon.js.map +1 -0
  577. package/dist/components/star.js +37 -0
  578. package/dist/components/star.js.map +1 -0
  579. package/dist/components/stop-icon.d.ts +11 -0
  580. package/dist/components/stop-icon.js +8 -0
  581. package/dist/components/stop-icon.js.map +1 -0
  582. package/dist/components/stop.js +37 -0
  583. package/dist/components/stop.js.map +1 -0
  584. package/dist/components/translate-icon.d.ts +11 -0
  585. package/dist/components/translate-icon.js +8 -0
  586. package/dist/components/translate-icon.js.map +1 -0
  587. package/dist/components/translate.js +37 -0
  588. package/dist/components/translate.js.map +1 -0
  589. package/dist/components/trash-icon.d.ts +11 -0
  590. package/dist/components/trash-icon.js +8 -0
  591. package/dist/components/trash-icon.js.map +1 -0
  592. package/dist/components/trash.js +37 -0
  593. package/dist/components/trash.js.map +1 -0
  594. package/dist/components/underline-icon.d.ts +11 -0
  595. package/dist/components/underline-icon.js +8 -0
  596. package/dist/components/underline-icon.js.map +1 -0
  597. package/dist/components/underline.js +37 -0
  598. package/dist/components/underline.js.map +1 -0
  599. package/dist/components/utils.js +140 -0
  600. package/dist/components/utils.js.map +1 -0
  601. package/dist/components/warning-icon.d.ts +11 -0
  602. package/dist/components/warning-icon.js +8 -0
  603. package/dist/components/warning-icon.js.map +1 -0
  604. package/dist/components/warning.js +37 -0
  605. package/dist/components/warning.js.map +1 -0
  606. package/dist/esm/_commonjsHelpers-57e89916.js +20 -0
  607. package/dist/esm/_commonjsHelpers-57e89916.js.map +1 -0
  608. package/dist/esm/app-globals-47969cee.js +9 -0
  609. package/dist/esm/app-globals-47969cee.js.map +1 -0
  610. package/dist/esm/archive-icon_7.entry.js +110 -0
  611. package/dist/esm/archive-icon_7.entry.js.map +1 -0
  612. package/dist/esm/arrow-icon.entry.js +20 -0
  613. package/dist/esm/arrow-icon.entry.js.map +1 -0
  614. package/dist/esm/bold-icon_3.entry.js +50 -0
  615. package/dist/esm/bold-icon_3.entry.js.map +1 -0
  616. package/dist/esm/calendar-cancel-icon.entry.js +20 -0
  617. package/dist/esm/calendar-cancel-icon.entry.js.map +1 -0
  618. package/dist/esm/calendar-check-icon_3.entry.js +50 -0
  619. package/dist/esm/calendar-check-icon_3.entry.js.map +1 -0
  620. package/dist/esm/calendar-icon.entry.js +20 -0
  621. package/dist/esm/calendar-icon.entry.js.map +1 -0
  622. package/dist/esm/chevron-icon.entry.js +20 -0
  623. package/dist/esm/chevron-icon.entry.js.map +1 -0
  624. package/dist/esm/close-icon_2.entry.js +35 -0
  625. package/dist/esm/close-icon_2.entry.js.map +1 -0
  626. package/dist/esm/document-refresh-icon.entry.js +20 -0
  627. package/dist/esm/document-refresh-icon.entry.js.map +1 -0
  628. package/dist/esm/duration-bddc4a13.js +78 -0
  629. package/dist/esm/duration-bddc4a13.js.map +1 -0
  630. package/dist/esm/elements-60ebdb01.js +21583 -0
  631. package/dist/esm/elements-60ebdb01.js.map +1 -0
  632. package/dist/esm/flow-40ff9cea.js +888 -0
  633. package/dist/esm/flow-40ff9cea.js.map +1 -0
  634. package/dist/esm/focus-visible-e8093c16.js +325 -0
  635. package/dist/esm/focus-visible-e8093c16.js.map +1 -0
  636. package/dist/esm/forward-icon_6.entry.js +2207 -0
  637. package/dist/esm/forward-icon_6.entry.js.map +1 -0
  638. package/dist/esm/globe-icon.entry.js +20 -0
  639. package/dist/esm/globe-icon.entry.js.map +1 -0
  640. package/dist/esm/index-2b85580a.js +196 -0
  641. package/dist/esm/index-2b85580a.js.map +1 -0
  642. package/dist/esm/index-b2270b4a.js +2141 -0
  643. package/dist/esm/index-b2270b4a.js.map +1 -0
  644. package/dist/esm/index.es-6f3582a1.js +3211 -0
  645. package/dist/esm/index.es-6f3582a1.js.map +1 -0
  646. package/dist/esm/index.js +8 -0
  647. package/dist/esm/index.js.map +1 -0
  648. package/dist/esm/loader.js +13 -0
  649. package/dist/esm/loader.js.map +1 -0
  650. package/dist/esm/loading-icon.entry.js +20 -0
  651. package/dist/esm/loading-icon.entry.js.map +1 -0
  652. package/dist/esm/mailbox-store-0019772c.js +521 -0
  653. package/dist/esm/mailbox-store-0019772c.js.map +1 -0
  654. package/dist/esm/nylas-booked-event-card_9.entry.js +8115 -0
  655. package/dist/esm/nylas-booked-event-card_9.entry.js.map +1 -0
  656. package/dist/esm/nylas-if-state_3.entry.js +403 -0
  657. package/dist/esm/nylas-if-state_3.entry.js.map +1 -0
  658. package/dist/esm/nylas-list-folders.entry.js +116 -0
  659. package/dist/esm/nylas-list-folders.entry.js.map +1 -0
  660. package/dist/esm/nylas-list-threads.entry.js +85 -0
  661. package/dist/esm/nylas-list-threads.entry.js.map +1 -0
  662. package/dist/esm/nylas-mailbox-pagination.entry.js +136 -0
  663. package/dist/esm/nylas-mailbox-pagination.entry.js.map +1 -0
  664. package/dist/esm/nylas-mailbox-toolbar-button.entry.js +96 -0
  665. package/dist/esm/nylas-mailbox-toolbar-button.entry.js.map +1 -0
  666. package/dist/esm/nylas-open-hours-picker.entry.js +329 -0
  667. package/dist/esm/nylas-open-hours-picker.entry.js.map +1 -0
  668. package/dist/esm/nylas-provider.entry.js +180 -0
  669. package/dist/esm/nylas-provider.entry.js.map +1 -0
  670. package/dist/esm/nylas-scheduler.entry.js +238 -0
  671. package/dist/esm/nylas-scheduler.entry.js.map +1 -0
  672. package/dist/esm/nylas-threads-refresh.entry.js +114 -0
  673. package/dist/esm/nylas-threads-refresh.entry.js.map +1 -0
  674. package/dist/esm/nylas-threads-search.entry.js +80 -0
  675. package/dist/esm/nylas-threads-search.entry.js.map +1 -0
  676. package/dist/esm/nylas-view-thread.entry.js +230 -0
  677. package/dist/esm/nylas-view-thread.entry.js.map +1 -0
  678. package/dist/esm/nylas-web-elements.js +22 -0
  679. package/dist/esm/nylas-web-elements.js.map +1 -0
  680. package/dist/esm/play-icon_2.entry.js +35 -0
  681. package/dist/esm/play-icon_2.entry.js.map +1 -0
  682. package/dist/esm/polyfills/core-js.js +11 -0
  683. package/dist/esm/polyfills/dom.js +79 -0
  684. package/dist/esm/polyfills/es5-html-element.js +1 -0
  685. package/dist/esm/polyfills/index.js +34 -0
  686. package/dist/esm/polyfills/system.js +6 -0
  687. package/dist/esm/property-0065dde7.js +36 -0
  688. package/dist/esm/property-0065dde7.js.map +1 -0
  689. package/dist/esm/refresh-icon.entry.js +20 -0
  690. package/dist/esm/refresh-icon.entry.js.map +1 -0
  691. package/dist/esm/register-component-55376f31.js +138 -0
  692. package/dist/esm/register-component-55376f31.js.map +1 -0
  693. package/dist/esm/scheduler-store-5a39585a.js +251 -0
  694. package/dist/esm/scheduler-store-5a39585a.js.map +1 -0
  695. package/dist/esm/translate-icon.entry.js +20 -0
  696. package/dist/esm/translate-icon.entry.js.map +1 -0
  697. package/dist/esm/utils-5074a070.js +140 -0
  698. package/dist/esm/utils-5074a070.js.map +1 -0
  699. package/dist/index.cjs.js +1 -0
  700. package/dist/index.js +1 -0
  701. package/dist/nylas-web-elements/index.esm.js +2 -0
  702. package/dist/nylas-web-elements/index.esm.js.map +1 -0
  703. package/dist/nylas-web-elements/nylas-web-elements.css +239 -0
  704. package/dist/nylas-web-elements/nylas-web-elements.esm.js +2 -0
  705. package/dist/nylas-web-elements/nylas-web-elements.esm.js.map +1 -0
  706. package/dist/nylas-web-elements/p-06974d68.js +2 -0
  707. package/dist/nylas-web-elements/p-06974d68.js.map +1 -0
  708. package/dist/nylas-web-elements/p-113fe52e.entry.js +2 -0
  709. package/dist/nylas-web-elements/p-113fe52e.entry.js.map +1 -0
  710. package/dist/nylas-web-elements/p-16fb3c85.entry.js +2 -0
  711. package/dist/nylas-web-elements/p-16fb3c85.entry.js.map +1 -0
  712. package/dist/nylas-web-elements/p-24c42c37.entry.js +2 -0
  713. package/dist/nylas-web-elements/p-24c42c37.entry.js.map +1 -0
  714. package/dist/nylas-web-elements/p-2881b62f.js +16519 -0
  715. package/dist/nylas-web-elements/p-2881b62f.js.map +1 -0
  716. package/dist/nylas-web-elements/p-33da6cf1.entry.js +2 -0
  717. package/dist/nylas-web-elements/p-33da6cf1.entry.js.map +1 -0
  718. package/dist/nylas-web-elements/p-37f99b96.entry.js +2 -0
  719. package/dist/nylas-web-elements/p-37f99b96.entry.js.map +1 -0
  720. package/dist/nylas-web-elements/p-3bc3426e.entry.js +2 -0
  721. package/dist/nylas-web-elements/p-3bc3426e.entry.js.map +1 -0
  722. package/dist/nylas-web-elements/p-3c8822f1.entry.js +2 -0
  723. package/dist/nylas-web-elements/p-3c8822f1.entry.js.map +1 -0
  724. package/dist/nylas-web-elements/p-5770704d.js +2 -0
  725. package/dist/nylas-web-elements/p-5770704d.js.map +1 -0
  726. package/dist/nylas-web-elements/p-5862975b.js +2 -0
  727. package/dist/nylas-web-elements/p-5862975b.js.map +1 -0
  728. package/dist/nylas-web-elements/p-647cf7be.entry.js +2 -0
  729. package/dist/nylas-web-elements/p-647cf7be.entry.js.map +1 -0
  730. package/dist/nylas-web-elements/p-663edeb8.entry.js +2 -0
  731. package/dist/nylas-web-elements/p-663edeb8.entry.js.map +1 -0
  732. package/dist/nylas-web-elements/p-67c9158e.entry.js +2 -0
  733. package/dist/nylas-web-elements/p-67c9158e.entry.js.map +1 -0
  734. package/dist/nylas-web-elements/p-6ba7a037.js +2 -0
  735. package/dist/nylas-web-elements/p-6ba7a037.js.map +1 -0
  736. package/dist/nylas-web-elements/p-6da0b8f0.entry.js +2 -0
  737. package/dist/nylas-web-elements/p-6da0b8f0.entry.js.map +1 -0
  738. package/dist/nylas-web-elements/p-6df00ba0.js +27 -0
  739. package/dist/nylas-web-elements/p-6df00ba0.js.map +1 -0
  740. package/dist/nylas-web-elements/p-74141ef6.entry.js +2 -0
  741. package/dist/nylas-web-elements/p-74141ef6.entry.js.map +1 -0
  742. package/dist/nylas-web-elements/p-85d41197.entry.js +2 -0
  743. package/dist/nylas-web-elements/p-85d41197.entry.js.map +1 -0
  744. package/dist/nylas-web-elements/p-97518578.entry.js +2 -0
  745. package/dist/nylas-web-elements/p-97518578.entry.js.map +1 -0
  746. package/dist/nylas-web-elements/p-98ec4a7a.js +2 -0
  747. package/dist/nylas-web-elements/p-98ec4a7a.js.map +1 -0
  748. package/dist/nylas-web-elements/p-998d25d5.entry.js +2 -0
  749. package/dist/nylas-web-elements/p-998d25d5.entry.js.map +1 -0
  750. package/dist/nylas-web-elements/p-a7bfd3af.entry.js +77 -0
  751. package/dist/nylas-web-elements/p-a7bfd3af.entry.js.map +1 -0
  752. package/dist/nylas-web-elements/p-a95208c7.js +2 -0
  753. package/dist/nylas-web-elements/p-a95208c7.js.map +1 -0
  754. package/dist/nylas-web-elements/p-adacdaeb.entry.js +2 -0
  755. package/dist/nylas-web-elements/p-adacdaeb.entry.js.map +1 -0
  756. package/dist/nylas-web-elements/p-b7d4b7b5.entry.js +2 -0
  757. package/dist/nylas-web-elements/p-b7d4b7b5.entry.js.map +1 -0
  758. package/dist/nylas-web-elements/p-b85dfeac.entry.js +2 -0
  759. package/dist/nylas-web-elements/p-b85dfeac.entry.js.map +1 -0
  760. package/dist/nylas-web-elements/p-b96b37f1.entry.js +2 -0
  761. package/dist/nylas-web-elements/p-b96b37f1.entry.js.map +1 -0
  762. package/dist/nylas-web-elements/p-c2e69618.entry.js +2 -0
  763. package/dist/nylas-web-elements/p-c2e69618.entry.js.map +1 -0
  764. package/dist/nylas-web-elements/p-c440f148.entry.js +2 -0
  765. package/dist/nylas-web-elements/p-c440f148.entry.js.map +1 -0
  766. package/dist/nylas-web-elements/p-c66e27d0.js +3 -0
  767. package/dist/nylas-web-elements/p-c66e27d0.js.map +1 -0
  768. package/dist/nylas-web-elements/p-c685e944.entry.js +3 -0
  769. package/dist/nylas-web-elements/p-c685e944.entry.js.map +1 -0
  770. package/dist/nylas-web-elements/p-cb65c223.js +2 -0
  771. package/dist/nylas-web-elements/p-cb65c223.js.map +1 -0
  772. package/dist/nylas-web-elements/p-cc21d351.js +17 -0
  773. package/dist/nylas-web-elements/p-cc21d351.js.map +1 -0
  774. package/dist/nylas-web-elements/p-d4b1e3e4.entry.js +2 -0
  775. package/dist/nylas-web-elements/p-d4b1e3e4.entry.js.map +1 -0
  776. package/dist/nylas-web-elements/p-db24cc70.entry.js +2 -0
  777. package/dist/nylas-web-elements/p-db24cc70.entry.js.map +1 -0
  778. package/dist/nylas-web-elements/p-de1bcc4a.js +2 -0
  779. package/dist/nylas-web-elements/p-de1bcc4a.js.map +1 -0
  780. package/dist/nylas-web-elements/p-df9f71ea.js +2 -0
  781. package/dist/nylas-web-elements/p-df9f71ea.js.map +1 -0
  782. package/dist/nylas-web-elements/p-eeb0a591.js +2 -0
  783. package/dist/nylas-web-elements/p-eeb0a591.js.map +1 -0
  784. package/dist/nylas-web-elements/p-f029c1b7.entry.js +2 -0
  785. package/dist/nylas-web-elements/p-f029c1b7.entry.js.map +1 -0
  786. package/dist/nylas-web-elements/p-f9a4758a.entry.js +2 -0
  787. package/dist/nylas-web-elements/p-f9a4758a.entry.js.map +1 -0
  788. package/dist/types/common/abstract-provider.d.ts +52 -0
  789. package/dist/types/common/component-types.d.ts +22 -0
  790. package/dist/types/common/constants.d.ts +6 -0
  791. package/dist/types/common/global.d.ts +1 -0
  792. package/dist/types/common/icons/archive.d.ts +5 -0
  793. package/dist/types/common/icons/arrow.d.ts +5 -0
  794. package/dist/types/common/icons/bold.d.ts +5 -0
  795. package/dist/types/common/icons/calendar-cancel.d.ts +5 -0
  796. package/dist/types/common/icons/calendar-check.d.ts +5 -0
  797. package/dist/types/common/icons/calendar.d.ts +5 -0
  798. package/dist/types/common/icons/checkmark-circle.d.ts +5 -0
  799. package/dist/types/common/icons/chevron.d.ts +5 -0
  800. package/dist/types/common/icons/close.d.ts +5 -0
  801. package/dist/types/common/icons/document-refresh.d.ts +5 -0
  802. package/dist/types/common/icons/folder.d.ts +5 -0
  803. package/dist/types/common/icons/forward.d.ts +5 -0
  804. package/dist/types/common/icons/globe.d.ts +5 -0
  805. package/dist/types/common/icons/inbox.d.ts +5 -0
  806. package/dist/types/common/icons/italic.d.ts +5 -0
  807. package/dist/types/common/icons/loading.d.ts +5 -0
  808. package/dist/types/common/icons/nylas-logo.d.ts +5 -0
  809. package/dist/types/common/icons/people.d.ts +5 -0
  810. package/dist/types/common/icons/play.d.ts +5 -0
  811. package/dist/types/common/icons/refresh.d.ts +5 -0
  812. package/dist/types/common/icons/reply-all.d.ts +5 -0
  813. package/dist/types/common/icons/reply.d.ts +5 -0
  814. package/dist/types/common/icons/sent.d.ts +5 -0
  815. package/dist/types/common/icons/spam.d.ts +5 -0
  816. package/dist/types/common/icons/star.d.ts +5 -0
  817. package/dist/types/common/icons/stop.d.ts +5 -0
  818. package/dist/types/common/icons/translate.d.ts +5 -0
  819. package/dist/types/common/icons/trash.d.ts +5 -0
  820. package/dist/types/common/icons/underline.d.ts +5 -0
  821. package/dist/types/common/icons/warning.d.ts +5 -0
  822. package/dist/types/common/mocks/threads.d.ts +3 -0
  823. package/dist/types/common/nylas-theme/index.d.ts +27 -0
  824. package/dist/types/common/register-component.d.ts +29 -0
  825. package/dist/types/common/types.d.ts +108 -0
  826. package/dist/types/components/mailbox/nylas-composer/nylas-composer.d.ts +22 -0
  827. package/dist/types/components/mailbox/nylas-composer/test/nylas-composer.spec-disabled.d.ts +1 -0
  828. package/dist/types/components/mailbox/nylas-list-folders/nylas-list-folders.d.ts +19 -0
  829. package/dist/types/components/mailbox/nylas-list-threads/nylas-list-threads.d.ts +19 -0
  830. package/dist/types/components/mailbox/nylas-mailbox/nylas-mailbox.d.ts +35 -0
  831. package/dist/types/components/mailbox/nylas-mailbox-pagination/nylas-mailbox-pagination.d.ts +30 -0
  832. package/dist/types/components/mailbox/nylas-mailbox-toolbar-button/nylas-mailbox-toolbar-button.d.ts +26 -0
  833. package/dist/types/components/mailbox/nylas-summarize-message-button/nylas-summarize-message-button.d.ts +25 -0
  834. package/dist/types/components/mailbox/nylas-threads-refresh/nylas-threads-refresh.d.ts +23 -0
  835. package/dist/types/components/mailbox/nylas-threads-search/nylas-threads-search.d.ts +13 -0
  836. package/dist/types/components/mailbox/nylas-view-email/nylas-view-email.d.ts +25 -0
  837. package/dist/types/components/mailbox/nylas-view-thread/nylas-view-thread.d.ts +30 -0
  838. package/dist/types/components/mailbox/nylas-view-thread/view-thread-message.d.ts +12 -0
  839. package/dist/types/components/nylas-if-state/nylas-if-state.d.ts +22 -0
  840. package/dist/types/components/nylas-login/nylas-login.d.ts +26 -0
  841. package/dist/types/components/nylas-provider/nylas-provider.d.ts +35 -0
  842. package/dist/types/components/scheduler/nylas-booked-event-card/nylas-booked-event-card.d.ts +22 -0
  843. package/dist/types/components/scheduler/nylas-booking-form/nylas-booking-form.d.ts +33 -0
  844. package/dist/types/components/scheduler/nylas-cancelled-event-card/nylas-cancelled-event-card.d.ts +13 -0
  845. package/dist/types/components/scheduler/nylas-date-picker/nylas-date-picker.d.ts +19 -0
  846. package/dist/types/components/scheduler/nylas-locale-switch/nylas-locale-switch.d.ts +13 -0
  847. package/dist/types/components/scheduler/nylas-notification/nylas-notification.d.ts +13 -0
  848. package/dist/types/components/scheduler/nylas-open-hours-picker/nylas-open-hours-picker.d.ts +40 -0
  849. package/dist/types/components/scheduler/nylas-scheduler/nylas-scheduler.d.ts +41 -0
  850. package/dist/types/components/scheduler/nylas-scheduler/scheduler-view.d.ts +6 -0
  851. package/dist/types/components/scheduler/nylas-selected-event-card/nylas-selected-event-card.d.ts +15 -0
  852. package/dist/types/components/scheduler/nylas-timeslot-picker/nylas-timeslot-picker.d.ts +28 -0
  853. package/dist/types/components.d.ts +2123 -0
  854. package/dist/types/connector/connector-interface.d.ts +35 -0
  855. package/dist/types/connector/nylas-connector/index.d.ts +59 -0
  856. package/dist/types/connector/nylas-mailbox-connector/index.d.ts +52 -0
  857. package/dist/types/connector/nylas-scheduler-connector/index.d.ts +24 -0
  858. package/dist/types/connector/shared/api/auth.d.ts +13 -0
  859. package/dist/types/connector/shared/api/folders.d.ts +10 -0
  860. package/dist/types/connector/shared/api/messages.d.ts +13 -0
  861. package/dist/types/connector/shared/api/scheduler.d.ts +29 -0
  862. package/dist/types/connector/shared/api/threads.d.ts +20 -0
  863. package/dist/types/index.d.ts +4 -0
  864. package/dist/types/routers/hash-router.d.ts +21 -0
  865. package/dist/types/routers/router-interface.d.ts +16 -0
  866. package/dist/types/stencil-public-runtime.d.ts +1681 -0
  867. package/dist/types/stores/auth-store.d.ts +9 -0
  868. package/dist/types/stores/mailbox-store.d.ts +19 -0
  869. package/dist/types/stores/scheduler-store.d.ts +32 -0
  870. package/dist/types/utils/color-utils.d.ts +9 -0
  871. package/dist/types/utils/utils.d.ts +28 -0
  872. package/loader/cdn.js +3 -0
  873. package/loader/index.cjs.js +3 -0
  874. package/loader/index.d.ts +21 -0
  875. package/loader/index.es2017.js +3 -0
  876. package/loader/index.js +4 -0
  877. package/loader/package.json +11 -0
  878. package/package.json +69 -0
  879. package/readme.md +42 -0
@@ -0,0 +1,2207 @@
1
+ import { r as registerInstance, h, c as createEvent, H as Host, a as getElement, F as Fragment } from './index-b2270b4a.js';
2
+ import { d as debug, k as htmlToPlainText, l as detectIfMessageIsHTML, m as detectHTMLOrPlainText, p as parsePlainTextToHTML } from './utils-5074a070.js';
3
+ import { R as RegisterComponent } from './register-component-55376f31.js';
4
+ import { c as commonjsGlobal } from './_commonjsHelpers-57e89916.js';
5
+
6
+ const iconCss$2 = ".sc-forward-icon-h{display:flex}";
7
+ const ForwardIconStyle0 = iconCss$2;
8
+
9
+ const ForwardIcon = class {
10
+ constructor(hostRef) {
11
+ registerInstance(this, hostRef);
12
+ this.width = '15';
13
+ this.height = '15';
14
+ }
15
+ render() {
16
+ return (h("svg", { key: '4f51b5a4b2779e9877ce09164250017619114cb0', fill: "auto", width: this.width, height: this.height, viewBox: "0 0 1920 1920", xmlns: "http://www.w3.org/2000/svg" }, h("path", { key: 'b2f1b016bdaef66b1c014791dd681fdfbdb3a160', d: "m1246.246 64-90.496 90.496 477.952 477.952h-590.848C467.878 632.448.038 1100.416.038 1675.392v109.056h128v-109.056c0-504.576 410.368-914.944 914.816-914.944h590.848l-477.952 478.08 90.496 90.496 632.448-632.576L1246.246 64Z", "fill-rule": "evenodd" })));
17
+ }
18
+ };
19
+ ForwardIcon.style = ForwardIconStyle0;
20
+
21
+ const nylasComposerCss = ":host{display:grid;color:var(--nylas-color-primary-900)}.editor{position:relative;display:block;max-height:300px;overflow:auto;padding:1rem;border:1px solid var(--nylas-color-primary-300)}.editor blockquote{visibility:hidden;overflow:hidden;position:relative;transition:height 0.3s ease;margin:0}.editor blockquote::before{content:\"...\";visibility:visible;opacity:1;position:absolute;top:0;left:0;background-color:var(--nylas-color-primary-300);width:20px;text-align:center;color:var(--nylas-color-primary-800);vertical-align:middle;display:flex;justify-content:center;align-items:center;align-self:center;cursor:pointer}.editor .collapsed{height:20px}.editor .expanded{visibility:visible;opacity:1;height:auto;margin:0px 0px 0px 0.8ex;border-left:1px solid var(--nylas-color-primary-300);padding-left:1rem}.editor .expanded::before{display:none;}.buttons{display:flex;margin-top:1rem;justify-content:space-between}.buttons sp-button{border-radius:var(--nylas-border-radius);background-color:var(--nylas-color-primary-400);color:var(--nylas-color-primary-900);fill:var(--nylas-color-primary-900)}.buttons sp-button:hover{background-color:var(--nylas-color-primary-500)}.buttons sp-button:disabled{background-color:var(--nylas-color-primary-200);color:var(--nylas-color-primary-600);cursor:not-allowed}.buttons sp-button chevron-icon{display:inline-block}.buttons .close{justify-self:end}.toolbar{position:absolute;display:none;background-color:var(--nylas-color-primary-200);border-radius:var(--nylas-border-radius);z-index:1}.toolbar sp-button{border:0}";
22
+ const NylasComposerStyle0 = nylasComposerCss;
23
+
24
+ const NylasComposer = class {
25
+ constructor(hostRef) {
26
+ registerInstance(this, hostRef);
27
+ this.close = createEvent(this, "close", 7);
28
+ this.send = createEvent(this, "send", 7);
29
+ this.closeComposer = (event) => {
30
+ this.close.emit(event);
31
+ };
32
+ this.sendComposer = (event) => {
33
+ if (!this.editorEl) {
34
+ debug('no editor element');
35
+ return;
36
+ }
37
+ const messageBody = this.editorEl.querySelector('.message-body');
38
+ if (!messageBody) {
39
+ debug('no message body');
40
+ return;
41
+ }
42
+ if (this.message) {
43
+ this.send.emit({
44
+ message: this.message,
45
+ replyBody: messageBody.querySelector('.message-body')?.innerHTML || '',
46
+ });
47
+ this.close.emit(event);
48
+ this.editorEl.innerHTML = '';
49
+ }
50
+ };
51
+ this.message = undefined;
52
+ this.viewEmailElement = undefined;
53
+ }
54
+ connectedCallback() { }
55
+ disconnectedCallback() {
56
+ if (this.editorEl) {
57
+ this.editorEl.innerHTML = '';
58
+ }
59
+ }
60
+ componentWillLoad() { }
61
+ async componentDidLoad() {
62
+ if (this.message) {
63
+ this.watchBody(this.message);
64
+ }
65
+ if (!this.editorEl) {
66
+ debug('[connectedCallback] no editor element');
67
+ return;
68
+ }
69
+ if (!this.toolbarEl) {
70
+ debug('[connectedCallback] no toolbar element');
71
+ return;
72
+ }
73
+ const editorEl = this.editorEl;
74
+ const toolbarEl = this.toolbarEl;
75
+ editorEl.addEventListener('mouseup', _ => {
76
+ const selection = this.host.shadowRoot?.getSelection();
77
+ if (!selection) {
78
+ debug('no selection');
79
+ return;
80
+ }
81
+ const range = selection.getRangeAt(0);
82
+ const text = selection.toString();
83
+ if (!text) {
84
+ toolbarEl.style.display = 'none';
85
+ return;
86
+ }
87
+ const messageBody = editorEl.querySelector('.message-body');
88
+ if (!messageBody) {
89
+ debug('no message body');
90
+ return;
91
+ }
92
+ const foundNode = range.commonAncestorContainer;
93
+ const foundElement = foundNode.parentElement;
94
+ if (!foundElement) {
95
+ return;
96
+ }
97
+ const messageBodyRect = messageBody.getBoundingClientRect();
98
+ debug('messageBodyRect', { messageBodyRect });
99
+ const foundRect = foundElement.getBoundingClientRect();
100
+ debug('foundRect', { foundRect });
101
+ const textNode = foundElement.childNodes[0];
102
+ const textContent = textNode.textContent || '';
103
+ const textPosition = textContent.indexOf(text);
104
+ const fontSize = window.getComputedStyle(foundElement).fontSize;
105
+ const fontSizeNumber = parseInt(fontSize.replace('px', ''), 10);
106
+ const top = foundRect.top - messageBodyRect.top - toolbarEl.clientHeight;
107
+ const left = textPosition * (1 / fontSizeNumber) * 100;
108
+ toolbarEl.style.top = `${top}px`;
109
+ toolbarEl.style.left = `${left}px`;
110
+ toolbarEl.style.display = 'block';
111
+ });
112
+ }
113
+ watchBody(newMessage) {
114
+ if (!this.editorEl) {
115
+ debug('no editor element');
116
+ return;
117
+ }
118
+ this.editorEl.querySelectorAll('.message-body').forEach(el => el.remove());
119
+ const messageBody = document.createElement('div');
120
+ messageBody.classList.add('message-body');
121
+ const emptyParagraph = document.createElement('p');
122
+ emptyParagraph.innerHTML = ' ';
123
+ messageBody.appendChild(emptyParagraph);
124
+ const br = document.createElement('br');
125
+ messageBody.appendChild(br);
126
+ const replyText = document.createElement('div');
127
+ replyText.classList.add('reply-text');
128
+ replyText.innerText = `On ${new Date(newMessage.date * 1000).toLocaleDateString(undefined, { dateStyle: 'full' })} <${newMessage.from
129
+ ?.map(from => from.name || from.email)
130
+ .join(', ')}> wrote:`;
131
+ messageBody.appendChild(replyText);
132
+ if (newMessage.body) {
133
+ const replyElement = document.createElement('html');
134
+ replyElement.innerHTML = newMessage.body;
135
+ const replyContainer = document.createElement('blockquote');
136
+ replyContainer.classList.add('collapsed');
137
+ replyContainer.classList.add('gmail_quote');
138
+ replyContainer.innerHTML = replyElement.innerHTML;
139
+ messageBody.appendChild(replyContainer);
140
+ debug('replyContainer', { replyContainer });
141
+ }
142
+ this.editorEl.appendChild(messageBody);
143
+ this.editorEl.querySelectorAll('blockquote.collapsed').forEach(blockquote => {
144
+ blockquote.addEventListener('click', function (event) {
145
+ event.preventDefault();
146
+ const el = event.target;
147
+ el.classList.remove('collapsed');
148
+ el.classList.add('expanded');
149
+ }, { once: true });
150
+ });
151
+ this.editorEl.focus();
152
+ }
153
+ render() {
154
+ return (h(Host, { key: 'a1e6e146356d27b4612c1381a051e421468016f9' }, h("sp-theme", { key: 'a55f43e956e35a41e0854b7653f3eaa0472e4603', scale: "medium", color: "dark" }, h("div", { key: 'dca393d6d4cae7d64630c2e684fa403638135aab', class: "editor", contentEditable: true, ref: r => (this.editorEl = r) }, h("div", { key: 'e77b4c9ea8b843cb15ebe92b49120bcf7b6a7ce4', class: "toolbar", ref: r => (this.toolbarEl = r), contentEditable: false }, h("sp-button", { key: '0b825b12e643a37c4e746eec4fc51608f576a58b', quiet: true, onClick: () => document.execCommand('bold') }, h("div", { key: '95051b6e9b07e9792e180e09a0ca74c834a6f6c8', slot: "icon" }, h("bold-icon", { key: '6f33cd1e9525984d8c9b001f2b3a114bf08ec9a5' })), h("div", { key: '250323dfd86467b528903b7cdbfc704efffcc789', slot: "label" }, "Bold")), h("sp-button", { key: 'af4d4302617dd0ee1ad3d50161e4a019e4fbc1e7', quiet: true, onClick: () => document.execCommand('underline') }, h("div", { key: 'aa2e4a6c9be743d228b5ebc7a8c59d59cbed5b2c', slot: "icon" }, h("underline-icon", { key: '6833ead83e35cd0b07c0c88b81be3446d3efd824' })), h("div", { key: '1c18f62267adfa70e176efed64f745dd202c0230', slot: "label" }, "Underline")), h("sp-button", { key: '08139372218452b7b83aa9580cb9a797106b189f', quiet: true, onClick: () => document.execCommand('italic') }, h("div", { key: 'bd439d444ae836a0c612e57f92b7c0e303ff732a', slot: "icon" }, h("italic-icon", { key: 'c25d86181198e1f1b176caad9ccfc0ecd5653c15' })), h("div", { key: 'c6231490b7c86113f8dbcfc8386ec5581f6b2a3a', slot: "label" }, "Italic")))), h("div", { key: '95921362af8283ee5d04cf17faf4c8b5725ba7bd', class: 'buttons' }, h("sp-button", { key: '6c21a44e39720b78fddda544d3b3e3dd2597d9c3', onClick: this.sendComposer, class: "send" }, "Send"), h("sp-button", { key: '2d0354668c676f6e723be1f0e9614cff6120d361', onClick: this.closeComposer, class: "close" }, "Close")))));
155
+ }
156
+ get host() { return getElement(this); }
157
+ static get watchers() { return {
158
+ "message": ["watchBody"]
159
+ }; }
160
+ };
161
+ NylasComposer.style = NylasComposerStyle0;
162
+
163
+ const nylasSummarizeMessageButtonCss = ":host{display:block}sp-button{padding:0;border:0;border-radius:var(--nylas-border-radius);min-block-size:50%;min-inline-size:2rem;background-color:var(--nylas-color-primary-300);fill:var(--nylas-color-primary-800)}sp-button:hover{background-color:var(--nylas-color-primary-400)}.summarize-button.stopped{animation:none}.summarize-button.playing{animation:pulse 2s infinite}.summarize-button.loading{display:flex;align-content:center;height:1.5rem;width:2rem;vertical-align:middle;animation:pulse 2s infinite;flex-wrap:wrap}.summarize-button.loading loading-icon{--dot-color:var(--nylas-color-primary-600)}@keyframes pulse{0%{transform:scale(1);box-shadow:0 0 0 0 var(--nylas-color-primary-300)}70%{transform:scale(1.05);box-shadow:0 0 0 10px rgba(255, 69, 0, 0)}100%{transform:scale(1);box-shadow:0 0 0 0 rgba(255, 69, 0, 0)}}@keyframes wave{0%{transform:translateX(0)}50%{transform:translateX(100%)}100%{transform:translateX(0)}}";
164
+ const NylasSummarizeMessageButtonStyle0 = nylasSummarizeMessageButtonCss;
165
+
166
+ var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
167
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
168
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
169
+ r = Reflect.decorate(decorators, target, key, desc);
170
+ else
171
+ for (var i = decorators.length - 1; i >= 0; i--)
172
+ if (d = decorators[i])
173
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
174
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
175
+ };
176
+ var __metadata = (undefined && undefined.__metadata) || function (k, v) {
177
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
178
+ return Reflect.metadata(k, v);
179
+ };
180
+ const NylasSummarizeMessageButton = class {
181
+ constructor(hostRef) {
182
+ registerInstance(this, hostRef);
183
+ this.summarize = createEvent(this, "summarize", 7);
184
+ this.abortController = new AbortController();
185
+ this.onClick = async (event) => {
186
+ event.preventDefault();
187
+ event.stopPropagation();
188
+ if (this.state === 'stopped') {
189
+ if (this.message) {
190
+ this.abortController = new AbortController();
191
+ const event = this.summarize.emit({
192
+ abortController: this.abortController,
193
+ playAudio: this.playAudio,
194
+ message: this.message,
195
+ updateState: this.updateState,
196
+ });
197
+ if (!event.defaultPrevented) {
198
+ debug(`[nylas-summarize-message-button] Default event not prevented, summarizing message`);
199
+ if (this.audioRef) {
200
+ await this.audioRef
201
+ .play()
202
+ .then(() => this.audioRef?.pause())
203
+ .catch(error => console.error('Error playing audio:', error));
204
+ await this.audioRef.play().catch(error => console.error('Error playing audio:', error));
205
+ }
206
+ }
207
+ }
208
+ }
209
+ else if (this.state === 'playing') {
210
+ this.abortController?.abort();
211
+ this.audioRef?.pause();
212
+ }
213
+ else {
214
+ this.state = 'stopped';
215
+ }
216
+ };
217
+ this.message = undefined;
218
+ this.state = 'stopped';
219
+ this.playAudio = this.playAudio.bind(this);
220
+ this.updateState = this.updateState.bind(this);
221
+ }
222
+ connectedCallback() { }
223
+ disconnectedCallback() { }
224
+ async componentWillLoad() {
225
+ debug(`[nylas-summarize-message-button] Component will load`);
226
+ }
227
+ async componentDidLoad() {
228
+ debug(`[nylas-summarize-message-button] Component did load`);
229
+ }
230
+ async updateState(state) {
231
+ this.state = state;
232
+ }
233
+ async playAudio(ttsResponseBody) {
234
+ if (!this.audioRef) {
235
+ this.state = 'stopped';
236
+ return;
237
+ }
238
+ if (!ttsResponseBody) {
239
+ this.state = 'stopped';
240
+ return;
241
+ }
242
+ const audioElement = this.audioRef;
243
+ if (!('MediaSource' in window)) {
244
+ const rb = await ttsResponseBody;
245
+ if (rb == null) {
246
+ throw new Error('ReadableStream not yet supported in this browser.');
247
+ }
248
+ const reader = rb.getReader();
249
+ const chunks = [];
250
+ await this.readChunk(reader, chunks);
251
+ const blob = new Blob(chunks, { type: 'audio/mpeg' });
252
+ const blobUrl = URL.createObjectURL(blob);
253
+ audioElement.src = blobUrl;
254
+ return;
255
+ }
256
+ const mediaSource = new MediaSource();
257
+ let sourceBuffer;
258
+ let sourceDone = false;
259
+ audioElement.src = URL.createObjectURL(mediaSource);
260
+ mediaSource.addEventListener('sourceopen', onMediaSourceOpen);
261
+ async function onMediaSourceOpen() {
262
+ sourceBuffer = mediaSource.addSourceBuffer('audio/mpeg');
263
+ sourceBuffer.addEventListener('updateend', onUpdateEnd);
264
+ const rb = await ttsResponseBody;
265
+ if (rb == null) {
266
+ throw new Error('ReadableStream not yet supported in this browser.');
267
+ }
268
+ const reader = rb.getReader();
269
+ const pump = () => {
270
+ reader
271
+ .read()
272
+ .then(({ done, value }) => {
273
+ if (done) {
274
+ sourceDone = true;
275
+ return;
276
+ }
277
+ if (!sourceBuffer.updating) {
278
+ sourceBuffer.appendBuffer(value);
279
+ }
280
+ pump();
281
+ })
282
+ .catch(error => {
283
+ console.error('Error while fetching and appending chunks:', error);
284
+ });
285
+ };
286
+ pump();
287
+ if (audioElement.paused) {
288
+ audioElement.play().catch(error => console.error('Error playing audio:', error));
289
+ }
290
+ }
291
+ function onUpdateEnd() {
292
+ if (sourceDone) {
293
+ mediaSource.endOfStream();
294
+ mediaSource.removeEventListener('sourceopen', onMediaSourceOpen);
295
+ mediaSource.removeEventListener('sourceclose', () => {
296
+ debug(`[nylas-summarize-message-button] Source closed`);
297
+ });
298
+ sourceBuffer.removeEventListener('updateend', onUpdateEnd);
299
+ return;
300
+ }
301
+ }
302
+ }
303
+ async readChunk(reader, chunks) {
304
+ return reader.read().then(({ done, value }) => {
305
+ if (done) {
306
+ return chunks;
307
+ }
308
+ chunks.push(value);
309
+ return this.readChunk(reader, chunks);
310
+ });
311
+ }
312
+ render() {
313
+ return (h(Host, { key: '507fa8a1d6570be296501c8e154ef8b85cda0871' }, h("sp-theme", { key: '2db0d8c57e95c758f240a0e9328c26ec4e3d2e77', scale: "medium", color: "dark" }, h("sp-button", { key: 'df8bb0eb9069456125bd570eb280f018e0ebb9e3', label: "Summarize email", "icon-only": true, onClickCapture: this.onClick, class: {
314
+ 'summarize-button': true,
315
+ 'stopped': this.state === 'stopped',
316
+ 'loading': this.state === 'loading',
317
+ 'playing': this.state === 'playing',
318
+ } }, this.state === 'stopped' && h("play-icon", null), this.state === 'loading' && h("loading-icon", null), this.state === 'playing' && h("stop-icon", null)), h("audio", { key: '3bc2427c264410ae9c68f1aec3d3b0c675ae108b', ref: r => (this.audioRef = r), autoPlay: true, onPlaying: () => (this.state = 'playing'), onPause: () => (this.state = 'stopped'), onEnded: () => {
319
+ this.state = 'stopped';
320
+ debug(`[nylas-summarize-message-button] Audio ended`);
321
+ } }))));
322
+ }
323
+ };
324
+ __decorate([
325
+ RegisterComponent({
326
+ name: 'nylas-summarize-message-button',
327
+ eventToProps: {
328
+ summarize: async (event, nylasConnector) => {
329
+ const { playAudio, updateState, abortController, message } = event.detail;
330
+ const text = htmlToPlainText(message.body || '');
331
+ await updateState('loading');
332
+ try {
333
+ const summary = await nylasConnector.messages.summarizeText(text);
334
+ const ttsResponseBody = nylasConnector.messages.textToSpeech(summary, abortController);
335
+ await playAudio(ttsResponseBody);
336
+ }
337
+ catch (error) {
338
+ await updateState('stopped');
339
+ console.error('Error summarizing message:', error);
340
+ }
341
+ },
342
+ },
343
+ fireRegisterEvent: true,
344
+ }),
345
+ __metadata("design:type", Function),
346
+ __metadata("design:paramtypes", []),
347
+ __metadata("design:returntype", void 0)
348
+ ], NylasSummarizeMessageButton.prototype, "render", null);
349
+ NylasSummarizeMessageButton.style = NylasSummarizeMessageButtonStyle0;
350
+
351
+ function invertColor(color) {
352
+ if (!window.matchMedia('(prefers-color-scheme: dark)').matches) {
353
+ return color;
354
+ }
355
+ if (!color) {
356
+ return color;
357
+ }
358
+ if (color === 'transparent') {
359
+ return 'color';
360
+ }
361
+ if (color.startsWith('#')) {
362
+ return invertHexColor(color);
363
+ }
364
+ if (color.startsWith('rgb')) {
365
+ return invertRgbColor(color);
366
+ }
367
+ if (color.startsWith('hsl')) {
368
+ return invertHslColor(color);
369
+ }
370
+ if (isNamedColor(color)) {
371
+ return invertNamedColor(color);
372
+ }
373
+ return color;
374
+ }
375
+ function invertHexColor(hex) {
376
+ if (hex.length < 7) {
377
+ hex = '#' + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3];
378
+ }
379
+ const r = (255 - parseInt(hex.slice(1, 3), 16)).toString(16).padStart(2, '0');
380
+ const g = (255 - parseInt(hex.slice(3, 5), 16)).toString(16).padStart(2, '0');
381
+ const b = (255 - parseInt(hex.slice(5, 7), 16)).toString(16).padStart(2, '0');
382
+ return `#${r}${g}${b}`;
383
+ }
384
+ function invertRgbColor(rgb) {
385
+ const match = rgb.match(/\d+/g)?.map(Number);
386
+ if (!match) {
387
+ return rgb;
388
+ }
389
+ const [r, g, b] = match;
390
+ return `rgb(${255 - r}, ${255 - g}, ${255 - b})`;
391
+ }
392
+ function invertHslColor(hsl) {
393
+ const match = hsl.match(/\d+\.?\d*/g)?.map(Number);
394
+ if (!match) {
395
+ return hsl;
396
+ }
397
+ const [h, s, l] = match;
398
+ return `hsl(${h}, ${s}%, ${100 - l}%)`;
399
+ }
400
+ function isNamedColor(color) {
401
+ return /^[a-z]+$/i.test(color);
402
+ }
403
+ function invertNamedColor(color) {
404
+ return invertRgbColor(namedColorToRgb(color));
405
+ }
406
+ function namedColorToRgb(color) {
407
+ if (color.toLowerCase() === 'red') {
408
+ return 'rgb(255, 0, 0)';
409
+ }
410
+ return 'rgb(0, 0, 0)';
411
+ }
412
+ function transformElement(element) {
413
+ if (element instanceof HTMLStyleElement) {
414
+ let styleTextContent = element.textContent;
415
+ if (styleTextContent) {
416
+ styleTextContent = styleTextContent.replaceAll(/@media\s*\(prefers-color-scheme:\s*(dark|light)\)\s*\{([^}]+)\}/g, '');
417
+ const borderColor = styleTextContent.matchAll(/border-color:\s*([^;]+)/g);
418
+ if (borderColor) {
419
+ for (const match of borderColor) {
420
+ const [fullMatch, color] = match;
421
+ const escapedFullMatch = fullMatch.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
422
+ styleTextContent = styleTextContent.replaceAll(escapedFullMatch, fullMatch.replace(color, invertColor(color)));
423
+ }
424
+ }
425
+ const border = styleTextContent.matchAll(/border:\s*([^;]+)/g);
426
+ if (border) {
427
+ for (const match of border) {
428
+ const fullMatch = match[0].trim();
429
+ const escapedFullMatch = fullMatch.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
430
+ const [_width, _style, color] = match[1].split(' ');
431
+ styleTextContent = styleTextContent.replaceAll(escapedFullMatch, fullMatch.replace(color, invertColor(color)));
432
+ }
433
+ }
434
+ const backgroundColor = styleTextContent.matchAll(/background-color:\s*([^;]+)/g);
435
+ if (backgroundColor) {
436
+ for (const match of backgroundColor) {
437
+ const [fullMatch, color] = match;
438
+ const escapedFullMatch = fullMatch.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
439
+ styleTextContent = styleTextContent.replaceAll(escapedFullMatch, fullMatch.replace(color, invertColor(color)));
440
+ debug('backgroundColor', { fullMatch, replace: fullMatch.replace(color, invertColor(color)), color, invertColor: invertColor(color) });
441
+ }
442
+ }
443
+ const background = styleTextContent.matchAll(/background:\s*([^;]+)/g);
444
+ if (background) {
445
+ for (const match of background) {
446
+ const fullMatch = match[0].trim();
447
+ const escapedFullMatch = fullMatch.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
448
+ const [_width, _style, color] = match[1].split(' ');
449
+ styleTextContent = styleTextContent.replaceAll(escapedFullMatch, fullMatch.replace(color, invertColor(color)));
450
+ }
451
+ }
452
+ const color = styleTextContent.matchAll(/color:\s*([^;]+)/g);
453
+ if (color) {
454
+ for (const match of color) {
455
+ const [fullMatch, color] = match;
456
+ const escapedFullMatch = fullMatch.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
457
+ styleTextContent = styleTextContent.replaceAll(escapedFullMatch, fullMatch.replace(color, invertColor(color)));
458
+ }
459
+ }
460
+ element.textContent = styleTextContent;
461
+ }
462
+ }
463
+ if (element instanceof HTMLElement) {
464
+ const computedStyle = window.getComputedStyle(element);
465
+ const color = computedStyle.color || element.style.color;
466
+ const backgroundColor = computedStyle.backgroundColor || element.style.backgroundColor;
467
+ const borderColor = computedStyle.borderColor || element.style.borderColor;
468
+ if (color && !backgroundColor) {
469
+ element.style.color = '';
470
+ }
471
+ else if (color && backgroundColor) {
472
+ element.style.color = invertColor(color);
473
+ element.style.backgroundColor = invertColor(backgroundColor);
474
+ debug('element', element);
475
+ debug('computedStyle.color', color);
476
+ debug('computedStyle.backgroundColor', backgroundColor);
477
+ debug('invertColor(color)', invertColor(color));
478
+ debug('invertColor(backgroundColor)', invertColor(backgroundColor));
479
+ }
480
+ else if (!color && backgroundColor) {
481
+ element.style.backgroundColor = '';
482
+ }
483
+ if (borderColor) {
484
+ debug('borderColor', borderColor);
485
+ element.style.borderColor = invertColor(borderColor);
486
+ }
487
+ if (element.hasAttribute('bgcolor')) {
488
+ element.removeAttribute('bgcolor');
489
+ }
490
+ }
491
+ }
492
+ function processStyles(root) {
493
+ transformElement(root);
494
+ const elements = root.querySelectorAll('*');
495
+ elements.forEach(element => transformElement(element));
496
+ }
497
+
498
+ var purify = {exports: {}};
499
+
500
+ /*! @license DOMPurify 3.0.8 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.8/LICENSE */
501
+
502
+ (function (module, exports) {
503
+ (function (global, factory) {
504
+ module.exports = factory() ;
505
+ })(commonjsGlobal, (function () {
506
+ const {
507
+ entries,
508
+ setPrototypeOf,
509
+ isFrozen,
510
+ getPrototypeOf,
511
+ getOwnPropertyDescriptor
512
+ } = Object;
513
+ let {
514
+ freeze,
515
+ seal,
516
+ create
517
+ } = Object; // eslint-disable-line import/no-mutable-exports
518
+ let {
519
+ apply,
520
+ construct
521
+ } = typeof Reflect !== 'undefined' && Reflect;
522
+ if (!freeze) {
523
+ freeze = function freeze(x) {
524
+ return x;
525
+ };
526
+ }
527
+ if (!seal) {
528
+ seal = function seal(x) {
529
+ return x;
530
+ };
531
+ }
532
+ if (!apply) {
533
+ apply = function apply(fun, thisValue, args) {
534
+ return fun.apply(thisValue, args);
535
+ };
536
+ }
537
+ if (!construct) {
538
+ construct = function construct(Func, args) {
539
+ return new Func(...args);
540
+ };
541
+ }
542
+ const arrayForEach = unapply(Array.prototype.forEach);
543
+ const arrayPop = unapply(Array.prototype.pop);
544
+ const arrayPush = unapply(Array.prototype.push);
545
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
546
+ const stringToString = unapply(String.prototype.toString);
547
+ const stringMatch = unapply(String.prototype.match);
548
+ const stringReplace = unapply(String.prototype.replace);
549
+ const stringIndexOf = unapply(String.prototype.indexOf);
550
+ const stringTrim = unapply(String.prototype.trim);
551
+ const regExpTest = unapply(RegExp.prototype.test);
552
+ const typeErrorCreate = unconstruct(TypeError);
553
+
554
+ /**
555
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
556
+ *
557
+ * @param {Function} func - The function to be wrapped and called.
558
+ * @returns {Function} A new function that calls the given function with a specified thisArg and arguments.
559
+ */
560
+ function unapply(func) {
561
+ return function (thisArg) {
562
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
563
+ args[_key - 1] = arguments[_key];
564
+ }
565
+ return apply(func, thisArg, args);
566
+ };
567
+ }
568
+
569
+ /**
570
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
571
+ *
572
+ * @param {Function} func - The constructor function to be wrapped and called.
573
+ * @returns {Function} A new function that constructs an instance of the given constructor function with the provided arguments.
574
+ */
575
+ function unconstruct(func) {
576
+ return function () {
577
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
578
+ args[_key2] = arguments[_key2];
579
+ }
580
+ return construct(func, args);
581
+ };
582
+ }
583
+
584
+ /**
585
+ * Add properties to a lookup table
586
+ *
587
+ * @param {Object} set - The set to which elements will be added.
588
+ * @param {Array} array - The array containing elements to be added to the set.
589
+ * @param {Function} transformCaseFunc - An optional function to transform the case of each element before adding to the set.
590
+ * @returns {Object} The modified set with added elements.
591
+ */
592
+ function addToSet(set, array) {
593
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
594
+ if (setPrototypeOf) {
595
+ // Make 'in' and truthy checks like Boolean(set.constructor)
596
+ // independent of any properties defined on Object.prototype.
597
+ // Prevent prototype setters from intercepting set as a this value.
598
+ setPrototypeOf(set, null);
599
+ }
600
+ let l = array.length;
601
+ while (l--) {
602
+ let element = array[l];
603
+ if (typeof element === 'string') {
604
+ const lcElement = transformCaseFunc(element);
605
+ if (lcElement !== element) {
606
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
607
+ if (!isFrozen(array)) {
608
+ array[l] = lcElement;
609
+ }
610
+ element = lcElement;
611
+ }
612
+ }
613
+ set[element] = true;
614
+ }
615
+ return set;
616
+ }
617
+
618
+ /**
619
+ * Clean up an array to harden against CSPP
620
+ *
621
+ * @param {Array} array - The array to be cleaned.
622
+ * @returns {Array} The cleaned version of the array
623
+ */
624
+ function cleanArray(array) {
625
+ for (let index = 0; index < array.length; index++) {
626
+ if (getOwnPropertyDescriptor(array, index) === undefined) {
627
+ array[index] = null;
628
+ }
629
+ }
630
+ return array;
631
+ }
632
+
633
+ /**
634
+ * Shallow clone an object
635
+ *
636
+ * @param {Object} object - The object to be cloned.
637
+ * @returns {Object} A new object that copies the original.
638
+ */
639
+ function clone(object) {
640
+ const newObject = create(null);
641
+ for (const [property, value] of entries(object)) {
642
+ if (getOwnPropertyDescriptor(object, property) !== undefined) {
643
+ if (Array.isArray(value)) {
644
+ newObject[property] = cleanArray(value);
645
+ } else if (value && typeof value === 'object' && value.constructor === Object) {
646
+ newObject[property] = clone(value);
647
+ } else {
648
+ newObject[property] = value;
649
+ }
650
+ }
651
+ }
652
+ return newObject;
653
+ }
654
+
655
+ /**
656
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
657
+ *
658
+ * @param {Object} object - The object to look up the getter function in its prototype chain.
659
+ * @param {String} prop - The property name for which to find the getter function.
660
+ * @returns {Function} The getter function found in the prototype chain or a fallback function.
661
+ */
662
+ function lookupGetter(object, prop) {
663
+ while (object !== null) {
664
+ const desc = getOwnPropertyDescriptor(object, prop);
665
+ if (desc) {
666
+ if (desc.get) {
667
+ return unapply(desc.get);
668
+ }
669
+ if (typeof desc.value === 'function') {
670
+ return unapply(desc.value);
671
+ }
672
+ }
673
+ object = getPrototypeOf(object);
674
+ }
675
+ function fallbackValue(element) {
676
+ console.warn('fallback value for', element);
677
+ return null;
678
+ }
679
+ return fallbackValue;
680
+ }
681
+
682
+ 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', 'section', 'select', 'shadow', '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']);
683
+
684
+ // SVG
685
+ const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
686
+ 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']);
687
+
688
+ // List of SVG elements that are disallowed by default.
689
+ // We still need to know them so that we can do namespace
690
+ // checks properly in case one wants to add them to
691
+ // allow-list.
692
+ 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']);
693
+ 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']);
694
+
695
+ // Similarly to SVG, we want to know all MathML elements,
696
+ // even those that we disallow by default.
697
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
698
+ const text = freeze(['#text']);
699
+
700
+ 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', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', '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', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
701
+ const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', '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', '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', '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', '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', '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', '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']);
702
+ const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', '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']);
703
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
704
+
705
+ // eslint-disable-next-line unicorn/better-regex
706
+ const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
707
+ const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
708
+ const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
709
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
710
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
711
+ const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
712
+ );
713
+
714
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
715
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
716
+ );
717
+
718
+ const DOCTYPE_NAME = seal(/^html$/i);
719
+
720
+ var EXPRESSIONS = /*#__PURE__*/Object.freeze({
721
+ __proto__: null,
722
+ MUSTACHE_EXPR: MUSTACHE_EXPR,
723
+ ERB_EXPR: ERB_EXPR,
724
+ TMPLIT_EXPR: TMPLIT_EXPR,
725
+ DATA_ATTR: DATA_ATTR,
726
+ ARIA_ATTR: ARIA_ATTR,
727
+ IS_ALLOWED_URI: IS_ALLOWED_URI,
728
+ IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
729
+ ATTR_WHITESPACE: ATTR_WHITESPACE,
730
+ DOCTYPE_NAME: DOCTYPE_NAME
731
+ });
732
+
733
+ const getGlobal = function getGlobal() {
734
+ return typeof window === 'undefined' ? null : window;
735
+ };
736
+
737
+ /**
738
+ * Creates a no-op policy for internal use only.
739
+ * Don't export this function outside this module!
740
+ * @param {TrustedTypePolicyFactory} trustedTypes The policy factory.
741
+ * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
742
+ * @return {TrustedTypePolicy} The policy created (or null, if Trusted Types
743
+ * are not supported or creating the policy failed).
744
+ */
745
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
746
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
747
+ return null;
748
+ }
749
+
750
+ // Allow the callers to control the unique policy name
751
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
752
+ // Policy creation with duplicate names throws in Trusted Types.
753
+ let suffix = null;
754
+ const ATTR_NAME = 'data-tt-policy-suffix';
755
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
756
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
757
+ }
758
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
759
+ try {
760
+ return trustedTypes.createPolicy(policyName, {
761
+ createHTML(html) {
762
+ return html;
763
+ },
764
+ createScriptURL(scriptUrl) {
765
+ return scriptUrl;
766
+ }
767
+ });
768
+ } catch (_) {
769
+ // Policy creation failed (most likely another DOMPurify script has
770
+ // already run). Skip creating the policy, as this will only cause errors
771
+ // if TT are enforced.
772
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
773
+ return null;
774
+ }
775
+ };
776
+ function createDOMPurify() {
777
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
778
+ const DOMPurify = root => createDOMPurify(root);
779
+
780
+ /**
781
+ * Version label, exposed for easier checks
782
+ * if DOMPurify is up to date or not
783
+ */
784
+ DOMPurify.version = '3.0.8';
785
+
786
+ /**
787
+ * Array of elements that DOMPurify removed during sanitation.
788
+ * Empty if nothing was removed.
789
+ */
790
+ DOMPurify.removed = [];
791
+ if (!window || !window.document || window.document.nodeType !== 9) {
792
+ // Not running in a browser, provide a factory function
793
+ // so that you can pass your own Window
794
+ DOMPurify.isSupported = false;
795
+ return DOMPurify;
796
+ }
797
+ let {
798
+ document
799
+ } = window;
800
+ const originalDocument = document;
801
+ const currentScript = originalDocument.currentScript;
802
+ const {
803
+ DocumentFragment,
804
+ HTMLTemplateElement,
805
+ Node,
806
+ Element,
807
+ NodeFilter,
808
+ NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
809
+ HTMLFormElement,
810
+ DOMParser,
811
+ trustedTypes
812
+ } = window;
813
+ const ElementPrototype = Element.prototype;
814
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
815
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
816
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
817
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
818
+
819
+ // As per issue #47, the web-components registry is inherited by a
820
+ // new document created via createHTMLDocument. As per the spec
821
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
822
+ // a new empty registry is used when creating a template contents owner
823
+ // document, so we use that as our parent document to ensure nothing
824
+ // is inherited.
825
+ if (typeof HTMLTemplateElement === 'function') {
826
+ const template = document.createElement('template');
827
+ if (template.content && template.content.ownerDocument) {
828
+ document = template.content.ownerDocument;
829
+ }
830
+ }
831
+ let trustedTypesPolicy;
832
+ let emptyHTML = '';
833
+ const {
834
+ implementation,
835
+ createNodeIterator,
836
+ createDocumentFragment,
837
+ getElementsByTagName
838
+ } = document;
839
+ const {
840
+ importNode
841
+ } = originalDocument;
842
+ let hooks = {};
843
+
844
+ /**
845
+ * Expose whether this browser supports running the full DOMPurify.
846
+ */
847
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
848
+ const {
849
+ MUSTACHE_EXPR,
850
+ ERB_EXPR,
851
+ TMPLIT_EXPR,
852
+ DATA_ATTR,
853
+ ARIA_ATTR,
854
+ IS_SCRIPT_OR_DATA,
855
+ ATTR_WHITESPACE
856
+ } = EXPRESSIONS;
857
+ let {
858
+ IS_ALLOWED_URI: IS_ALLOWED_URI$1
859
+ } = EXPRESSIONS;
860
+
861
+ /**
862
+ * We consider the elements and attributes below to be safe. Ideally
863
+ * don't add any new ones but feel free to remove unwanted ones.
864
+ */
865
+
866
+ /* allowed element names */
867
+ let ALLOWED_TAGS = null;
868
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
869
+
870
+ /* Allowed attribute names */
871
+ let ALLOWED_ATTR = null;
872
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
873
+
874
+ /*
875
+ * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
876
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
877
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
878
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
879
+ */
880
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
881
+ tagNameCheck: {
882
+ writable: true,
883
+ configurable: false,
884
+ enumerable: true,
885
+ value: null
886
+ },
887
+ attributeNameCheck: {
888
+ writable: true,
889
+ configurable: false,
890
+ enumerable: true,
891
+ value: null
892
+ },
893
+ allowCustomizedBuiltInElements: {
894
+ writable: true,
895
+ configurable: false,
896
+ enumerable: true,
897
+ value: false
898
+ }
899
+ }));
900
+
901
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
902
+ let FORBID_TAGS = null;
903
+
904
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
905
+ let FORBID_ATTR = null;
906
+
907
+ /* Decide if ARIA attributes are okay */
908
+ let ALLOW_ARIA_ATTR = true;
909
+
910
+ /* Decide if custom data attributes are okay */
911
+ let ALLOW_DATA_ATTR = true;
912
+
913
+ /* Decide if unknown protocols are okay */
914
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
915
+
916
+ /* Decide if self-closing tags in attributes are allowed.
917
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
918
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
919
+
920
+ /* Output should be safe for common template engines.
921
+ * This means, DOMPurify removes data attributes, mustaches and ERB
922
+ */
923
+ let SAFE_FOR_TEMPLATES = false;
924
+
925
+ /* Decide if document with <html>... should be returned */
926
+ let WHOLE_DOCUMENT = false;
927
+
928
+ /* Track whether config is already set on this instance of DOMPurify. */
929
+ let SET_CONFIG = false;
930
+
931
+ /* Decide if all elements (e.g. style, script) must be children of
932
+ * document.body. By default, browsers might move them to document.head */
933
+ let FORCE_BODY = false;
934
+
935
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
936
+ * string (or a TrustedHTML object if Trusted Types are supported).
937
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
938
+ */
939
+ let RETURN_DOM = false;
940
+
941
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
942
+ * string (or a TrustedHTML object if Trusted Types are supported) */
943
+ let RETURN_DOM_FRAGMENT = false;
944
+
945
+ /* Try to return a Trusted Type object instead of a string, return a string in
946
+ * case Trusted Types are not supported */
947
+ let RETURN_TRUSTED_TYPE = false;
948
+
949
+ /* Output should be free from DOM clobbering attacks?
950
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
951
+ */
952
+ let SANITIZE_DOM = true;
953
+
954
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
955
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
956
+ *
957
+ * HTML/DOM spec rules that enable DOM Clobbering:
958
+ * - Named Access on Window (§7.3.3)
959
+ * - DOM Tree Accessors (§3.1.5)
960
+ * - Form Element Parent-Child Relations (§4.10.3)
961
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
962
+ * - HTMLCollection (§4.2.10.2)
963
+ *
964
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
965
+ * with a constant string, i.e., `user-content-`
966
+ */
967
+ let SANITIZE_NAMED_PROPS = false;
968
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
969
+
970
+ /* Keep element content when removing element? */
971
+ let KEEP_CONTENT = true;
972
+
973
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
974
+ * of importing it into a new Document and returning a sanitized copy */
975
+ let IN_PLACE = false;
976
+
977
+ /* Allow usage of profiles like html, svg and mathMl */
978
+ let USE_PROFILES = {};
979
+
980
+ /* Tags to ignore content of when KEEP_CONTENT is true */
981
+ let FORBID_CONTENTS = null;
982
+ 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']);
983
+
984
+ /* Tags that are safe for data: URIs */
985
+ let DATA_URI_TAGS = null;
986
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
987
+
988
+ /* Attributes safe for values like "javascript:" */
989
+ let URI_SAFE_ATTRIBUTES = null;
990
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
991
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
992
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
993
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
994
+ /* Document namespace */
995
+ let NAMESPACE = HTML_NAMESPACE;
996
+ let IS_EMPTY_INPUT = false;
997
+
998
+ /* Allowed XHTML+XML namespaces */
999
+ let ALLOWED_NAMESPACES = null;
1000
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
1001
+
1002
+ /* Parsing of strict XHTML documents */
1003
+ let PARSER_MEDIA_TYPE = null;
1004
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
1005
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
1006
+ let transformCaseFunc = null;
1007
+
1008
+ /* Keep a reference to config to pass to hooks */
1009
+ let CONFIG = null;
1010
+
1011
+ /* Ideally, do not touch anything below this line */
1012
+ /* ______________________________________________ */
1013
+
1014
+ const formElement = document.createElement('form');
1015
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
1016
+ return testValue instanceof RegExp || testValue instanceof Function;
1017
+ };
1018
+
1019
+ /**
1020
+ * _parseConfig
1021
+ *
1022
+ * @param {Object} cfg optional config literal
1023
+ */
1024
+ // eslint-disable-next-line complexity
1025
+ const _parseConfig = function _parseConfig() {
1026
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1027
+ if (CONFIG && CONFIG === cfg) {
1028
+ return;
1029
+ }
1030
+
1031
+ /* Shield configuration object from tampering */
1032
+ if (!cfg || typeof cfg !== 'object') {
1033
+ cfg = {};
1034
+ }
1035
+
1036
+ /* Shield configuration object from prototype pollution */
1037
+ cfg = clone(cfg);
1038
+ PARSER_MEDIA_TYPE =
1039
+ // eslint-disable-next-line unicorn/prefer-includes
1040
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
1041
+
1042
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
1043
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
1044
+
1045
+ /* Set configuration parameters */
1046
+ ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
1047
+ ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
1048
+ ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES' in cfg ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
1049
+ URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES),
1050
+ // eslint-disable-line indent
1051
+ cfg.ADD_URI_SAFE_ATTR,
1052
+ // eslint-disable-line indent
1053
+ transformCaseFunc // eslint-disable-line indent
1054
+ ) // eslint-disable-line indent
1055
+ : DEFAULT_URI_SAFE_ATTRIBUTES;
1056
+ DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS),
1057
+ // eslint-disable-line indent
1058
+ cfg.ADD_DATA_URI_TAGS,
1059
+ // eslint-disable-line indent
1060
+ transformCaseFunc // eslint-disable-line indent
1061
+ ) // eslint-disable-line indent
1062
+ : DEFAULT_DATA_URI_TAGS;
1063
+ FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
1064
+ FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
1065
+ FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
1066
+ USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
1067
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
1068
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
1069
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
1070
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
1071
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
1072
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
1073
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
1074
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
1075
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
1076
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
1077
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
1078
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
1079
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
1080
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
1081
+ IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
1082
+ NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
1083
+ CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
1084
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
1085
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
1086
+ }
1087
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
1088
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
1089
+ }
1090
+ if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
1091
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
1092
+ }
1093
+ if (SAFE_FOR_TEMPLATES) {
1094
+ ALLOW_DATA_ATTR = false;
1095
+ }
1096
+ if (RETURN_DOM_FRAGMENT) {
1097
+ RETURN_DOM = true;
1098
+ }
1099
+
1100
+ /* Parse profile info */
1101
+ if (USE_PROFILES) {
1102
+ ALLOWED_TAGS = addToSet({}, text);
1103
+ ALLOWED_ATTR = [];
1104
+ if (USE_PROFILES.html === true) {
1105
+ addToSet(ALLOWED_TAGS, html$1);
1106
+ addToSet(ALLOWED_ATTR, html);
1107
+ }
1108
+ if (USE_PROFILES.svg === true) {
1109
+ addToSet(ALLOWED_TAGS, svg$1);
1110
+ addToSet(ALLOWED_ATTR, svg);
1111
+ addToSet(ALLOWED_ATTR, xml);
1112
+ }
1113
+ if (USE_PROFILES.svgFilters === true) {
1114
+ addToSet(ALLOWED_TAGS, svgFilters);
1115
+ addToSet(ALLOWED_ATTR, svg);
1116
+ addToSet(ALLOWED_ATTR, xml);
1117
+ }
1118
+ if (USE_PROFILES.mathMl === true) {
1119
+ addToSet(ALLOWED_TAGS, mathMl$1);
1120
+ addToSet(ALLOWED_ATTR, mathMl);
1121
+ addToSet(ALLOWED_ATTR, xml);
1122
+ }
1123
+ }
1124
+
1125
+ /* Merge configuration parameters */
1126
+ if (cfg.ADD_TAGS) {
1127
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
1128
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
1129
+ }
1130
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
1131
+ }
1132
+ if (cfg.ADD_ATTR) {
1133
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
1134
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
1135
+ }
1136
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
1137
+ }
1138
+ if (cfg.ADD_URI_SAFE_ATTR) {
1139
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
1140
+ }
1141
+ if (cfg.FORBID_CONTENTS) {
1142
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
1143
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
1144
+ }
1145
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
1146
+ }
1147
+
1148
+ /* Add #text in case KEEP_CONTENT is set to true */
1149
+ if (KEEP_CONTENT) {
1150
+ ALLOWED_TAGS['#text'] = true;
1151
+ }
1152
+
1153
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
1154
+ if (WHOLE_DOCUMENT) {
1155
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
1156
+ }
1157
+
1158
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
1159
+ if (ALLOWED_TAGS.table) {
1160
+ addToSet(ALLOWED_TAGS, ['tbody']);
1161
+ delete FORBID_TAGS.tbody;
1162
+ }
1163
+ if (cfg.TRUSTED_TYPES_POLICY) {
1164
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
1165
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
1166
+ }
1167
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
1168
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
1169
+ }
1170
+
1171
+ // Overwrite existing TrustedTypes policy.
1172
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
1173
+
1174
+ // Sign local variables required by `sanitize`.
1175
+ emptyHTML = trustedTypesPolicy.createHTML('');
1176
+ } else {
1177
+ // Uninitialized policy, attempt to initialize the internal dompurify policy.
1178
+ if (trustedTypesPolicy === undefined) {
1179
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
1180
+ }
1181
+
1182
+ // If creating the internal policy succeeded sign internal variables.
1183
+ if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
1184
+ emptyHTML = trustedTypesPolicy.createHTML('');
1185
+ }
1186
+ }
1187
+
1188
+ // Prevent further manipulation of configuration.
1189
+ // Not available in IE8, Safari 5, etc.
1190
+ if (freeze) {
1191
+ freeze(cfg);
1192
+ }
1193
+ CONFIG = cfg;
1194
+ };
1195
+ const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
1196
+ const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']);
1197
+
1198
+ // Certain elements are allowed in both SVG and HTML
1199
+ // namespace. We need to specify them explicitly
1200
+ // so that they don't get erroneously deleted from
1201
+ // HTML namespace.
1202
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
1203
+
1204
+ /* Keep track of all possible SVG and MathML tags
1205
+ * so that we can perform the namespace checks
1206
+ * correctly. */
1207
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
1208
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
1209
+
1210
+ /**
1211
+ * @param {Element} element a DOM element whose namespace is being checked
1212
+ * @returns {boolean} Return false if the element has a
1213
+ * namespace that a spec-compliant parser would never
1214
+ * return. Return true otherwise.
1215
+ */
1216
+ const _checkValidNamespace = function _checkValidNamespace(element) {
1217
+ let parent = getParentNode(element);
1218
+
1219
+ // In JSDOM, if we're inside shadow DOM, then parentNode
1220
+ // can be null. We just simulate parent in this case.
1221
+ if (!parent || !parent.tagName) {
1222
+ parent = {
1223
+ namespaceURI: NAMESPACE,
1224
+ tagName: 'template'
1225
+ };
1226
+ }
1227
+ const tagName = stringToLowerCase(element.tagName);
1228
+ const parentTagName = stringToLowerCase(parent.tagName);
1229
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
1230
+ return false;
1231
+ }
1232
+ if (element.namespaceURI === SVG_NAMESPACE) {
1233
+ // The only way to switch from HTML namespace to SVG
1234
+ // is via <svg>. If it happens via any other tag, then
1235
+ // it should be killed.
1236
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1237
+ return tagName === 'svg';
1238
+ }
1239
+
1240
+ // The only way to switch from MathML to SVG is via`
1241
+ // svg if parent is either <annotation-xml> or MathML
1242
+ // text integration points.
1243
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
1244
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
1245
+ }
1246
+
1247
+ // We only allow elements that are defined in SVG
1248
+ // spec. All others are disallowed in SVG namespace.
1249
+ return Boolean(ALL_SVG_TAGS[tagName]);
1250
+ }
1251
+ if (element.namespaceURI === MATHML_NAMESPACE) {
1252
+ // The only way to switch from HTML namespace to MathML
1253
+ // is via <math>. If it happens via any other tag, then
1254
+ // it should be killed.
1255
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1256
+ return tagName === 'math';
1257
+ }
1258
+
1259
+ // The only way to switch from SVG to MathML is via
1260
+ // <math> and HTML integration points
1261
+ if (parent.namespaceURI === SVG_NAMESPACE) {
1262
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
1263
+ }
1264
+
1265
+ // We only allow elements that are defined in MathML
1266
+ // spec. All others are disallowed in MathML namespace.
1267
+ return Boolean(ALL_MATHML_TAGS[tagName]);
1268
+ }
1269
+ if (element.namespaceURI === HTML_NAMESPACE) {
1270
+ // The only way to switch from SVG to HTML is via
1271
+ // HTML integration points, and from MathML to HTML
1272
+ // is via MathML text integration points
1273
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
1274
+ return false;
1275
+ }
1276
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
1277
+ return false;
1278
+ }
1279
+
1280
+ // We disallow tags that are specific for MathML
1281
+ // or SVG and should never appear in HTML namespace
1282
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
1283
+ }
1284
+
1285
+ // For XHTML and XML documents that support custom namespaces
1286
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
1287
+ return true;
1288
+ }
1289
+
1290
+ // The code should never reach this place (this means
1291
+ // that the element somehow got namespace that is not
1292
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
1293
+ // Return false just in case.
1294
+ return false;
1295
+ };
1296
+
1297
+ /**
1298
+ * _forceRemove
1299
+ *
1300
+ * @param {Node} node a DOM node
1301
+ */
1302
+ const _forceRemove = function _forceRemove(node) {
1303
+ arrayPush(DOMPurify.removed, {
1304
+ element: node
1305
+ });
1306
+ try {
1307
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
1308
+ node.parentNode.removeChild(node);
1309
+ } catch (_) {
1310
+ node.remove();
1311
+ }
1312
+ };
1313
+
1314
+ /**
1315
+ * _removeAttribute
1316
+ *
1317
+ * @param {String} name an Attribute name
1318
+ * @param {Node} node a DOM node
1319
+ */
1320
+ const _removeAttribute = function _removeAttribute(name, node) {
1321
+ try {
1322
+ arrayPush(DOMPurify.removed, {
1323
+ attribute: node.getAttributeNode(name),
1324
+ from: node
1325
+ });
1326
+ } catch (_) {
1327
+ arrayPush(DOMPurify.removed, {
1328
+ attribute: null,
1329
+ from: node
1330
+ });
1331
+ }
1332
+ node.removeAttribute(name);
1333
+
1334
+ // We void attribute values for unremovable "is"" attributes
1335
+ if (name === 'is' && !ALLOWED_ATTR[name]) {
1336
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
1337
+ try {
1338
+ _forceRemove(node);
1339
+ } catch (_) {}
1340
+ } else {
1341
+ try {
1342
+ node.setAttribute(name, '');
1343
+ } catch (_) {}
1344
+ }
1345
+ }
1346
+ };
1347
+
1348
+ /**
1349
+ * _initDocument
1350
+ *
1351
+ * @param {String} dirty a string of dirty markup
1352
+ * @return {Document} a DOM, filled with the dirty markup
1353
+ */
1354
+ const _initDocument = function _initDocument(dirty) {
1355
+ /* Create a HTML document */
1356
+ let doc = null;
1357
+ let leadingWhitespace = null;
1358
+ if (FORCE_BODY) {
1359
+ dirty = '<remove></remove>' + dirty;
1360
+ } else {
1361
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
1362
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
1363
+ leadingWhitespace = matches && matches[0];
1364
+ }
1365
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
1366
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
1367
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
1368
+ }
1369
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
1370
+ /*
1371
+ * Use the DOMParser API by default, fallback later if needs be
1372
+ * DOMParser not work for svg when has multiple root element.
1373
+ */
1374
+ if (NAMESPACE === HTML_NAMESPACE) {
1375
+ try {
1376
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
1377
+ } catch (_) {}
1378
+ }
1379
+
1380
+ /* Use createHTMLDocument in case DOMParser is not available */
1381
+ if (!doc || !doc.documentElement) {
1382
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
1383
+ try {
1384
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
1385
+ } catch (_) {
1386
+ // Syntax error if dirtyPayload is invalid xml
1387
+ }
1388
+ }
1389
+ const body = doc.body || doc.documentElement;
1390
+ if (dirty && leadingWhitespace) {
1391
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
1392
+ }
1393
+
1394
+ /* Work on whole document or just its body */
1395
+ if (NAMESPACE === HTML_NAMESPACE) {
1396
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
1397
+ }
1398
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
1399
+ };
1400
+
1401
+ /**
1402
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
1403
+ *
1404
+ * @param {Node} root The root element or node to start traversing on.
1405
+ * @return {NodeIterator} The created NodeIterator
1406
+ */
1407
+ const _createNodeIterator = function _createNodeIterator(root) {
1408
+ return createNodeIterator.call(root.ownerDocument || root, root,
1409
+ // eslint-disable-next-line no-bitwise
1410
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null);
1411
+ };
1412
+
1413
+ /**
1414
+ * _isClobbered
1415
+ *
1416
+ * @param {Node} elm element to check for clobbering attacks
1417
+ * @return {Boolean} true if clobbered, false if safe
1418
+ */
1419
+ const _isClobbered = function _isClobbered(elm) {
1420
+ return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
1421
+ };
1422
+
1423
+ /**
1424
+ * Checks whether the given object is a DOM node.
1425
+ *
1426
+ * @param {Node} object object to check whether it's a DOM node
1427
+ * @return {Boolean} true is object is a DOM node
1428
+ */
1429
+ const _isNode = function _isNode(object) {
1430
+ return typeof Node === 'function' && object instanceof Node;
1431
+ };
1432
+
1433
+ /**
1434
+ * _executeHook
1435
+ * Execute user configurable hooks
1436
+ *
1437
+ * @param {String} entryPoint Name of the hook's entry point
1438
+ * @param {Node} currentNode node to work on with the hook
1439
+ * @param {Object} data additional hook parameters
1440
+ */
1441
+ const _executeHook = function _executeHook(entryPoint, currentNode, data) {
1442
+ if (!hooks[entryPoint]) {
1443
+ return;
1444
+ }
1445
+ arrayForEach(hooks[entryPoint], hook => {
1446
+ hook.call(DOMPurify, currentNode, data, CONFIG);
1447
+ });
1448
+ };
1449
+
1450
+ /**
1451
+ * _sanitizeElements
1452
+ *
1453
+ * @protect nodeName
1454
+ * @protect textContent
1455
+ * @protect removeChild
1456
+ *
1457
+ * @param {Node} currentNode to check for permission to exist
1458
+ * @return {Boolean} true if node was killed, false if left alive
1459
+ */
1460
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
1461
+ let content = null;
1462
+
1463
+ /* Execute a hook if present */
1464
+ _executeHook('beforeSanitizeElements', currentNode, null);
1465
+
1466
+ /* Check if element is clobbered or can clobber */
1467
+ if (_isClobbered(currentNode)) {
1468
+ _forceRemove(currentNode);
1469
+ return true;
1470
+ }
1471
+
1472
+ /* Now let's check the element's type and name */
1473
+ const tagName = transformCaseFunc(currentNode.nodeName);
1474
+
1475
+ /* Execute a hook if present */
1476
+ _executeHook('uponSanitizeElement', currentNode, {
1477
+ tagName,
1478
+ allowedTags: ALLOWED_TAGS
1479
+ });
1480
+
1481
+ /* Detect mXSS attempts abusing namespace confusion */
1482
+ if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
1483
+ _forceRemove(currentNode);
1484
+ return true;
1485
+ }
1486
+
1487
+ /* Remove element if anything forbids its presence */
1488
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1489
+ /* Check if we have a custom element to handle */
1490
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
1491
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
1492
+ return false;
1493
+ }
1494
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
1495
+ return false;
1496
+ }
1497
+ }
1498
+
1499
+ /* Keep content except for bad-listed elements */
1500
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1501
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
1502
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
1503
+ if (childNodes && parentNode) {
1504
+ const childCount = childNodes.length;
1505
+ for (let i = childCount - 1; i >= 0; --i) {
1506
+ parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
1507
+ }
1508
+ }
1509
+ }
1510
+ _forceRemove(currentNode);
1511
+ return true;
1512
+ }
1513
+
1514
+ /* Check whether element has a valid namespace */
1515
+ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
1516
+ _forceRemove(currentNode);
1517
+ return true;
1518
+ }
1519
+
1520
+ /* Make sure that older browsers don't get fallback-tag mXSS */
1521
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
1522
+ _forceRemove(currentNode);
1523
+ return true;
1524
+ }
1525
+
1526
+ /* Sanitize element content to be template-safe */
1527
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
1528
+ /* Get the element's text content */
1529
+ content = currentNode.textContent;
1530
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
1531
+ content = stringReplace(content, expr, ' ');
1532
+ });
1533
+ if (currentNode.textContent !== content) {
1534
+ arrayPush(DOMPurify.removed, {
1535
+ element: currentNode.cloneNode()
1536
+ });
1537
+ currentNode.textContent = content;
1538
+ }
1539
+ }
1540
+
1541
+ /* Execute a hook if present */
1542
+ _executeHook('afterSanitizeElements', currentNode, null);
1543
+ return false;
1544
+ };
1545
+
1546
+ /**
1547
+ * _isValidAttribute
1548
+ *
1549
+ * @param {string} lcTag Lowercase tag name of containing element.
1550
+ * @param {string} lcName Lowercase attribute name.
1551
+ * @param {string} value Attribute value.
1552
+ * @return {Boolean} Returns true if `value` is valid, otherwise false.
1553
+ */
1554
+ // eslint-disable-next-line complexity
1555
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1556
+ /* Make sure attribute cannot clobber */
1557
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1558
+ return false;
1559
+ }
1560
+
1561
+ /* Allow valid data-* attributes: At least one character after "-"
1562
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
1563
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
1564
+ We don't need to check the value; it's always URI safe. */
1565
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
1566
+ if (
1567
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1568
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1569
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1570
+ _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)) ||
1571
+ // Alternative, second condition checks if it's an `is`-attribute, AND
1572
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1573
+ 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 {
1574
+ return false;
1575
+ }
1576
+ /* Check value is safe. First, is attr inert? If so, is safe */
1577
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; 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, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {
1578
+ return false;
1579
+ } else ;
1580
+ return true;
1581
+ };
1582
+
1583
+ /**
1584
+ * _isBasicCustomElement
1585
+ * checks if at least one dash is included in tagName, and it's not the first char
1586
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
1587
+ *
1588
+ * @param {string} tagName name of the tag of the node to sanitize
1589
+ * @returns {boolean} Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
1590
+ */
1591
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
1592
+ return tagName.indexOf('-') > 0;
1593
+ };
1594
+
1595
+ /**
1596
+ * _sanitizeAttributes
1597
+ *
1598
+ * @protect attributes
1599
+ * @protect nodeName
1600
+ * @protect removeAttribute
1601
+ * @protect setAttribute
1602
+ *
1603
+ * @param {Node} currentNode to sanitize
1604
+ */
1605
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
1606
+ /* Execute a hook if present */
1607
+ _executeHook('beforeSanitizeAttributes', currentNode, null);
1608
+ const {
1609
+ attributes
1610
+ } = currentNode;
1611
+
1612
+ /* Check if we have attributes; if not we might have a text node */
1613
+ if (!attributes) {
1614
+ return;
1615
+ }
1616
+ const hookEvent = {
1617
+ attrName: '',
1618
+ attrValue: '',
1619
+ keepAttr: true,
1620
+ allowedAttributes: ALLOWED_ATTR
1621
+ };
1622
+ let l = attributes.length;
1623
+
1624
+ /* Go backwards over all attributes; safely remove bad ones */
1625
+ while (l--) {
1626
+ const attr = attributes[l];
1627
+ const {
1628
+ name,
1629
+ namespaceURI,
1630
+ value: attrValue
1631
+ } = attr;
1632
+ const lcName = transformCaseFunc(name);
1633
+ let value = name === 'value' ? attrValue : stringTrim(attrValue);
1634
+
1635
+ /* Execute a hook if present */
1636
+ hookEvent.attrName = lcName;
1637
+ hookEvent.attrValue = value;
1638
+ hookEvent.keepAttr = true;
1639
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1640
+ _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
1641
+ value = hookEvent.attrValue;
1642
+ /* Did the hooks approve of the attribute? */
1643
+ if (hookEvent.forceKeepAttr) {
1644
+ continue;
1645
+ }
1646
+
1647
+ /* Remove attribute */
1648
+ _removeAttribute(name, currentNode);
1649
+
1650
+ /* Did the hooks approve of the attribute? */
1651
+ if (!hookEvent.keepAttr) {
1652
+ continue;
1653
+ }
1654
+
1655
+ /* Work around a security issue in jQuery 3.0 */
1656
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
1657
+ _removeAttribute(name, currentNode);
1658
+ continue;
1659
+ }
1660
+
1661
+ /* Sanitize attribute content to be template-safe */
1662
+ if (SAFE_FOR_TEMPLATES) {
1663
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
1664
+ value = stringReplace(value, expr, ' ');
1665
+ });
1666
+ }
1667
+
1668
+ /* Is `value` valid for this attribute? */
1669
+ const lcTag = transformCaseFunc(currentNode.nodeName);
1670
+ if (!_isValidAttribute(lcTag, lcName, value)) {
1671
+ continue;
1672
+ }
1673
+
1674
+ /* Full DOM Clobbering protection via namespace isolation,
1675
+ * Prefix id and name attributes with `user-content-`
1676
+ */
1677
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
1678
+ // Remove the attribute with this value
1679
+ _removeAttribute(name, currentNode);
1680
+
1681
+ // Prefix the value and later re-create the attribute with the sanitized value
1682
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
1683
+ }
1684
+
1685
+ /* Handle attributes that require Trusted Types */
1686
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
1687
+ if (namespaceURI) ; else {
1688
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
1689
+ case 'TrustedHTML':
1690
+ {
1691
+ value = trustedTypesPolicy.createHTML(value);
1692
+ break;
1693
+ }
1694
+ case 'TrustedScriptURL':
1695
+ {
1696
+ value = trustedTypesPolicy.createScriptURL(value);
1697
+ break;
1698
+ }
1699
+ }
1700
+ }
1701
+ }
1702
+
1703
+ /* Handle invalid data-* attribute set by try-catching it */
1704
+ try {
1705
+ if (namespaceURI) {
1706
+ currentNode.setAttributeNS(namespaceURI, name, value);
1707
+ } else {
1708
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1709
+ currentNode.setAttribute(name, value);
1710
+ }
1711
+ arrayPop(DOMPurify.removed);
1712
+ } catch (_) {}
1713
+ }
1714
+
1715
+ /* Execute a hook if present */
1716
+ _executeHook('afterSanitizeAttributes', currentNode, null);
1717
+ };
1718
+
1719
+ /**
1720
+ * _sanitizeShadowDOM
1721
+ *
1722
+ * @param {DocumentFragment} fragment to iterate over recursively
1723
+ */
1724
+ const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
1725
+ let shadowNode = null;
1726
+ const shadowIterator = _createNodeIterator(fragment);
1727
+
1728
+ /* Execute a hook if present */
1729
+ _executeHook('beforeSanitizeShadowDOM', fragment, null);
1730
+ while (shadowNode = shadowIterator.nextNode()) {
1731
+ /* Execute a hook if present */
1732
+ _executeHook('uponSanitizeShadowNode', shadowNode, null);
1733
+
1734
+ /* Sanitize tags and elements */
1735
+ if (_sanitizeElements(shadowNode)) {
1736
+ continue;
1737
+ }
1738
+
1739
+ /* Deep shadow DOM detected */
1740
+ if (shadowNode.content instanceof DocumentFragment) {
1741
+ _sanitizeShadowDOM(shadowNode.content);
1742
+ }
1743
+
1744
+ /* Check attributes, sanitize if necessary */
1745
+ _sanitizeAttributes(shadowNode);
1746
+ }
1747
+
1748
+ /* Execute a hook if present */
1749
+ _executeHook('afterSanitizeShadowDOM', fragment, null);
1750
+ };
1751
+
1752
+ /**
1753
+ * Sanitize
1754
+ * Public method providing core sanitation functionality
1755
+ *
1756
+ * @param {String|Node} dirty string or DOM node
1757
+ * @param {Object} cfg object
1758
+ */
1759
+ // eslint-disable-next-line complexity
1760
+ DOMPurify.sanitize = function (dirty) {
1761
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1762
+ let body = null;
1763
+ let importedNode = null;
1764
+ let currentNode = null;
1765
+ let returnNode = null;
1766
+ /* Make sure we have a string to sanitize.
1767
+ DO NOT return early, as this will return the wrong type if
1768
+ the user has requested a DOM object rather than a string */
1769
+ IS_EMPTY_INPUT = !dirty;
1770
+ if (IS_EMPTY_INPUT) {
1771
+ dirty = '<!-->';
1772
+ }
1773
+
1774
+ /* Stringify, in case dirty is an object */
1775
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
1776
+ if (typeof dirty.toString === 'function') {
1777
+ dirty = dirty.toString();
1778
+ if (typeof dirty !== 'string') {
1779
+ throw typeErrorCreate('dirty is not a string, aborting');
1780
+ }
1781
+ } else {
1782
+ throw typeErrorCreate('toString is not a function');
1783
+ }
1784
+ }
1785
+
1786
+ /* Return dirty HTML if DOMPurify cannot run */
1787
+ if (!DOMPurify.isSupported) {
1788
+ return dirty;
1789
+ }
1790
+
1791
+ /* Assign config vars */
1792
+ if (!SET_CONFIG) {
1793
+ _parseConfig(cfg);
1794
+ }
1795
+
1796
+ /* Clean up removed elements */
1797
+ DOMPurify.removed = [];
1798
+
1799
+ /* Check if dirty is correctly typed for IN_PLACE */
1800
+ if (typeof dirty === 'string') {
1801
+ IN_PLACE = false;
1802
+ }
1803
+ if (IN_PLACE) {
1804
+ /* Do some early pre-sanitization to avoid unsafe root nodes */
1805
+ if (dirty.nodeName) {
1806
+ const tagName = transformCaseFunc(dirty.nodeName);
1807
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1808
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
1809
+ }
1810
+ }
1811
+ } else if (dirty instanceof Node) {
1812
+ /* If dirty is a DOM element, append to an empty document to avoid
1813
+ elements being stripped by the parser */
1814
+ body = _initDocument('<!---->');
1815
+ importedNode = body.ownerDocument.importNode(dirty, true);
1816
+ if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
1817
+ /* Node is already a body, use as is */
1818
+ body = importedNode;
1819
+ } else if (importedNode.nodeName === 'HTML') {
1820
+ body = importedNode;
1821
+ } else {
1822
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1823
+ body.appendChild(importedNode);
1824
+ }
1825
+ } else {
1826
+ /* Exit directly if we have nothing to do */
1827
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
1828
+ // eslint-disable-next-line unicorn/prefer-includes
1829
+ dirty.indexOf('<') === -1) {
1830
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
1831
+ }
1832
+
1833
+ /* Initialize the document to work on */
1834
+ body = _initDocument(dirty);
1835
+
1836
+ /* Check we have a DOM node from the data */
1837
+ if (!body) {
1838
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
1839
+ }
1840
+ }
1841
+
1842
+ /* Remove first element node (ours) if FORCE_BODY is set */
1843
+ if (body && FORCE_BODY) {
1844
+ _forceRemove(body.firstChild);
1845
+ }
1846
+
1847
+ /* Get node iterator */
1848
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
1849
+
1850
+ /* Now start iterating over the created document */
1851
+ while (currentNode = nodeIterator.nextNode()) {
1852
+ /* Sanitize tags and elements */
1853
+ if (_sanitizeElements(currentNode)) {
1854
+ continue;
1855
+ }
1856
+
1857
+ /* Shadow DOM detected, sanitize it */
1858
+ if (currentNode.content instanceof DocumentFragment) {
1859
+ _sanitizeShadowDOM(currentNode.content);
1860
+ }
1861
+
1862
+ /* Check attributes, sanitize if necessary */
1863
+ _sanitizeAttributes(currentNode);
1864
+ }
1865
+
1866
+ /* If we sanitized `dirty` in-place, return it. */
1867
+ if (IN_PLACE) {
1868
+ return dirty;
1869
+ }
1870
+
1871
+ /* Return sanitized string or DOM */
1872
+ if (RETURN_DOM) {
1873
+ if (RETURN_DOM_FRAGMENT) {
1874
+ returnNode = createDocumentFragment.call(body.ownerDocument);
1875
+ while (body.firstChild) {
1876
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1877
+ returnNode.appendChild(body.firstChild);
1878
+ }
1879
+ } else {
1880
+ returnNode = body;
1881
+ }
1882
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
1883
+ /*
1884
+ AdoptNode() is not used because internal state is not reset
1885
+ (e.g. the past names map of a HTMLFormElement), this is safe
1886
+ in theory but we would rather not risk another attack vector.
1887
+ The state that is cloned by importNode() is explicitly defined
1888
+ by the specs.
1889
+ */
1890
+ returnNode = importNode.call(originalDocument, returnNode, true);
1891
+ }
1892
+ return returnNode;
1893
+ }
1894
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
1895
+
1896
+ /* Serialize doctype if allowed */
1897
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
1898
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
1899
+ }
1900
+
1901
+ /* Sanitize final string template-safe */
1902
+ if (SAFE_FOR_TEMPLATES) {
1903
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
1904
+ serializedHTML = stringReplace(serializedHTML, expr, ' ');
1905
+ });
1906
+ }
1907
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
1908
+ };
1909
+
1910
+ /**
1911
+ * Public method to set the configuration once
1912
+ * setConfig
1913
+ *
1914
+ * @param {Object} cfg configuration object
1915
+ */
1916
+ DOMPurify.setConfig = function () {
1917
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1918
+ _parseConfig(cfg);
1919
+ SET_CONFIG = true;
1920
+ };
1921
+
1922
+ /**
1923
+ * Public method to remove the configuration
1924
+ * clearConfig
1925
+ *
1926
+ */
1927
+ DOMPurify.clearConfig = function () {
1928
+ CONFIG = null;
1929
+ SET_CONFIG = false;
1930
+ };
1931
+
1932
+ /**
1933
+ * Public method to check if an attribute value is valid.
1934
+ * Uses last set config, if any. Otherwise, uses config defaults.
1935
+ * isValidAttribute
1936
+ *
1937
+ * @param {String} tag Tag name of containing element.
1938
+ * @param {String} attr Attribute name.
1939
+ * @param {String} value Attribute value.
1940
+ * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
1941
+ */
1942
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
1943
+ /* Initialize shared config vars if necessary. */
1944
+ if (!CONFIG) {
1945
+ _parseConfig({});
1946
+ }
1947
+ const lcTag = transformCaseFunc(tag);
1948
+ const lcName = transformCaseFunc(attr);
1949
+ return _isValidAttribute(lcTag, lcName, value);
1950
+ };
1951
+
1952
+ /**
1953
+ * AddHook
1954
+ * Public method to add DOMPurify hooks
1955
+ *
1956
+ * @param {String} entryPoint entry point for the hook to add
1957
+ * @param {Function} hookFunction function to execute
1958
+ */
1959
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
1960
+ if (typeof hookFunction !== 'function') {
1961
+ return;
1962
+ }
1963
+ hooks[entryPoint] = hooks[entryPoint] || [];
1964
+ arrayPush(hooks[entryPoint], hookFunction);
1965
+ };
1966
+
1967
+ /**
1968
+ * RemoveHook
1969
+ * Public method to remove a DOMPurify hook at a given entryPoint
1970
+ * (pops it from the stack of hooks if more are present)
1971
+ *
1972
+ * @param {String} entryPoint entry point for the hook to remove
1973
+ * @return {Function} removed(popped) hook
1974
+ */
1975
+ DOMPurify.removeHook = function (entryPoint) {
1976
+ if (hooks[entryPoint]) {
1977
+ return arrayPop(hooks[entryPoint]);
1978
+ }
1979
+ };
1980
+
1981
+ /**
1982
+ * RemoveHooks
1983
+ * Public method to remove all DOMPurify hooks at a given entryPoint
1984
+ *
1985
+ * @param {String} entryPoint entry point for the hooks to remove
1986
+ */
1987
+ DOMPurify.removeHooks = function (entryPoint) {
1988
+ if (hooks[entryPoint]) {
1989
+ hooks[entryPoint] = [];
1990
+ }
1991
+ };
1992
+
1993
+ /**
1994
+ * RemoveAllHooks
1995
+ * Public method to remove all DOMPurify hooks
1996
+ */
1997
+ DOMPurify.removeAllHooks = function () {
1998
+ hooks = {};
1999
+ };
2000
+ return DOMPurify;
2001
+ }
2002
+ var purify = createDOMPurify();
2003
+
2004
+ return purify;
2005
+
2006
+ }));
2007
+
2008
+ }(purify));
2009
+
2010
+ const DOMPurify = purify.exports;
2011
+
2012
+ const nylasViewEmailCss = ":host{display:inline-grid;overflow:hidden;width:100%}.view-email{width:100%}.view-email div.gmail_quote{display:none;color:var(--nylas-color-primary-400)}.view-email div.gmail_quote.show{display:block}.view-email blockquote{border-color:var(--nylas-color-primary-500) !important}.view-email .nylas-view-email-toggle-button{display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--nylas-color-primary-200);color:var(--nylas-color-primary-600);border:0;border-radius:2px;font-size:14px;font-weight:500;line-height:1.5;transition:all 0.2s ease-in-out}.view-email .nylas-view-email-toggle-button:hover{background-color:var(--nylas-color-primary-200);color:var(--nylas-color-primary-600)}";
2013
+ const NylasViewEmailStyle0 = nylasViewEmailCss;
2014
+
2015
+ DOMPurify.addHook('afterSanitizeAttributes', function (node) {
2016
+ if ('target' in node) {
2017
+ node.setAttribute('target', '_blank');
2018
+ node.setAttribute('rel', 'noopener');
2019
+ }
2020
+ });
2021
+ const NylasViewEmail = class {
2022
+ constructor(hostRef) {
2023
+ registerInstance(this, hostRef);
2024
+ this.htmlElement = document.createElement('html');
2025
+ this.setBody = (body) => {
2026
+ this.state = 'loading';
2027
+ this.styles = [];
2028
+ this.hoistedFontURLs = new Map();
2029
+ this.sanitizedBody = '';
2030
+ document.querySelectorAll('.nylas-view-email-font').forEach(link => {
2031
+ link.remove();
2032
+ });
2033
+ const isHTML = this.message ? detectIfMessageIsHTML(this.message) : detectHTMLOrPlainText(body);
2034
+ if (!isHTML) {
2035
+ body = `<html><body>${parsePlainTextToHTML(body)}</body></html>`;
2036
+ }
2037
+ this.htmlElement.innerHTML = body;
2038
+ if (this.detectDarkMode) {
2039
+ processStyles(this.htmlElement);
2040
+ }
2041
+ this.htmlElement.querySelectorAll('link').forEach(link => {
2042
+ console.debug(`[nylas-view-email] Hoisting link: ${link.getAttribute('href')}`);
2043
+ if (link.getAttribute('rel') === 'stylesheet' && link.getAttribute('href')) {
2044
+ const href = link.getAttribute('href');
2045
+ if (href) {
2046
+ const url = new URL(href, window.location.href);
2047
+ if (url.protocol === 'https:' || url.protocol === 'http:') {
2048
+ this.hoistedFontURLs.set(url.href, url.href);
2049
+ }
2050
+ }
2051
+ }
2052
+ });
2053
+ this.htmlElement.querySelectorAll('style').forEach(style => {
2054
+ style.innerHTML.split('\n').forEach(line => {
2055
+ const match = line.match(/@import url\((.*)\)/);
2056
+ if (match) {
2057
+ const url = new URL(match[1], window.location.href);
2058
+ if (url.protocol === 'https:' || url.protocol === 'http:') {
2059
+ this.hoistedFontURLs.set(url.href, url.href);
2060
+ }
2061
+ }
2062
+ });
2063
+ style.innerHTML = style.innerHTML.replace('body', ':host');
2064
+ this.styles.push(style);
2065
+ style.remove();
2066
+ });
2067
+ this.htmlElement.querySelectorAll('a').forEach(a => {
2068
+ a.setAttribute('target', '_blank');
2069
+ });
2070
+ const gmailQuote = this.htmlElement.querySelector('.gmail_quote');
2071
+ if (gmailQuote) {
2072
+ const toggleButton = document.createElement('button');
2073
+ toggleButton.classList.add('nylas-view-email-toggle-button');
2074
+ toggleButton.setAttribute('aria-label', 'Show quoted text');
2075
+ toggleButton.innerText = '...';
2076
+ gmailQuote.parentElement?.insertBefore(toggleButton, gmailQuote);
2077
+ }
2078
+ this.sanitizedBody = DOMPurify.sanitize(this.htmlElement.innerHTML);
2079
+ this.hoistedFontURLs.forEach((url, _key) => {
2080
+ const link = document.createElement('link');
2081
+ link.setAttribute('rel', 'stylesheet');
2082
+ link.setAttribute('href', url);
2083
+ link.classList.add('nylas-view-email-font');
2084
+ document.head.appendChild(link);
2085
+ });
2086
+ this.state = 'ready';
2087
+ };
2088
+ this.handleMobileSize = () => {
2089
+ const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
2090
+ if (vw <= 768) {
2091
+ const viewEmailReact = this.viewEmailElement?.getBoundingClientRect();
2092
+ if (viewEmailReact && this.viewEmailElement && this.parent) {
2093
+ if (viewEmailReact.width > vw) {
2094
+ const parentElement = this.parent;
2095
+ const parentReact = parentElement?.getBoundingClientRect();
2096
+ debug('Parent width:', parentReact?.width, 'Parent height:', parentReact?.height);
2097
+ debug('Parent client width:', parentElement.clientWidth, 'Parent client height:', parentElement.clientHeight);
2098
+ const scaleX = parentReact.width / viewEmailReact.width;
2099
+ const scaleY = parentReact.height / viewEmailReact.height;
2100
+ const scale = Math.min(scaleX, scaleY);
2101
+ debug('Scale:', scale);
2102
+ this.viewEmailElement.style.setProperty('transform', `scale(${scale})`);
2103
+ this.viewEmailElement.style.setProperty('transform-origin', `top left`);
2104
+ this.viewEmailElement.style.setProperty('height', `${viewEmailReact.height * scale}px`);
2105
+ }
2106
+ }
2107
+ }
2108
+ else {
2109
+ this.viewEmailElement?.style.removeProperty('transform');
2110
+ this.viewEmailElement?.style.removeProperty('transform-origin');
2111
+ this.viewEmailElement?.style.removeProperty('height');
2112
+ }
2113
+ };
2114
+ this.message = undefined;
2115
+ this.parent = undefined;
2116
+ this.attachments = [];
2117
+ this.detectDarkMode = true;
2118
+ this.state = 'loading';
2119
+ this.sanitizedBody = '';
2120
+ this.styles = [];
2121
+ this.viewEmailElement = undefined;
2122
+ this.hoistedFontURLs = new Map();
2123
+ }
2124
+ connectedCallback() { }
2125
+ disconnectedCallback() {
2126
+ debug(`[nylas-view-email] Component disconnected`);
2127
+ this.state = 'loading';
2128
+ this.styles = [];
2129
+ this.hoistedFontURLs = new Map();
2130
+ this.sanitizedBody = '';
2131
+ document.querySelectorAll('.nylas-view-email-font').forEach(link => {
2132
+ link.remove();
2133
+ });
2134
+ }
2135
+ async componentWillLoad() {
2136
+ debug(`[nylas-view-email] component loaded`);
2137
+ this.setBody(this.message?.body ?? '');
2138
+ }
2139
+ async componentDidLoad() {
2140
+ debug(`[nylas-view-thread] Component did load`);
2141
+ this.handleMobileSize();
2142
+ }
2143
+ async messageChanged() {
2144
+ debug(`[nylas-view-thread] Message changed`, { message: this.message });
2145
+ this.setBody(this.message?.body ?? '');
2146
+ }
2147
+ handleScroll() {
2148
+ this.handleMobileSize();
2149
+ }
2150
+ viewEmailElementChanged() {
2151
+ const toggleButton = this.viewEmailElement?.querySelectorAll('.nylas-view-email-toggle-button');
2152
+ if (toggleButton) {
2153
+ toggleButton.forEach(button => {
2154
+ button.addEventListener('click', () => {
2155
+ const gmailQuote = this.viewEmailElement?.querySelector('.gmail_quote');
2156
+ if (gmailQuote) {
2157
+ gmailQuote.classList.toggle('show');
2158
+ }
2159
+ });
2160
+ });
2161
+ }
2162
+ }
2163
+ render() {
2164
+ console.debug(`[nylas-view-email] render`, { hoistedFontURLs: this.hoistedFontURLs });
2165
+ return (h(Host, { key: 'c32409cd5bf30781d0d400103e9715bf48e13b23' }, this.state === 'loading' && h("div", null, "Loading..."), this.state === 'ready' && (h(Fragment, null, this.styles.map(style => (h("style", null, DOMPurify.sanitize(style.innerHTML)))), h("div", { class: 'view-email', part: "view-email", innerHTML: this.sanitizedBody, ref: el => (this.viewEmailElement = el) })))));
2166
+ }
2167
+ get host() { return getElement(this); }
2168
+ static get watchers() { return {
2169
+ "message": ["messageChanged"],
2170
+ "viewEmailElement": ["viewEmailElementChanged"]
2171
+ }; }
2172
+ };
2173
+ NylasViewEmail.style = NylasViewEmailStyle0;
2174
+
2175
+ const iconCss$1 = ".sc-reply-all-icon-h{display:flex}";
2176
+ const ReplyAllIconStyle0 = iconCss$1;
2177
+
2178
+ const ReplyAllIcon = class {
2179
+ constructor(hostRef) {
2180
+ registerInstance(this, hostRef);
2181
+ this.width = '15';
2182
+ this.height = '15';
2183
+ }
2184
+ render() {
2185
+ return (h("svg", { key: '90b30777b0de1b9622f557cb54af3397458b1599', fill: "auto", width: this.width, height: this.height, viewBox: "0 0 1920 1920", xmlns: "http://www.w3.org/2000/svg" }, h("path", { key: '4a7b8ec38ab7e5ed3d78d9b7c1c9730e94be8a45', d: "m1030.975 188 81.249 81.249-429.228 429.228h300.747c516.223 0 936.257 420.034 936.257 936.257v98.028h-114.92v-98.028c0-452.901-368.436-821.337-821.337-821.337H682.996l429.228 429.229-81.25 81.248-567.936-567.937L1030.975 188Zm-463.038.011 81.249 81.25-486.688 486.688 486.688 486.688-81.249 81.249L0 755.949 567.937 188.01Z", "fill-rule": "evenodd" })));
2186
+ }
2187
+ };
2188
+ ReplyAllIcon.style = ReplyAllIconStyle0;
2189
+
2190
+ const iconCss = ".sc-reply-icon-h{display:flex}";
2191
+ const ReplyIconStyle0 = iconCss;
2192
+
2193
+ const ReplyIcon = class {
2194
+ constructor(hostRef) {
2195
+ registerInstance(this, hostRef);
2196
+ this.width = '15';
2197
+ this.height = '15';
2198
+ }
2199
+ render() {
2200
+ return (h("svg", { key: 'd3fe83055b3bb9b88f5347f3bb5d8cec29354dce', fill: "auto", width: this.width, height: this.height, viewBox: "0 0 1920 1920", xmlns: "http://www.w3.org/2000/svg" }, h("path", { key: 'c2082dfa35e4bb43d4e0489243b47b4d08ff34ac', d: "M835.942 632.563H244.966l478.08-478.08-90.496-90.496L-.026 696.563 632.55 1329.14l90.496-90.496-478.08-478.08h590.976c504.448 0 914.816 410.368 914.816 914.816v109.184h128V1675.38c0-574.976-467.84-1042.816-1042.816-1042.816", "fill-rule": "evenodd" })));
2201
+ }
2202
+ };
2203
+ ReplyIcon.style = ReplyIconStyle0;
2204
+
2205
+ export { ForwardIcon as forward_icon, NylasComposer as nylas_composer, NylasSummarizeMessageButton as nylas_summarize_message_button, NylasViewEmail as nylas_view_email, ReplyAllIcon as reply_all_icon, ReplyIcon as reply_icon };
2206
+
2207
+ //# sourceMappingURL=forward-icon_6.entry.js.map