@prolibu-suite/cobalt-core 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (590) hide show
  1. package/custom-elements.json +15675 -11199
  2. package/dist/cjs/co-accordion.cjs.entry.js +3 -3
  3. package/dist/cjs/co-app-shell.cjs.entry.js +4 -4
  4. package/dist/cjs/co-autocomplete.cjs.entry.js +10 -7
  5. package/dist/cjs/co-avatar-group.cjs.entry.js +77 -0
  6. package/dist/cjs/co-avatar.cjs.entry.js +6 -4
  7. package/dist/cjs/co-badge.cjs.entry.js +2 -2
  8. package/dist/cjs/co-bottom-sheet.cjs.entry.js +325 -0
  9. package/dist/cjs/co-button-group.cjs.entry.js +3 -3
  10. package/dist/cjs/co-button.cjs.entry.js +6 -6
  11. package/dist/cjs/co-calendar-month.cjs.entry.js +381 -0
  12. package/dist/cjs/co-calendar_3.cjs.entry.js +11 -11
  13. package/dist/cjs/co-card.cjs.entry.js +3 -3
  14. package/dist/cjs/co-checkbox-group.cjs.entry.js +5 -5
  15. package/dist/cjs/co-checkbox.cjs.entry.js +5 -5
  16. package/dist/cjs/co-chip.cjs.entry.js +11 -8
  17. package/dist/cjs/co-color-picker.cjs.entry.js +7 -5
  18. package/dist/cjs/co-column-picker.cjs.entry.js +3 -3
  19. package/dist/cjs/co-combobox.cjs.entry.js +7 -7
  20. package/dist/cjs/co-command-search.cjs.entry.js +151 -12
  21. package/dist/cjs/co-data-table-pagination.cjs.entry.js +5 -5
  22. package/dist/cjs/co-data-table.cjs.entry.js +25 -11
  23. package/dist/cjs/co-date-picker.cjs.entry.js +2 -2
  24. package/dist/cjs/co-date-range-picker.cjs.entry.js +3 -3
  25. package/dist/cjs/co-date-range.cjs.entry.js +2 -2
  26. package/dist/cjs/co-empty-state.cjs.entry.js +2 -2
  27. package/dist/cjs/co-event-calendar.cjs.entry.js +318 -0
  28. package/dist/cjs/co-fab.cjs.entry.js +3 -3
  29. package/dist/cjs/co-file-field.cjs.entry.js +8 -8
  30. package/dist/cjs/co-helper-text.cjs.entry.js +3 -3
  31. package/dist/cjs/co-icon-button.cjs.entry.js +5 -5
  32. package/dist/cjs/co-icon.cjs.entry.js +33 -25
  33. package/dist/cjs/co-input.cjs.entry.js +6 -6
  34. package/dist/cjs/co-json-field.cjs.entry.js +10 -6
  35. package/dist/cjs/co-lightbox.cjs.entry.js +5 -5
  36. package/dist/cjs/co-list-footer.cjs.entry.js +25 -0
  37. package/dist/cjs/co-list-item.cjs.entry.js +60 -4
  38. package/dist/cjs/co-loader_2.cjs.entry.js +293 -0
  39. package/dist/cjs/co-menu-divider.cjs.entry.js +2 -2
  40. package/dist/cjs/co-menu-item.cjs.entry.js +17 -10
  41. package/dist/cjs/co-menu.cjs.entry.js +2 -2
  42. package/dist/cjs/co-modal.cjs.entry.js +16 -4
  43. package/dist/cjs/co-navbar.cjs.entry.js +3 -3
  44. package/dist/cjs/co-number-field.cjs.entry.js +18 -6
  45. package/dist/cjs/co-page-header.cjs.entry.js +2 -2
  46. package/dist/cjs/co-phone-field.cjs.entry.js +6 -4
  47. package/dist/cjs/co-popover.cjs.entry.js +45 -14
  48. package/dist/cjs/co-progress-bar.cjs.entry.js +8 -4
  49. package/dist/cjs/co-progress-circle.cjs.entry.js +3 -3
  50. package/dist/cjs/co-radio-group.cjs.entry.js +4 -4
  51. package/dist/cjs/co-radio.cjs.entry.js +4 -4
  52. package/dist/cjs/co-rating.cjs.entry.js +4 -4
  53. package/dist/cjs/co-ref-field.cjs.entry.js +36 -13
  54. package/dist/cjs/co-rich-text-editor.cjs.entry.js +1879 -33
  55. package/dist/cjs/co-rich-text-toolbar.cjs.entry.js +995 -71
  56. package/dist/cjs/co-rich-text-viewer.cjs.entry.js +55 -19
  57. package/dist/cjs/co-row.cjs.entry.js +3 -3
  58. package/dist/cjs/co-select.cjs.entry.js +8 -8
  59. package/dist/cjs/co-separator.cjs.entry.js +2 -2
  60. package/dist/cjs/co-sidebar-nav.cjs.entry.js +29 -9
  61. package/dist/cjs/co-sidebar.cjs.entry.js +3 -3
  62. package/dist/cjs/co-skeleton.cjs.entry.js +26 -0
  63. package/dist/cjs/co-slider.cjs.entry.js +3 -3
  64. package/dist/cjs/co-switch.cjs.entry.js +6 -6
  65. package/dist/cjs/co-tab-group.cjs.entry.js +2 -2
  66. package/dist/cjs/co-tab.cjs.entry.js +3 -3
  67. package/dist/cjs/co-tags-field.cjs.entry.js +19 -13
  68. package/dist/cjs/co-textarea.cjs.entry.js +11 -7
  69. package/dist/cjs/co-toast.cjs.entry.js +2 -2
  70. package/dist/cjs/co-toggle-button-group.cjs.entry.js +4 -4
  71. package/dist/cjs/co-toggle-button.cjs.entry.js +4 -4
  72. package/dist/cjs/co-tooltip.cjs.entry.js +51 -16
  73. package/dist/cjs/co-transfer-list.cjs.entry.js +3 -3
  74. package/dist/cjs/co-video.cjs.entry.js +839 -0
  75. package/dist/cjs/cobalt.cjs.js +2 -2
  76. package/dist/cjs/fieldChip-CDIMz_Y6.js +7 -0
  77. package/dist/cjs/{index-CaEJnpZe.js → index-5NdsiFjZ.js} +14509 -6317
  78. package/dist/cjs/{index-DoFnrUVH.js → index-BumlM92r.js} +45 -21
  79. package/dist/cjs/loader.cjs.js +2 -2
  80. package/dist/cjs/overlayAfterClose-BdeXrhVY.js +12 -0
  81. package/dist/{esm/sanitizer-DcK0GGZC.js → cjs/purify.es-DX41ZWS2.js} +3 -107
  82. package/dist/cjs/{requiredMark-DA6y-4rp.js → requiredMark-CqMGt1H1.js} +1 -1
  83. package/dist/cjs/richTextI18n-B7ktXg3M.js +382 -0
  84. package/dist/cjs/toolbar-config-3PlT-3zm.js +216 -0
  85. package/dist/cjs/tz-Dgom0W69.js +127 -0
  86. package/dist/cobalt/cobalt.css +1 -1
  87. package/dist/cobalt/cobalt.esm.js +1 -1
  88. package/dist/cobalt/p-0a506c9d.entry.js +1 -0
  89. package/dist/cobalt/p-0bb55163.entry.js +1 -0
  90. package/dist/cobalt/{p-6404bd21.entry.js → p-0e8c0d87.entry.js} +1 -1
  91. package/dist/cobalt/p-12e2c2c4.entry.js +1 -0
  92. package/dist/cobalt/p-136ad468.entry.js +1 -0
  93. package/dist/cobalt/{p-654bbc2a.entry.js → p-14b59277.entry.js} +1 -1
  94. package/dist/cobalt/p-1531d3c9.entry.js +1 -0
  95. package/dist/cobalt/p-1774d211.entry.js +1 -0
  96. package/dist/cobalt/p-180e1106.entry.js +1 -0
  97. package/dist/cobalt/p-1a07c23c.entry.js +1 -0
  98. package/dist/cobalt/p-1dc9c49e.entry.js +1 -0
  99. package/dist/cobalt/p-1f747e45.entry.js +1 -0
  100. package/dist/cobalt/p-201eaf35.entry.js +1 -0
  101. package/dist/cobalt/p-260101ab.entry.js +1 -0
  102. package/dist/cobalt/p-279bf91c.entry.js +1 -0
  103. package/dist/cobalt/p-29be61a9.entry.js +1 -0
  104. package/dist/cobalt/p-2d2ce434.entry.js +1 -0
  105. package/dist/cobalt/{p-aa63812a.entry.js → p-2f86e1e0.entry.js} +1 -1
  106. package/dist/cobalt/{p-522fcdb7.entry.js → p-31ab9a46.entry.js} +1 -1
  107. package/dist/cobalt/{p-fe9e85b6.entry.js → p-37595103.entry.js} +1 -1
  108. package/dist/cobalt/{p-def448e4.entry.js → p-377c2ccc.entry.js} +1 -1
  109. package/dist/cobalt/p-3863ea91.entry.js +1 -0
  110. package/dist/cobalt/p-3a257cb0.entry.js +1 -0
  111. package/dist/cobalt/p-3e187456.entry.js +1 -0
  112. package/dist/cobalt/{p-5d01bd4d.entry.js → p-4431faac.entry.js} +1 -1
  113. package/dist/cobalt/{p-54f26e95.entry.js → p-4504f7b0.entry.js} +1 -1
  114. package/dist/cobalt/{p-f8728b21.entry.js → p-456fa86f.entry.js} +1 -1
  115. package/dist/cobalt/{p-3f9b3fcb.entry.js → p-4871690e.entry.js} +1 -1
  116. package/dist/cobalt/{p-d17e1444.entry.js → p-4c01d984.entry.js} +1 -1
  117. package/dist/cobalt/p-51a53177.entry.js +1 -0
  118. package/dist/cobalt/p-52de17da.entry.js +1 -0
  119. package/dist/cobalt/p-5890e4d1.entry.js +1 -0
  120. package/dist/cobalt/{p-f2c5cb74.entry.js → p-58a53421.entry.js} +1 -1
  121. package/dist/cobalt/p-62274eba.entry.js +1 -0
  122. package/dist/cobalt/p-635b03d5.entry.js +1 -0
  123. package/dist/cobalt/p-64ddee92.entry.js +1 -0
  124. package/dist/cobalt/p-65af5017.entry.js +1 -0
  125. package/dist/cobalt/p-69d4c0c8.entry.js +1 -0
  126. package/dist/cobalt/p-6c480916.entry.js +1 -0
  127. package/dist/cobalt/p-6d1217c3.entry.js +1 -0
  128. package/dist/cobalt/{p-f0e8fa7d.entry.js → p-6e808b3a.entry.js} +1 -1
  129. package/dist/cobalt/{p-f97ad9ad.entry.js → p-70b14b05.entry.js} +1 -1
  130. package/dist/cobalt/{p-97c20011.entry.js → p-790d384e.entry.js} +1 -1
  131. package/dist/cobalt/p-8012e152.entry.js +1 -0
  132. package/dist/cobalt/p-80b27203.entry.js +1 -0
  133. package/dist/cobalt/p-867c1465.entry.js +1 -0
  134. package/dist/cobalt/p-86a143d7.entry.js +1 -0
  135. package/dist/cobalt/{p-e8b58332.entry.js → p-8d59f5ad.entry.js} +1 -1
  136. package/dist/cobalt/p-8d7fdb9d.entry.js +1 -0
  137. package/dist/cobalt/{p-7f818368.entry.js → p-8dc1dab8.entry.js} +1 -1
  138. package/dist/cobalt/{p-beb9c11d.entry.js → p-8e1dc062.entry.js} +1 -1
  139. package/dist/cobalt/p-929e647f.entry.js +1 -0
  140. package/dist/cobalt/p-92bd9b29.entry.js +1 -0
  141. package/dist/cobalt/p-93046365.entry.js +1 -0
  142. package/dist/cobalt/p-98ab5f3f.entry.js +1 -0
  143. package/dist/cobalt/{p-c87285b6.entry.js → p-9a04ca90.entry.js} +1 -1
  144. package/dist/cobalt/{p-7ef766c6.entry.js → p-9a088515.entry.js} +1 -1
  145. package/dist/cobalt/p-9abbd436.entry.js +1 -0
  146. package/dist/cobalt/p-9d69c067.entry.js +1 -0
  147. package/dist/cobalt/p-B-ckjCUA.js +1 -0
  148. package/dist/cobalt/p-B2QLgWrz.js +2 -0
  149. package/dist/cobalt/p-B6JZk8fL.js +1 -0
  150. package/dist/cobalt/p-BZJ7NCm5.js +1 -0
  151. package/dist/cobalt/p-CYsftTKf.js +2 -0
  152. package/dist/cobalt/p-CegCk7FL.js +1 -0
  153. package/dist/cobalt/p-Ch1jfwZ2.js +1 -0
  154. package/dist/cobalt/p-ChibIpZv.js +1 -0
  155. package/dist/cobalt/p-afb7e19e.entry.js +1 -0
  156. package/dist/cobalt/{p-b758c2e6.entry.js → p-b6f20268.entry.js} +1 -1
  157. package/dist/cobalt/{p-bb07da22.entry.js → p-ba90e871.entry.js} +1 -1
  158. package/dist/cobalt/p-c10697e1.entry.js +1 -0
  159. package/dist/cobalt/p-c4f59532.entry.js +1 -0
  160. package/dist/cobalt/{p-1e0282b8.entry.js → p-cb235aa7.entry.js} +1 -1
  161. package/dist/cobalt/p-cfb36943.entry.js +1 -0
  162. package/dist/cobalt/p-d809bd44.entry.js +1 -0
  163. package/dist/cobalt/p-e53861e4.entry.js +1 -0
  164. package/dist/cobalt/p-e54dd404.entry.js +1 -0
  165. package/dist/cobalt/{p-01fc77c4.entry.js → p-eb18fdbf.entry.js} +1 -1
  166. package/dist/cobalt/{p-95d14878.entry.js → p-eb73052a.entry.js} +1 -1
  167. package/dist/cobalt/{p-273afd93.entry.js → p-ef7d4ae3.entry.js} +1 -1
  168. package/dist/cobalt/p-f4063c41.entry.js +1 -0
  169. package/dist/cobalt/p-oImf-7fN.js +1 -0
  170. package/dist/cobalt/{p-CyYF8IJE.js → p-tPYikBRJ.js} +1 -1
  171. package/dist/collection/collection-manifest.json +10 -3
  172. package/dist/collection/components/co-accordion/co-accordion.js +2 -2
  173. package/dist/collection/components/co-app-shell/co-app-shell.css +79 -6
  174. package/dist/collection/components/co-app-shell/co-app-shell.js +2 -2
  175. package/dist/collection/components/co-autocomplete/co-autocomplete.css +28 -1
  176. package/dist/collection/components/co-autocomplete/co-autocomplete.js +27 -4
  177. package/dist/collection/components/co-avatar/co-avatar.css +38 -1
  178. package/dist/collection/components/co-avatar/co-avatar.js +23 -2
  179. package/dist/collection/components/co-avatar-group/co-avatar-group.css +86 -0
  180. package/dist/collection/components/co-avatar-group/co-avatar-group.js +224 -0
  181. package/dist/collection/components/co-badge/co-badge.js +1 -1
  182. package/dist/collection/components/co-bottom-sheet/co-bottom-sheet.css +136 -0
  183. package/dist/collection/components/co-bottom-sheet/co-bottom-sheet.js +507 -0
  184. package/dist/collection/components/co-button/co-button.css +40 -7
  185. package/dist/collection/components/co-button/co-button.js +26 -7
  186. package/dist/collection/components/co-button-group/co-button-group.js +2 -2
  187. package/dist/collection/components/co-calendar/co-calendar.js +1 -1
  188. package/dist/collection/components/co-calendar-month/co-calendar-month.css +231 -0
  189. package/dist/collection/components/co-calendar-month/co-calendar-month.js +594 -0
  190. package/dist/collection/components/co-card/co-card.js +2 -2
  191. package/dist/collection/components/co-checkbox/co-checkbox.css +7 -1
  192. package/dist/collection/components/co-checkbox/co-checkbox.js +3 -3
  193. package/dist/collection/components/co-checkbox-group/co-checkbox-group.css +7 -1
  194. package/dist/collection/components/co-checkbox-group/co-checkbox-group.js +3 -3
  195. package/dist/collection/components/co-chip/co-chip.css +27 -7
  196. package/dist/collection/components/co-chip/co-chip.js +52 -10
  197. package/dist/collection/components/co-color-picker/co-color-picker.css +35 -1
  198. package/dist/collection/components/co-color-picker/co-color-picker.js +24 -2
  199. package/dist/collection/components/co-column-picker/co-column-picker.js +2 -2
  200. package/dist/collection/components/co-combobox/co-combobox.css +7 -47
  201. package/dist/collection/components/co-combobox/co-combobox.js +4 -4
  202. package/dist/collection/components/co-command-search/co-command-search.css +163 -1
  203. package/dist/collection/components/co-command-search/co-command-search.js +355 -14
  204. package/dist/collection/components/co-command-search/commandSearchGroup.js +17 -0
  205. package/dist/collection/components/co-command-search/commandSearchLogic.js +27 -0
  206. package/dist/collection/components/co-data-table/co-data-table.css +37 -1
  207. package/dist/collection/components/co-data-table/co-data-table.js +25 -11
  208. package/dist/collection/components/co-data-table-pagination/co-data-table-pagination.js +4 -4
  209. package/dist/collection/components/co-date-field/co-date-field.css +7 -1
  210. package/dist/collection/components/co-date-field/co-date-field.js +4 -4
  211. package/dist/collection/components/co-date-range/co-date-range.js +1 -1
  212. package/dist/collection/components/co-date-range-picker/co-date-range-picker.css +7 -1
  213. package/dist/collection/components/co-drawer/co-drawer.css +1 -0
  214. package/dist/collection/components/co-drawer/co-drawer.js +2 -2
  215. package/dist/collection/components/co-empty-state/co-empty-state.js +1 -1
  216. package/dist/collection/components/co-event-calendar/co-event-calendar.css +146 -0
  217. package/dist/collection/components/co-event-calendar/co-event-calendar.js +620 -0
  218. package/dist/collection/components/co-fab/co-fab.js +2 -2
  219. package/dist/collection/components/co-file-field/co-file-field.css +7 -1
  220. package/dist/collection/components/co-file-field/co-file-field.js +5 -5
  221. package/dist/collection/components/co-helper-text/co-helper-text.js +2 -2
  222. package/dist/collection/components/co-icon/co-icon.js +7 -37
  223. package/dist/collection/components/co-icon/iconLoader.js +39 -0
  224. package/dist/collection/components/co-icon-button/co-icon-button.css +19 -8
  225. package/dist/collection/components/co-icon-button/co-icon-button.js +23 -4
  226. package/dist/collection/components/co-input/co-input.css +7 -1
  227. package/dist/collection/components/co-input/co-input.js +3 -3
  228. package/dist/collection/components/co-json-field/co-json-field.css +25 -1
  229. package/dist/collection/components/co-json-field/co-json-field.js +27 -3
  230. package/dist/collection/components/co-lightbox/co-lightbox.js +4 -4
  231. package/dist/collection/components/co-list-footer/co-list-footer.css +50 -0
  232. package/dist/collection/components/co-list-footer/co-list-footer.js +149 -0
  233. package/dist/collection/components/co-list-item/co-list-item.css +7 -0
  234. package/dist/collection/components/co-list-item/co-list-item.js +65 -2
  235. package/dist/collection/components/co-loader/co-loader.css +9 -0
  236. package/dist/collection/components/co-menu/co-menu.js +1 -1
  237. package/dist/collection/components/co-menu-divider/co-menu-divider.js +1 -1
  238. package/dist/collection/components/co-menu-item/co-menu-item.css +18 -0
  239. package/dist/collection/components/co-menu-item/co-menu-item.js +15 -8
  240. package/dist/collection/components/co-modal/co-modal.css +42 -2
  241. package/dist/collection/components/co-modal/co-modal.js +42 -2
  242. package/dist/collection/components/co-navbar/co-navbar.js +2 -2
  243. package/dist/collection/components/co-number-field/co-number-field.css +19 -1
  244. package/dist/collection/components/co-number-field/co-number-field.js +34 -3
  245. package/dist/collection/components/co-overlay/co-overlay.css +15 -1
  246. package/dist/collection/components/co-overlay/co-overlay.js +266 -1
  247. package/dist/collection/components/co-overlay/focusTrap.js +53 -0
  248. package/dist/collection/components/co-overlay/overlayAfterClose.js +8 -0
  249. package/dist/collection/components/co-page-header/co-page-header.js +1 -1
  250. package/dist/collection/components/co-phone-field/co-phone-field.css +30 -2
  251. package/dist/collection/components/co-phone-field/co-phone-field.js +23 -1
  252. package/dist/collection/components/co-popover/co-popover.css +9 -0
  253. package/dist/collection/components/co-popover/co-popover.js +43 -12
  254. package/dist/collection/components/co-progress-bar/co-progress-bar.css +22 -0
  255. package/dist/collection/components/co-progress-bar/co-progress-bar.js +26 -2
  256. package/dist/collection/components/co-progress-circle/co-progress-circle.js +2 -2
  257. package/dist/collection/components/co-radio/co-radio.js +3 -3
  258. package/dist/collection/components/co-radio-group/co-radio-group.js +3 -3
  259. package/dist/collection/components/co-rating/co-rating.js +3 -3
  260. package/dist/collection/components/co-ref-field/co-ref-field.css +64 -6
  261. package/dist/collection/components/co-ref-field/co-ref-field.js +0 -0
  262. package/dist/collection/components/co-rich-text-editor/co-rich-text-editor.css +1125 -41
  263. package/dist/collection/components/co-rich-text-editor/co-rich-text-editor.js +2008 -53
  264. package/dist/collection/components/co-rich-text-toolbar/co-rich-text-toolbar.css +791 -9
  265. package/dist/collection/components/co-rich-text-toolbar/co-rich-text-toolbar.js +1071 -71
  266. package/dist/collection/components/co-rich-text-viewer/co-rich-text-viewer.css +78 -0
  267. package/dist/collection/components/co-rich-text-viewer/co-rich-text-viewer.js +46 -41
  268. package/dist/collection/components/co-row/co-row.js +2 -2
  269. package/dist/collection/components/co-select/co-select.css +7 -1
  270. package/dist/collection/components/co-select/co-select.js +5 -5
  271. package/dist/collection/components/co-separator/co-separator.js +1 -1
  272. package/dist/collection/components/co-sidebar/co-sidebar.js +2 -2
  273. package/dist/collection/components/co-sidebar-nav/co-sidebar-nav.css +99 -12
  274. package/dist/collection/components/co-sidebar-nav/co-sidebar-nav.js +28 -8
  275. package/dist/collection/components/co-skeleton/co-skeleton.css +28 -0
  276. package/dist/collection/components/co-skeleton/co-skeleton.js +97 -0
  277. package/dist/collection/components/co-slider/co-slider.js +2 -2
  278. package/dist/collection/components/co-switch/co-switch.css +9 -1
  279. package/dist/collection/components/co-switch/co-switch.js +3 -3
  280. package/dist/collection/components/co-tab/co-tab.js +2 -2
  281. package/dist/collection/components/co-tab-group/co-tab-group.js +1 -1
  282. package/dist/collection/components/co-tags-field/co-tags-field.css +39 -1
  283. package/dist/collection/components/co-tags-field/co-tags-field.js +36 -10
  284. package/dist/collection/components/co-textarea/co-textarea.css +26 -1
  285. package/dist/collection/components/co-textarea/co-textarea.js +28 -4
  286. package/dist/collection/components/co-toast/co-toast.js +1 -1
  287. package/dist/collection/components/co-toggle-button/co-toggle-button.css +26 -4
  288. package/dist/collection/components/co-toggle-button/co-toggle-button.js +3 -3
  289. package/dist/collection/components/co-toggle-button-group/co-toggle-button-group.css +16 -12
  290. package/dist/collection/components/co-toggle-button-group/co-toggle-button-group.js +2 -2
  291. package/dist/collection/components/co-tooltip/co-tooltip.css +8 -0
  292. package/dist/collection/components/co-tooltip/co-tooltip.js +69 -14
  293. package/dist/collection/components/co-transfer-list/co-transfer-list.js +2 -2
  294. package/dist/collection/components/co-video/co-video.css +497 -0
  295. package/dist/collection/components/co-video/co-video.js +1772 -0
  296. package/dist/collection/utils/fieldChip.js +2 -0
  297. package/dist/collection/utils/icon-config.js +12 -0
  298. package/dist/collection/utils/richTextI18n.js +378 -0
  299. package/dist/collection/utils/sheetGesture.js +53 -0
  300. package/dist/components/co-accordion.js +1 -1
  301. package/dist/components/co-app-shell.js +1 -1
  302. package/dist/components/co-autocomplete.js +1 -1
  303. package/dist/components/co-avatar-group.d.ts +11 -0
  304. package/dist/components/co-avatar-group.js +1 -0
  305. package/dist/components/co-avatar.js +1 -1
  306. package/dist/components/co-badge.js +1 -1
  307. package/dist/components/co-bottom-sheet.d.ts +11 -0
  308. package/dist/components/co-bottom-sheet.js +1 -0
  309. package/dist/components/co-button-group.js +1 -1
  310. package/dist/components/co-button.js +1 -1
  311. package/dist/components/co-calendar-month.d.ts +11 -0
  312. package/dist/components/co-calendar-month.js +1 -0
  313. package/dist/components/co-calendar.js +1 -1
  314. package/dist/components/co-card.js +1 -1
  315. package/dist/components/co-checkbox-group.js +1 -1
  316. package/dist/components/co-checkbox.js +1 -1
  317. package/dist/components/co-chip.js +1 -1
  318. package/dist/components/co-color-picker.js +1 -1
  319. package/dist/components/co-column-picker.js +1 -1
  320. package/dist/components/co-combobox.js +1 -1
  321. package/dist/components/co-command-search.js +1 -1
  322. package/dist/components/co-data-table-pagination.js +1 -1
  323. package/dist/components/co-data-table.js +1 -1
  324. package/dist/components/co-date-field.js +1 -1
  325. package/dist/components/co-date-picker.js +1 -1
  326. package/dist/components/co-date-range-picker.js +1 -1
  327. package/dist/components/co-date-range.js +1 -1
  328. package/dist/components/co-drawer.js +1 -1
  329. package/dist/components/co-empty-state.js +1 -1
  330. package/dist/components/co-event-calendar.d.ts +11 -0
  331. package/dist/components/co-event-calendar.js +1 -0
  332. package/dist/components/co-fab.js +1 -1
  333. package/dist/components/co-file-field.js +1 -1
  334. package/dist/components/co-helper-text.js +1 -1
  335. package/dist/components/co-icon-button.js +1 -1
  336. package/dist/components/co-icon.js +1 -1
  337. package/dist/components/co-input.js +1 -1
  338. package/dist/components/co-json-field.js +1 -1
  339. package/dist/components/co-lightbox.js +1 -1
  340. package/dist/components/co-list-footer.d.ts +11 -0
  341. package/dist/components/co-list-footer.js +1 -0
  342. package/dist/components/co-list-item.js +1 -1
  343. package/dist/components/co-loader.js +1 -1
  344. package/dist/components/co-menu-divider.js +1 -1
  345. package/dist/components/co-menu-item.js +1 -1
  346. package/dist/components/co-menu.js +1 -1
  347. package/dist/components/co-modal.js +1 -1
  348. package/dist/components/co-navbar.js +1 -1
  349. package/dist/components/co-number-field.js +1 -1
  350. package/dist/components/co-overlay.js +1 -1
  351. package/dist/components/co-page-header.js +1 -1
  352. package/dist/components/co-phone-field.js +1 -1
  353. package/dist/components/co-popover.js +1 -1
  354. package/dist/components/co-progress-bar.js +1 -1
  355. package/dist/components/co-progress-circle.js +1 -1
  356. package/dist/components/co-radio-group.js +1 -1
  357. package/dist/components/co-radio.js +1 -1
  358. package/dist/components/co-rating.js +1 -1
  359. package/dist/components/co-ref-field.js +1 -1
  360. package/dist/components/co-rich-text-editor.js +1 -1
  361. package/dist/components/co-rich-text-toolbar.js +1 -1
  362. package/dist/components/co-rich-text-viewer.js +1 -1
  363. package/dist/components/co-row.js +1 -1
  364. package/dist/components/co-select.js +1 -1
  365. package/dist/components/co-separator.js +1 -1
  366. package/dist/components/co-sidebar-nav.js +1 -1
  367. package/dist/components/co-sidebar.js +1 -1
  368. package/dist/components/co-skeleton.d.ts +11 -0
  369. package/dist/components/co-skeleton.js +1 -0
  370. package/dist/components/co-slider.js +1 -1
  371. package/dist/components/co-switch.js +1 -1
  372. package/dist/components/co-tab-group.js +1 -1
  373. package/dist/components/co-tab.js +1 -1
  374. package/dist/components/co-tags-field.js +1 -1
  375. package/dist/components/co-textarea.js +1 -1
  376. package/dist/components/co-toast.js +1 -1
  377. package/dist/components/co-toggle-button-group.js +1 -1
  378. package/dist/components/co-toggle-button.js +1 -1
  379. package/dist/components/co-tooltip.js +1 -1
  380. package/dist/components/co-transfer-list.js +1 -1
  381. package/dist/components/co-video.d.ts +11 -0
  382. package/dist/components/co-video.js +1 -0
  383. package/dist/components/index.js +1 -1
  384. package/dist/components/p-B2QLgWrz.js +2 -0
  385. package/dist/components/{p-BeWXpX8I.js → p-B7vGYFbO.js} +1 -1
  386. package/dist/components/p-BB2OaYKF.js +1 -0
  387. package/dist/components/p-BFeE_fiq.js +1 -0
  388. package/dist/components/p-BNKz39GA.js +1 -0
  389. package/dist/components/p-Ba4v1NXo.js +1 -0
  390. package/dist/components/p-C_ULDaks.js +1 -0
  391. package/dist/components/p-CegCk7FL.js +1 -0
  392. package/dist/components/p-ChibIpZv.js +1 -0
  393. package/dist/components/p-D3Y_ti3Q.js +1 -0
  394. package/dist/components/{p-DObrQi5F.js → p-DKh8ZK4U.js} +1 -1
  395. package/dist/components/{p-C9tHLXKS.js → p-DeZxp9vb.js} +1 -1
  396. package/dist/components/p-DvhR3H61.js +1 -0
  397. package/dist/components/p-DxCFMMfY.js +1 -0
  398. package/dist/components/{p-OGpfa9Yd.js → p-DzoNGEDU.js} +1 -1
  399. package/dist/components/p-EPZfLt5l.js +1 -0
  400. package/dist/components/p-FMnqPWcM.js +1 -0
  401. package/dist/components/p-Hzh9U2cM.js +1 -0
  402. package/dist/components/p-WZ06pT2Y.js +1 -0
  403. package/dist/components/p-tloAgDin.js +1 -0
  404. package/dist/esm/co-accordion.entry.js +3 -3
  405. package/dist/esm/co-app-shell.entry.js +4 -4
  406. package/dist/esm/co-autocomplete.entry.js +10 -7
  407. package/dist/esm/co-avatar-group.entry.js +75 -0
  408. package/dist/esm/co-avatar.entry.js +6 -4
  409. package/dist/esm/co-badge.entry.js +2 -2
  410. package/dist/esm/co-bottom-sheet.entry.js +323 -0
  411. package/dist/esm/co-button-group.entry.js +3 -3
  412. package/dist/esm/co-button.entry.js +6 -6
  413. package/dist/esm/co-calendar-month.entry.js +379 -0
  414. package/dist/esm/co-calendar_3.entry.js +12 -12
  415. package/dist/esm/co-card.entry.js +3 -3
  416. package/dist/esm/co-checkbox-group.entry.js +5 -5
  417. package/dist/esm/co-checkbox.entry.js +5 -5
  418. package/dist/esm/co-chip.entry.js +11 -8
  419. package/dist/esm/co-color-picker.entry.js +7 -5
  420. package/dist/esm/co-column-picker.entry.js +3 -3
  421. package/dist/esm/co-combobox.entry.js +7 -7
  422. package/dist/esm/co-command-search.entry.js +151 -12
  423. package/dist/esm/co-data-table-pagination.entry.js +5 -5
  424. package/dist/esm/co-data-table.entry.js +25 -11
  425. package/dist/esm/co-date-picker.entry.js +2 -2
  426. package/dist/esm/co-date-range-picker.entry.js +4 -4
  427. package/dist/esm/co-date-range.entry.js +2 -2
  428. package/dist/esm/co-empty-state.entry.js +2 -2
  429. package/dist/esm/co-event-calendar.entry.js +316 -0
  430. package/dist/esm/co-fab.entry.js +3 -3
  431. package/dist/esm/co-file-field.entry.js +8 -8
  432. package/dist/esm/co-helper-text.entry.js +3 -3
  433. package/dist/esm/co-icon-button.entry.js +5 -5
  434. package/dist/esm/co-icon.entry.js +33 -25
  435. package/dist/esm/co-input.entry.js +6 -6
  436. package/dist/esm/co-json-field.entry.js +10 -6
  437. package/dist/esm/co-lightbox.entry.js +5 -5
  438. package/dist/esm/co-list-footer.entry.js +23 -0
  439. package/dist/esm/co-list-item.entry.js +60 -4
  440. package/dist/esm/co-loader_2.entry.js +290 -0
  441. package/dist/esm/co-menu-divider.entry.js +2 -2
  442. package/dist/esm/co-menu-item.entry.js +17 -10
  443. package/dist/esm/co-menu.entry.js +2 -2
  444. package/dist/esm/co-modal.entry.js +16 -4
  445. package/dist/esm/co-navbar.entry.js +3 -3
  446. package/dist/esm/co-number-field.entry.js +18 -6
  447. package/dist/esm/co-page-header.entry.js +2 -2
  448. package/dist/esm/co-phone-field.entry.js +6 -4
  449. package/dist/esm/co-popover.entry.js +45 -14
  450. package/dist/esm/co-progress-bar.entry.js +8 -4
  451. package/dist/esm/co-progress-circle.entry.js +3 -3
  452. package/dist/esm/co-radio-group.entry.js +4 -4
  453. package/dist/esm/co-radio.entry.js +4 -4
  454. package/dist/esm/co-rating.entry.js +4 -4
  455. package/dist/esm/co-ref-field.entry.js +36 -13
  456. package/dist/esm/co-rich-text-editor.entry.js +1879 -33
  457. package/dist/esm/co-rich-text-toolbar.entry.js +995 -71
  458. package/dist/esm/co-rich-text-viewer.entry.js +55 -19
  459. package/dist/esm/co-row.entry.js +3 -3
  460. package/dist/esm/co-select.entry.js +8 -8
  461. package/dist/esm/co-separator.entry.js +2 -2
  462. package/dist/esm/co-sidebar-nav.entry.js +29 -9
  463. package/dist/esm/co-sidebar.entry.js +3 -3
  464. package/dist/esm/co-skeleton.entry.js +24 -0
  465. package/dist/esm/co-slider.entry.js +3 -3
  466. package/dist/esm/co-switch.entry.js +6 -6
  467. package/dist/esm/co-tab-group.entry.js +2 -2
  468. package/dist/esm/co-tab.entry.js +3 -3
  469. package/dist/esm/co-tags-field.entry.js +19 -13
  470. package/dist/esm/co-textarea.entry.js +11 -7
  471. package/dist/esm/co-toast.entry.js +2 -2
  472. package/dist/esm/co-toggle-button-group.entry.js +4 -4
  473. package/dist/esm/co-toggle-button.entry.js +4 -4
  474. package/dist/esm/co-tooltip.entry.js +51 -16
  475. package/dist/esm/co-transfer-list.entry.js +3 -3
  476. package/dist/esm/co-video.entry.js +837 -0
  477. package/dist/esm/cobalt.js +3 -3
  478. package/dist/esm/{dates-CyYF8IJE.js → dates-tPYikBRJ.js} +1 -1
  479. package/dist/esm/fieldChip-GPikjpYw.js +5 -0
  480. package/dist/esm/{index-BKmfyPZK.js → index-CYsftTKf.js} +45 -21
  481. package/dist/esm/{index-BjAqSidM.js → index-w_Wxgclf.js} +14508 -6305
  482. package/dist/esm/loader.js +3 -3
  483. package/dist/esm/overlayAfterClose-Ch1jfwZ2.js +10 -0
  484. package/dist/{cjs/sanitizer-CjHZAkOm.js → esm/purify.es-B2QLgWrz.js} +1 -110
  485. package/dist/esm/{requiredMark-DFvtYtkE.js → requiredMark-CEbXKHcU.js} +1 -1
  486. package/dist/esm/richTextI18n-B-ckjCUA.js +380 -0
  487. package/dist/esm/toolbar-config-ChibIpZv.js +212 -0
  488. package/dist/esm/tz-B6JZk8fL.js +119 -0
  489. package/dist/types/components/co-autocomplete/co-autocomplete.d.ts +2 -0
  490. package/dist/types/components/co-avatar/co-avatar.d.ts +2 -0
  491. package/dist/types/components/co-avatar-group/co-avatar-group.d.ts +33 -0
  492. package/dist/types/components/co-bottom-sheet/co-bottom-sheet.d.ts +81 -0
  493. package/dist/types/components/co-button/co-button.d.ts +3 -1
  494. package/dist/types/components/co-calendar-month/co-calendar-month.d.ts +83 -0
  495. package/dist/types/components/co-chip/co-chip.d.ts +7 -2
  496. package/dist/types/components/co-color-picker/co-color-picker.d.ts +2 -0
  497. package/dist/types/components/co-command-search/co-command-search.d.ts +39 -6
  498. package/dist/types/components/co-command-search/commandSearchGroup.d.ts +20 -0
  499. package/dist/types/components/co-command-search/commandSearchLogic.d.ts +17 -0
  500. package/dist/types/components/co-data-table/co-data-table.d.ts +2 -1
  501. package/dist/types/components/co-event-calendar/co-event-calendar.d.ts +110 -0
  502. package/dist/types/components/co-icon/co-icon.d.ts +1 -1
  503. package/dist/types/components/co-icon/iconLoader.d.ts +6 -0
  504. package/dist/types/components/co-icon-button/co-icon-button.d.ts +2 -0
  505. package/dist/types/components/co-json-field/co-json-field.d.ts +3 -0
  506. package/dist/types/components/co-list-footer/co-list-footer.d.ts +26 -0
  507. package/dist/types/components/co-list-item/co-list-item.d.ts +11 -0
  508. package/dist/types/components/co-modal/co-modal.d.ts +6 -0
  509. package/dist/types/components/co-number-field/co-number-field.d.ts +13 -0
  510. package/dist/types/components/co-overlay/co-overlay.d.ts +45 -0
  511. package/dist/types/components/co-overlay/focusTrap.d.ts +20 -0
  512. package/dist/types/components/co-overlay/overlayAfterClose.d.ts +5 -0
  513. package/dist/types/components/co-phone-field/co-phone-field.d.ts +2 -0
  514. package/dist/types/components/co-popover/co-popover.d.ts +9 -0
  515. package/dist/types/components/co-progress-bar/co-progress-bar.d.ts +2 -0
  516. package/dist/types/components/co-ref-field/co-ref-field.d.ts +17 -2
  517. package/dist/types/components/co-rich-text-editor/co-rich-text-editor.d.ts +161 -9
  518. package/dist/types/components/co-rich-text-toolbar/co-rich-text-toolbar.d.ts +119 -13
  519. package/dist/types/components/co-rich-text-viewer/co-rich-text-viewer.d.ts +1 -14
  520. package/dist/types/components/co-skeleton/co-skeleton.d.ts +13 -0
  521. package/dist/types/components/co-tags-field/co-tags-field.d.ts +2 -0
  522. package/dist/types/components/co-textarea/co-textarea.d.ts +3 -0
  523. package/dist/types/components/co-tooltip/co-tooltip.d.ts +12 -0
  524. package/dist/types/components/co-video/co-video.d.ts +203 -0
  525. package/dist/types/components.d.ts +1729 -72
  526. package/dist/types/utils/fieldChip.d.ts +37 -0
  527. package/dist/types/utils/icon-config.d.ts +11 -0
  528. package/dist/types/utils/richTextI18n.d.ts +130 -0
  529. package/dist/types/utils/sheetGesture.d.ts +31 -0
  530. package/package.json +3 -2
  531. package/dist/cjs/co-loader.cjs.entry.js +0 -34
  532. package/dist/cjs/co-overlay.cjs.entry.js +0 -23
  533. package/dist/cobalt/p-0a6d8061.entry.js +0 -1
  534. package/dist/cobalt/p-0bf288cd.entry.js +0 -1
  535. package/dist/cobalt/p-136bdbd2.entry.js +0 -1
  536. package/dist/cobalt/p-15708d32.entry.js +0 -1
  537. package/dist/cobalt/p-1578b019.entry.js +0 -1
  538. package/dist/cobalt/p-23d48581.entry.js +0 -1
  539. package/dist/cobalt/p-2718ff27.entry.js +0 -1
  540. package/dist/cobalt/p-2b4d8535.entry.js +0 -1
  541. package/dist/cobalt/p-3190d715.entry.js +0 -1
  542. package/dist/cobalt/p-41228dce.entry.js +0 -1
  543. package/dist/cobalt/p-44672953.entry.js +0 -1
  544. package/dist/cobalt/p-53ce9023.entry.js +0 -1
  545. package/dist/cobalt/p-5e7141aa.entry.js +0 -1
  546. package/dist/cobalt/p-5f905739.entry.js +0 -1
  547. package/dist/cobalt/p-6678ac0a.entry.js +0 -1
  548. package/dist/cobalt/p-66a912dd.entry.js +0 -1
  549. package/dist/cobalt/p-6759ee1c.entry.js +0 -1
  550. package/dist/cobalt/p-69a40bfd.entry.js +0 -1
  551. package/dist/cobalt/p-6a6a62cb.entry.js +0 -1
  552. package/dist/cobalt/p-6d43b6cd.entry.js +0 -1
  553. package/dist/cobalt/p-759c3dd0.entry.js +0 -1
  554. package/dist/cobalt/p-782f729f.entry.js +0 -1
  555. package/dist/cobalt/p-83b89bf8.entry.js +0 -1
  556. package/dist/cobalt/p-88dc561a.entry.js +0 -1
  557. package/dist/cobalt/p-8c27aff7.entry.js +0 -1
  558. package/dist/cobalt/p-996179f7.entry.js +0 -1
  559. package/dist/cobalt/p-9c533830.entry.js +0 -1
  560. package/dist/cobalt/p-9d89bf47.entry.js +0 -1
  561. package/dist/cobalt/p-BKmfyPZK.js +0 -2
  562. package/dist/cobalt/p-BchB6Hdr.js +0 -1
  563. package/dist/cobalt/p-DcK0GGZC.js +0 -2
  564. package/dist/cobalt/p-Qqq8fysz.js +0 -1
  565. package/dist/cobalt/p-aa17c70b.entry.js +0 -1
  566. package/dist/cobalt/p-ad4c1b41.entry.js +0 -1
  567. package/dist/cobalt/p-ae4d3207.entry.js +0 -1
  568. package/dist/cobalt/p-af64da37.entry.js +0 -1
  569. package/dist/cobalt/p-c6a242e4.entry.js +0 -1
  570. package/dist/cobalt/p-cd57e8b4.entry.js +0 -1
  571. package/dist/cobalt/p-ce3a535f.entry.js +0 -1
  572. package/dist/cobalt/p-d958566a.entry.js +0 -1
  573. package/dist/cobalt/p-dd873bf8.entry.js +0 -1
  574. package/dist/cobalt/p-e4de8865.entry.js +0 -1
  575. package/dist/cobalt/p-eba0bf7f.entry.js +0 -1
  576. package/dist/cobalt/p-fad3605d.entry.js +0 -1
  577. package/dist/cobalt/p-ff2690e5.entry.js +0 -1
  578. package/dist/components/p-BXdfh__-.js +0 -1
  579. package/dist/components/p-BchB6Hdr.js +0 -1
  580. package/dist/components/p-BiW0ubLs.js +0 -1
  581. package/dist/components/p-CaMgu2_g.js +0 -1
  582. package/dist/components/p-DBhNS7JD.js +0 -1
  583. package/dist/components/p-DPi_U-Kl.js +0 -1
  584. package/dist/components/p-DcK0GGZC.js +0 -2
  585. package/dist/components/p-MiSJXuBx.js +0 -1
  586. package/dist/components/p-Sgn-2g8m.js +0 -1
  587. package/dist/components/p-jDjfGZJp.js +0 -1
  588. package/dist/components/p-o8hrDIKe.js +0 -1
  589. package/dist/esm/co-loader.entry.js +0 -32
  590. package/dist/esm/co-overlay.entry.js +0 -21
@@ -0,0 +1 @@
1
+ import{p as t}from"./p-B2QLgWrz.js";import{C as e,T as n,t as r}from"./p-ChibIpZv.js";function i(t){this.content=t}function s(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),o=e.child(r);if(i!=o){if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(let t=0;i.text[t]==o.text[t];t++)n++;return n}if(i.content.size||o.content.size){let t=s(i.content,o.content,n+1);if(null!=t)return t}n+=i.nodeSize}else n+=i.nodeSize}}function o(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(0==i||0==s)return i==s?null:{a:n,b:r};let l=t.child(--i),u=e.child(--s),a=l.nodeSize;if(l!=u){if(!l.sameMarkup(u))return{a:n,b:r};if(l.isText&&l.text!=u.text){let t=0,e=Math.min(l.text.length,u.text.length);for(;t<e&&l.text[l.text.length-t-1]==u.text[u.text.length-t-1];)t++,n--,r--;return{a:n,b:r}}if(l.content.size||u.content.size){let t=o(l.content,u.content,n-1,r-1);if(t)return t}n-=a,r-=a}else n-=a,r-=a}}i.prototype={constructor:i,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),o=r.content.slice();return-1==s?o.push(n||t,e):(o[s+1]=e,n&&(o[s]=n)),new i(o)},remove:function(t){var e=this.find(t);if(-1==e)return this;var n=this.content.slice();return n.splice(e,2),new i(n)},addToStart:function(t,e){return new i([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new i(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),o=r.find(t);return s.splice(-1==o?s.length:o,0,e,n),new i(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=i.from(t)).size?new i(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=i.from(t)).size?new i(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=i.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach((function(e,n){t[e]=n})),t},get size(){return this.content.length>>1}},i.from=function(t){if(t instanceof i)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new i(e)};class l{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,n,r=0,i){for(let s=0,o=0;o<e;s++){let l=this.content[s],u=o+l.nodeSize;if(u>t&&!1!==n(l,r+o,i||null,s)&&l.content.size){let i=o+1;l.nodesBetween(Math.max(0,t-i),Math.min(l.content.size,e-i),n,r+i)}o=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,r){let i="",s=!0;return this.nodesBetween(t,e,((o,l)=>{let u=o.isText?o.text.slice(Math.max(t,l)-l,e-l):o.isLeaf?r?"function"==typeof r?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&n&&(s?s=!1:i+=n),i+=u}),0),i}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,n=t.firstChild,r=this.content.slice(),i=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),i=1);i<t.content.length;i++)r.push(t.content[i]);return new l(r,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let n=[],r=0;if(e>t)for(let i=0,s=0;s<e;i++){let o=this.content[i],l=s+o.nodeSize;l>t&&((s<t||l>e)&&(o=o.isText?o.cut(Math.max(0,t-s),Math.min(o.text.length,e-s)):o.cut(Math.max(0,t-s-1),Math.min(o.content.size,e-s-1))),n.push(o),r+=o.nodeSize),s=l}return new l(n,r)}cutByIndex(t,e){return t==e?l.empty:0==t&&e==this.content.length?this:new l(this.content.slice(t,e))}replaceChild(t,e){let n=this.content[t];if(n==e)return this;let r=this.content.slice(),i=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new l(r,i)}addToStart(t){return new l([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new l(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let r=this.content[e];t(r,n,e),n+=r.nodeSize}}findDiffStart(t,e=0){return s(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return o(this,t,e,n)}findIndex(t){if(0==t)return a(0,t);if(t==this.size)return a(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,n=0;;e++){let r=n+this.child(e).nodeSize;if(r>=t)return r==t?a(e+1,r):a(e,n);n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return l.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return l.fromArray(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return l.empty;let e,n=0;for(let r=0;r<t.length;r++){let i=t[r];n+=i.nodeSize,r&&i.isText&&t[r-1].sameMarkup(i)?(e||(e=t.slice(0,r)),e[e.length-1]=i.withText(e[e.length-1].text+i.text)):e&&e.push(i)}return new l(e||t,n)}static from(t){if(!t)return l.empty;if(t instanceof l)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new l([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}l.empty=new l([],0);const u={index:0,offset:0};function a(t,e){return u.index=t,u.offset=e,u}function h(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!h(t[n],e[n]))return!1}else{for(let n in t)if(!(n in e)||!h(t[n],e[n]))return!1;for(let n in e)if(!(n in t))return!1}return!0}let c=class t{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,n=!1;for(let r=0;r<t.length;r++){let i=t[r];if(this.eq(i))return t;if(this.type.excludes(i.type))e||(e=t.slice(0,r));else{if(i.type.excludes(this.type))return t;!n&&i.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(i)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&h(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);let r=n.create(e.attrs);return n.checkAttrs(r.attrs),r}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return t.none;if(e instanceof t)return[e];let n=e.slice();return n.sort(((t,e)=>t.type.rank-e.type.rank)),n}};c.none=[];class f extends Error{}class d{constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let n=m(this.content,t+this.openStart,e,this.openStart+1,this.openEnd+1);return n&&new d(n,this.openStart,this.openEnd)}removeBetween(t,e){return new d(p(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return d.empty;let n=e.openStart||0,r=e.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new d(l.fromJSON(t,e.content),n,r)}static maxOpen(t,e=!0){let n=0,r=0;for(let r=t.firstChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=t.lastChild;n&&!n.isLeaf&&(e||!n.type.spec.isolating);n=n.lastChild)r++;return new d(t,n,r)}}function p(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||s.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(p(s.content,e-i-1,n-i-1)))}function m(t,e,n,r,i,s){let{index:o,offset:l}=t.findIndex(e),u=t.maybeChild(o);if(l==e||u.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=m(u.content,e-l-1,n,0==o?r-1:0,o==t.childCount-1?i-1:0,u);return a&&t.replaceChild(o,u.copy(a))}function g(t,e,n){if(n.openStart>t.depth)throw new f("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new f("Inconsistent open depths");return w(t,e,n,0)}function w(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=w(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=r||e.depth!=r){let{start:i,end:o}=function(t,e){let n=e.depth-t.openStart,r=e.node(n).copy(t.content);for(let t=n-1;t>=0;t--)r=e.node(t).copy(l.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}(n,t);return M(s,T(t,i,o,e,r))}{let r=t.parent,i=r.content;return M(r,i.cut(0,t.parentOffset).append(n.content).append(i.cut(e.parentOffset)))}}return M(s,x(t,e,r))}function b(t,e){if(!e.type.compatibleContent(t.type))throw new f("Cannot join "+e.type.name+" onto "+t.type.name)}function y(t,e,n){let r=t.node(n);return b(r,e.node(n)),r}function v(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function k(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(v(t.nodeAfter,r),s++));for(let t=s;t<o;t++)v(i.child(t),r);e&&e.depth==n&&e.textOffset&&v(e.nodeBefore,r)}function M(t,e){return t.type.checkContent(e),t.copy(e)}function T(t,e,n,r,i){let s=t.depth>i&&y(t,e,i+1),o=r.depth>i&&y(n,r,i+1),u=[];return k(null,t,i,u),s&&o&&e.index(i)==n.index(i)?(b(s,o),v(M(s,T(t,e,n,r,i+1)),u)):(s&&v(M(s,x(t,e,i+1)),u),k(e,n,i,u),o&&v(M(o,x(n,r,i+1)),u)),k(r,null,i,u),new l(u)}function x(t,e,n){let r=[];return k(null,t,n,r),t.depth>n&&v(M(y(t,e,n+1),x(t,e,n+1)),r),k(e,null,n,r),new l(r)}d.empty=new d(l.empty,0,0);class L{constructor(t,e,n){this.pos=t,this.path=e,this.parentOffset=n,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let n=this.path[3*e],r=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)r+=n.child(e).nodeSize;return r}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return c.none;if(this.textOffset)return t.child(e).marks;let n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){let t=n;n=r,r=t}let i=n.marks;for(var s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let n=e.marks,r=t.parent.maybeChild(t.index());for(var i=0;i<n.length;i++)!1!==n[i].type.spec.inclusive||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new O(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let n=[],r=0,i=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(i),o=i-s;if(n.push(e,t,r+s),!o)break;if(e=e.child(t),e.isText)break;i=o-1,r+=s+1}return new L(e,n,i)}static resolveCached(t,e){let n=E.get(t);if(n)for(let t=0;t<n.elts.length;t++){let r=n.elts[t];if(r.pos==e)return r}else E.set(t,n=new S);let r=n.elts[n.i]=L.resolve(t,e);return n.i=(n.i+1)%A,r}}class S{constructor(){this.elts=[],this.i=0}}const A=12,E=new WeakMap;class O{constructor(t,e,n){this.$from=t,this.$to=e,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const $=Object.create(null);let C=class t{constructor(t,e,n,r=c.none){this.type=t,this.attrs=e,this.marks=r,this.content=n||l.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,n,r=0){this.content.nodesBetween(t,e,n,r,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,n,r){return this.content.textBetween(t,e,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,n){return this.type==t&&h(this.attrs,e||t.defaultAttrs||$)&&c.sameSet(this.marks,n||c.none)}copy(e=null){return e==this.content?this:new t(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.content,e)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,n=!1){if(t==e)return d.empty;let r=this.resolve(t),i=this.resolve(e),s=n?0:r.sharedDepth(e),o=r.start(s),l=r.node(s).content.cut(r.pos-o,i.pos-o);return new d(l,r.depth-s,i.depth-s)}replace(t,e,n){return g(this.resolve(t),this.resolve(e),n)}nodeAt(t){for(let e=this;;){let{index:n,offset:r}=e.content.findIndex(t);if(e=e.maybeChild(n),!e)return null;if(r==t||e.isText)return e;t-=r+1}}childAfter(t){let{index:e,offset:n}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:n}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:n}=this.content.findIndex(t);if(n<t)return{node:this.content.child(e),index:e,offset:n};let r=this.content.child(e-1);return{node:r,index:e-1,offset:n-r.nodeSize}}resolve(t){return L.resolveCached(this,t)}resolveNoCache(t){return L.resolve(this,t)}rangeHasMark(t,e,n){let r=!1;return e>t&&this.nodesBetween(t,e,(t=>(n.isInSet(t.marks)&&(r=!0),!r))),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),H(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,n=l.empty,r=0,i=n.childCount){let s=this.contentMatchAt(t).matchFragment(n,r,i),o=s&&s.matchFragment(this.content,e);if(!o||!o.validEnd)return!1;for(let t=r;t<i;t++)if(!this.type.allowsMarks(n.child(t).marks))return!1;return!0}canReplaceWith(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(t).matchType(n),s=i&&i.matchFragment(this.content,e);return!!s&&s.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=c.none;for(let e=0;e<this.marks.length;e++){let n=this.marks[e];n.type.checkAttrs(n.attrs),t=n.addToSet(t)}if(!c.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let n;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}let r=l.fromJSON(t,e.content),i=t.nodeType(e.type).create(e.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};C.prototype.text=void 0;class R extends C{constructor(t,e,n,r){if(super(t,e,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):H(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new R(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new R(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function H(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class N{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let n=new I(t,e);if(null==n.next)return N.empty;let r=P(n);n.next&&n.err("Unexpected trailing text");let i=function(t){let e=Object.create(null);return function n(r){let i=[];r.forEach((e=>{t[e].forEach((({term:e,to:n})=>{if(!e)return;let r;for(let t=0;t<i.length;t++)i[t][0]==e&&(r=i[t][1]);F(t,n).forEach((t=>{r||i.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)}))}))}));let s=e[r.join(",")]=new N(r.indexOf(t.length-1)>-1);for(let t=0;t<i.length;t++){let r=i[t][1].sort(_);s.next.push({type:i[t][0],next:e[r.join(",")]||n(r)})}return s}(F(t,0))}(function(t){let e=[[]];return i(function t(e,s){if("choice"==e.type)return e.exprs.reduce(((e,n)=>e.concat(t(n,s))),[]);if("seq"!=e.type){if("star"==e.type){let o=n();return r(s,o),i(t(e.expr,o),o),[r(o)]}if("plus"==e.type){let o=n();return i(t(e.expr,s),o),i(t(e.expr,o),o),[r(o)]}if("opt"==e.type)return[r(s)].concat(t(e.expr,s));if("range"==e.type){let o=s;for(let r=0;r<e.min;r++){let r=n();i(t(e.expr,o),r),o=r}if(-1==e.max)i(t(e.expr,o),o);else for(let s=e.min;s<e.max;s++){let s=n();r(o,s),i(t(e.expr,o),s),o=s}return[r(o)]}if("name"==e.type)return[r(s,void 0,e.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let o=t(e.exprs[r],s);if(r==e.exprs.length-1)return o;i(o,s=n())}}(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){let i={term:r,to:n};return e[t].push(i),i}function i(t,e){t.forEach((t=>t.to=e))}}(r));return function(t,e){for(let n=0,r=[t];n<r.length;n++){let t=r[n],i=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:n,next:o}=t.next[e];s.push(n.name),!i||n.isText||n.hasRequiredAttrs()||(i=!1),-1==r.indexOf(o)&&r.push(o)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(i,n),i}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let r=this;for(let i=e;r&&i<n;i++)r=r.matchType(t.child(i).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return!0;return!1}fillBefore(t,e=!1,n=0){let r=[this];return function i(s,o){let u=s.matchFragment(t,n);if(u&&(!e||u.validEnd))return l.from(o.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:n}=s.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let t=i(n,o.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(t)){let t=[];for(let e=r;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<i.next.length;t++){let{type:s,next:o}=i.next[t];s.isLeaf||s.hasRequiredAttrs()||s.name in e||r.type&&!o.validEnd||(n.push({match:s.contentMatch,type:s,via:r}),e[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(n){t.push(n);for(let r=0;r<n.next.length;r++)-1==t.indexOf(n.next[r].next)&&e(n.next[r].next)}(this),t.map(((e,n)=>{let r=n+(e.validEnd?"*":" ")+" ";for(let n=0;n<e.next.length;n++)r+=(n?", ":"")+e.next[n].type.name+"->"+t.indexOf(e.next[n].next);return r})).join("\n")}}N.empty=new N(!0);class I{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function P(t){let e=[];do{e.push(D(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function D(t){let e=[];do{e.push(B(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function B(t){let e=function(t){if(t.eat("(")){let e=P(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let t in n){let r=n[t];r.isInGroup(e)&&i.push(r)}return 0==i.length&&t.err("No node type or group '"+e+"' found"),i}(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=z(t,e)}return e}function j(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function z(t,e){let n=j(t),r=n;return t.eat(",")&&(r="}"!=t.next?j(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function _(t,e){return e-t}function F(t,e){let n=[];return function e(r){let i=t[r];if(1==i.length&&!i[0].term)return e(i[0].to);n.push(r);for(let t=0;t<i.length;t++){let{term:r,to:s}=i[t];r||-1!=n.indexOf(s)||e(s)}}(e),n.sort(_)}function W(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function K(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(void 0===i){let e=t[r];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=e.default}n[r]=i}return n}function U(t,e,n){for(let r in e)if(!(r in t))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in t){let r=t[n];r.validate&&r.validate(e[n])}}function J(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new V(t,r,e[r]);return n}let q=class t{constructor(t,e,n){this.name=t,this.schema=e,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=J(t,n.attrs),this.defaultAttrs=W(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==N.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:K(this.attrs,t)}create(t=null,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new C(this,this.computeAttrs(t),l.from(e),c.setFrom(n))}createChecked(t=null,e,n){return e=l.from(e),this.checkContent(e),new C(this,this.computeAttrs(t),e,c.setFrom(n))}createAndFill(t=null,e,n){if(t=this.computeAttrs(t),(e=l.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let r=this.contentMatch.matchFragment(e),i=r&&r.fillBefore(l.empty,!0);return i?new C(this,t,e.append(i),c.setFrom(n)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){U(this.attrs,t,"node")}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:c.none:t}static compile(e,n){let r=Object.create(null);e.forEach(((e,i)=>r[e]=new t(e,n,i)));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let t in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class V{constructor(t,e,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(t,e,n){let r=n.split("|");return n=>{let i=null===n?"null":typeof n;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}(t,e,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class G{constructor(t,e,n,r){this.name=t,this.rank=e,this.schema=n,this.spec=r,this.attrs=J(t,r.attrs),this.excluded=null;let i=W(this.attrs);this.instance=i?new c(this,i):null}create(t=null){return!t&&this.instance?this.instance:new c(this,K(this.attrs,t))}static compile(t,e){let n=Object.create(null),r=0;return t.forEach(((t,i)=>n[t]=new G(t,r++,e,i))),n}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){U(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class X{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let n in t)e[n]=t[n];e.nodes=i.from(t.nodes),e.marks=i.from(t.marks||{}),this.nodes=q.compile(this.spec.nodes,this),this.marks=G.compile(this.spec.marks,this);let n=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],r=e.spec.content||"",i=e.spec.marks;if(e.contentMatch=n[r]||(n[r]=N.parse(r,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==i?null:i?Q(this,i.split(" ")):""!=i&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],n=e.spec.excludes;e.excluded=null==n?[e]:""==n?[]:Q(this,n.split(" "))}this.nodeFromJSON=t=>C.fromJSON(this,t),this.markFromJSON=t=>c.fromJSON(this,t),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof q))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,r)}text(t,e){let n=this.nodes.text;return new R(n,n.defaultAttrs,t,c.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function Q(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);else for(let e in t.marks){let r=t.marks[e];("_"==i||r.spec.group&&r.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=r)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}class Z{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let n=this.matchedStyles=[];e.forEach((t=>{if(function(t){return null!=t.tag}(t))this.tags.push(t);else if(function(t){return null!=t.style}(t)){let e=/[^=]*/.exec(t.style)[0];n.indexOf(e)<0&&n.push(e),this.styles.push(t)}})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let n=t.nodes[e.node];return n.contentMatch.matchType(n)}))}parse(t,e={}){let n=new it(this,e,!1);return n.addAll(t,c.none,e.from,e.to),n.finish()}parseSlice(t,e={}){let n=new it(this,e,!0);return n.addAll(t,c.none,e.from,e.to),d.maxOpen(n.finish())}matchTag(t,e,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(st(t,n.tag)&&(void 0===n.namespace||t.namespaceURI==n.namespace)&&(!n.context||e.matchesContext(n.context))){if(n.getAttrs){let e=n.getAttrs(t);if(!1===e)continue;n.attrs=e||void 0}return n}}}matchStyle(t,e,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],s=r.style;if(!(0!=s.indexOf(t)||r.context&&!n.matchesContext(r.context)||s.length>t.length&&(61!=s.charCodeAt(t.length)||s.slice(t.length+1)!=e))){if(r.getAttrs){let t=r.getAttrs(e);if(!1===t)continue;r.attrs=t||void 0}return r}}}static schemaRules(t){let e=[];function n(t){let n=null==t.priority?50:t.priority,r=0;for(;r<e.length;r++){let t=e[r];if((null==t.priority?50:t.priority)<n)break}e.splice(r,0,t)}for(let e in t.marks){let r=t.marks[e].spec.parseDOM;r&&r.forEach((t=>{n(t=ot(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)}))}for(let e in t.nodes){let r=t.nodes[e].spec.parseDOM;r&&r.forEach((t=>{n(t=ot(t)),t.node||t.ignore||t.mark||(t.node=e)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Z(t,Z.schemaRules(t)))}}const Y={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},tt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},et={ol:!0,ul:!0};function nt(t,e,n){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&n}class rt{constructor(t,e,n,r,i,s){this.type=t,this.attrs=e,this.marks=n,this.solid=r,this.options=s,this.content=[],this.activeMarks=c.none,this.match=i||(4&s?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(l.from(t));if(!e){let e,n=this.type.contentMatch;return(e=n.findWrapping(t.type))?(this.match=n,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let e=l.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(l.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Y.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class it{constructor(t,e,n){this.parser=t,this.options=e,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,i=e.topNode,s=nt(null,e.preserveWhitespace,0)|(n?4:0);r=i?new rt(i.type,i.attrs,c.none,!0,e.topMatch||i.type.contentMatch,s):new rt(n?null:t.schema.topNodeType,null,c.none,!0,null,s),this.nodes=[r],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){3==t.nodeType?this.addTextNode(t,e):1==t.nodeType&&this.addElement(t,e)}addTextNode(t,e){let n=t.nodeValue,r=this.top,i=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:s}=this.parser;if("full"===i||r.inlineContext(t)||/[^ \t\r\n\u000c]/.test(n)){if(i)if("full"===i)n=n.replace(/\r\n?/g,"\n");else if(s.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(s.linebreakReplacement.create())){let t=n.split(/\r?\n|\r/);for(let n=0;n<t.length;n++)n&&this.insertNode(s.linebreakReplacement.create(),e,!0),t[n]&&this.insertNode(s.text(t[n]),e,!/\S/.test(t[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let e=r.content[r.content.length-1],i=t.previousSibling;(!e||i&&"BR"==i.nodeName||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))&&(n=n.slice(1))}n&&this.insertNode(s.text(n),e,!/\S/.test(n)),this.findInText(t)}else this.findInside(t)}addElement(t,e,n){let r=this.localPreserveWS,i=this.top;("PRE"==t.tagName||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let s,o=t.nodeName.toLowerCase();et.hasOwnProperty(o)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&et.hasOwnProperty(t)&&n?(n.appendChild(e),e=n):"li"==t?n=e:t&&(n=null)}}(t);let l=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(s=this.parser.matchTag(t,this,n));t:if(l?l.ignore:tt.hasOwnProperty(o))this.findInside(t),this.ignoreFallback(t,e);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(t=l.skip);let n,r=this.needsBlock;if(Y.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,e);break t}let s=l&&l.skip?e:this.readStyles(t,e);s&&this.addAll(t,s),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(t,e);n&&this.addElementByRule(t,l,n,!1===l.consuming?s:void 0)}this.localPreserveWS=r}leafFallback(t,e){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),e,!0)}readStyles(t,e){let n=t.style;if(n&&n.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let r=this.parser.matchedStyles[t],i=n.getPropertyValue(r);if(i)for(let t;;){let n=this.parser.matchStyle(r,i,this,t);if(!n)break;if(n.ignore)return null;if(e=n.clearMark?e.filter((t=>!n.clearMark(t))):e.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;t=n}}return e}addElementByRule(t,e,n,r){let i,s;if(e.node)if(s=this.parser.schema.nodes[e.node],s.isLeaf)this.insertNode(s.create(e.attrs),n,"BR"==t.nodeName)||this.leafFallback(t,n);else{let t=this.enter(s,e.attrs||null,n,e.preserveWhitespace);t&&(i=!0,n=t)}else n=n.concat(this.parser.schema.marks[e.mark].create(e.attrs));let o=this.top;if(s&&s.isLeaf)this.findInside(t);else if(r)this.addElement(t,n,r);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,n,!1)));else{let r=t;"string"==typeof e.contentElement?r=t.querySelector(e.contentElement):"function"==typeof e.contentElement?r=e.contentElement(t):e.contentElement&&(r=e.contentElement),this.findAround(t,r,!0),this.addAll(r,n),this.findAround(t,r,!1)}i&&this.sync(o)&&this.open--}addAll(t,e,n,r){let i=n||0;for(let s=n?t.childNodes[n]:t.firstChild,o=null==r?null:t.childNodes[r];s!=o;s=s.nextSibling,++i)this.findAtPoint(t,i),this.addDOM(s,e);this.findAtPoint(t,i)}findPlace(t,e,n){let r,i;for(let e=this.open,s=0;e>=0;e--){let o=this.nodes[e],l=o.findWrapping(t);if(l&&(!r||r.length>l.length+s)&&(r=l,i=o,!l.length))break;if(o.solid){if(n)break;s+=2}}if(!r)return null;this.sync(i);for(let t=0;t<r.length;t++)e=this.enterInner(r[t],null,e,!1);return e}insertNode(t,e,n){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&(e=this.enterInner(t,null,e))}let r=this.findPlace(t,e,n);if(r){this.closeExtra();let e=this.top;e.match&&(e.match=e.match.matchType(t.type));let n=c.none;for(let i of r.concat(t.marks))(e.type?e.type.allowsMarkType(i.type):lt(i.type,t.type))&&(n=i.addToSet(n));return e.content.push(t.mark(n)),!0}return!1}enter(t,e,n,r){let i=this.findPlace(t.create(e),n,!1);return i&&(i=this.enterInner(t,e,n,!0,r)),i}enterInner(t,e,n,r=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let o=nt(t,i,s.options);4&s.options&&0==s.content.length&&(o|=4);let l=c.none;return n=n.filter((e=>!(s.type?s.type.allowsMarkType(e.type):lt(e.type,t))||(l=e.addToSet(l),!1))),this.nodes.push(new rt(t,e,l,r,null,o)),this.open++,n}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(t){for(let e=this.open;e>=0;e--){if(this.nodes[e]==t)return this.open=e,!0;this.localPreserveWS&&(this.nodes[e].options|=1)}return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let n=this.nodes[e].content;for(let e=n.length-1;e>=0;e--)t+=n[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,n){if(t!=e&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==t.nodeType&&t.contains(this.find[r].node)&&e.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),i=(r?0:1)-(n?n.depth+1:0),s=(t,o)=>{for(;t>=0;t--){let l=e[t];if(""==l){if(t==e.length-1||0==t)continue;for(;o>=i;o--)if(s(t-1,o))return!0;return!1}{let t=o>0||0==o&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!t||t.name!=l&&!t.isInGroup(l))return!1;o--}}return!0};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function st(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ot(t){let e={};for(let n in t)e[n]=t[n];return e}function lt(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=t=>{s.push(t);for(let n=0;n<t.edgeCount;n++){let{type:r,next:i}=t.edge(n);if(r==e)return!0;if(s.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}class ut{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},n){n||(n=ht(e).createDocumentFragment());let r=n,i=[];return t.forEach((t=>{if(i.length||t.marks.length){let n=0,s=0;for(;n<i.length&&s<t.marks.length;){let e=t.marks[s];if(this.marks[e.type.name]){if(!e.eq(i[n][0])||!1===e.type.spec.spanning)break;n++,s++}else s++}for(;n<i.length;)r=i.pop()[1];for(;s<t.marks.length;){let n=t.marks[s++],o=this.serializeMark(n,t.isInline,e);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(t,e))})),n}serializeNodeInner(t,e){if(t.isText)return ht(e).createTextNode(t.text);let{dom:n,contentDOM:r}=ft(ht(e),this.nodes[t.type.name](t),null,t.attrs);if(r){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,r)}return n}serializeNode(t,e={}){let n=this.serializeNodeInner(t,e);for(let r=t.marks.length-1;r>=0;r--){let i=this.serializeMark(t.marks[r],t.isInline,e);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(t,e,n={}){let r=this.marks[t.type.name];return r&&ft(ht(n),r(t,e),null,t.attrs)}static renderSpec(t,e,n=null,r){return"string"==typeof e?{dom:t.createTextNode(e)}:ft(t,e,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new ut(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=at(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return at(t.marks)}}function at(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function ht(t){return t.document||window.document}const ct=new WeakMap;function ft(t,e,n,r){if(1==e.nodeType)return{dom:e};if(e.dom&&1==e.dom.nodeType)return e;let i,s=e[0];if("string"!=typeof s)throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=function(t){let e=ct.get(t);return void 0===e&&ct.set(t,e=function(t){let e=null;return function t(n){if(n&&"object"==typeof n)if(Array.isArray(n))if("string"==typeof n[0])e||(e=[]),e.push(n);else for(let e=0;e<n.length;e++)t(n[e]);else for(let e in n)t(n[e])}(t),e}(t)),e}(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o,l=s.indexOf(" ");l>0&&(n=s.slice(0,l),s=s.slice(l+1));let u=n?t.createElementNS(n,s):t.createElement(s),a=e[1],h=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a)){h=2;for(let t in a)if(null!=a[t]){let e=t.indexOf(" ");e>0?u.setAttributeNS(t.slice(0,e),t.slice(e+1),a[t]):"style"==t&&u.style?u.style.cssText=a[t]:u.setAttribute(t,a[t])}}for(let i=h;i<e.length;i++){let s=e[i];if(0===s){if(i<e.length-1||i>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}if("string"==typeof s)u.appendChild(t.createTextNode(s));else{let{dom:e,contentDOM:i}=ft(t,s,n,r);if(u.appendChild(e),i){if(o)throw new RangeError("Multiple content holes");o=i}}}return{dom:u,contentDOM:o}}const dt=Math.pow(2,16);function pt(t,e){return t+e*dt}function mt(t){return 65535&t}class gt{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class wt{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&wt.empty)return wt.empty}recover(t){let e=0,n=mt(t);if(!this.inverted)for(let t=0;t<n;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/dt}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,n){let r=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?r:0);if(l>t)break;let u=this.ranges[o+i],a=this.ranges[o+s],h=l+u;if(t<=h){let i=l+r+((u?t==l?-1:t==h?1:e:e)<0?0:a);if(n)return i;let s=t==(e<0?l:h)?null:pt(o/3,t-l),c=t==l?2:t==h?1:4;return(e<0?t!=l:t!=h)&&(c|=8),new gt(i,c,s)}r+=a-u}return n?t+r:new gt(t+r,0,null)}touches(t,e){let n=0,r=mt(e),i=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let o=this.ranges[e]-(this.inverted?n:0);if(o>t)break;let l=this.ranges[e+i];if(t<=o+l&&e==3*r)return!0;n+=this.ranges[e+s]-l}return!1}forEach(t){let e=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let s=this.ranges[r],o=s-(this.inverted?i:0),l=s+(this.inverted?0:i),u=this.ranges[r+e],a=this.ranges[r+n];t(o,o+u,l,l+a),i+=a-u}}invert(){return new wt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?wt.empty:new wt(t<0?[0,-t,0]:[0,0,t])}}wt.empty=new wt([]);class bt{constructor(t,e,n=0,r=(t?t.length:0)){this.mirror=e,this.from=n,this.to=r,this._maps=t||[],this.ownData=!(t||e)}get maps(){return this._maps}slice(t=0,e=this.maps.length){return new bt(this._maps,this.mirror,t,e)}appendMap(t,e){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),null!=e&&this.setMirror(this._maps.length-1,e)}appendMapping(t){for(let e=0,n=this._maps.length;e<t._maps.length;e++){let r=t.getMirror(e);this.appendMap(t._maps[e],null!=r&&r<e?n+r:void 0)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,n=this._maps.length+t._maps.length;e>=0;e--){let r=t.getMirror(e);this.appendMap(t._maps[e].invert(),null!=r&&r>e?n-r-1:void 0)}}invert(){let t=new bt;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let n=this.from;n<this.to;n++)t=this._maps[n].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,!1)}_map(t,e,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(t,e);if(null!=i.recover){let e=this.getMirror(n);if(null!=e&&e>n&&e<this.to){n=e,t=this._maps[e].recover(i.recover);continue}}r|=i.delInfo,t=i.pos}return n?t:new gt(t,r,null)}}const yt=Object.create(null);class vt{getMap(){return wt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=yt[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in yt)throw new RangeError("Duplicate use of step JSON ID "+t);return yt[t]=e,e.prototype.jsonID=t,e}}class kt{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new kt(t,null)}static fail(t){return new kt(null,t)}static fromReplace(t,e,n,r){try{return kt.ok(t.replace(e,n,r))}catch(t){if(t instanceof f)return kt.fail(t.message);throw t}}}function Mt(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(Mt(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return l.fromArray(r)}class Tt extends vt{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=t.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new d(Mt(e.content,((t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t),r),e.openStart,e.openEnd);return kt.fromReplace(t,this.from,this.to,i)}invert(){return new xt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new Tt(e.pos,n.pos,this.mark)}merge(t){return t instanceof Tt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Tt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Tt(e.from,e.to,t.markFromJSON(e.mark))}}vt.jsonID("addMark",Tt);class xt extends vt{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=new d(Mt(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return kt.fromReplace(t,this.from,this.to,n)}invert(){return new Tt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new xt(e.pos,n.pos,this.mark)}merge(t){return t instanceof xt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new xt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new xt(e.from,e.to,t.markFromJSON(e.mark))}}vt.jsonID("removeMark",xt);class Lt extends vt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return kt.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return kt.fromReplace(t,this.pos,this.pos+1,new d(l.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let n=0;n<e.marks.length;n++)if(!e.marks[n].isInSet(t))return new Lt(this.pos,e.marks[n]);return new Lt(this.pos,this.mark)}}return new St(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Lt(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Lt(e.pos,t.markFromJSON(e.mark))}}vt.jsonID("addNodeMark",Lt);class St extends vt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return kt.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return kt.fromReplace(t,this.pos,this.pos+1,new d(l.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new Lt(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new St(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new St(e.pos,t.markFromJSON(e.mark))}}vt.jsonID("removeNodeMark",St);class At extends vt{constructor(t,e,n,r=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=r}apply(t){return this.structure&&Ot(t,this.from,this.to)?kt.fail("Structure replace would overwrite content"):kt.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new wt([this.from,this.to-this.from,this.slice.size])}invert(t){return new At(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.to,-1),n=this.from==this.to&&At.MAP_BIAS<0?e:t.mapResult(this.from,1);return n.deletedAcross&&e.deletedAcross?null:new At(n.pos,Math.max(n.pos,e.pos),this.slice,this.structure)}merge(t){if(!(t instanceof At)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let e=this.slice.size+t.slice.size==0?d.empty:new d(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new At(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?d.empty:new d(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new At(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new At(e.from,e.to,d.fromJSON(t,e.slice),!!e.structure)}}At.MAP_BIAS=1,vt.jsonID("replace",At);class Et extends vt{constructor(t,e,n,r,i,s,o=!1){super(),this.from=t,this.to=e,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=s,this.structure=o}apply(t){if(this.structure&&(Ot(t,this.from,this.gapFrom)||Ot(t,this.gapTo,this.to)))return kt.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return kt.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,e.content);return n?kt.fromReplace(t,this.from,this.to,n):kt.fail("Content does not fit in gap")}getMap(){return new wt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new Et(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1),r=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1),i=this.to==this.gapTo?n.pos:t.map(this.gapTo,1);return e.deletedAcross&&n.deletedAcross||r<e.pos||i>n.pos?null:new Et(e.pos,n.pos,r,i,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Et(e.from,e.to,e.gapFrom,e.gapTo,d.fromJSON(t,e.slice),e.insert,!!e.structure)}}function Ot(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let t=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,i--}}return!1}function $t(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),o=[],u=e+1;for(let e=0;e<s.childCount;e++){let a=s.child(e),h=u+a.nodeSize,c=r.matchType(a.type);if(c){r=c;for(let e=0;e<a.marks.length;e++)n.allowsMarkType(a.marks[e].type)||t.step(new xt(u,h,a.marks[e]));if(i&&a.isText&&"pre"!=n.whitespace){let t,e,r=/\r?\n|\r/g;for(;t=r.exec(a.text);)e||(e=new d(l.from(n.schema.text(" ",n.allowedMarks(a.marks))),0,0)),o.push(new At(u+t.index,u+t.index+t[0].length,e))}}else o.push(new At(u,h,d.empty));u=h}if(!r.validEnd){let e=r.fillBefore(l.empty,!0);t.replace(u,u,new d(e,0,0))}for(let e=o.length-1;e>=0;e--)t.step(o[e])}function Ct(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Rt(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth,r=0,i=0;;--n){let s=t.$from.node(n),o=t.$from.index(n)+r,l=t.$to.indexAfter(n)-i;if(n<t.depth&&s.canReplace(o,l,e))return n;if(0==n||s.type.spec.isolating||!Ct(s,o,l))break;o&&(r=1),l<s.childCount&&(i=1)}return null}function Ht(t,e,n=null,r=t){let i=function(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);return s&&n.canReplaceWith(r,i,s.length?s[0]:e)?s:null}(t,e),s=i&&function(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let l=(o.length?o[o.length-1]:e).contentMatch;for(let t=r;l&&t<i;t++)l=l.matchType(n.child(t).type);return l&&l.validEnd?o:null}(r,e);return s?i.map(Nt).concat({type:e,attrs:n}).concat(s.map(Nt)):null}function Nt(t){return{type:t,attrs:null}}function It(t,e,n,r){e.forEach(((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let i=t.mapping.slice(r).map(n+1+s+o.index);t.replaceWith(i,i+1,e.type.schema.linebreakReplacement.create())}}}))}function Pt(t,e,n,r){e.forEach(((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let i=t.mapping.slice(r).map(n+1+s);t.replaceWith(i,i+1,e.type.schema.text("\n"))}}))}function Dt(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let t=i.depth-1,e=n-2;t>s;t--,e--){let n=i.node(t),s=i.index(t);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(s,n.childCount),l=r&&r[e+1];l&&(o=o.replaceChild(0,l.type.create(l.attrs)));let u=r&&r[e]||n;if(!n.canReplace(s+1,n.childCount)||!u.type.validContent(o))return!1}let l=i.indexAfter(s),u=r&&r[0];return i.node(s).canReplaceWith(l,l,u?u.type:i.node(s+1).type)}function Bt(t,e){let n=t.resolve(e),r=n.index();return jt(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function jt(t,e){return!(!t||!e||t.isLeaf||!function(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i);if(n=n.matchType(s.type==r?t.type.schema.nodes.text:s.type),!n)return!1;if(!t.type.allowsMarks(s.marks))return!1}return n.validEnd}(t,e))}function zt(t,e,n=-1){let r=t.resolve(e);for(let t=r.depth;;t--){let i,s,o=r.index(t);if(t==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(t+1),o++,s=r.node(t).maybeChild(o)):(i=r.node(t).maybeChild(o-1),s=r.node(t+1)),i&&!i.isTextblock&&jt(i,s)&&r.node(t).canReplace(o,o+1))return e;if(0==t)break;e=n<0?r.before(t):r.after(t)}}function _t(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let t=0;t<n.openStart;t++)i=i.firstChild.content;for(let t=1;t<=(0==n.openStart&&n.size?2:1);t++)for(let e=r.depth;e>=0;e--){let n=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1,s=r.index(e)+(n>0?1:0),o=r.node(e),l=!1;if(1==t)l=o.canReplace(s,s,i);else{let t=o.contentMatchAt(s).findWrapping(i.firstChild.type);l=t&&o.canReplaceWith(s,s,t[0])}if(l)return 0==n?r.pos:n<0?r.before(e+1):r.after(e+1)}return null}function Ft(t,e,n=e,r=d.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return Wt(i,s,r)?new At(e,n,r):new Kt(i,s,r).fit()}function Wt(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}vt.jsonID("replaceAround",Et);class Kt{constructor(t,e,n){this.$from=t,this.$to=e,this.unplaced=n,this.frontier=[],this.placed=l.empty;for(let e=0;e<=t.depth;e++){let n=t.node(e);this.frontier.push({type:n.type,match:n.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=l.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(t<0?this.$to:n.doc.resolve(t));if(!r)return null;let i=this.placed,s=n.depth,o=r.depth;for(;s&&o&&1==i.childCount;)i=i.firstChild.content,s--,o--;let l=new d(i,s,o);return t>-1?new Et(n.pos,t,this.$to.pos,this.$to.end(),l,e):l.size||n.pos!=this.$to.pos?new At(n.pos,r.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<t;n++){let i=e.firstChild;if(e.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){t=n;break}e=i.content}for(let e=1;e<=2;e++)for(let n=1==e?t:this.unplaced.openStart;n>=0;n--){let t,r=null;n?(r=qt(this.unplaced.content,n-1).firstChild,t=r.content):t=this.unplaced.content;let i=t.firstChild;for(let t=this.depth;t>=0;t--){let s,{type:o,match:u}=this.frontier[t],a=null;if(1==e&&(i?u.matchType(i.type)||(a=u.fillBefore(l.from(i),!1)):r&&o.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:t,parent:r,inject:a};if(2==e&&i&&(s=u.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:t,parent:r,wrap:s};if(r&&u.matchType(r.type))break}}}openMore(){let{content:t,openStart:e,openEnd:n}=this.unplaced,r=qt(t,e);return!(!r.childCount||r.firstChild.isLeaf||(this.unplaced=new d(t,e+1,Math.max(n,r.size+e>=t.size-n?e+1:0)),0))}dropNode(){let{content:t,openStart:e,openEnd:n}=this.unplaced,r=qt(t,e);if(r.childCount<=1&&e>0){let i=t.size-e<=e+r.size;this.unplaced=new d(Ut(t,e-1,1),e-1,i?e-1:n)}else this.unplaced=new d(Ut(t,e,1),e,n)}placeNodes({sliceDepth:t,frontierDepth:e,parent:n,inject:r,wrap:i}){for(;this.depth>e;)this.closeFrontierNode();if(i)for(let t=0;t<i.length;t++)this.openFrontierNode(i[t]);let s=this.unplaced,o=n?n.content:s.content,u=s.openStart-t,a=0,h=[],{match:c,type:f}=this.frontier[e];if(r){for(let t=0;t<r.childCount;t++)h.push(r.child(t));c=c.matchFragment(r)}let p=o.size+t-(s.content.size-s.openEnd);for(;a<o.childCount;){let t=o.child(a),e=c.matchType(t.type);if(!e)break;a++,(a>1||0==u||t.content.size)&&(c=e,h.push(Vt(t.mark(f.allowedMarks(t.marks)),1==a?u:0,a==o.childCount?p:-1)))}let m=a==o.childCount;m||(p=-1),this.placed=Jt(this.placed,e,l.from(h)),this.frontier[e].match=c,m&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=o;t<p;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=m?0==t?d.empty:new d(Ut(s.content,t-1,1),t-1,p<0?s.openEnd:t-1):new d(Ut(s.content,t,a),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!Gt(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:n,type:r}=this.frontier[e],i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=Gt(t,e,r,n,i);if(s){for(let n=e-1;n>=0;n--){let{match:e,type:r}=this.frontier[n],i=Gt(t,n,r,e,!0);if(!i||i.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=Jt(this.placed,e.depth,e.fit)),t=e.move;for(let n=e.depth+1;n<=t.depth;n++){let e=t.node(n),r=e.type.contentMatch.fillBefore(e.content,!0,t.index(n));this.openFrontierNode(e.type,e.attrs,r)}return t}openFrontierNode(t,e=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=Jt(this.placed,this.depth,l.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(l.empty,!0);t.childCount&&(this.placed=Jt(this.placed,this.frontier.length,t))}}function Ut(t,e,n){return 0==e?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Ut(t.firstChild.content,e-1,n)))}function Jt(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Jt(t.lastChild.content,e-1,n)))}function qt(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Vt(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Vt(r.firstChild,e-1,1==r.childCount?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(l.empty,!0)))),t.copy(r)}function Gt(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!function(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}(n,s.content,o)?l:null}function Xt(t,e,n,r,i){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Xt(i.content,e+1,n,r,i)))}if(e>r){let e=i.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(l.empty,!0))}return t}function Qt(t,e){let n=[];for(let r=Math.min(t.depth,e.depth);r>=0;r--){let i=t.start(r);if(i<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(i==e.start(r)||r==t.depth&&r==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==i-1)&&n.push(r)}return n}class Zt extends vt{constructor(t,e,n){super(),this.pos=t,this.attr=e,this.value=n}apply(t){let e=t.nodeAt(this.pos);if(!e)return kt.fail("No node at attribute step's position");let n=Object.create(null);for(let t in e.attrs)n[t]=e.attrs[t];n[this.attr]=this.value;let r=e.type.create(n,null,e.marks);return kt.fromReplace(t,this.pos,this.pos+1,new d(l.from(r),0,e.isLeaf?0:1))}getMap(){return wt.empty}invert(t){return new Zt(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Zt(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Zt(e.pos,e.attr,e.value)}}vt.jsonID("attr",Zt);class Yt extends vt{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let n in t.attrs)e[n]=t.attrs[n];e[this.attr]=this.value;let n=t.type.create(e,t.content,t.marks);return kt.ok(n)}getMap(){return wt.empty}invert(t){return new Yt(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if("string"!=typeof e.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Yt(e.attr,e.value)}}vt.jsonID("docAttr",Yt);let te=class extends Error{};te=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},(te.prototype=Object.create(Error.prototype)).constructor=te,te.prototype.name="TransformError";class ee{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new bt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new te(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}changedRange(){let t=1e9,e=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(t=r.map(t,1),e=r.map(e,-1)),r.forEach(((n,r,i,s)=>{t=Math.min(t,i),e=Math.max(e,s)}))}return 1e9==t?null:{from:t,to:e}}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,n=d.empty){let r=Ft(this.doc,t,e,n);return r&&this.step(r),this}replaceWith(t,e,n){return this.replace(t,e,new d(l.from(n),0,0))}delete(t,e){return this.replace(t,e,d.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,n){return function(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(Wt(i,s,r))return t.step(new At(e,n,r));let o=Qt(i,s);0==o[o.length-1]&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let t=i.depth,e=i.pos-1;t>0;t--,e--){let n=i.node(t).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(t)>-1?l=t:i.before(t)==e&&o.splice(1,0,-t)}let u=o.indexOf(l),a=[],h=r.openStart;for(let t=r.content,e=0;;e++){let n=t.firstChild;if(a.push(n),e==r.openStart)break;t=n.content}for(let t=h-1;t>=0;t--){let e=a[t],n=(c=e.type).spec.defining||c.spec.definingForContent;if(n&&!e.sameMarkup(i.node(Math.abs(l)-1)))h=t;else if(n||!e.type.isTextblock)break}var c;for(let e=r.openStart;e>=0;e--){let l=(e+h+1)%(r.openStart+1),c=a[l];if(c)for(let e=0;e<o.length;e++){let a=o[(e+u)%o.length],h=!0;a<0&&(h=!1,a=-a);let f=i.node(a-1),p=i.index(a-1);if(f.canReplaceWith(p,p,c.type,c.marks))return t.replace(i.before(a),h?s.after(a):n,new d(Xt(r.content,0,r.openStart,l),l,r.openEnd))}}let f=t.steps.length;for(let l=o.length-1;l>=0&&(t.replace(e,n,r),!(t.steps.length>f));l--){let t=o[l];t<0||(e=i.before(t),n=s.after(t))}}(this,t,e,n),this}replaceRangeWith(t,e,n){return function(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=function(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(0==r.parentOffset)for(let t=r.depth-1;t>=0;t--){let e=r.index(t);if(r.node(t).canReplaceWith(e,e,n))return r.before(t+1);if(e>0)return null}if(r.parentOffset==r.parent.content.size)for(let t=r.depth-1;t>=0;t--){let e=r.indexAfter(t);if(r.node(t).canReplaceWith(e,e,n))return r.after(t+1);if(e<r.node(t).childCount)return null}return null}(t.doc,e,r.type);null!=i&&(e=n=i)}t.replaceRange(e,n,new d(l.from(r),0,0))}(this,t,e,n),this}deleteRange(t,e){return function(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&0==r.parentOffset&&0==i.parentOffset){let s=r.sharedDepth(n),o=!1;for(let t=r.depth;t>s;t--)r.node(t).type.spec.isolating&&(o=!0);for(let t=i.depth;t>s;t--)i.node(t).type.spec.isolating&&(o=!0);if(!o){for(let t=r.depth;t>0&&e==r.start(t);t--)e=r.before(t);for(let t=i.depth;t>0&&n==i.start(t);t--)n=i.before(t);r=t.doc.resolve(e),i=t.doc.resolve(n)}}let s=Qt(r,i);for(let e=0;e<s.length;e++){let n=s[e],o=e==s.length-1;if(o&&0==n||r.node(n).type.contentMatch.validEnd)return t.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return t.delete(r.before(n),i.after(n))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}(this,t,e),this}lift(t,e){return function(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),u=i.after(s+1),a=o,h=u,c=l.empty,f=0;for(let t=s,e=!1;t>n;t--)e||r.index(t)>0?(e=!0,c=l.from(r.node(t).copy(c)),f++):a--;let p=l.empty,m=0;for(let t=s,e=!1;t>n;t--)e||i.after(t+1)<i.end(t)?(e=!0,p=l.from(i.node(t).copy(p)),m++):h++;t.step(new Et(a,h,o,u,new d(c.append(p),f,m),c.size-f,!0))}(this,t,e),this}join(t,e=1){return function(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),o=s.node().type;if(i&&o.inlineContent){let t="pre"==o.whitespace,e=!!o.contentMatch.matchType(i);t&&!e?r=!1:!t&&e&&(r=!0)}let l=t.steps.length;if(!1===r){let r=t.doc.resolve(e+n);Pt(t,r.node(),r.before(),l)}o.inlineContent&&$t(t,e+n-1,o,s.node().contentMatchAt(s.index()),null==r);let u=t.mapping.slice(l),a=u.map(e-n);if(t.step(new At(a,u.map(e+n,-1),d.empty,!0)),!0===r){let e=t.doc.resolve(a);It(t,e.node(),e.before(),t.steps.length)}}(this,t,e),this}wrap(t,e){return function(t,e,n){let r=l.empty;for(let t=n.length-1;t>=0;t--){if(r.size){let e=n[t].type.contentMatch.matchFragment(r);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=l.from(n[t].type.create(n[t].attrs,r))}let i=e.start,s=e.end;t.step(new Et(i,s,i,s,new d(r,0,0),n.length,!0))}(this,t,e),this}setBlockType(t,e=t,n,r=null){return function(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,((e,n)=>{let o="function"==typeof i?i(e):i;if(e.isTextblock&&!e.hasMarkup(r,o)&&function(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}(t.doc,t.mapping.slice(s).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let t="pre"==r.whitespace,e=!!r.contentMatch.matchType(r.schema.linebreakReplacement);t&&!e?i=!1:!t&&e&&(i=!0)}!1===i&&Pt(t,e,n,s),$t(t,t.mapping.slice(s).map(n,1),r,void 0,null===i);let u=t.mapping.slice(s),a=u.map(n,1),h=u.map(n+e.nodeSize,1);return t.step(new Et(a,h,a+1,h-1,new d(l.from(r.create(o,null,e.marks)),0,0),1,!0)),!0===i&&It(t,e,n,s),!1}}))}(this,t,e,n,r),this}setNodeMarkup(t,e,n=null,r){return function(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Et(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new d(l.from(o),0,0),1,!0))}(this,t,e,n,r),this}setNodeAttribute(t,e,n){return this.step(new Zt(t,e,n)),this}setDocAttribute(t,e){return this.step(new Yt(t,e)),this}addNodeMark(t,e){return this.step(new Lt(t,e)),this}removeNodeMark(t,e){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(e instanceof c)e.isInSet(n.marks)&&this.step(new St(t,e));else{let r,i=n.marks,s=[];for(;r=e.isInSet(i);)s.push(new St(t,r)),i=r.removeFromSet(i);for(let t=s.length-1;t>=0;t--)this.step(s[t])}return this}split(t,e=1,n){return function(t,e,n=1,r){let i=t.doc.resolve(e),s=l.empty,o=l.empty;for(let t=i.depth,e=i.depth-n,u=n-1;t>e;t--,u--){s=l.from(i.node(t).copy(s));let e=r&&r[u];o=l.from(e?e.type.create(e.attrs,o):i.node(t).copy(o))}t.step(new At(e,e,new d(s.append(o),n,n),!0))}(this,t,e,n),this}addMark(t,e,n){return function(t,e,n,r){let i,s,o=[],l=[];t.doc.nodesBetween(e,n,((t,u,a)=>{if(!t.isInline)return;let h=t.marks;if(!r.isInSet(h)&&a.type.allowsMarkType(r.type)){let a=Math.max(u,e),c=Math.min(u+t.nodeSize,n),f=r.addToSet(h);for(let t=0;t<h.length;t++)h[t].isInSet(f)||(i&&i.to==a&&i.mark.eq(h[t])?i.to=c:o.push(i=new xt(a,c,h[t])));s&&s.to==a?s.to=c:l.push(s=new Tt(a,c,r))}})),o.forEach((e=>t.step(e))),l.forEach((e=>t.step(e)))}(this,t,e,n),this}removeMark(t,e,n){return function(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,((t,o)=>{if(!t.isInline)return;s++;let l=null;if(r instanceof G){let e,n=t.marks;for(;e=r.isInSet(n);)(l||(l=[])).push(e),n=e.removeFromSet(n)}else r?r.isInSet(t.marks)&&(l=[r]):l=t.marks;if(l&&l.length){let r=Math.min(o+t.nodeSize,n);for(let t=0;t<l.length;t++){let n,u=l[t];for(let t=0;t<i.length;t++){let e=i[t];e.step==s-1&&u.eq(i[t].style)&&(n=e)}n?(n.to=r,n.step=s):i.push({style:u,from:Math.max(o,e),to:r,step:s})}}})),i.forEach((e=>t.step(new xt(e.from,e.to,e.style))))}(this,t,e,n),this}clearIncompatible(t,e,n){return $t(this,t,e,n),this}}const ne=Object.create(null);class re{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new ie(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=d.empty){let n=e.content.lastChild,r=null;for(let t=0;t<e.openEnd;t++)r=n,n=n.lastChild;let i=t.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:l,$to:u}=s[o],a=t.mapping.slice(i);t.replaceRange(a.map(l.pos),a.map(u.pos),o?d.empty:e),0==o&&pe(t,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:s,$to:o}=r[i],l=t.mapping.slice(n),u=l.map(s.pos),a=l.map(o.pos);i?t.deleteRange(u,a):(t.replaceRangeWith(u,a,e),pe(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let r=t.parent.inlineContent?new le(t):de(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(let r=t.depth-1;r>=0;r--){let i=e<0?de(t.node(0),t.node(r),t.before(r+1),t.index(r),e,n):de(t.node(0),t.node(r),t.after(r+1),t.index(r)+1,e,n);if(i)return i}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new ce(t.node(0))}static atStart(t){return de(t,t,0,0,1)||new ce(t)}static atEnd(t){return de(t,t,t.content.size,t.childCount,-1)||new ce(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=ne[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in ne)throw new RangeError("Duplicate use of selection JSON ID "+t);return ne[t]=e,e.prototype.jsonID=t,e}getBookmark(){return le.between(this.$anchor,this.$head).getBookmark()}}re.prototype.visible=!0;class ie{constructor(t,e){this.$from=t,this.$to=e}}let se=!1;function oe(t){se||t.parent.inlineContent||(se=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class le extends re{constructor(t,e=t){oe(t),oe(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let n=t.resolve(e.map(this.head));if(!n.parent.inlineContent)return re.near(n);let r=t.resolve(e.map(this.anchor));return new le(r.parent.inlineContent?r:n,n)}replace(t,e=d.empty){if(super.replace(t,e),e==d.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof le&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new ue(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new le(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,n=e){let r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))}static between(t,e,n){let r=t.pos-e.pos;if(n&&!r||(n=r>=0?1:-1),!e.parent.inlineContent){let t=re.findFrom(e,n,!0)||re.findFrom(e,-n,!0);if(!t)return re.near(e,n);e=t.$head}return t.parent.inlineContent||(0==r||(t=(re.findFrom(t,-n,!0)||re.findFrom(t,n,!0)).$anchor).pos<e.pos!=r<0)&&(t=e),new le(t,e)}}re.jsonID("text",le);class ue{constructor(t,e){this.anchor=t,this.head=e}map(t){return new ue(t.map(this.anchor),t.map(this.head))}resolve(t){return le.between(t.resolve(this.anchor),t.resolve(this.head))}}class ae extends re{constructor(t){let e=t.nodeAfter,n=t.node(0).resolve(t.pos+e.nodeSize);super(t,n),this.node=e}map(t,e){let{deleted:n,pos:r}=e.mapResult(this.anchor),i=t.resolve(r);return n?re.near(i):new ae(i)}content(){return new d(l.from(this.node),0,0)}eq(t){return t instanceof ae&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new he(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ae(t.resolve(e.anchor))}static create(t,e){return new ae(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}ae.prototype.visible=!1,re.jsonID("node",ae);class he{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:n}=t.mapResult(this.anchor);return e?new ue(n,n):new he(n)}resolve(t){let e=t.resolve(this.anchor),n=e.nodeAfter;return n&&ae.isSelectable(n)?new ae(e):re.near(e)}}class ce extends re{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=d.empty){if(e==d.empty){t.delete(0,t.doc.content.size);let e=re.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new ce(t)}map(t){return new ce(t)}eq(t){return t instanceof ce}getBookmark(){return fe}}re.jsonID("all",ce);const fe={map(){return this},resolve:t=>new ce(t)};function de(t,e,n,r,i,s=!1){if(e.inlineContent)return le.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let r=e.child(o);if(r.isAtom){if(!s&&ae.isSelectable(r))return ae.create(t,n-(i<0?r.nodeSize:0))}else{let e=de(t,r,n+i,i<0?r.childCount:0,i,s);if(e)return e}n+=r.nodeSize*i}return null}function pe(t,e,n){let r=t.steps.length-1;if(r<e)return;let i,s=t.steps[r];(s instanceof At||s instanceof Et)&&(t.mapping.maps[r].forEach(((t,e,n,r)=>{null==i&&(i=r)})),t.setSelection(re.near(t.doc.resolve(i),n)))}class me extends ee{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return c.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let n=this.selection;return e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||c.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,n){let r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();{if(null==n&&(n=e),!t)return this.deleteRange(e,n);let i=this.storedMarks;if(!i){let t=this.doc.resolve(e);i=n==e?t.marks():t.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,r.text(t,i)),this.selection.empty||this.selection.to!=e+t.length||this.setSelection(re.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function ge(t,e){return e&&t?t.bind(e):t}class we{constructor(t,e,n){this.name=t,this.init=ge(e.init,n),this.apply=ge(e.apply,n)}}const be=[new we("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new we("selection",{init:(t,e)=>t.selection||re.atStart(e.doc),apply:t=>t.selection}),new we("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,n,r)=>r.selection.$cursor?t.storedMarks:null}),new we("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class ye{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=be.slice(),e&&e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t),this.pluginsByKey[t.key]=t,t.spec.state&&this.fields.push(new we(t.key,t.spec.state,t))}))}}class ve{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=e){let e=this.config.plugins[n];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],n=this.applyInner(t),r=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let l=r?r[s].n:0,u=r?r[s].state:this,a=l<e.length&&o.spec.appendTransaction.call(o,l?e.slice(l):e,u,n);if(a&&n.filterTransaction(a,s)){if(a.setMeta("appendedTransaction",t),!r){r=[];for(let t=0;t<this.config.plugins.length;t++)r.push(t<s?{state:n,n:e.length}:{state:this,n:0})}e.push(a),n=n.applyInner(a),i=!0}r&&(r[s]={state:n,n:e.length})}}if(!i)return{state:n,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new ve(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let i=n[r];e[i.name]=i.apply(t,this[i.name],this,e)}return e}get tr(){return new me(this)}static create(t){let e=new ye(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new ve(e);for(let r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n}reconfigure(t){let e=new ye(this.schema,t.plugins),n=e.fields,r=new ve(e);for(let e=0;e<n.length;e++){let i=n[e].name;r[i]=this.hasOwnProperty(i)?this[i]:n[e].init(t,r)}return r}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((t=>t.toJSON()))),t&&"object"==typeof t)for(let n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=t[n],i=r.spec.state;i&&i.toJSON&&(e[n]=i.toJSON.call(r,this[r.key]))}return e}static fromJSON(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let r=new ye(t.schema,t.plugins),i=new ve(r);return r.fields.forEach((r=>{if("doc"==r.name)i.doc=C.fromJSON(t.schema,e.doc);else if("selection"==r.name)i.selection=re.fromJSON(i.doc,e.selection);else if("storedMarks"==r.name)e.storedMarks&&(i.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let s in n){let o=n[s],l=o.spec.state;if(o.key==r.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,s))return void(i[r.name]=l.fromJSON.call(o,t,e[s],i))}i[r.name]=r.init(t,i)}})),i}}function ke(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):"handleDOMEvents"==r&&(i=ke(i,e,{})),n[r]=i}return n}class Me{constructor(t){this.spec=t,this.props={},t.props&&ke(t.props,this,this.props),this.key=t.key?t.key.key:xe("plugin")}getState(t){return t[this.key]}}const Te=Object.create(null);function xe(t){return t in Te?t+"$"+ ++Te[t]:(Te[t]=0,t+"$")}class Le{constructor(t="key"){this.key=xe(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}function Se(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}function Ae(t,e,n){let r=e.nodeBefore,i=e.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let t=r.lastChild;if(!t)return!1;r=t}let s=e.nodeAfter,o=e.pos+1;for(;!s.isTextblock;o++){if(s.type.spec.isolating)return!1;let t=s.firstChild;if(!t)return!1;s=t}let l=Ft(t.doc,i,o,d.empty);if(!l||l.from!=i||l instanceof At&&l.slice.size>=o-i)return!1;if(n){let e=t.tr.step(l);e.setSelection(le.create(e.doc,i)),n(e.scrollIntoView())}return!0}function Ee(t,e,n=!1){for(let r=t;r;r="start"==e?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}function Oe(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function $e(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}function Ce(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}function Re(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function He(t,e,n,r){let i,s,o=e.nodeBefore,u=e.nodeAfter,a=o.type.spec.isolating||u.type.spec.isolating;if(!a&&function(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!(!(r&&i&&r.type.compatibleContent(i.type))||(!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(s,s+1)||!i.isTextblock&&!Bt(t.doc,e.pos)||(n&&n(t.tr.join(e.pos).scrollIntoView()),0)))}(t,e,n))return!0;let h=!a&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(i=(s=o.contentMatchAt(o.childCount)).findWrapping(u.type))&&s.matchType(i[0]||u.type).validEnd){if(n){let r=e.pos+u.nodeSize,s=l.empty;for(let t=i.length-1;t>=0;t--)s=l.from(i[t].create(null,s));s=l.from(o.copy(s));let a=t.tr.step(new Et(e.pos-1,r,e.pos,r,new d(s,1,0),i.length,!0)),h=a.doc.resolve(r+2*i.length);h.nodeAfter&&h.nodeAfter.type==o.type&&Bt(a.doc,h.pos)&&a.join(h.pos),n(a.scrollIntoView())}return!0}let c=u.type.spec.isolating||r>0&&a?null:re.findFrom(e,1),f=c&&c.$from.blockRange(c.$to),p=f&&Rt(f);if(null!=p&&p>=e.depth)return n&&n(t.tr.lift(f,p).scrollIntoView()),!0;if(h&&Ee(u,"start",!0)&&Ee(o,"end")){let r=o,i=[];for(;i.push(r),!r.isTextblock;)r=r.lastChild;let s=u,a=1;for(;!s.isTextblock;s=s.firstChild)a++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=l.empty;for(let t=i.length-1;t>=0;t--)r=l.from(i[t].copy(r));n(t.tr.step(new Et(e.pos-i.length,e.pos+u.nodeSize,e.pos+a,e.pos+u.nodeSize-a,new d(r,i.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Ne(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return!!i.node(s).isTextblock&&(n&&n(e.tr.setSelection(le.create(e.doc,t<0?i.start(s):i.end(s)))),!0)}}const Ie=Ne(-1),Pe=Ne(1);function De(t,e=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(s,o,((r,s)=>{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(t,e))if(r.type==t)i=!0;else{let e=n.doc.resolve(s),r=e.index();i=e.parent.canReplaceWith(r,r+1,t)}}))}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(s,o,t,e)}r(i.scrollIntoView())}return!0}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();const Be=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},je=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let ze=null;const _e=function(t,e,n){let r=ze||(ze=document.createRange());return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},Fe=function(t,e,n,r){return n&&(Ke(t,e,n,r,-1)||Ke(t,e,n,r,1))},We=/^(img|br|input|textarea|hr)$/i;function Ke(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Ue(t))){let n=t.parentNode;if(!n||1!=n.nodeType||Je(t)||We.test(t.nodeName)||"false"==t.contentEditable)return!1;e=Be(t)+(i<0?0:1),t=n}else{if(1!=t.nodeType)return!1;{let n=t.childNodes[e+(i<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(s=n.pmViewDesc)||void 0===s?void 0:s.ignoreForSelection))return!1;e+=i}else t=n,e=i<0?Ue(t):0}}}}function Ue(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Je(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const qe=function(t){return t.focusNode&&Fe(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ve(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const Ge="undefined"!=typeof navigator?navigator:null,Xe="undefined"!=typeof document?document:null,Qe=Ge&&Ge.userAgent||"",Ze=/Edge\/(\d+)/.exec(Qe),Ye=/MSIE \d/.exec(Qe),tn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Qe),en=!!(Ye||tn||Ze),nn=Ye?document.documentMode:tn?+tn[1]:Ze?+Ze[1]:0,rn=!en&&/gecko\/(\d+)/i.test(Qe),sn=!en&&/Chrome\/(\d+)/.exec(Qe),on=!!sn,ln=sn?+sn[1]:0,un=!en&&!!Ge&&/Apple Computer/.test(Ge.vendor),an=un&&(/Mobile\/\w+/.test(Qe)||!!Ge&&Ge.maxTouchPoints>2),hn=an||!!Ge&&/Mac/.test(Ge.platform),cn=!!Ge&&/Win/.test(Ge.platform),fn=/Android \d/.test(Qe),dn=!!Xe&&"webkitFontSmoothing"in Xe.documentElement.style,pn=dn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function mn(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function gn(t,e){return"number"==typeof t?t:t[e]}function wn(t){let e=t.getBoundingClientRect();return{left:e.left,right:e.left+t.clientWidth*(e.width/t.offsetWidth||1),top:e.top,bottom:e.top+t.clientHeight*(e.height/t.offsetHeight||1)}}function bn(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(1!=o.nodeType){o=je(o);continue}let t=o,n=t==s.body,l=n?mn(s):wn(t),u=0,a=0;if(e.top<l.top+gn(r,"top")?a=-(l.top-e.top+gn(i,"top")):e.bottom>l.bottom-gn(r,"bottom")&&(a=e.bottom-e.top>l.bottom-l.top?e.top+gn(i,"top")-l.top:e.bottom-l.bottom+gn(i,"bottom")),e.left<l.left+gn(r,"left")?u=-(l.left-e.left+gn(i,"left")):e.right>l.right-gn(r,"right")&&(u=e.right-l.right+gn(i,"right")),u||a)if(n)s.defaultView.scrollBy(u,a);else{let n=t.scrollLeft,r=t.scrollTop;a&&(t.scrollTop+=a),u&&(t.scrollLeft+=u);let i=t.scrollLeft-n,s=t.scrollTop-r;e={left:e.left-i,top:e.top-s,right:e.right-i,bottom:e.bottom-s}}let h=n?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(h))break;o="absolute"==h?o.offsetParent:je(o)}}function yn(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=je(r));return e}function vn(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let kn=null;function Mn(t,e){let n,r,i,s,o=2e8,l=0,u=e.top,a=e.top;for(let h=t.firstChild,c=0;h;h=h.nextSibling,c++){let t;if(1==h.nodeType)t=h.getClientRects();else{if(3!=h.nodeType)continue;t=_e(h).getClientRects()}for(let f=0;f<t.length;f++){let d=t[f];if(d.top<=u&&d.bottom>=a){u=Math.max(d.bottom,u),a=Math.min(d.top,a);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<o){n=h,o=t,r=t&&3==n.nodeType?{left:d.right<e.left?d.right:d.left,top:e.top}:e,1==h.nodeType&&t&&(l=c+(e.left>=(d.left+d.right)/2?1:0));continue}}else d.top>e.top&&!i&&d.left<=e.left&&d.right>=e.left&&(i=h,s={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top});!n&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(l=c+1)}}return!n&&i&&(n=i,r=s,o=0),n&&3==n.nodeType?function(t,e){let n,r=t.nodeValue.length,i=document.createRange();for(let s=0;s<r;s++){i.setEnd(t,s+1),i.setStart(t,s);let r=An(i,1);if(r.top!=r.bottom&&Tn(e,r)){n={node:t,offset:s+(e.left>=(r.left+r.right)/2?1:0)};break}}return i.detach(),n||{node:t,offset:0}}(n,r):!n||o&&1==n.nodeType?{node:t,offset:l}:Mn(n,r)}function Tn(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function xn(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let n=t.childNodes[s];if(1==n.nodeType){let t=n.getClientRects();for(let r=0;r<t.length;r++){let i=t[r];if(Tn(e,i))return xn(n,e,i)}}if((s=(s+1)%r)==i)break}return t}function Ln(t,e){let n,r=t.dom.ownerDocument,i=0,s=function(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Ue(r.offsetNode),r.offset)}}catch(t){}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Ue(r.startContainer),r.startOffset)}}}(r,e.left,e.top);s&&({node:n,offset:i}=s);let o,l=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top);if(!l||!t.dom.contains(1!=l.nodeType?l.parentNode:l)){let n=t.dom.getBoundingClientRect();if(!Tn(e,n))return null;if(l=xn(t.dom,e,n),!l)return null}if(un)for(let t=l;n&&t;t=je(t))t.draggable&&(n=void 0);if(l=function(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(l,e),n){if(rn&&1==n.nodeType&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let t,r=n.childNodes[i];"IMG"==r.nodeName&&(t=r.getBoundingClientRect()).right<=e.left&&t.bottom>e.top&&i++}let r;dn&&i&&1==n.nodeType&&1==(r=n.childNodes[i-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=e.top&&i--,n==t.dom&&i==n.childNodes.length-1&&1==n.lastChild.nodeType&&e.top>n.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:0!=i&&1==n.nodeType&&"BR"==n.childNodes[i-1].nodeName||(o=function(t,e,n,r){let i=-1;for(let n=e,s=!1;n!=t.dom;){let e,o=t.docView.nearestDesc(n,!0);if(!o)return null;if(1==o.dom.nodeType&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((e=o.dom.getBoundingClientRect()).width||e.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!s&&e.left>r.left||e.top>r.top?i=o.posBefore:(!s&&e.right<r.left||e.bottom<r.top)&&(i=o.posAfter),s=!0),!o.contentDOM&&i<0&&!o.node.isText))return(o.node.isBlock?r.top<(e.top+e.bottom)/2:r.left<(e.left+e.right)/2)?o.posBefore:o.posAfter;n=o.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}(t,n,i,e))}null==o&&(o=function(t,e,n){let{node:r,offset:i}=Mn(e,n),s=-1;if(1==r.nodeType&&!r.firstChild){let t=r.getBoundingClientRect();s=t.left!=t.right&&n.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}(t,l,e));let u=t.docView.nearestDesc(l,!0);return{pos:o,inside:u?u.posAtStart-u.border:-1}}function Sn(t){return t.top<t.bottom||t.left<t.right}function An(t,e){let n=t.getClientRects();if(n.length){let t=n[e<0?0:n.length-1];if(Sn(t))return t}return Array.prototype.find.call(n,Sn)||t.getBoundingClientRect()}const En=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function On(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=dn||rn;if(3==r.nodeType){if(!o||!En.test(r.nodeValue)&&(n<0?i:i!=r.nodeValue.length)){let t=i,e=i,s=n<0?1:-1;return n<0&&!i?(e++,s=-1):n>=0&&i==r.nodeValue.length?(t--,s=1):n<0?t--:e++,$n(An(_e(r,t,e),s),s<0)}{let t=An(_e(r,i,i),n);if(rn&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let e=An(_e(r,i-1,i-1),-1);if(e.top==t.top){let n=An(_e(r,i,i+1),-1);if(n.top!=t.top)return $n(n,n.left<e.left)}}return t}}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(null==s&&i&&(n<0||i==Ue(r))){let t=r.childNodes[i-1];if(1==t.nodeType)return Cn(t.getBoundingClientRect(),!1)}if(null==s&&i<Ue(r)){let t=r.childNodes[i];if(1==t.nodeType)return Cn(t.getBoundingClientRect(),!0)}return Cn(r.getBoundingClientRect(),n>=0)}if(null==s&&i&&(n<0||i==Ue(r))){let t=r.childNodes[i-1],e=3==t.nodeType?_e(t,Ue(t)-(o?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return $n(An(e,1),!1)}if(null==s&&i<Ue(r)){let t=r.childNodes[i];for(;t.pmViewDesc&&t.pmViewDesc.ignoreForCoords;)t=t.nextSibling;let e=t?3==t.nodeType?_e(t,0,o?0:1):1==t.nodeType?t:null:null;if(e)return $n(An(e,-1),!0)}return $n(An(3==r.nodeType?_e(r):r,-n),n>=0)}function $n(t,e){if(0==t.width)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Cn(t,e){if(0==t.height)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Rn(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}const Hn=/[\u0590-\u08ac]/;let Nn=null,In=null,Pn=!1;class Dn{constructor(t,e,n,r){this.parent=t,this.children=e,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,n=this.posAtStart;;e++){let r=this.children[e];if(r==t)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){let n,r;if(t==this.contentDOM)n=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(t==this.contentDOM)n=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(t==this.dom&&this.contentDOM)r=e>Be(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!1;break}if(e.previousSibling)break}if(null==r&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!0;break}if(e.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let n=!0,r=t;r;r=r.parentNode){let i,s=this.getDesc(r);if(s&&(!e||s.node)){if(!n||!(i=s.nodeDOM)||(1==i.nodeType?i.contains(1==t.nodeType?t:t.parentNode):i==t))return s;n=!1}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,n){for(let r=t;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(t,e,n)}return-1}descAt(t){for(let e=0,n=0;e<this.children.length;e++){let r=this.children[e],i=n+r.size;if(n==t&&i!=n){for(;!r.border&&r.children.length;)for(let t=0;t<r.children.length;t++){let e=r.children[t];if(e.size){r=e;break}}return r}if(t<i)return r.descAt(t-n-r.border);n=i}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let n=0,r=0;for(let e=0;n<this.children.length;n++){let i=this.children[n],s=e+i.size;if(s>t||i instanceof Kn){r=t-e;break}e=s}if(r)return this.children[n].domFromPos(r-this.children[n].border,e);for(let t;n&&!(t=this.children[n-1]).size&&t instanceof Bn&&t.side>=0;n--);if(e<=0){let t,r=!0;for(;t=n?this.children[n-1]:null,t&&t.dom.parentNode!=this.contentDOM;n--,r=!1);return t&&e&&r&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?Be(t.dom)+1:0}}{let t,r=!0;for(;t=n<this.children.length?this.children[n]:null,t&&t.dom.parentNode!=this.contentDOM;n++,r=!1);return t&&r&&!t.border&&!t.domAtom?t.domFromPos(0,e):{node:this.contentDOM,offset:t?Be(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,n=0){if(0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let s=n,o=0;;o++){let n=this.children[o],l=s+n.size;if(-1==r&&t<=l){let i=s+n.border;if(t>=i&&e<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(t,e,i);t=s;for(let e=o;e>0;e--){let n=this.children[e-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=Be(n.dom)+1;break}t-=n.size}-1==r&&(r=0)}if(r>-1&&(l>e||o==this.children.length-1)){e=l;for(let t=o+1;t<this.children.length;t++){let n=this.children[t];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=Be(n.dom);break}e+=n.size}-1==i&&(i=this.contentDOM.childNodes.length);break}s=l}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:i}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:n}=this.domFromPos(t,0);if(1!=e.nodeType||n==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[n]}setSelection(t,e,n,r=!1){let i=Math.min(t,e),s=Math.max(t,e);for(let o=0,l=0;o<this.children.length;o++){let u=this.children[o],a=l+u.size;if(i>l&&s<a)return u.setSelection(t-l-u.border,e-l-u.border,n,r);l=a}let o=this.domFromPos(t,t?-1:1),l=e==t?o:this.domFromPos(e,e?-1:1),u=n.root.getSelection(),a=n.domSelectionRange(),h=!1;if((rn||un)&&t==e){let{node:t,offset:e}=o;if(3==t.nodeType){if(h=!(!e||"\n"!=t.nodeValue[e-1]),h&&e==t.nodeValue.length)for(let e,n=t;n;n=n.parentNode){if(e=n.nextSibling){"BR"==e.nodeName&&(o=l={node:e.parentNode,offset:Be(e)+1});break}let t=n.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}else{let n=t.childNodes[e-1];h=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(rn&&a.focusNode&&a.focusNode!=l.node&&1==a.focusNode.nodeType){let t=a.focusNode.childNodes[a.focusOffset];t&&"false"==t.contentEditable&&(r=!0)}if(!(r||h&&un)&&Fe(o.node,o.offset,a.anchorNode,a.anchorOffset)&&Fe(l.node,l.offset,a.focusNode,a.focusOffset))return;let c=!1;if((u.extend||t==e)&&(!h||!rn)){u.collapse(o.node,o.offset);try{t!=e&&u.extend(l.node,l.offset),c=!0}catch(t){}}if(!c){if(t>e){let t=o;o=l,l=t}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(o.node,o.offset),u.removeAllRanges(),u.addRange(n)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],s=n+i.size;if(n==s?t<=s&&e>=n:t<s&&e>n){let r=n+i.border,o=s-i.border;if(t>=r&&e<=o)return this.dirty=t==n||e==s?2:1,void(t!=r||e!=o||!i.contentLost&&i.dom.parentNode==this.contentDOM?i.markDirty(t-r,e-r):i.dirty=3);i.dirty=i.dom!=i.contentDOM||i.dom.parentNode!=this.contentDOM||i.children.length?3:2}n=s}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=1==t?2:1;e.dirty<n&&(e.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}}class Bn extends Dn{constructor(t,e,n,r){let i,s=e.type.toDOM;if("function"==typeof s&&(s=s(n,(()=>i?i.parent?i.parent.posBeforeChild(i):void 0:r))),!e.type.spec.raw){if(1!=s.nodeType){let t=document.createElement("span");t.appendChild(s),s=t}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(t,[],s,null),this.widget=e,this.widget=e,i=this}matchesWidget(t){return 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class jn extends Dn{constructor(t,e,n,r){super(t,[],e,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class zn extends Dn{constructor(t,e,n,r,i){super(t,[],n,r),this.mark=e,this.spec=i}static create(t,e,n,r){let i=r.nodeViews[e.type.name],s=i&&i(e,r,n);return s&&s.dom||(s=ut.renderSpec(document,e.type.spec.toDOM(e,n),null,e.attrs)),new zn(t,e,s.dom,s.contentDOM||s.dom,s)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let t=this.parent;for(;!t.node;)t=t.parent;t.dirty<this.dirty&&(t.dirty=this.dirty),this.dirty=0}}slice(t,e,n){let r=zn.create(this.parent,this.mark,!0,n),i=this.children,s=this.size;e<s&&(i=rr(i,e,s,n)),t>0&&(i=rr(i,0,t,n));for(let t=0;t<i.length;t++)i[t].parent=r;return r.children=i,r}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class _n extends Dn{constructor(t,e,n,r,i,s,o,l,u){super(t,[],i,s),this.node=e,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,e,n,r,i,s){let o,l=i.nodeViews[e.type.name],u=l&&l(e,i,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:s),n,r),a=u&&u.dom,h=u&&u.contentDOM;if(e.isText)if(a){if(3!=a.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else a=document.createTextNode(e.text);else if(!a){let t=ut.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:a,contentDOM:h}=t)}h||e.isText||"BR"==a.nodeName||(a.hasAttribute("contenteditable")||(a.contentEditable="false"),e.type.spec.draggable&&(a.draggable=!0));let c=a;return a=Zn(a,n,e),u?o=new Un(t,e,n,r,a,h||null,c,u,i,s+1):e.isText?new Wn(t,e,n,r,a,c,i):new _n(t,e,n,r,a,h||null,c,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>l.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,n){return 0==this.dirty&&t.eq(this.node)&&Yn(e,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let n=this.node.inlineContent,r=e,i=t.composing?this.localCompositionInfo(t,e):null,s=i&&i.pos>-1?i:null,o=i&&i.pos<0,l=new er(this,s&&s.node,t);!function(t,e,n,r){let i=e.locals(t),s=0;if(0==i.length){for(let n=0;n<t.childCount;n++){let o=t.child(n);r(o,i,e.forChild(s,o),n),s+=o.nodeSize}return}let o=0,l=[],u=null;for(let a=0;;){let h,c,f,d;for(;o<i.length&&i[o].to==s;){let t=i[o++];t.widget&&(h?(c||(c=[h])).push(t):h=t)}if(h)if(c){c.sort(nr);for(let t=0;t<c.length;t++)n(c[t],a,!!u)}else n(h,a,!!u);if(u)d=-1,f=u,u=null;else{if(!(a<t.childCount))break;d=a,f=t.child(a++)}for(let t=0;t<l.length;t++)l[t].to<=s&&l.splice(t--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let t=p;o<i.length&&i[o].from<t&&(t=i[o].from);for(let e=0;e<l.length;e++)l[e].to<t&&(t=l[e].to);t<p&&(u=f.cut(t-s),f=f.cut(0,t-s),p=t,d=-1)}else for(;o<i.length&&i[o].to<p;)o++;r(f,f.isInline&&!f.isLeaf?l.filter((t=>!t.inline)):l.slice(),e.forChild(s,f),d),s=p}}(this.node,this.innerDeco,((e,i,s)=>{e.spec.marks?l.syncToMarks(e.spec.marks,n,t,i):e.type.side>=0&&!s&&l.syncToMarks(i==this.node.childCount?c.none:this.node.child(i).marks,n,t,i),l.placeWidget(e,t,r)}),((e,s,u,a)=>{let h;l.syncToMarks(e.marks,n,t,a),l.findNodeMatch(e,s,u,a)||o&&t.state.selection.from>r&&t.state.selection.to<r+e.nodeSize&&(h=l.findIndexWithChild(i.node))>-1&&l.updateNodeAt(e,s,u,h,t)||l.updateNextNode(e,s,u,t,a,r)||l.addNode(e,s,u,t,r),r+=e.nodeSize})),l.syncToMarks([],n,t,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(s&&this.protectLocalComposition(t,s),Jn(this.contentDOM,this.children,t),an&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t),t.style.cssText=e}}(this.dom))}localCompositionInfo(t,e){let{from:n,to:r}=t.state.selection;if(!(t.state.selection instanceof le)||n<e||r>e+this.node.content.size)return null;let i=t.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let t=i.nodeValue,s=function(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let u=o.text;for(;i<t.childCount;){let e=t.child(i++);if(s+=e.nodeSize,!e.isText)break;u+=e.text}if(s>=n){if(s>=r&&u.slice(r-e.length-l,r-l)==e)return r-e.length;let t=l<r?u.lastIndexOf(e,r-l-1):-1;if(t>=0&&t+e.length+l>=n)return l+t;if(n==r&&u.length>=r+e.length-l&&u.slice(r-l,r-l+e.length)==e)return r}}return-1}(this.node.content,t,n-e,r-e);return s<0?null:{node:i,pos:s,text:t}}return{node:i,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:n,text:r}){if(this.getDesc(e))return;let i=e;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new jn(this,i,e,r);t.input.compositionNodes.push(s),this.children=rr(this.children,n,n+r.length,t,s)}update(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node)||(this.updateInner(t,e,n,r),0))}updateInner(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(t){if(Yn(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Xn(this.dom,this.nodeDOM,Gn(this.outerDeco,this.node,e),Gn(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Fn(t,e,n,r,i){Zn(r,e,t);let s=new _n(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class Wn extends _n{constructor(t,e,n,r,i,s,o){super(t,e,n,r,i,null,s,o,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node)||(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,0))}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,n){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,n)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,n){let r=this.node.cut(t,e),i=document.createTextNode(r.text);return new Wn(this.parent,r,this.outerDeco,this.innerDeco,i,i,n)}markDirty(t,e){super.markDirty(t,e),this.dom==this.nodeDOM||0!=t&&e!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(t){return this.node.text==t}}class Kn extends Dn{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Un extends _n{constructor(t,e,n,r,i,s,o,l,u,a){super(t,e,n,r,i,s,o,u,a),this.spec=l}update(t,e,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let i=this.spec.update(t,e,n);return i&&this.updateInner(t,e,n,r),i}return!(!this.contentDOM&&!t.isLeaf)&&super.update(t,e,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,r){this.spec.setSelection?this.spec.setSelection(t,e,n.root):super.setSelection(t,e,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Jn(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=tr(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof zn){let e=r?r.previousSibling:t.lastChild;Jn(o.contentDOM,o.children,n),r=e?e.nextSibling:t.firstChild}}for(;r;)r=tr(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const qn=function(t){t&&(this.nodeName=t)};qn.prototype=Object.create(null);const Vn=[new qn];function Gn(t,e,n){if(0==t.length)return Vn;let r=n?Vn[0]:new qn,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new qn(o.nodeName));for(let t in o){let s=o[t];null!=s&&(n&&1==i.length&&i.push(r=new qn(e.isInline?"span":"div")),"class"==t?r.class=(r.class?r.class+" ":"")+s:"style"==t?r.style=(r.style?r.style+";":"")+s:"nodeName"!=t&&(r[t]=s))}}}return i}function Xn(t,e,n,r){if(n==Vn&&r==Vn)return e;let i=e;for(let e=0;e<r.length;e++){let s=r[e],o=n[e];if(e){let e;o&&o.nodeName==s.nodeName&&i!=t&&(e=i.parentNode)&&e.nodeName.toLowerCase()==s.nodeName||(e=document.createElement(s.nodeName),e.pmIsDeco=!0,e.appendChild(i),o=Vn[0]),i=e}Qn(i,o||Vn[0],s)}return i}function Qn(t,e,n){for(let r in e)"class"==r||"style"==r||"nodeName"==r||r in n||t.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let e=0;e<r.length;e++)-1==i.indexOf(r[e])&&t.classList.remove(r[e]);for(let e=0;e<i.length;e++)-1==r.indexOf(i[e])&&t.classList.add(i[e]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(e.style);)t.style.removeProperty(n[1])}n.style&&(t.style.cssText+=n.style)}}function Zn(t,e,n){return Xn(t,t,Vn,Gn(e,n,1!=t.nodeType))}function Yn(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function tr(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class er{constructor(t,e,n){this.lock=e,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,o=[];t:for(;i>0;){let l;for(;;)if(r){let t=n.children[r-1];if(!(t instanceof zn)){l=t,r--;break}n=t,r=t.children.length}else{if(n==e)break t;r=n.parent.children.indexOf(n),n=n.parent}let u=l.node;if(u){if(u!=t.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,n,r){let i=0,s=this.stack.length>>1,o=Math.min(s,t.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(t[i])&&!1!==t[i].type.spec.spanning;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<t.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let e=this.index;e<o;e++){let n=this.top.children[e];if(n.matchesMark(t[s])&&!this.isLocked(n.dom)){i=e;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=zn.create(this.top,t[s],e,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,s++}}findNodeMatch(t,e,n,r){let i,s=-1;if(r>=this.preMatch.index&&(i=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&i.matchesNode(t,e,n))s=this.top.children.indexOf(i,this.index);else for(let r=this.index,i=Math.min(this.top.children.length,r+5);r<i;r++){let i=this.top.children[r];if(i.matchesNode(t,e,n)&&!this.preMatch.matched.has(i)){s=r;break}}return!(s<0||(this.destroyBetween(this.index,s),this.index++,0))}updateNodeAt(t,e,n,r,i){let s=this.top.children[r];return 3==s.dirty&&s.dom==s.contentDOM&&(s.dirty=2),!!s.update(t,e,n,i)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++)if(this.top.children[t]==e)return t;return-1}t=e}}updateNextNode(t,e,n,r,i,s){for(let o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof _n){let u=this.preMatch.matched.get(l);if(null!=u&&u!=i)return!1;let a,h=l.dom,c=this.isLocked(h)&&!(t.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==t.text&&3!=l.dirty&&Yn(e,l.outerDeco));if(!c&&l.update(t,e,n,r))return this.destroyBetween(this.index,o),l.dom!=h&&(this.changed=!0),this.index++,!0;if(!c&&(a=this.recreateWrapper(l,t,e,n,r,s)))return this.destroyBetween(this.index,o),this.top.children[this.index]=a,a.contentDOM&&(a.dirty=2,a.updateChildren(r,s+1),a.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,e,n,r,i,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!Yn(n,t.outerDeco)||!r.eq(t.innerDeco))return null;let o=_n.create(this.top,e,n,r,i,s);if(o.contentDOM){o.children=t.children,t.children=[];for(let t of o.children)t.parent=o}return t.destroy(),o}addNode(t,e,n,r,i){let s=_n.create(this.top,t,e,n,r,i);s.contentDOM&&s.updateChildren(r,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(t,e,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(t)||t!=r.widget&&r.widget.type.toDOM.parentNode){let r=new Bn(this.top,t,e,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof zn;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof Wn)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((un||on)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let n=document.createElement(t);"IMG"==t&&(n.className="ProseMirror-separator",n.alt=""),"BR"==t&&(n.className="ProseMirror-trailingBreak");let r=new Kn(this.top,[],n,null);e!=this.top?e.children.push(r):e.children.splice(this.index++,0,r),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||1==t.nodeType&&t.contains(this.lock.parentNode))}}function nr(t,e){return t.type.side-e.type.side}function rr(t,e,n,r,i){let s=[];for(let o=0,l=0;o<t.length;o++){let u=t[o],a=l,h=l+=u.size;a>=n||h<=e?s.push(u):(a<e&&s.push(u.slice(0,e-a,r)),i&&(s.push(i),i=void 0),h>n&&s.push(u.slice(n-a,u.size,r)))}return s}function ir(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&0==i.size,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l,u,a=r.resolve(o);if(qe(n)){for(l=o;i&&!i.node;)i=i.parent;let t=i.node;if(i&&t.isAtom&&ae.isSelectable(t)&&i.parent&&(!t.isInline||!function(t,e,n){for(let r=0==e,i=e==Ue(t);r||i;){if(t==n)return!0;let e=Be(t);if(!(t=t.parentNode))return!1;r=r&&0==e,i=i&&e==Ue(t)}}(n.focusNode,n.focusOffset,i.dom))){let t=i.posBefore;u=new ae(o==t?a:r.resolve(t))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let e=o,i=o;for(let r=0;r<n.rangeCount;r++){let s=n.getRangeAt(r);e=Math.min(e,t.docView.posFromDOM(s.startContainer,s.startOffset,1)),i=Math.max(i,t.docView.posFromDOM(s.endContainer,s.endOffset,-1))}if(e<0)return null;[l,o]=i==t.state.selection.anchor?[i,e]:[e,i],a=r.resolve(o)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let h=r.resolve(l);return u||(u=dr(t,h,a,"pointer"==e||t.state.selection.head<a.pos&&!s?1:-1)),u}function sr(t){return t.editable?t.hasFocus():mr(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function or(t,e=!1){let n=t.state.selection;if(cr(t,n),sr(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&on){let e=t.domSelectionRange(),n=t.domObserver.currentSelection;if(e.anchorNode&&n.anchorNode&&Fe(e.anchorNode,e.anchorOffset,n.anchorNode,n.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r="IMG"==n.nodeName;r?e.collapse(n.parentNode,Be(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&en&&nn<=11&&(n.disabled=!0,n.disabled=!1)}(t);else{let r,i,{anchor:s,head:o}=n;!lr||n instanceof le||(n.$from.parent.inlineContent||(r=ur(t,n.from)),n.empty||n.$from.parent.inlineContent||(i=ur(t,n.to))),t.docView.setSelection(s,o,t,e),lr&&(r&&hr(r),i&&hr(i)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==i||(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout((()=>{sr(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const lr=un||on&&ln<63;function ur(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(un&&i&&"false"==i.contentEditable)return ar(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return ar(i);if(s)return ar(s)}}function ar(t){return t.contentEditable="true",un&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function hr(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function cr(t,e){if(e instanceof ae){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(fr(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else fr(t)}function fr(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function dr(t,e,n,r){return t.someProp("createSelectionBetween",(r=>r(t,e,n)))||le.between(e,n,r)}function pr(t){return!(t.editable&&!t.hasFocus())&&mr(t)}function mr(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function gr(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&re.findFrom(s,e)}function wr(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function br(t,e,n){let r=t.state.selection;if(!(r instanceof le)){if(r instanceof ae&&r.node.isInline)return wr(t,new le(e>0?r.$to:r.$from));{let n=gr(t.state,e);return!!n&&wr(t,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,i=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(n.pos+i.nodeSize*(e<0?-1:1));return wr(t,new le(r.$anchor,s))}if(!r.empty)return!1;if(t.endOfTextblock(e>0?"forward":"backward")){let n=gr(t.state,e);return!!(n&&n instanceof ae)&&wr(t,n)}if(!(hn&&n.indexOf("m")>-1)){let n,i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText)return!1;let o=e<0?i.pos-s.nodeSize:i.pos;return!!(s.isAtom||(n=t.docView.descAt(o))&&!n.contentDOM)&&(ae.isSelectable(s)?wr(t,new ae(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):!!dn&&wr(t,new le(t.state.doc.resolve(e<0?o:o+s.nodeSize))))}}function yr(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function vr(t,e){let n=t.pmViewDesc;return n&&0==n.size&&(e<0||t.nextSibling||"BR"!=t.nodeName)}function kr(t,e){return e<0?function(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(rn&&1==n.nodeType&&r<yr(n)&&vr(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(1!=n.nodeType)break;{let t=n.childNodes[r-1];if(vr(t,-1))i=n,s=--r;else{if(3!=t.nodeType)break;n=t,r=n.nodeValue.length}}}else{if(Mr(n))break;{let e=n.previousSibling;for(;e&&vr(e,-1);)i=n.parentNode,s=Be(e),e=e.previousSibling;if(e)n=e,r=yr(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Tr(t,n,r):i&&Tr(t,i,s)}(t):function(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=yr(n);for(;;)if(r<o){if(1!=n.nodeType)break;if(!vr(n.childNodes[r],1))break;i=n,s=++r}else{if(Mr(n))break;{let e=n.nextSibling;for(;e&&vr(e,1);)i=e.parentNode,s=Be(e)+1,e=e.nextSibling;if(e)n=e,r=0,o=yr(n);else{if(n=n.parentNode,n==t.dom)break;r=o=0}}}i&&Tr(t,i,s)}(t)}function Mr(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Tr(t,e,n){if(3!=e.nodeType){let t,r;(r=function(t,e){for(;t&&e==t.childNodes.length&&!Je(t);)e=Be(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=n,e=0}}(e,n))?(e=r,n=0):(t=function(t,e){for(;t&&!e&&!Je(t);)e=Be(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=(t=n).childNodes.length}}(e,n))&&(e=t,n=t.nodeValue.length)}let r=t.domSelection();if(!r)return;if(qe(r)){let t=document.createRange();t.setEnd(e,n),t.setStart(e,n),r.removeAllRanges(),r.addRange(t)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout((()=>{t.state==i&&or(t)}),50)}function xr(t,e){let n=t.state.doc.resolve(e);if(!on&&!cn&&n.parent.inlineContent){let r=t.coordsAtPos(e);if(e>n.start()){let n=t.coordsAtPos(e-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(e<n.end()){let n=t.coordsAtPos(e+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(t.dom).direction?"rtl":"ltr"}function Lr(t,e,n){let r=t.state.selection;if(r instanceof le&&!r.empty||n.indexOf("s")>-1)return!1;if(hn&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let n=gr(t.state,e);if(n&&n instanceof ae)return wr(t,n)}if(!i.parent.inlineContent){let n=e<0?i:s,o=r instanceof ce?re.near(n,e):re.findFrom(n,e);return!!o&&wr(t,o)}return!1}function Sr(t,e){if(!(t.state.selection instanceof le))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=t.state.tr;return e<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),t.dispatch(r),!0}return!1}function Ar(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Er(t,e){t.someProp("transformCopied",(n=>{e=n(e,t)}));let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,s--;let t=r.firstChild;n.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),r=t.content}let o=t.someProp("clipboardSerializer")||ut.fromSchema(t.state.schema),l=Br(),u=l.createElement("div");u.appendChild(o.serializeFragment(r,{document:l}));let a,h=u.firstChild,c=0;for(;h&&1==h.nodeType&&(a=Pr[h.nodeName.toLowerCase()]);){for(let t=a.length-1;t>=0;t--){let e=l.createElement(a[t]);for(;u.firstChild;)e.appendChild(u.firstChild);u.appendChild(e),c++}h=u.firstChild}return h&&1==h.nodeType&&h.setAttribute("data-pm-slice",`${i} ${s}${c?` -${c}`:""} ${JSON.stringify(n)}`),{dom:u,text:t.someProp("clipboardTextSerializer",(n=>n(e,t)))||e.content.textBetween(0,e.content.size,"\n\n"),slice:e}}function Or(t,e,n,r,i){let s,o,u=i.parent.type.spec.code;if(!n&&!e)return null;let a=!!e&&(r||u||!n);if(a){if(t.someProp("transformPastedText",(n=>{e=n(e,u||r,t)})),u)return o=new d(l.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0),t.someProp("transformPasted",(e=>{o=e(o,t,!0)})),o;let n=t.someProp("clipboardTextParser",(n=>n(e,i,r,t)));if(n)o=n;else{let n=i.marks(),{schema:r}=t.state,o=ut.fromSchema(r);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=s.appendChild(document.createElement("p"));t&&e.appendChild(o.serializeNode(r.text(t,n)))}))}}else t.someProp("transformPastedHTML",(e=>{n=e(n,t)})),s=function(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n,r=Br().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(t);if((n=i&&Pr[i[1].toLowerCase()])&&(t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join("")),r.innerHTML=function(t){let e=window.trustedTypes;return e?(jr||(jr=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),jr.createHTML(t)):t}(t),n)for(let t=0;t<n.length;t++)r=r.querySelector(n[t])||r;return r}(n),dn&&function(t){let e=t.querySelectorAll(on?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}(s);let h=s&&s.querySelector("[data-pm-slice]"),c=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let t=+c[3];t>0;t--){let t=s.firstChild;for(;t&&1!=t.nodeType;)t=t.nextSibling;if(!t)break;s=t}if(!o){let e=t.someProp("clipboardParser")||t.someProp("domParser")||Z.fromSchema(t.state.schema);o=e.parseSlice(s,{preserveWhitespace:!(!a&&!c),context:i,ruleFromNode:t=>"BR"!=t.nodeName||t.nextSibling||!t.parentNode||$r.test(t.parentNode.nodeName)?null:{ignore:!0}})}if(c)o=function(t,e){if(!t.size)return t;let n,r=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}let{content:i,openStart:s,openEnd:o}=t;for(let t=n.length-2;t>=0;t-=2){let e=r.nodes[n[t]];if(!e||e.hasRequiredAttrs())break;i=l.from(e.create(n[t+1],i)),s++,o++}return new d(i,s,o)}(Ir(o,+c[1],+c[2]),c[4]);else if(o=d.maxOpen(function(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let r,i=e.node(n).contentMatchAt(e.index(n)),s=[];if(t.forEach((t=>{if(!s)return;let e,n=i.findWrapping(t.type);if(!n)return s=null;if(e=s.length&&r.length&&Rr(n,r,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=Hr(s[s.length-1],r.length));let e=Cr(t,n);s.push(e),i=i.matchType(e.type),r=n}})),s)return l.from(s)}return t}(o.content,i),!0),o.openStart||o.openEnd){let t=0,e=0;for(let e=o.content.firstChild;t<o.openStart&&!e.type.spec.isolating;t++,e=e.firstChild);for(let t=o.content.lastChild;e<o.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild);o=Ir(o,t,e)}return t.someProp("transformPasted",(e=>{o=e(o,t,a)})),o}const $r=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Cr(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,l.from(t));return t}function Rr(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=Rr(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(l.from(Cr(n,t,i+1))))}}function Hr(t,e){if(0==e)return t;let n=t.content.replaceChild(t.childCount-1,Hr(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(l.empty,!0);return t.copy(n.append(r))}function Nr(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,u=o.content;return t.childCount>1&&(s=0),i<r-1&&(u=Nr(u,e,n,r,i+1,s)),i>=n&&(u=e<0?o.contentMatchAt(0).fillBefore(u,s<=i).append(u):u.append(o.contentMatchAt(o.childCount).fillBefore(l.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(u))}function Ir(t,e,n){return e<t.openStart&&(t=new d(Nr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new d(Nr(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Pr={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Dr=null;function Br(){return Dr||(Dr=document.implementation.createHTMLDocument("title"))}let jr=null;const zr={},_r={},Fr={touchstart:!0,touchmove:!0};class Wr{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Kr(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Ur(t){t.someProp("handleDOMEvents",(e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=e=>Jr(t,e))}))}function Jr(t,e){return t.someProp("handleDOMEvents",(n=>{let r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function qr(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Vr(t){return{left:t.clientX,top:t.clientY}}function Gr(t,e,n,r,i){if(-1==r)return!1;let s=t.state.doc.resolve(r);for(let r=s.depth+1;r>0;r--)if(t.someProp(e,(e=>r>s.depth?e(t,n,s.nodeAfter,s.before(r),i,!0):e(t,n,s.node(r),s.before(r),i,!1))))return!0;return!1}function Xr(t,e){if(t.focused||t.focus(),t.state.selection.eq(e))return;let n=t.state.tr.setSelection(e);n.setMeta("pointer",!0),t.dispatch(n)}function Qr(t,e,n,r){return Gr(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(n=>n(t,e,r)))}function Zr(t,e,n,r){return Gr(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",(n=>n(t,e,r)))||function(t,e,n){if(0!=n.button)return!1;let r=t.state.doc;if(-1==e)return!!r.inlineContent&&(Xr(t,le.create(r,0,r.content.size)),!0);let i=r.resolve(e);for(let e=i.depth+1;e>0;e--){let n=e>i.depth?i.nodeAfter:i.node(e),s=i.before(e);if(n.inlineContent)Xr(t,le.create(r,s+1,s+1+n.content.size));else{if(!ae.isSelectable(n))continue;Xr(t,ae.create(r,s))}return!0}}(t,n,r)}function Yr(t){return oi(t)}_r.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=16==n.keyCode||n.shiftKey,!ni(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!fn||!on||13!=n.keyCode))if(229!=n.keyCode&&t.domObserver.forceFlush(),!an||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)t.someProp("handleKeyDown",(e=>e(t,n)))||function(t,e){let n=e.keyCode,r=function(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);if(8==n||hn&&72==n&&"c"==r)return Sr(t,-1)||kr(t,-1);if(46==n&&!e.shiftKey||hn&&68==n&&"c"==r)return Sr(t,1)||kr(t,1);if(13==n||27==n)return!0;if(37==n||hn&&66==n&&"c"==r){let e=37==n?"ltr"==xr(t,t.state.selection.from)?-1:1:-1;return br(t,e,r)||kr(t,e)}if(39==n||hn&&70==n&&"c"==r){let e=39==n?"ltr"==xr(t,t.state.selection.from)?1:-1:1;return br(t,e,r)||kr(t,e)}return 38==n||hn&&80==n&&"c"==r?Lr(t,-1,r)||kr(t,-1):40==n||hn&&78==n&&"c"==r?function(t){if(!un||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&1==e.nodeType&&0==n&&e.firstChild&&"false"==e.firstChild.contentEditable){let n=e.firstChild;Ar(t,n,"true"),setTimeout((()=>Ar(t,n,"false")),20)}return!1}(t)||Lr(t,1,r)||kr(t,1):r==(hn?"m":"c")&&(66==n||73==n||89==n||90==n)}(t,n)?n.preventDefault():Kr(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",(e=>e(t,Ve(13,"Enter")))),t.input.lastIOSEnter=0)}),200)}},_r.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},_r.keypress=(t,e)=>{let n=e;if(ni(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||hn&&n.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,n))))return void n.preventDefault();let r=t.state.selection;if(!(r instanceof le&&r.$from.sameParent(r.$to))){let e=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(e).scrollIntoView();/[\r\n]/.test(e)||t.someProp("handleTextInput",(n=>n(t,r.$from.pos,r.$to.pos,e,i)))||t.dispatch(i()),n.preventDefault()}};const ti=hn?"metaKey":"ctrlKey";zr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Yr(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&function(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}(n,t.input.lastClick)&&!n[ti]&&t.input.lastClick.button==n.button&&("singleClick"==t.input.lastClick.type?s="doubleClick":"doubleClick"==t.input.lastClick.type&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button};let o=t.posAtCoords(Vr(n));o&&("singleClick"==s?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new ei(t,o,n,!!r)):("doubleClick"==s?Qr:Zr)(t,o.pos,o.inside,n)?n.preventDefault():Kr(t,"pointer"))};class ei{constructor(t,e,n,r){let i,s;if(this.view=t,this.pos=e,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[ti],this.allowDefault=n.shiftKey,e.inside>-1)i=t.state.doc.nodeAt(e.inside),s=e.inside;else{let n=t.state.doc.resolve(e.pos);i=n.parent,s=n.depth?n.before():0}const o=r?null:n.target,l=o?t.docView.nearestDesc(o,!0):null;this.target=l&&1==l.nodeDOM.nodeType?l.nodeDOM:null;let{selection:u}=t.state;0==n.button&&(i.type.spec.draggable&&!1!==i.type.spec.selectable||u instanceof ae&&u.from<=s&&u.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!rn||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),Kr(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>or(this.view))),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(Vr(t))),this.updateAllowDefault(t),this.allowDefault||!e?Kr(this.view,"pointer"):function(t,e,n,r,i){return Gr(t,"handleClickOn",e,n,r)||t.someProp("handleClick",(n=>n(t,e,r)))||(i?function(t,e){if(-1==e)return!1;let n,r,i=t.state.selection;i instanceof ae&&(n=i.node);let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(ae.isSelectable(e)){r=n&&i.$from.depth>0&&t>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos?s.before(i.$from.depth):s.before(t);break}}return null!=r&&(Xr(t,ae.create(t.state.doc,r)),!0)}(t,n):function(t,e){if(-1==e)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&ae.isSelectable(r))&&(Xr(t,new ae(n)),!0)}(t,n))}(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||un&&this.mightDrag&&!this.mightDrag.node.isAtom||on&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(Xr(this.view,re.near(this.view.state.doc.resolve(e.pos))),t.preventDefault()):Kr(this.view,"pointer")}move(t){this.updateAllowDefault(t),Kr(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function ni(t,e){return!!t.composing||!!(un&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}zr.touchstart=t=>{t.input.lastTouch=Date.now(),Yr(t),Kr(t,"pointer")},zr.touchmove=t=>{t.input.lastTouch=Date.now(),Kr(t,"pointer")},zr.contextmenu=t=>Yr(t);const ri=fn?5e3:-1;function ii(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout((()=>oi(t)),e))}function si(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=function(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function oi(t,e=!1){if(!(fn&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),si(t),e||t.docView&&t.docView.dirty){let n=ir(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):!t.markCursor&&!e||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.updateState(t.state):t.dispatch(t.state.tr.deleteSelection()),!0}return!1}}_r.compositionstart=_r.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof le&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((t=>!1===t.type.spec.inclusive))||on&&cn&&function(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||1!=e.nodeType||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return 1==r.nodeType&&"false"==r.contentEditable}(t)))t.markCursor=t.state.storedMarks||n.marks(),oi(t,!0),t.markCursor=null;else if(oi(t,!e.selection.empty),rn&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let e=t.domSelectionRange();for(let n=e.focusNode,r=e.focusOffset;n&&1==n.nodeType&&0!=r;){let e=r<0?n.lastChild:n.childNodes[r-1];if(!e)break;if(3==e.nodeType){let n=t.domSelection();n&&n.collapse(e,e.nodeValue.length);break}n=e,r=-1}}t.input.composing=!0}ii(t,ri)},_r.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then((()=>t.domObserver.flush())),t.input.compositionID++,ii(t,20))};const li=en&&nn<15||an&&pn<604;function ui(t,e,n,r,i){let s=Or(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,i,s||d.empty))))return!0;if(!s)return!1;let o=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(s),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ai(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}zr.copy=_r.cut=(t,e)=>{let n=e,r=t.state.selection,i="cut"==n.type;if(r.empty)return;let s=li?null:n.clipboardData,o=r.content(),{dom:l,text:u}=Er(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",u)):function(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},_r.paste=(t,e)=>{let n=e;if(t.composing&&!fn)return;let r=li?null:n.clipboardData,i=t.input.shiftKey&&45!=t.input.lastKeyCode;r&&ui(t,ai(r),r.getData("text/html"),i,n)?n.preventDefault():function(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&45!=t.input.lastKeyCode;setTimeout((()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ui(t,r.value,null,i,e):ui(t,r.textContent,r.innerHTML,i,e)}),50)}(t,n)};class hi{constructor(t,e,n){this.slice=t,this.move=e,this.node=n}}const ci=hn?"altKey":"ctrlKey";function fi(t,e){let n;return t.someProp("dragCopies",(t=>{n=n||t(e)})),null!=n?!n:!e[ci]}zr.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i,s=t.state.selection,o=s.empty?null:t.posAtCoords(Vr(n));if(o&&o.pos>=s.from&&o.pos<=(s instanceof ae?s.to-1:s.to));else if(r&&r.mightDrag)i=ae.create(t.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let e=t.docView.nearestDesc(n.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&(i=ae.create(t.state.doc,e.posBefore))}let l=(i||t.state.selection).content(),{dom:u,text:a,slice:h}=Er(t,l);(!n.dataTransfer.files.length||!on||ln>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(li?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",li||n.dataTransfer.setData("text/plain",a),t.dragging=new hi(h,fi(t,n),i)},zr.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{t.dragging==e&&(t.dragging=null)}),50)},_r.dragover=_r.dragenter=(t,e)=>e.preventDefault(),_r.drop=(t,e)=>{try{!function(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Vr(e));if(!r)return;let i=t.state.doc.resolve(r.pos),s=n&&n.slice;s?t.someProp("transformPasted",(e=>{s=e(s,t,!1)})):s=Or(t,ai(e.dataTransfer),li?null:e.dataTransfer.getData("text/html"),!1,i);let o=!(!n||!fi(t,e));if(t.someProp("handleDrop",(n=>n(t,e,s||d.empty,o))))return void e.preventDefault();if(!s)return;e.preventDefault();let l=s?_t(t.state.doc,i.pos,s):i.pos;null==l&&(l=i.pos);let u=t.state.tr;if(o){let{node:t}=n;t?t.replace(u):u.deleteSelection()}let a=u.mapping.map(l),h=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,c=u.doc;if(h?u.replaceRangeWith(a,a,s.content.firstChild):u.replaceRange(a,a,s),u.doc.eq(c))return;let f=u.doc.resolve(a);if(h&&ae.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new ae(f));else{let e=u.mapping.map(l);u.mapping.maps[u.mapping.maps.length-1].forEach(((t,n,r,i)=>e=i)),u.setSelection(dr(t,f,u.doc.resolve(e)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}(t,e,t.dragging)}finally{t.dragging=null}},zr.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&or(t)}),20))},zr.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)},zr.beforeinput=(t,e)=>{if(on&&fn&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;if(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",(e=>e(t,Ve(8,"Backspace")))))return;let{$cursor:n}=t.state.selection;n&&n.pos>0&&t.dispatch(t.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let t in _r)zr[t]=_r[t];function di(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class pi{constructor(t,e){this.toDOM=t,this.spec=e||yi,this.side=this.spec.side||0}map(t,e,n,r){let{pos:i,deleted:s}=t.mapResult(e.from+r,this.side<0?-1:1);return s?null:new wi(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof pi&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&di(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class mi{constructor(t,e){this.attrs=t,this.spec=e||yi}map(t,e,n,r){let i=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,s=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=s?null:new wi(i,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof mi&&di(this.attrs,t.attrs)&&di(this.spec,t.spec)}static is(t){return t.type instanceof mi}destroy(){}}class gi{constructor(t,e){this.attrs=t,this.spec=e||yi}map(t,e,n,r){let i=t.mapResult(e.from+r,1);if(i.deleted)return null;let s=t.mapResult(e.to+r,-1);return s.deleted||s.pos<=i.pos?null:new wi(i.pos-n,s.pos-n,this)}valid(t,e){let n,{index:r,offset:i}=t.content.findIndex(e.from);return i==e.from&&!(n=t.child(r)).isText&&i+n.nodeSize==e.to}eq(t){return this==t||t instanceof gi&&di(this.attrs,t.attrs)&&di(this.spec,t.spec)}destroy(){}}class wi{constructor(t,e,n){this.from=t,this.to=e,this.type=n}copy(t,e){return new wi(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,n){return this.type.map(t,this,e,n)}static widget(t,e,n){return new wi(t,t,new pi(e,n))}static inline(t,e,n,r){return new wi(t,e,new mi(n,r))}static node(t,e,n,r){return new wi(t,e,new gi(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof mi}get widget(){return this.type instanceof pi}}const bi=[],yi={};class vi{constructor(t,e){this.local=t.length?t:bi,this.children=e.length?e:bi}static create(t,e){return e.length?Si(e,t,0,yi):ki}find(t,e,n){let r=[];return this.findInner(null==t?0:t,null==e?1e9:e,r,0,n),r}findInner(t,e,n,r,i){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=e&&o.to>=t&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<e&&this.children[s+1]>t){let o=this.children[s]+1;this.children[s+2].findInner(t-o,e-o,n,r+o,i)}}map(t,e,n){return this==ki||0==t.maps.length?this:this.mapInner(t,e,0,0,n||yi)}mapInner(t,e,n,r,i){let s;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(t,n,r);l&&l.type.valid(e,l)?(s||(s=[])).push(l):i.onRemove&&i.onRemove(this.local[o].spec)}return this.children.length?function(t,e,n,r,i,s,o){let l=t.slice();for(let t=0,e=s;t<n.maps.length;t++){let r=0;n.maps[t].forEach(((t,n,i,s)=>{let o=s-i-(n-t);for(let i=0;i<l.length;i+=3){let s=l[i+1];if(s<0||t>s+e-r)continue;let u=l[i]+e-r;n>=u?l[i+1]=t<=u?-2:-1:t>=e&&o&&(l[i]+=o,l[i+1]+=o)}r+=o})),e=n.maps[t].map(e,-1)}let u=!1;for(let e=0;e<l.length;e+=3)if(l[e+1]<0){if(-2==l[e+1]){u=!0,l[e+1]=-1;continue}let a=n.map(t[e]+s),h=a-i;if(h<0||h>=r.content.size){u=!0;continue}let c=n.map(t[e+1]+s,-1)-i,{index:f,offset:d}=r.content.findIndex(h),p=r.maybeChild(f);if(p&&d==h&&d+p.nodeSize==c){let r=l[e+2].mapInner(n,p,a+1,t[e]+s+1,o);r!=ki?(l[e]=h,l[e+1]=c,l[e+2]=r):(l[e+1]=-2,u=!0)}else u=!0}if(u){let u=function(t,e,n,r,i,s,o){function l(t,e){for(let s=0;s<t.local.length;s++){let l=t.local[s].map(r,i,e);l?n.push(l):o.onRemove&&o.onRemove(t.local[s].spec)}for(let n=0;n<t.children.length;n+=3)l(t.children[n+2],t.children[n]+e+1)}for(let n=0;n<t.length;n+=3)-1==t[n+1]&&l(t[n+2],e[n]+s+1);return n}(l,t,e,n,i,s,o),a=Si(u,r,0,o);e=a.local;for(let t=0;t<l.length;t+=3)l[t+1]<0&&(l.splice(t,3),t-=3);for(let t=0,e=0;t<a.children.length;t+=3){let n=a.children[t];for(;e<l.length&&l[e]<n;)e+=3;l.splice(e,0,a.children[t],a.children[t+1],a.children[t+2])}}return new vi(e.sort(Ai),l)}(this.children,s||[],t,e,n,r,i):s?new vi(s.sort(Ai),bi):ki}add(t,e){return e.length?this==ki?vi.create(t,e):this.addInner(t,e,0):this}addInner(t,e,n){let r,i=0;t.forEach(((t,s)=>{let o,l=s+n;if(o=xi(e,t,l)){for(r||(r=this.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(t,o,l+1):r.splice(i,0,s,s+t.nodeSize,Si(o,t,l+1,yi)),i+=3}}));let s=Ti(i?Li(e):e,-n);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||s.splice(e--,1);return new vi(s.length?this.local.concat(s).sort(Ai):this.local,r||this.children)}remove(t){return 0==t.length||this==ki?this:this.removeInner(t,0)}removeInner(t,e){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let i,s=n[r]+e,o=n[r+1]+e;for(let e,n=0;n<t.length;n++)(e=t[n])&&e.from>s&&e.to<o&&(t[n]=null,(i||(i=[])).push(e));if(!i)continue;n==this.children&&(n=this.children.slice());let l=n[r+2].removeInner(i,s+1);l!=ki?n[r+2]=l:(n.splice(r,3),r-=3)}if(r.length)for(let n,i=0;i<t.length;i++)if(n=t[i])for(let t=0;t<r.length;t++)r[t].eq(n,e)&&(r==this.local&&(r=this.local.slice()),r.splice(t--,1));return n==this.children&&r==this.local?this:r.length||n.length?new vi(r,n):ki}forChild(t,e){if(this==ki)return this;if(e.isLeaf)return vi.empty;let n,r;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(n=this.children[e+2]);break}let i=t+1,s=i+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>i&&e.type instanceof mi){let t=Math.max(i,e.from)-i,n=Math.min(s,e.to)-i;t<n&&(r||(r=[])).push(e.copy(t,n))}}if(r){let t=new vi(r.sort(Ai),bi);return n?new Mi([t,n]):t}return n||ki}eq(t){if(this==t)return!0;if(!(t instanceof vi)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(t){return Ei(this.localsInner(t))}localsInner(t){if(this==ki)return bi;if(t.inlineContent||!this.local.some(mi.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++)this.local[t].type instanceof mi||e.push(this.local[t]);return e}forEachSet(t){t(this)}}vi.empty=new vi([],[]),vi.removeOverlap=Ei;const ki=vi.empty;class Mi{constructor(t){this.members=t}map(t,e){const n=this.members.map((n=>n.map(t,e,yi)));return Mi.from(n)}forChild(t,e){if(e.isLeaf)return vi.empty;let n=[];for(let r=0;r<this.members.length;r++){let i=this.members[r].forChild(t,e);i!=ki&&(i instanceof Mi?n=n.concat(i.members):n.push(i))}return Mi.from(n)}eq(t){if(!(t instanceof Mi)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(t);if(i.length)if(e){n&&(e=e.slice(),n=!1);for(let t=0;t<i.length;t++)e.push(i[t])}else e=i}return e?Ei(n?e:e.sort(Ai)):bi}static from(t){switch(t.length){case 0:return ki;case 1:return t[0];default:return new Mi(t.every((t=>t instanceof vi))?t:t.reduce(((t,e)=>t.concat(e instanceof vi?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function Ti(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new wi(i.from+e,i.to+e,i.type))}return n}function xi(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let e,s=0;s<t.length;s++)(e=t[s])&&e.from>n&&e.to<r&&((i||(i=[])).push(e),t[s]=null);return i}function Li(t){let e=[];for(let n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function Si(t,e,n,r){let i=[],s=!1;e.forEach(((e,o)=>{let l=xi(t,e,o+n);if(l){s=!0;let t=Si(l,e,n+o+1,r);t!=ki&&i.push(o,o+e.nodeSize,t)}}));let o=Ti(s?Li(t):t,-n).sort(Ai);for(let t=0;t<o.length;t++)o[t].type.valid(e,o[t])||(r.onRemove&&r.onRemove(o[t].spec),o.splice(t--,1));return o.length||i.length?new vi(o,i):ki}function Ai(t,e){return t.from-e.from||t.to-e.to}function Ei(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from!=r.from){s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),Oi(e,i,r.copy(s.from,r.to)));break}s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),Oi(e,i+1,s.copy(r.to,s.to)))}}return e}function Oi(t,e,n){for(;e<t.length&&Ai(n,t[e])>0;)e++;t.splice(e,0,n)}function $i(t){let e=[];return t.someProp("decorations",(n=>{let r=n(t.state);r&&r!=ki&&e.push(r)})),t.cursorWrapper&&e.push(vi.create(t.state.doc,[t.cursorWrapper.deco])),Mi.from(e)}const Ci={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ri=en&&nn<=11;class Hi{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class Ni{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Hi,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);en&&nn<=11&&e.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():un&&t.composing&&e.some((t=>"childList"==t.type&&"TR"==t.target.nodeName))?(t.input.badSafariComposition=!0,this.flushSoon()):this.flush()})),Ri&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Ci)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(pr(this.view)){if(this.suppressingSelectionUpdates)return or(this.view);if(en&&nn<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Fe(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e,n=new Set;for(let e=t.focusNode;e;e=je(e))n.add(e);for(let r=t.anchorNode;r;r=je(r))if(n.has(r)){e=r;break}let r=e&&this.view.docView.nearestDesc(e);return r&&r.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();e.length&&(this.queue=[]);let n=t.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&pr(t)&&!this.ignoreSelectionChange(n),i=-1,s=-1,o=!1,l=[];if(t.editable)for(let t=0;t<e.length;t++){let n=this.registerMutation(e[t],l);n&&(i=i<0?n.from:Math.min(n.from,i),s=s<0?n.to:Math.max(n.to,s),n.typeOver&&(o=!0))}if(!l.some((t=>"BR"==t.nodeName))||8!=t.input.lastKeyCode&&46!=t.input.lastKeyCode){if(rn&&l.length){let e=l.filter((t=>"BR"==t.nodeName));if(2==e.length){let[t,n]=e;t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of e){let e=r.parentNode;!e||"LI"!=e.nodeName||n&&Bi(t,n)==e||r.remove()}}}}else for(let t of l)if("BR"==t.nodeName&&t.parentNode){let e=t.nextSibling;for(;e&&1==e.nodeType;){if("false"==e.contentEditable){t.parentNode.removeChild(t);break}e=e.firstChild}}let u=null;i<0&&r&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&qe(n)&&(u=ir(t))&&u.eq(re.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,or(t),this.currentSelection.set(n),t.scrollToSelection()):(i>-1||r)&&(i>-1&&(t.docView.markDirty(i,s),function(t){if(!Ii.has(t)&&(Ii.set(t,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace))){if(t.requiresGeckoHackNode=rn,Pi)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Pi=!0}}(t)),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,function(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let s of e)if("TR"==(null===(n=s.parentNode)||void 0===n?void 0:n.nodeName)){let e=s.nextSibling;for(;e&&"TD"!=e.nodeName&&"TH"!=e.nodeName;)e=e.nextSibling;if(e){let n=e;for(;;){let t=n.firstChild;if(!t||1!=t.nodeType||"false"==t.contentEditable||/^(BR|IMG)$/.test(t.nodeName))break;n=t}n.insertBefore(s,n.firstChild),r==s&&t.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}(t,l)),this.handleDOMChange(i,s,o,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||or(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(let n=0;n<t.addedNodes.length;n++){let r=t.addedNodes[n];e.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let r=t.previousSibling,i=t.nextSibling;if(en&&nn<=11&&t.addedNodes.length)for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:n,nextSibling:s}=t.addedNodes[e];(!n||Array.prototype.indexOf.call(t.addedNodes,n)<0)&&(r=n),(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)&&(i=s)}let s=r&&r.parentNode==t.target?Be(r)+1:0,o=n.localPosFromDOM(t.target,s,-1),l=i&&i.parentNode==t.target?Be(i):t.target.childNodes.length;return{from:o,to:n.localPosFromDOM(t.target,l,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=t.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let Ii=new WeakMap,Pi=!1;function Di(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Fe(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function Bi(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let e=t.docView.nearestDesc(n,!0);if(e&&e.node.isBlock)return n}return null}function ji(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(un&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||un&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const zi=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function _i(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:dr(t,e.resolve(n.anchor),e.resolve(n.head))}function Fi(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let e=t.node(r).maybeChild(t.indexAfter(r));for(;e&&!e.isLeaf;)e=e.firstChild,i++}return i}function Wi(t){if(2!=t.length)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class Ki{constructor(t,e){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Wr,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(Gi),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=qi(this),Ji(this),this.nodeViews=Vi(this),this.docView=Fn(this.state.doc,Ui(this),$i(this),this.dom,this),this.domObserver=new Ni(this,((t,e,n,r)=>function(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,n=ir(t,e);if(n&&!t.state.selection.eq(n)){if(on&&fn&&13===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,Ve(13,"Enter")))))return;let r=t.state.tr.setSelection(n);"pointer"==e?r.setMeta("pointer",!0):"key"==e&&r.scrollIntoView(),s&&r.setMeta("composition",s),t.dispatch(r)}return}let o=t.state.doc.resolve(e),u=o.sharedDepth(n);e=o.before(u+1),n=t.state.doc.resolve(n).after(u+1);let a,h,c=t.state.selection,f=function(t,e,n){let r,{node:i,fromOffset:s,toOffset:o,from:l,to:u}=t.docView.parseRange(e,n),a=t.domSelectionRange(),h=a.anchorNode;if(h&&t.dom.contains(1==h.nodeType?h:h.parentNode)&&(r=[{node:h,offset:a.anchorOffset}],qe(a)||r.push({node:a.focusNode,offset:a.focusOffset})),on&&8===t.input.lastKeyCode)for(let t=o;t>s;t--){let e=i.childNodes[t-1],n=e.pmViewDesc;if("BR"==e.nodeName&&!n){o=t;break}if(!n||n.size)break}let c=t.state.doc,f=t.someProp("domParser")||Z.fromSchema(t.state.schema),d=c.resolve(l),p=null,m=f.parse(i,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:!0,from:s,to:o,preserveWhitespace:"pre"!=d.parent.type.whitespace||"full",findPositions:r,ruleFromNode:ji,context:d});if(r&&null!=r[0].pos){let t=r[0].pos,e=r[1]&&r[1].pos;null==e&&(e=t),p={anchor:t+l,head:e+l}}return{doc:m,sel:p,from:l,to:u}}(t,e,n),d=t.state.doc,p=d.slice(f.from,f.to);8===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime?(a=t.state.selection.to,h="end"):(a=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let m=function(t,e,n,r,i){let s=t.findDiffStart(e,n);if(null==s)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if("end"==i&&(r-=o+Math.max(0,s-Math.min(o,l))-s),o<s&&t.size<e.size){let t=r<=s&&r>=o?s-r:0;s-=t,s&&s<e.size&&Wi(e.textBetween(s-1,s+1))&&(s+=t?1:-1),l=s+(l-o),o=s}else if(l<s){let e=r<=s&&r>=l?s-r:0;s-=e,s&&s<t.size&&Wi(t.textBetween(s-1,s+1))&&(s+=e?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}(p.content,f.doc.content,f.from,a,h);if(m&&t.input.domChangeCount++,(an&&t.input.lastIOSEnter>Date.now()-225||fn)&&i.some((t=>1==t.nodeType&&!zi.test(t.nodeName)))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",(e=>e(t,Ve(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(!m){if(!(r&&c instanceof le&&!c.empty&&c.$head.sameParent(c.$anchor))||t.composing||f.sel&&f.sel.anchor!=f.sel.head){if(f.sel){let e=_i(t,t.state.doc,f.sel);if(e&&!e.eq(t.state.selection)){let n=t.state.tr.setSelection(e);s&&n.setMeta("composition",s),t.dispatch(n)}}return}m={start:c.from,endA:c.to,endB:c.to}}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof le&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=f.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to)),en&&nn<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>f.from&&"  "==f.doc.textBetween(m.start-f.from-1,m.start-f.from+1)&&(m.start--,m.endA--,m.endB--);let g=f.doc.resolveNoCache(m.start-f.from),w=f.doc.resolveNoCache(m.endB-f.from),b=d.resolve(m.start),y=g.sameParent(w)&&g.parent.inlineContent&&b.end()>=m.endA;if((an&&t.input.lastIOSEnter>Date.now()-225&&(!y||i.some((t=>"DIV"==t.nodeName||"P"==t.nodeName)))||!y&&g.pos<f.doc.content.size&&(!g.sameParent(w)||!g.parent.inlineContent)&&g.pos<w.pos&&!/\S/.test(f.doc.textBetween(g.pos,w.pos,"","")))&&t.someProp("handleKeyDown",(e=>e(t,Ve(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>m.start&&function(t,e,n,r,i){if(n-e<=i.pos-r.pos||Fi(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let t=s.nodeAfter;return null!=t&&n==e+t.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(Fi(s,!0,!0));return!(!o.parent.isTextblock||o.pos>n||Fi(o,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(o.parent.content)}(d,m.start,m.endA,g,w)&&t.someProp("handleKeyDown",(e=>e(t,Ve(8,"Backspace")))))return void(fn&&on&&t.domObserver.suppressSelectionUpdates());on&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),fn&&!y&&g.start()!=w.start()&&0==w.parentOffset&&g.depth==w.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==m.endA&&(m.endB-=2,w=f.doc.resolveNoCache(m.endB-f.from),setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,Ve(13,"Enter"))}))}),20));let v,k=m.start,M=m.endA,T=e=>{let n=e||t.state.tr.replace(k,M,f.doc.slice(m.start-f.from,m.endB-f.from));if(f.sel){let e=_i(t,n.doc,f.sel);e&&!(on&&t.composing&&e.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==k||e.head==n.mapping.map(M)-1)||en&&e.empty&&e.head==k)&&n.setSelection(e)}return s&&n.setMeta("composition",s),n.scrollIntoView()};if(y)if(g.pos==w.pos){en&&nn<=11&&0==g.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((()=>or(t)),20));let e=T(t.state.tr.delete(k,M)),n=d.resolve(m.start).marksAcross(d.resolve(m.endA));n&&e.ensureMarks(n),t.dispatch(e)}else if(m.endA==m.endB&&(v=function(t,e){let n,r,i,s=t.firstChild.marks,o=e.firstChild.marks,u=s,a=o;for(let t=0;t<o.length;t++)u=o[t].removeFromSet(u);for(let t=0;t<s.length;t++)a=s[t].removeFromSet(a);if(1==u.length&&0==a.length)r=u[0],n="add",i=t=>t.mark(r.addToSet(t.marks));else{if(0!=u.length||1!=a.length)return null;r=a[0],n="remove",i=t=>t.mark(r.removeFromSet(t.marks))}let h=[];for(let t=0;t<e.childCount;t++)h.push(i(e.child(t)));if(l.from(h).eq(t))return{mark:r,type:n}}(g.parent.content.cut(g.parentOffset,w.parentOffset),b.parent.content.cut(b.parentOffset,m.endA-b.start())))){let e=T(t.state.tr);"add"==v.type?e.addMark(k,M,v.mark):e.removeMark(k,M,v.mark),t.dispatch(e)}else if(g.parent.child(g.index()).isText&&g.index()==w.index()-(w.textOffset?0:1)){let e=g.parent.textBetween(g.parentOffset,w.parentOffset),n=()=>T(t.state.tr.insertText(e,k,M));t.someProp("handleTextInput",(r=>r(t,k,M,e,n)))||t.dispatch(n())}else t.dispatch(T());else t.dispatch(T())}(this,t,e,n,r))),this.domObserver.start(),function(t){for(let e in zr){let n=zr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{!qr(t,e)||Jr(t,e)||!t.editable&&e.type in _r||n(t,e)},Fr[e]?{passive:!0}:void 0)}un&&t.dom.addEventListener("input",(()=>null)),Ur(t)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Ur(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(Gi),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var n;let r=this.state,i=!1,s=!1;t.storedMarks&&this.composing&&(si(this),s=!0),this.state=t;let o=r.plugins!=t.plugins||this._props.plugins!=e.plugins;if(o||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=Vi(this);(function(t,e){let n=0,r=0;for(let r in t){if(t[r]!=e[r])return!0;n++}for(let t in e)r++;return n!=r})(t,this.nodeViews)&&(this.nodeViews=t,i=!0)}(o||e.handleDOMEvents!=this._props.handleDOMEvents)&&Ur(this),this.editable=qi(this),Ji(this);let l=$i(this),u=Ui(this),a=r.plugins==t.plugins||r.doc.eq(t.doc)?t.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",h=i||!this.docView.matchesNode(t.doc,u,l);!h&&t.selection.eq(r.selection)||(s=!0);let c="preserve"==a&&s&&null==this.dom.style.overflowAnchor&&function(t){let e,n,r=t.dom.getBoundingClientRect(),i=Math.max(0,r.top);for(let s=(r.left+r.right)/2,o=i+1;o<Math.min(innerHeight,r.bottom);o+=5){let r=t.root.elementFromPoint(s,o);if(!r||r==t.dom||!t.dom.contains(r))continue;let l=r.getBoundingClientRect();if(l.top>=i-20){e=r,n=l.top;break}}return{refDOM:e,refTop:n,stack:yn(t.dom)}}(this);if(s){this.domObserver.stop();let e=h&&(en||on)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&function(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}(r.selection,t.selection);if(h){let n=on?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=function(t,e){for(;;){if(3==t.nodeType&&e)return t;if(1==t.nodeType&&e>0){if("false"==t.contentEditable)return null;e=Ue(t=t.childNodes[e-1])}else{if(!t.parentNode||Je(t))return null;e=Be(t),t=t.parentNode}}}(e.focusNode,e.focusOffset),r=function(t,e){for(;;){if(3==t.nodeType&&e<t.nodeValue.length)return t;if(1==t.nodeType&&e<t.childNodes.length){if("false"==t.contentEditable)return null;t=t.childNodes[e],e=0}else{if(!t.parentNode||Je(t))return null;e=Be(t)+1,t=t.parentNode}}}(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let e=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!e||!e.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let t=n.pmViewDesc;if(t&&t.isText(n.nodeValue))return r}}return n||r}(this)),!i&&this.docView.update(t.doc,u,l,this)||(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Fn(t.doc,u,l,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Fe(e.node,e.offset,n.anchorNode,n.anchorOffset)}(this))?or(this,e):(cr(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==a?this.dom.scrollTop=0:"to selection"==a?this.scrollToSelection():c&&function({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;vn(n,0==r?0:r-e)}(c)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(t&&this.dom.contains(1==t.nodeType?t:t.parentNode))if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof ae){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&bn(this,e.getBoundingClientRect(),t)}else bn(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}}}updateDraggedNode(t,e){let n=t.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let t=n.from+(this.state.doc.content.size-e.doc.content.size);(t>0&&t<this.state.doc.content.size&&this.state.doc.nodeAt(t))==n.node&&(r=t)}this.dragging=new hi(t.slice,t.move,r<0?void 0:ae.create(this.state.doc,r))}someProp(t,e){let n,r=this._props&&this._props[t];if(null!=r&&(n=e?e(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let i=this.directPlugins[r].props[t];if(null!=i&&(n=e?e(i):i))return n}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let s=i[r].props[t];if(null!=s&&(n=e?e(s):s))return n}}hasFocus(){if(en){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if("false"==t.contentEditable)return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(kn)return t.focus(kn);let e=yn(t);t.focus(null==kn?{get preventScroll(){return kn={preventScroll:!0},!0}}:void 0),kn||(kn=!1,vn(e,0))}(this.dom),or(this),this.domObserver.start()}get root(){let t=this._root;if(null==t)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return t||document}updateRoot(){this._root=null}posAtCoords(t){return Ln(this,t)}coordsAtPos(t,e=1){return On(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let r=this.docView.posFromDOM(t,e,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(t,e){return function(t,e,n){return Nn==e&&In==n?Pn:(Nn=e,In=n,Pn="up"==n||"down"==n?function(t,e,n){let r=e.selection,i="up"==n?r.$from:r.$to;return Rn(t,e,(()=>{let{node:e}=t.docView.domFromPos(i.pos,"up"==n?-1:1);for(;;){let n=t.docView.nearestDesc(e,!0);if(!n)break;if(n.node.isBlock){e=n.contentDOM||n.dom;break}e=n.dom.parentNode}let r=On(t,i.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=_e(t,0,t.nodeValue.length).getClientRects()}for(let t=0;t<e.length;t++){let i=e[t];if(i.bottom>i.top+1&&("up"==n?r.top-i.top>2*(i.bottom-r.top):i.bottom-r.bottom>2*(r.bottom-i.top)))return!1}}return!0}))}(t,e,n):function(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=t.domSelection();return l?Hn.test(r.parent.textContent)&&l.modify?Rn(t,e,(()=>{let{focusNode:e,focusOffset:i,anchorNode:s,anchorOffset:o}=t.domSelectionRange(),u=l.caretBidiLevel;l.modify("move",n,"character");let a=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:h,focusOffset:c}=t.domSelectionRange(),f=h&&!a.contains(1==h.nodeType?h:h.parentNode)||e==h&&i==c;try{l.collapse(s,o),e&&(e!=s||i!=o)&&l.extend&&l.extend(e,i)}catch(t){}return null!=u&&(l.caretBidiLevel=u),f})):"left"==n||"backward"==n?s:o:r.pos==r.start()||r.pos==r.end()}(t,e,n))}(this,e||this.state,t)}pasteHTML(t,e){return ui(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return ui(this,t,null,!0,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return Er(this,t)}destroy(){this.docView&&(function(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],$i(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ze=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function(t,e){Jr(t,e)||!zr[e.type]||!t.editable&&e.type in _r||zr[e.type](t,e)}(this,t)}domSelectionRange(){let t=this.domSelection();return t?un&&11===this.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t,e){if(e.getComposedRanges){let n=e.getComposedRanges(t.root)[0];if(n)return Di(t,n)}let n;function r(t){t.preventDefault(),t.stopImmediatePropagation(),n=t.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Di(t,n):null}(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ui(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(t.state)),n)for(let t in n)"class"==t?e.class+=" "+n[t]:"style"==t?e.style=(e.style?e.style+";":"")+n[t]:e[t]||"contenteditable"==t||"nodeName"==t||(e[t]=String(n[t]))})),e.translate||(e.translate="no"),[wi.node(0,t.state.doc.content.size,e)]}function Ji(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:wi.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function qi(t){return!t.someProp("editable",(e=>!1===e(t.state)))}function Vi(t){let e=Object.create(null);function n(t){for(let n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function Gi(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}Ki.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};for(var Xi={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Qi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Zi="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Yi="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ts=0;ts<10;ts++)Xi[48+ts]=Xi[96+ts]=String(ts);for(ts=1;ts<=24;ts++)Xi[ts+111]="F"+ts;for(ts=65;ts<=90;ts++)Xi[ts]=String.fromCharCode(ts+32),Qi[ts]=String.fromCharCode(ts);for(var es in Xi)Qi.hasOwnProperty(es)||(Qi[es]=Xi[es]);const ns="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),rs="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function is(t){let e,n,r,i,s=t.split(/-(?!$)/),o=s[s.length-1];"Space"==o&&(o=" ");for(let t=0;t<s.length-1;t++){let o=s[t];if(/^(cmd|meta|m)$/i.test(o))i=!0;else if(/^a(lt)?$/i.test(o))e=!0;else if(/^(c|ctrl|control)$/i.test(o))n=!0;else if(/^s(hift)?$/i.test(o))r=!0;else{if(!/^mod$/i.test(o))throw new Error("Unrecognized modifier name: "+o);ns?i=!0:n=!0}}return e&&(o="Alt-"+o),n&&(o="Ctrl-"+o),i&&(o="Meta-"+o),r&&(o="Shift-"+o),o}function ss(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function ls(t){let e=function(t){let e=Object.create(null);for(let n in t)e[is(n)]=t[n];return e}(t);return function(t,n){let r,i=function(t){var e=!(Zi&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Yi&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?Qi:Xi)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(n),s=e[ss(i,n)];if(s&&s(t.state,t.dispatch,t))return!0;if(1==i.length&&" "!=i){if(n.shiftKey){let r=e[ss(i,n,!1)];if(r&&r(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(rs&&n.ctrlKey&&n.altKey)&&(r=Xi[n.keyCode])&&r!=i){let i=e[ss(r,n)];if(i&&i(t.state,t.dispatch,t))return!0}}return!1}}var us=Object.defineProperty,as=(t,e)=>{for(var n in e)us(t,n,{get:e[n],enumerable:!0})};function hs(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}var cs=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map((([t,e])=>[t,(...t)=>{const n=e(...t)(s);return i.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(i),n}])))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o=[],l=!!t,u=t||i.tr,a={...Object.fromEntries(Object.entries(n).map((([t,n])=>[t,(...t)=>{const r=this.buildProps(u,e),i=n(...t)(r);return o.push(i),a}]))),run:()=>(l||!e||u.getMeta("preventDispatch")||this.hasCustomState||s.dispatch(u),o.every((t=>!0===t)))};return a}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map((([t,e])=>[t,(...t)=>e(...t)({...s,dispatch:void 0})]))),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o={tr:t,editor:r,view:s,state:hs({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map((([t,e])=>[t,(...t)=>e(...t)(o)])))}};return o}},fs={};as(fs,{blur:()=>ds,clearContent:()=>ps,clearNodes:()=>ms,command:()=>gs,createParagraphNear:()=>ws,cut:()=>bs,deleteCurrentNode:()=>ys,deleteNode:()=>ks,deleteRange:()=>Ms,deleteSelection:()=>xs,enter:()=>Ls,exitCode:()=>Ss,extendMarkRange:()=>Hs,first:()=>Ns,focus:()=>zs,forEach:()=>_s,insertContent:()=>Fs,insertContentAt:()=>Js,joinBackward:()=>Gs,joinDown:()=>Vs,joinForward:()=>Xs,joinItemBackward:()=>Qs,joinItemForward:()=>Zs,joinTextblockBackward:()=>Ys,joinTextblockForward:()=>to,joinUp:()=>qs,keyboardShortcut:()=>no,lift:()=>io,liftEmptyBlock:()=>so,liftListItem:()=>oo,newlineInCode:()=>lo,resetAttributes:()=>ho,scrollIntoView:()=>co,selectAll:()=>fo,selectNodeBackward:()=>po,selectNodeForward:()=>mo,selectParentNode:()=>go,selectTextblockEnd:()=>wo,selectTextblockStart:()=>bo,setContent:()=>vo,setMark:()=>ol,setMeta:()=>ll,setNode:()=>ul,setNodeSelection:()=>al,setTextDirection:()=>hl,setTextSelection:()=>cl,sinkListItem:()=>fl,splitBlock:()=>pl,splitListItem:()=>ml,toggleList:()=>bl,toggleMark:()=>yl,toggleNode:()=>vl,toggleWrap:()=>kl,undoInputRule:()=>Ml,unsetAllMarks:()=>Tl,unsetMark:()=>xl,unsetTextDirection:()=>Ll,updateAttributes:()=>Sl,wrapIn:()=>Al,wrapInList:()=>El});var ds=()=>({editor:t,view:e})=>(requestAnimationFrame((()=>{var n;t.isDestroyed||(e.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())})),!0),ps=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),ms=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return!n||(i.forEach((({$from:n,$to:r})=>{t.doc.nodesBetween(n.pos,r.pos,((t,n)=>{if(t.type.isText)return;const{doc:r,mapping:i}=e,s=r.resolve(i.map(n)),o=r.resolve(i.map(n+t.nodeSize)),l=s.blockRange(o);if(!l)return;const u=Rt(l);if(t.type.isTextblock){const{defaultType:t}=s.parent.contentMatchAt(s.index());e.setNodeMarkup(l.start,t)}(u||0===u)&&e.lift(l,u)}))})),!0)},gs=t=>e=>t(e),ws=()=>({state:t,dispatch:e})=>((t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof ce||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Re(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=t.tr.insert(n,s.createAndFill());o.setSelection(le.create(o.doc,n+1)),e(o.scrollIntoView())}return!0})(t,e),bs=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new le(r.doc.resolve(Math.max(o-1,0)))),!0},ys=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let n=i.depth;n>0;n-=1)if(i.node(n).type===r.type){if(e){const e=i.before(n),r=i.after(n);t.delete(e,r).scrollIntoView()}return!0}return!1};function vs(t,e){if("string"==typeof t){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var ks=t=>({tr:e,state:n,dispatch:r})=>{const i=vs(t,n.schema),s=e.selection.$anchor;for(let t=s.depth;t>0;t-=1)if(s.node(t).type===i){if(r){const n=s.before(t),r=s.after(t);e.delete(n,r).scrollIntoView()}return!0}return!1},Ms=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},Ts=(t,e,n)=>{return t.parent.isInline?"left"===n&&t.pos>t.start()||"right"===n&&t.pos<t.end()?t.pos:(r=e.nodes[t.parent.type.name].spec).content&&/^text(\*|\+)/.test(r.content)?"left"===n?t.start()-1:t.end()+1:t.pos:t.pos;var r},xs=()=>({state:t,dispatch:e})=>{const{$from:n,$to:r}=t.selection;if(t.selection.empty)return!1;const{from:i,to:s}=((t,e,n)=>({from:Ts(t,n,"left"),to:Ts(e,n,"right")}))(n,r,t.schema);return e&&(t.tr.deleteRange(i,s).scrollIntoView(),e(t.tr)),!0},Ls=()=>({commands:t})=>t.keyboardShortcut("Enter"),Ss=()=>({state:t,dispatch:e})=>((t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=Re(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let r=n.after(),i=t.tr.replaceWith(r,r,o.createAndFill());i.setSelection(re.near(i.doc.resolve(r),1)),e(i.scrollIntoView())}return!0})(t,e);function As(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function Es(t,e,n={strict:!0}){const r=Object.keys(e);return!r.length||r.every((r=>n.strict?e[r]===t[r]:As(e[r])?e[r].test(t[r]):e[r]===t[r]))}function Os(t,e,n={}){return t.find((t=>t.type===e&&Es(Object.fromEntries(Object.keys(n).map((e=>[e,t.attrs[e]]))),n)))}function $s(t,e,n={}){return!!Os(t,e,n)}function Cs(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(r.node&&r.node.marks.some((t=>t.type===e))||(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some((t=>t.type===e)))return;if(!n){const t=r.node.marks.find((t=>t.type===e));t&&(n=t.attrs)}if(!Os([...r.node.marks],e,n))return;let i=r.index,s=t.start()+r.offset,o=i+1,l=s+r.node.nodeSize;for(;i>0&&$s([...t.parent.child(i-1).marks],e,n);)i-=1,s-=t.parent.child(i).nodeSize;for(;o<t.parent.childCount&&$s([...t.parent.child(o).marks],e,n);)l+=t.parent.child(o).nodeSize,o+=1;return{from:s,to:l}}function Rs(t,e){if("string"==typeof t){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var Hs=(t,e)=>({tr:n,state:r,dispatch:i})=>{const s=Rs(t,r.schema),{doc:o,selection:l}=n,{$from:u,from:a,to:h}=l;if(i){const t=Cs(u,s,e);if(t&&t.from<=a&&t.to>=h){const e=le.create(o,t.from,t.to);n.setSelection(e)}}return!0},Ns=t=>e=>{const n="function"==typeof t?t(e):t;for(let t=0;t<n.length;t+=1)if(n[t](e))return!0;return!1};function Is(t){return t instanceof le}function Ps(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Ds(t,e=null){if(!e)return null;const n=re.atStart(t),r=re.atEnd(t);if("start"===e||!0===e)return n;if("end"===e)return r;const i=n.from,s=r.to;return"all"===e?le.create(t,Ps(0,i,s),Ps(t.content.size,i,s)):le.create(t,Ps(e,i,s),Ps(e,i,s))}function Bs(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function js(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var zs=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(js()||Bs())&&r.dom.focus(),"undefined"==typeof navigator||!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||js()||Bs()||r.dom.focus({preventScroll:!0}),requestAnimationFrame((()=>{n.isDestroyed||(r.focus(),(null==e?void 0:e.scrollIntoView)&&n.commands.scrollIntoView())}))};try{if(r.hasFocus()&&null===t||!1===t)return!0}catch{return!1}if(s&&null===t&&!Is(n.state.selection))return o(),!0;const l=Ds(i.doc,t)||n.state.selection,u=n.state.selection.eq(l);return s&&(u||i.setSelection(l),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},_s=(t,e)=>n=>t.every(((t,r)=>e(t,{...n,index:r}))),Fs=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Ws=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):1===r.nodeType&&Ws(r)}return t};function Ks(t){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=(new window.DOMParser).parseFromString(e,"text/html").body;return Ws(n)}function Us(t,e,n){if(t instanceof C||t instanceof l)return t;n={slice:!0,parseOptions:{},...n};const r="string"==typeof t;if("object"==typeof t&&null!==t)try{if(Array.isArray(t)&&t.length>0)return l.fromArray(t.map((t=>e.nodeFromJSON(t))));const r=e.nodeFromJSON(t);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",r),Us("",e,n)}if(r){if(n.errorOnInvalidContent){let r=!1,i="";const s=new X({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:t=>(r=!0,i="string"==typeof t?t:t.outerHTML,null)}]}})});if(n.slice?Z.fromSchema(s).parseSlice(Ks(t),n.parseOptions):Z.fromSchema(s).parse(Ks(t),n.parseOptions),n.errorOnInvalidContent&&r)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const r=Z.fromSchema(e);return n.slice?r.parseSlice(Ks(t),n.parseOptions).content:r.parse(Ks(t),n.parseOptions)}return Us("",e,n)}var Js=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){let i;const u=t=>{s.emit("contentError",{editor:s,error:t,disableCollaboration:()=>{"collaboration"in s.storage&&"object"==typeof s.storage.collaboration&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},a={preserveWhitespace:"full",...(n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n}).parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Us(e,s.schema,{parseOptions:a,errorOnInvalidContent:!0})}catch(t){u(t)}try{i=Us(e,s.schema,{parseOptions:a,errorOnInvalidContent:null!=(o=n.errorOnInvalidContent)?o:s.options.enableContentCheck})}catch(t){return u(t),!1}let h,{from:c,to:f}="number"==typeof t?{from:t,to:t}:{from:t.from,to:t.to},d=!0,p=!0;if(("type"in i?[i]:i).forEach((t=>{t.check(),d=!!d&&t.isText&&0===t.marks.length,p=!!p&&t.isBlock})),c===f&&p){const{parent:t}=r.doc.resolve(c);t.isTextblock&&!t.type.spec.code&&!t.childCount&&(c-=1,f+=1)}if(d){if(Array.isArray(e))h=e.map((t=>t.text||"")).join("");else if(e instanceof l){let t="";e.forEach((e=>{e.text&&(t+=e.text)})),h=t}else h="object"==typeof e&&e&&e.text?e.text:e;r.insertText(h,c,f)}else{h=i;const t=r.doc.resolve(c),e=t.node();0===t.parentOffset&&(e.isText||e.isTextblock)&&e.content.size>0&&p&&(c=Math.max(0,c-1)),r.replaceWith(c,f,h)}n.updateSelection&&function(t,e){const n=t.steps.length-1;if(n<e)return;const r=t.steps[n];if(!(r instanceof At||r instanceof Et))return;let i=0;t.mapping.maps[n].forEach(((t,e,n,r)=>{0===i&&(i=r)})),t.setSelection(re.near(t.doc.resolve(i),-1))}(r,r.steps.length-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:c,text:h}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:c,text:h})}return!0},qs=()=>({state:t,dispatch:e})=>((t,e)=>{let n,r=t.selection,i=r instanceof ae;if(i){if(r.node.isTextblock||!Bt(t.doc,r.from))return!1;n=r.from}else if(n=zt(t.doc,r.from,-1),null==n)return!1;if(e){let r=t.tr.join(n);i&&r.setSelection(ae.create(r.doc,n-t.doc.resolve(n).nodeBefore.nodeSize)),e(r.scrollIntoView())}return!0})(t,e),Vs=()=>({state:t,dispatch:e})=>((t,e)=>{let n,r=t.selection;if(r instanceof ae){if(r.node.isTextblock||!Bt(t.doc,r.to))return!1;n=r.to}else if(n=zt(t.doc,r.to,1),null==n)return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0})(t,e),Gs=()=>({state:t,dispatch:e})=>((t,e)=>{let n=Se(t,void 0);if(!n)return!1;let r=Oe(n);if(!r){let r=n.blockRange(),i=r&&Rt(r);return null!=i&&(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)}let i=r.nodeBefore;if(He(t,r,e,-1))return!0;if(0==n.parent.content.size&&(Ee(i,"end")||ae.isSelectable(i)))for(let s=n.depth;;s--){let o=Ft(t.doc,n.before(s),n.after(s),d.empty);if(o&&o.slice.size<o.to-o.from){if(e){let n=t.tr.step(o);n.setSelection(Ee(i,"end")?re.findFrom(n.doc.resolve(n.mapping.map(r.pos,-1)),-1):ae.create(n.doc,r.pos-i.nodeSize)),e(n.scrollIntoView())}return!0}if(1==s||n.node(s-1).childCount>1)break}return!(!i.isAtom||r.depth!=n.depth-1||(e&&e(t.tr.delete(r.pos-i.nodeSize,r.pos).scrollIntoView()),0))})(t,e),Xs=()=>({state:t,dispatch:e})=>((t,e)=>{let n=$e(t,void 0);if(!n)return!1;let r=Ce(n);if(!r)return!1;let i=r.nodeAfter;if(He(t,r,e,1))return!0;if(0==n.parent.content.size&&(Ee(i,"start")||ae.isSelectable(i))){let s=Ft(t.doc,n.before(),n.after(),d.empty);if(s&&s.slice.size<s.to-s.from){if(e){let n=t.tr.step(s);n.setSelection(Ee(i,"start")?re.findFrom(n.doc.resolve(n.mapping.map(r.pos)),1):ae.create(n.doc,n.mapping.map(r.pos))),e(n.scrollIntoView())}return!0}}return!(!i.isAtom||r.depth!=n.depth-1||(e&&e(t.tr.delete(r.pos,r.pos+i.nodeSize).scrollIntoView()),0))})(t,e),Qs=()=>({state:t,dispatch:e,tr:n})=>{try{const r=zt(t.doc,t.selection.$from.pos,-1);return null!=r&&(n.join(r,2),e&&e(n),!0)}catch{return!1}},Zs=()=>({state:t,dispatch:e,tr:n})=>{try{const r=zt(t.doc,t.selection.$from.pos,1);return null!=r&&(n.join(r,2),e&&e(n),!0)}catch{return!1}},Ys=()=>({state:t,dispatch:e})=>((t,e)=>{let n=Se(t,void 0);if(!n)return!1;let r=Oe(n);return!!r&&Ae(t,r,e)})(t,e),to=()=>({state:t,dispatch:e})=>((t,e)=>{let n=$e(t,void 0);if(!n)return!1;let r=Ce(n);return!!r&&Ae(t,r,e)})(t,e);function eo(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var no=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=function(t){const e=t.split(/-(?!$)/);let n,r,i,s,o=e[e.length-1];"Space"===o&&(o=" ");for(let t=0;t<e.length-1;t+=1){const o=e[t];if(/^(cmd|meta|m)$/i.test(o))s=!0;else if(/^a(lt)?$/i.test(o))n=!0;else if(/^(c|ctrl|control)$/i.test(o))r=!0;else if(/^s(hift)?$/i.test(o))i=!0;else{if(!/^mod$/i.test(o))throw new Error(`Unrecognized modifier name: ${o}`);js()||eo()?s=!0:r=!0}}return n&&(o=`Alt-${o}`),r&&(o=`Ctrl-${o}`),s&&(o=`Meta-${o}`),i&&(o=`Shift-${o}`),o}(t).split(/-(?!$)/),o=s.find((t=>!["Alt","Ctrl","Meta","Shift"].includes(t))),l=new KeyboardEvent("keydown",{key:"Space"===o?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction((()=>{n.someProp("handleKeyDown",(t=>t(n,l)))}));return null==u||u.steps.forEach((t=>{const e=t.map(r.mapping);e&&i&&r.maybeStep(e)})),!0};function ro(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?vs(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,((t,e)=>{if(t.isText)return;const n=Math.max(r,e),s=Math.min(i,e+t.nodeSize);l.push({node:t,from:n,to:s})}));const u=i-r,a=l.filter((t=>!o||o.name===t.node.type.name)).filter((t=>Es(t.node.attrs,n,{strict:!1})));return s?!!a.length:a.reduce(((t,e)=>t+e.to-e.from),0)>=u}var io=(t,e={})=>({state:n,dispatch:r})=>!!ro(n,vs(t,n.schema),e)&&((t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&Rt(i);return null!=s&&(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)})(n,r),so=()=>({state:t,dispatch:e})=>((t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Dt(t.doc,r))return e&&e(t.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Rt(r);return null!=i&&(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)})(t,e),oo=t=>({state:e,dispatch:n})=>{return(r=vs(t,e.schema),function(t,e){let{$from:n,$to:i}=t.selection,s=n.blockRange(i,(t=>t.childCount>0&&t.firstChild.type==r));return!!s&&(!e||(n.node(s.depth-1).type==r?function(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new Et(s-1,o,s,o,new d(l.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new O(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const u=Rt(r);if(null==u)return!1;i.lift(r,u);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return Bt(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}(t,e,r,s):function(t,e,n){let r=t.tr,i=n.parent;for(let t=n.end,e=n.endIndex-1,s=n.startIndex;e>s;e--)t-=i.child(e).nodeSize,r.delete(t-1,t+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let u=0==n.startIndex,a=n.endIndex==i.childCount,h=s.node(-1),c=s.index(-1);if(!h.canReplace(c+(u?0:1),c+1,o.content.append(a?l.empty:l.from(i))))return!1;let f=s.pos,p=f+o.nodeSize;return r.step(new Et(f-(u?1:0),p+(a?1:0),f+1,p-1,new d((u?l.empty:l.from(i.copy(l.empty))).append(a?l.empty:l.from(i.copy(l.empty))),u?0:1,a?0:1),u?0:1)),e(r.scrollIntoView()),!0}(t,e,s)))})(e,n);var r},lo=()=>({state:t,dispatch:e})=>((t,e)=>{let{$head:n,$anchor:r}=t.selection;return!(!n.parent.type.spec.code||!n.sameParent(r)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))})(t,e);function uo(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function ao(t,e){const n="string"==typeof e?[e]:e;return Object.keys(t).reduce(((e,r)=>(n.includes(r)||(e[r]=t[r]),e)),{})}var ho=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=uo("string"==typeof t?t:t.name,r.schema);if(!l)return!1;"node"===l&&(s=vs(t,r.schema)),"mark"===l&&(o=Rs(t,r.schema));let u=!1;return n.selection.ranges.forEach((t=>{r.doc.nodesBetween(t.$from.pos,t.$to.pos,((t,r)=>{s&&s===t.type&&(u=!0,i&&n.setNodeMarkup(r,void 0,ao(t.attrs,e))),o&&t.marks.length&&t.marks.forEach((s=>{o===s.type&&(u=!0,i&&n.addMark(r,r+t.nodeSize,o.create(ao(s.attrs,e))))}))}))})),u},co=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),fo=()=>({tr:t,dispatch:e})=>{if(e){const e=new ce(t.doc);t.setSelection(e)}return!0},po=()=>({state:t,dispatch:e})=>((t,e)=>{let{$head:n,empty:r}=t.selection,i=n;if(!r)return!1;if(n.parent.isTextblock){if(n.parentOffset>0)return!1;i=Oe(n)}let s=i&&i.nodeBefore;return!(!s||!ae.isSelectable(s)||(e&&e(t.tr.setSelection(ae.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),0))})(t,e),mo=()=>({state:t,dispatch:e})=>((t,e)=>{let{$head:n,empty:r}=t.selection,i=n;if(!r)return!1;if(n.parent.isTextblock){if(n.parentOffset<n.parent.content.size)return!1;i=Ce(n)}let s=i&&i.nodeAfter;return!(!s||!ae.isSelectable(s)||(e&&e(t.tr.setSelection(ae.create(t.doc,i.pos)).scrollIntoView()),0))})(t,e),go=()=>({state:t,dispatch:e})=>((t,e)=>{let n,{$from:r,to:i}=t.selection,s=r.sharedDepth(i);return 0!=s&&(n=r.before(s),e&&e(t.tr.setSelection(ae.create(t.doc,n))),!0)})(t,e),wo=()=>({state:t,dispatch:e})=>Pe(t,e),bo=()=>({state:t,dispatch:e})=>Ie(t,e);function yo(t,e,n={},r={}){return Us(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var vo=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:u}=s;if("full"!==r.preserveWhitespace){const l=yo(t,i.schema,r,{errorOnInvalidContent:null!=e?e:i.options.enableContentCheck});return o&&s.replaceWith(0,u.content.size,l).setMeta("preventUpdate",!n),!0}return o&&s.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:u.content.size},t,{parseOptions:r,errorOnInvalidContent:null!=e?e:i.options.enableContentCheck})};function ko(t,e){const n=Rs(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,(t=>{o.push(...t.marks)}));const l=o.find((t=>t.type.name===n.name));return l?{...l.attrs}:{}}function Mo(t,e){const n=new ee(t);return e.forEach((t=>{t.steps.forEach((t=>{n.step(t)}))})),n}function To(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function xo(t){return e=>To(e.$from,t)}function Lo(t,e,n){return void 0===t.config[e]&&t.parent?Lo(t.parent,e,n):"function"==typeof t.config[e]?t.config[e].bind({...n,parent:t.parent?Lo(t.parent,e,n):null}):t.config[e]}function So(t){return t.map((t=>{const e=Lo(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return e?[t,...So(e())]:t})).flat(10)}function Ao(t,e){const n=ut.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function Eo(t){return"function"==typeof t}function Oo(t,e,...n){return Eo(t)?e?t.bind(e)(...n):t(...n):t}function $o(t){return{baseExtensions:t.filter((t=>"extension"===t.type)),nodeExtensions:t.filter((t=>"node"===t.type)),markExtensions:t.filter((t=>"mark"===t.type))}}function Co(t){const e=[],{nodeExtensions:n,markExtensions:r}=$o(t),i=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter((t=>"text"!==t.name)).map((t=>t.name)),l=r.map((t=>t.name)),u=[...o,...l];return t.forEach((t=>{const n=Lo(t,"addGlobalAttributes",{name:t.name,options:t.options,storage:t.storage,extensions:i});n&&n().forEach((t=>{let n;n=Array.isArray(t.types)?t.types:"*"===t.types?u:"nodes"===t.types?o:"marks"===t.types?l:[],n.forEach((n=>{Object.entries(t.attributes).forEach((([t,r])=>{e.push({type:n,name:t,attribute:{...s,...r}})}))}))}))})),i.forEach((t=>{const n=Lo(t,"addAttributes",{name:t.name,options:t.options,storage:t.storage});if(!n)return;const r=n();Object.entries(r).forEach((([n,r])=>{const i={...s,...r};"function"==typeof(null==i?void 0:i.default)&&(i.default=i.default()),(null==i?void 0:i.isRequired)&&void 0===(null==i?void 0:i.default)&&delete i.default,e.push({type:t.name,name:n,attribute:i})}))})),e}function Ro(t){const e=[],n=function(t){const e=[];let n="",r=!1,i=!1,s=0;const o=t.length;for(let l=0;l<o;l+=1){const o=t[l];if("'"!==o||i)if('"'!==o||r){if(!r&&!i){if("("===o){s+=1,n+=o;continue}if(")"===o&&s>0){s-=1,n+=o;continue}if(";"===o&&0===s){e.push(n),n="";continue}}n+=o}else i=!i,n+=o;else r=!r,n+=o}return n&&e.push(n),e}(t||""),r=n.length;for(let t=0;t<r;t+=1){const r=n[t],i=r.indexOf(":");if(-1===i)continue;const s=r.slice(0,i).trim(),o=r.slice(i+1).trim();s&&o&&e.push([s,o])}return e}function Ho(...t){return t.filter((t=>!!t)).reduce(((t,e)=>{const n={...t};return Object.entries(e).forEach((([t,e])=>{if(n[t])if("class"===t){const r=e?String(e).split(" "):[],i=n[t]?n[t].split(" "):[],s=r.filter((t=>!i.includes(t)));n[t]=[...i,...s].join(" ")}else if("style"===t){const r=new Map([...Ro(n[t]),...Ro(e)]);n[t]=Array.from(r.entries()).map((([t,e])=>`${t}: ${e}`)).join("; ")}else n[t]=e;else n[t]=e})),n}),{})}function No(t,e){return e.filter((e=>e.type===t.type.name)).filter((t=>t.attribute.rendered)).map((e=>e.attribute.renderHTML?e.attribute.renderHTML(t.attrs)||{}:{[e.name]:t.attrs[e.name]})).reduce(((t,e)=>Ho(t,e)),{})}function Io(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(!1===r)return!1;const i=e.reduce(((t,e)=>{const r=e.attribute.parseHTML?e.attribute.parseHTML(n):function(t){return"string"!=typeof t?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):"true"===t||"false"!==t&&t}(n.getAttribute(e.name));return null==r?t:{...t,[e.name]:r}}),{});return{...r,...i}}}}function Po(t){return Object.fromEntries(Object.entries(t).filter((([t,e])=>("attrs"!==t||!function(t={}){return 0===Object.keys(t).length&&t.constructor===Object}(e))&&null!=e)))}function Do(t){var e,n;const r={};return!(null==(e=null==t?void 0:t.attribute)?void 0:e.isRequired)&&"default"in((null==t?void 0:t.attribute)||{})&&(r.default=t.attribute.default),void 0!==(null==(n=null==t?void 0:t.attribute)?void 0:n.validate)&&(r.validate=t.attribute.validate),[t.name,r]}function Bo(t,e){var n;const r=Co(t),{nodeExtensions:i,markExtensions:s}=$o(t),o=null==(n=i.find((t=>Lo(t,"topNode"))))?void 0:n.name,l=Object.fromEntries(i.map((n=>{const i=r.filter((t=>t.type===n.name)),s={name:n.name,options:n.options,storage:n.storage,editor:e},o=Po({...t.reduce(((t,e)=>{const r=Lo(e,"extendNodeSchema",s);return{...t,...r?r(n):{}}}),{}),content:Oo(Lo(n,"content",s)),marks:Oo(Lo(n,"marks",s)),group:Oo(Lo(n,"group",s)),inline:Oo(Lo(n,"inline",s)),atom:Oo(Lo(n,"atom",s)),selectable:Oo(Lo(n,"selectable",s)),draggable:Oo(Lo(n,"draggable",s)),code:Oo(Lo(n,"code",s)),whitespace:Oo(Lo(n,"whitespace",s)),linebreakReplacement:Oo(Lo(n,"linebreakReplacement",s)),defining:Oo(Lo(n,"defining",s)),isolating:Oo(Lo(n,"isolating",s)),attrs:Object.fromEntries(i.map(Do))}),l=Oo(Lo(n,"parseHTML",s));l&&(o.parseDOM=l.map((t=>Io(t,i))));const u=Lo(n,"renderHTML",s);u&&(o.toDOM=t=>u({node:t,HTMLAttributes:No(t,i)}));const a=Lo(n,"renderText",s);return a&&(o.toText=a),[n.name,o]}))),u=Object.fromEntries(s.map((n=>{const i=r.filter((t=>t.type===n.name)),s={name:n.name,options:n.options,storage:n.storage,editor:e},o=Po({...t.reduce(((t,e)=>{const r=Lo(e,"extendMarkSchema",s);return{...t,...r?r(n):{}}}),{}),inclusive:Oo(Lo(n,"inclusive",s)),excludes:Oo(Lo(n,"excludes",s)),group:Oo(Lo(n,"group",s)),spanning:Oo(Lo(n,"spanning",s)),code:Oo(Lo(n,"code",s)),attrs:Object.fromEntries(i.map(Do))}),l=Oo(Lo(n,"parseHTML",s));l&&(o.parseDOM=l.map((t=>Io(t,i))));const u=Lo(n,"renderHTML",s);return u&&(o.toDOM=t=>u({mark:t,HTMLAttributes:No(t,i)})),[n.name,o]})));return new X({topNode:o,nodes:l,marks:u})}function jo(t){return t.sort(((t,e)=>{const n=Lo(t,"priority")||100,r=Lo(e,"priority")||100;return n>r?-1:n<r?1:0}))}function zo(t){const e=jo(So(t)),n=function(t){const e=t.filter(((e,n)=>t.indexOf(e)!==n));return Array.from(new Set(e))}(e.map((t=>t.name)));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((t=>`'${t}'`)).join(", ")}]. This can lead to issues.`),e}function _o(t,e){return Bo(zo(t),e)}function Fo(t,e,n){const{from:r,to:i}=e,{blockSeparator:s="\n\n",textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,((t,n,u,a)=>{var h;t.isBlock&&n>r&&(l+=s);const c=null==o?void 0:o[t.type.name];if(c)return u&&(l+=c({node:t,pos:n,parent:u,index:a,range:e})),!1;t.isText&&(l+=null==(h=null==t?void 0:t.text)?void 0:h.slice(Math.max(r,n)-n,i-n))})),l}function Wo(t){return Object.fromEntries(Object.entries(t.nodes).filter((([,t])=>t.spec.toText)).map((([t,e])=>[t,e.spec.toText])))}function Ko(t,e){const n=uo("string"==typeof e?e:e.name,t.schema);return"node"===n?function(t,e){const n=vs(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,(t=>{s.push(t)}));const o=s.reverse().find((t=>t.type.name===n.name));return o?{...o.attrs}:{}}(t,e):"mark"===n?ko(t,e):{}}function Uo(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach(((t,i)=>{const s=[];if(t.ranges.length)t.forEach(((t,e)=>{s.push({from:t,to:e})}));else{const{from:t,to:e}=n[i];if(void 0===t||void 0===e)return;s.push({from:t,to:e})}s.forEach((({from:t,to:n})=>{const s=e.slice(i).map(t,-1),o=e.slice(i).map(n),l=e.invert().map(s,-1),u=e.invert().map(o);r.push({oldRange:{from:l,to:u},newRange:{from:s,to:o}})}))})),function(t){const e=function(t,e=JSON.stringify){const n={};return t.filter((t=>{const r=e(t);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)}))}(t);return 1===e.length?e:e.filter(((t,n)=>{const r=e.filter(((t,e)=>e!==n));return!r.some((e=>t.oldRange.from>=e.oldRange.from&&t.oldRange.to<=e.oldRange.to&&t.newRange.from>=e.newRange.from&&t.newRange.to<=e.newRange.to))}))}(r)}function Jo(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach((e=>{const i=Cs(n.resolve(t),e.type);i&&r.push({mark:e,...i})})):n.nodesBetween(t,e,((t,e)=>{t&&void 0!==(null==t?void 0:t.nodeSize)&&r.push(...t.marks.map((n=>({from:e,to:e+t.nodeSize,mark:n}))))})),r}var qo=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let s=r,o=null;for(;s>0&&null===o;){const t=i.node(s);(null==t?void 0:t.type.name)===e?o=t:s-=1}return[o,s]};function Vo(t,e){return e.nodes[t]||e.marks[t]||null}function Go(t,e,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const r=t.find((t=>t.type===e&&t.name===n));return!!r&&r.attribute.keepOnSplit})))}function Xo(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Rs(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter((t=>!s||s.name===t.type.name)).find((t=>Es(t.attrs,n,{strict:!1})));let o=0;const l=[];if(i.forEach((({$from:e,$to:n})=>{const r=e.pos,i=n.pos;t.doc.nodesBetween(r,i,((t,e)=>{if(s&&t.inlineContent&&!t.type.allowsMarkType(s))return!1;if(!t.isText&&!t.marks.length)return;const n=Math.max(r,e),u=Math.min(i,e+t.nodeSize);o+=u-n,l.push(...t.marks.map((t=>({mark:t,from:n,to:u}))))}))})),0===o)return!1;const u=l.filter((t=>!s||s.name===t.mark.type.name)).filter((t=>Es(t.mark.attrs,n,{strict:!1}))).reduce(((t,e)=>t+e.to-e.from),0),a=l.filter((t=>!s||t.mark.type!==s&&t.mark.type.excludes(s))).reduce(((t,e)=>t+e.to-e.from),0);return(u>0?u+a:u)>=o}var Qo=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const n=xo((t=>t.type.name===e))(t.selection);if(!n)return!1;const r=t.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},Zo=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Yo(t,e){return Array.isArray(e)?e.some((e=>("string"==typeof e?e:e.name)===t.name)):e}function tl(t,e){const{nodeExtensions:n}=$o(e),r=n.find((e=>e.name===t));if(!r)return!1;const i=Oo(Lo(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof i&&i.split(" ").includes("list")}function el(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if("hardBreak"===t.type.name)return!0;if(t.isText)return!/\S/.test(null!=(r=t.text)?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(0===t.content.childCount)return!0;if(e){let r=!0;return t.content.forEach((t=>{!1!==r&&(el(t,{ignoreWhitespace:n,checkChildren:e})||(r=!1))})),r}return!1}function nl(t){return t instanceof ae}var rl=class t{constructor(t){this.position=t}static fromJSON(e){return new t(e.position)}toJSON(){return{position:this.position}}};function il(t,e){const n=e.mapping.mapResult(t.position);return{position:new rl(n.pos),mapResult:n}}function sl(t){return new rl(t)}var ol=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:l}=s,u=Rs(t,r.schema);if(i)if(o){const t=ko(r,u);n.addStoredMark(u.create({...t,...e}))}else l.forEach((t=>{const i=t.$from.pos,s=t.$to.pos;r.doc.nodesBetween(i,s,((t,r)=>{const o=Math.max(r,i),l=Math.min(r+t.nodeSize,s);t.marks.find((t=>t.type===u))?t.marks.forEach((t=>{u===t.type&&n.addMark(o,l,u.create({...t.attrs,...e}))})):n.addMark(o,l,u.create(e))}))}));return function(t,e,n){var r;const{selection:i}=e;let s=null;if(Is(i)&&(s=i.$cursor),s){const e=null!=(r=t.storedMarks)?r:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(e)||!e.some((t=>t.type.excludes(n))))}const{ranges:o}=i;return o.some((({$from:e,$to:r})=>{let i=0===e.depth&&t.doc.inlineContent&&t.doc.type.allowsMarkType(n);return t.doc.nodesBetween(e.pos,r.pos,((t,e,r)=>{if(i)return!1;if(t.isInline){const e=!r||r.type.allowsMarkType(n),s=!!n.isInSet(t.marks)||!t.marks.some((t=>t.type.excludes(n)));i=e&&s}return!i})),i}))}(r,n,u)},ll=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),ul=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=vs(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),s.isTextblock?i().command((({commands:t})=>!!De(s,{...o,...e})(n)||t.clearNodes())).command((({state:t})=>De(s,{...o,...e})(t,r))).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},al=t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,r=Ps(t,0,n.content.size),i=ae.create(n,r);e.setSelection(i)}return!0},hl=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=r;let o,l;return"number"==typeof e?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),i&&n.doc.nodesBetween(o,l,((e,r)=>{e.isText||n.setNodeMarkup(r,void 0,{...e.attrs,dir:t})})),!0},cl=t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,{from:r,to:i}="number"==typeof t?{from:t,to:t}:t,s=le.atStart(n).from,o=le.atEnd(n).to,l=Ps(r,s,o),u=Ps(i,s,o),a=le.create(n,l,u);e.setSelection(a)}return!0},fl=t=>({state:e,dispatch:n})=>{const r=vs(t,e.schema);return(i=r,function(t,e){let{$from:n,$to:r}=t.selection,s=n.blockRange(r,(t=>t.childCount>0&&t.firstChild.type==i));if(!s)return!1;let o=s.startIndex;if(0==o)return!1;let u=s.parent,a=u.child(o-1);if(a.type!=i)return!1;if(e){let n=a.lastChild&&a.lastChild.type==u.type,r=l.from(n?i.create():null),o=new d(l.from(i.create(null,l.from(u.type.create(null,r)))),n?3:1,0),h=s.start,c=s.end;e(t.tr.step(new Et(h-(n?3:1),c,h,c,o,1,!0)).scrollIntoView())}return!0})(e,n);var i};function dl(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter((t=>null==e?void 0:e.includes(t.type.name)));t.tr.ensureMarks(r)}}var pl=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:u}=s,a=Go(i.extensionManager.attributes,l.node().type.name,l.node().attrs);if(s instanceof ae&&s.node.isBlock)return!(!l.parentOffset||!Dt(o,l.pos)||(r&&(t&&dl(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),0));if(!l.parent.isBlock)return!1;const h=u.parentOffset===u.parent.content.size,c=0===l.depth?void 0:function(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(l.node(-1).contentMatchAt(l.indexAfter(-1)));let f=h&&c?[{type:c,attrs:a}]:void 0,d=Dt(e.doc,e.mapping.map(l.pos),1,f);if(f||d||!Dt(e.doc,e.mapping.map(l.pos),1,c?[{type:c}]:void 0)||(d=!0,f=c?[{type:c,attrs:a}]:void 0),r){if(d&&(s instanceof le&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,f),c&&!h&&!l.parentOffset&&l.parent.type!==c)){const t=e.mapping.map(l.before()),n=e.doc.resolve(t);l.node(-1).canReplaceWith(n.index(),n.index()+1,c)&&e.setNodeMarkup(e.mapping.map(l.before()),c)}t&&dl(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return d},ml=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var o;const u=vs(t,r.schema),{$from:a,$to:h}=r.selection,c=r.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(h))return!1;const f=a.node(-1);if(f.type!==u)return!1;const p=s.extensionManager.attributes;if(0===a.parent.content.size&&a.node(-1).childCount===a.indexAfter(-1)){if(2===a.depth||a.node(-3).type!==u||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let t=l.empty;const r=a.index(-1)?1:a.index(-2)?2:3;for(let e=a.depth-r;e>=a.depth-3;e-=1)t=l.from(a.node(e).copy(t));const i=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,s={...Go(p,a.node().type.name,a.node().attrs),...e},h=(null==(o=u.contentMatch.defaultType)?void 0:o.createAndFill(s))||void 0;t=t.append(l.from(u.createAndFill(null,h)||void 0));const c=a.before(a.depth-(r-1));n.replace(c,a.after(-i),new d(t,4-r,0));let f=-1;n.doc.nodesBetween(c,n.doc.content.size,((t,e)=>{if(f>-1)return!1;t.isTextblock&&0===t.content.size&&(f=e+1)})),f>-1&&n.setSelection(le.near(n.doc.resolve(f))),n.scrollIntoView()}return!0}const m=h.pos===a.end()?f.contentMatchAt(0).defaultType:null,g={...Go(p,f.type.name,f.attrs),...e},w={...Go(p,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,h.pos);const b=m?[{type:u,attrs:g},{type:m,attrs:w}]:[{type:u,attrs:g}];if(!Dt(n.doc,a.pos,2))return!1;if(i){const{selection:t,storedMarks:e}=r,{splittableMarks:o}=s.extensionManager,l=e||t.$to.parentOffset&&t.$from.marks();if(n.split(a.pos,2,b).scrollIntoView(),!l||!i)return!0;const u=l.filter((t=>o.includes(t.type.name)));n.ensureMarks(u)}return!0},gl=(t,e)=>{const n=xo((t=>t.type===e))(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const i=t.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!Bt(t.doc,n.pos)||(t.join(n.pos),!0)},wl=(t,e)=>{const n=xo((t=>t.type===e))(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const i=t.doc.nodeAt(r);return n.node.type!==(null==i?void 0:i.type)||!Bt(t.doc,r)||(t.join(r),!0)},bl=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:u,commands:a,can:h})=>{const{extensions:c,splittableMarks:f}=i.extensionManager,d=vs(t,o.schema),p=vs(e,o.schema),{selection:m,storedMarks:g}=o,{$from:w,$to:b}=m,y=w.blockRange(b),v=g||m.$to.parentOffset&&m.$from.marks();if(!y)return!1;const k=xo((t=>tl(t.type.name,c)))(m),M=0===m.from&&m.to===o.doc.content.size,T=o.doc.content.content,x=1===T.length?T[0]:null,L=M&&x&&tl(x.type.name,c)?{node:x,pos:0}:null,S=null!=k?k:L,A=!!L;if((k&&y.depth>=1&&y.depth-k.depth<=1||A)&&S){if(S.node.type===d)return M&&A?u().command((({tr:t,dispatch:e})=>{const n=function(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),i=e.resolve(n.nodeSize-1);return le.between(r,i)}(t);return!!n&&(t.setSelection(n),e&&e(t),!0)})).liftListItem(p).run():a.liftListItem(p);if(tl(S.node.type.name,c)&&d.validContent(S.node.content))return u().command((()=>(s.setNodeMarkup(S.pos,d),!0))).command((()=>gl(s,d))).command((()=>wl(s,d))).run()}return n&&v&&l?u().command((()=>{const t=h().wrapInList(d,r),e=v.filter((t=>f.includes(t.type.name)));return s.ensureMarks(e),!!t||a.clearNodes()})).wrapInList(d,r).command((()=>gl(s,d))).command((()=>wl(s,d))).run():u().command((()=>!!h().wrapInList(d,r)||a.clearNodes())).wrapInList(d,r).command((()=>gl(s,d))).command((()=>wl(s,d))).run()},yl=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=Rs(t,r.schema);return Xo(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},vl=(t,e,n={})=>({state:r,commands:i})=>{const s=vs(t,r.schema),o=vs(e,r.schema),l=ro(r,s,n);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),l?i.setNode(o,u):i.setNode(s,{...u,...n})},kl=(t,e={})=>({state:n,commands:r})=>{const i=vs(t,n.schema);return ro(n,i,e)?r.lift(i):r.wrapIn(i,e)},Ml=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const e=t.tr,n=s.transform;for(let t=n.steps.length-1;t>=0;t-=1)e.step(n.steps[t].invert(n.docs[t]));if(s.text){const n=e.doc.resolve(s.from).marks();e.replaceWith(s.from,s.to,t.schema.text(s.text,n))}else e.delete(s.from,s.to)}return!0}}return!1},Tl=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{ignoreClearable:i=!1}=t,{selection:s}=e,{empty:o,ranges:l}=s;if(o)return!0;const{nonClearableMarks:u}=r.extensionManager;if(n){const t=Object.values(r.schema.marks).filter((t=>i||!u.includes(t.name)));l.forEach((n=>{for(const r of t)e.removeMark(n.$from.pos,n.$to.pos,r)}))}return!0},xl=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,u=Rs(t,r.schema),{$from:a,empty:h,ranges:c}=l;if(!i)return!0;if(h&&o){let{from:t,to:e}=l;const r=null==(s=a.marks().find((t=>t.type===u)))?void 0:s.attrs,i=Cs(a,u,r);i&&(t=i.from,e=i.to),n.removeMark(t,e,u)}else c.forEach((t=>{n.removeMark(t.$from.pos,t.$to.pos,u)}));return n.removeStoredMark(u),!0},Ll=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let s,o;return"number"==typeof t?(s=t,o=t):t&&"from"in t&&"to"in t?(s=t.from,o=t.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,((t,n)=>{if(t.isText)return;const r={...t.attrs};delete r.dir,e.setNodeMarkup(n,void 0,r)})),!0},Sl=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=uo("string"==typeof t?t:t.name,r.schema);if(!l)return!1;"node"===l&&(s=vs(t,r.schema)),"mark"===l&&(o=Rs(t,r.schema));let u=!1;return n.selection.ranges.forEach((t=>{const l=t.$from.pos,a=t.$to.pos;let h,c,f,d;r.doc.nodesBetween(l,a,n.selection.empty?(t,e)=>{s&&s===t.type&&(u=!0,f=Math.max(e,l),d=Math.min(e+t.nodeSize,a),h=e,c=t)}:(t,r)=>{r<l&&s&&s===t.type&&(u=!0,f=Math.max(r,l),d=Math.min(r+t.nodeSize,a),h=r,c=t),r>=l&&r<=a&&(s&&s===t.type&&(u=!0,i&&n.setNodeMarkup(r,void 0,{...t.attrs,...e})),o&&t.marks.length&&t.marks.forEach((s=>{if(o===s.type&&(u=!0,i)){const i=Math.max(r,l),u=Math.min(r+t.nodeSize,a);n.addMark(i,u,o.create({...s.attrs,...e}))}})))}),c&&(void 0!==h&&i&&n.setNodeMarkup(h,void 0,{...c.attrs,...e}),o&&c.marks.length&&c.marks.forEach((t=>{o===t.type&&i&&n.addMark(f,d,o.create({...t.attrs,...e}))})))})),u},Al=(t,e={})=>({state:n,dispatch:r})=>function(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=o&&Ht(o,t,e);return!!l&&(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0)}}(vs(t,n.schema),e)(n,r),El=(t,e={})=>({state:n,dispatch:r})=>function(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s);if(!o)return!1;let u=r?n.tr:null;return!!function(t,e,n,r=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&0==e.startIndex){if(0==e.$from.index(e.depth-1))return!1;let t=o.resolve(e.start-2);s=new O(t,t,e.depth),e.endIndex<e.parent.childCount&&(e=new O(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let u=Ht(s,n,r,e);return!!u&&(t&&function(t,e,n,r,i){let s=l.empty;for(let t=n.length-1;t>=0;t--)s=l.from(n[t].type.create(n[t].attrs,s));t.step(new Et(e.start-(r?2:0),e.end,e.start,e.end,new d(s,0,0),n.length,!0));let o=0;for(let t=0;t<n.length;t++)n[t].type==i&&(o=t+1);let u=n.length-o,a=e.start+n.length-(r?2:0),h=e.parent;for(let n=e.startIndex,r=e.endIndex,i=!0;n<r;n++,i=!1)!i&&Dt(t.doc,a,u)&&(t.split(a,u),a+=2*u),a+=h.child(n).nodeSize}(t,e,u,i,n),!0)}(u,o,t,e)&&(r&&r(u.scrollIntoView()),!0)}}(vs(t,n.schema),e)(n,r),Ol=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach((t=>t.apply(this,e))),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter((t=>t!==e)):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},$l=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=null==(e=t.undoable)||e}};function Cl(t){var e;const{editor:n,from:r,to:i,text:s,rules:o,plugin:l}=t,{view:u}=n;if(u.composing)return!1;const a=u.state.doc.resolve(r);if(a.parent.type.spec.code||(null==(e=a.nodeBefore||a.nodeAfter)?void 0:e.marks.find((t=>t.type.spec.code))))return!1;let h=!1;const c=((t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,((t,e,i,s)=>{var o,l;const u=(null==(l=(o=t.type.spec).toText)?void 0:l.call(o,{node:t,pos:e,parent:i,index:s}))||t.textContent||"%leaf%";n+=t.isAtom&&!t.isText?u:u.slice(0,Math.max(0,r-e))})),n})(a)+s;return o.forEach((t=>{if(h)return;const e=((t,e)=>{if(As(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r})(c,t.find);if(!e)return;const o=u.state.tr,a=hs({state:u.state,transaction:o}),f={from:r-(e[0].length-s.length),to:i},{commands:d,chain:p,can:m}=new cs({editor:n,state:a});null!==t.handler({state:a,range:f,match:e,commands:d,chain:p,can:m})&&o.steps.length&&(t.undoable&&o.setMeta(l,{transform:o,from:r,to:i,text:s}),u.dispatch(o),h=!0)})),h}function Rl(t){return"Object"===function(t){return Object.prototype.toString.call(t).slice(8,-1)}(t)&&t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Hl(t,e){const n={...t};return Rl(t)&&Rl(e)&&Object.keys(e).forEach((r=>{n[r]=Rl(e[r])&&Rl(t[r])?Hl(t[r],e[r]):e[r]})),n}var Nl=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Oo(Lo(this,"addOptions",{name:this.name}))}}get storage(){return{...Oo(Lo(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Hl(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Il=class t extends Nl{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}static handleExit({editor:t,mark:e}){const{tr:n}=t.state,r=t.state.selection.$from;if(r.pos===r.end()){const i=r.marks();if(!i.find((t=>(null==t?void 0:t.type.name)===e.name)))return!1;const s=i.find((t=>(null==t?void 0:t.type.name)===e.name));return s&&n.removeStoredMark(s),n.insertText(" ",r.pos),t.view.dispatch(n),!0}return!1}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}},Pl=class{constructor(t){this.find=t.find,this.handler=t.handler}};var Dl=null;function Bl(t){const{editor:e,rules:n}=t;let r,i=null,s=!1,o=!1,u="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{r="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{r=null}const a=({state:t,from:n,to:i,rule:s,pasteEvt:o})=>{const l=t.tr,a=hs({state:t,transaction:l});if(function(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=t,{commands:u,chain:a,can:h}=new cs({editor:e,state:n}),c=[];return n.doc.nodesBetween(r,i,((t,e)=>{var f,d,p,m,g;if((null==(d=null==(f=t.type)?void 0:f.spec)?void 0:d.code)||!(t.isText||t.isTextblock||t.isInline))return;const w=null!=(g=null!=(m=null==(p=t.content)?void 0:p.size)?m:t.nodeSize)?g:0,b=Math.max(r,e),y=Math.min(i,e+w);if(b>=y)return;const v=((t,e,n)=>{if(As(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map((e=>{const n=[e.text];return n.index=e.index,n.input=t,n.data=e.data,e.replaceWith&&(e.text.includes(e.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(e.replaceWith)),n})):[]})(t.isText?t.text||"":t.textBetween(b-e,y-e,void 0,""),s.find,o);v.forEach((t=>{if(void 0===t.index)return;const e=b+t.index+1,r=e+t[0].length,i={from:n.tr.mapping.map(e),to:n.tr.mapping.map(r)},f=s.handler({state:n,range:i,match:t,commands:u,chain:a,can:h,pasteEvent:o,dropEvent:l});c.push(f)}))})),c.every((t=>null!==t))}({editor:e,state:a,from:Math.max(n-1,0),to:i.b-1,rule:s,pasteEvent:o,dropEvent:r})&&l.steps.length){try{r="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{r=null}return u="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,l}};return n.map((t=>new Me({view(t){const n=n=>{var r;i=(null==(r=t.dom.parentElement)?void 0:r.contains(n.target))?t.dom.parentElement:null,i&&(Dl=e)},r=()=>{Dl&&(Dl=null)};return window.addEventListener("dragstart",n),window.addEventListener("dragend",r),{destroy(){window.removeEventListener("dragstart",n),window.removeEventListener("dragend",r)}}},props:{handleDOMEvents:{drop:(t,e)=>{if(o=i===t.dom.parentElement,r=e,!o){const t=Dl;(null==t?void 0:t.isEditable)&&setTimeout((()=>{const e=t.state.selection;e&&t.commands.deleteRange({from:e.from,to:e.to})}),10)}return!1},paste:(t,e)=>{var n;const r=null==(n=e.clipboardData)?void 0:n.getData("text/html");return u=e,s=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(e,n,r)=>{const i=e[0],h="paste"===i.getMeta("uiEvent")&&!s,c="drop"===i.getMeta("uiEvent")&&!o,f=i.getMeta("applyPasteRules"),d=!!f;if(!h&&!c&&!d)return;if(d){let{text:e}=f;"string"==typeof e||(e=Ao(l.from(e),r.schema));const{from:n}=f,i=n+e.length,s=(t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null==(e=n.clipboardData)||e.setData("text/html",t),n})(e);return a({rule:t,state:r,from:n,to:{b:i},pasteEvt:s})}const p=n.doc.content.findDiffStart(r.doc.content),m=n.doc.content.findDiffEnd(r.doc.content);return"number"==typeof p&&m&&p!==m.b?a({rule:t,state:r,from:p,to:m,pasteEvt:u}):void 0}})))}var jl=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=zo(t),this.schema=Bo(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce(((t,e)=>{const n=Lo(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Vo(e.name,this.schema)});return n?{...t,...n()}:t}),{})}get plugins(){const{editor:t}=this,e=jo([...this.extensions].reverse()).flatMap((e=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:Vo(e.name,this.schema)},r=[],i=Lo(e,"addKeyboardShortcuts",n);let s={};if("mark"===e.type&&Lo(e,"exitable",n)&&(s.ArrowRight=()=>Il.handleExit({editor:t,mark:e})),i){const e=Object.fromEntries(Object.entries(i()).map((([e,n])=>[e,()=>n({editor:t})])));s={...s,...e}}const o=new Me({props:{handleKeyDown:ls(s)}});r.push(o);const u=Lo(e,"addInputRules",n);if(Yo(e,t.options.enableInputRules)&&u){const e=u();if(e&&e.length){const n=function(t){const{editor:e,rules:n}=t,r=new Me({state:{init:()=>null,apply(t,i,s){const o=t.getMeta(r);if(o)return o;const u=t.getMeta("applyInputRules");return!!u&&setTimeout((()=>{let{text:t}=u;"string"==typeof t||(t=Ao(l.from(t),s.schema));const{from:i}=u;Cl({editor:e,from:i,to:i+t.length,text:t,rules:n,plugin:r})})),t.selectionSet||t.docChanged?null:i}},props:{handleTextInput:(t,i,s,o)=>Cl({editor:e,from:i,to:s,text:o,rules:n,plugin:r}),handleDOMEvents:{compositionend:t=>(setTimeout((()=>{const{$cursor:i}=t.state.selection;i&&Cl({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})})),!1)},handleKeyDown(t,i){if("Enter"!==i.key)return!1;const{$cursor:s}=t.state.selection;return!!s&&Cl({editor:e,from:s.pos,to:s.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}({editor:t,rules:e}),i=Array.isArray(n)?n:[n];r.push(...i)}}const a=Lo(e,"addPasteRules",n);if(Yo(e,t.options.enablePasteRules)&&a){const e=a();if(e&&e.length){const n=Bl({editor:t,rules:e});r.push(...n)}}const h=Lo(e,"addProseMirrorPlugins",n);if(h){const t=h();r.push(...t)}return r}));return e}get attributes(){return Co(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=$o(this.extensions);return Object.fromEntries(e.filter((t=>!!Lo(t,"addNodeView"))).map((e=>{const n=this.attributes.filter((t=>t.type===e.name)),r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:vs(e.name,this.schema)},i=Lo(e,"addNodeView",r);if(!i)return[];const s=i();return s?[e.name,(r,i,o,l,u)=>{const a=No(r,n);return s({node:r,view:i,getPos:o,decorations:l,innerDecorations:u,editor:t,extension:e,HTMLAttributes:a})}]:[]})))}dispatchTransaction(t){const{editor:e}=this;return jo([...this.extensions].reverse()).reduceRight(((t,n)=>{const r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:Vo(n.name,this.schema)},i=Lo(n,"dispatchTransaction",r);return i?e=>{i.call(r,{transaction:e,next:t})}:t}),t)}transformPastedHTML(t){const{editor:e}=this;return jo([...this.extensions]).reduce(((t,n)=>{const r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:Vo(n.name,this.schema)},i=Lo(n,"transformPastedHTML",r);return i?(e,n)=>{const s=t(e,n);return i.call(r,s)}:t}),t||(t=>t))}get markViews(){const{editor:t}=this,{markExtensions:e}=$o(this.extensions);return Object.fromEntries(e.filter((t=>!!Lo(t,"addMarkView"))).map((e=>{const n=this.attributes.filter((t=>t.type===e.name)),r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:Rs(e.name,this.schema)},i=Lo(e,"addMarkView",r);return i?[e.name,(r,s,o)=>{const l=No(r,n);return i()({mark:r,view:s,inline:o,editor:t,extension:e,HTMLAttributes:l,updateAttributes:e=>{!function(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants(((e,r)=>{const i=s.mapping.map(r),l=s.mapping.map(r)+e.nodeSize;let u=null;if(e.marks.forEach((t=>{if(t!==o)return!1;u=t})),!u)return;let a=!1;if(Object.keys(n).forEach((t=>{n[t]!==u.attrs[t]&&(a=!0)})),a){const e=t.type.create({...t.attrs,...n});s.removeMark(i,l,t.type),s.addMark(i,l,e)}})),s.docChanged&&e.view.dispatch(s)}(r,t,e)}})}]:[]})))}destroy(){this.extensions.forEach((t=>{let e=t;for(;e.parent;){const t=e.parent;t.child===e&&(t.child=null),e=t}})),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map((t=>[t.name,t.storage]))),t.forEach((t=>{var e,n;const r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:Vo(t.name,this.schema)};"mark"===t.type&&((null==(e=Oo(Lo(t,"keepOnSplit",r)))||e)&&this.splittableMarks.push(t.name),null==(n=Oo(Lo(t,"clearable",r)))||n||this.nonClearableMarks.push(t.name));const i=Lo(t,"onBeforeCreate",r),s=Lo(t,"onCreate",r),o=Lo(t,"onUpdate",r),l=Lo(t,"onSelectionUpdate",r),u=Lo(t,"onTransaction",r),a=Lo(t,"onFocus",r),h=Lo(t,"onBlur",r),c=Lo(t,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),u&&this.editor.on("transaction",u),a&&this.editor.on("focus",a),h&&this.editor.on("blur",h),c&&this.editor.on("destroy",c)}))}};jl.resolve=zo,jl.sort=jo,jl.flatten=So,as({},{ClipboardTextSerializer:()=>_l,Commands:()=>Fl,Delete:()=>Wl,Drop:()=>Kl,Editable:()=>Ul,FocusEvents:()=>ql,Keymap:()=>Vl,Paste:()=>Gl,Tabindex:()=>Xl,TextDirection:()=>Ql,focusEventsPluginKey:()=>Jl});var zl=class t extends Nl{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}},_l=zl.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new Me({key:new Le("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,s=Wo(n),{blockSeparator:o}=this.options,l={...void 0!==o?{blockSeparator:o}:{},textSerializers:s};return[...i.ranges].sort(((t,e)=>t.$from.pos-e.$from.pos)).map((({$from:t,$to:e})=>Fo(r,{from:t.pos,to:e.pos},l))).join(null!=o?o:"\n\n")}}})]}}),Fl=zl.create({name:"commands",addCommands:()=>({...fs})}),Wl=zl.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{var n,r,i,s;if(null!=(s=null==(i=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.filterTransaction)?void 0:i.call(r,t))?s:t.getMeta("y-sync$"))return;const o=Mo(t.before,[t,...e]);Uo(o).forEach((e=>{o.mapping.mapResult(e.oldRange.from).deletedAfter&&o.mapping.mapResult(e.oldRange.to).deletedBefore&&o.before.nodesBetween(e.oldRange.from,e.oldRange.to,((n,r)=>{const i=r+n.nodeSize-2,s=e.oldRange.from<=r&&i<=e.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:r,to:i,newFrom:o.mapping.map(r),newTo:o.mapping.map(i),deletedRange:e.oldRange,newRange:e.newRange,partial:!s,editor:this.editor,transaction:t,combinedTransform:o})}))}));const l=o.mapping;o.steps.forEach(((e,n)=>{var r,i;if(e instanceof xt){const s=l.slice(n).map(e.from,-1),u=l.slice(n).map(e.to),a=l.invert().map(s,-1),h=l.invert().map(u),c=s>0&&(null==(r=o.doc.nodeAt(s-1))?void 0:r.marks.some((t=>t.eq(e.mark)))),f=null==(i=o.doc.nodeAt(u))?void 0:i.marks.some((t=>t.eq(e.mark)));this.editor.emit("delete",{type:"mark",mark:e.mark,from:e.from,to:e.to,deletedRange:{from:a,to:h},newRange:{from:s,to:u},partial:Boolean(f||c),editor:this.editor,transaction:t,combinedTransform:o})}}))};null==(i=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.async)||i?setTimeout(s,0):s()}}),Kl=zl.create({name:"drop",addProseMirrorPlugins(){return[new Me({key:new Le("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Ul=zl.create({name:"editable",addProseMirrorPlugins(){return[new Me({key:new Le("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Jl=new Le("focusEvents"),ql=zl.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Me({key:Jl,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Vl=zl.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first((({commands:t})=>[()=>t.undoInputRule(),()=>t.command((({tr:e})=>{const{selection:n,doc:r}=e,{empty:i,$anchor:s}=n,{pos:o,parent:l}=s,u=s.parent.isTextblock&&o>0?e.doc.resolve(o-1):s,a=u.parent.type.spec.isolating&&1===u.parent.childCount?s.pos-s.parentOffset===s.pos:re.atStart(r).from===o;return!(!i||!l.type.isTextblock||l.textContent.length||!a||a&&"paragraph"===s.parent.type.name)&&t.clearNodes()})),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()])),e=()=>this.editor.commands.first((({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()])),n={Enter:()=>this.editor.commands.first((({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return js()||eo()?i:r},addProseMirrorPlugins(){return[new Me({key:new Le("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some((t=>t.getMeta("composition"))))return;const r=t.some((t=>t.docChanged))&&!e.doc.eq(n.doc),i=t.some((t=>t.getMeta("preventClearDocument")));if(!r||i)return;const{empty:s,from:o,to:l}=e.selection,u=re.atStart(e.doc).from,a=re.atEnd(e.doc).to;if(s||o!==u||l!==a)return;if(!el(n.doc))return;const h=n.tr,c=hs({state:n,transaction:h}),{commands:f}=new cs({editor:this.editor,state:c});return f.clearNodes(),h.steps.length?h:void 0}})]}}),Gl=zl.create({name:"paste",addProseMirrorPlugins(){return[new Me({key:new Le("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Xl=zl.create({name:"tabindex",addOptions:()=>({value:void 0}),addProseMirrorPlugins(){return[new Me({key:new Le("tabindex"),props:{attributes:()=>{var t;return this.editor.isEditable||void 0!==this.options.value?{tabindex:null!=(t=this.options.value)?t:"0"}:{}}}})]}}),Ql=zl.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=$o(this.extensions);return[{types:t.filter((t=>"text"!==t.name)).map((t=>t.name)),attributes:{dir:{default:this.options.direction,parseHTML:t=>{const e=t.getAttribute("dir");return!e||"ltr"!==e&&"rtl"!==e&&"auto"!==e?this.options.direction:e},renderHTML:t=>t.dir?{dir:t.dir}:{}}}}]},addProseMirrorPlugins(){return[new Me({key:new Le("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),Zl=class t{constructor(t,e,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=t,this.editor=e,this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return null!=(t=this.actualDepth)?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);e=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:e,to:n},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(0===this.depth)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new t(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new t(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new t(e,this.editor)}get children(){const e=[];return this.node.content.forEach(((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=n.isInline,o=this.pos+r+(n.isAtom&&!n.isText?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&!s&&l.depth<=this.depth)return;const u=new t(l,this.editor,i,i||s?n:null);i&&(u.actualDepth=this.depth+1),e.push(u)})),e}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,e={}){let n=null,r=this.parent;for(;r&&!n;)r.node.type.name===t&&(Object.keys(e).length>0||(n=r)),r=r.parent;return n}querySelector(t,e={}){return this.querySelectorAll(t,e,!0)[0]||null}querySelectorAll(t,e={},n=!1){let r=[];if(!this.children||0===this.children.length)return r;const i=Object.keys(e);return this.children.forEach((s=>{n&&r.length>0||(s.node.type.name===t&&i.every((t=>e[t]===s.node.attrs[t]))&&r.push(s),n&&r.length>0||(r=r.concat(s.querySelectorAll(t,e,n))))})),r}setAttribute(t){const{tr:e}=this.editor.state;e.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(e)}},Yl=class extends Ol{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:"undefined"!=typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:il,createMappablePosition:sl},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",(({event:t,slice:e,moved:n})=>this.options.onDrop(t,e,n))),this.on("paste",(({event:t,slice:e})=>this.options.onPaste(t,e))),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=Ds(e,this.options.autofocus);this.editorState=ve.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if("undefined"==typeof document)throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout((()=>{this.isDestroyed||(!1!==this.options.autofocus&&null!==this.options.autofocus&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)}),0)}unmount(){if(this.editorView){const t=this.editorView.dom;(null==t?void 0:t.editor)&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{"function"==typeof this.css.remove?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&"undefined"!=typeof document&&(this.css=function(t,e){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const r=document.createElement("style");return e&&r.setAttribute("nonce",e),r.setAttribute("data-tiptap-style",""),r.innerHTML='.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}',document.getElementsByTagName("head")[0].appendChild(r),r}(0,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if("state"===e)return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=Eo(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach((t=>{const e="string"==typeof t?`${t}$`:t.key;n=n.filter((t=>!t.key.startsWith(e)))})),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e,n,r;const i=[...this.options.enableCoreExtensions?[Ul,_l.configure({blockSeparator:null==(e=null==(t=this.options.coreExtensionOptions)?void 0:t.clipboardTextSerializer)?void 0:e.blockSeparator}),Fl,ql,Vl,Xl.configure({value:null==(r=null==(n=this.options.coreExtensionOptions)?void 0:n.tabindex)?void 0:r.value}),Kl,Gl,Wl,Ql.configure({direction:this.options.textDirection})].filter((t=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[t.name])):[],...this.options.extensions].filter((t=>["extension","node","mark"].includes(null==t?void 0:t.type)));this.extensionManager=new jl(i,this)}createCommandManager(){this.commandManager=new cs({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=yo(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message)))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&"object"==typeof this.storage.collaboration&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter((t=>"collaboration"!==t.name)),this.createExtensionManager()}}),t=yo(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,s=this.extensionManager.transformPastedHTML(e.transformPastedHTML);this.editorView=new Ki(t,{...e,attributes:{role:"textbox",...null==e?void 0:e.attributes},dispatchTransaction:i,transformPastedHTML:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const o=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(o),this.prependClass(),this.injectCSS(),this.view.dom.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void t.steps.forEach((t=>{var e;return null==(e=this.capturedTransaction)?void 0:e.step(t)})):void(this.capturedTransaction=t);const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast((t=>t.getMeta("focus")||t.getMeta("blur"))),l=null==o?void 0:o.getMeta("focus"),u=null==o?void 0:o.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),u&&this.emit("blur",{editor:this,event:u.event,transaction:o}),t.getMeta("preventUpdate")||!n.some((t=>t.docChanged))||s.doc.eq(e.doc)||this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Ko(this.state,t)}isActive(t,e){return function(t,e,n={}){if(!e)return ro(t,null,n)||Xo(t,null,n);const r=uo(e,t.schema);return"node"===r?ro(t,e,n):"mark"===r&&Xo(t,e,n)}(this.state,"string"==typeof t?t:null,"string"==typeof t?e:t)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ao(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:n={}}=t||{};return function(t,e){return Fo(t,{from:0,to:t.content.size},e)}(this.state.doc,{blockSeparator:e,textSerializers:{...Wo(this.schema),...n}})}get isEmpty(){return el(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return null==(e=null==(t=this.editorView)?void 0:t.isDestroyed)||e}$node(t,e){var n;return(null==(n=this.$doc)?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new Zl(e,this,!1,t>0&&e.nodeAfter&&!e.nodeAfter.isText?e.nodeAfter:null)}get $doc(){return this.$pos(0)}};function tu(t){return new $l({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Oo(t.getAttributes,void 0,r);if(!1===i||null===i)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const r=l.search(/\S/),u=n.from+l.indexOf(o),a=u+o.length;if(Jo(n.from,n.to,e.doc).filter((e=>e.mark.type.excluded.find((n=>n===t.type&&n!==e.mark.type)))).filter((t=>t.to>u)).length)return null;a<n.to&&s.delete(a,n.to),u>n.from&&s.delete(n.from+r,u),s.addMark(n.from+r,n.from+r+o.length,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function eu(t){return new $l({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Oo(t.getAttributes,void 0,r)||{},{tr:s}=e,o=n.from;let l=n.to;const u=t.type.create(i);if(r[1]){let t=o+r[0].lastIndexOf(r[1]);t>l?t=l:l=t+r[1].length,s.insertText(r[0][r[0].length-1],o+r[0].length-1),s.replaceWith(t,l,u)}else r[0]&&s.insert(t.type.isInline?o:o-1,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l));s.scrollIntoView()},undoable:t.undoable})}function nu(t){return new $l({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=Oo(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function ru(t){return new $l({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=Oo(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),l=o.doc.resolve(n.from).blockRange(),u=l&&Ht(l,t.type,s);if(!u)return null;if(o.wrap(l,u),t.keepMarks&&t.editor){const{selection:n,storedMarks:r}=e,{splittableMarks:i}=t.editor.extensionManager,s=r||n.$to.parentOffset&&n.$from.marks();if(s){const t=s.filter((t=>i.includes(t.type.name)));o.ensureMarks(t)}}if(t.keepAttributes){const e="bulletList"===t.type.name||"orderedList"===t.type.name?"listItem":"taskList";i().updateAttributes(e,s).run()}const a=o.doc.resolve(n.from-1).nodeBefore;a&&a.type===t.type&&Bt(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,a))&&o.join(n.from-1)},undoable:t.undoable})}var iu=class{constructor(t){var e,n,r,i,s,o;this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=t=>{this.isResizing&&this.activeHandle&&this.handleResize(t.clientX-this.startX,t.clientY-this.startY)},this.handleTouchMove=t=>{if(!this.isResizing||!this.activeHandle)return;const e=t.touches[0];e&&this.handleResize(e.clientX-this.startX,e.clientY-this.startY)},this.handleMouseUp=()=>{this.isResizing&&(this.onCommit(this.element.offsetWidth,this.element.offsetHeight),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp))},this.handleKeyDown=t=>{"Shift"===t.key&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=t=>{"Shift"===t.key&&(this.isShiftKeyPressed=!1)},this.node=t.node,this.editor=t.editor,this.element=t.element,this.element.draggable=!1,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(null==(e=t.options)?void 0:e.min)&&(this.minSize={...this.minSize,...t.options.min}),(null==(n=t.options)?void 0:n.max)&&(this.maxSize=t.options.max),(null==(r=null==t?void 0:t.options)?void 0:r.directions)&&(this.directions=t.options.directions),(null==(i=t.options)?void 0:i.preserveAspectRatio)&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(null==(s=t.options)?void 0:s.className)&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(null==(o=t.options)?void 0:o.createCustomHandle)&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return null!=(t=this.contentElement)?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&0===this.handleMap.size&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type===this.node.type&&(this.node=t,!this.onUpdate||this.onUpdate(t,e,n))}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),s=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),s&&(t.style.right="0"),"top"!==e&&"bottom"!==e||(t.style.left="0",t.style.right="0"),"left"!==e&&"right"!==e||(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach((t=>{let e;e=this.createCustomHandle?this.createCustomHandle(t):this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",(e=>this.handleResizeStart(e,t))),e.addEventListener("touchstart",(e=>this.handleResizeStart(e,t))),this.handleMap.set(t,e),this.wrapper.appendChild(e)}))}removeHandles(){this.handleMap.forEach((t=>t.remove())),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,"touches"in t?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),s=this.applyConstraints(r,i,n);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const s=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),u=t.includes("top");return s?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+n:u&&(i=this.startHeight-n),"right"!==t&&"left"!==t||(r=this.startWidth+(s?e:-e)),"top"!==t&&"bottom"!==t||(i=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,s,o;if(!n){let n=Math.max(this.minSize.width,t),s=Math.max(this.minSize.height,e);return(null==(r=this.maxSize)?void 0:r.width)&&(n=Math.min(this.maxSize.width,n)),(null==(i=this.maxSize)?void 0:i.height)&&(s=Math.min(this.maxSize.height,s)),{width:n,height:s}}let l=t,u=e;return l<this.minSize.width&&(l=this.minSize.width,u=l/this.aspectRatio),u<this.minSize.height&&(u=this.minSize.height,l=u*this.aspectRatio),(null==(s=this.maxSize)?void 0:s.width)&&l>this.maxSize.width&&(l=this.maxSize.width,u=l/this.aspectRatio),(null==(o=this.maxSize)?void 0:o.height)&&u>this.maxSize.height&&(u=this.maxSize.height,l=u*this.aspectRatio),{width:l,height:u}}applyAspectRatio(t,e,n){return"left"===n||"right"===n?{width:t,height:t/this.aspectRatio}:"top"===n||"bottom"===n?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function su(t,e){const n=t.getAttribute("style");if(!n)return null;const r=n.split(";").map((t=>t.trim())).filter(Boolean),i=e.toLowerCase();for(let t=r.length-1;t>=0;t-=1){const e=r[t],n=e.indexOf(":");if(-1!==n&&e.slice(0,n).trim().toLowerCase()===i)return e.slice(n+1).trim()}return null}function ou(t){if(!(null==t?void 0:t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,(t=>(n.push(t),`__QUOTED_${n.length-1}__`))),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const t=i.map((t=>t.trim().slice(1)));e.class=t.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]),Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach((([,t,r])=>{var i;const s=parseInt((null==(i=r.match(/__QUOTED_(\d+)__/))?void 0:i[1])||"0",10),o=n[s];o&&(e[t]=o.slice(1,-1))}));const o=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return o&&o.split(/\s+/).filter(Boolean).forEach((t=>{t.match(/^[a-zA-Z][\w-]*$/)&&(e[t]=!0)})),e}function lu(t){if(!t||0===Object.keys(t).length)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach((t=>e.push(`.${t}`))),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach((([t,n])=>{"class"!==t&&"id"!==t&&(!0===n?e.push(t):!1!==n&&null!=n&&e.push(`${t}="${String(n)}"`))})),e.join(" ")}function uu(t){const{nodeName:e,name:n,parseAttributes:r=ou,serializeAttributes:i=lu,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=t,u=n||e;return{parseMarkdown:(t,n)=>{const r={...s,...t.attributes};return n.createNode(e,r,[])},markdownTokenizer:{name:e,level:"block",start(t){var e;const n=new RegExp(`^:::${u}(?:\\s|$)`,"m"),r=null==(e=t.match(n))?void 0:e.index;return void 0!==r?r:-1},tokenize(t,n,i){const s=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),l=t.match(s);if(!l)return;const a=r(l[1]||"");return o.find((t=>!(t in a)))?void 0:{type:e,raw:l[0],attributes:a}}},renderMarkdown:t=>{const e=(t=>{if(!l)return t;const e={};return l.forEach((n=>{n in t&&(e[n]=t[n])})),e})(t.attrs||{}),n=i(e);return`:::${u}${n?` {${n}}`:""} :::`}}}function au(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=ou,serializeAttributes:s=lu,defaultAttributes:o={},content:l="block",allowedAttributes:u}=t,a=n||e;return{parseMarkdown:(t,n)=>{let i;if(r){const e=r(t);i="string"==typeof e?[{type:"text",text:e}]:e}else i="block"===l?n.parseChildren(t.tokens||[]):n.parseInline(t.tokens||[]);const s={...o,...t.attributes};return n.createNode(e,s,i)},markdownTokenizer:{name:e,level:"block",start(t){var e;const n=new RegExp(`^:::${a}`,"m"),r=null==(e=t.match(n))?void 0:e.index;return void 0!==r?r:-1},tokenize(t,n,r){var s;const o=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),u=t.match(o);if(!u)return;const[h,c=""]=u,f=i(c);let d=1;const p=h.length;let m="";const g=/^:::([\w-]*)(\s.*)?/gm,w=t.slice(p);for(g.lastIndex=0;;){const n=g.exec(w);if(null===n)break;const i=n.index,o=n[1];if(!(null==(s=n[2])?void 0:s.endsWith(":::")))if(o)d+=1;else if(d-=1,0===d){const s=w.slice(0,i);m=s.trim();const o=t.slice(0,p+i+n[0].length);let u=[];if(m)if("block"===l)for(u=r.blockTokens(s),u.forEach((t=>{!t.text||t.tokens&&0!==t.tokens.length||(t.tokens=r.inlineTokens(t.text))}));u.length>0;){const t=u[u.length-1];if("paragraph"!==t.type||t.text&&""!==t.text.trim())break;u.pop()}else u=r.inlineTokens(m);return{type:e,raw:o,attributes:f,content:m,tokens:u}}}}},renderMarkdown:(t,e)=>{const n=(t=>{if(!u)return t;const e={};return u.forEach((n=>{n in t&&(e[n]=t[n])})),e})(t.attrs||{}),r=s(n),i=r?` {${r}}`:"",o=e.renderChildren(t.content||[],"\n\n");return`:::${a}${i}\n\n${o}\n\n:::`}}}function hu(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;null!==r;){const[,i,s,o]=r;e[i]=s||o,r=n.exec(t)}return e}function cu(t){return Object.entries(t).filter((([,t])=>null!=t)).map((([t,e])=>`${t}="${e}"`)).join(" ")}function fu(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=hu,serializeAttributes:s=cu,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:u}=t,a=n||e,h=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(t,n)=>{const i={...o,...t.attributes};if(l)return n.createNode(e,i);const s=r?r(t):t.content||"";return n.createNode(e,i,s?[n.createTextNode(s)]:[])},markdownTokenizer:{name:e,level:"inline",start(t){const e=l?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`),n=t.match(e),r=null==n?void 0:n.index;return void 0!==r?r:-1},tokenize(t,n,r){const s=l?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),o=t.match(s);if(!o)return;let u="",a="";if(l){const[,t]=o;a=t}else{const[,t,e]=o;a=t,u=e||""}const c=i(a.trim());return{type:e,raw:o[0],content:u.trim(),attributes:c}}},renderMarkdown:t=>{let e="";r?e=r(t):t.content&&t.content.length>0&&(e=t.content.filter((t=>"text"===t.type)).map((t=>t.text)).join(""));const n=(t=>{if(!u)return t;const e={};return u.forEach((n=>{const r="string"==typeof n?n:n.name,i="string"==typeof n?void 0:n.skipIfDefault;if(r in t){const n=t[r];if(void 0!==i&&n===i)return;e[r]=n}})),e})(t.attrs||{}),i=s(n),o=i?` ${i}`:"";return l?`[${a}${o}]`:`[${a}${o}]${e}[/${a}]`}}}function du(t,e,n){var r,i,s,o;const l=t.split("\n"),u=[];let a="",h=0;const c=e.baseIndentSize||2;for(;h<l.length;){const t=l[h],f=t.match(e.itemPattern);if(!f){if(u.length>0)break;if(""===t.trim()){h+=1,a=`${a}${t}\n`;continue}return}const d=e.extractItemData(f),{indentLevel:p,mainContent:m}=d;a=`${a}${t}\n`;const g=[m];for(h+=1;h<l.length;){const t=l[h];if(""===t.trim()){const e=l.slice(h+1).findIndex((t=>""!==t.trim()));if(-1===e)break;if(((null==(i=null==(r=l[h+1+e].match(/^(\s*)/))?void 0:r[1])?void 0:i.length)||0)>p){g.push(t),a=`${a}${t}\n`,h+=1;continue}break}if(!(((null==(o=null==(s=t.match(/^(\s*)/))?void 0:s[1])?void 0:o.length)||0)>p))break;g.push(t),a=`${a}${t}\n`,h+=1}let w;const b=g.slice(1);if(b.length>0){const t=b.map((t=>t.slice(p+c))).join("\n");t.trim()&&(w=e.customNestedParser?e.customNestedParser(t):n.blockTokens(t))}const y=e.createToken(d,w);u.push(y)}if(0!==u.length)return{items:u,raw:a}}function pu(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i="function"==typeof n?n(r):n,[s,...o]=t.content;let l=`${i}${e.renderChildren([s])}`;return o&&o.length>0&&o.forEach(((t,n)=>{var r,i;const s=null!=(i=null==(r=e.renderChild)?void 0:r.call(e,t,n+1))?i:e.renderChildren([t]);if(null!=s){const n=s.split("\n").map((t=>e.indent(t||""))).join("\n");l+="paragraph"===t.type?`\n\n${n}`:`\n${n}`}})),l}as({},{createAtomBlockMarkdownSpec:()=>uu,createBlockMarkdownSpec:()=>au,createInlineMarkdownSpec:()=>fu,parseAttributes:()=>ou,parseIndentedBlocks:()=>du,renderNestedMarkdownContent:()=>pu,serializeAttributes:()=>lu});var mu=class t extends Nl{constructor(){super(...arguments),this.type="node"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}};function gu(t){return new Pl({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=Oo(t.getAttributes,void 0,r,i);if(!1===s||null===s)return null;const{tr:o}=e,l=r[r.length-1],u=r[0];let a=n.to;if(l){const i=u.search(/\S/),h=n.from+u.indexOf(l),c=h+l.length;if(Jo(n.from,n.to,e.doc).filter((e=>e.mark.type.excluded.find((n=>n===t.type&&n!==e.mark.type)))).filter((t=>t.to>h)).length)return null;c<n.to&&o.delete(c,n.to),h>n.from&&o.delete(n.from+i,h),a=n.from+i+l.length,o.addMark(n.from+i,a,t.type.create(s||{})),void 0!==r.index&&void 0!==r.input&&r.index+r[0].length>=r.input.length||o.removeStoredMark(t.type)}}})}const wu=["top","right","bottom","left"],bu=["start","end"],yu=wu.reduce(((t,e)=>t.concat(e,e+"-"+bu[0],e+"-"+bu[1])),[]),vu=Math.min,ku=Math.max,Mu=Math.round,Tu=t=>({x:t,y:t}),xu={left:"right",right:"left",bottom:"top",top:"bottom"};function Lu(t,e,n){return ku(t,vu(e,n))}function Su(t,e){return"function"==typeof t?t(e):t}function Au(t){return t.split("-")[0]}function Eu(t){return t.split("-")[1]}function Ou(t){return"x"===t?"y":"x"}function $u(t){return"y"===t?"height":"width"}function Cu(t){const e=t[0];return"t"===e||"b"===e?"y":"x"}function Ru(t){return Ou(Cu(t))}function Hu(t,e,n){void 0===n&&(n=!1);const r=Eu(t),i=Ru(t),s=$u(i);let o="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=ju(o)),[o,ju(o)]}function Nu(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const Iu=["left","right"],Pu=["right","left"],Du=["top","bottom"],Bu=["bottom","top"];function ju(t){const e=Au(t);return xu[e]+t.slice(e.length)}function zu(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function _u(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function Fu(t,e,n){let{reference:r,floating:i}=t;const s=Cu(e),o=Ru(e),l=$u(o),u=Au(e),a="y"===s,h=r.x+r.width/2-i.width/2,c=r.y+r.height/2-i.height/2,f=r[l]/2-i[l]/2;let d;switch(u){case"top":d={x:h,y:r.y-i.height};break;case"bottom":d={x:h,y:r.y+r.height};break;case"right":d={x:r.x+r.width,y:c};break;case"left":d={x:r.x-i.width,y:c};break;default:d={x:r.x,y:r.y}}switch(Eu(e)){case"start":d[o]-=f*(n&&a?-1:1);break;case"end":d[o]+=f*(n&&a?-1:1)}return d}async function Wu(t,e){var n;void 0===e&&(e={});const{x:r,y:i,platform:s,rects:o,elements:l,strategy:u}=t,{boundary:a="clippingAncestors",rootBoundary:h="viewport",elementContext:c="floating",altBoundary:f=!1,padding:d=0}=Su(e,t),p=zu(d),m=l[f?"floating"===c?"reference":"floating":c],g=_u(await s.getClippingRect({element:null==(n=await(null==s.isElement?void 0:s.isElement(m)))||n?m:m.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(l.floating)),boundary:a,rootBoundary:h,strategy:u})),w="floating"===c?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,b=await(null==s.getOffsetParent?void 0:s.getOffsetParent(l.floating)),y=await(null==s.isElement?void 0:s.isElement(b))&&await(null==s.getScale?void 0:s.getScale(b))||{x:1,y:1},v=_u(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:b,strategy:u}):w);return{top:(g.top-v.top+p.top)/y.y,bottom:(v.bottom-g.bottom+p.bottom)/y.y,left:(g.left-v.left+p.left)/y.x,right:(v.right-g.right+p.right)/y.x}}function Ku(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Uu(t){return wu.some((e=>t[e]>=0))}function Ju(t){const e=vu(...t.map((t=>t.left))),n=vu(...t.map((t=>t.top)));return{x:e,y:n,width:ku(...t.map((t=>t.right)))-e,height:ku(...t.map((t=>t.bottom)))-n}}const qu=new Set(["left","top"]);function Vu(){return"undefined"!=typeof window}function Gu(t){return Zu(t)?(t.nodeName||"").toLowerCase():"#document"}function Xu(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function Qu(t){var e;return null==(e=(Zu(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function Zu(t){return!!Vu()&&(t instanceof Node||t instanceof Xu(t).Node)}function Yu(t){return!!Vu()&&(t instanceof Element||t instanceof Xu(t).Element)}function ta(t){return!!Vu()&&(t instanceof HTMLElement||t instanceof Xu(t).HTMLElement)}function ea(t){return!(!Vu()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof Xu(t).ShadowRoot)}function na(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=fa(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&"inline"!==i&&"contents"!==i}function ra(t){return/^(table|td|th)$/.test(Gu(t))}function ia(t){try{if(t.matches(":popover-open"))return!0}catch(t){}try{return t.matches(":modal")}catch(t){return!1}}const sa=/transform|translate|scale|rotate|perspective|filter/,oa=/paint|layout|strict|content/,la=t=>!!t&&"none"!==t;let ua;function aa(t){const e=Yu(t)?fa(t):t;return la(e.transform)||la(e.translate)||la(e.scale)||la(e.rotate)||la(e.perspective)||!ha()&&(la(e.backdropFilter)||la(e.filter))||sa.test(e.willChange||"")||oa.test(e.contain||"")}function ha(){return null==ua&&(ua="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ua}function ca(t){return/^(html|body|#document)$/.test(Gu(t))}function fa(t){return Xu(t).getComputedStyle(t)}function da(t){return Yu(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function pa(t){if("html"===Gu(t))return t;const e=t.assignedSlot||t.parentNode||ea(t)&&t.host||Qu(t);return ea(e)?e.host:e}function ma(t){const e=pa(t);return ca(e)?t.ownerDocument?t.ownerDocument.body:t.body:ta(e)&&na(e)?e:ma(e)}function ga(t,e){var n;void 0===e&&(e=[]);const r=ma(t),i=r===(null==(n=t.ownerDocument)?void 0:n.body),s=Xu(r);return i?e.concat(s,s.visualViewport||[],na(r)?r:[],[]):e.concat(r,ga(r,[]))}function wa(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function ba(t){const e=fa(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=ta(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,l=Mu(n)!==s||Mu(r)!==o;return l&&(n=s,r=o),{width:n,height:r,$:l}}function ya(t){return Yu(t)?t:t.contextElement}function va(t){const e=ya(t);if(!ta(e))return Tu(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=ba(e);let o=(s?Mu(n.width):n.width)/r,l=(s?Mu(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),l&&Number.isFinite(l)||(l=1),{x:o,y:l}}const ka=Tu(0);function Ma(t){const e=Xu(t);return ha()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:ka}function Ta(t,e,n,r){void 0===e&&(e=!1),void 0===n&&(n=!1);const i=t.getBoundingClientRect(),s=ya(t);let o=Tu(1);e&&(r?Yu(r)&&(o=va(r)):o=va(t));const l=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==Xu(t))&&e}(s,n,r)?Ma(s):Tu(0);let u=(i.left+l.x)/o.x,a=(i.top+l.y)/o.y,h=i.width/o.x,c=i.height/o.y;if(s){const t=Xu(s),e=r&&Yu(r)?Xu(r):r;let n=t,i=wa(n);for(;i&&r&&e!==n;){const t=va(i),e=i.getBoundingClientRect(),r=fa(i),s=e.left+(i.clientLeft+parseFloat(r.paddingLeft))*t.x,o=e.top+(i.clientTop+parseFloat(r.paddingTop))*t.y;u*=t.x,a*=t.y,h*=t.x,c*=t.y,u+=s,a+=o,n=Xu(i),i=wa(n)}}return _u({width:h,height:c,x:u,y:a})}function xa(t,e){const n=da(t).scrollLeft;return e?e.left+n:Ta(Qu(t)).left+n}function La(t,e){const n=t.getBoundingClientRect();return{x:n.left+e.scrollLeft-xa(t,n),y:n.top+e.scrollTop}}function Sa(t,e,n){let r;if("viewport"===e)r=function(t,e){const n=Xu(t),r=Qu(t),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,u=0;if(i){s=i.width,o=i.height;const t=ha();(!t||t&&"fixed"===e)&&(l=i.offsetLeft,u=i.offsetTop)}const a=xa(r);if(a<=0){const t=r.ownerDocument,e=t.body,n=getComputedStyle(e),i="CSS1Compat"===t.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-e.clientWidth-i);o<=25&&(s-=o)}else a<=25&&(s+=a);return{width:s,height:o,x:l,y:u}}(t,n);else if("document"===e)r=function(t){const e=Qu(t),n=da(t),r=t.ownerDocument.body,i=ku(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=ku(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+xa(t);const l=-n.scrollTop;return"rtl"===fa(r).direction&&(o+=ku(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}(Qu(t));else if(Yu(e))r=function(t,e){const n=Ta(t,!0,"fixed"===e),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=ta(t)?va(t):Tu(1);return{width:t.clientWidth*s.x,height:t.clientHeight*s.y,x:i*s.x,y:r*s.y}}(e,n);else{const n=Ma(t);r={x:e.x-n.x,y:e.y-n.y,width:e.width,height:e.height}}return _u(r)}function Aa(t,e){const n=pa(t);return!(n===e||!Yu(n)||ca(n))&&("fixed"===fa(n).position||Aa(n,e))}function Ea(t,e,n){const r=ta(e),i=Qu(e),s="fixed"===n,o=Ta(t,!0,s,e);let l={scrollLeft:0,scrollTop:0};const u=Tu(0);function a(){u.x=xa(i)}if(r||!r&&!s)if(("body"!==Gu(e)||na(i))&&(l=da(e)),r){const t=Ta(e,!0,s,e);u.x=t.x+e.clientLeft,u.y=t.y+e.clientTop}else i&&a();s&&!r&&i&&a();const h=!i||r||s?Tu(0):La(i,l);return{x:o.left+l.scrollLeft-u.x-h.x,y:o.top+l.scrollTop-u.y-h.y,width:o.width,height:o.height}}function Oa(t){return"static"===fa(t).position}function $a(t,e){if(!ta(t)||"fixed"===fa(t).position)return null;if(e)return e(t);let n=t.offsetParent;return Qu(t)===n&&(n=n.ownerDocument.body),n}function Ca(t,e){const n=Xu(t);if(ia(t))return n;if(!ta(t)){let e=pa(t);for(;e&&!ca(e);){if(Yu(e)&&!Oa(e))return e;e=pa(e)}return n}let r=$a(t,e);for(;r&&ra(r)&&Oa(r);)r=$a(r,e);return r&&ca(r)&&Oa(r)&&!aa(r)?n:r||function(t){let e=pa(t);for(;ta(e)&&!ca(e);){if(aa(e))return e;if(ia(e))return null;e=pa(e)}return null}(t)||n}const Ra={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s="fixed"===i,o=Qu(r),l=!!e&&ia(e.floating);if(r===o||l&&s)return n;let u={scrollLeft:0,scrollTop:0},a=Tu(1);const h=Tu(0),c=ta(r);if((c||!c&&!s)&&(("body"!==Gu(r)||na(o))&&(u=da(r)),c)){const t=Ta(r);a=va(r),h.x=t.x+r.clientLeft,h.y=t.y+r.clientTop}const f=!o||c||s?Tu(0):La(o,u);return{width:n.width*a.x,height:n.height*a.y,x:n.x*a.x-u.scrollLeft*a.x+h.x+f.x,y:n.y*a.y-u.scrollTop*a.y+h.y+f.y}},getDocumentElement:Qu,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const s="clippingAncestors"===n?ia(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let r=ga(t,[]).filter((t=>Yu(t)&&"body"!==Gu(t))),i=null;const s="fixed"===fa(t).position;let o=s?pa(t):t;for(;Yu(o)&&!ca(o);){const e=fa(o),n=aa(o);n||"fixed"!==e.position||(i=null),(s?!n&&!i:!n&&"static"===e.position&&i&&("absolute"===i.position||"fixed"===i.position)||na(o)&&!n&&Aa(t,o))?r=r.filter((t=>t!==o)):i=e,o=pa(o)}return e.set(t,r),r}(e,this._c):[].concat(n),o=[...s,r],l=Sa(e,o[0],i);let u=l.top,a=l.right,h=l.bottom,c=l.left;for(let t=1;t<o.length;t++){const n=Sa(e,o[t],i);u=ku(n.top,u),a=vu(n.right,a),h=vu(n.bottom,h),c=ku(n.left,c)}return{width:a-c,height:h-u,x:c,y:u}},getOffsetParent:Ca,getElementRects:async function(t){const e=this.getOffsetParent||Ca,n=this.getDimensions,r=await n(t.floating);return{reference:Ea(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:n}=ba(t);return{width:e,height:n}},getScale:va,isElement:Yu,isRTL:function(t){return"rtl"===fa(t).direction}},Ha=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:l,platform:u,elements:a}=e,{mainAxis:h=!0,crossAxis:c=!0,fallbackPlacements:f,fallbackStrategy:d="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=Su(t,e);if(null!=(n=s.arrow)&&n.alignmentOffset)return{};const w=Au(i),b=Cu(l),y=Au(l)===l,v=await(null==u.isRTL?void 0:u.isRTL(a.floating)),k=f||(y||!m?[ju(l)]:function(t){const e=ju(t);return[Nu(t),e,Nu(e)]}(l)),M="none"!==p;!f&&M&&k.push(...function(t,e,n,r){const i=Eu(t);let s=function(t,e,n){switch(t){case"top":case"bottom":return n?e?Pu:Iu:e?Iu:Pu;case"left":case"right":return e?Du:Bu;default:return[]}}(Au(t),"start"===n,r);return i&&(s=s.map((t=>t+"-"+i)),e&&(s=s.concat(s.map(Nu)))),s}(l,m,p,v));const T=[l,...k],x=await u.detectOverflow(e,g),L=[];let S=(null==(r=s.flip)?void 0:r.overflows)||[];if(h&&L.push(x[w]),c){const t=Hu(i,o,v);L.push(x[t[0]],x[t[1]])}if(S=[...S,{placement:i,overflows:L}],!L.every((t=>t<=0))){var A,E;const t=((null==(A=s.flip)?void 0:A.index)||0)+1,e=T[t];if(e&&("alignment"!==c||b===Cu(e)||S.every((t=>Cu(t.placement)!==b||t.overflows[0]>0))))return{data:{index:t,overflows:S},reset:{placement:e}};let n=null==(E=S.filter((t=>t.overflows[0]<=0)).sort(((t,e)=>t.overflows[1]-e.overflows[1]))[0])?void 0:E.placement;if(!n)switch(d){case"bestFit":{var O;const t=null==(O=S.filter((t=>{if(M){const e=Cu(t.placement);return e===b||"y"===e}return!0})).map((t=>[t.placement,t.overflows.filter((t=>t>0)).reduce(((t,e)=>t+e),0)])).sort(((t,e)=>t[1]-e[1]))[0])?void 0:O[0];t&&(n=t);break}case"initialPlacement":n=l}if(i!==n)return{reset:{placement:n}}}return{}}}};let Na,Ia;if("undefined"!=typeof WeakMap){let t=new WeakMap;Na=e=>t.get(e),Ia=(e,n)=>(t.set(e,n),n)}else{const t=[],e=10;let n=0;Na=e=>{for(let n=0;n<t.length;n+=2)if(t[n]==e)return t[n+1]},Ia=(r,i)=>(n==e&&(n=0),t[n++]=r,t[n++]=i)}var Pa=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,i=e/this.width|0;let s=r+1,o=i+1;for(let t=1;s<this.width&&this.map[e+t]==n;t++)s++;for(let t=1;o<this.height&&this.map[e+this.width*t]==n;t++)o++;return{left:r,top:i,right:s,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:i,top:s,bottom:o}=this.findCell(t);return"horiz"==e?(n<0?0==r:i==this.width)?null:this.map[s*this.width+(n<0?r-1:i)]:(n<0?0==s:o==this.height)?null:this.map[r+this.width*(n<0?s-1:o)]}rectBetween(t,e){const{left:n,right:r,top:i,bottom:s}=this.findCell(t),{left:o,right:l,top:u,bottom:a}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(i,u),right:Math.max(r,l),bottom:Math.max(s,a)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let i=t.left;i<t.right;i++){const s=r*this.width+i,o=this.map[s];n[o]||(n[o]=!0,i==t.left&&i&&this.map[s-1]==o||r==t.top&&r&&this.map[s-this.width]==o||e.push(o))}return e}positionAt(t,e,n){for(let r=0,i=0;;r++){const s=i+n.child(r).nodeSize;if(r==t){let n=e+t*this.width;const r=(t+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?s-1:this.map[n]}i=s}}static get(t){return Na(t)||Ia(t,function(t){if("table"!=t.type.spec.tableRole)throw new RangeError("Not a table node: "+t.type.name);const e=function(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const i=t.child(r);let s=0;if(n)for(let e=0;e<r;e++){const n=t.child(e);for(let t=0;t<n.childCount;t++){const i=n.child(t);e+i.attrs.rowspan>r&&(s+=i.attrs.colspan)}}for(let t=0;t<i.childCount;t++){const e=i.child(t);s+=e.attrs.colspan,e.attrs.rowspan>1&&(n=!0)}-1==e?e=s:e!=s&&(e=Math.max(e,s))}return e}(t),n=t.childCount,r=[];let i=0,s=null;const o=[];for(let t=0,i=e*n;t<i;t++)r[t]=0;for(let l=0,u=0;l<n;l++){const a=t.child(l);u++;for(let t=0;;t++){for(;i<r.length&&0!=r[i];)i++;if(t==a.childCount)break;const h=a.child(t),{colspan:c,rowspan:f,colwidth:d}=h.attrs;for(let t=0;t<f;t++){if(t+l>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:f-t});break}const a=i+t*e;for(let t=0;t<c;t++){0==r[a+t]?r[a+t]=u:(s||(s=[])).push({type:"collision",row:l,pos:u,n:c-t});const n=d&&d[t];if(n){const r=(a+t)%e*2,i=o[r];null==i||i!=n&&1==o[r+1]?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=c,u+=h.nodeSize}const h=(l+1)*e;let c=0;for(;i<h;)0==r[i++]&&c++;c&&(s||(s=[])).push({type:"missing",row:l,n:c}),u++}0!==e&&0!==n||(s||(s=[])).push({type:"zero_sized"});const l=new Pa(e,n,r,s);let u=!1;for(let t=0;!u&&t<o.length;t+=2)null!=o[t]&&o[t+1]<n&&(u=!0);return u&&function(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i<t.map.length;i++){const s=t.map[i];if(r[s])continue;r[s]=!0;const o=n.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let l=null;const u=o.attrs;for(let n=0;n<u.colspan;n++){const r=e[(i+n)%t.width*2];null==r||u.colwidth&&u.colwidth[n]==r||((l||(l=Da(u)))[n]=r)}l&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}(l,o,t),l}(t))}};function Da(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Ba(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const ja=new Le("selectingCells");function za(t){for(let e=t.depth-1;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return t.node(0).resolve(t.before(e+1));return null}function _a(t){const e=t.selection.$head;for(let t=e.depth;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return!0;return!1}function Fa(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&"cell"==e.node.type.spec.tableRole)return e.$anchor;const n=za(e.$head)||function(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if("cell"==r||"header_cell"==r)return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if("cell"==r||"header_cell"==r)return t.doc.resolve(n-e.nodeSize)}}(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Wa(t){return"row"==t.parent.type.spec.tableRole&&!!t.nodeAfter}function Ka(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Ua(t,e,n){const r=t.node(-1),i=Pa.get(r),s=t.start(-1),o=i.nextCell(t.pos-s,e,n);return null==o?null:t.node(0).resolve(s+o)}function Ja(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some((t=>t>0))||(r.colwidth=null)),r}function qa(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let t=0;t<n;t++)r.colwidth.splice(e,0,0)}return r}var Va=class t extends re{constructor(t,e=t){const n=t.node(-1),r=Pa.get(n),i=t.start(-1),s=r.rectBetween(t.pos-i,e.pos-i),o=t.node(0),l=r.cellsInRect(s).filter((t=>t!=e.pos-i));l.unshift(e.pos-i);const u=l.map((t=>{const e=n.nodeAt(t);if(!e)throw new RangeError(`No cell with offset ${t} found`);const r=i+t+1;return new ie(o.resolve(r),o.resolve(r+e.content.size))}));super(u[0].$from,u[0].$to,u),this.$anchorCell=t,this.$headCell=e}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(Wa(r)&&Wa(i)&&Ka(r,i)){const e=this.$anchorCell.node(-1)!=r.node(-1);return e&&this.isRowSelection()?t.rowSelection(r,i):e&&this.isColSelection()?t.colSelection(r,i):new t(r,i)}return le.between(r,i)}content(){const t=this.$anchorCell.node(-1),e=Pa.get(t),n=this.$anchorCell.start(-1),r=e.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},s=[];for(let n=r.top;n<r.bottom;n++){const o=[];for(let s=n*e.width+r.left,l=r.left;l<r.right;l++,s++){const n=e.map[s];if(i[n])continue;i[n]=!0;const l=e.findCell(n);let u=t.nodeAt(n);if(!u)throw new RangeError(`No cell with offset ${n} found`);const a=r.left-l.left,h=l.right-r.right;if(a>0||h>0){let t=u.attrs;if(a>0&&(t=Ja(t,0,a)),h>0&&(t=Ja(t,t.colspan-h,h)),l.left<r.left){if(u=u.type.createAndFill(t),!u)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}else u=u.type.create(t,u.content)}if(l.top<r.top||l.bottom>r.bottom){const t={...u.attrs,rowspan:Math.min(l.bottom,r.bottom)-Math.max(l.top,r.top)};u=l.top<r.top?u.type.createAndFill(t):u.type.create(t,u.content)}o.push(u)}s.push(t.child(n).copy(l.from(o)))}const o=this.isColSelection()&&this.isRowSelection()?t:s;return new d(l.from(o),1,1)}replace(t,e=d.empty){const n=t.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){const{$from:s,$to:o}=r[i],l=t.mapping.slice(n);t.replace(l.map(s.pos),l.map(o.pos),i?d.empty:e)}const i=re.findFrom(t.doc.resolve(t.mapping.slice(n).map(this.to)),-1);i&&t.setSelection(i)}replaceWith(t,e){this.replace(t,new d(l.from(e),0,0))}forEachCell(t){const e=this.$anchorCell.node(-1),n=Pa.get(e),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)t(e.nodeAt(i[n]),r+i[n])}isColSelection(){const t=this.$anchorCell.index(-1),e=this.$headCell.index(-1);return!(Math.min(t,e)>0)&&Math.max(t+this.$anchorCell.nodeAfter.attrs.rowspan,e+this.$headCell.nodeAfter.attrs.rowspan)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=Pa.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(n.pos-s),u=e.node(0);return o.top<=l.top?(o.top>0&&(e=u.resolve(s+i.map[o.left])),l.bottom<i.height&&(n=u.resolve(s+i.map[i.width*(i.height-1)+l.right-1]))):(l.top>0&&(n=u.resolve(s+i.map[l.left])),o.bottom<i.height&&(e=u.resolve(s+i.map[i.width*(i.height-1)+o.right-1]))),new t(e,n)}isRowSelection(){const t=this.$anchorCell.node(-1),e=Pa.get(t),n=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-n),i=e.colCount(this.$headCell.pos-n);return!(Math.min(r,i)>0)&&Math.max(r+this.$anchorCell.nodeAfter.attrs.colspan,i+this.$headCell.nodeAfter.attrs.colspan)==e.width}eq(e){return e instanceof t&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=Pa.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(n.pos-s),u=e.node(0);return o.left<=l.left?(o.left>0&&(e=u.resolve(s+i.map[o.top*i.width])),l.right<i.width&&(n=u.resolve(s+i.map[i.width*(l.top+1)-1]))):(l.left>0&&(n=u.resolve(s+i.map[l.top*i.width])),o.right<i.width&&(e=u.resolve(s+i.map[i.width*(o.top+1)-1]))),new t(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new t(e.resolve(n),e.resolve(r))}getBookmark(){return new Ga(this.$anchorCell.pos,this.$headCell.pos)}};Va.prototype.visible=!1,re.jsonID("cell",Va);var Ga=class t{constructor(t,e){this.anchor=t,this.head=e}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(t){const e=t.resolve(this.anchor),n=t.resolve(this.head);return"row"==e.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&e.index()<e.parent.childCount&&n.index()<n.parent.childCount&&Ka(e,n)?new Va(e,n):re.near(n,1)}};function Xa(t){if(!(t.selection instanceof Va))return null;const e=[];return t.selection.forEachCell(((t,n)=>{e.push(wi.node(n,n+t.nodeSize,{class:"selectedCell"}))})),vi.create(t.doc,e)}const Qa=new Le("fix-tables");function Za(t,e,n,r){const i=t.childCount,s=e.childCount;t:for(let o=0,l=0;o<s;o++){const s=e.child(o);for(let e=l,r=Math.min(i,o+3);e<r;e++)if(t.child(e)==s){l=e+1,n+=s.nodeSize;continue t}r(s,n),l<i&&t.child(l).sameMarkup(s)?Za(t.child(l),s,n+1,r):s.nodesBetween(0,s.content.size,r,n+1),n+=s.nodeSize}}function Ya(t,e){let n;const r=(e,r)=>{"table"==e.type.spec.tableRole&&(n=function(t,e,n,r){const i=Pa.get(e);if(!i.problems)return r;r||(r=t.tr);const s=[];for(let t=0;t<i.height;t++)s.push(0);for(let t=0;t<i.problems.length;t++){const o=i.problems[t];if("collision"==o.type){const t=e.nodeAt(o.pos);if(!t)continue;const i=t.attrs;for(let t=0;t<i.rowspan;t++)s[o.row+t]+=o.n;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,Ja(i,i.colspan-o.n,o.n))}else if("missing"==o.type)s[o.row]+=o.n;else if("overlong_rowspan"==o.type){const t=e.nodeAt(o.pos);if(!t)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-o.n})}else if("colwidth mismatch"==o.type){const t=e.nodeAt(o.pos);if(!t)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...t.attrs,colwidth:o.colwidth})}else if("zero_sized"==o.type){const t=r.mapping.map(n);r.delete(t,t+e.nodeSize)}}let o,l;for(let t=0;t<s.length;t++)s[t]&&(null==o&&(o=t),l=t);for(let u=0,a=n+1;u<i.height;u++){const n=e.child(u),i=a+n.nodeSize,h=s[u];if(h>0){let e="cell";n.firstChild&&(e=n.firstChild.type.spec.tableRole);const s=[];for(let n=0;n<h;n++){const n=Ba(t.schema)[e].createAndFill();n&&s.push(n)}r.insert(r.mapping.map(0!=u&&o!=u-1||l!=u?i-1:a+1),s)}a=i}return r.setMeta(Qa,{fixTables:!0})}(t,e,r,n))};return e?e.doc!=t.doc&&Za(e.doc,t.doc,0,r):t.doc.descendants(r),n}function th(t){const e=t.selection,n=Fa(t),r=n.node(-1),i=n.start(-1),s=Pa.get(r);return{...e instanceof Va?s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):s.findCell(n.pos-i),tableStart:i,map:s,table:r}}function eh(t,{map:e,tableStart:n,table:r},i){let s=i>0?-1:0;(function(t,e,n){const r=Ba(e.type.schema).header_cell;for(let i=0;i<t.height;i++)if(e.nodeAt(t.map[n+i*t.width]).type!=r)return!1;return!0})(e,r,i+s)&&(s=0==i||i==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+i;if(i>0&&i<e.width&&e.map[l-1]==e.map[l]){const s=e.map[l],u=r.nodeAt(s);t.setNodeMarkup(t.mapping.map(n+s),null,qa(u.attrs,i-e.colCount(s))),o+=u.attrs.rowspan-1}else{const u=null==s?Ba(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,a=e.positionAt(o,i,r);t.insert(t.mapping.map(n+a),u.createAndFill())}}return t}function nh(t,{map:e,table:n,tableStart:r},i){const s=t.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+i,u=e.map[l],a=n.nodeAt(u),h=a.attrs;if(i>0&&e.map[l-1]==u||i<e.width-1&&e.map[l+1]==u)t.setNodeMarkup(t.mapping.slice(s).map(r+u),null,Ja(h,i-e.colCount(u)));else{const e=t.mapping.slice(s).map(r+u);t.delete(e,e+a.nodeSize)}o+=h.rowspan}}function rh(t,{map:e,tableStart:n,table:r},i){let s=n;for(let t=0;t<i;t++)s+=r.child(t).nodeSize;const o=[];let l=i>0?-1:0;(function(t,e,n){var r;const i=Ba(e.type.schema).header_cell;for(let s=0;s<t.width;s++)if((null===(r=e.nodeAt(t.map[s+n*t.width]))||void 0===r?void 0:r.type)!=i)return!1;return!0})(e,r,i+l)&&(l=0==i||i==e.height?null:0);for(let s=0,a=e.width*i;s<e.width;s++,a++)if(i>0&&i<e.height&&e.map[a]==e.map[a-e.width]){const i=e.map[a],o=r.nodeAt(i).attrs;t.setNodeMarkup(n+i,null,{...o,rowspan:o.rowspan+1}),s+=o.colspan-1}else{var u;const t=null==l?Ba(r.type.schema).cell:null===(u=r.nodeAt(e.map[a+l*e.width]))||void 0===u?void 0:u.type,n=null==t?void 0:t.createAndFill();n&&o.push(n)}return t.insert(s,Ba(r.type.schema).row.create(null,o)),t}function ih(t,{map:e,table:n,tableStart:r},i){let s=0;for(let t=0;t<i;t++)s+=n.child(t).nodeSize;const o=s+n.child(i).nodeSize,l=t.mapping.maps.length;t.delete(s+r,o+r);const u=new Set;for(let s=0,o=i*e.width;s<e.width;s++,o++){const a=e.map[o];if(!u.has(a))if(u.add(a),i>0&&a==e.map[o-e.width]){const e=n.nodeAt(a).attrs;t.setNodeMarkup(t.mapping.slice(l).map(a+r),null,{...e,rowspan:e.rowspan-1}),s+=e.colspan-1}else if(i<e.height&&a==e.map[o+e.width]){const o=n.nodeAt(a),u=o.attrs,h=o.type.create({...u,rowspan:o.attrs.rowspan-1},o.content),c=e.positionAt(i+1,s,n);t.insert(t.mapping.slice(l).map(r+c),h),s+=u.colspan-1}}}function sh(t){const e=t.content;return 1==e.childCount&&e.child(0).isTextblock&&0==e.child(0).childCount}function oh(t,e){const n=t.selection;if(!(n instanceof Va)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=th(t),{map:i}=r;if(function({width:t,height:e,map:n},r){let i=r.top*t+r.left,s=i,o=(r.bottom-1)*t+r.left,l=i+(r.right-r.left-1);for(let e=r.top;e<r.bottom;e++){if(r.left>0&&n[s]==n[s-1]||r.right<t&&n[l]==n[l+1])return!0;s+=t,l+=t}for(let s=r.left;s<r.right;s++){if(r.top>0&&n[i]==n[i-t]||r.bottom<e&&n[o]==n[o+t])return!0;i++,o++}return!1}(i,r))return!1;if(e){const n=t.tr,s={};let o,u,a=l.empty;for(let t=r.top;t<r.bottom;t++)for(let e=r.left;e<r.right;e++){const l=i.map[t*i.width+e],h=r.table.nodeAt(l);if(!s[l]&&h)if(s[l]=!0,null==o)o=l,u=h;else{sh(h)||(a=a.append(h.content));const t=n.mapping.map(l+r.tableStart);n.delete(t,t+h.nodeSize)}}if(null==o||null==u)return!0;if(n.setNodeMarkup(o+r.tableStart,null,{...qa(u.attrs,u.attrs.colspan,r.right-r.left-u.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const t=o+1+u.content.size,e=sh(u)?o+1:t;n.replaceWith(e+r.tableStart,t+r.tableStart,a)}n.setSelection(new Va(n.doc.resolve(o+r.tableStart))),e(n)}return!0}function lh(t,e){const n=Ba(t.schema);return(r=({node:t})=>n[t.type.spec.tableRole],(t,e)=>{const n=t.selection;let i,s;if(n instanceof Va){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;i=n.$anchorCell.nodeAfter,s=n.$anchorCell.pos}else{var o;if(i=function(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if("cell"===n||"header_cell"===n)return t.node(e)}return null}(n.$from),!i)return!1;s=null===(o=za(n.$from))||void 0===o?void 0:o.pos}if(null==i||null==s)return!1;if(1==i.attrs.colspan&&1==i.attrs.rowspan)return!1;if(e){let o=i.attrs;const l=[],u=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});const a=th(t),h=t.tr;for(let t=0;t<a.right-a.left;t++)l.push(u?{...o,colwidth:u&&u[t]?[u[t]]:null}:o);let c;for(let t=a.top;t<a.bottom;t++){let e=a.map.positionAt(t,a.left,a.table);t==a.top&&(e+=i.nodeSize);for(let n=a.left,s=0;n<a.right;n++,s++)n==a.left&&t==a.top||h.insert(c=h.mapping.map(e+a.tableStart,1),r({node:i,row:t,col:n}).createAndFill(l[s]))}h.setNodeMarkup(s,r({node:i,row:a.top,col:a.left}),l[0]),n instanceof Va&&h.setSelection(new Va(h.doc.resolve(n.$anchorCell.pos),c?h.doc.resolve(c):void 0)),e(h)}return!0})(t,e);var r}function uh(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:"row"==t?e.map.width:1,bottom:"column"==t?e.map.height:1});for(let t=0;t<r.length;t++){const i=e.table.nodeAt(r[t]);if(i&&i.type!==n.header_cell)return!1}return!0}function ah(t,e){return(e=e||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(t){return function(e,n){if(!_a(e))return!1;if(n){const r=Ba(e.schema),i=th(e),s=e.tr,o=i.map.cellsInRect("column"==t?{left:i.left,top:0,right:i.right,bottom:i.map.height}:"row"==t?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=o.map((t=>i.table.nodeAt(t)));for(let t=0;t<o.length;t++)l[t].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[t],r.cell,l[t].attrs);if(0===s.steps.length)for(let t=0;t<o.length;t++)s.setNodeMarkup(i.tableStart+o[t],r.header_cell,l[t].attrs);n(s)}return!0}}(t):function(e,n){if(!_a(e))return!1;if(n){const r=Ba(e.schema),i=th(e),s=e.tr,o=uh("row",i,r),l=uh("column",i,r),u=("column"===t?o:"row"===t&&l)?1:0,a="column"==t?l?r.cell:r.header_cell:"row"==t?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect("column"==t?{left:0,top:u,right:1,bottom:i.map.height}:"row"==t?{left:u,top:0,right:i.map.width,bottom:1}:i).forEach((t=>{const e=t+i.tableStart,n=s.doc.nodeAt(e);n&&s.setNodeMarkup(e,a,n.attrs)})),n(s)}return!0}}ah("row",{useDeprecatedLogic:!0}),ah("column",{useDeprecatedLogic:!0});const hh=ah("cell",{useDeprecatedLogic:!0});function ch(t){return function(e,n){if(!_a(e))return!1;const r=function(t,e){if(e<0){const e=t.nodeBefore;if(e)return t.pos-e.nodeSize;for(let e=t.index(-1)-1,n=t.before();e>=0;e--){const r=t.node(-1).child(e),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const e=t.node(-1);for(let n=t.indexAfter(-1),r=t.after();n<e.childCount;n++){const t=e.child(n);if(t.childCount)return r+1;r+=t.nodeSize}}return null}(Fa(e),t);if(null==r)return!1;if(n){const t=e.doc.resolve(r);n(e.tr.setSelection(le.between(t,(i=t,i.node(0).resolve(i.pos+i.nodeAfter.nodeSize)))).scrollIntoView())}var i;return!0}}function fh(t,e){const n=t.selection;if(!(n instanceof Va))return!1;if(e){const r=t.tr,i=Ba(t.schema).cell.createAndFill().content;n.forEachCell(((t,e)=>{t.content.eq(i)||r.replace(r.mapping.map(e+1),r.mapping.map(e+t.nodeSize-1),new d(i,0,0))})),r.docChanged&&e(r)}return!0}function dh(t,e){const n=t.createAndFill();return new ee(n).replace(0,n.content.size,e).doc}function ph(t,e,n,r,i,s,o,l){if(0==o||o==e.height)return!1;let u=!1;for(let a=i;a<s;a++){const i=o*e.width+a,s=e.map[i];if(e.map[i-e.width]==s){u=!0;const i=n.nodeAt(s),{top:h,left:c}=e.findCell(s);t.setNodeMarkup(t.mapping.slice(l).map(s+r),null,{...i.attrs,rowspan:o-h}),t.insert(t.mapping.slice(l).map(e.positionAt(o,c,n)),i.type.createAndFill({...i.attrs,rowspan:h+i.attrs.rowspan-o})),a+=i.attrs.colspan-1}}return u}function mh(t,e,n,r,i,s,o,l){if(0==o||o==e.width)return!1;let u=!1;for(let a=i;a<s;a++){const i=a*e.width+o,s=e.map[i];if(e.map[i-1]==s){u=!0;const i=n.nodeAt(s),h=e.colCount(s),c=t.mapping.slice(l).map(s+r);t.setNodeMarkup(c,null,Ja(i.attrs,o-h,i.attrs.colspan-(o-h))),t.insert(c+i.nodeSize,i.type.createAndFill(Ja(i.attrs,0,o-h))),a+=i.attrs.rowspan-1}}return u}function gh(t,e,n,r,i){let s=n?t.doc.nodeAt(n-1):t.doc;if(!s)throw new Error("No table found");let o=Pa.get(s);const{top:u,left:a}=r,h=a+i.width,c=u+i.height,f=t.tr;let p=0;function m(){if(s=n?f.doc.nodeAt(n-1):f.doc,!s)throw new Error("No table found");o=Pa.get(s),p=f.mapping.maps.length}(function(t,e,n,r,i,s,o){const u=Ba(t.doc.type.schema);let a,h;if(i>e.width)for(let s=0,l=0;s<e.height;s++){const c=n.child(s);l+=c.nodeSize;const f=[];let d;d=null==c.lastChild||c.lastChild.type==u.cell?a||(a=u.cell.createAndFill()):h||(h=u.header_cell.createAndFill());for(let t=e.width;t<i;t++)f.push(d);t.insert(t.mapping.slice(o).map(l-1+r),f)}if(s>e.height){const c=[];for(let t=0,r=(e.height-1)*e.width;t<Math.max(e.width,i);t++){const i=!(t>=e.width)&&n.nodeAt(e.map[r+t]).type==u.header_cell;c.push(i?h||(h=u.header_cell.createAndFill()):a||(a=u.cell.createAndFill()))}const f=u.row.create(null,l.from(c)),d=[];for(let t=e.height;t<s;t++)d.push(f);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),d)}return!(!a&&!h)})(f,o,s,n,h,c,p)&&m(),ph(f,o,s,n,a,h,u,p)&&m(),ph(f,o,s,n,a,h,c,p)&&m(),mh(f,o,s,n,u,c,a,p)&&m(),mh(f,o,s,n,u,c,h,p)&&m();for(let t=u;t<c;t++){const e=o.positionAt(t,a,s),r=o.positionAt(t,h,s);f.replace(f.mapping.slice(p).map(e+n),f.mapping.slice(p).map(r+n),new d(i.rows[t-u],0,0))}m(),f.setSelection(new Va(f.doc.resolve(n+o.positionAt(u,a,s)),f.doc.resolve(n+o.positionAt(c-1,h-1,s)))),e(f)}const wh=ls({ArrowLeft:yh("horiz",-1),ArrowRight:yh("horiz",1),ArrowUp:yh("vert",-1),ArrowDown:yh("vert",1),"Shift-ArrowLeft":vh("horiz",-1),"Shift-ArrowRight":vh("horiz",1),"Shift-ArrowUp":vh("vert",-1),"Shift-ArrowDown":vh("vert",1),Backspace:fh,"Mod-Backspace":fh,Delete:fh,"Mod-Delete":fh});function bh(t,e,n){return!n.eq(t.selection)&&(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function yh(t,e){return(n,r,i)=>{if(!i)return!1;const s=n.selection;if(s instanceof Va)return bh(n,r,re.near(s.$headCell,e));if("horiz"!=t&&!s.empty)return!1;const o=xh(i,t,e);if(null==o)return!1;if("horiz"==t)return bh(n,r,re.near(n.doc.resolve(s.head+e),e));{const i=n.doc.resolve(o),s=Ua(i,t,e);let l;return l=s?re.near(s,1):e<0?re.near(n.doc.resolve(i.before(-1)),-1):re.near(n.doc.resolve(i.after(-1)),1),bh(n,r,l)}}}function vh(t,e){return(n,r,i)=>{if(!i)return!1;const s=n.selection;let o;if(s instanceof Va)o=s;else{const r=xh(i,t,e);if(null==r)return!1;o=new Va(n.doc.resolve(r))}const l=Ua(o.$headCell,t,e);return!!l&&bh(n,r,new Va(o.$anchorCell,l))}}function kh(t,e){const n=za(t.state.doc.resolve(e));return!!n&&(t.dispatch(t.state.tr.setSelection(new Va(n))),!0)}function Mh(t,e,n){if(!_a(t.state))return!1;let r=function(t){if(0===t.size)return null;let{content:e,openStart:n,openEnd:r}=t;for(;1==e.childCount&&(n>0&&r>0||"table"==e.child(0).type.spec.tableRole);)n--,r--,e=e.child(0).content;const i=e.child(0),s=i.type.spec.tableRole,o=i.type.schema,u=[];if("row"==s)for(let t=0;t<e.childCount;t++){let i=e.child(t).content;const s=t?0:Math.max(0,n-1),l=t<e.childCount-1?0:Math.max(0,r-1);(s||l)&&(i=dh(Ba(o).row,new d(i,s,l)).content),u.push(i)}else{if("cell"!=s&&"header_cell"!=s)return null;u.push(n||r?dh(Ba(o).row,new d(e,n,r)).content:e)}return function(t,e){const n=[];for(let t=0;t<e.length;t++){const r=e[t];for(let e=r.childCount-1;e>=0;e--){const{rowspan:i,colspan:s}=r.child(e).attrs;for(let e=t;e<t+i;e++)n[e]=(n[e]||0)+s}}let r=0;for(let t=0;t<n.length;t++)r=Math.max(r,n[t]);for(let i=0;i<n.length;i++)if(i>=e.length&&e.push(l.empty),n[i]<r){const s=Ba(t).cell.createAndFill(),o=[];for(let t=n[i];t<r;t++)o.push(s);e[i]=e[i].append(l.from(o))}return{height:e.length,width:r,rows:e}}(o,u)}(n);const i=t.state.selection;if(i instanceof Va){r||(r={width:1,height:1,rows:[l.from(dh(Ba(t.state.schema).cell,n))]});const e=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),o=Pa.get(e).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=function({width:t,height:e,rows:n},r,i){if(t!=r){const e=[],i=[];for(let t=0;t<n.length;t++){const s=n[t],o=[];for(let n=e[t]||0,i=0;n<r;i++){let l=s.child(i%s.childCount);n+l.attrs.colspan>r&&(l=l.type.createChecked(Ja(l.attrs,l.attrs.colspan,n+l.attrs.colspan-r),l.content)),o.push(l),n+=l.attrs.colspan;for(let n=1;n<l.attrs.rowspan;n++)e[t+n]=(e[t+n]||0)+l.attrs.colspan}i.push(l.from(o))}n=i,t=r}if(e!=i){const t=[];for(let r=0,s=0;r<i;r++,s++){const o=[],u=n[s%e];for(let t=0;t<u.childCount;t++){let e=u.child(t);r+e.attrs.rowspan>i&&(e=e.type.create({...e.attrs,rowspan:Math.max(1,i-e.attrs.rowspan)},e.content)),o.push(e)}t.push(l.from(o))}n=t,e=i}return{width:t,height:e,rows:n}}(r,o.right-o.left,o.bottom-o.top),gh(t.state,t.dispatch,s,o,r),!0}if(r){const e=Fa(t.state),n=e.start(-1);return gh(t.state,t.dispatch,n,Pa.get(e.node(-1)).findCell(e.pos-n),r),!0}return!1}function Th(t,e){var n;if(0!=e.button)return;if(e.ctrlKey||e.metaKey)return;const r=Lh(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof Va)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&null!=(i=za(t.state.selection.$anchor))&&(null===(n=Sh(t,e))||void 0===n?void 0:n.pos)!=i.pos)s(i,e),e.preventDefault();else if(!r)return;function s(e,n){let r=Sh(t,n);const i=null==ja.getState(t.state);if(!r||!Ka(e,r)){if(!i)return;r=e}const s=new Va(e,r);if(i||!t.state.selection.eq(s)){const n=t.state.tr.setSelection(s);i&&n.setMeta(ja,e.pos),t.dispatch(n)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),null!=ja.getState(t.state)&&t.dispatch(t.state.tr.setMeta(ja,-1))}function l(n){const i=n,l=ja.getState(t.state);let u;if(null!=l)u=t.state.doc.resolve(l);else if(Lh(t,i.target)!=r&&(u=Sh(t,e),!u))return o();u&&s(u,i)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function xh(t,e,n){if(!(t.state.selection instanceof le))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const s=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:s.childCount))return null;if("cell"==s.type.spec.tableRole||"header_cell"==s.type.spec.tableRole){const s=r.before(i);return t.endOfTextblock("vert"==e?n>0?"down":"up":n>0?"right":"left")?s:null}}return null}function Lh(t,e){for(;e&&e!=t.dom;e=e.parentNode)if("TD"==e.nodeName||"TH"==e.nodeName)return e;return null}function Sh(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&za(t.state.doc.resolve(r))||za(t.state.doc.resolve(i))}var Ah=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Eh(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type==this.node.type&&(this.node=t,Eh(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return"attributes"==t.type&&(t.target==this.table||this.colgroup.contains(t.target))}};function Eh(t,e,n,r,i,s){let o=0,l=!0,u=e.firstChild;const a=t.firstChild;if(a){for(let t=0,n=0;t<a.childCount;t++){const{colspan:h,colwidth:c}=a.child(t).attrs;for(let t=0;t<h;t++,n++){const a=i==n?s:c&&c[t],h=a?a+"px":"";if(o+=a||r,a||(l=!1),u)u.style.width!=h&&(u.style.width=h),u=u.nextSibling;else{const t=document.createElement("col");t.style.width=h,e.appendChild(t)}}}for(;u;){var h;const t=u.nextSibling;null===(h=u.parentNode)||void 0===h||h.removeChild(u),u=t}l?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const Oh=new Le("tableColumnResizing");function $h({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=Ah,lastColumnResizable:i=!0}={}){const s=new Me({key:Oh,state:{init(t,e){var i;const o=null===(i=s.spec)||void 0===i||null===(i=i.props)||void 0===i?void 0:i.nodeViews,l=Ba(e.schema).table.name;return r&&o&&(o[l]=(t,e)=>new r(t,n,e)),new Ch(-1,!1)},apply:(t,e)=>e.apply(t)},props:{attributes:t=>{const e=Oh.getState(t);return e&&e.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(e,n)=>{!function(t,e,n,r){if(!t.editable)return;const i=Oh.getState(t.state);if(i&&!i.dragging){const s=function(t){for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}(e.target);let o=-1;if(s){const{left:r,right:i}=s.getBoundingClientRect();e.clientX-r<=n?o=Rh(t,e,"left",n):i-e.clientX<=n&&(o=Rh(t,e,"right",n))}if(o!=i.activeHandle){if(!r&&-1!==o){const e=t.state.doc.resolve(o),n=e.node(-1),r=Pa.get(n),i=e.start(-1);if(r.colCount(e.pos-i)+e.nodeAfter.attrs.colspan-1==r.width-1)return}Nh(t,o)}}}(e,n,t,i)},mouseleave:t=>{!function(t){if(!t.editable)return;const e=Oh.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Nh(t,-1)}(t)},mousedown:(t,r)=>{!function(t,e,n,r){var i;if(!t.editable)return!1;const s=null!==(i=t.dom.ownerDocument.defaultView)&&void 0!==i?i:window,o=Oh.getState(t.state);if(!o||-1==o.activeHandle||o.dragging)return!1;const l=t.state.doc.nodeAt(o.activeHandle),u=function(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const s=t.domAtPos(e);let o=s.node.childNodes[s.offset].offsetWidth,l=n;if(r)for(let t=0;t<n;t++)r[t]&&(o-=r[t],l--);return o/l}(t,o.activeHandle,l.attrs);function a(e){s.removeEventListener("mouseup",a),s.removeEventListener("mousemove",h);const r=Oh.getState(t.state);(null==r?void 0:r.dragging)&&(function(t,e,n){const r=t.state.doc.resolve(e),i=r.node(-1),s=Pa.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,u=t.state.tr;for(let t=0;t<s.height;t++){const e=t*s.width+l;if(t&&s.map[e]==s.map[e-s.width])continue;const r=s.map[e],a=i.nodeAt(r).attrs,h=1==a.colspan?0:l-s.colCount(r);if(a.colwidth&&a.colwidth[h]==n)continue;const c=a.colwidth?a.colwidth.slice():Array(a.colspan).fill(0);c[h]=n,u.setNodeMarkup(o+r,null,{...a,colwidth:c})}u.docChanged&&t.dispatch(u)}(t,r.activeHandle,Hh(r.dragging,e,n)),t.dispatch(t.state.tr.setMeta(Oh,{setDragging:null})))}function h(e){if(!e.which)return a(e);const i=Oh.getState(t.state);if(i&&i.dragging){const s=Hh(i.dragging,e,n);Ih(t,i.activeHandle,s,r)}}t.dispatch(t.state.tr.setMeta(Oh,{setDragging:{startX:e.clientX,startWidth:u}})),Ih(t,o.activeHandle,u,r),s.addEventListener("mouseup",a),s.addEventListener("mousemove",h),e.preventDefault()}(t,r,e,n)}},decorations:t=>{const e=Oh.getState(t);if(e&&e.activeHandle>-1)return function(t,e){const n=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return vi.empty;const s=Pa.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let e=0;e<s.height;e++){const r=l+e*s.width;if(!(l!=s.width-1&&s.map[r]==s.map[r+1]||0!=e&&s.map[r]==s.map[r-s.width])){var u;const e=s.map[r],l=o+e+i.nodeAt(e).nodeSize-1,a=document.createElement("div");a.className="column-resize-handle",(null===(u=Oh.getState(t))||void 0===u?void 0:u.dragging)&&n.push(wi.node(o+e,o+e+i.nodeAt(e).nodeSize,{class:"column-resize-dragging"})),n.push(wi.widget(l,a))}}return vi.create(t.doc,n)}(t,e.activeHandle)},nodeViews:{}}});return s}var Ch=class t{constructor(t,e){this.activeHandle=t,this.dragging=e}apply(e){const n=this,r=e.getMeta(Oh);if(r&&null!=r.setHandle)return new t(r.setHandle,!1);if(r&&void 0!==r.setDragging)return new t(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let r=e.mapping.map(n.activeHandle,-1);return Wa(e.doc.resolve(r))||(r=-1),new t(r,n.dragging)}return n}};function Rh(t,e,n,r){const i=t.posAtCoords({left:e.clientX+("right"==n?-r:r),top:e.clientY});if(!i)return-1;const{pos:s}=i,o=za(t.state.doc.resolve(s));if(!o)return-1;if("right"==n)return o.pos;const l=Pa.get(o.node(-1)),u=o.start(-1),a=l.map.indexOf(o.pos-u);return a%l.width==0?-1:u+l.map[a-1]}function Hh(t,e,n){return Math.max(n,t.startWidth+(e.clientX-t.startX))}function Nh(t,e){t.dispatch(t.state.tr.setMeta(Oh,{setHandle:e}))}function Ih(t,e,n,r){const i=t.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),l=Pa.get(s).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1;let u=t.domAtPos(i.start(-1)).node;for(;u&&"TABLE"!=u.nodeName;)u=u.parentNode;u&&Eh(s,u.firstChild,u,r,l,n)}function Ph({allowTableNodeSelection:t=!1}={}){return new Me({key:ja,state:{init:()=>null,apply(t,e){const n=t.getMeta(ja);if(null!=n)return-1==n?null:n;if(null==e||!t.docChanged)return e;const{deleted:r,pos:i}=t.mapping.mapResult(e);return r?null:i}},props:{decorations:Xa,handleDOMEvents:{mousedown:Th},createSelectionBetween:t=>null!=ja.getState(t.state)?t.state.selection:null,handleTripleClick:kh,handleKeyDown:wh,handlePaste:Mh},appendTransaction:(e,n,r)=>function(t,e,n){const r=(e||t).selection,i=(e||t).doc;let s,o;if(r instanceof ae&&(o=r.node.type.spec.tableRole)){if("cell"==o||"header_cell"==o)s=Va.create(i,r.from);else if("row"==o){const t=i.resolve(r.from+1);s=Va.rowSelection(t,t)}else if(!n){const t=Pa.get(r.node),e=r.from+1;s=Va.create(i,e+1,e+t.map[t.width*t.height-1])}}else r instanceof le&&function({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,i=t.depth;for(;i>=0&&!(t.after(i+1)<t.end(i));i--,n++);for(let t=e.depth;t>=0&&!(e.before(t+1)>e.start(t));t--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}(r)?s=le.create(i,r.from):r instanceof le&&function({$from:t,$to:e}){let n,r;for(let e=t.depth;e>0;e--){const r=t.node(e);if("cell"===r.type.spec.tableRole||"header_cell"===r.type.spec.tableRole){n=r;break}}for(let t=e.depth;t>0;t--){const n=e.node(t);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){r=n;break}}return n!==r&&0===e.parentOffset}(r)&&(s=le.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}(r,Ya(r,n),t)})}var Dh=class{constructor({editor:t,element:e,view:n,pluginKey:r="bubbleMenu",updateDelay:i=250,resizeDelay:s=60,shouldShow:o,appendTo:l,getReferencedVirtualElement:u,options:a}){var h;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:t,state:e,from:n,to:r})=>{const{doc:i,selection:s}=e,{empty:o}=s,l=!i.textBetween(n,r).length&&Is(e.selection),u=this.element.contains(document.activeElement);return!(!t.hasFocus()&&!u||o||l||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout((()=>{this.updatePosition()}),this.resizeDelay)},this.focusHandler=()=>{setTimeout((()=>this.update(this.editor.view)))},this.blurHandler=({event:t})=>{var e;this.editor.isDestroyed?this.destroy():this.preventHide?this.preventHide=!1:(null==t?void 0:t.relatedTarget)&&(null==(e=this.element.parentNode)?void 0:e.contains(t.relatedTarget))||(null==t?void 0:t.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(t,e)=>{const n=!(null==e?void 0:e.selection.eq(t.state.selection)),r=!(null==e?void 0:e.doc.eq(t.state.doc));(n||r)&&(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout((()=>{this.updateHandler(t,n,r,e)}),this.updateDelay))},this.updateHandler=(t,e,n,r)=>{const{composing:i}=t;i||!e&&!n||(this.getShouldShow(r)?(this.show(),this.updatePosition()):this.hide())},this.transactionHandler=({transaction:t})=>{const e=t.getMeta(this.pluginKey);"updatePosition"===e?this.updatePosition():e&&"object"==typeof e&&"updateOptions"===e.type?this.updateOptions(e.options):"hide"===e?this.hide():"show"===e&&(this.updatePosition(),this.show())},this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=s,this.appendTo=l,this.scrollTarget=null!=(h=null==a?void 0:a.scrollTarget)?h:window,this.getReferencedVirtualElement=u,this.floatingUIOptions={...this.floatingUIOptions,...a},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(Ha("boolean"!=typeof this.floatingUIOptions.flip?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push((void 0===(e="boolean"!=typeof this.floatingUIOptions.shift?this.floatingUIOptions.shift:void 0)&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:o=!0,crossAxis:l=!1,limiter:u={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...a}=Su(e,t),h={x:n,y:r},c=await s.detectOverflow(t,a),f=Cu(Au(i)),d=Ou(f);let p=h[d],m=h[f];o&&(p=Lu(p+c["y"===d?"top":"left"],p,p-c["y"===d?"bottom":"right"])),l&&(m=Lu(m+c["y"===f?"top":"left"],m,m-c["y"===f?"bottom":"right"]));const g=u.fn({...t,[d]:p,[f]:m});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[d]:o,[f]:l}}}}})),this.floatingUIOptions.offset&&t.push(function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:o,middlewareData:l}=e,u=await async function(t,e){const{placement:n,platform:r,elements:i}=t,s=await(null==r.isRTL?void 0:r.isRTL(i.floating)),o=Au(n),l=Eu(n),u="y"===Cu(n),a=qu.has(o)?-1:1,h=s&&u?-1:1,c=Su(e,t);let{mainAxis:f,crossAxis:d,alignmentAxis:p}="number"==typeof c?{mainAxis:c,crossAxis:0,alignmentAxis:null}:{mainAxis:c.mainAxis||0,crossAxis:c.crossAxis||0,alignmentAxis:c.alignmentAxis};return l&&"number"==typeof p&&(d="end"===l?-1*p:p),u?{x:d*h,y:f*a}:{x:f*a,y:d*h}}(e,t);return o===(null==(n=l.offset)?void 0:n.placement)&&null!=(r=l.arrow)&&r.alignmentOffset?{}:{x:i+u.x,y:s+u.y,data:{...u,placement:o}}}}}("boolean"!=typeof this.floatingUIOptions.offset?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push((t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:s,platform:o,elements:l,middlewareData:u}=e,{element:a,padding:h=0}=Su(t,e)||{};if(null==a)return{};const c=zu(h),f={x:n,y:r},d=Ru(i),p=$u(d),m=await o.getDimensions(a),g="y"===d,w=g?"top":"left",b=g?"bottom":"right",y=g?"clientHeight":"clientWidth",v=s.reference[p]+s.reference[d]-f[d]-s.floating[p],k=f[d]-s.reference[d],M=await(null==o.getOffsetParent?void 0:o.getOffsetParent(a));let T=M?M[y]:0;T&&await(null==o.isElement?void 0:o.isElement(M))||(T=l.floating[y]||s.floating[p]);const x=v/2-k/2,L=T/2-m[p]/2-1,S=vu(c[w],L),A=vu(c[b],L),E=S,O=T-m[p]-A,$=T/2-m[p]/2+x,C=Lu(E,$,O),R=!u.arrow&&null!=Eu(i)&&$!==C&&s.reference[p]/2-($<E?S:A)-m[p]/2<0,H=R?$<E?$-E:$-O:0;return{[d]:f[d]+H,data:{[d]:C,centerOffset:$-C-H,...R&&{alignmentOffset:H}},reset:R}}}))(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:s,platform:o,elements:l}=e,{apply:u=()=>{},...a}=Su(t,e),h=await o.detectOverflow(e,a),c=Au(i),f=Eu(i),d="y"===Cu(i),{width:p,height:m}=s.floating;let g,w;"top"===c||"bottom"===c?(g=c,w=f===(await(null==o.isRTL?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(w=c,g="end"===f?"top":"bottom");const b=m-h.top-h.bottom,y=p-h.left-h.right;let v=vu(m-h[g],b),k=vu(p-h[w],y);if(null!=(n=e.middlewareData.shift)&&n.enabled.x&&(k=y),null!=(r=e.middlewareData.shift)&&r.enabled.y&&(v=b),!e.middlewareData.shift&&!f){const t=ku(h.left,0),e=ku(h.right,0),n=ku(h.top,0),r=ku(h.bottom,0);d?k=p-2*(0!==t||0!==e?t+e:ku(h.left,h.right)):v=m-2*(0!==n||0!==r?n+r:ku(h.top,h.bottom))}await u({...e,availableWidth:k,availableHeight:v});const M=await o.getDimensions(l.floating);return p!==M.width||m!==M.height?{reset:{rects:!0}}:{}}}}("boolean"!=typeof this.floatingUIOptions.size?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,i;const{rects:s,middlewareData:o,placement:l,platform:u,elements:a}=e,{crossAxis:h=!1,alignment:c,allowedPlacements:f=yu,autoAlignment:d=!0,...p}=Su(t,e),m=void 0!==c||f===yu?function(t,e,n){return(t?[...n.filter((e=>Eu(e)===t)),...n.filter((e=>Eu(e)!==t))]:n.filter((t=>Au(t)===t))).filter((n=>!t||Eu(n)===t||!!e&&Nu(n)!==n))}(c||null,d,f):f,g=await u.detectOverflow(e,p),w=(null==(n=o.autoPlacement)?void 0:n.index)||0,b=m[w];if(null==b)return{};const y=Hu(b,s,await(null==u.isRTL?void 0:u.isRTL(a.floating)));if(l!==b)return{reset:{placement:m[0]}};const v=[g[Au(b)],g[y[0]],g[y[1]]],k=[...(null==(r=o.autoPlacement)?void 0:r.overflows)||[],{placement:b,overflows:v}],M=m[w+1];if(M)return{data:{index:w+1,overflows:k},reset:{placement:M}};const T=k.map((t=>{const e=Eu(t.placement);return[t.placement,e&&h?t.overflows.slice(0,2).reduce(((t,e)=>t+e),0):t.overflows[0],t.overflows]})).sort(((t,e)=>t[1]-e[1])),x=(null==(i=T.filter((t=>t[2].slice(0,Eu(t[0])?2:3).every((t=>t<=0))))[0])?void 0:i[0])||T[0][0];return x!==l?{data:{index:w+1,overflows:k},reset:{placement:x}}:{}}}}("boolean"!=typeof this.floatingUIOptions.autoPlacement?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:i="referenceHidden",...s}=Su(t,e);switch(i){case"referenceHidden":{const t=Ku(await r.detectOverflow(e,{...s,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:Uu(t)}}}case"escaped":{const t=Ku(await r.detectOverflow(e,{...s,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:Uu(t)}}}default:return{}}}}}("boolean"!=typeof this.floatingUIOptions.hide?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:i,platform:s,strategy:o}=e,{padding:l=2,x:u,y:a}=Su(t,e),h=Array.from(await(null==s.getClientRects?void 0:s.getClientRects(r.reference))||[]),c=function(t){const e=t.slice().sort(((t,e)=>t.y-e.y)),n=[];let r=null;for(let t=0;t<e.length;t++){const i=e[t];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map((t=>_u(Ju(t))))}(h),f=_u(Ju(h)),d=zu(l),p=await s.getElementRects({reference:{getBoundingClientRect:function(){if(2===c.length&&c[0].left>c[1].right&&null!=u&&null!=a)return c.find((t=>u>t.left-d.left&&u<t.right+d.right&&a>t.top-d.top&&a<t.bottom+d.bottom))||f;if(c.length>=2){if("y"===Cu(n)){const t=c[0],e=c[c.length-1],r="top"===Au(n),i=t.top,s=e.bottom,o=r?t.left:e.left,l=r?t.right:e.right;return{top:i,bottom:s,left:o,right:l,width:l-o,height:s-i,x:o,y:i}}const t="left"===Au(n),e=ku(...c.map((t=>t.right))),r=vu(...c.map((t=>t.left))),i=c.filter((n=>t?n.left===r:n.right===e)),s=i[0].top,o=i[i.length-1].bottom;return{top:s,bottom:o,left:r,right:e,width:e-r,height:o-s,x:r,y:s}}return f}},floating:r.floating,strategy:o});return i.reference.x!==p.reference.x||i.reference.y!==p.reference.y||i.reference.width!==p.reference.width||i.reference.height!==p.reference.height?{reset:{rects:p}}:{}}}}("boolean"!=typeof this.floatingUIOptions.inline?this.floatingUIOptions.inline:void 0)),t;var e}get virtualElement(){var t,e,n;const{selection:r}=this.editor.state,i=null==(t=this.getReferencedVirtualElement)?void 0:t.call(this);if(i)return i;if(!(null==(n=null==(e=this.view)?void 0:e.dom)?void 0:n.parentNode))return;const s=function(t,e,n){const r=t.state.doc.content.size,i=Ps(e,0,r),s=Ps(n,0,r),o=t.coordsAtPos(i),l=t.coordsAtPos(s,-1),u=Math.min(o.top,l.top),a=Math.max(o.bottom,l.bottom),h=Math.min(o.left,l.left),c=Math.max(o.right,l.right),f={top:u,bottom:a,left:h,right:c,width:c-h,height:a-u,x:h,y:u};return{...f,toJSON:()=>f}}(this.view,r.from,r.to);let o={getBoundingClientRect:()=>s,getClientRects:()=>[s]};if(r instanceof ae){let t=this.view.nodeDOM(r.from);const e=t.dataset.nodeViewWrapper?t:t.querySelector("[data-node-view-wrapper]");e&&(t=e),t&&(o={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(r instanceof Va){const{$anchorCell:t,$headCell:e}=r,n=e?e.pos:t.pos,i=this.view.nodeDOM(t?t.pos:e.pos),s=this.view.nodeDOM(n);if(!i||!s)return;const l=i===s?i.getBoundingClientRect():function(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),i=Math.min(t.left,e.left),s=Math.max(t.right,e.right);return new DOMRect(i,n,s-i,r-n)}(i.getBoundingClientRect(),s.getBoundingClientRect());o={getBoundingClientRect:()=>l,getClientRects:()=>[l]}}return o}updatePosition(){if(!this.isVisible)return;const t=this.virtualElement;t&&((t,e,n)=>{const r=new Map,i={platform:Ra,...n},s={...i.platform,_c:r};return(async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:Wu},u=await(null==o.isRTL?void 0:o.isRTL(e));let a=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:h,y:c}=Fu(a,r,u),f=r,d=0;const p={};for(let n=0;n<s.length;n++){const m=s[n];if(!m)continue;const{name:g,fn:w}=m,{x:b,y,data:v,reset:k}=await w({x:h,y:c,initialPlacement:r,placement:f,strategy:i,middlewareData:p,rects:a,platform:l,elements:{reference:t,floating:e}});h=null!=b?b:h,c=null!=y?y:c,p[g]={...p[g],...v},k&&d<50&&(d++,"object"==typeof k&&(k.placement&&(f=k.placement),k.rects&&(a=!0===k.rects?await o.getElementRects({reference:t,floating:e,strategy:i}):k.rects),({x:h,y:c}=Fu(a,f,u))),n=-1)}return{x:h,y:c,placement:f,strategy:i,middlewareData:p}})(t,e,{...i,platform:s})})(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then((({x:t,y:e,strategy:n,middlewareData:r})=>{var i,s;this.isVisible&&!this.editor.isDestroyed&&this.element.isConnected&&((null==(i=r.hide)?void 0:i.referenceHidden)||(null==(s=r.hide)?void 0:s.escaped)?this.element.style.visibility="hidden":(this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${t}px`,this.element.style.top=`${e}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()))}))}update(t,e){const{state:n}=t;if(this.updateDelay>0&&n.selection.from!==n.selection.to)return void this.handleDebouncedUpdate(t,e);const r=!(null==e?void 0:e.selection.eq(t.state.selection)),i=!(null==e?void 0:e.doc.eq(t.state.doc));this.updateHandler(t,r,i,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:i}=r,s=Math.min(...i.map((t=>t.$from.pos))),o=Math.max(...i.map((t=>t.$to.pos)));return(null==(e=this.shouldShow)?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:s,to:o}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const e="function"==typeof this.appendTo?this.appendTo():this.appendTo;null==(t=null!=e?e:this.view.dom.parentElement)||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(t){var e;if(void 0!==t.updateDelay&&(this.updateDelay=t.updateDelay),void 0!==t.resizeDelay&&(this.resizeDelay=t.resizeDelay),void 0!==t.appendTo&&(this.appendTo=t.appendTo),void 0!==t.getReferencedVirtualElement&&(this.getReferencedVirtualElement=t.getReferencedVirtualElement),void 0!==t.shouldShow&&t.shouldShow&&(this.shouldShow=t.shouldShow),void 0!==t.options){const n=null!=(e=t.options.scrollTarget)?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Bh=zl.create({name:"bubbleMenu",addOptions:()=>({element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}),addProseMirrorPlugins(){return this.options.element?[(t={pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow},new Me({key:"string"==typeof t.pluginKey?new Le(t.pluginKey):t.pluginKey,view:e=>new Dh({view:e,...t})}))]:[];var t}}),jh=(t,e)=>{if("slot"===t)return 0;if(t instanceof Function)return t(e);const{children:n,...r}=null!=e?e:{};if("svg"===t)throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},zh=/^\s*>\s$/,_h=mu.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:t}){return jh("blockquote",{...Ho(this.options.HTMLAttributes,t),children:jh("slot",{})})},parseMarkdown:(t,e)=>{var n;const r=null!=(n=e.parseBlockChildren)?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";const n=[];return t.content.forEach(((t,r)=>{var i,s;const o=(null!=(s=null==(i=e.renderChild)?void 0:i.call(e,t,r))?s:e.renderChildren([t])).split("\n").map((t=>""===t.trim()?">":`> ${t}`));n.push(o.join("\n"))})),n.join("\n>\n")},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[ru({find:zh,type:this.type})]}}),Fh=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Wh=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Kh=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Uh=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Jh=Il.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!==t.style.fontWeight&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return jh("strong",{...Ho(this.options.HTMLAttributes,t),children:jh("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[tu({find:Fh,type:this.type}),tu({find:Kh,type:this.type})]},addPasteRules(){return[gu({find:Wh,type:this.type}),gu({find:Uh,type:this.type})]}}),qh=t=>{const e=/`([^`]+)`(?!`)$/.exec(t);return e?e.index>0&&"`"===t[e.index-1]?null:{index:e.index,text:e[0],replaceWith:e[1]}:null},Vh=t=>{const e=/`([^`]+)`(?!`)/g,n=[];let r;for(;null!==(r=e.exec(t));)r.index>0&&"`"===t[r.index-1]||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n},Gh=Il.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:t}){return["code",Ho(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[tu({find:qh,type:this.type})]},addPasteRules(){return[gu({find:Vh,type:this.type})]}}),Xh=/^```([a-z]+)?[\s\n]$/,Qh=/^~~~([a-z]+)?[\s\n]$/,Zh=mu.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;return[...(null==(e=t.firstElementChild)?void 0:e.classList)||[]].filter((t=>t.startsWith(n))).map((t=>t.replace(n,"")))[0]||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:t,HTMLAttributes:e}){return["pre",Ho(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return!1===(null==(n=t.raw)?void 0:n.startsWith("```"))&&!1===(null==(r=t.raw)?void 0:r.startsWith("~~~"))&&"indented"!==t.codeBlockStyle?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=(null==(n=t.attrs)?void 0:n.language)||"";return r=t.content?[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join("\n"):`\`\`\`${i}\n\n\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection;return!(!t||e.parent.type.name!==this.name)&&!(1!==e.pos&&e.parent.textContent.length)&&this.editor.commands.clearNodes()},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=null!=(e=this.options.tabSize)?e:4,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command((({tr:t})=>{const{from:e,to:n}=i,s=r.doc.textBetween(e,n,"\n","\n").split("\n").map((t=>l+t)).join("\n");return t.replaceWith(e,n,r.schema.text(s)),!0}))},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=null!=(e=this.options.tabSize)?e:4,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;return s.parent.type===this.type&&t.commands.command(o?({tr:t})=>{var e;const{pos:i}=s,o=s.start(),l=s.end(),u=r.doc.textBetween(o,l,"\n","\n").split("\n");let a=0,h=0;const c=i-o;for(let t=0;t<u.length;t+=1){if(h+u[t].length>=c){a=t;break}h+=u[t].length+1}const f=(null==(e=u[a].match(/^ */))?void 0:e[0])||"",d=Math.min(f.length,n);if(0===d)return!0;let p=o;for(let t=0;t<a;t+=1)p+=u[t].length+1;return t.delete(p,p+d),i-p<=d&&t.setSelection(le.create(t.doc,p)),!0}:({tr:t})=>{const{from:e,to:s}=i,o=r.doc.textBetween(e,s,"\n","\n").split("\n").map((t=>{var e;const r=(null==(e=t.match(/^ */))?void 0:e[0])||"",i=Math.min(r.length,n);return t.slice(i)})).join("\n");return t.replaceWith(e,s,r.schema.text(o)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith("\n\n");return!(!s||!o)&&t.chain().command((({tr:t})=>(t.delete(r.pos-2,r.pos),!0))).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:s}=n;if(!s||i.parent.type!==this.type)return!1;if(i.parentOffset!==i.parent.nodeSize-2)return!1;const o=i.after();return void 0!==o&&(r.nodeAt(o)?t.commands.command((({tr:t})=>(t.setSelection(re.near(r.resolve(o))),!0))):t.commands.exitCode())}}},addInputRules(){return[nu({find:Xh,type:this.type,getAttributes:t=>({language:t[1]})}),nu({find:Qh,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Me({key:new Le("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData)return!1;if(this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=null==i?void 0:i.mode;if(!n||!s)return!1;const{tr:o,schema:l}=t.state,u=l.text(n.replace(/\r\n?/g,"\n"));return o.replaceSelectionWith(this.type.create({language:s},u)),o.selection.$from.parent.type!==this.type&&o.setSelection(le.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),Yh=mu.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,"\n\n"):""}),tc=mu.create({name:"hardBreak",markdownTokenName:"br",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:t}){return["br",Ho(this.options.HTMLAttributes,t)]},renderText:()=>"\n",renderMarkdown:()=>" \n",parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command((()=>{const{selection:t,storedMarks:i}=n;if(t.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:o}=r.extensionManager,l=i||t.$to.parentOffset&&t.$from.marks();return e().insertContent({type:this.name}).command((({tr:t,dispatch:e})=>{if(e&&l&&s){const e=l.filter((t=>o.includes(t.type.name)));t.ensureMarks(e)}return!0})).run()}))])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),ec=mu.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map((t=>({tag:`h${t}`,attrs:{level:t}})))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Ho(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(null==(n=t.attrs)?void 0:n.level)?parseInt(t.attrs.level,10):1,i="#".repeat(r);return t.content?`${i} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.setNode(this.name,t),toggleHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return this.options.levels.reduce(((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})})),{})},addInputRules(){return this.options.levels.map((t=>nu({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}})))}}),nc=mu.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{},nextNodeType:"paragraph"}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:t}){return["hr",Ho(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!function(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof ae){const t=r.index();return r.parent.canReplaceWith(t,t+1,e)}let i=r.depth;for(;i>=0;){const t=r.index(i);if(r.node(i).contentMatchAt(t).matchType(e))return!0;i-=1}return!1}(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return nl(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command((({state:t,tr:e,dispatch:n})=>{if(n){const{$to:n}=e.selection,r=n.end();if(n.nodeAfter)e.setSelection(n.nodeAfter.isTextblock?le.create(e.doc,n.pos+1):n.nodeAfter.isBlock?ae.create(e.doc,n.pos):le.create(e.doc,n.pos));else{const i=t.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType,s=null==i?void 0:i.create();s&&(e.insert(r,s),e.setSelection(le.create(e.doc,r+1)))}e.scrollIntoView()}return!0})).run()}}},addInputRules(){return[eu({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),rc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,ic=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,sc=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,oc=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,lc=Il.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>"normal"!==t.style.fontStyle&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Ho(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[tu({find:rc,type:this.type}),tu({find:sc,type:this.type})]},addPasteRules(){return[gu({find:ic,type:this.type}),gu({find:oc,type:this.type})]}});const uc="numeric",ac="ascii",hc="alpha",cc="asciinumeric",fc="alphanumeric",dc="domain",pc="emoji",mc="scheme",gc="slashscheme",wc="whitespace";function bc(t,e){return t in e||(e[t]=[]),e[t]}function yc(t,e,n){e[uc]&&(e[cc]=!0,e[fc]=!0),e[ac]&&(e[cc]=!0,e[hc]=!0),e[cc]&&(e[fc]=!0),e[hc]&&(e[fc]=!0),e[fc]&&(e[dc]=!0),e[pc]&&(e[dc]=!0);for(const r in e){const e=bc(r,n);e.indexOf(t)<0&&e.push(t)}}function vc(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}vc.groups={},vc.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let n=0;n<e.jr.length;n++){const r=e.jr[n][1];if(r&&e.jr[n][0].test(t))return r}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){let i;return r=r||vc.groups,e&&e.j?i=e:(i=new vc(e),n&&r&&yc(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let e=0;e<s-1;e++)i=i.tt(t[e]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||vc.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let o,l=i.go(t);if(l?(o=new vc,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new vc,s){if(r)if(o.t&&"string"==typeof o.t){const t=Object.assign(function(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}(o.t,r),n);yc(s,t,r)}else n&&yc(s,n,r);o.t=s}return i.j[t]=o,o}};const kc=(t,e,n,r,i)=>t.ta(e,n,r,i),Mc=(t,e,n,r,i)=>t.tr(e,n,r,i),Tc=(t,e,n,r,i)=>t.ts(e,n,r,i),xc=(t,e,n,r,i)=>t.tt(e,n,r,i),Lc="WORD",Sc="UWORD",Ac="ASCIINUMERICAL",Ec="ALPHANUMERICAL",Oc="LOCALHOST",$c="TLD",Cc="UTLD",Rc="SCHEME",Hc="SLASH_SCHEME",Nc="NUM",Ic="WS",Pc="NL",Dc="OPENBRACE",Bc="CLOSEBRACE",jc="OPENBRACKET",zc="CLOSEBRACKET",_c="OPENPAREN",Fc="CLOSEPAREN",Wc="OPENANGLEBRACKET",Kc="CLOSEANGLEBRACKET",Uc="FULLWIDTHLEFTPAREN",Jc="FULLWIDTHRIGHTPAREN",qc="LEFTCORNERBRACKET",Vc="RIGHTCORNERBRACKET",Gc="LEFTWHITECORNERBRACKET",Xc="RIGHTWHITECORNERBRACKET",Qc="FULLWIDTHLESSTHAN",Zc="FULLWIDTHGREATERTHAN",Yc="AMPERSAND",tf="APOSTROPHE",ef="ASTERISK",nf="AT",rf="BACKSLASH",sf="BACKTICK",of="CARET",lf="COLON",uf="COMMA",af="DOLLAR",hf="DOT",cf="EQUALS",ff="EXCLAMATION",df="HYPHEN",pf="PERCENT",mf="PIPE",gf="PLUS",wf="POUND",bf="QUERY",yf="QUOTE",vf="FULLWIDTHMIDDLEDOT",kf="SEMI",Mf="SLASH",Tf="TILDE",xf="UNDERSCORE",Lf="EMOJI",Sf="SYM";var Af=Object.freeze({__proto__:null,ALPHANUMERICAL:Ec,AMPERSAND:Yc,APOSTROPHE:tf,ASCIINUMERICAL:Ac,ASTERISK:ef,AT:nf,BACKSLASH:rf,BACKTICK:sf,CARET:of,CLOSEANGLEBRACKET:Kc,CLOSEBRACE:Bc,CLOSEBRACKET:zc,CLOSEPAREN:Fc,COLON:lf,COMMA:uf,DOLLAR:af,DOT:hf,EMOJI:Lf,EQUALS:cf,EXCLAMATION:ff,FULLWIDTHGREATERTHAN:Zc,FULLWIDTHLEFTPAREN:Uc,FULLWIDTHLESSTHAN:Qc,FULLWIDTHMIDDLEDOT:vf,FULLWIDTHRIGHTPAREN:Jc,HYPHEN:df,LEFTCORNERBRACKET:qc,LEFTWHITECORNERBRACKET:Gc,LOCALHOST:Oc,NL:Pc,NUM:Nc,OPENANGLEBRACKET:Wc,OPENBRACE:Dc,OPENBRACKET:jc,OPENPAREN:_c,PERCENT:pf,PIPE:mf,PLUS:gf,POUND:wf,QUERY:bf,QUOTE:yf,RIGHTCORNERBRACKET:Vc,RIGHTWHITECORNERBRACKET:Xc,SCHEME:Rc,SEMI:kf,SLASH:Mf,SLASH_SCHEME:Hc,SYM:Sf,TILDE:Tf,TLD:$c,UNDERSCORE:xf,UTLD:Cc,UWORD:Sc,WORD:Lc,WS:Ic});const Ef=/[a-z]/,Of=/\p{L}/u,$f=/\p{Emoji}/u,Cf=/\d/,Rf=/\s/;let Hf=null,Nf=null;function If(t,e){const n=function(t){const e=[],n=t.length;let r=0;for(;r<n;){let i,s=t.charCodeAt(r),o=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}(e.replace(/[A-Z]/g,(t=>t.toLowerCase()))),r=n.length,i=[];let s=0,o=0;for(;o<r;){let l=t,u=null,a=0,h=null,c=-1,f=-1;for(;o<r&&(u=l.go(n[o]));)l=u,l.accepts()?(c=0,f=0,h=l):c>=0&&(c+=n[o].length,f++),a+=n[o].length,s+=n[o].length,o++;s-=c,o-=f,a-=c,i.push({t:h.t,v:e.slice(s-a,s),s:s-a,e:s})}return i}function Pf(t,e,n,r,i){let s;const o=e.length;for(let n=0;n<o-1;n++){const o=e[n];t.j[o]?s=t.j[o]:(s=new vc(r),s.jr=i.slice(),t.j[o]=s),t=s}return s=new vc(n),s.jr=i.slice(),t.j[e[o-1]]=s,s}function Df(t){const e=[],n=[];let r=0;for(;r<t.length;){let i=0;for(;"0123456789".indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let e=parseInt(t.substring(r,r+i),10);e>0;e--)n.pop();r+=i}else n.push(t[r]),r++}return e}const Bf={defaultProtocol:"http",events:null,format:zf,formatHref:zf,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function jf(t,e=null){let n=Object.assign({},Bf);t&&(n=Object.assign(n,t instanceof jf?t.o:t));const r=n.ignoreTags,i=[];for(let t=0;t<r.length;t++)i.push(r[t].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}function zf(t){return t}function _f(t,e){this.t="token",this.v=t,this.tk=e}function Ff(t,e){class n extends _f{constructor(e,n){super(e,n),this.t=t}}for(const t in e)n.prototype[t]=e[t];return n.t=t,n}jf.prototype={o:Bf,ignoreTags:[],defaultRender:t=>t,check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=null!=e;let i=this.o[t];return i?("object"==typeof i?(i=n.t in i?i[n.t]:Bf[t],"function"==typeof i&&r&&(i=i(e,n))):"function"==typeof i&&r&&(i=i(e,n.t,n)),i):i},getObj(t,e,n){let r=this.o[t];return"function"==typeof r&&null!=e&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}},_f.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Bf.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),s=this.toFormattedString(t),o={},l=t.get("className",n,e),u=t.get("target",n,e),a=t.get("rel",n,e),h=t.getObj("attributes",n,e),c=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),u&&(o.target=u),a&&(o.rel=a),h&&Object.assign(o,h),{tagName:i,attributes:o,content:s,eventListeners:c}}};const Wf=Ff("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Kf=Ff("text"),Uf=Ff("nl"),Jf=Ff("url",{isLink:!0,toHref(t=Bf.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Oc&&t[1].t===lf}}),qf=t=>new vc(t);function Vf(t,e,n){return new t(e.slice(n[0].s,n[n.length-1].e),n)}const Gf="undefined"!=typeof console&&console&&console.warn||(()=>{}),Xf={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Qf(t,e=!1){if(Xf.initialized&&Gf(`linkifyjs: already initialized - will not register custom scheme "${t}" until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error('linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or "-"\n2. Cannot start or end with "-"\n3. "-" cannot repeat');Xf.customSchemes.push([t,e])}function Zf(t){return Xf.initialized||function(){Xf.scanner=function(t=[]){const e={};vc.groups=e;const n=new vc;null==Hf&&(Hf=Df("aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2")),null==Nf&&(Nf=Df("ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2")),xc(n,"'",tf),xc(n,"{",Dc),xc(n,"}",Bc),xc(n,"[",jc),xc(n,"]",zc),xc(n,"(",_c),xc(n,")",Fc),xc(n,"<",Wc),xc(n,">",Kc),xc(n,"(",Uc),xc(n,")",Jc),xc(n,"「",qc),xc(n,"」",Vc),xc(n,"『",Gc),xc(n,"』",Xc),xc(n,"<",Qc),xc(n,">",Zc),xc(n,"&",Yc),xc(n,"*",ef),xc(n,"@",nf),xc(n,"`",sf),xc(n,"^",of),xc(n,":",lf),xc(n,",",uf),xc(n,"$",af),xc(n,".",hf),xc(n,"=",cf),xc(n,"!",ff),xc(n,"-",df),xc(n,"%",pf),xc(n,"|",mf),xc(n,"+",gf),xc(n,"#",wf),xc(n,"?",bf),xc(n,'"',yf),xc(n,"/",Mf),xc(n,";",kf),xc(n,"~",Tf),xc(n,"_",xf),xc(n,"\\",rf),xc(n,"・",vf);const r=Mc(n,Cf,Nc,{[uc]:!0});Mc(r,Cf,r);const i=Mc(r,Ef,Ac,{[cc]:!0}),s=Mc(r,Of,Ec,{[fc]:!0}),o=Mc(n,Ef,Lc,{[ac]:!0});Mc(o,Cf,i),Mc(o,Ef,o),Mc(i,Cf,i),Mc(i,Ef,i);const l=Mc(n,Of,Sc,{[hc]:!0});Mc(l,Ef),Mc(l,Cf,s),Mc(l,Of,l),Mc(s,Cf,s),Mc(s,Ef),Mc(s,Of,s);const u=xc(n,"\n",Pc,{[wc]:!0}),a=xc(n,"\r",Ic,{[wc]:!0}),h=Mc(n,Rf,Ic,{[wc]:!0});xc(n,"",h),xc(a,"\n",u),xc(a,"",h),Mc(a,Rf,h),xc(h,"\r"),xc(h,"\n"),Mc(h,Rf,h),xc(h,"",h);const c=Mc(n,$f,Lf,{[pc]:!0});xc(c,"#"),Mc(c,$f,c),xc(c,"️",c);const f=xc(c,"‍");xc(f,"#"),Mc(f,$f,c);const d=[[Ef,o],[Cf,i]],p=[[Ef,null],[Of,l],[Cf,s]];for(let t=0;t<Hf.length;t++)Pf(n,Hf[t],$c,Lc,d);for(let t=0;t<Nf.length;t++)Pf(n,Nf[t],Cc,Sc,p);yc($c,{tld:!0,ascii:!0},e),yc(Cc,{utld:!0,alpha:!0},e),Pf(n,"file",Rc,Lc,d),Pf(n,"mailto",Rc,Lc,d),Pf(n,"http",Hc,Lc,d),Pf(n,"https",Hc,Lc,d),Pf(n,"ftp",Hc,Lc,d),Pf(n,"ftps",Hc,Lc,d),yc(Rc,{scheme:!0,ascii:!0},e),yc(Hc,{slashscheme:!0,ascii:!0},e),t=t.sort(((t,e)=>t[0]>e[0]?1:-1));for(let e=0;e<t.length;e++){const r=t[e][0],i=t[e][1]?{[mc]:!0}:{[gc]:!0};r.indexOf("-")>=0?i[dc]=!0:Ef.test(r)?Cf.test(r)?i[cc]=!0:i[ac]=!0:i[uc]=!0,Tc(n,r,r,i)}return Tc(n,"localhost",Oc,{ascii:!0}),n.jd=new vc(Sf),{start:n,tokens:Object.assign({groups:e},Af)}}(Xf.customSchemes);for(let t=0;t<Xf.tokenQueue.length;t++)Xf.tokenQueue[t][1]({scanner:Xf.scanner});Xf.parser=function({groups:t}){const e=t.domain.concat([Yc,ef,nf,rf,sf,of,af,cf,df,Nc,pf,mf,gf,wf,Mf,Sf,Tf,xf]),n=[tf,lf,uf,hf,ff,pf,bf,yf,kf,Wc,Kc,Dc,Bc,zc,jc,_c,Fc,Uc,Jc,qc,Vc,Gc,Xc,Qc,Zc],r=[Yc,tf,ef,rf,sf,of,af,cf,df,Dc,Bc,pf,mf,gf,wf,bf,Mf,Sf,Tf,xf],i=qf(),s=xc(i,Tf);kc(s,r,s),kc(s,t.domain,s);const o=qf(),l=qf(),u=qf();kc(i,t.domain,o),kc(i,t.scheme,l),kc(i,t.slashscheme,u),kc(o,r,s),kc(o,t.domain,o);const a=xc(o,nf);xc(s,nf,a),xc(l,nf,a),xc(u,nf,a);const h=xc(s,hf);kc(h,r,s),kc(h,t.domain,s);const c=qf();kc(a,t.domain,c),kc(c,t.domain,c);const f=xc(c,hf);kc(f,t.domain,c);const d=qf(Wf);kc(f,t.tld,d),kc(f,t.utld,d),xc(a,Oc,d);const p=xc(c,df);xc(p,df,p),kc(p,t.domain,c),kc(d,t.domain,c),xc(d,hf,f),xc(d,df,p);const m=xc(o,df),g=xc(o,hf);xc(m,df,m),kc(m,t.domain,o),kc(g,r,s),kc(g,t.domain,o);const w=qf(Jf);kc(g,t.tld,w),kc(g,t.utld,w),kc(w,t.domain,o),kc(w,r,s),xc(w,hf,g),xc(w,df,m),xc(w,nf,a);const b=xc(w,lf),y=qf(Jf);kc(b,t.numeric,y);const v=qf(Jf),k=qf();kc(v,e,v),kc(v,n,k),kc(k,e,v),kc(k,n,k),xc(w,Mf,v),xc(y,Mf,v);const M=xc(l,lf),T=xc(u,lf),x=xc(T,Mf),L=xc(x,Mf);kc(l,t.domain,o),xc(l,hf,g),xc(l,df,m),kc(u,t.domain,o),xc(u,hf,g),xc(u,df,m),kc(M,t.domain,v),xc(M,Mf,v),xc(M,bf,v),kc(L,t.domain,v),kc(L,e,v),xc(L,Mf,v);const S=[[Dc,Bc],[jc,zc],[_c,Fc],[Wc,Kc],[Uc,Jc],[qc,Vc],[Gc,Xc],[Qc,Zc]];for(let t=0;t<S.length;t++){const[r,i]=S[t],s=xc(v,r);xc(k,r,s);const o=qf(Jf);kc(s,e,o);const l=qf();kc(s,n,l),xc(s,i,v),kc(o,e,o),kc(o,n,l),kc(l,e,o),kc(l,n,l),xc(o,i,v),xc(l,i,v)}return xc(i,Oc,w),xc(i,Pc,Uf),{start:i,tokens:Af}}(Xf.scanner.tokens);for(let t=0;t<Xf.pluginQueue.length;t++)Xf.pluginQueue[t][1]({scanner:Xf.scanner,parser:Xf.parser});Xf.initialized=!0}(),function(t,e,n){let r=n.length,i=0,s=[],o=[];for(;i<r;){let l=t,u=null,a=null,h=0,c=null,f=-1;for(;i<r&&!(u=l.go(n[i].t));)o.push(n[i++]);for(;i<r&&(a=u||l.go(n[i].t));)u=null,l=a,l.accepts()?(f=0,c=l):f>=0&&f++,i++,h++;if(f<0)i-=h,i<r&&(o.push(n[i]),i++);else{o.length>0&&(s.push(Vf(Kf,e,o)),o=[]),i-=f,h-=f;const t=c.t,r=n.slice(i-h,i);s.push(Vf(t,e,r))}}return o.length>0&&s.push(Vf(Kf,e,o)),s}(Xf.parser.start,t,If(Xf.scanner.start,t))}function Yf(t,e=null,n=null){if(e&&"object"==typeof e){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new jf(n),i=Zf(t),s=[];for(let t=0;t<i.length;t++){const n=i[t];!n.isLink||e&&n.t!==e||!r.check(n)||s.push(n.toFormattedObject(r))}return s}Zf.scan=If;var td="[\0-   ᠎ -\u2029  ]",ed=new RegExp(td),nd=new RegExp(`${td}$`),rd=new RegExp(td,"g");function id(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach((t=>{const e="string"==typeof t?t:t.scheme;e&&n.push(e)})),!t||t.replace(rd,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var sd=Il.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach((t=>{"string"!=typeof t?Qf(t.scheme,t.optionalSlashes):Qf(t)}))},onDestroy(){vc.groups={},Xf.scanner=null,Xf.parser=null,Xf.tokenQueue=[],Xf.pluginQueue=[],Xf.customSchemes=[],Xf.initialized=!1},inclusive(){return this.options.autolink},addOptions:()=>({openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!id(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const r=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!/^\d{1,3}(\.\d{1,3}){3}$/.test(r)&&!!/\./.test(r)}}),addAttributes(){return{href:{default:null,parseHTML:t=>t.getAttribute("href")},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!(!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!id(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:t=>!!id(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Ho(this.options.HTMLAttributes,t),0]:["a",Ho(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,i,s;const o=null!=(r=null==(n=t.attrs)?void 0:n.href)?r:"",l=null!=(s=null==(i=t.attrs)?void 0:i.title)?s:"",u=e.renderChildren(t);return l?`[${u}](${o} "${l}")`:`[${u}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return!!this.options.isAllowedUri(n,{defaultValidate:t=>!!id(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})&&e().setMark(this.name,t).setMeta("preventAutolink",!0).run()},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return!(n&&!this.options.isAllowedUri(n,{defaultValidate:t=>!!id(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[gu({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Yf(t).filter((t=>t.isLink&&this.options.isAllowedUri(t.value,{defaultValidate:t=>!!id(t,n),protocols:n,defaultProtocol:r})));i.length&&i.forEach((t=>{this.options.shouldAutoLink(t.value)&&e.push({text:t.value,data:{href:t.href},index:t.start})}))}return e},type:this.type,getAttributes:t=>{var e;return{href:null==(e=t.data)?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;var r;return this.options.autolink&&t.push((r={type:this.type,defaultProtocol:this.options.defaultProtocol,validate:t=>this.options.isAllowedUri(t,{defaultValidate:t=>!!id(t,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink},new Me({key:new Le("autolink"),appendTransaction:(t,e,n)=>{const i=t.some((t=>t.docChanged))&&!e.doc.eq(n.doc),s=t.some((t=>t.getMeta("preventAutolink")));if(!i||s)return;const{tr:o}=n;return Uo(Mo(e.doc,[...t])).forEach((({newRange:t})=>{const e=function(t,e){const n=[];return t.nodesBetween(e.from,e.to,((t,e)=>{(t=>t.isTextblock)(t)&&n.push({node:t,pos:e})})),n}(n.doc,t);let i,s;if(e.length>1)i=e[0],s=n.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0," ");else if(e.length){const r=n.doc.textBetween(t.from,t.to," "," ");if(!nd.test(r))return;i=e[0],s=n.doc.textBetween(i.pos,t.to,void 0," ")}if(i&&s){const t=s.split(ed).filter(Boolean);if(t.length<=0)return!1;const e=t[t.length-1],u=i.pos+s.lastIndexOf(e);if(!e)return!1;const a=Zf(e).map((t=>t.toObject(r.defaultProtocol)));if(!(1===(l=a).length?l[0].isLink:3===l.length&&l[1].isLink&&["()","[]"].includes(l[0].value+l[2].value)))return!1;a.filter((t=>t.isLink)).map((t=>({...t,from:u+t.start+1,to:u+t.end+1}))).filter((t=>!n.schema.marks.code||!n.doc.rangeHasMark(t.from,t.to,n.schema.marks.code))).filter((t=>r.validate(t.value))).filter((t=>r.shouldAutoLink(t.value))).forEach((t=>{Jo(t.from,t.to,n.doc).some((t=>t.mark.type===r.type))||o.addMark(t.from,t.to,r.type.create({href:t.href}))}))}var l})),o.steps.length?o:void 0}}))),t.push(function(t){return new Me({key:new Le("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(0!==r.button)return!1;if(!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const e=r.target;if(!e)return!1;const n=t.editor.view.dom;o=e.closest("a"),o&&!n.contains(o)&&(o=null)}if(!o)return!1;let l=!1;if(t.enableClickSelection&&(l=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const n=Ko(e.state,t.type.name),r=null!=(i=o.href)?i:n.href,u=null!=(s=o.target)?s:n.target;r&&(window.open(r,u),l=!0)}return l}}})}({type:this.type,editor:this.editor,openOnClick:"whenNotEditable"===this.options.openOnClick||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(function(t){return new Me({key:new Le("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:o}=s,{empty:l}=o;if(l)return!1;let u="";r.content.forEach((t=>{u+=t.textContent}));const a=Yf(u,{defaultProtocol:t.defaultProtocol}).find((t=>t.isLink&&t.value===u));return!(!u||!a||void 0!==i&&!i(a.value))&&t.editor.commands.setMark(t.type,{href:a.href})}}})}({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),od=Object.defineProperty,ld="textStyle",ud=/^\s*([-+*])\s$/,ad=mu.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:t}){return["ul",Ho(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>"list"!==t.type||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,"\n"):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(ld)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ru({find:ud,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ru({find:ud,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ld),editor:this.editor})),[t]}}),hd=(t,e)=>zl.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const n=()=>((t,e,n)=>((t,e,n,r)=>{const i=((t,e,n)=>{const{selection:r}=t;if(!r.empty)return null;const{$from:i}=r;if(!i.parent.isTextblock)return null;if(i.parentOffset!==i.parent.content.size)return null;let s=-1;for(let t=i.depth;t>0;t-=1)if(i.node(t).type.name===e){s=t;break}if(s<0)return null;const o=i.node(s),l=i.index(s);if(l+1>=o.childCount)return null;const u=o.child(l+1);if(!n.includes(u.type.name))return null;const a=t.schema.nodes[e];let h=!1;if(u.forEach((t=>{t.type===a&&t.childCount>1&&(h=!0)})),!h)return null;const c=t.doc.resolve(i.after()).nodeAfter;if(!c||!n.includes(c.type.name))return null;const f=[];return c.forEach((t=>{f.push(t)})),0===f.length?null:{listItemDepth:s,nestedList:c,nestedListPos:i.after(),insertPos:i.after(s),items:f}})(t,n,r);if(!i)return!1;const{selection:s}=t,{nestedList:o,nestedListPos:u,insertPos:a,items:h}=i,c=t.tr;c.delete(u,u+o.nodeSize);const f=c.mapping.map(a);return c.insert(f,l.from(h)),c.setSelection(s.map(c.doc,c.mapping)),e&&e(c),!0})(t.state,t.view.dispatch,e,n))(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}});function cd(t,e){return e.parseInline(e.tokenizeInline?e.tokenizeInline(t):[{type:"text",raw:t,text:t}])}var fd=mu.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Ho(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if("list_item"!==t.type)return[];const r=null!=(n=e.parseBlockChildren)?n:e.parseChildren;let i=[];if(t.tokens&&t.tokens.length>0){if(function(t){var e,n;const r=null==(e=t.tokens)?void 0:e[0];return Boolean(t.text&&1===(null==(n=t.tokens)?void 0:n.length)&&"list"===(null==r?void 0:r.type)&&r.ordered&&r.raw===t.text)}(t))return{type:"listItem",content:[{type:"paragraph",content:cd(t.text||"",e)}]};if(t.tokens.some((t=>"paragraph"===t.type)))i=r(t.tokens);else{const n=t.tokens[0];if(n&&"text"===n.type&&n.tokens&&n.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(n.tokens)}],t.tokens.length>1){const e=r(t.tokens.slice(1));i.push(...e)}}else i=r(t.tokens)}}return 0===i.length&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(t,e,n)=>pu(t,e,(t=>{var e,n;return"bulletList"===t.parentType?"- ":"orderedList"===t.parentType?`${((null==(n=null==(e=t.meta)?void 0:e.parentAttrs)?void 0:n.start)||1)+t.index}. `:"- "}),n),addExtensions(){return[hd(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});((t,e)=>{for(var n in e)od(t,n,{get:e[n],enumerable:!0})})({},{findListItemPos:()=>dd,getNextListDepth:()=>pd,handleBackspace:()=>gd,handleDelete:()=>yd,hasListBefore:()=>md,hasListItemAfter:()=>vd,hasListItemBefore:()=>kd,listItemHasSubList:()=>Md,nextListIsDeeper:()=>wd,nextListIsHigher:()=>bd});var dd=(t,e)=>{const{$from:n}=e.selection,r=vs(t,e.schema);let i=null,s=n.depth,o=n.pos,l=null;for(;s>0&&null===l;)i=n.node(s),i.type===r?l=s:(s-=1,o-=1);return null===l?null:{$pos:e.doc.resolve(o),depth:l}},pd=(t,e)=>{const n=dd(t,e);if(!n)return!1;const[,r]=qo(e,t,n.$pos.pos+4);return r},md=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),s=t.doc.resolve(i).node();return!(!s||!n.includes(s.type.name))},gd=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ro(t.state,e)&&md(t.state,e,n)){const{$anchor:n}=t.state.selection,r=t.state.doc.resolve(n.before()-1),i=[];r.node().descendants(((t,n)=>{t.type.name===e&&i.push({node:t,pos:n})}));const s=i.at(-1);if(!s)return!1;const o=t.state.doc.resolve(r.start()+s.pos+1);return t.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}return!!ro(t.state,e)&&!!Zo(t.state)&&t.chain().liftListItem(e).run()},wd=(t,e)=>{const n=pd(t,e),r=dd(t,e);return!(!r||!n)&&n>r.depth},bd=(t,e)=>{const n=pd(t,e),r=dd(t,e);return!(!r||!n)&&n<r.depth},yd=(t,e)=>{if(!ro(t.state,e))return!1;if(!Qo(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!(!n.empty&&r.sameParent(i))&&(wd(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():bd(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward())},vd=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return i.index()!==i.parent.childCount-1&&(null==(n=i.nodeAfter)?void 0:n.type.name)===t},kd=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return 0!==i.index()&&(null==(n=i.nodeBefore)?void 0:n.type.name)===t},Md=(t,e,n)=>{if(!n)return!1;const r=vs(t,e.schema);let i=!1;return n.descendants((t=>{t.type===r&&(i=!0)})),i},Td=zl.create({name:"listKeymap",addOptions:()=>({listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}),addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach((({itemName:n})=>{void 0!==t.state.schema.nodes[n]&&yd(t,n)&&(e=!0)})),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach((({itemName:n})=>{void 0!==t.state.schema.nodes[n]&&yd(t,n)&&(e=!0)})),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach((({itemName:n,wrapperNames:r})=>{void 0!==t.state.schema.nodes[n]&&gd(t,n,r)&&(e=!0)})),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach((({itemName:n,wrapperNames:r})=>{void 0!==t.state.schema.nodes[n]&&gd(t,n,r)&&(e=!0)})),e}}}}),xd=/^(\s*)(\d+)\.\s+(.*)$/,Ld=/^\s/;function Sd(t){const e=[],n=[];let r=!1;return t.forEach((t=>{if(!r)return""===t.trim()||e.length>0&&function(t){const e=t.trimStart();return/^[-+*]\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)||/^~~~/.test(e)}(t)?(r=!0,void n.push(t)):void e.push(t);n.push(t)})),{paragraphLines:e,blockLines:n}}function Ad(t,e,n){const r=[];let i=0;for(;i<t.length;){const s=t[i];if(s.indent===e){const{paragraphLines:o,blockLines:l}=Sd(s.contentLines),u=o.join("\n").trim(),a=[];u&&a.push({type:"paragraph",raw:u,tokens:n.inlineTokens(u)});const h=l.join("\n").trim();if(h){const t=n.blockTokens(h);a.push(...t)}let c=i+1;const f=[];for(;c<t.length&&t[c].indent>e;)f.push(t[c]),c+=1;if(f.length>0){const t=Math.min(...f.map((t=>t.indent))),e=Ad(f,t,n);a.push({type:"list",ordered:!0,start:f[0].number,items:e,raw:f.map((t=>t.raw)).join("\n")})}r.push({type:"list_item",raw:s.raw,tokens:a}),i=c}else i+=1}return r}var Ed="textStyle",Od=/^(\d+)\.\s$/,$d=mu.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return 1===e?["ol",Ho(this.options.HTMLAttributes,n),0]:["ol",Ho(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if("list"!==t.type||!t.ordered)return[];const n=t.start||1,r=t.items?function(t,e){return t.map((t=>{if("list_item"!==t.type)return e.parseChildren([t])[0];const n=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach((t=>{if("paragraph"===t.type||"list"===t.type||"blockquote"===t.type||"code"===t.type)n.push(...e.parseChildren([t]));else if("text"===t.type&&t.tokens){const r=e.parseChildren([t]);n.push({type:"paragraph",content:r})}else{const r=e.parseChildren([t]);r.length>0&&n.push(...r)}})),{type:"listItem",content:n}}))}(t.items,e):[];return 1!==n?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,"\n"):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=null==e?void 0:e.index;return void 0!==n?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split("\n"),[s,o]=function(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(xd);if(!s)break;const[,o,l,u]=s,a=o.length,h=[u];let c=n+1;const f=[i];let d=!1;for(;c<t.length;){const e=t[c];if(e.match(xd))break;if(""===e.trim())f.push(e),h.push(""),d=!0,c+=1;else if(e.match(Ld))f.push(e),h.push(e.slice(a+2)),c+=1;else{if(d)break;f.push(e),h.push(e),c+=1}}e.push({indent:a,number:parseInt(l,10),content:h.join("\n").trim(),contentLines:h,raw:f.join("\n")}),r=c,n=c}return[e,r]}(i);if(0===s.length)return;const l=Ad(s,0,n);return 0!==l.length?{type:"list",ordered:!0,start:(null==(r=s[0])?void 0:r.number)||1,items:l,raw:i.slice(0,o).join("\n")}:void 0}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(Ed)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=ru({find:Od,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ru({find:Od,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Ed)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})),[t]}}),Cd=/^\s*(\[([( |x])?\])\s$/,Rd=mu.create({name:"taskItem",addOptions:()=>({nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}),content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes:()=>({checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return""===e||"true"===e},renderHTML:t=>({"data-checked":t.checked})}}),parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Ho(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(n.push(e.createNode("paragraph",{},t.tokens&&t.tokens.length>0?e.parseInline(t.tokens):t.text?[e.createNode("text",{text:t.text})]:[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;return pu(t,e,`- [${(null==(n=t.attrs)?void 0:n.checked)?"x":" "}] `)},addExtensions(){return this.options.nested?[hd(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),u=document.createElement("div"),a=t=>{var e,n;l.ariaLabel=(null==(n=null==(e=this.options.a11y)?void 0:e.checkboxLabel)?void 0:n.call(e,t,l.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};a(t),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",(t=>t.preventDefault())),l.addEventListener("change",(e=>{if(!r.isEditable&&!this.options.onReadOnlyChecked)return void(l.checked=!l.checked);const{checked:i}=e.target;r.isEditable&&"function"==typeof n&&r.chain().focus(void 0,{scrollIntoView:!1}).command((({tr:t})=>{const e=n();if("number"!=typeof e)return!1;const r=t.doc.nodeAt(e);return t.setNodeMarkup(e,void 0,{...null==r?void 0:r.attrs,checked:i}),!0})).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,i)||(l.checked=!l.checked))})),Object.entries(this.options.HTMLAttributes).forEach((([t,e])=>{i.setAttribute(t,e)})),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,s.append(l,o),i.append(s,u),Object.entries(e).forEach((([t,e])=>{i.setAttribute(t,e)}));let h=new Set(Object.keys(e));return{dom:i,contentDOM:u,update:t=>{if(t.type!==this.type)return!1;i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,a(t);const e=No(t,r.extensionManager.attributes),n=new Set(Object.keys(e)),s=this.options.HTMLAttributes;return h.forEach((t=>{n.has(t)||(t in s?i.setAttribute(t,s[t]):i.removeAttribute(t))})),Object.entries(e).forEach((([t,e])=>{null==e?t in s?i.setAttribute(t,s[t]):i.removeAttribute(t):i.setAttribute(t,e)})),h=n,!0}}}},addInputRules(){return[ru({find:Cd,type:this.type,getAttributes:t=>({checked:"x"===t[t.length-1]})})]}}),Hd=mu.create({name:"taskList",addOptions:()=>({itemTypeName:"taskItem",HTMLAttributes:{}}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Ho(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,"\n"):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=null==(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))?void 0:e.index;return void 0!==n?n:-1},tokenize(t,e,n){const r=t=>{const e=du(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:t=>({indentLevel:t[1].length,mainContent:t[4],checked:"x"===t[3].toLowerCase()}),createToken:(t,e)=>({type:"taskItem",raw:"",mainContent:t.mainContent,indentLevel:t.indentLevel,checked:t.checked,text:t.mainContent,tokens:n.inlineTokens(t.mainContent),nestedTokens:e}),customNestedParser:r},n);return e?[{type:"taskList",raw:e.raw,items:e.items}]:n.blockTokens(t)},i=du(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:t=>({indentLevel:t[1].length,mainContent:t[4],checked:"x"===t[3].toLowerCase()}),createToken:(t,e)=>({type:"taskItem",raw:"",mainContent:t.mainContent,indentLevel:t.indentLevel,checked:t.checked,text:t.mainContent,tokens:n.inlineTokens(t.mainContent),nestedTokens:e}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});zl.create({name:"listKit",addExtensions(){const t=[];return!1!==this.options.bulletList&&t.push(ad.configure(this.options.bulletList)),!1!==this.options.listItem&&t.push(fd.configure(this.options.listItem)),!1!==this.options.listKeymap&&t.push(Td.configure(this.options.listKeymap)),!1!==this.options.orderedList&&t.push($d.configure(this.options.orderedList)),!1!==this.options.taskItem&&t.push(Rd.configure(this.options.taskItem)),!1!==this.options.taskList&&t.push(Hd.configure(this.options.taskList)),t}});var Nd="&nbsp;",Id=mu.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",Ho(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(1===n.length&&"image"===n[0].type)return e.parseChildren([n[0]]);const r=e.parseInline(n);return e.createNode("paragraph",void 0,1!==n.length||"text"!==n[0].type||n[0].raw!==Nd&&n[0].text!==Nd&&" "!==n[0].raw&&" "!==n[0].text||1!==r.length||"text"!==r[0].type||r[0].text!==Nd&&" "!==r[0].text?r:[])},renderMarkdown:(t,e,n)=>{var r,i;if(!t)return"";const s=Array.isArray(t.content)?t.content:[];if(0===s.length){const t=Array.isArray(null==(r=null==n?void 0:n.previousNode)?void 0:r.content)?n.previousNode.content:[];return"paragraph"===(null==(i=null==n?void 0:n.previousNode)?void 0:i.type)&&0===t.length?Nd:""}return e.renderChildren(s)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Pd=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Dd=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Bd=Il.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>!!t.includes("line-through")&&{}}],renderHTML({HTMLAttributes:t}){return["s",Ho(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[tu({find:Pd,type:this.type})]},addPasteRules(){return[gu({find:Dd,type:this.type})]}}),jd=mu.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),zd=Il.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>!!t.includes("underline")&&{}}],renderHTML({HTMLAttributes:t}){return["u",Ho(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown:(t,e)=>`++${e.renderChildren(t)}++`,markdownTokenizer:{name:"underline",level:"inline",start:t=>t.indexOf("++"),tokenize(t,e,n){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!r)return;const i=r[2].trim();return{type:"underline",raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function _d(t={}){return new Me({view:e=>new Fd(e,t)})}class Fd{constructor(t,e){var n;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=e.width)&&void 0!==n?n:1,this.color=!1===e.color?void 0:e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let n=t=>{this[e](t)};return t.dom.addEventListener(e,n),{name:e,handler:n}}))}destroy(){this.handlers.forEach((({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e)))}update(t,e){null!=this.cursorPos&&e.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,null==t?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t,e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r=this.editorView.dom,i=r.getBoundingClientRect(),s=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(n){let n=e.nodeBefore,r=e.nodeAfter;if(n||r){let e=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(e){let i=e.getBoundingClientRect(),s=n?i.bottom:i.top;n&&r&&(s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let l=this.width/2*o;t={left:i.left,right:i.right,top:s-l,bottom:s+l}}}}if(!t){let e=this.editorView.coordsAtPos(this.cursorPos),n=this.width/2*s;t={left:e.left-n,right:e.left+n,top:e.top,bottom:e.bottom}}let l,u,a=this.editorView.dom.offsetParent;if(this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!a||a==document.body&&"static"==getComputedStyle(a).position)l=-pageXOffset,u=-pageYOffset;else{let t=a.getBoundingClientRect();l=t.left-a.scrollLeft*(t.width/a.offsetWidth),u=t.top-a.scrollTop*(t.height/a.offsetHeight)}this.element.style.left=(t.left-l)/s+"px",this.element.style.top=(t.top-u)/o+"px",this.element.style.width=(t.right-t.left)/s+"px",this.element.style.height=(t.bottom-t.top)/o+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),n=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,e,t):r;if(e&&!i){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=_t(this.editorView.state.doc,t,this.editorView.dragging.slice);null!=e&&(t=e)}this.setCursor(t),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}class Wd extends re{constructor(t){super(t,t)}map(t,e){let n=t.resolve(e.map(this.head));return Wd.valid(n)?new Wd(n):re.near(n)}content(){return d.empty}eq(t){return t instanceof Wd&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new Wd(t.resolve(e.pos))}getBookmark(){return new Kd(this.anchor)}static valid(t){let e=t.parent;if(e.inlineContent||!function(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(0!=n)for(let t=r.child(n-1);;t=t.lastChild){if(0==t.childCount&&!t.inlineContent||Ud(t.type))return!0;if(t.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(t)||!function(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n!=r.childCount)for(let t=r.child(n);;t=t.firstChild){if(0==t.childCount&&!t.inlineContent||Ud(t.type))return!0;if(t.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(t))return!1;let n=e.type.spec.allowGapCursor;if(null!=n)return n;let r=e.contentMatchAt(t.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,e,n=!1){t:for(;;){if(!n&&Wd.valid(t))return t;let r=t.pos,i=null;for(let n=t.depth;;n--){let s=t.node(n);if(e>0?t.indexAfter(n)<s.childCount:t.index(n)>0){i=s.child(e>0?t.indexAfter(n):t.index(n)-1);break}if(0==n)return null;r+=e;let o=t.doc.resolve(r);if(Wd.valid(o))return o}for(;;){let s=e>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!ae.isSelectable(i)){t=t.doc.resolve(r+i.nodeSize*e),n=!1;continue t}break}i=s,r+=e;let o=t.doc.resolve(r);if(Wd.valid(o))return o}return null}}}Wd.prototype.visible=!1,Wd.findFrom=Wd.findGapCursorFrom,re.jsonID("gapcursor",Wd);class Kd{constructor(t){this.pos=t}map(t){return new Kd(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return Wd.valid(e)?new Wd(e):re.near(e)}}function Ud(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}const Jd=ls({ArrowLeft:qd("horiz",-1),ArrowRight:qd("horiz",1),ArrowUp:qd("vert",-1),ArrowDown:qd("vert",1)});function qd(t,e){const n="vert"==t?e>0?"down":"up":e>0?"right":"left";return function(t,r,i){let s=t.selection,o=e>0?s.$to:s.$from,l=s.empty;if(s instanceof le){if(!i.endOfTextblock(n)||0==o.depth)return!1;l=!1,o=t.doc.resolve(e>0?o.after():o.before())}let u=Wd.findGapCursorFrom(o,e,l);return!!u&&(r&&r(t.tr.setSelection(new Wd(u))),!0)}}function Vd(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Wd.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&ae.isSelectable(t.state.doc.nodeAt(i.inside))||(t.dispatch(t.state.tr.setSelection(new Wd(r))),0))}function Gd(t,e){if("insertCompositionText"!=e.inputType||!(t.state.selection instanceof Wd))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=l.empty;for(let t=r.length-1;t>=0;t--)i=l.from(r[t].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new d(i,0,0));return s.setSelection(le.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function Xd(t){if(!(t.selection instanceof Wd))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",vi.create(t.doc,[wi.widget(t.selection.head,e,{key:"gapcursor"})])}var Qd=200,Zd=function(){};Zd.prototype.append=function(t){return t.length?(t=Zd.from(t),!this.length&&t||t.length<Qd&&this.leafAppend(t)||this.length<Qd&&t.leafPrepend(this)||this.appendInner(t)):this},Zd.prototype.prepend=function(t){return t.length?Zd.from(t).append(this):this},Zd.prototype.appendInner=function(t){return new tp(this,t)},Zd.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.length),t>=e?Zd.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))},Zd.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)},Zd.prototype.forEach=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)},Zd.prototype.map=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=this.length);var r=[];return this.forEach((function(e,n){return r.push(t(e,n))}),e,n),r},Zd.from=function(t){return t instanceof Zd?t:t&&t.length?new Yd(t):Zd.empty};var Yd=function(t){function e(e){t.call(this),this.values=e}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(t,n){return 0==t&&n==this.length?this:new e(this.values.slice(t,n))},e.prototype.getInner=function(t){return this.values[t]},e.prototype.forEachInner=function(t,e,n,r){for(var i=e;i<n;i++)if(!1===t(this.values[i],r+i))return!1},e.prototype.forEachInvertedInner=function(t,e,n,r){for(var i=e-1;i>=n;i--)if(!1===t(this.values[i],r+i))return!1},e.prototype.leafAppend=function(t){if(this.length+t.length<=Qd)return new e(this.values.concat(t.flatten()))},e.prototype.leafPrepend=function(t){if(this.length+t.length<=Qd)return new e(t.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(Zd);Zd.empty=new Yd([]);var tp=function(t){function e(e,n){t.call(this),this.left=e,this.right=n,this.length=e.length+n.length,this.depth=Math.max(e.depth,n.depth)+1}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,e,n,r){var i=this.left.length;return!(e<i&&!1===this.left.forEachInner(t,e,Math.min(n,i),r))&&!(n>i&&!1===this.right.forEachInner(t,Math.max(e-i,0),Math.min(this.length,n)-i,r+i))&&void 0},e.prototype.forEachInvertedInner=function(t,e,n,r){var i=this.left.length;return!(e>i&&!1===this.right.forEachInvertedInner(t,e-i,Math.max(n,i)-i,r+i))&&!(n<i&&!1===this.left.forEachInvertedInner(t,Math.min(e,i),n,r))&&void 0},e.prototype.sliceInner=function(t,e){if(0==t&&e==this.length)return this;var n=this.left.length;return e<=n?this.left.slice(t,e):t>=n?this.right.slice(t-n,e-n):this.left.slice(t,n).append(this.right.slice(0,e-n))},e.prototype.leafAppend=function(t){var n=this.right.leafAppend(t);if(n)return new e(this.left,n)},e.prototype.leafPrepend=function(t){var n=this.left.leafPrepend(t);if(n)return new e(n,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e}(Zd);class ep{constructor(t,e){this.items=t,this.eventCount=e}popEvent(t,e){if(0==this.eventCount)return null;let n,r,i=this.items.length;for(;;i--)if(this.items.get(i-1).selection){--i;break}e&&(n=this.remapping(i,this.items.length),r=n.maps.length);let s,o,l=t.tr,u=[],a=[];return this.items.forEach(((t,e)=>{if(!t.step)return n||(n=this.remapping(i,e+1),r=n.maps.length),r--,void a.push(t);if(n){a.push(new np(t.map));let e,i=t.step.map(n.slice(r));i&&l.maybeStep(i).doc&&(e=l.mapping.maps[l.mapping.maps.length-1],u.push(new np(e,void 0,void 0,u.length+a.length))),r--,e&&n.appendMap(e,r)}else l.maybeStep(t.step);return t.selection?(s=n?t.selection.map(n.slice(r)):t.selection,o=new ep(this.items.slice(0,i).append(a.reverse().concat(u)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:l,selection:s}}addTransform(t,e,n,r){let i=[],s=this.eventCount,o=this.items,l=!r&&o.length?o.get(o.length-1):null;for(let n=0;n<t.steps.length;n++){let u,a=t.steps[n].invert(t.docs[n]),h=new np(t.mapping.maps[n],a,e);(u=l&&l.merge(h))&&(h=u,n?i.pop():o=o.slice(0,o.length-1)),i.push(h),e&&(s++,e=void 0),r||(l=h)}let u=s-n.depth;return u>ip&&(o=function(t,e){let n;return t.forEach(((t,r)=>{if(t.selection&&0==e--)return n=r,!1})),t.slice(n)}(o,u),s-=u),new ep(o.append(i),s)}remapping(t,e){let n=new bt;return this.items.forEach(((e,r)=>{n.appendMap(e.map,null!=e.mirrorOffset&&r-e.mirrorOffset>=t?n.maps.length-e.mirrorOffset:void 0)}),t,e),n}addMaps(t){return 0==this.eventCount?this:new ep(this.items.append(t.map((t=>new np(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-e),i=t.mapping,s=t.steps.length,o=this.eventCount;this.items.forEach((t=>{t.selection&&o--}),r);let l=e;this.items.forEach((e=>{let r=i.getMirror(--l);if(null==r)return;s=Math.min(s,r);let u=i.maps[r];if(e.step){let s=t.steps[r].invert(t.docs[r]),a=e.selection&&e.selection.map(i.slice(l+1,r));a&&o++,n.push(new np(u,s,a))}else n.push(new np(u))}),r);let u=[];for(let t=e;t<s;t++)u.push(new np(i.maps[t]));let a=this.items.slice(0,r).append(u).append(n),h=new ep(a,o);return h.emptyItemCount()>500&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let t=0;return this.items.forEach((e=>{e.step||t++})),t}compress(t=this.items.length){let e=this.remapping(0,t),n=e.maps.length,r=[],i=0;return this.items.forEach(((s,o)=>{if(o>=t)r.push(s),s.selection&&i++;else if(s.step){let t=s.step.map(e.slice(n)),o=t&&t.getMap();if(n--,o&&e.appendMap(o,n),t){let l=s.selection&&s.selection.map(e.slice(n));l&&i++;let u,a=new np(o.invert(),t,l),h=r.length-1;(u=r.length&&r[h].merge(a))?r[h]=u:r.push(a)}}else s.map&&n--}),this.items.length,0),new ep(Zd.from(r.reverse()),i)}}ep.empty=new ep(Zd.empty,0);class np{constructor(t,e,n,r){this.map=t,this.step=e,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new np(e.getMap().invert(),e,this.selection)}}}class rp{constructor(t,e,n,r,i){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}}const ip=20;function sp(t){let e=[];for(let n=t.length-1;n>=0&&0==e.length;n--)t[n].forEach(((t,n,r,i)=>e.push(r,i)));return e}function op(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}let lp=!1,up=null;function ap(t){let e=t.plugins;if(up!=e){lp=!1,up=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){lp=!0;break}}return lp}const hp=new Le("history"),cp=new Le("closeHistory");function fp(t={}){return new Me({key:hp,state:{init:()=>new rp(ep.empty,ep.empty,null,0,-1),apply:(e,n,r)=>function(t,e,n,r){let i,s=n.getMeta(hp);if(s)return s.historyState;n.getMeta(cp)&&(t=new rp(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(0==n.steps.length)return t;if(o&&o.getMeta(hp))return o.getMeta(hp).redo?new rp(t.done.addTransform(n,void 0,r,ap(e)),t.undone,sp(n.mapping.maps),t.prevTime,t.prevComposition):new rp(t.done,t.undone.addTransform(n,void 0,r,ap(e)),null,t.prevTime,t.prevComposition);if(!1===n.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(i=n.getMeta("rebased"))?new rp(t.done.rebased(n,i),t.undone.rebased(n,i),op(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new rp(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),op(t.prevRanges,n.mapping),t.prevTime,t.prevComposition);{let i=n.getMeta("composition"),s=0==t.prevTime||!o&&t.prevComposition!=i&&(t.prevTime<(n.time||0)-r.newGroupDelay||!function(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach(((t,r)=>{for(let i=0;i<e.length;i+=2)t<=e[i+1]&&r>=e[i]&&(n=!0)})),n}(n,t.prevRanges)),l=o?op(t.prevRanges,n.mapping):sp(n.mapping.maps);return new rp(t.done.addTransform(n,s?e.selection.getBookmark():void 0,r,ap(e)),ep.empty,l,n.time,null==i?t.prevComposition:i)}}(n,r,e,t)},config:t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},props:{handleDOMEvents:{beforeinput(t,e){let n=e.inputType,r="historyUndo"==n?pp:"historyRedo"==n?mp:null;return!(!r||!t.editable)&&(e.preventDefault(),r(t.state,t.dispatch))}}}})}function dp(t,e){return(n,r)=>{let i=hp.getState(n);if(!i||0==(t?i.undone:i.done).eventCount)return!1;if(r){let s=function(t,e,n){let r=ap(e),i=hp.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),u=new rp(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(hp,{redo:n,historyState:u})}(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const pp=dp(!1,!0),mp=dp(!0,!0);var gp=zl.create({name:"characterCount",addOptions:()=>({limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter((t=>""!==t)).length}),addStorage:()=>({characters:()=>0,words:()=>0}),onBeforeCreate(){this.storage.characters=t=>{const e=(null==t?void 0:t.node)||this.editor.state.doc;if("textSize"===((null==t?void 0:t.mode)||this.options.mode)){const t=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(t)}return e.nodeSize},this.storage.words=t=>{const e=(null==t?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Me({key:new Le("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(null==i||0===i||!1===this.options.autoTrim)return void(t=!0);const s=this.storage.characters({node:r.doc});if(s>i){const e=0,n=s-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const o=r.tr.deleteRange(e,n);return t=!0,o}t=!0},filterTransaction:(t,e)=>{const n=this.options.limit;if(!t.docChanged||0===n||null==n)return!0;const r=this.storage.characters({node:e.doc}),i=this.storage.characters({node:t.doc});if(i<=n)return!0;if(r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r)return!1;if(!t.getMeta("paste"))return!1;const s=t.selection.$head.pos;return t.deleteRange(s-(i-n),s),!(this.storage.characters({node:t.doc})>n)}})]}}),wp=zl.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[_d(this.options)]}});zl.create({name:"focus",addOptions:()=>({className:"has-focus",mode:"all"}),addProseMirrorPlugins(){return[new Me({key:new Le("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return vi.create(t,[]);let o=0;"deepest"===this.options.mode&&t.descendants(((t,e)=>{if(!t.isText)return i>=e&&i<=e+t.nodeSize-1&&void(o+=1)}));let l=0;return t.descendants(((t,e)=>!t.isText&&(i>=e&&i<=e+t.nodeSize-1&&(l+=1,"deepest"===this.options.mode&&o-l>0||"shallowest"===this.options.mode&&l>1?"deepest"===this.options.mode:void s.push(wi.node(e,e+t.nodeSize,{class:this.options.className})))))),vi.create(t,s)}}})]}});var bp=zl.create({name:"gapCursor",addProseMirrorPlugins:()=>[new Me({props:{decorations:Xd,createSelectionBetween:(t,e,n)=>e.pos==n.pos&&Wd.valid(n)?new Wd(n):null,handleClick:Vd,handleKeyDown:Jd,handleDOMEvents:{beforeinput:Gd}}})],extendNodeSchema(t){var e;return{allowGapCursor:null!=(e=Oo(Lo(t,"allowGapCursor",{name:t.name,options:t.options,storage:t.storage})))?e:null}}}),yp="placeholder",vp=new Le("tiptap__placeholder");function kp(t){const{editor:e,placeholder:n,dataAttribute:r,pos:i,node:s,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:u,emptyEditor:a}}=t,h=[u];return o&&h.push(a),wi.node(i,i+s.nodeSize,{class:h.join(" "),[r]:"function"==typeof n?n({editor:e,node:s,pos:i,hasAnchor:l}):n})}function Mp(t,e){return"function"==typeof t?t(e):t}function Tp(t){const e=getComputedStyle(t);return/auto|scroll|overlay/.test(`${e.overflow} ${e.overflowY} ${e.overflowX}`)}var xp={init:()=>({topPos:null,bottomPos:null}),apply(t,e){const n=t.getMeta(vp);return(null==n?void 0:n.positions)?{topPos:n.positions.top,bottomPos:n.positions.bottom}:t.docChanged?{topPos:null!==e.topPos?t.mapping.map(e.topPos):null,bottomPos:null!==e.bottomPos?t.mapping.map(e.bottomPos):null}:e}};function Lp(t){const e=function(t){let e=t;for(;e;){if(Tp(e))return e;const t=e.parentElement;if(!t){const t=e.getRootNode();if(t instanceof ShadowRoot){e=t.host;continue}return window}e=t}return window}(t.dom),n=()=>{const n=function({doc:t,view:e,scrollContainer:n}){const r=e.dom.getBoundingClientRect(),i=n?(s=n)===window?{top:0,bottom:window.innerHeight}:s.getBoundingClientRect():{top:0,bottom:window.innerHeight};var s;const o=Math.max(r.top,i.top)-200,l=Math.min(r.bottom,i.bottom)+200;if(o>=l)return{top:0,bottom:t.content.size};const u="rtl"===getComputedStyle(e.dom).direction?Math.max(r.right-2,r.left+2):r.left+2,a=e.posAtCoords({left:u,top:o+2}),h=e.posAtCoords({left:u,top:l-2});return{top:a?a.pos:0,bottom:h?h.pos:t.content.size}}({view:t,doc:t.state.doc,scrollContainer:e}),r=vp.getState(t.state);if((null==r?void 0:r.topPos)===n.top&&(null==r?void 0:r.bottomPos)===n.bottom)return;const i=t.state.tr.setMeta(vp,{positions:n});t.dispatch(i)};let r=null,i=0;const s=()=>{null===r&&(r=requestAnimationFrame((()=>{r=null;const t=performance.now();t-i>=150?(i=t,n()):s()})))};return e.addEventListener("scroll",s,{passive:!0}),n(),{update(e,n){t.state.doc.content.size!==n.doc.content.size&&s()},destroy:()=>{null!==r&&cancelAnimationFrame(r),e.removeEventListener("scroll",s)}}}function Sp({editor:t,options:e}){const n=e.dataAttribute?`data-${r=e.dataAttribute,r.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}`:`data-${yp}`;var r;return new Me({key:vp,state:xp,view:Lp,props:{decorations:({doc:r,selection:i})=>function({editor:t,options:e,dataAttribute:n,doc:r,selection:i}){var s,o;if(!t.isEditable&&e.showOnlyWhenEditable)return null;const{anchor:l}=i,u=[],a=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const i=r.resolve(l),s=i.depth>0?i.node(1):i.nodeAfter,o=i.depth>0?i.before(1):l;if(s&&s.type.isTextblock&&el(s)){const r=l>=o&&l<=o+s.nodeSize;u.push(kp({editor:t,isEmptyDoc:a,dataAttribute:n,hasAnchor:r,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Mp(e.emptyNodeClass,{editor:t,node:s,pos:o,hasAnchor:r})},node:s,pos:o}))}}else{const i=vp.getState(t.state),h=null!=(s=null==i?void 0:i.topPos)?s:0,c=null!=(o=null==i?void 0:i.bottomPos)?o:r.content.size;r.nodesBetween(h,c,((r,i)=>{const s=l>=i&&l<=i+r.nodeSize,o=!r.isLeaf&&el(r);return r.type.isTextblock?(!s&&e.showOnlyCurrent||!o||u.push(kp({editor:t,isEmptyDoc:a,dataAttribute:n,hasAnchor:s,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Mp(e.emptyNodeClass,{editor:t,node:r,pos:i,hasAnchor:s})},node:r,pos:i})),e.includeChildren):e.includeChildren}))}return vi.create(r,u)}({editor:t,options:e,dataAttribute:n,doc:r,selection:i})}})}var Ap=zl.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:yp,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[Sp({editor:this.editor,options:this.options})]}});function Ep({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(null==e?void 0:e.type)===t}zl.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Me({key:new Le("selection"),props:{decorations:n=>n.selection.empty||t.isFocused||!t.isEditable||nl(n.selection)||t.view.dragging?null:vi.create(n.doc,[wi.inline(n.selection.from,n.selection.to,{class:e.className})])}})]}});var Op=zl.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var t;const e=new Le(this.name),n=this.options.node||(null==(t=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map((([,t])=>t)).filter((t=>(this.options.notAfter||[]).concat(n).includes(t.name)));return[new Me({key:e,appendTransaction:(t,r,i)=>{const{doc:s,tr:o,schema:l}=i,u=e.getState(i),a=s.content.size,h=l.nodes[n];if(!t.some((t=>t.getMeta("skipTrailingNode")))&&u)return o.insert(a,h.create())},state:{init:(t,e)=>!Ep({node:e.tr.doc.lastChild,types:r}),apply:(t,e)=>t.docChanged?t.getMeta("__uniqueIDTransaction")?e:!Ep({node:t.doc.lastChild,types:r}):e}})]}}),$p=zl.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:t,dispatch:e})=>pp(t,e),redo:()=>({state:t,dispatch:e})=>mp(t,e)}),addProseMirrorPlugins(){return[fp(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Cp=zl.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return!1!==this.options.bold&&i.push(Jh.configure(this.options.bold)),!1!==this.options.blockquote&&i.push(_h.configure(this.options.blockquote)),!1!==this.options.bulletList&&i.push(ad.configure(this.options.bulletList)),!1!==this.options.code&&i.push(Gh.configure(this.options.code)),!1!==this.options.codeBlock&&i.push(Zh.configure(this.options.codeBlock)),!1!==this.options.document&&i.push(Yh.configure(this.options.document)),!1!==this.options.dropcursor&&i.push(wp.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&i.push(bp.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&i.push(tc.configure(this.options.hardBreak)),!1!==this.options.heading&&i.push(ec.configure(this.options.heading)),!1!==this.options.undoRedo&&i.push($p.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&i.push(nc.configure(this.options.horizontalRule)),!1!==this.options.italic&&i.push(lc.configure(this.options.italic)),!1!==this.options.listItem&&i.push(fd.configure(this.options.listItem)),!1!==this.options.listKeymap&&i.push(Td.configure(null==(t=this.options)?void 0:t.listKeymap)),!1!==this.options.link&&i.push(sd.configure(null==(e=this.options)?void 0:e.link)),!1!==this.options.orderedList&&i.push($d.configure(this.options.orderedList)),!1!==this.options.paragraph&&i.push(Id.configure(this.options.paragraph)),!1!==this.options.strike&&i.push(Bd.configure(this.options.strike)),!1!==this.options.text&&i.push(jd.configure(this.options.text)),!1!==this.options.underline&&i.push(zd.configure(null==(n=this.options)?void 0:n.underline)),!1!==this.options.trailingNode&&i.push(Op.configure(null==(r=this.options)?void 0:r.trailingNode)),i}}),Rp=(t,e=0)=>{const n=[];return!t.children.length||e>20||Array.from(t.children).forEach((t=>{"SPAN"===t.tagName?n.push(t):t.children.length&&n.push(...Rp(t,e+1))})),n},Hp=Il.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{},mergeNestedSpanStyles:!0}),parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>!!t.hasAttribute("style")&&(this.options.mergeNestedSpanStyles&&(t=>{if(!t.children.length)return;const e=Rp(t);e&&e.forEach((t=>{var e,n;const r=t.getAttribute("style"),i=null==(n=null==(e=t.parentElement)?void 0:e.closest("span"))?void 0:n.getAttribute("style");t.setAttribute("style",`${i};${r}`)}))})(t),{})}]},renderHTML({HTMLAttributes:t}){return["span",Ho(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,((e,n)=>{if(e.isTextblock)return!0;e.marks.filter((t=>t.type===this.type)).some((t=>Object.values(t.attrs).some((t=>!!t))))||t.removeMark(n,n+e.nodeSize,this.type)})),!0}}}}),Np=zl.create({name:"backgroundColor",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=null!=(e=su(t,"background-color"))?e:t.style.backgroundColor;return null==n?void 0:n.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands:()=>({setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()})}),Ip=zl.create({name:"color",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=null!=(e=su(t,"color"))?e:t.style.color;return null==n?void 0:n.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands:()=>({setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()})}),Pp=zl.create({name:"fontFamily",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>{var e;return null!=(e=su(t,"font-family"))?e:t.style.fontFamily},renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands:()=>({setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()})}),Dp=zl.create({name:"fontSize",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>{var e;return null!=(e=su(t,"font-size"))?e:t.style.fontSize},renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands:()=>({setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()})}),Bp=zl.create({name:"lineHeight",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>{var e;return null!=(e=su(t,"line-height"))?e:t.style.lineHeight},renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands:()=>({setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()})});zl.create({name:"textStyleKit",addExtensions(){const t=[];return!1!==this.options.backgroundColor&&t.push(Np.configure(this.options.backgroundColor)),!1!==this.options.color&&t.push(Ip.configure(this.options.color)),!1!==this.options.fontFamily&&t.push(Pp.configure(this.options.fontFamily)),!1!==this.options.fontSize&&t.push(Dp.configure(this.options.fontSize)),!1!==this.options.lineHeight&&t.push(Bp.configure(this.options.lineHeight)),!1!==this.options.textStyle&&t.push(Hp.configure(this.options.textStyle)),t}});var jp=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;const zp=mu.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Ho(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,s,o;const l=null!=(n=null==(e=t.attrs)?void 0:e.src)?n:"",u=null!=(i=null==(r=t.attrs)?void 0:r.alt)?i:"",a=null!=(o=null==(s=t.attrs)?void 0:s.title)?o:"";return a?`![${u}](${l} "${a}")`:`![${u}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||"undefined"==typeof document)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:s,HTMLAttributes:o,editor:l})=>{const u=document.createElement("img");u.draggable=!1;const a=Ho(this.options.HTMLAttributes,o);Object.entries(a).forEach((([t,e])=>{if(null!=e)switch(t){case"width":case"height":break;default:u.setAttribute(t,e)}})),null!==a.src&&(u.src=a.src);const h=new iu({element:u,editor:l,node:i,getPos:s,onResize:(t,e)=>{u.style.width=`${t}px`,u.style.height=`${e}px`},onCommit:(t,e)=>{const n=s();void 0!==n&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:t,height:e}).run()},onUpdate:t=>t.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:!0===r}}),c=h.dom;return c.style.visibility="hidden",c.style.pointerEvents="none",u.onload=()=>{c.style.visibility="",c.style.pointerEvents=""},h}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[eu({find:jp,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}).extend({name:"image",addAttributes(){return{...this.parent?.(),dataFileId:{default:null,parseHTML:t=>t.getAttribute("data-file-id"),renderHTML:t=>t.dataFileId?{"data-file-id":t.dataFileId}:{}},imageLayout:{default:"inline",parseHTML:t=>function(t){switch(t){case"wrap-left":case"wrap-right":case"center":case"full-width":case"inline":return t;case"wrap-text":return"wrap-left";case"break-text":case"behind-text":case"in-front-text":return"center";default:return"inline"}}(t.getAttribute("data-image-layout")),renderHTML:t=>t.imageLayout&&"inline"!==t.imageLayout?{"data-image-layout":t.imageLayout}:{}}}},addNodeView(){const t=this.parent?.();return"function"!=typeof t?t??null:e=>{const n=t(e);if(!n)return n;const r=n.update?.bind(n);return n.update=(t,e,i)=>{const s=!r||r(t,e,i);return s&&(t=>{const e=n.dom??null;if(!e||"image"!==t?.type?.name)return;const r="IMG"===e.tagName?e:e.querySelector("img");if(!r)return;const i=t.attrs?.src;null!=i&&r.getAttribute("src")!==i&&(r.src=i);const s=t.attrs?.dataFileId;s?r.setAttribute("data-file-id",String(s)):r.removeAttribute("data-file-id")})(t),s},n}}});function _p(t){const e=/^(\d+(?:\.\d+)?)px$/.exec((t.style&&t.style.width||"").trim());return e?Math.round(parseFloat(e[1])):null}const Fp=["bottom-right","bottom-left"];function Wp(){return t=>{const{editor:e,getPos:n}=t;let r=t.node;const i=ut.fromSchema(e.schema),s=i.serializeNode(r);s.classList.add("co-rte-embed");const o=t=>{s.style.width=null!=t&&""!==t&&"100%"!==t?"number"==typeof t?`${t}px`:String(t):""};return o(r.attrs.width),e.isEditable&&Fp.forEach((t=>{const i=document.createElement("div");i.className=`co-rte-embed__handle co-rte-embed__handle--${t}`,i.setAttribute("data-embed-handle",t),i.addEventListener("mousedown",(i=>function(t,i){t.preventDefault(),t.stopPropagation();const o=t.clientX,l=s.offsetWidth,u=s.parentElement?.clientWidth||l,a=s.querySelector("iframe");a&&(a.style.pointerEvents="none"),s.classList.add("co-rte-embed--resizing");const h=t=>{const e=t.clientX-o;let n=i.includes("left")?l-e:l+e;n=Math.max(160,Math.min(Math.round(n),u)),s.style.width=`${n}px`},c=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",c),a&&(a.style.pointerEvents=""),s.classList.remove("co-rte-embed--resizing");const t=Math.round(s.offsetWidth),i=u&&t>=u-4?null:t;if("function"==typeof n){const t=n();null!=t&&e.view.dispatch(e.view.state.tr.setNodeMarkup(t,void 0,{...r.attrs,width:i}))}};document.addEventListener("mousemove",h),document.addEventListener("mouseup",c)}(i,t))),s.appendChild(i)})),{dom:s,ignoreMutation:()=>!0,update:t=>{if(t.type!==r.type)return!1;const e=t.attrs.src!==r.attrs.src||t.attrs.start!==r.attrs.start;if(r=t,e){const t=i.serializeNode(r).querySelector("iframe"),e=s.querySelector("iframe");t&&e&&e.replaceWith(t)}return o(r.attrs.width),!0},selectNode:()=>s.classList.add("co-rte-embed--selected"),deselectNode:()=>s.classList.remove("co-rte-embed--selected")}}}function Kp(t){return!!t&&/^https:\/\//i.test(t.trim())}const Up=mu.create({name:"iframe",group:"block",atom:!0,draggable:!0,selectable:!0,addOptions:()=>({HTMLAttributes:{}}),addAttributes:()=>({src:{default:null,parseHTML:t=>t.querySelector("iframe")?.getAttribute("src")||t.getAttribute("src")},width:{default:null,parseHTML:t=>_p(t.closest("[data-iframe]")||t)}}),parseHTML:()=>[{tag:"div[data-iframe]"},{tag:"iframe[src]",getAttrs:t=>!t.closest("[data-youtube-video]")&&(!!Kp(t.getAttribute("src")||"")&&{})}],addNodeView:()=>Wp(),renderHTML({HTMLAttributes:t}){const{src:e,width:n,...r}=t,i={"data-iframe":"",class:"co-rte-iframe"};return null!=n&&""!==n&&"100%"!==n&&(i.style=`width:${"number"==typeof n?`${n}px`:n};max-width:100%`),["div",Ho(r,i),["iframe",Ho(this.options.HTMLAttributes,{src:e,width:"100%",frameborder:"0",allowfullscreen:"true",loading:"lazy"})]]},addCommands(){return{setIframe:t=>({commands:e})=>!!Kp(t.src)&&e.insertContent({type:this.name,attrs:t}),updateIframe:t=>({commands:e})=>!!Kp(t.src)&&e.updateAttributes(this.name,t)}}});function Jp(t){return"left"===t||"right"===t||"center"===t?t:null}function qp(){return{default:null,parseHTML:t=>function(t){const e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return Jp(e||n)}(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}var Vp=mu.create({name:"tableCell",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),i=r?r.split(",").map((t=>parseInt(t,10))):null;if(!i){const r=null==(e=t.closest("table"))?void 0:e.querySelectorAll("colgroup > col"),i=Array.from((null==(n=t.parentElement)?void 0:n.children)||[]).indexOf(t);if(i&&i>-1&&r&&r[i]){const t=r[i].getAttribute("width");return t?[parseInt(t,10)]:null}}return i}},align:qp()}),tableRole:"cell",isolating:!0,parseHTML:()=>[{tag:"td"}],renderHTML({HTMLAttributes:t}){return["td",Ho(this.options.HTMLAttributes,t),0]}}),Gp=mu.create({name:"tableHeader",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map((t=>parseInt(t,10))):null}},align:qp()}),tableRole:"header_cell",isolating:!0,parseHTML:()=>[{tag:"th"}],renderHTML({HTMLAttributes:t}){return["th",Ho(this.options.HTMLAttributes,t),0]}}),Xp=mu.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:t}){return["tr",Ho(this.options.HTMLAttributes,t),0]}});function Qp(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Zp(t,e,n,r,i,s){var o;let l=0,u=!0,a=e.firstChild;const h=t.firstChild;if(null!==h)for(let t=0,n=0;t<h.childCount;t+=1){const{colspan:o,colwidth:c}=h.child(t).attrs;for(let t=0;t<o;t+=1,n+=1){const o=i===n?s:c&&c[t];if(l+=o||r,o||(u=!1),a){if(a.style.width!==(o?`${o}px`:"")){const[t,e]=Qp(r,o);a.style.setProperty(t,e)}a=a.nextSibling}else{const t=document.createElement("col"),[n,i]=Qp(r,o);t.style.setProperty(n,i),e.appendChild(t)}}}for(;a;){const t=a.nextSibling;null==(o=a.parentNode)||o.removeChild(a),a=t}const c=t.attrs.style&&"string"==typeof t.attrs.style&&/\bwidth\s*:/i.test(t.attrs.style);u&&!c?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var Yp=class{constructor(t,e,n,r={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(const[t,e]of Object.entries(r))null!=e&&("style"===t?this.table.style.cssText=String(e):this.table.setAttribute(t,String(e)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Zp(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type===this.node.type&&(this.node=t,Zp(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!(!n||r||"attributes"!==t.type&&"childList"!==t.type&&"characterData"!==t.type)}};function tm(t){return t.createAndFill()}var em=({editor:t})=>{const{selection:e}=t.state;if(!(e instanceof Va))return!1;let n=0;const r=To(e.ranges[0].$from,(t=>"table"===t.type.name));return null==r||r.node.descendants((t=>{if("table"===t.type.name)return!1;["tableCell","tableHeader"].includes(t.type.name)&&(n+=1)})),n===e.ranges.length&&(t.commands.deleteTable(),!0)},nm=mu.create({name:"table",addOptions:()=>({HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Yp,lastColumnResizable:!0,allowTableNodeSelection:!1}),content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML:()=>[{tag:"table"}],renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=function(t,e){let n=0,r=!0;const i=[],s=t.firstChild;if(!s)return{};for(let t=0,o=0;t<s.childCount;t+=1){const{colspan:l,colwidth:u}=s.child(t).attrs;for(let t=0;t<l;t+=1,o+=1){const s=undefined===o?undefined:u&&u[t];n+=s||e,s||(r=!1);const[l,a]=Qp(e,s);i.push(["col",{style:`${l}: ${a}`}])}}const o=r?`${n}px`:"",l=r?"":`${n}px`;return{colgroup:["colgroup",{},...i],tableWidth:o,tableMinWidth:l}}(t,this.options.cellMinWidth),s=["table",Ho(this.options.HTMLAttributes,e,{style:e.style||(r?`width: ${r}`:`min-width: ${i}`)}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},s]:s},parseMarkdown:(t,e)=>{const n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){const i=[];t.header.forEach(((t,n)=>{var s;const o=Jp(null!=(s=r[n])?s:t.align);i.push(e.createNode("tableHeader",o?{align:o}:{},[{type:"paragraph",content:e.parseInline(t.tokens)}]))})),n.push(e.createNode("tableRow",{},i))}return t.rows&&t.rows.forEach((t=>{const i=[];t.forEach(((t,n)=>{var s;const o=Jp(null!=(s=r[n])?s:t.align);i.push(e.createNode("tableCell",o?{align:o}:{},[{type:"paragraph",content:e.parseInline(t.tokens)}]))})),n.push(e.createNode("tableRow",{},i))})),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>function(t,e,n={}){var r;const i=null!=(r=n.cellLineSeparator)?r:"";if(!t||!t.content||0===t.content.length)return"";const s=[];t.content.forEach((t=>{const n=[];t.content&&t.content.forEach((t=>{let r="";r=t.content&&Array.isArray(t.content)&&t.content.length>1?t.content.map((t=>e.renderChildren(t))).join(i):t.content?e.renderChildren(t.content):"";const s=(r||"").replace(/\s+/g," ").trim(),o="tableHeader"===t.type,l=Jp(null==(u=t.attrs)?void 0:u.align);var u;n.push({text:s,isHeader:o,align:l})})),s.push(n)}));const o=s.reduce(((t,e)=>Math.max(t,e.length)),0);if(0===o)return"";const l=Array.from({length:o}).fill(0);s.forEach((t=>{var e;for(let n=0;n<o;n+=1){const r=((null==(e=t[n])?void 0:e.text)||"").length;r>l[n]&&(l[n]=r),l[n]<3&&(l[n]=3)}}));const u=(t,e)=>t+" ".repeat(Math.max(0,e-t.length)),a=s[0],h=a.some((t=>t.isHeader)),c=Array.from({length:o}).fill(null);s.forEach((t=>{var e;for(let n=0;n<o;n+=1)!c[n]&&(null==(e=t[n])?void 0:e.align)&&(c[n]=t[n].align)}));let f="\n";const d=Array.from({length:o}).map(((t,e)=>h&&a[e]&&a[e].text||""));return f+=`| ${d.map(((t,e)=>u(t,l[e]))).join(" | ")} |\n`,f+=`| ${l.map(((t,e)=>{const n=Math.max(3,t),r=c[e];return"left"===r?`:${"-".repeat(n)}`:"right"===r?`${"-".repeat(n)}:`:"center"===r?`:${"-".repeat(n)}:`:"-".repeat(n)})).join(" | ")} |\n`,(h?s.slice(1):s).forEach((t=>{f+=`| ${Array.from({length:o}).fill(0).map(((e,n)=>u(t[n]&&t[n].text||"",l[n]))).join(" | ")} |\n`})),f}(t,e),addCommands:()=>({insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const o=function(t,e,n,r){const i=function(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach((n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)})),t.cached.tableNodeTypes=e,e}(t),s=[],o=[];for(let t=0;t<n;t+=1){const t=tm(i.cell);if(t&&o.push(t),r){const t=tm(i.header_cell);t&&s.push(t)}}const l=[];for(let t=0;t<e;t+=1)l.push(i.row.createChecked(null,r&&0===t?s:o));return i.table.createChecked(null,l)}(s.schema,t,e,n);if(i){const t=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(le.near(r.doc.resolve(t)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>function(t,e){if(!_a(t))return!1;if(e){const n=th(t);e(eh(t.tr,n,n.left))}return!0}(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>function(t,e){if(!_a(t))return!1;if(e){const n=th(t);e(eh(t.tr,n,n.right))}return!0}(t,e),deleteColumn:()=>({state:t,dispatch:e})=>function(t,e){if(!_a(t))return!1;if(e){const n=th(t),r=t.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let t=n.right-1;nh(r,n,t),t!=n.left;t--){const t=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!t)throw new RangeError("No table found");n.table=t,n.map=Pa.get(t)}e(r)}return!0}(t,e),addRowBefore:()=>({state:t,dispatch:e})=>function(t,e){if(!_a(t))return!1;if(e){const n=th(t);e(rh(t.tr,n,n.top))}return!0}(t,e),addRowAfter:()=>({state:t,dispatch:e})=>function(t,e){if(!_a(t))return!1;if(e){const n=th(t);e(rh(t.tr,n,n.bottom))}return!0}(t,e),deleteRow:()=>({state:t,dispatch:e})=>function(t,e){if(!_a(t))return!1;if(e){const n=th(t),r=t.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let t=n.bottom-1;ih(r,n,t),t!=n.top;t--){const t=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!t)throw new RangeError("No table found");n.table=t,n.map=Pa.get(n.table)}e(r)}return!0}(t,e),deleteTable:()=>({state:t,dispatch:e})=>function(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if("table"==n.node(r).type.spec.tableRole)return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}(t,e),mergeCells:()=>({state:t,dispatch:e})=>oh(t,e),splitCell:()=>({state:t,dispatch:e})=>lh(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>ah("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>ah("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>hh(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>!!oh(t,e)||lh(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>function(t,e){return function(n,r){if(!_a(n))return!1;const i=Fa(n);if(i.nodeAfter.attrs[t]===e)return!1;if(r){const s=n.tr;n.selection instanceof Va?n.selection.forEachCell(((n,r)=>{n.attrs[t]!==e&&s.setNodeMarkup(r,null,{...n.attrs,[t]:e})})):s.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(s)}return!0}}(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>ch(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>ch(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Ya(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const n=Va.create(e.doc,t.anchorCell,t.headCell);e.setSelection(n)}return!0}}),addKeyboardShortcuts(){return{Tab:()=>!!this.editor.commands.goToNextCell()||!!this.editor.can().addRowAfter()&&this.editor.chain().addRowAfter().goToNextCell().run(),"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:em,"Mod-Backspace":em,Delete:em,"Mod-Delete":em}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[$h({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Ph({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const t=this.options.View;return this.options.resizable&&this.editor.isEditable||!t?null:({node:e,view:n,HTMLAttributes:r})=>{const i=Ho(this.options.HTMLAttributes,r);return new t(e,this.options.cellMinWidth,n,i)}},extendNodeSchema:t=>({tableRole:Oo(Lo(t,"tableRole",{name:t.name,options:t.options,storage:t.storage}))})});zl.create({name:"tableKit",addExtensions(){const t=[];return!1!==this.options.table&&t.push(nm.configure(this.options.table)),!1!==this.options.tableCell&&t.push(Vp.configure(this.options.tableCell)),!1!==this.options.tableHeader&&t.push(Gp.configure(this.options.tableHeader)),!1!==this.options.tableRow&&t.push(Xp.configure(this.options.tableRow)),t}});var rm=/^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu\.be|youtube-nocookie\.com))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/,im=/^((?:https?:)?\/\/)?((?:www|m|music)\.)?((?:youtube\.com|youtu\.be|youtube-nocookie\.com))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/g,sm=t=>t.match(rm),om=(t,e)=>e?"https://www.youtube-nocookie.com/embed/videoseries?list=":t?"https://www.youtube-nocookie.com/embed/":"https://www.youtube.com/embed/",lm=t=>{const{url:e,allowFullscreen:n,autoplay:r,ccLanguage:i,ccLoadPolicy:s,controls:o,disableKBcontrols:l,enableIFrameApi:u,endTime:a,interfaceLanguage:h,ivLoadPolicy:c,loop:f,modestBranding:d,nocookie:p,origin:m,playlist:g,progressBarColor:w,startAt:b,rel:y}=t;if(!sm(e))return null;if(e.includes("/embed/"))return e;if(e.includes("youtu.be")){const t=e.split("/").pop();return t?`${om(p)}${t}`:null}const v=/(?:(v|list)=|shorts\/)([-\w]+)/gm.exec(e);if(!v||!v[2])return null;let k=`${om(p,"list"===v[1])}${v[2]}`;const M=[];return!1===n&&M.push("fs=0"),r&&M.push("autoplay=1"),i&&M.push(`cc_lang_pref=${i}`),s&&M.push("cc_load_policy=1"),o||M.push("controls=0"),l&&M.push("disablekb=1"),u&&M.push("enablejsapi=1"),a&&M.push(`end=${a}`),h&&M.push(`hl=${h}`),c&&M.push(`iv_load_policy=${c}`),f&&M.push("loop=1"),d&&M.push("modestbranding=1"),m&&M.push(`origin=${m}`),g&&M.push(`playlist=${g}`),b&&M.push(`start=${b}`),w&&M.push(`color=${w}`),void 0!==y&&M.push(`rel=${y}`),M.length&&(k+=`${"list"===v[1]?"&":"?"}${M.join("&")}`),k},um=t=>{if(!t)return null;const e=Number.parseInt(t,10);return Number.isNaN(e)?null:e},am=t=>{const e=t.getAttribute("src");if(!e)return null;const n=(t=>{let e;try{e=new URL(t)}catch{return null}const n=e.hostname.replace(/^www\./,"");if("youtube.com"!==n&&"youtube-nocookie.com"!==n)return null;let r=null;if("/embed/videoseries"===e.pathname){const t=e.searchParams.get("list");if(!t)return null;r=`https://www.youtube.com/playlist?list=${t}`}else{const t=e.pathname.match(/^\/embed\/([\w-]+)$/);if(!(null==t?void 0:t[1]))return null;r=`https://www.youtube.com/watch?v=${t[1]}`}if(!sm(r))return null;const i={src:r},s=e.searchParams.get("start");if(s){const t=Number.parseInt(s,10);Number.isNaN(t)||(i.start=t)}return i})(e);return n||{src:e}};const hm=mu.create({name:"youtube",addOptions:()=>({addPasteHandler:!0,allowFullscreen:!0,autoplay:!1,ccLanguage:void 0,ccLoadPolicy:void 0,controls:!0,disableKBcontrols:!1,enableIFrameApi:!1,endTime:0,height:480,interfaceLanguage:void 0,ivLoadPolicy:0,loop:!1,modestBranding:!1,HTMLAttributes:{},inline:!1,nocookie:!1,origin:"",playlist:"",progressBarColor:void 0,width:640,rel:1}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null,parseHTML:t=>{var e;return null==(e=am(t))?void 0:e.src}},start:{default:0,parseHTML:t=>{var e;return null==(e=am(t))?void 0:e.start}},width:{default:this.options.width,parseHTML:t=>um(t.getAttribute("width"))},height:{default:this.options.height,parseHTML:t=>um(t.getAttribute("height"))}}},parseHTML:()=>[{tag:"div[data-youtube-video] iframe"}],addCommands(){return{setYoutubeVideo:t=>({commands:e})=>!!sm(t.src)&&e.insertContent({type:this.name,attrs:t})}},addPasteRules(){return this.options.addPasteHandler?[(t={find:im,type:this.type,getAttributes:t=>({src:t.input})},new Pl({find:t.find,handler({match:e,chain:n,range:r,pasteEvent:i}){const s=Oo(t.getAttributes,void 0,e,i),o=Oo(t.getContent,void 0,s);if(!1===s||null===s)return null;const l={type:t.type.name,attrs:s};o&&(l.content=o),e.input&&n().deleteRange(r).insertContentAt(r.from,l)}}))]:[];var t},renderHTML({HTMLAttributes:t}){const e=lm({url:t.src,allowFullscreen:this.options.allowFullscreen,autoplay:this.options.autoplay,ccLanguage:this.options.ccLanguage,ccLoadPolicy:this.options.ccLoadPolicy,controls:this.options.controls,disableKBcontrols:this.options.disableKBcontrols,enableIFrameApi:this.options.enableIFrameApi,endTime:this.options.endTime,interfaceLanguage:this.options.interfaceLanguage,ivLoadPolicy:this.options.ivLoadPolicy,loop:this.options.loop,modestBranding:this.options.modestBranding,nocookie:this.options.nocookie,origin:this.options.origin,playlist:this.options.playlist,progressBarColor:this.options.progressBarColor,startAt:t.start||0,rel:this.options.rel});return t.src=e,["div",{"data-youtube-video":""},["iframe",Ho(this.options.HTMLAttributes,{width:this.options.width,height:this.options.height,allowfullscreen:this.options.allowFullscreen,autoplay:this.options.autoplay,ccLanguage:this.options.ccLanguage,ccLoadPolicy:this.options.ccLoadPolicy,disableKBcontrols:this.options.disableKBcontrols,enableIFrameApi:this.options.enableIFrameApi,endTime:this.options.endTime,interfaceLanguage:this.options.interfaceLanguage,ivLoadPolicy:this.options.ivLoadPolicy,loop:this.options.loop,modestBranding:this.options.modestBranding,origin:this.options.origin,playlist:this.options.playlist,progressBarColor:this.options.progressBarColor,rel:this.options.rel},t)]]},...uu({nodeName:"youtube",allowedAttributes:["src","width","height","start"]})}).extend({addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:t=>_p(t.closest("[data-youtube-video]")||t),renderHTML:()=>({})},height:{default:null,renderHTML:()=>({})}}},addNodeView:()=>Wp(),renderHTML({node:t,HTMLAttributes:e}){const n=this.options,r=lm({url:e.src,allowFullscreen:n.allowFullscreen,autoplay:n.autoplay,ccLanguage:n.ccLanguage,ccLoadPolicy:n.ccLoadPolicy,controls:n.controls,disableKBcontrols:n.disableKBcontrols,enableIFrameApi:n.enableIFrameApi,endTime:n.endTime,interfaceLanguage:n.interfaceLanguage,ivLoadPolicy:n.ivLoadPolicy,loop:n.loop,modestBranding:n.modestBranding,nocookie:n.nocookie,origin:n.origin,playlist:n.playlist,progressBarColor:n.progressBarColor,startAt:e.start||0,rel:n.rel}),i=t.attrs.width,s={"data-youtube-video":""};return null!=i&&""!==i&&"100%"!==i&&(s.style=`width:${"number"==typeof i?`${i}px`:i};max-width:100%`),["div",s,["iframe",Ho(n.HTMLAttributes,{src:r,width:"100%",allowfullscreen:n.allowFullscreen,frameborder:"0"})]]}});var cm=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,fm=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,dm=Il.create({name:"highlight",addOptions:()=>({multicolor:!1,HTMLAttributes:{}}),addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||su(t,"background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML:()=>[{tag:"mark"}],renderHTML({HTMLAttributes:t}){return["mark",Ho(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const r=/^(==)([^=]+)(==)/.exec(t);if(r){const t=r[2].trim(),e=n.inlineTokens(t);return{type:"highlight",raw:r[0],text:t,tokens:e}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[tu({find:cm,type:this.type})]},addPasteRules(){return[gu({find:fm,type:this.type})]}}),pm=zl.create({name:"textAlign",addOptions:()=>({types:[],alignments:["left","center","right","justify"],defaultAlignment:null}),addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>!!this.options.alignments.includes(t)&&this.options.types.map((n=>e.updateAttributes(n,{textAlign:t}))).some((t=>t)),unsetTextAlign:()=>({commands:t})=>this.options.types.map((e=>t.resetAttributes(e,"textAlign"))).some((t=>t)),toggleTextAlign:t=>({editor:e,commands:n})=>!!this.options.alignments.includes(t)&&(e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}});const mm=mu.create({name:"variable",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes:()=>({name:{default:null,parseHTML:t=>t.getAttribute("data-variable"),renderHTML:t=>t.name?{"data-variable":t.name}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-variable-label"),renderHTML:t=>t.label?{"data-variable-label":t.label}:{}}}),parseHTML:()=>[{tag:"span[data-variable]"},{tag:'span[data-type="variable"]'}],renderHTML({node:t,HTMLAttributes:e}){const n=t.attrs.label||t.attrs.name||"";return["span",Ho(e,{"data-type":"variable",class:"co-rte-variable",contenteditable:"false"}),n]},renderText:({node:t})=>`{{${t.attrs.name||""}}}`,addCommands(){return{insertVariable:(t,e)=>({commands:n})=>n.insertContent({type:this.name,attrs:{name:t,label:e??null}})}}}),gm=mu.create({name:"mention",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes:()=>({id:{default:null,parseHTML:t=>t.getAttribute("data-mention-id"),renderHTML:t=>t.id?{"data-mention-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-mention-label"),renderHTML:t=>t.label?{"data-mention-label":t.label}:{}}}),parseHTML:()=>[{tag:"span[data-mention-id]"}],renderHTML({node:t,HTMLAttributes:e}){const n=t.attrs.label||"";return["span",Ho(e,{"data-type":"mention",class:"co-rte-mention",contenteditable:"false"}),`@${n}`]},renderText:({node:t})=>`@${t.attrs.label||""}`,addCommands(){return{insertMention:(t,e)=>({commands:n})=>n.insertContent({type:this.name,attrs:{id:t,label:e}})}}}),wm={info:"ℹ️",warning:"⚠️",success:"✅",error:"❌"},bm=mu.create({name:"callout",group:"block",content:"block+",defining:!0,addAttributes:()=>({type:{default:"info",parseHTML:t=>t.getAttribute("data-callout")||"info",renderHTML:t=>({"data-callout":t.type})}}),parseHTML:()=>[{tag:"div[data-callout]"}],renderHTML({node:t,HTMLAttributes:e}){const n=t.attrs.type||"info";return["div",Ho(e,{class:`callout callout--${n}`,"data-callout":n}),["span",{class:"callout__icon",contenteditable:"false"},wm[n]],["div",{class:"callout__content"},0]]},addCommands(){return{insertCallout:(t="info")=>({commands:e})=>e.insertContent({type:this.name,attrs:{type:t},content:[{type:"paragraph"}]}),setCalloutType:t=>({commands:e})=>e.updateAttributes(this.name,{type:t})}}}),ym=zl.create({name:"fontSize",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize?.replace(/['"]+/g,"")||null,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands:()=>({setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()})}),vm=zl.create({name:"fontWeight",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontWeight:{default:null,parseHTML:t=>t.style.fontWeight||null,renderHTML:t=>t.fontWeight?{style:`font-weight: ${t.fontWeight}`}:{}}}}]},addCommands:()=>({setFontWeight:t=>({chain:e})=>e().setMark("textStyle",{fontWeight:t}).run(),unsetFontWeight:()=>({chain:t})=>t().setMark("textStyle",{fontWeight:null}).removeEmptyTextStyle().run()})}),km=zl.create({name:"fontFamily",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily?.replace(/['"]+/g,"")||null,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily} !important`}:{}}}}]},addCommands:()=>({setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()})}),Mm=zl.create({name:"lineHeight",addOptions:()=>({types:["paragraph","heading"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight||null,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({commands:e})=>this.options.types.every((n=>e.updateAttributes(n,{lineHeight:t}))),unsetLineHeight:()=>({commands:t})=>this.options.types.every((e=>t.resetAttributes(e,"lineHeight")))}}}),Tm=zl.create({name:"letterSpacing",addOptions:()=>({types:["textStyle"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{letterSpacing:{default:null,parseHTML:t=>t.style.letterSpacing||null,renderHTML:t=>t.letterSpacing?{style:`letter-spacing: ${t.letterSpacing}`}:{}}}}]},addCommands:()=>({setLetterSpacing:t=>({chain:e})=>e().setMark("textStyle",{letterSpacing:t}).run(),unsetLetterSpacing:()=>({chain:t})=>t().setMark("textStyle",{letterSpacing:null}).removeEmptyTextStyle().run()})}),xm=zl.create({name:"indent",addOptions:()=>({types:["paragraph","heading"],minLevel:0,maxLevel:10,step:40}),addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:0,parseHTML:t=>{const e=t.style.marginLeft;if(!e)return 0;const n=parseInt(e,10);return isNaN(n)?0:Math.round(n/this.options.step)},renderHTML:t=>{const e=Number(t.indent)||0;return e<=0?{}:{style:`margin-left: ${e*this.options.step}px !important`}}}}}]},addCommands(){const t=t=>({editor:e,commands:n})=>{const{types:r,minLevel:i,maxLevel:s}=this.options,o=r.find((t=>e.isActive(t)));if(!o)return!1;const l=Number(e.getAttributes(o).indent)||0,u=Math.min(s,Math.max(i,l+t));return u!==l&&n.updateAttributes(o,{indent:u})};return{indent:()=>t(1),outdent:()=>t(-1)}}}),Lm=zl.create({name:"listStyle",addOptions:()=>({types:["bulletList","orderedList"]}),addGlobalAttributes(){return[{types:this.options.types,attributes:{listStyleType:{default:null,parseHTML:t=>t.style.listStyleType||null,renderHTML:t=>t.listStyleType?{style:`list-style-type: ${t.listStyleType}`}:{}}}}]},addCommands:()=>({setListStyleType:t=>({commands:e,editor:n})=>{const r=n.isActive("orderedList")?"orderedList":"bulletList";return e.updateAttributes(r,{listStyleType:t})}})});var Sm=Object.defineProperty,Am="textStyle",Em=/^\s*([-+*])\s$/,Om=mu.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:t}){return["ul",Ho(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>"list"!==t.type||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,"\n"):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(Am)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ru({find:Em,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ru({find:Em,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Am),editor:this.editor})),[t]}}),$m=(t,e)=>zl.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const n=()=>((t,e,n)=>((t,e,n,r)=>{const i=((t,e,n)=>{const{selection:r}=t;if(!r.empty)return null;const{$from:i}=r;if(!i.parent.isTextblock)return null;if(i.parentOffset!==i.parent.content.size)return null;let s=-1;for(let t=i.depth;t>0;t-=1)if(i.node(t).type.name===e){s=t;break}if(s<0)return null;const o=i.node(s),l=i.index(s);if(l+1>=o.childCount)return null;const u=o.child(l+1);if(!n.includes(u.type.name))return null;const a=t.schema.nodes[e];let h=!1;if(u.forEach((t=>{t.type===a&&t.childCount>1&&(h=!0)})),!h)return null;const c=t.doc.resolve(i.after()).nodeAfter;if(!c||!n.includes(c.type.name))return null;const f=[];return c.forEach((t=>{f.push(t)})),0===f.length?null:{listItemDepth:s,nestedList:c,nestedListPos:i.after(),insertPos:i.after(s),items:f}})(t,n,r);if(!i)return!1;const{selection:s}=t,{nestedList:o,nestedListPos:u,insertPos:a,items:h}=i,c=t.tr;c.delete(u,u+o.nodeSize);const f=c.mapping.map(a);return c.insert(f,l.from(h)),c.setSelection(s.map(c.doc,c.mapping)),e&&e(c),!0})(t.state,t.view.dispatch,e,n))(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),Cm=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],Rm="abcdefghijklmnopqrstuvwxyz",Hm=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function Nm(t){let e=t,n="";for(const[t,r]of Cm)for(;e>=t;)n+=r,e-=t;return n}function Im(t){return Nm(t).toUpperCase()}function Pm(t){const e=t.toLowerCase();let n=0,r=0;for(;n<e.length;){let t=!1;for(const[i,s]of Cm)if(e.startsWith(s,n)){r+=i,n+=s.length,t=!0;break}if(!t)return 0}return r}function Dm(t){if(t<=26)return Rm[t-1];const e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?Rm[n]:Rm[e]+Rm[n]}function Bm(t){if(t&&!/^\d+$/.test(t))return function(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;const e=Pm(t);return!(e<=0)&&(t===t.toLowerCase()?Nm(e):Im(e))===t}(t)?t===t.toLowerCase()?"i":"I":/^[a-z]{1,2}$/.test(t)?"a":/^[A-Z]{1,2}$/.test(t)?"A":void 0}function jm(t){if(/^\d+$/.test(t))return parseInt(t,10);const e=Bm(t);if("i"===e||"I"===e)return Pm(t);if("a"===e||"A"===e){const e=function(t){const e=t.toLowerCase();return 1===e.length?e.charCodeAt(0)-"a".charCodeAt(0)+1:2===e.length?26*(e.charCodeAt(0)-"a".charCodeAt(0)+1)+(e.charCodeAt(1)-"a".charCodeAt(0))+1:0}(t);return e>0?e:1}const n=parseInt(t,10);return Number.isNaN(n)?1:n}function zm(t,e){if("numeric"===t)return String(e);switch(t){case"a":return Dm(e);case"A":return Dm(e).toUpperCase();case"i":return Nm(e);case"I":return Im(e);default:return String(e)}}function _m(t){const{type:e,start:n}=function(t){return{type:Bm(t),start:jm(t)}}(t),r={};return e&&(r.type=e),1!==n&&(r.start=n),r}function Fm(t,e){return e.parseInline(e.tokenizeInline?e.tokenizeInline(t):[{type:"text",raw:t,text:t}])}var Wm=mu.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Ho(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if("list_item"!==t.type)return[];const r=null!=(n=e.parseBlockChildren)?n:e.parseChildren;let i=[];if(t.tokens&&t.tokens.length>0){if(function(t){var e,n;const r=null==(e=t.tokens)?void 0:e[0];return Boolean(t.text&&1===(null==(n=t.tokens)?void 0:n.length)&&"list"===(null==r?void 0:r.type)&&r.ordered&&r.raw===t.text)}(t))return{type:"listItem",content:[{type:"paragraph",content:Fm(t.text||"",e)}]};if(t.tokens.some((t=>"paragraph"===t.type)))i=r(t.tokens);else{const n=t.tokens[0];if(n&&"text"===n.type&&n.tokens&&n.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(n.tokens)}],t.tokens.length>1){const e=r(t.tokens.slice(1));i.push(...e)}}else i=r(t.tokens)}}return 0===i.length&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(t,e,n)=>pu(t,e,(t=>{var e,n,r,i;if("bulletList"===t.parentType)return"- ";if("orderedList"===t.parentType){const s=(null==(n=null==(e=t.meta)?void 0:e.parentAttrs)?void 0:n.start)||1;return function(t,e,n=". "){const r=e+1;if(!t||"1"===t)return`${r}${n}`;switch(t){case"a":return`${Dm(r)}${n}`;case"A":return`${Dm(r).toUpperCase()}${n}`;case"i":return`${Nm(r)}${n}`;case"I":return`${Im(r)}${n}`;default:return`${r}${n}`}}(null==(i=null==(r=t.meta)?void 0:r.parentAttrs)?void 0:i.type,s-1+(t.index||0),". ")}return"- "}),n),addExtensions(){return[$m(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});((t,e)=>{for(var n in e)Sm(t,n,{get:e[n],enumerable:!0})})({},{findListItemPos:()=>Km,getNextListDepth:()=>Um,handleBackspace:()=>qm,handleDelete:()=>Xm,hasListBefore:()=>Jm,hasListItemAfter:()=>Qm,hasListItemBefore:()=>Zm,listItemHasSubList:()=>Ym,nextListIsDeeper:()=>Vm,nextListIsHigher:()=>Gm});var Km=(t,e)=>{const{$from:n}=e.selection,r=vs(t,e.schema);let i=null,s=n.depth,o=n.pos,l=null;for(;s>0&&null===l;)i=n.node(s),i.type===r?l=s:(s-=1,o-=1);return null===l?null:{$pos:e.doc.resolve(o),depth:l}},Um=(t,e)=>{const n=Km(t,e);if(!n)return!1;const[,r]=qo(e,t,n.$pos.pos+4);return r},Jm=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),s=t.doc.resolve(i).node();return!(!s||!n.includes(s.type.name))},qm=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ro(t.state,e)&&Jm(t.state,e,n)){const{$anchor:n}=t.state.selection,r=t.state.doc.resolve(n.before()-1),i=[];r.node().descendants(((t,n)=>{t.type.name===e&&i.push({node:t,pos:n})}));const s=i.at(-1);if(!s)return!1;const o=t.state.doc.resolve(r.start()+s.pos+1);return t.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}return!!ro(t.state,e)&&!!Zo(t.state)&&t.chain().liftListItem(e).run()},Vm=(t,e)=>{const n=Um(t,e),r=Km(t,e);return!(!r||!n)&&n>r.depth},Gm=(t,e)=>{const n=Um(t,e),r=Km(t,e);return!(!r||!n)&&n<r.depth},Xm=(t,e)=>{if(!ro(t.state,e))return!1;if(!Qo(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!(!n.empty&&r.sameParent(i))&&(Vm(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Gm(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward())},Qm=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return i.index()!==i.parent.childCount-1&&(null==(n=i.nodeAfter)?void 0:n.type.name)===t},Zm=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return 0!==i.index()&&(null==(n=i.nodeBefore)?void 0:n.type.name)===t},Ym=(t,e,n)=>{if(!n)return!1;const r=vs(t,e.schema);let i=!1;return n.descendants((t=>{t.type===r&&(i=!0)})),i},tg=zl.create({name:"listKeymap",addOptions:()=>({listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}),addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach((({itemName:n})=>{void 0!==t.state.schema.nodes[n]&&Xm(t,n)&&(e=!0)})),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach((({itemName:n})=>{void 0!==t.state.schema.nodes[n]&&Xm(t,n)&&(e=!0)})),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach((({itemName:n,wrapperNames:r})=>{void 0!==t.state.schema.nodes[n]&&qm(t,n,r)&&(e=!0)})),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach((({itemName:n,wrapperNames:r})=>{void 0!==t.state.schema.nodes[n]&&qm(t,n,r)&&(e=!0)})),e}}}}),eg=new RegExp(`^(\\s*)(${Hm})([.)])\\s+(.*)$`),ng=new RegExp(`^(\\s*)(${Hm})([.)])\\s+`),rg=/^\s/;function ig(t){const e=[],n=[];let r=!1;return t.forEach((t=>{if(!r)return""===t.trim()||e.length>0&&function(t){const e=t.trimStart();return/^[-+*]\s+/.test(e)||function(t){return eg.test(t.trimStart())}(e)||/^>\s?/.test(e)||/^```/.test(e)||/^~~~/.test(e)}(t)?(r=!0,void n.push(t)):void e.push(t);n.push(t)})),{paragraphLines:e,blockLines:n}}var sg=new RegExp(`^(${Hm})([.)])\\s+(.+)$`);function og(t,e,n){const r=[];let i=0;for(;i<t.length;){const s=t[i];if(s.indent===e){const{paragraphLines:o,blockLines:l}=ig(s.contentLines),u=o.join("\n").trim(),a=[];u&&a.push({type:"paragraph",raw:u,tokens:n.inlineTokens(u)});const h=l.join("\n").trim();if(h){const t=n.blockTokens(h);a.push(...t)}let c=i+1;const f=[];for(;c<t.length&&t[c].indent>e;)f.push(t[c]),c+=1;if(f.length>0){const t=Math.min(...f.map((t=>t.indent))),e=og(f,t,n);a.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:e,raw:f.map((t=>t.raw)).join("\n")})}r.push({type:"list_item",raw:s.raw,tokens:a}),i=c}else i+=1}return r}var lg="textStyle",ug=/^(\d+)\.\s$/;function ag(t){const e=t.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}var hg=mu.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>{const e=t.getAttribute("type");if(e)return e;const n=t.getAttribute("style");if(n){const t=ag(n);if(t)return t}const r=t.querySelector("li");if(r){const t=r.getAttribute("style");if(t){const e=ag(t);if(e)return e}}return null}}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:t}){const{start:e,type:n,...r}=t,i=Ho(this.options.HTMLAttributes,r);return 1!==e&&(i.start=e),n&&"1"!==n&&(i.type=n),["ol",i,0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if("list"!==t.type||!t.ordered)return[];const n=t.start||1,r=t.typeMarker,i=t.items?function(t,e){return t.map((t=>{if("list_item"!==t.type)return e.parseChildren([t])[0];const n=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach((t=>{if("paragraph"===t.type||"list"===t.type||"blockquote"===t.type||"code"===t.type)n.push(...e.parseChildren([t]));else if("text"===t.type&&t.tokens){const r=e.parseChildren([t]);n.push({type:"paragraph",content:r})}else{const r=e.parseChildren([t]);r.length>0&&n.push(...r)}})),{type:"listItem",content:n}}))}(t.items,e):[],s={};return 1!==n&&(s.start=n),r&&(s.type=r),Object.keys(s).length>0?{type:"orderedList",attrs:s,content:i}:{type:"orderedList",content:i}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,"\n"):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(ng),n=null==e?void 0:e.index;return void 0!==n?n:-1},tokenize:(t,e,n)=>{var r,i;const s=t.split("\n"),[o,l]=function(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(eg);if(!s)break;const[,o,l,u,a]=s,h=o.length,c=parseInt(l,10),f=isNaN(c)?Bm(l):void 0,d=isNaN(c)?jm(l):c,p=[a];let m=n+1;const g=[i];let w=!1;for(;m<t.length;){const e=t[m];if(e.match(eg))break;if(""===e.trim())g.push(e),p.push(""),w=!0,m+=1;else if(e.match(rg)){const t=e.length-e.trimStart().length,n=h+l.length+1;g.push(e),p.push(e.slice(Math.min(t,n))),m+=1}else{if(w)break;g.push(e),p.push(e),m+=1}}e.push({indent:h,number:d,type:f,content:p.join("\n").trim(),contentLines:p,raw:g.join("\n")}),r=m,n=m}return[e,r]}(s);if(0===o.length)return;const u=og(o,0,n);return 0!==u.length?{type:"list",ordered:!0,start:(null==(r=o[0])?void 0:r.number)||1,typeMarker:null==(i=o[0])?void 0:i.type,items:u,raw:s.slice(0,l).join("\n")}:void 0}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(lg)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins:()=>[new Me({props:{handlePaste:(t,e)=>{var n,r;const i=null==(n=e.clipboardData)?void 0:n.getData("text/html");if(null==i?void 0:i.trim())return!1;const s=null==(r=e.clipboardData)?void 0:r.getData("text/plain");if(!s)return!1;const o=function(t){const e=t.split("\n").filter((t=>t.trim().length>0));if(0===e.length)return null;const n=[];for(const t of e){const e=t.trim().match(sg);if(!e)return null;n.push({marker:e[1],content:e[3]})}return function(t){var e;if(0===t.length)return!1;const n=null!=(e=Bm(t[0]))?e:"numeric",r=jm(t[0]);if(r<1)return!1;for(let e=0;e<t.length;e++){const i=zm(n,r+e);if(t[e]!==i)return!1}return!0}(n.map((t=>t.marker)))?{type:"orderedList",attrs:_m(n[0].marker),content:n.map((t=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:t.content}]}]})))}:null}(s);if(!o)return!1;try{const e=t.state.schema.nodeFromJSON(o),n=t.state.tr.replaceSelectionWith(e);return t.dispatch(n),!0}catch{return!1}}}})],addInputRules(){const t=(t,e)=>(!e.attrs.type||"1"===e.attrs.type)&&e.childCount+e.attrs.start===+t[1];let e=ru({find:ug,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=ru({find:ug,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(lg)}),joinPredicate:t,editor:this.editor})),[e]}}),cg=/^\s*(\[([( |x])?\])\s$/,fg=mu.create({name:"taskItem",addOptions:()=>({nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}),content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes:()=>({checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return""===e||"true"===e},renderHTML:t=>({"data-checked":t.checked})}}),parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Ho(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(n.push(e.createNode("paragraph",{},t.tokens&&t.tokens.length>0?e.parseInline(t.tokens):t.text?[e.createNode("text",{text:t.text})]:[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;return pu(t,e,`- [${(null==(n=t.attrs)?void 0:n.checked)?"x":" "}] `)},addExtensions(){return this.options.nested?[$m(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),u=document.createElement("div"),a=t=>{var e,n;l.ariaLabel=(null==(n=null==(e=this.options.a11y)?void 0:e.checkboxLabel)?void 0:n.call(e,t,l.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};a(t),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",(t=>t.preventDefault())),l.addEventListener("change",(e=>{if(!r.isEditable&&!this.options.onReadOnlyChecked)return void(l.checked=!l.checked);const{checked:i}=e.target;r.isEditable&&"function"==typeof n&&r.chain().focus(void 0,{scrollIntoView:!1}).command((({tr:t})=>{const e=n();if("number"!=typeof e)return!1;const r=t.doc.nodeAt(e);return t.setNodeMarkup(e,void 0,{...null==r?void 0:r.attrs,checked:i}),!0})).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,i)||(l.checked=!l.checked))})),Object.entries(this.options.HTMLAttributes).forEach((([t,e])=>{i.setAttribute(t,e)})),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,s.append(l,o),i.append(s,u),Object.entries(e).forEach((([t,e])=>{i.setAttribute(t,e)}));let h=new Set(Object.keys(e));return{dom:i,contentDOM:u,update:t=>{if(t.type!==this.type)return!1;i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,a(t);const e=No(t,r.extensionManager.attributes),n=new Set(Object.keys(e)),s=this.options.HTMLAttributes;return h.forEach((t=>{n.has(t)||(t in s?i.setAttribute(t,s[t]):i.removeAttribute(t))})),Object.entries(e).forEach((([t,e])=>{null==e?t in s?i.setAttribute(t,s[t]):i.removeAttribute(t):i.setAttribute(t,e)})),h=n,!0}}}},addInputRules(){return[ru({find:cg,type:this.type,getAttributes:t=>({checked:"x"===t[t.length-1]})})]}}),dg=mu.create({name:"taskList",addOptions:()=>({itemTypeName:"taskItem",HTMLAttributes:{}}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Ho(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,"\n"):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=null==(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))?void 0:e.index;return void 0!==n?n:-1},tokenize(t,e,n){const r=t=>{const e=du(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:t=>({indentLevel:t[1].length,mainContent:t[4],checked:"x"===t[3].toLowerCase()}),createToken:(t,e)=>({type:"taskItem",raw:"",mainContent:t.mainContent,indentLevel:t.indentLevel,checked:t.checked,text:t.mainContent,tokens:n.inlineTokens(t.mainContent),nestedTokens:e}),customNestedParser:r},n);return e?[{type:"taskList",raw:e.raw,items:e.items}]:n.blockTokens(t)},i=du(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:t=>({indentLevel:t[1].length,mainContent:t[4],checked:"x"===t[3].toLowerCase()}),createToken:(t,e)=>({type:"taskItem",raw:"",mainContent:t.mainContent,indentLevel:t.indentLevel,checked:t.checked,text:t.mainContent,tokens:n.inlineTokens(t.mainContent),nestedTokens:e}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});zl.create({name:"listKit",addExtensions(){const t=[];return!1!==this.options.bulletList&&t.push(Om.configure(this.options.bulletList)),!1!==this.options.listItem&&t.push(Wm.configure(this.options.listItem)),!1!==this.options.listKeymap&&t.push(tg.configure(this.options.listKeymap)),!1!==this.options.orderedList&&t.push(hg.configure(this.options.orderedList)),!1!==this.options.taskItem&&t.push(fg.configure(this.options.taskItem)),!1!==this.options.taskList&&t.push(dg.configure(this.options.taskList)),t}});const pg=dg.extend({addAttributes(){return{...this.parent?.()??{},variant:{default:"strike",parseHTML:t=>t.getAttribute("data-variant")||"strike",renderHTML:t=>({"data-variant":t.variant||"strike"})}}},addCommands(){return{...this.parent?.()??{},setTaskListVariant:t=>({commands:e})=>e.updateAttributes("taskList",{variant:t})}}}),mg=fg.extend({}).configure({nested:!0,onReadOnlyChecked:()=>!0});var gg=Il.create({name:"superscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sup"},{style:"vertical-align",getAttrs:t=>"super"===t&&null}],renderHTML({HTMLAttributes:t}){return["sup",Ho(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),wg=Il.create({name:"subscript",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"sub"},{style:"vertical-align",getAttrs:t=>"sub"===t&&null}],renderHTML({HTMLAttributes:t}){return["sub",Ho(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}});const bg={openOnClick:!1,autolink:!0,HTMLAttributes:{rel:"noopener noreferrer nofollow",target:"_blank"}},yg={comment:{heading:!1,code:!1,codeBlock:!1,blockquote:!1,bulletList:!1,orderedList:!1,listItem:!1,horizontalRule:!1,strike:!1,underline:!1,link:bg},task:{heading:!1,codeBlock:!1,horizontalRule:!1,link:bg},email:{heading:{levels:[2,3]},code:!1,codeBlock:!1,horizontalRule:!1,link:bg},document:{heading:{levels:[1,2,3,4]},link:bg}},vg={comment:"compact",task:"basic",email:"full",document:"full"},kg={comment:2e3,task:1e4,email:null,document:null};function Mg(t="task",e={}){const{placeholder:n,maxLength:r,features:i={},includeUiExtensions:s=!0}=e,o=[Cp.configure(yg[t]??yg.task)];o.push(Hp,Ip),"comment"!==t&&o.push(Lm),"document"!==t&&"task"!==t||o.push(pg,mg);const l="document"===t;if(l&&o.push(ym,km,vm,Mm,Tm,xm,gg,wg),(l||"email"===t)&&o.push(pm.configure({types:["heading","paragraph"]})),(i.variables??("email"===t||"document"===t))&&o.push(mm),i.mentions&&o.push(gm),(i.image??"document"===t)&&o.push(zp.configure({inline:!0,allowBase64:!0,resize:{enabled:!0,directions:["top-left","top","top-right","left","right","bottom-left","bottom","bottom-right"],minWidth:50,minHeight:50}})),(i.table??"document"===t)&&o.push(nm.configure({resizable:!0}),Xp,Vp,Gp),(i.youtube??"document"===t)&&o.push(hm.configure({controls:!0,nocookie:!0})),(i.iframe??"document"===t)&&o.push(Up),(i.callout??"document"===t)&&o.push(bm),(i.highlight??"document"===t)&&o.push(dm.configure({multicolor:!0})),s){n&&o.push(Ap.configure({placeholder:n}));const t=r??i.characterCount;t&&o.push(gp.configure({limit:t}))}return o}function Tg(t){const e=t=>Array.from(t??[]).filter((t=>t.type.startsWith("image/"))),n=async(e,n,r)=>{if(!e.state.schema.nodes.image)return;let i;try{i=await(t=>new Promise(((e,n)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=n,r.readAsDataURL(t)})))(n)}catch{return}const s=e.state.schema.nodes.image.create({src:i}),o=null!=r?e.state.tr.insert(r,s):e.state.tr.replaceSelectionWith(s);e.dispatch(o);try{const r=await t(n),s="string"==typeof r?{src:r}:{src:r.src,dataFileId:r.fileId??null};let o=!1;e.state.doc.descendants(((t,n)=>{if(o)return!1;if("image"===t.type.name&&t.attrs.src===i){o=!0;const r=e.state.tr.setNodeMarkup(n,void 0,{...t.attrs,...s});return e.dispatch(r),!1}}))}catch{}};return{handlePaste(t,r){const i=e(r.clipboardData?.files);return!(!i.length||!t.state.schema.nodes.image||(r.preventDefault(),i.forEach((e=>n(t,e))),0))},handleDrop(t,r){if(t.dragging)return!1;const i=e(r.dataTransfer?.files);if(!i.length||!t.state.schema.nodes.image)return!1;r.preventDefault();const s=t.posAtCoords({left:r.clientX,top:r.clientY});return i.forEach((e=>n(t,e,s?.pos))),!0}}}const xg=["p","br","strong","em","a","span"],Lg=["href","target","rel","data-mention-id","data-mention-label"],Sg={comment:{ALLOWED_TAGS:[...xg],ALLOWED_ATTR:[...Lg],ALLOW_DATA_ATTR:!1},task:{ALLOWED_TAGS:[...xg,"u","s","code","ul","ol","li","blockquote","input","label"],ALLOWED_ATTR:[...Lg,"type","checked","disabled","data-type","data-checked","data-variant"],ALLOW_DATA_ATTR:!1},email:{ALLOWED_TAGS:[...xg,"u","s","code","ul","ol","li","blockquote","h2","h3","div","img"],ALLOWED_ATTR:[...Lg,"style","data-variable","src","alt","width","height","data-file-id","data-image-layout"],ALLOW_DATA_ATTR:!1},document:{ALLOWED_TAGS:[...xg,"u","s","code","ul","ol","li","blockquote","h1","h2","h3","h4","hr","div","mark","img","table","thead","tbody","tr","th","td","input","label","iframe"],ALLOWED_ATTR:[...Lg,"style","data-variable","colspan","rowspan","src","alt","width","height","type","checked","disabled","allowfullscreen","frameborder","allow","loading"],ALLOW_DATA_ATTR:!0}},Ag=/^https:\/\/[^\s"'<>]+$/i,Eg=["script","object","embed","form","textarea","style"],Og=["onerror","onload","onclick"];function $g(e,n="task"){if(!e)return"";const r=Sg[n]??Sg.task;t.addHook("uponSanitizeElement",((t,e)=>{if("input"===e.tagName&&"checkbox"!==t.type&&t.parentNode?.removeChild(t),"iframe"===e.tagName){const e=t.getAttribute("src")||"";Ag.test(e)||t.parentNode?.removeChild(t)}}));try{return t.sanitize(e,{ALLOWED_TAGS:r.ALLOWED_TAGS,ALLOWED_ATTR:r.ALLOWED_ATTR,ALLOW_DATA_ATTR:r.ALLOW_DATA_ATTR??!1,FORBID_TAGS:Eg,FORBID_ATTR:Og,ADD_ATTR:["target","allowfullscreen","frameborder","allow"]})}finally{t.removeHook("uponSanitizeElement")}}function Cg(t,e){return Mg(t,{includeUiExtensions:!1,features:e})}var Rg=Object.freeze({__proto__:null,COLOR_PALETTE:e,CalloutNode:bm,CobaltTaskItem:mg,CobaltTaskList:pg,FontFamilyExtension:km,FontSizeExtension:ym,FontWeightExtension:vm,IndentExtension:xm,LetterSpacingExtension:Tm,LineHeightExtension:Mm,ListStyleExtension:Lm,MentionNode:gm,PRESETS:["comment","task","email","document"],SANITIZE_CONFIGS:Sg,TABLE_CONTEXT_ITEMS:n,VariableNode:mm,createEditor:function(t={}){const{preset:e="task",element:n=null,content:r=null,editable:i=!0,placeholder:s,maxLength:o,features:l,customExtensions:u=[],bubbleMenuElement:a,imageUpload:h,onUpdate:c,onSelectionUpdate:f,onFocus:d,onBlur:p,onCreate:m,onDestroy:g,onContentError:w}=t,b=[...Mg(e,{placeholder:s,maxLength:o,features:l}),...u];let y;return a&&b.push(Bh.configure({element:a,updateDelay:150,shouldShow:({editor:t,state:e})=>{const{empty:n}=e.selection;return!t.isActive("codeBlock")&&!("NodeSelection"===e.selection.constructor.name||!t.isActive("table")&&n)},getReferencedVirtualElement:()=>{if(!y||!y.isActive("table"))return null;const{$from:t}=y.state.selection;for(let e=t.depth;e>0;e--)if("table"===t.node(e).type.name){const n=y.view.nodeDOM(t.before(e));if(n){const t=("TABLE"===n.tagName?n:n.querySelector("table"))||n;return{getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]}}break}return null},options:{placement:"bottom",offset:6,flip:{padding:8},shift:{padding:8},onHide:()=>{a.dispatchEvent(new Event("co-bubble-hide"))},onShow:()=>{a.dispatchEvent(new Event("co-bubble-show"))}}})),y=new Yl({...n?{element:n}:{},...h?{editorProps:Tg(h)}:{},extensions:b,content:r??"",editable:i,injectCSS:!1,enableContentCheck:!1,emitContentError:!0,onContentError:({error:t})=>w?.(t),onCreate:({editor:t})=>m?.(t),onUpdate:({editor:t})=>c?.(t),onSelectionUpdate:({editor:t})=>f?.(t),onFocus:({editor:t})=>d?.(t),onBlur:({editor:t})=>p?.(t),onDestroy:()=>g?.()}),y},defaultToolbarForPreset:function(t="task"){return vg[t]??"basic"},getExtensions:Mg,htmlToJson:function(t,e="task",n){return function(t,e){if("undefined"==typeof window)throw new Error("generateJSON can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");const n=_o(e),r=(new window.DOMParser).parseFromString(t,"text/html");if(!r)throw new Error("Failed to parse HTML string");return Z.fromSchema(n).parse(r.body,void 0).toJSON()}($g(t??"",e),Cg(e,n))},jsonToHtml:function(t,e="task",n){return function(t){if(!t)return!0;const e=t.content;return!Array.isArray(e)||0===e.length||e.every((t=>"paragraph"===t?.type&&(!t.content||0===t.content.length)))}(t)?"":$g(function(t,e){if("undefined"==typeof window)throw new Error("generateHTML can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");const n=_o(e);return function(t,e){if("undefined"==typeof window)throw new Error("getHTMLFromFragment can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");const n=window.document.createElement("div");return ut.fromSchema(e).serializeFragment(t.content,{document:window.document},n),n.innerHTML}(C.fromJSON(n,t),n)}(t,Cg(e,n)),e)},jsonToText:function(t){if(!t)return"";const e=new Set(["paragraph","heading","blockquote","listItem","bulletList","orderedList","codeBlock","horizontalRule"]),n=[],r=t=>{t&&("text"!==t.type||"string"!=typeof t.text?"variable"!==t.type?"mention"!==t.type?"hardBreak"!==t.type?(Array.isArray(t.content)&&t.content.forEach(r),e.has(t.type)&&n.push("\n")):n.push("\n"):n.push(`@${t.attrs?.label??""}`):n.push(`{{${t.attrs?.name??""}}}`):n.push(t.text))};return r(t),n.join("").replace(/\n{3,}/g,"\n\n").trim()},maxLengthForPreset:function(t="task"){return kg[t]??null},sanitize:$g,toolbarItems:r});export{Rg as R}