@vonage/vivid 5.25.0 → 5.28.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 (747) hide show
  1. package/accordion/index.cjs +1 -1
  2. package/accordion/index.js +8 -8
  3. package/accordion-item/index.cjs +1 -1
  4. package/action-group/index.cjs +3 -3
  5. package/action-group/index.js +10 -5
  6. package/alert/index.cjs +7 -7
  7. package/alert/index.js +47 -35
  8. package/audio-player/index.cjs +18 -18
  9. package/audio-player/index.js +15 -11
  10. package/avatar/index.cjs +9 -9
  11. package/avatar/index.js +27 -18
  12. package/badge/index.cjs +1 -1
  13. package/banner/index.cjs +5 -5
  14. package/banner/index.js +33 -27
  15. package/breadcrumb/index.cjs +1 -1
  16. package/breadcrumb/index.js +5 -1
  17. package/breadcrumb-item/index.cjs +1 -1
  18. package/breadcrumb-item/index.js +6 -6
  19. package/bundled/affix.cjs +3 -3
  20. package/bundled/affix.js +1 -1
  21. package/bundled/anchored.cjs +2 -2
  22. package/bundled/anchored.js +13 -1
  23. package/bundled/aria-binding-directive.cjs +1 -1
  24. package/bundled/aria-binding-directive.js +2 -2
  25. package/bundled/aria.cjs +1 -1
  26. package/bundled/base-color-picker.cjs +2 -2
  27. package/bundled/base-color-picker.js +1 -1
  28. package/bundled/base-progress.cjs +1 -1
  29. package/bundled/breadcrumb-item.cjs +1 -1
  30. package/bundled/button.cjs +1 -1
  31. package/bundled/calendar-event.cjs +1 -1
  32. package/bundled/calendar-event.js +17 -4
  33. package/bundled/calendar-picker.template.cjs +5 -5
  34. package/bundled/calendar-picker.template.js +56 -58
  35. package/bundled/char-count.cjs +2 -2
  36. package/bundled/children.cjs +1 -1
  37. package/bundled/children.js +1 -1
  38. package/bundled/class-names.cjs +1 -1
  39. package/bundled/component-enum.cjs +1 -0
  40. package/bundled/component-enum.js +9 -0
  41. package/bundled/data-grid.options.cjs +1 -1
  42. package/bundled/data-grid.options.js +7 -6
  43. package/bundled/decorate.cjs +1 -1
  44. package/bundled/decorate.js +1 -1
  45. package/bundled/definition.cjs +1 -1
  46. package/bundled/definition10.cjs +12 -18
  47. package/bundled/definition10.js +24 -69
  48. package/bundled/definition11.cjs +74 -10
  49. package/bundled/definition11.js +194 -24
  50. package/bundled/definition12.cjs +18 -70
  51. package/bundled/definition12.js +48 -186
  52. package/bundled/definition13.cjs +5 -22
  53. package/bundled/definition13.js +9 -58
  54. package/bundled/definition14.cjs +1 -5
  55. package/bundled/definition14.js +9 -9
  56. package/bundled/definition15.cjs +3 -3
  57. package/bundled/definition15.js +18 -18
  58. package/bundled/definition16.cjs +3 -3
  59. package/bundled/definition16.js +23 -17
  60. package/bundled/definition17.cjs +6 -6
  61. package/bundled/definition17.js +8 -8
  62. package/bundled/definition18.cjs +2 -2
  63. package/bundled/definition19.cjs +21 -21
  64. package/bundled/definition19.js +66 -61
  65. package/bundled/definition2.cjs +13 -1
  66. package/bundled/definition2.js +22 -185
  67. package/bundled/definition20.cjs +3 -3
  68. package/bundled/definition20.js +6 -7
  69. package/bundled/definition21.cjs +7 -7
  70. package/bundled/definition21.js +22 -23
  71. package/bundled/definition22.cjs +3 -3
  72. package/bundled/definition22.js +25 -25
  73. package/bundled/definition23.cjs +8 -4
  74. package/bundled/definition23.js +31 -9
  75. package/bundled/definition24.cjs +2 -2
  76. package/bundled/definition24.js +1 -1
  77. package/bundled/definition25.cjs +5 -5
  78. package/bundled/definition25.js +16 -11
  79. package/bundled/definition3.cjs +25 -12
  80. package/bundled/definition3.js +90 -21
  81. package/bundled/definition4.cjs +29 -25
  82. package/bundled/definition4.js +50 -89
  83. package/bundled/definition5.cjs +28 -29
  84. package/bundled/definition5.js +144 -45
  85. package/bundled/definition6.cjs +6 -29
  86. package/bundled/definition6.js +20 -130
  87. package/bundled/definition7.cjs +14 -6
  88. package/bundled/definition7.js +159 -20
  89. package/bundled/definition8.cjs +24 -14
  90. package/bundled/definition8.js +90 -144
  91. package/bundled/definition9.cjs +20 -22
  92. package/bundled/definition9.js +54 -80
  93. package/bundled/delegates-aria.cjs +1 -1
  94. package/bundled/delegates-aria.js +3 -2
  95. package/bundled/dialog.cjs +1 -1
  96. package/bundled/dialog.js +1 -1
  97. package/bundled/divider.cjs +1 -1
  98. package/bundled/divider.js +9 -9
  99. package/bundled/dom.cjs +1 -1
  100. package/bundled/enums.cjs +1 -1
  101. package/bundled/extractOptions.cjs +1 -1
  102. package/bundled/feedback-message.cjs +8 -0
  103. package/bundled/feedback-message.js +41 -0
  104. package/bundled/floating-ui.dom.cjs +1 -1
  105. package/bundled/floating-ui.dom.js +163 -197
  106. package/bundled/form-associated.cjs +1 -1
  107. package/bundled/form-associated.js +3 -4
  108. package/bundled/form-element.cjs +1 -1
  109. package/bundled/host-semantics.cjs +1 -1
  110. package/bundled/icon.cjs +1 -1
  111. package/bundled/kbd-shortcut.cjs +1 -1
  112. package/bundled/key-codes.cjs +1 -1
  113. package/bundled/linkable.cjs +2 -2
  114. package/bundled/listbox.cjs +1 -1
  115. package/bundled/listbox.js +3 -5
  116. package/bundled/localized.cjs +1 -1
  117. package/bundled/localized.js +45 -32
  118. package/bundled/mixins.cjs +9 -16
  119. package/bundled/mixins.js +23 -57
  120. package/bundled/numberConverter.cjs +2 -2
  121. package/bundled/numberConverter.js +1 -1
  122. package/bundled/numbers.cjs +1 -1
  123. package/bundled/optgroup.cjs +1 -1
  124. package/bundled/option.cjs +1 -1
  125. package/bundled/option.js +9 -7
  126. package/bundled/picker-field.template.cjs +2 -2
  127. package/bundled/picker-field.template.js +8 -8
  128. package/bundled/platform.cjs +1 -1
  129. package/bundled/playbackRates.cjs +1 -1
  130. package/bundled/ref.cjs +1 -1
  131. package/bundled/ref.js +1 -1
  132. package/bundled/render-in-light-dom.cjs +1 -1
  133. package/bundled/render-in-light-dom.js +4 -4
  134. package/bundled/repeat.cjs +1 -1
  135. package/bundled/repeat.js +16 -15
  136. package/bundled/scrollIntoView.cjs +1 -1
  137. package/bundled/scrollIntoView.js +1 -3
  138. package/bundled/single-date-picker.cjs +1 -1
  139. package/bundled/single-value-picker.cjs +1 -1
  140. package/bundled/single-value-picker.js +1 -1
  141. package/bundled/slider.template.cjs +12 -12
  142. package/bundled/slider.template.js +209 -32
  143. package/bundled/slottable-request.cjs +3 -3
  144. package/bundled/slottable-request.js +26 -17
  145. package/bundled/slotted.cjs +1 -1
  146. package/bundled/slotted.js +1 -1
  147. package/bundled/text-field.cjs +1 -1
  148. package/bundled/text-field.js +1 -1
  149. package/bundled/time-selection-picker.template.cjs +4 -4
  150. package/bundled/time-selection-picker.template.js +10 -7
  151. package/bundled/trapped-focus.cjs +1 -1
  152. package/bundled/utils.cjs +1 -1
  153. package/bundled/vivid-element.cjs +3 -3
  154. package/bundled/vivid-element.js +397 -358
  155. package/bundled/when.cjs +1 -1
  156. package/bundled/when.js +1 -1
  157. package/bundled/with-contextual-help.cjs +1 -1
  158. package/bundled/with-contextual-help.js +1 -1
  159. package/bundled/with-error-text.cjs +1 -1
  160. package/bundled/with-success-text.cjs +1 -1
  161. package/button/index.cjs +1 -1
  162. package/button/index.js +1 -1
  163. package/calendar/index.cjs +1 -1
  164. package/calendar/index.js +7 -7
  165. package/calendar-event/index.cjs +2 -2
  166. package/calendar-event/index.js +10 -8
  167. package/card/index.cjs +4 -2
  168. package/card/index.js +12 -7
  169. package/checkbox/index.cjs +1 -1
  170. package/color-picker/index.cjs +17 -17
  171. package/color-picker/index.js +19 -17
  172. package/combobox/index.cjs +9 -9
  173. package/combobox/index.js +46 -44
  174. package/contextual-help/index.cjs +1 -1
  175. package/contextual-help/index.js +1 -1
  176. package/country/index.cjs +1 -1
  177. package/country-group/index.cjs +1 -1
  178. package/country-group/index.js +8 -4
  179. package/custom-elements.json +9302 -9180
  180. package/data-grid/index.cjs +6 -6
  181. package/data-grid/index.js +92 -99
  182. package/date-picker/index.cjs +1 -1
  183. package/date-picker/index.js +10 -6
  184. package/date-range-picker/index.cjs +1 -1
  185. package/date-range-picker/index.js +13 -9
  186. package/date-time-picker/index.cjs +1 -1
  187. package/date-time-picker/index.js +11 -7
  188. package/dial-pad/index.cjs +4 -3
  189. package/dial-pad/index.js +14 -9
  190. package/dialog/index.cjs +1 -1
  191. package/dialog/index.js +9 -6
  192. package/divider/index.cjs +1 -1
  193. package/elevation/definition.cjs +1 -0
  194. package/elevation/definition.js +2 -2
  195. package/elevation/index.cjs +1 -1
  196. package/elevation/index.js +1 -1
  197. package/empty-state/index.cjs +3 -3
  198. package/empty-state/index.js +18 -6
  199. package/fab/index.cjs +3 -3
  200. package/fab/index.js +14 -6
  201. package/file-picker/index.cjs +8 -10
  202. package/file-picker/index.js +25 -22
  203. package/flag/index.cjs +1 -1
  204. package/flag/index.js +7 -3
  205. package/form-field/definition.cjs +5 -0
  206. package/form-field/definition.js +2 -0
  207. package/form-field/index.cjs +29 -0
  208. package/form-field/index.js +57 -0
  209. package/header/definition.cjs +1 -1
  210. package/header/definition.js +1 -1
  211. package/header/index.cjs +1 -1
  212. package/header/index.js +9 -5
  213. package/icon/index.cjs +1 -1
  214. package/icon/index.js +1 -1
  215. package/index.cjs +159 -154
  216. package/index.js +42 -40
  217. package/kbd-key/definition.cjs +1 -1
  218. package/kbd-key/definition.js +1 -1
  219. package/kbd-key/index.cjs +3 -3
  220. package/kbd-key/index.js +22 -13
  221. package/kbd-shortcut/definition.cjs +1 -1
  222. package/kbd-shortcut/definition.js +1 -1
  223. package/kbd-shortcut/index.cjs +1 -1
  224. package/kbd-shortcut/index.js +6 -6
  225. package/layout/definition.cjs +1 -1
  226. package/layout/definition.js +1 -1
  227. package/layout/index.cjs +1 -1
  228. package/layout/index.js +7 -3
  229. package/lib/accordion-item/accordion-item.d.ts +11 -6
  230. package/lib/action-group/action-group.d.ts +10 -5
  231. package/lib/alert/alert.d.ts +15 -18
  232. package/lib/avatar/avatar.d.ts +16 -7
  233. package/lib/badge/badge.d.ts +18 -7
  234. package/lib/badge/badge.template.d.ts +2 -1
  235. package/lib/banner/banner.d.ts +18 -20
  236. package/lib/button/button.d.ts +25 -16
  237. package/lib/calendar-event/calendar-event.d.ts +14 -7
  238. package/lib/checkbox/checkbox.d.ts +31 -28
  239. package/lib/combobox/combobox.d.ts +37 -32
  240. package/lib/components.d.ts +1 -0
  241. package/lib/data-grid/data-grid.options.d.ts +6 -1
  242. package/lib/dial-pad/locale.d.ts +1 -0
  243. package/lib/divider/divider.d.ts +9 -6
  244. package/lib/elevation/definition.d.ts +2 -0
  245. package/lib/empty-state/empty-state.d.ts +7 -2
  246. package/lib/fab/fab.d.ts +3 -2
  247. package/lib/form-field/definition.d.ts +4 -0
  248. package/lib/form-field/form-field.d.ts +6 -0
  249. package/lib/form-field/form-field.template.d.ts +3 -0
  250. package/lib/icon/icon.d.ts +1 -1
  251. package/lib/kbd-key/kbd-key.d.ts +7 -2
  252. package/lib/listbox/listbox.d.ts +1 -0
  253. package/lib/menu-item/menu-item.d.ts +17 -14
  254. package/lib/nav-disclosure/nav-disclosure.d.ts +18 -11
  255. package/lib/nav-item/nav-item.d.ts +19 -12
  256. package/lib/note/note.d.ts +10 -6
  257. package/lib/number-field/number-field.d.ts +45 -40
  258. package/lib/option/option.d.ts +13 -10
  259. package/lib/popover/popover.d.ts +2 -1
  260. package/lib/popup/definition.d.ts +2 -0
  261. package/lib/progress/progress.d.ts +10 -5
  262. package/lib/progress-ring/progress-ring.d.ts +10 -6
  263. package/lib/radio/radio.d.ts +18 -15
  264. package/lib/range-slider/range-slider.d.ts +19 -15
  265. package/lib/rich-text-editor/rich-text-editor.d.ts +436 -5
  266. package/lib/rich-text-editor/rte/__tests__/async-generator.d.ts +1 -0
  267. package/lib/rich-text-editor/rte/features/atom.d.ts +6 -2
  268. package/lib/rich-text-editor/rte/instance.d.ts +2 -1
  269. package/lib/rich-text-editor/rte/utils/ui.d.ts +2 -1
  270. package/lib/searchable-select/option-tag.d.ts +12 -7
  271. package/lib/searchable-select/searchable-select.d.ts +7 -2
  272. package/lib/select/select.d.ts +45 -40
  273. package/lib/selectable-box/selectable-box.d.ts +9 -5
  274. package/lib/slider/slider.d.ts +18 -14
  275. package/lib/split-button/split-button.d.ts +24 -15
  276. package/lib/status/status.d.ts +10 -7
  277. package/lib/switch/switch.d.ts +13 -9
  278. package/lib/tab/tab.d.ts +19 -14
  279. package/lib/table/locale.d.ts +10 -0
  280. package/lib/table/table-sorting-button.d.ts +425 -0
  281. package/lib/tabs/tabs.d.ts +6 -3
  282. package/lib/tag/tag.d.ts +24 -15
  283. package/lib/tag-name-map.d.ts +2 -1
  284. package/lib/text-field/text-field.d.ts +46 -41
  285. package/lib/video-player/__tests__/video-fixtures.d.ts +3 -0
  286. package/listbox/definition.cjs +1 -1
  287. package/listbox/definition.js +1 -1
  288. package/listbox/index.cjs +7 -5
  289. package/listbox/index.js +24 -10
  290. package/locales/de-DE.cjs +46 -33
  291. package/locales/de-DE.js +46 -33
  292. package/locales/en-GB.cjs +46 -33
  293. package/locales/en-GB.js +46 -33
  294. package/locales/ja-JP.cjs +47 -33
  295. package/locales/ja-JP.js +47 -33
  296. package/locales/zh-CN.cjs +46 -33
  297. package/locales/zh-CN.js +46 -33
  298. package/menu/index.cjs +1 -1
  299. package/menu-item/index.cjs +1 -1
  300. package/nav/definition.cjs +1 -1
  301. package/nav/definition.js +1 -1
  302. package/nav/index.cjs +1 -1
  303. package/nav/index.js +6 -4
  304. package/nav-disclosure/definition.cjs +1 -1
  305. package/nav-disclosure/definition.js +1 -1
  306. package/nav-disclosure/index.cjs +3 -3
  307. package/nav-disclosure/index.js +13 -8
  308. package/nav-item/definition.cjs +1 -1
  309. package/nav-item/definition.js +1 -1
  310. package/nav-item/index.cjs +2 -2
  311. package/nav-item/index.js +15 -10
  312. package/note/definition.cjs +1 -1
  313. package/note/definition.js +1 -1
  314. package/note/index.cjs +6 -4
  315. package/note/index.js +22 -9
  316. package/number-field/definition.cjs +1 -1
  317. package/number-field/definition.js +1 -1
  318. package/number-field/index.cjs +11 -11
  319. package/number-field/index.js +41 -36
  320. package/optgroup/index.cjs +1 -1
  321. package/option/index.cjs +1 -1
  322. package/package.json +29 -36
  323. package/pagination/definition.cjs +1 -1
  324. package/pagination/definition.js +1 -1
  325. package/pagination/index.cjs +1 -1
  326. package/pagination/index.js +9 -9
  327. package/platform-switch/definition.cjs +1 -1
  328. package/platform-switch/definition.js +1 -1
  329. package/platform-switch/index.cjs +1 -1
  330. package/platform-switch/index.js +6 -2
  331. package/popover/definition.cjs +1 -1
  332. package/popover/definition.js +1 -1
  333. package/popover/index.cjs +2 -2
  334. package/popover/index.js +82 -41
  335. package/popup/definition.cjs +1 -0
  336. package/popup/definition.js +2 -2
  337. package/popup/index.cjs +1 -1
  338. package/popup/index.js +1 -1
  339. package/progress/definition.cjs +1 -1
  340. package/progress/definition.js +1 -1
  341. package/progress/index.cjs +7 -7
  342. package/progress/index.js +21 -11
  343. package/progress-ring/index.cjs +1 -1
  344. package/progress-ring/index.js +1 -1
  345. package/radio/definition.cjs +1 -1
  346. package/radio/definition.js +1 -1
  347. package/radio/index.cjs +1 -1
  348. package/radio-group/definition.cjs +1 -1
  349. package/radio-group/definition.js +1 -1
  350. package/radio-group/index.cjs +2 -2
  351. package/radio-group/index.js +14 -9
  352. package/range-slider/definition.cjs +1 -1
  353. package/range-slider/definition.js +1 -1
  354. package/range-slider/index.cjs +8 -8
  355. package/range-slider/index.js +31 -32
  356. package/rich-text-editor/definition.cjs +1 -1
  357. package/rich-text-editor/definition.js +1 -1
  358. package/rich-text-editor/index.cjs +25 -16
  359. package/rich-text-editor/index.js +2450 -2154
  360. package/rich-text-view/definition.cjs +1 -1
  361. package/rich-text-view/definition.js +1 -1
  362. package/rich-text-view/index.cjs +1 -1
  363. package/rich-text-view/index.js +6 -4
  364. package/searchable-select/definition.cjs +1 -1
  365. package/searchable-select/definition.js +1 -1
  366. package/searchable-select/index.cjs +22 -22
  367. package/searchable-select/index.js +97 -93
  368. package/select/definition.cjs +1 -1
  369. package/select/definition.js +1 -1
  370. package/select/index.cjs +1 -1
  371. package/selectable-box/definition.cjs +1 -1
  372. package/selectable-box/definition.js +1 -1
  373. package/selectable-box/index.cjs +8 -8
  374. package/selectable-box/index.js +24 -20
  375. package/shared/localization/Locale.d.ts +2 -0
  376. package/shared/patterns/anchored.d.ts +2 -0
  377. package/shared/styles/appearance.d.ts +2 -0
  378. package/shared/styles/connotation.d.ts +2 -0
  379. package/shared/styles/connotationOverrides.d.ts +1 -0
  380. package/shared/utils/component-enum.d.ts +7 -0
  381. package/side-drawer/definition.cjs +1 -1
  382. package/side-drawer/definition.js +1 -1
  383. package/side-drawer/index.cjs +1 -1
  384. package/side-drawer/index.js +10 -7
  385. package/simple-color-picker/definition.cjs +1 -1
  386. package/simple-color-picker/definition.js +1 -1
  387. package/simple-color-picker/index.cjs +2 -2
  388. package/simple-color-picker/index.js +20 -20
  389. package/slider/definition.cjs +2 -1
  390. package/slider/definition.js +2 -1
  391. package/slider/index.cjs +1 -1
  392. package/slider/index.js +1 -1
  393. package/split-button/definition.cjs +1 -1
  394. package/split-button/definition.js +1 -1
  395. package/split-button/index.cjs +9 -7
  396. package/split-button/index.js +58 -37
  397. package/status/definition.cjs +1 -1
  398. package/status/definition.js +1 -1
  399. package/status/index.cjs +5 -5
  400. package/status/index.js +22 -13
  401. package/switch/definition.cjs +1 -1
  402. package/switch/definition.js +1 -1
  403. package/switch/index.cjs +3 -3
  404. package/switch/index.js +22 -11
  405. package/tab/definition.cjs +1 -1
  406. package/tab/definition.js +1 -1
  407. package/tab/index.cjs +1 -1
  408. package/tab/index.js +1 -1
  409. package/tab-panel/definition.cjs +1 -1
  410. package/tab-panel/definition.js +1 -1
  411. package/tab-panel/index.cjs +1 -1
  412. package/tab-panel/index.js +1 -1
  413. package/table/definition.cjs +1 -1
  414. package/table/definition.js +1 -1
  415. package/table/index.cjs +20 -18
  416. package/table/index.js +54 -42
  417. package/tabs/definition.cjs +1 -1
  418. package/tabs/definition.js +1 -1
  419. package/tabs/index.cjs +4 -4
  420. package/tabs/index.js +32 -30
  421. package/tag/definition.cjs +1 -1
  422. package/tag/definition.js +1 -1
  423. package/tag/index.cjs +6 -6
  424. package/tag/index.js +28 -12
  425. package/tag-group/definition.cjs +1 -1
  426. package/tag-group/definition.js +1 -1
  427. package/tag-group/index.cjs +1 -1
  428. package/tag-group/index.js +6 -4
  429. package/text-area/definition.cjs +1 -1
  430. package/text-area/definition.js +1 -1
  431. package/text-area/index.cjs +5 -5
  432. package/text-area/index.js +18 -15
  433. package/text-field/index.cjs +1 -1
  434. package/text-field/index.js +1 -1
  435. package/time-picker/definition.cjs +1 -1
  436. package/time-picker/definition.js +1 -1
  437. package/time-picker/index.cjs +1 -1
  438. package/time-picker/index.js +9 -6
  439. package/toggletip/index.cjs +1 -1
  440. package/toggletip/index.js +1 -1
  441. package/tooltip/index.cjs +1 -1
  442. package/tooltip/index.js +1 -1
  443. package/tree-item/definition.cjs +1 -1
  444. package/tree-item/definition.js +1 -1
  445. package/tree-item/index.cjs +1 -1
  446. package/tree-item/index.js +1 -1
  447. package/tree-view/definition.cjs +1 -1
  448. package/tree-view/definition.js +1 -1
  449. package/tree-view/index.cjs +1 -1
  450. package/tree-view/index.js +7 -5
  451. package/unbundled/affix.cjs +0 -1
  452. package/unbundled/anchored.cjs +39 -1
  453. package/unbundled/anchored.js +28 -1
  454. package/unbundled/aria-binding-directive.cjs +2 -2
  455. package/unbundled/aria-binding-directive.js +2 -1
  456. package/unbundled/base-color-picker.cjs +0 -1
  457. package/unbundled/base-progress.cjs +0 -1
  458. package/unbundled/breadcrumb-item.cjs +0 -1
  459. package/unbundled/button.cjs +0 -1
  460. package/unbundled/calendar-event.cjs +29 -1
  461. package/unbundled/calendar-event.js +18 -1
  462. package/unbundled/calendar-picker.template.cjs +109 -91
  463. package/unbundled/calendar-picker.template.js +109 -90
  464. package/unbundled/char-count.cjs +0 -1
  465. package/unbundled/component-enum.cjs +18 -0
  466. package/unbundled/component-enum.js +13 -0
  467. package/unbundled/data-grid.options.cjs +8 -0
  468. package/unbundled/data-grid.options.js +3 -1
  469. package/unbundled/decorate.cjs +1 -1
  470. package/unbundled/decorate.js +1 -1
  471. package/unbundled/definition.cjs +1 -2
  472. package/unbundled/definition.js +1 -1
  473. package/unbundled/definition10.cjs +2 -343
  474. package/unbundled/definition10.js +4 -338
  475. package/unbundled/definition11.cjs +6 -7
  476. package/unbundled/definition11.js +6 -6
  477. package/unbundled/definition12.cjs +4 -4
  478. package/unbundled/definition12.js +5 -4
  479. package/unbundled/definition13.cjs +2 -2
  480. package/unbundled/definition13.js +2 -1
  481. package/unbundled/definition14.cjs +12 -4
  482. package/unbundled/definition14.js +12 -3
  483. package/unbundled/definition15.cjs +32 -6
  484. package/unbundled/definition15.js +32 -5
  485. package/unbundled/definition16.cjs +20 -14
  486. package/unbundled/definition16.js +20 -13
  487. package/unbundled/definition17.cjs +0 -1
  488. package/unbundled/definition18.cjs +4 -3
  489. package/unbundled/definition18.js +4 -2
  490. package/unbundled/definition19.cjs +2 -3
  491. package/unbundled/definition19.js +9 -8
  492. package/unbundled/definition2.cjs +9 -4
  493. package/unbundled/definition2.js +9 -3
  494. package/unbundled/definition20.cjs +1 -2
  495. package/unbundled/definition20.js +7 -6
  496. package/unbundled/definition21.cjs +4 -3
  497. package/unbundled/definition21.js +4 -2
  498. package/unbundled/definition22.cjs +0 -1
  499. package/unbundled/definition23.cjs +12 -6
  500. package/unbundled/definition23.js +11 -4
  501. package/unbundled/definition24.cjs +8 -8
  502. package/unbundled/definition24.js +9 -8
  503. package/unbundled/definition25.cjs +7 -4
  504. package/unbundled/definition25.js +7 -3
  505. package/unbundled/definition26.cjs +6 -4
  506. package/unbundled/definition26.js +5 -2
  507. package/unbundled/definition27.cjs +10 -7
  508. package/unbundled/definition27.js +10 -6
  509. package/unbundled/definition28.cjs +3 -3
  510. package/unbundled/definition28.js +2 -1
  511. package/unbundled/definition29.cjs +2 -3
  512. package/unbundled/definition29.js +3 -3
  513. package/unbundled/definition3.cjs +5 -6
  514. package/unbundled/definition3.js +5 -5
  515. package/unbundled/definition30.cjs +0 -1
  516. package/unbundled/definition31.cjs +15 -13
  517. package/unbundled/definition31.js +14 -11
  518. package/unbundled/definition32.cjs +0 -1
  519. package/unbundled/definition33.cjs +0 -1
  520. package/unbundled/definition34.cjs +0 -1
  521. package/unbundled/definition35.cjs +39 -51
  522. package/unbundled/definition35.js +40 -51
  523. package/unbundled/definition36.cjs +2 -3
  524. package/unbundled/definition36.js +9 -8
  525. package/unbundled/definition37.cjs +0 -1
  526. package/unbundled/definition38.cjs +0 -1
  527. package/unbundled/definition39.cjs +0 -1
  528. package/unbundled/definition4.cjs +4 -3
  529. package/unbundled/definition4.js +11 -6
  530. package/unbundled/definition40.cjs +5 -4
  531. package/unbundled/definition40.js +5 -3
  532. package/unbundled/definition41.cjs +0 -1
  533. package/unbundled/definition42.cjs +11 -3
  534. package/unbundled/definition42.js +11 -2
  535. package/unbundled/definition43.cjs +7 -3
  536. package/unbundled/definition43.js +7 -2
  537. package/unbundled/definition44.cjs +12 -11
  538. package/unbundled/definition44.js +11 -9
  539. package/unbundled/definition45.cjs +73 -52
  540. package/unbundled/definition45.js +69 -47
  541. package/unbundled/definition46.cjs +53 -46
  542. package/unbundled/definition46.js +49 -41
  543. package/unbundled/definition47.cjs +40 -165
  544. package/unbundled/definition47.js +36 -160
  545. package/unbundled/definition48.cjs +177 -32
  546. package/unbundled/definition48.js +174 -22
  547. package/unbundled/definition49.cjs +32 -596
  548. package/unbundled/definition49.js +29 -591
  549. package/unbundled/definition5.cjs +9 -3
  550. package/unbundled/definition5.js +15 -7
  551. package/unbundled/definition50.cjs +609 -78
  552. package/unbundled/definition50.js +605 -75
  553. package/unbundled/definition51.cjs +74 -34
  554. package/unbundled/definition51.js +70 -29
  555. package/unbundled/definition52.cjs +59 -24
  556. package/unbundled/definition52.js +57 -18
  557. package/unbundled/definition53.cjs +23 -40
  558. package/unbundled/definition53.js +19 -35
  559. package/unbundled/definition54.cjs +40 -316
  560. package/unbundled/definition54.js +38 -313
  561. package/unbundled/definition55.cjs +305 -196
  562. package/unbundled/definition55.js +301 -191
  563. package/unbundled/definition56.cjs +210 -41
  564. package/unbundled/definition56.js +206 -36
  565. package/unbundled/definition57.cjs +42 -271
  566. package/unbundled/definition57.js +38 -266
  567. package/unbundled/definition58.cjs +351 -51
  568. package/unbundled/definition58.js +348 -46
  569. package/unbundled/definition59.cjs +58 -147
  570. package/unbundled/definition59.js +59 -144
  571. package/unbundled/definition6.cjs +22 -7
  572. package/unbundled/definition6.js +22 -6
  573. package/unbundled/definition60.cjs +129 -226
  574. package/unbundled/definition60.js +126 -222
  575. package/unbundled/definition61.cjs +200 -420
  576. package/unbundled/definition61.js +197 -416
  577. package/unbundled/definition62.cjs +442 -3743
  578. package/unbundled/definition62.js +433 -3570
  579. package/unbundled/definition63.cjs +3788 -729
  580. package/unbundled/definition63.js +3617 -721
  581. package/unbundled/definition64.cjs +784 -98
  582. package/unbundled/definition64.js +781 -94
  583. package/unbundled/definition65.cjs +100 -1003
  584. package/unbundled/definition65.js +98 -997
  585. package/unbundled/definition66.cjs +996 -94
  586. package/unbundled/definition66.js +992 -89
  587. package/unbundled/definition67.cjs +111 -74
  588. package/unbundled/definition67.js +107 -63
  589. package/unbundled/definition68.cjs +69 -157
  590. package/unbundled/definition68.js +65 -152
  591. package/unbundled/definition69.cjs +156 -120
  592. package/unbundled/definition69.js +152 -115
  593. package/unbundled/definition7.cjs +0 -1
  594. package/unbundled/definition7.js +10 -4
  595. package/unbundled/definition70.cjs +154 -50
  596. package/unbundled/definition70.js +150 -45
  597. package/unbundled/definition71.cjs +58 -86
  598. package/unbundled/definition71.js +57 -81
  599. package/unbundled/definition72.cjs +99 -20
  600. package/unbundled/definition72.js +98 -15
  601. package/unbundled/definition73.cjs +20 -89
  602. package/unbundled/definition73.js +16 -84
  603. package/unbundled/definition74.cjs +79 -296
  604. package/unbundled/definition74.js +73 -217
  605. package/unbundled/definition75.cjs +304 -312
  606. package/unbundled/definition75.js +232 -304
  607. package/unbundled/definition76.cjs +328 -27
  608. package/unbundled/definition76.js +320 -23
  609. package/unbundled/definition77.cjs +27 -125
  610. package/unbundled/definition77.js +23 -120
  611. package/unbundled/definition78.cjs +120 -233
  612. package/unbundled/definition78.js +116 -228
  613. package/unbundled/definition79.cjs +258 -26
  614. package/unbundled/definition79.js +249 -23
  615. package/unbundled/definition8.cjs +19 -12
  616. package/unbundled/definition8.js +19 -11
  617. package/unbundled/definition80.cjs +29 -149
  618. package/unbundled/definition80.js +27 -134
  619. package/unbundled/definition81.cjs +118 -174
  620. package/unbundled/definition81.js +109 -169
  621. package/unbundled/definition82.cjs +180 -477
  622. package/unbundled/definition82.js +178 -472
  623. package/unbundled/definition83.cjs +517 -0
  624. package/unbundled/definition83.js +498 -0
  625. package/unbundled/definition9.cjs +4 -3
  626. package/unbundled/definition9.js +4 -2
  627. package/unbundled/delegates-aria.cjs +4 -2
  628. package/unbundled/delegates-aria.js +4 -2
  629. package/unbundled/divider.cjs +8 -3
  630. package/unbundled/divider.js +3 -3
  631. package/unbundled/en-US.cjs +46 -33
  632. package/unbundled/en-US.js +46 -33
  633. package/unbundled/feedback-message.cjs +59 -0
  634. package/unbundled/feedback-message.js +48 -0
  635. package/unbundled/form-associated.cjs +1 -4
  636. package/unbundled/form-associated.js +1 -3
  637. package/unbundled/form-element.cjs +0 -1
  638. package/unbundled/icon.cjs +0 -1
  639. package/unbundled/kbd-shortcut.cjs +0 -1
  640. package/unbundled/linkable.cjs +1 -2
  641. package/unbundled/linkable.js +1 -1
  642. package/unbundled/listbox.cjs +0 -2
  643. package/unbundled/listbox.js +0 -1
  644. package/unbundled/localized.cjs +0 -1
  645. package/unbundled/mixins.cjs +3 -54
  646. package/unbundled/mixins.js +3 -47
  647. package/unbundled/numberConverter.cjs +8 -3
  648. package/unbundled/numberConverter.js +8 -3
  649. package/unbundled/optgroup.cjs +0 -1
  650. package/unbundled/option.cjs +8 -1
  651. package/unbundled/option.js +3 -1
  652. package/unbundled/picker-field.template.cjs +1 -2
  653. package/unbundled/picker-field.template.js +1 -1
  654. package/unbundled/randomId.cjs +0 -1
  655. package/unbundled/{chunk.cjs → rolldown-runtime.cjs} +1 -1
  656. package/unbundled/scrollIntoView.cjs +0 -1
  657. package/unbundled/scrollIntoView.js +0 -1
  658. package/unbundled/slider.template.cjs +340 -2
  659. package/unbundled/slider.template.js +338 -5
  660. package/unbundled/text-field.cjs +1 -1
  661. package/unbundled/text-field.js +1 -1
  662. package/unbundled/time-selection-picker.template.cjs +2 -3
  663. package/unbundled/time-selection-picker.template.js +2 -2
  664. package/unbundled/vivid-element.cjs +63 -4
  665. package/unbundled/vivid-element.js +63 -3
  666. package/unbundled/with-contextual-help.cjs +0 -1
  667. package/unbundled/with-error-text.cjs +0 -1
  668. package/unbundled/with-success-text.cjs +0 -1
  669. package/video-player/definition.cjs +1 -1
  670. package/video-player/definition.js +1 -1
  671. package/video-player/index.cjs +31 -31
  672. package/video-player/index.js +2094 -2085
  673. package/visually-hidden/index.cjs +1 -1
  674. package/vivid.api.json +509 -1125
  675. package/lib/accordion/variations.browser-spec.d.ts +0 -1
  676. package/lib/action-group/variations.browser-spec.d.ts +0 -1
  677. package/lib/alert/variations.browser-spec.d.ts +0 -1
  678. package/lib/audio-player/variations.browser-spec.d.ts +0 -1
  679. package/lib/avatar/variations.browser-spec.d.ts +0 -1
  680. package/lib/badge/variations.browser-spec.d.ts +0 -1
  681. package/lib/banner/variations.browser-spec.d.ts +0 -1
  682. package/lib/breadcrumb-item/variations.browser-spec.d.ts +0 -1
  683. package/lib/button/variations.browser-spec.d.ts +0 -1
  684. package/lib/calendar/variations.browser-spec.d.ts +0 -1
  685. package/lib/calendar-event/variations.browser-spec.d.ts +0 -1
  686. package/lib/card/variations.browser-spec.d.ts +0 -1
  687. package/lib/checkbox/variations.browser-spec.d.ts +0 -1
  688. package/lib/color-picker/variations.browser-spec.d.ts +0 -1
  689. package/lib/combobox/variations.browser-spec.d.ts +0 -1
  690. package/lib/contextual-help/variations.browser-spec.d.ts +0 -1
  691. package/lib/country/variations.browser-spec.d.ts +0 -1
  692. package/lib/data-grid/variations.browser-spec.d.ts +0 -1
  693. package/lib/date-picker/variations.browser-spec.d.ts +0 -1
  694. package/lib/date-range-picker/variations.browser-spec.d.ts +0 -1
  695. package/lib/date-time-picker/variations.browser-spec.d.ts +0 -1
  696. package/lib/dial-pad/variations.browser-spec.d.ts +0 -1
  697. package/lib/dialog/variations.browser-spec.d.ts +0 -1
  698. package/lib/divider/variations.browser-spec.d.ts +0 -1
  699. package/lib/empty-state/variations.browser-spec.d.ts +0 -1
  700. package/lib/fab/variations.browser-spec.d.ts +0 -1
  701. package/lib/file-picker/variations.browser-spec.d.ts +0 -1
  702. package/lib/flag/variations.browser-spec.d.ts +0 -1
  703. package/lib/header/variations.browser-spec.d.ts +0 -1
  704. package/lib/icon/variations.browser-spec.d.ts +0 -1
  705. package/lib/kbd-key/variations.browser-spec.d.ts +0 -1
  706. package/lib/kbd-shortcut/variations.browser-spec.d.ts +0 -1
  707. package/lib/layout/variations.browser-spec.d.ts +0 -1
  708. package/lib/listbox/variations.browser-spec.d.ts +0 -1
  709. package/lib/menu/variations.browser-spec.d.ts +0 -1
  710. package/lib/menu-item/variations.browser-spec.d.ts +0 -1
  711. package/lib/nav/variations.browser-spec.d.ts +0 -1
  712. package/lib/nav-disclosure/variations.browser-spec.d.ts +0 -1
  713. package/lib/nav-item/variations.browser-spec.d.ts +0 -1
  714. package/lib/note/variations.browser-spec.d.ts +0 -1
  715. package/lib/number-field/variations.browser-spec.d.ts +0 -1
  716. package/lib/optgroup/variations.browser-spec.d.ts +0 -1
  717. package/lib/option/variations.browser-spec.d.ts +0 -1
  718. package/lib/pagination/variations.browser-spec.d.ts +0 -1
  719. package/lib/popover/variations.browser-spec.d.ts +0 -1
  720. package/lib/progress/variations.browser-spec.d.ts +0 -1
  721. package/lib/progress-ring/variations.browser-spec.d.ts +0 -1
  722. package/lib/radio/variations.browser-spec.d.ts +0 -1
  723. package/lib/radio-group/variations.browser-spec.d.ts +0 -1
  724. package/lib/range-slider/variations.browser-spec.d.ts +0 -1
  725. package/lib/rich-text-editor/variations.browser-spec.d.ts +0 -1
  726. package/lib/rich-text-view/variations.browser-spec.d.ts +0 -1
  727. package/lib/searchable-select/variations.browser-spec.d.ts +0 -1
  728. package/lib/select/variations.browser-spec.d.ts +0 -1
  729. package/lib/selectable-box/variations.browser-spec.d.ts +0 -1
  730. package/lib/side-drawer/variations.browser-spec.d.ts +0 -1
  731. package/lib/simple-color-picker/variations.browser-spec.d.ts +0 -1
  732. package/lib/slider/variations.browser-spec.d.ts +0 -1
  733. package/lib/split-button/variations.browser-spec.d.ts +0 -1
  734. package/lib/status/variations.browser-spec.d.ts +0 -1
  735. package/lib/switch/variations.browser-spec.d.ts +0 -1
  736. package/lib/table/variations.browser-spec.d.ts +0 -1
  737. package/lib/tabs/variations.browser-spec.d.ts +0 -1
  738. package/lib/tag/variations.browser-spec.d.ts +0 -1
  739. package/lib/text-area/variations.browser-spec.d.ts +0 -1
  740. package/lib/text-field/variations.browser-spec.d.ts +0 -1
  741. package/lib/time-picker/variations.browser-spec.d.ts +0 -1
  742. package/lib/toggletip/variations.browser-spec.d.ts +0 -1
  743. package/lib/tooltip/variations.browser-spec.d.ts +0 -1
  744. package/lib/tree-item/variations.browser-spec.d.ts +0 -1
  745. package/lib/video-player/variations.browser-spec.d.ts +0 -1
  746. /package/lib/{accordion-item/variations.browser-spec.d.ts → form-field/index.d.ts} +0 -0
  747. /package/unbundled/{chunk.js → rolldown-runtime.js} +0 -0
@@ -1,10 +1,18 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../bundled/localized.cjs`),t=require(`../bundled/vivid-element.cjs`),n=require(`../bundled/ref.cjs`),r=require(`../bundled/decorate.cjs`),i=require(`../bundled/definition5.cjs`),a=require(`../bundled/definition6.cjs`),o=require(`../bundled/definition8.cjs`),s=require(`../bundled/definition9.cjs`),c=require(`../bundled/render-in-light-dom.cjs`),l=require(`../bundled/definition12.cjs`),u=require(`../bundled/option.cjs`),d=require(`../bundled/definition17.cjs`),f=require(`../bundled/definition19.cjs`),p=require(`../bundled/definition20.cjs`),m=require(`../bundled/divider.cjs`),h=require(`../bundled/slottable-request.cjs`),g=require(`../bundled/definition21.cjs`),ee=require(`../bundled/definition22.cjs`);var te=`:host{display:block}.rte{--editor-padding-inline:var(--rich-text-editor-padding-inline,16px);--editor-padding-block:var(--rich-text-editor-padding-block,8px);block-size:100%;max-block-size:inherit;min-block-size:inherit;flex-direction:column;display:flex}.editor{display:contents}.editor-viewport{contain:layout;flex-direction:column;flex:1;min-block-size:0;display:flex;position:relative;overflow:hidden}.editor-scroll-area{background-color:var(--vvd-color-canvas);color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);--scrollbar-track-color:transparent;--scrollbar-thumb-color:color-mix(in sRGB, var(--vvd-color-neutral-950), transparent 70%);scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin;flex-direction:column;flex:1;min-block-size:0;display:flex;overflow-y:auto}.editor-scroll-area ::-webkit-scrollbar{width:4px}.editor-scroll-area ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.editor-scroll-area ::-webkit-scrollbar-thumb{background-color:var(--scrollbar-fallback-track-color,var(--scrollbar-thumb-color));border:0;border-radius:4px}.popovers--disabled>*{display:none!important}`,_=class extends e.n(t.t){instanceChanged(e){e?.[h.c].destroyViewIfNeeded(),this._initViewIfNeeded(),e?.[h.c].styles.removeStylesFrom(this.shadowRoot),this.instance?.[h.c].styles.addStylesTo(this.shadowRoot)}_initViewIfNeeded(){let e=this.instance?.[h.c];e&&this.$fastController.isConnected&&!e.view&&(this._syncStateIfNeeded(),e.createView(this._editorEl))}_destroyViewIfNeeded(){this.instance?.[h.c].destroyViewIfNeeded()}connectedCallback(){super.connectedCallback(),this._initViewIfNeeded()}disconnectedCallback(){super.disconnectedCallback(),this._destroyViewIfNeeded()}localeChanged(){this._syncStateIfNeeded()}_syncStateIfNeeded(){this.instance?.[h.c].updateHostState({locale:this.locale,ctx:this._ctx})}};r.t([t.A],_.prototype,`instance`,void 0);var v=e=>t.p`<template :_ctx="${()=>e}">
2
- <div class="rte">
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../bundled/localized.cjs"),t=require("../bundled/vivid-element.cjs"),n=require("../bundled/ref.cjs"),r=require("../bundled/decorate.cjs"),i=require("../bundled/class-names.cjs"),a=require("../bundled/definition4.cjs"),o=require("../bundled/delegates-aria.cjs"),s=require("../bundled/definition5.cjs"),c=require("../bundled/definition7.cjs"),l=require("../bundled/definition8.cjs"),u=require("../bundled/render-in-light-dom.cjs"),d=require("../bundled/definition11.cjs"),f=require("../bundled/option.cjs"),p=require("../bundled/definition17.cjs"),m=require("../bundled/definition19.cjs"),h=require("../bundled/definition20.cjs"),g=require("../bundled/divider.cjs"),_=require("../bundled/slottable-request.cjs"),ee=require("../bundled/definition21.cjs"),v=require("../bundled/definition22.cjs");var te=`:host{display:block}.rte{--editor-padding-inline:var(--rich-text-editor-padding-inline,16px);--editor-padding-block:var(--rich-text-editor-padding-block,8px);block-size:100%;max-block-size:inherit;min-block-size:inherit;flex-direction:column;display:flex}.rte.appearance-fieldset{background-color:var(--_appearance-color-fill);outline:1px solid var(--_appearance-color-outline);outline-offset:-1px;border-radius:8px;transition:outline-color .2s,background-color .2s}.rte.appearance-fieldset:focus-within{--focus-stroke-gap-color:transparent;box-shadow:0 0 0 4px color-mix(in sRGB, var(--focus-stroke-color,var(--vvd-color-cta-500)), transparent 85%), inset 0 0 0 3px var(--focus-stroke-gap-color,currentColor);outline:1px solid var(--focus-stroke-color,var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset,0px))}.rte.appearance-fieldset .editor-viewport{border-start-start-radius:inherit;border-start-end-radius:inherit}.rte.appearance-fieldset .editor-scroll-area{background:0 0}.rte.appearance-fieldset .toolbar{border-end-end-radius:inherit;border-end-start-radius:inherit}.editor{display:contents}.editor-viewport{contain:layout;flex-direction:column;flex:1;min-block-size:0;display:flex;position:relative;overflow:hidden}.editor-scroll-area{background-color:var(--vvd-color-canvas);color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);--scrollbar-track-color:transparent;--scrollbar-thumb-color:color-mix(in sRGB, var(--vvd-color-neutral-950), transparent 70%);scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin;flex-direction:column;flex:1;min-block-size:0;display:flex;overflow-y:auto}.editor-scroll-area ::-webkit-scrollbar{width:4px}.editor-scroll-area ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.editor-scroll-area ::-webkit-scrollbar-thumb{background-color:var(--scrollbar-fallback-track-color,var(--scrollbar-thumb-color));border:0;border-radius:4px}.popovers--disabled>*{display:none!important}`,y=class extends o.t(e.n(t.t)){constructor(...e){super(...e),this._disabled=!1}instanceChanged(e){e?.[_.c].destroyViewIfNeeded(),e&&(e[_.c].onDisabledChanged=null),this._disabled=!1,this._initViewIfNeeded(),e?.[_.c].styles.removeStylesFrom(this.shadowRoot),this.instance?.[_.c].styles.addStylesTo(this.shadowRoot)}_initViewIfNeeded(){let e=this.instance?.[_.c];e&&this.$fastController.isConnected&&!e.view&&(this._syncStateIfNeeded(),e.onDisabledChanged=e=>{this._disabled=e},e.createView(this._editableEl))}_destroyViewIfNeeded(){this.instance?.[_.c].destroyViewIfNeeded()}connectedCallback(){super.connectedCallback(),this._initViewIfNeeded()}disconnectedCallback(){super.disconnectedCallback(),this._destroyViewIfNeeded(),this.instance&&(this.instance[_.c].onDisabledChanged=null)}localeChanged(){this._syncStateIfNeeded()}_syncStateIfNeeded(){this.instance?.[_.c].updateHostState({locale:this.locale,ctx:this._ctx})}focus(e){let t=this.instance?.[_.c].view;t&&t.editable?(this._editableEl.focus(e),t.focus()):super.focus(e)}};r.t([t.A],y.prototype,`instance`,void 0),r.t([t.m],y.prototype,`appearance`,void 0),r.t([t.m],y.prototype,`state`,void 0),r.t([t.A],y.prototype,`_disabled`,void 0);var ne=e=>t.p`<template :_ctx="${()=>e}">
2
+ <div
3
+ class="${e=>i.t(`rte`,`connotation-accent`,`with-idle`,`with-hover`,`with-disabled`,`with-error`,`with-success`,[`disabled`,e._disabled],[`appearance-${e.appearance}`,!!e.appearance],[`error`,e.state===`error`],[`success`,e.state===`success`])}"
4
+ >
3
5
  <slot name="editor-before"></slot>
4
- <div class="editor-viewport" ${n.t(`editorViewportElement`)}>
6
+ <div
7
+ class="editor-viewport"
8
+ part="editor-viewport"
9
+ ${n.t(`editorViewportElement`)}
10
+ >
5
11
  <div class="editor-scroll-area" part="editor-scrollable-area">
6
12
  <slot name="editor-start"></slot>
7
- <div class="editor rich-text" ${n.t(`_editorEl`)}></div>
13
+ <div class="editor rich-text">
14
+ <div part="editor" ${o.n()} ${n.t(`_editableEl`)}></div>
15
+ </div>
8
16
  <div class="popovers"></div>
9
17
  <slot name="editor-end"></slot>
10
18
  </div>
@@ -13,22 +21,23 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
13
21
  <slot name="status"></slot>
14
22
  <div class="toolbar"></div>
15
23
  </div>
16
- </template>`,y={default:{placement:void 0,placementStrategy:o.r.AutoPlacementHorizontal,shiftCrossAxis:!1,strategy:`absolute`},autocomplete:{placement:`bottom-start`,placementStrategy:o.r.Flip,shiftCrossAxis:!1,strategy:`fixed`},imageOptions:{placement:`bottom`,placementStrategy:o.r.Flip,shiftCrossAxis:!0,strategy:`absolute`}},ne=e=>{let n=e.tagFor(o.i);return t.p`<${n}
24
+ </template>`,re={default:{placement:void 0,placementStrategy:c.r.AutoPlacementHorizontal,shiftCrossAxis:!1,strategy:`fixed`},autocomplete:{placement:`bottom-start`,placementStrategy:c.r.Flip,shiftCrossAxis:!1,strategy:`fixed`},imageOptions:{placement:`bottom`,placementStrategy:c.r.Flip,shiftCrossAxis:!0,strategy:`absolute`}},b=e=>{let n=e.tagFor(c.i);return t.p`<${n}
17
25
  :anchor="${e=>e.anchorEl}"
18
- :placement="${e=>y[e.kind].placement}"
19
- :placementStrategy="${e=>y[e.kind].placementStrategy}"
20
- :shiftCrossAxis="${e=>y[e.kind].shiftCrossAxis}"
26
+ :placement="${e=>re[e.kind].placement}"
27
+ :placementStrategy="${e=>re[e.kind].placementStrategy}"
28
+ :shiftCrossAxis="${e=>re[e.kind].shiftCrossAxis}"
21
29
  :open="${e=>e.open}"
22
30
  :offset="${e=>e.offset}"
23
- :strategy="${e=>y[e.kind].strategy}"
31
+ :strategy="${e=>re[e.kind].strategy}"
24
32
  exportparts="vvd-theme-alternate"
25
33
  >
26
34
  <slot></slot>
27
- </${n}>`},re=class extends t.t{constructor(...e){super(...e),this.kind=`default`,this.anchorBlocksPopover=!1,this.onAnchorBlockPopoverChanged=()=>{this.anchorBlocksPopover=this.anchorEl?.dataset.blockPopover===`true`||!1},this.requestedOpenState=!1}static setBlockPopover(e,t){e.dataset.blockPopover=t?`true`:`false`;let n=new CustomEvent(`block-popover-changed`,{bubbles:!1,composed:!1});e.dispatchEvent(n)}dismiss(){this.anchorBlocksPopover=!0}anchorElChanged(e,t){e?.removeEventListener(`block-popover-changed`,this.onAnchorBlockPopoverChanged),t?.addEventListener(`block-popover-changed`,this.onAnchorBlockPopoverChanged),this.onAnchorBlockPopoverChanged()}anchorIdChanged(){this.updateAnchor()}updateAnchor(){this.anchorId&&this.isConnected?this.anchorEl=this.getRootNode().getElementById(this.anchorId)||void 0:this.anchorEl=void 0}requestOpenState(e){this.requestedOpenState=e}get open(){return this.requestedOpenState&&!!this.anchorEl&&!this.anchorBlocksPopover}#e;connectedCallback(){super.connectedCallback(),this.updateAnchor(),this.#e=new MutationObserver(e=>{e.some(e=>Array.from(e.addedNodes).some(e=>e instanceof HTMLElement&&e.id===this.anchorId))&&this.updateAnchor()}),this.#e.observe(this.getRootNode(),{childList:!0,subtree:!0})}disconnectedCallback(){super.disconnectedCallback(),this.#e.disconnect()}};r.t([t.A],re.prototype,`kind`,void 0),r.t([t.A],re.prototype,`offset`,void 0),r.t([t.A],re.prototype,`anchorBlocksPopover`,void 0),r.t([t.A],re.prototype,`anchorEl`,void 0),r.t([t.A],re.prototype,`anchorId`,void 0),r.t([t.A],re.prototype,`requestedOpenState`,void 0),r.t([t.j],re.prototype,`open`,null);var ie=t.u(`rich-text-editor-popover`,re,ne,[o.t],{}),ae=65535,oe=2**16;function b(e,t){return e+t*oe}function se(e){return e&ae}function ce(e){return(e-(e&ae))/oe}var le=1,ue=2,de=4,fe=8,pe=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&fe)>0}get deletedBefore(){return(this.delInfo&(le|de))>0}get deletedAfter(){return(this.delInfo&(ue|de))>0}get deletedAcross(){return(this.delInfo&de)>0}},me=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=se(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+ce(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:b(o/3,e-s),f=e==s?ue:e==u?le:de;return(t<0?e!=s:e!=u)&&(f|=fe),new pe(a,f,d)}r+=l-c}return n?e+r:new pe(e+r,0,null)}touches(e,t){let n=0,r=se(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};me.empty=new me([]);var he=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new pe(e,r,null)}},x=Object.create(null),S=class{getMap(){return me.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=x[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in x)throw RangeError(`Duplicate use of step JSON ID `+e);return x[e]=t,t.prototype.jsonID=e,t}},C=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof h.g)return e.fail(t.message);throw t}}};function ge(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(ge(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return h.d.fromArray(r)}var w=class e extends S{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new h.v(ge(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return C.fromReplace(e,this.from,this.to,i)}invert(){return new _e(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(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,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};S.jsonID(`addMark`,w);var _e=class e extends S{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new h.v(ge(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return C.fromReplace(e,this.from,this.to,n)}invert(){return new w(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(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,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};S.jsonID(`removeMark`,_e);var ve=class e extends S{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return C.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return C.fromReplace(e,this.pos,this.pos+1,new h.v(h.d.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new ye(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};S.jsonID(`addNodeMark`,ve);var ye=class e extends S{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return C.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return C.fromReplace(e,this.pos,this.pos+1,new h.v(h.d.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new ve(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};S.jsonID(`removeNodeMark`,ye);var be=class e extends S{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&xe(e,this.from,this.to)?C.fail(`Structure replace would overwrite content`):C.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new me([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?h.v.empty:new h.v(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?h.v.empty:new h.v(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,h.v.fromJSON(t,n.slice),!!n.structure)}};be.MAP_BIAS=1,S.jsonID(`replace`,be);var T=class e extends S{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(xe(e,this.from,this.gapFrom)||xe(e,this.gapTo,this.to)))return C.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return C.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?C.fromReplace(e,this.from,this.to,n):C.fail(`Content does not fit in gap`)}getMap(){return new me([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,h.v.fromJSON(t,n.slice),n.insert,!!n.structure)}};S.jsonID(`replaceAround`,T);function xe(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Se(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new _e(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new w(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function Ce(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof h.p){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new _e(t.from,t.to,t.style)))}function we(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new be(s,l,h.v.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new _e(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new h.v(h.d.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new be(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(h.d.empty,!0);e.replace(s,s,new h.v(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Te(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Ee(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Te(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function De(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=h.d.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=h.d.from(r.node(e).copy(u)),d++):c--;let f=h.d.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=h.d.from(i.node(e).copy(f)),p++):l++;e.step(new T(c,l,o,s,new h.v(u.append(f),d,p),u.size-d,!0))}function Oe(e,t,n){let r=h.d.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=h.d.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new T(i,a,i,a,new h.v(r,0,0),n.length,!0))}function ke(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Me(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&je(e,t,n,a),we(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new T(c,l,c+1,l-1,new h.v(h.d.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Ae(e,t,n,a),!1}})}function Ae(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function je(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
28
- `))}})}function Me(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Ne(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new T(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new h.v(h.d.from(o),0,0),1,!0))}function Pe(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<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 e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function Fe(e,t,n=1,r){let i=e.doc.resolve(t),a=h.d.empty,o=h.d.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=h.d.from(i.node(e).copy(a));let t=r&&r[s];o=h.d.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new be(t,t,new h.v(a.append(o),n,n),!0))}function Ie(e,t){let n=e.resolve(t),r=n.index();return Re(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Le(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function Re(e,t){return!!(e&&t&&!e.isLeaf&&Le(e,t))}function ze(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);je(e,r.node(),r.before(),s)}o.inlineContent&&we(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new be(l,c.map(t+n,-1),h.v.empty,!0)),r===!0){let t=e.doc.resolve(l);Ae(e,t.node(),t.before(),e.steps.length)}return e}function Be(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function Ve(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function He(e,t,n=t,r=h.v.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return Ue(i,a,r)?new be(t,n,r):new We(i,a,r).fit()}function Ue(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var We=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=h.d.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=h.d.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new h.v(i,a,o);return e>-1?new T(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new be(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Ke(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(h.d.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Ke(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new h.v(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Ke(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new h.v(E(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new h.v(E(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let a=this.unplaced,o=n?n.content:a.content,s=a.openStart-e,c=0,l=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)l.push(r.child(e));u=u.matchFragment(r)}let f=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let e=o.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||s==0||e.content.size)&&(u=t,l.push(qe(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=Ge(this.placed,t,h.d.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?e==0?h.v.empty:new h.v(E(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new h.v(E(a.content,e,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Je(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(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Je(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=Je(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Ge(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Ge(this.placed,this.depth,h.d.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(h.d.empty,!0);e.childCount&&(this.placed=Ge(this.placed,this.frontier.length,e))}};function E(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(E(e.firstChild.content,t-1,n)))}function Ge(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Ge(e.lastChild.content,t-1,n)))}function Ke(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function qe(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,qe(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(h.d.empty,!0)))),e.copy(r)}function Je(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!Ye(n,a.content,o)?s:null}function Ye(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function Xe(e){return e.spec.defining||e.spec.definingForContent}function Ze(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(Ue(i,a,r))return e.step(new be(t,n,r));let o=et(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=Xe(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t<o.length;t++){let l=o[(t+c)%o.length],u=!0;l<0&&(u=!1,l=-l);let f=i.node(l-1),p=i.index(l-1);if(f.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(l),u?a.after(l):n,new h.v(Qe(r.content,0,r.openStart,s),s,r.openEnd))}}let d=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function Qe(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(Qe(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(h.d.empty,!0))}return e}function $e(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Be(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new h.v(h.d.from(r),0,0))}function D(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=et(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.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 e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function et(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var tt=class e extends S{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return C.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return C.fromReplace(e,this.pos,this.pos+1,new h.v(h.d.from(r),0,+!t.isLeaf))}getMap(){return me.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};S.jsonID(`attr`,tt);var nt=class e extends S{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return C.ok(n)}getMap(){return me.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};S.jsonID(`docAttr`,nt);var rt=class extends Error{};rt=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},rt.prototype=Object.create(Error.prototype),rt.prototype.constructor=rt,rt.prototype.name=`TransformError`;var it=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new he}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new rt(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=h.v.empty){let r=He(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new h.v(h.d.from(n),0,0))}delete(e,t){return this.replace(e,t,h.v.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Ze(this,e,t,n),this}replaceRangeWith(e,t,n){return $e(this,e,t,n),this}deleteRange(e,t){return D(this,e,t),this}lift(e,t){return De(this,e,t),this}join(e,t=1){return ze(this,e,t),this}wrap(e,t){return Oe(this,e,t),this}setBlockType(e,t=e,n,r=null){return ke(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return Ne(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new tt(e,t,n)),this}setDocAttribute(e,t){return this.step(new nt(e,t)),this}addNodeMark(e,t){return this.step(new ve(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof h.f)t.isInSet(n.marks)&&this.step(new ye(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new ye(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return Fe(this,e,t,n),this}addMark(e,t,n){return Se(this,e,t,n),this}removeMark(e,t,n){return Ce(this,e,t,n),this}clearIncompatible(e,t,n){return we(this,e,t,n),this}},at=Object.create(null),O=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new ot(e.min(t),e.max(t))]}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 e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=h.v.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?h.v.empty:t),o==0&&pt(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),pt(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new k(e):ft(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?ft(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):ft(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new j(e.node(0))}static atStart(e){return ft(e,e,0,0,1)||new j(e)}static atEnd(e){return ft(e,e,e.content.size,e.childCount,-1)||new j(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=at[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in at)throw RangeError(`Duplicate use of selection JSON ID `+e);return at[e]=t,t.prototype.jsonID=e,t}getBookmark(){return k.between(this.$anchor,this.$head).getBookmark()}};O.prototype.visible=!0;var ot=class{constructor(e,t){this.$from=e,this.$to=t}},st=!1;function ct(e){!st&&!e.parent.inlineContent&&(st=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var k=class e extends O{constructor(e,t=e){ct(e),ct(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return O.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=h.v.empty){if(super.replace(e,t),t==h.v.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new lt(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=O.findFrom(n,r,!0)||O.findFrom(n,-r,!0);if(e)n=e.$head;else return O.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(O.findFrom(t,-r,!0)||O.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};O.jsonID(`text`,k);var lt=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return k.between(e.resolve(this.anchor),e.resolve(this.head))}},A=class e extends O{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?O.near(a):new e(a)}content(){return new h.v(h.d.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new ut(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};A.prototype.visible=!1,O.jsonID(`node`,A);var ut=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new lt(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&A.isSelectable(n)?new A(t):O.near(t)}},j=class e extends O{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=h.v.empty){if(t==h.v.empty){e.delete(0,e.doc.content.size);let t=O.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return dt}};O.jsonID(`all`,j);var dt={map(){return this},resolve(e){return new j(e)}};function ft(e,t,n,r,i,a=!1){if(t.inlineContent)return k.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=ft(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&A.isSelectable(r))return A.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function pt(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof be||i instanceof T))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(O.near(e.doc.resolve(o),n))}var mt=1,ht=2,gt=4,_t=class extends it{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.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(e){if(e.$from.doc!=this.doc)throw RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|mt)&~ht,this.storedMarks=null,this}get selectionSet(){return(this.updated&mt)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ht,this}ensureMarks(e){return h.f.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&ht)>0}addStep(e,t){super.addStep(e,t),this.updated&=~ht,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||h.f.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(O.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=gt,this}get scrolledIntoView(){return(this.updated&gt)>0}};function vt(e,t){return!t||!e?e:e.bind(t)}var yt=class{constructor(e,t,n){this.name=e,this.init=vt(t.init,n),this.apply=vt(t.apply,n)}},bt=[new yt(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new yt(`selection`,{init(e,t){return e.selection||O.atStart(t.doc)},apply(e){return e.selection}}),new yt(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new yt(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],xt=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=bt.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new yt(e.key,e.spec.state,e))})}},St=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new _t(this)}static create(t){let n=new xt(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new xt(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new xt(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=h.m.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=O.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function Ct(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=Ct(i,t,{})),n[r]=i}return n}var M=class{constructor(e){this.spec=e,this.props={},e.props&&Ct(e.props,this,this.props),this.key=e.key?e.key.key:Tt(`plugin`)}getState(e){return e[this.key]}},wt=Object.create(null);function Tt(e){return e in wt?e+`$`+ ++wt[e]:(wt[e]=0,e+`$`)}var Et=class{constructor(e=`key`){this.key=Tt(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},N=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Dt=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},Ot=null,kt=function(e,t,n){let r=Ot||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},At=function(){Ot=null},jt=function(e,t,n,r){return n&&(Nt(e,t,n,r,-1)||Nt(e,t,n,r,1))},Mt=/^(img|br|input|textarea|hr)$/i;function Nt(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Pt(e))){let n=e.parentNode;if(!n||n.nodeType!=1||Rt(e)||Mt.test(e.nodeName)||e.contentEditable==`false`)return!1;t=N(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`)if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else e=n,t=i<0?Pt(e):0}else return!1}}function Pt(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Ft(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=Pt(e)}else if(e.parentNode&&!Rt(e))t=N(e),e=e.parentNode;else return null}}function It(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable==`false`)return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!Rt(e))t=N(e)+1,e=e.parentNode;else return null}}function Lt(e,t,n){for(let r=t==0,i=t==Pt(e);r||i;){if(e==n)return!0;let t=N(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==Pt(e)}}function Rt(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var zt=function(e){return e.focusNode&&jt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Bt(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function Vt(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function Ht(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Pt(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Pt(r.startContainer),r.startOffset)}}}var Ut=typeof navigator<`u`?navigator:null,Wt=typeof document<`u`?document:null,Gt=Ut&&Ut.userAgent||``,Kt=/Edge\/(\d+)/.exec(Gt),qt=/MSIE \d/.exec(Gt),Jt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Gt),P=!!(qt||Jt||Kt),Yt=qt?document.documentMode:Jt?+Jt[1]:Kt?+Kt[1]:0,Xt=!P&&/gecko\/(\d+)/i.test(Gt);Xt&&+(/Firefox\/(\d+)/.exec(Gt)||[0,0])[1];var Zt=!P&&/Chrome\/(\d+)/.exec(Gt),F=!!Zt,Qt=Zt?+Zt[1]:0,I=!P&&!!Ut&&/Apple Computer/.test(Ut.vendor),$t=I&&(/Mobile\/\w+/.test(Gt)||!!Ut&&Ut.maxTouchPoints>2),en=$t||(Ut?/Mac/.test(Ut.platform):!1),tn=Ut?/Win/.test(Ut.platform):!1,nn=/Android \d/.test(Gt),rn=!!Wt&&`webkitFontSmoothing`in Wt.documentElement.style,an=rn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function on(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function sn(e,t){return typeof e==`number`?e:e[t]}function cn(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function ln(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=Dt(o);continue}let e=o,n=e==a.body,s=n?on(a):cn(e),c=0,l=0;if(t.top<s.top+sn(r,`top`)?l=-(s.top-t.top+sn(i,`top`)):t.bottom>s.bottom-sn(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+sn(i,`top`)-s.top:t.bottom-s.bottom+sn(i,`bottom`)),t.left<s.left+sn(r,`left`)?c=-(s.left-t.left+sn(i,`left`)):t.right>s.right-sn(r,`right`)&&(c=t.right-s.right+sn(i,`right`)),c||l)if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:Dt(o)}}function un(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o<Math.min(innerHeight,t.bottom);o+=5){let t=e.root.elementFromPoint(a,o);if(!t||t==e.dom||!e.dom.contains(t))continue;let s=t.getBoundingClientRect();if(s.top>=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:dn(e.dom)}}function dn(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Dt(r));return t}function fn({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;pn(n,r==0?0:r-t)}function pn(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:a}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var mn=null;function hn(e){if(e.setActive)return e.setActive();if(mn)return e.focus(mn);let t=dn(e);e.focus(mn==null?{get preventScroll(){return mn={preventScroll:!0},!0}}:void 0),mn||(mn=!1,pn(t,0))}function gn(e,t){let n,r=2e8,i,a=0,o=t.top,s=t.top,c,l;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(u.nodeType==1)e=u.getClientRects();else if(u.nodeType==3)e=kt(u).getClientRects();else continue;for(let f=0;f<e.length;f++){let p=e[f];if(p.top<=o&&p.bottom>=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=u,r=e,i=e&&n.nodeType==3?{left:p.right<t.left?p.right:p.left,top:t.top}:t,u.nodeType==1&&e&&(a=d+ +(t.left>=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?_n(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:gn(n,i)}function _n(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(e,a+1),r.setStart(e,a);let n=Tn(r,1);if(n.top!=n.bottom&&vn(t,n)){i={node:e,offset:a+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function vn(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function yn(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function bn(e,t,n){let{node:r,offset:i}=gn(t,n),a=-1;if(r.nodeType==1&&!r.firstChild){let e=r.getBoundingClientRect();a=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function xn(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right<r.left||o.bottom<r.top)&&(i=t.posAfter),a=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}function Sn(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let n=e.childNodes[a];if(n.nodeType==1){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(vn(t,i))return Sn(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function Cn(e,t){let n=e.dom.ownerDocument,r,i=0,a=Ht(n,t.left,t.top);a&&({node:r,offset:i}=a);let o=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!o||!e.dom.contains(o.nodeType==1?o:o.parentNode)){let n=e.dom.getBoundingClientRect();if(!vn(t,n)||(o=Sn(e.dom,t,n),!o))return null}if(I)for(let e=o;r&&e;e=Dt(e))e.draggable&&(r=void 0);if(o=yn(o,t),r){if(Xt&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let e=r.childNodes[i],n;e.nodeName==`IMG`&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&i++}let n;rn&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=xn(e,r,i,t))}s??=bn(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function wn(e){return e.top<e.bottom||e.left<e.right}function Tn(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(wn(e))return e}return Array.prototype.find.call(n,wn)||e.getBoundingClientRect()}var En=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Dn(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=rn||Xt;if(r.nodeType==3)if(o&&(En.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=Tn(kt(r,i,i),n);if(Xt&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=Tn(kt(r,i-1,i-1),-1);if(t.top==e.top){let n=Tn(kt(r,i,i+1),-1);if(n.top!=e.top)return On(n,n.left<t.left)}}return e}else{let e=i,t=i,a=n<0?1:-1;return n<0&&!i?(t++,a=-1):n>=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,On(Tn(kt(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Pt(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return kn(e.getBoundingClientRect(),!1)}if(a==null&&i<Pt(r)){let e=r.childNodes[i];if(e.nodeType==1)return kn(e.getBoundingClientRect(),!0)}return kn(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==Pt(r))){let e=r.childNodes[i-1],t=e.nodeType==3?kt(e,Pt(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return On(Tn(t,1),!1)}if(a==null&&i<Pt(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?kt(e,0,+!o):e.nodeType==1?e:null:null;if(t)return On(Tn(t,-1),!0)}return On(Tn(r.nodeType==3?kt(r):r,-n),n>=0)}function On(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function kn(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function An(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function jn(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return An(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Dn(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=kt(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var Mn=/[\u0590-\u08ac]/;function Nn(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!Mn.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:An(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var Pn=null,Fn=null,In=!1;function Ln(e,t,n){return Pn==t&&Fn==n?In:(Pn=t,Fn=n,In=n==`up`||n==`down`?jn(e,t,n):Nn(e,t,n))}var Rn=0,zn=1,Bn=2,Vn=3,Hn=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=Rn,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)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(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>N(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],a=t+i.size;if(a>e||i instanceof Yn){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof Un&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?N(e.dom)+1:0}}else{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,!(!e||e.dom.parentNode==this.contentDOM);n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?N(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let a=n,o=0;;o++){let n=this.children[o],s=a+n.size;if(r==-1&&e<=s){let i=a+n.border;if(e>=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=N(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=N(n.dom);break}t+=n.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw RangeError(`No node after pos `+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),a=Math.max(e,t);for(let o=0,s=0;o<this.children.length;o++){let c=this.children[o],l=s+c.size;if(i>s&&a<l)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=l}let o=this.domFromPos(e,e?-1:1),s=t==e?o:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),l=n.domSelectionRange(),u=!1;if((Xt||I)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
29
- `),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:N(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(Xt&&l.focusNode&&l.focusNode!=s.node&&l.focusNode.nodeType==1){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&I)&&jt(o.node,o.offset,l.anchorNode,l.anchorOffset)&&jt(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&Xt)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?Bn:zn,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Vn:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Bn:Vn}n=a}this.dirty=Bn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Bn:zn;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Un=class extends Hn{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Rn&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||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}},Wn=class extends Hn{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},Gn=class e extends Hn{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=h.u.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Vn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Vn&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Rn){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=Rn}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=fr(a,n,o,r)),t>0&&(a=fr(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Kn=class e extends Hn{constructor(e,t,n,r,i,a,o,s,c){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=h.u.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=rr(u,r,n),l?c=new Xn(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new Jn(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(e.preserveWhitespace=`full`),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>h.d.empty)}return e}matchesNode(e,t,n){return this.dirty==Rn&&e.eq(this.node)&&ir(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new or(this,a&&a.node,e);lr(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?h.f.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==Bn)&&(a&&this.protectLocalComposition(e,a),Zn(this.contentDOM,this.children,e),$t&&ur(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof k)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=dr(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;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&&=void 0}let a=new Wn(this,i,t,r);e.input.compositionNodes.push(a),this.children=fr(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==Vn||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Rn}updateOuterDeco(e){if(ir(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=tr(this.dom,this.nodeDOM,er(this.outerDeco,this.node,t),er(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function qn(e,t,n,r,i){rr(r,t,e);let a=new Kn(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var Jn=class e extends Kn{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==Vn||this.dirty!=Rn&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Rn||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Rn,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Vn)}get domAtom(){return!1}isText(e){return this.node.text==e}},Yn=class extends Hn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Rn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},Xn=class extends Kn{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==Vn)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Zn(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=ar(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof Gn){let t=r?r.previousSibling:e.lastChild;Zn(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=ar(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var Qn=function(e){e&&(this.nodeName=e)};Qn.prototype=Object.create(null);var $n=[new Qn];function er(e,t,n){if(e.length==0)return $n;let r=n?$n[0]:new Qn,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new Qn(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new Qn(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function tr(e,t,n,r){if(n==$n&&r==$n)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName?i=t:(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=$n[0],i=t)}nr(i,o||$n[0],a)}return i}function nr(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function rr(e,t,n){return tr(e,e,$n,er(t,n,e.nodeType!=1))}function ir(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function ar(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var or=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=sr(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=Rn,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.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 t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;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=Gn.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==Vn&&a.dom==a.contentDOM&&(a.dirty=Bn),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof Kn){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=Vn&&ir(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Bn,u.updateChildren(r,a+1),u.dirty=Rn),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ir(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=Kn.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=Kn.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new Un(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Gn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Jn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((I||F)&&e&&e.dom.contentEditable==`false`&&this.addHackNode(`IMG`,t),this.addHackNode(`BR`,this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new Yn(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function sr(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];outer:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof Gn)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function cr(e,t){return e.type.side-t.type.side}function lr(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u)if(d){d.sort(cr);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function ur(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function dr(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function fr(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function pr(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(zt(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&A.isSelectable(e)&&i.parent&&!(e.isInline&&Lt(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new A(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=wr(e,u,s,n)}return l}function mr(e){return e.editable?e.hasFocus():Er(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function hr(e,t=!1){let n=e.state.selection;if(Sr(e,n),mr(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&F){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&jt(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)xr(e);else{let{anchor:r,head:i}=n,a,o;gr&&!(n instanceof k)&&(n.$from.parent.inlineContent||(a=_r(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=_r(e,n.to))),e.docView.setSelection(r,i,e,t),gr&&(a&&yr(a),o&&yr(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&br(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var gr=I||F&&Qt<63;function _r(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(I&&i&&i.contentEditable==`false`)return vr(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return vr(i);if(a)return vr(a)}}function vr(e){return e.contentEditable=`true`,I&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function yr(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function br(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!mr(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function xr(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,N(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&P&&Yt<=11&&(n.disabled=!0,n.disabled=!1)}function Sr(e,t){if(t instanceof A){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Cr(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Cr(e)}function Cr(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function wr(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||k.between(t,n,r)}function Tr(e){return e.editable&&!e.hasFocus()?!1:Er(e)}function Er(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Dr(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return jt(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Or(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&O.findFrom(a,t)}function kr(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Ar(e,t,n){let r=e.state.selection;if(r instanceof k){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return kr(e,new k(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=Or(e.state,t);return n&&n instanceof A?kr(e,n):!1}else if(!(en&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?A.isSelectable(i)?kr(e,new A(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):rn?kr(e,new k(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof A&&r.node.isInline)return kr(e,new k(t>0?r.$to:r.$from));else{let n=Or(e.state,t);return n?kr(e,n):!1}}function jr(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Mr(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function Nr(e,t){return t<0?Pr(e):Fr(e)}function Pr(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(Xt&&n.nodeType==1&&r<jr(n)&&Mr(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(Mr(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(Ir(n))break;else{let t=n.previousSibling;for(;t&&Mr(t,-1);)i=n.parentNode,a=N(t),t=t.previousSibling;if(t)n=t,r=jr(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?zr(e,n,r):i&&zr(e,i,a)}function Fr(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=jr(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(Mr(e,1))a=n,o=++r;else break}else if(Ir(n))break;else{let t=n.nextSibling;for(;t&&Mr(t,1);)a=t.parentNode,o=N(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=jr(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&zr(e,a,o)}function Ir(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Lr(e,t){for(;e&&t==e.childNodes.length&&!Rt(e);)t=N(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=0}}function Rr(e,t){for(;e&&!t&&!Rt(e);)t=N(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function zr(e,t,n){if(t.nodeType!=3){let e,r;(r=Lr(t,n))?(t=r,n=0):(e=Rr(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(zt(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&hr(e)},50)}function Br(e,t){let n=e.state.doc.resolve(t);if(!(F||tn)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-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(t<n.end()){let n=e.coordsAtPos(t+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 getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function Vr(e,t,n){let r=e.state.selection;if(r instanceof k&&!r.empty||n.indexOf(`s`)>-1||en&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=Or(e.state,t);if(n&&n instanceof A)return kr(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof j?O.near(n,t):O.findFrom(n,t);return o?kr(e,o):!1}return!1}function Hr(e,t){if(!(e.state.selection instanceof k))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function Ur(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Wr(e){if(!I||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;Ur(e,n,`true`),setTimeout(()=>Ur(e,n,`false`),20)}return!1}function Gr(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function Kr(e,t){let n=t.keyCode,r=Gr(t);if(n==8||en&&n==72&&r==`c`)return Hr(e,-1)||Nr(e,-1);if(n==46&&!t.shiftKey||en&&n==68&&r==`c`)return Hr(e,1)||Nr(e,1);if(n==13||n==27)return!0;if(n==37||en&&n==66&&r==`c`){let t=n==37?Br(e,e.state.selection.from)==`ltr`?-1:1:-1;return Ar(e,t,r)||Nr(e,t)}else if(n==39||en&&n==70&&r==`c`){let t=n==39?Br(e,e.state.selection.from)==`ltr`?1:-1:1;return Ar(e,t,r)||Nr(e,t)}else if(n==38||en&&n==80&&r==`c`)return Vr(e,-1,r)||Nr(e,-1);else if(n==40||en&&n==78&&r==`c`)return Wr(e)||Vr(e,1,r)||Nr(e,1);else if(r==(en?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function qr(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||h.u.fromSchema(e.state.schema),s=ii(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=ni[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
35
+ </${n}>`},x=class extends t.t{constructor(...e){super(...e),this.kind=`default`,this.anchorBlocksPopover=!1,this.onAnchorBlockPopoverChanged=()=>{this.anchorBlocksPopover=this.anchorEl?.dataset.blockPopover===`true`||!1},this.requestedOpenState=!1}static setBlockPopover(e,t){e.dataset.blockPopover=t?`true`:`false`;let n=new CustomEvent(`block-popover-changed`,{bubbles:!1,composed:!1});e.dispatchEvent(n)}dismiss(){this.anchorBlocksPopover=!0}anchorElChanged(e,t){e?.removeEventListener(`block-popover-changed`,this.onAnchorBlockPopoverChanged),t?.addEventListener(`block-popover-changed`,this.onAnchorBlockPopoverChanged),this.onAnchorBlockPopoverChanged()}anchorIdChanged(){this.updateAnchor()}updateAnchor(){this.anchorEl=this.anchorId&&this.isConnected&&this.getRootNode().getElementById(this.anchorId)||void 0}requestOpenState(e){this.requestedOpenState=e}get open(){return this.requestedOpenState&&!!this.anchorEl&&!this.anchorBlocksPopover}#e;connectedCallback(){super.connectedCallback(),this.updateAnchor(),this.#e=new MutationObserver(e=>{e.some(e=>Array.from(e.addedNodes).some(e=>e instanceof HTMLElement&&e.id===this.anchorId))&&this.updateAnchor()}),this.#e.observe(this.getRootNode(),{childList:!0,subtree:!0})}disconnectedCallback(){super.disconnectedCallback(),this.#e.disconnect()}};r.t([t.A],x.prototype,`kind`,void 0),r.t([t.A],x.prototype,`offset`,void 0),r.t([t.A],x.prototype,`anchorBlocksPopover`,void 0),r.t([t.A],x.prototype,`anchorEl`,void 0),r.t([t.A],x.prototype,`anchorId`,void 0),r.t([t.A],x.prototype,`requestedOpenState`,void 0),r.t([t.j],x.prototype,`open`,null);var ie=t.u(`rich-text-editor-popover`,x,b,[c.t],{}),ae=65535,oe=2**16;function se(e,t){return e+t*oe}function ce(e){return e&ae}function le(e){return(e-(e&ae))/oe}var ue=1,de=2,fe=4,pe=8,me=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&pe)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&fe)>0}},he=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=ce(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+le(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:se(o/3,e-s),f=e==s?de:e==u?ue:fe;return(t<0?e!=s:e!=u)&&(f|=pe),new me(a,f,d)}r+=l-c}return n?e+r:new me(e+r,0,null)}touches(e,t){let n=0,r=ce(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};he.empty=new he([]);var ge=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new me(e,r,null)}},S=Object.create(null),C=class{getMap(){return he.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=S[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in S)throw RangeError(`Duplicate use of step JSON ID `+e);return S[e]=t,t.prototype.jsonID=e,t}},w=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof _.g)return e.fail(t.message);throw t}}};function _e(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(_e(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return _.d.fromArray(r)}var ve=class e extends C{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new _.v(_e(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return w.fromReplace(e,this.from,this.to,i)}invert(){return new ye(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(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,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};C.jsonID(`addMark`,ve);var ye=class e extends C{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new _.v(_e(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return w.fromReplace(e,this.from,this.to,n)}invert(){return new ve(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(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,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};C.jsonID(`removeMark`,ye);var be=class e extends C{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return w.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return w.fromReplace(e,this.pos,this.pos+1,new _.v(_.d.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new xe(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};C.jsonID(`addNodeMark`,be);var xe=class e extends C{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return w.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return w.fromReplace(e,this.pos,this.pos+1,new _.v(_.d.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new be(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};C.jsonID(`removeNodeMark`,xe);var Se=class e extends C{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&E(e,this.from,this.to)?w.fail(`Structure replace would overwrite content`):w.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new he([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?_.v.empty:new _.v(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?_.v.empty:new _.v(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,_.v.fromJSON(t,n.slice),!!n.structure)}};Se.MAP_BIAS=1,C.jsonID(`replace`,Se);var T=class e extends C{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(E(e,this.from,this.gapFrom)||E(e,this.gapTo,this.to)))return w.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return w.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?w.fromReplace(e,this.from,this.to,n):w.fail(`Content does not fit in gap`)}getMap(){return new he([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,_.v.fromJSON(t,n.slice),n.insert,!!n.structure)}};C.jsonID(`replaceAround`,T);function E(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Ce(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new ye(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new ve(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function D(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof _.p){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new ye(t.from,t.to,t.style)))}function we(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Se(s,l,_.v.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new ye(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new _.v(_.d.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new Se(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(_.d.empty,!0);e.replace(s,s,new _.v(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Te(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Ee(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Te(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function De(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=_.d.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=_.d.from(r.node(e).copy(u)),d++):c--;let f=_.d.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=_.d.from(i.node(e).copy(f)),p++):l++;e.step(new T(c,l,o,s,new _.v(u.append(f),d,p),u.size-d,!0))}function Oe(e,t,n){let r=_.d.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=_.d.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new T(i,a,i,a,new _.v(r,0,0),n.length,!0))}function ke(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Me(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&je(e,t,n,a),we(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new T(c,l,c+1,l-1,new _.v(_.d.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Ae(e,t,n,a),!1}})}function Ae(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function je(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
36
+ `))}})}function Me(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Ne(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new T(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new _.v(_.d.from(o),0,0),1,!0))}function Pe(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<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 e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function Fe(e,t,n=1,r){let i=e.doc.resolve(t),a=_.d.empty,o=_.d.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=_.d.from(i.node(e).copy(a));let t=r&&r[s];o=_.d.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Se(t,t,new _.v(a.append(o),n,n),!0))}function Ie(e,t){let n=e.resolve(t),r=n.index();return Re(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Le(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function Re(e,t){return!!(e&&t&&!e.isLeaf&&Le(e,t))}function ze(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);je(e,r.node(),r.before(),s)}o.inlineContent&&we(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new Se(l,c.map(t+n,-1),_.v.empty,!0)),r===!0){let t=e.doc.resolve(l);Ae(e,t.node(),t.before(),e.steps.length)}return e}function Be(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function Ve(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function He(e,t,n=t,r=_.v.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return Ue(i,a,r)?new Se(t,n,r):new We(i,a,r).fit()}function Ue(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var We=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=_.d.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=_.d.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new _.v(i,a,o);return e>-1?new T(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new Se(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=qe(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(_.d.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=qe(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new _.v(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=qe(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new _.v(Ge(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new _.v(Ge(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let a=this.unplaced,o=n?n.content:a.content,s=a.openStart-e,c=0,l=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)l.push(r.child(e));u=u.matchFragment(r)}let f=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let e=o.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||s==0||e.content.size)&&(u=t,l.push(Je(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=Ke(this.placed,t,_.d.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?e==0?_.v.empty:new _.v(Ge(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new _.v(Ge(a.content,e,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ye(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(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Ye(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=Ye(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Ke(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Ke(this.placed,this.depth,_.d.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(_.d.empty,!0);e.childCount&&(this.placed=Ke(this.placed,this.frontier.length,e))}};function Ge(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Ge(e.firstChild.content,t-1,n)))}function Ke(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Ke(e.lastChild.content,t-1,n)))}function qe(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Je(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Je(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(_.d.empty,!0)))),e.copy(r)}function Ye(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!Xe(n,a.content,o)?s:null}function Xe(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function Ze(e){return e.spec.defining||e.spec.definingForContent}function Qe(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(Ue(i,a,r))return e.step(new Se(t,n,r));let o=nt(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=Ze(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t<o.length;t++){let l=o[(t+c)%o.length],u=!0;l<0&&(u=!1,l=-l);let f=i.node(l-1),p=i.index(l-1);if(f.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(l),u?a.after(l):n,new _.v($e(r.content,0,r.openStart,s),s,r.openEnd))}}let d=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function $e(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy($e(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(_.d.empty,!0))}return e}function et(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Be(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new _.v(_.d.from(r),0,0))}function tt(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=nt(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.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 e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function nt(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var rt=class e extends C{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return w.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return w.fromReplace(e,this.pos,this.pos+1,new _.v(_.d.from(r),0,+!t.isLeaf))}getMap(){return he.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};C.jsonID(`attr`,rt);var it=class e extends C{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return w.ok(n)}getMap(){return he.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};C.jsonID(`docAttr`,it);var at=class extends Error{};at=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},at.prototype=Object.create(Error.prototype),at.prototype.constructor=at,at.prototype.name=`TransformError`;var ot=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ge}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new at(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=_.v.empty){let r=He(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new _.v(_.d.from(n),0,0))}delete(e,t){return this.replace(e,t,_.v.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Qe(this,e,t,n),this}replaceRangeWith(e,t,n){return et(this,e,t,n),this}deleteRange(e,t){return tt(this,e,t),this}lift(e,t){return De(this,e,t),this}join(e,t=1){return ze(this,e,t),this}wrap(e,t){return Oe(this,e,t),this}setBlockType(e,t=e,n,r=null){return ke(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return Ne(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new rt(e,t,n)),this}setDocAttribute(e,t){return this.step(new it(e,t)),this}addNodeMark(e,t){return this.step(new be(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof _.f)t.isInSet(n.marks)&&this.step(new xe(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new xe(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return Fe(this,e,t,n),this}addMark(e,t,n){return Ce(this,e,t,n),this}removeMark(e,t,n){return D(this,e,t,n),this}clearIncompatible(e,t,n){return we(this,e,t,n),this}},st=Object.create(null),O=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new ct(e.min(t),e.max(t))]}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 e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=_.v.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?_.v.empty:t),o==0&&mt(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),mt(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new k(e):pt(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?pt(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):pt(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new M(e.node(0))}static atStart(e){return pt(e,e,0,0,1)||new M(e)}static atEnd(e){return pt(e,e,e.content.size,e.childCount,-1)||new M(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=st[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in st)throw RangeError(`Duplicate use of selection JSON ID `+e);return st[e]=t,t.prototype.jsonID=e,t}getBookmark(){return k.between(this.$anchor,this.$head).getBookmark()}};O.prototype.visible=!0;var ct=class{constructor(e,t){this.$from=e,this.$to=t}},lt=!1;function ut(e){!lt&&!e.parent.inlineContent&&(lt=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var k=class e extends O{constructor(e,t=e){ut(e),ut(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return O.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=_.v.empty){if(super.replace(e,t),t==_.v.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new dt(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=O.findFrom(n,r,!0)||O.findFrom(n,-r,!0);if(e)n=e.$head;else return O.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(O.findFrom(t,-r,!0)||O.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};O.jsonID(`text`,k);var dt=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return k.between(e.resolve(this.anchor),e.resolve(this.head))}},A=class e extends O{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?O.near(a):new e(a)}content(){return new _.v(_.d.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new j(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};A.prototype.visible=!1,O.jsonID(`node`,A);var j=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new dt(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&A.isSelectable(n)?new A(t):O.near(t)}},M=class e extends O{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=_.v.empty){if(t==_.v.empty){e.delete(0,e.doc.content.size);let t=O.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return ft}};O.jsonID(`all`,M);var ft={map(){return this},resolve(e){return new M(e)}};function pt(e,t,n,r,i,a=!1){if(t.inlineContent)return k.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=pt(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&A.isSelectable(r))return A.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function mt(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Se||i instanceof T))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(O.near(e.doc.resolve(o),n))}var ht=1,gt=2,_t=4,vt=class extends ot{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.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(e){if(e.$from.doc!=this.doc)throw RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|ht)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&ht)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=gt,this}ensureMarks(e){return _.f.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&gt)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||_.f.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(O.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=_t,this}get scrolledIntoView(){return(this.updated&_t)>0}};function yt(e,t){return!t||!e?e:e.bind(t)}var bt=class{constructor(e,t,n){this.name=e,this.init=yt(t.init,n),this.apply=yt(t.apply,n)}},xt=[new bt(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new bt(`selection`,{init(e,t){return e.selection||O.atStart(t.doc)},apply(e){return e.selection}}),new bt(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new bt(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],St=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=xt.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new bt(e.key,e.spec.state,e))})}},Ct=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new vt(this)}static create(t){let n=new St(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new St(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new St(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=_.m.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=O.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function wt(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=wt(i,t,{})),n[r]=i}return n}var N=class{constructor(e){this.spec=e,this.props={},e.props&&wt(e.props,this,this.props),this.key=e.key?e.key.key:Et(`plugin`)}getState(e){return e[this.key]}},Tt=Object.create(null);function Et(e){return e in Tt?e+`$`+ ++Tt[e]:(Tt[e]=0,e+`$`)}var Dt=class{constructor(e=`key`){this.key=Et(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},P=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Ot=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},kt=null,At=function(e,t,n){let r=kt||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},jt=function(){kt=null},Mt=function(e,t,n,r){return n&&(Pt(e,t,n,r,-1)||Pt(e,t,n,r,1))},Nt=/^(img|br|input|textarea|hr)$/i;function Pt(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Ft(e))){let n=e.parentNode;if(!n||n.nodeType!=1||zt(e)||Nt.test(e.nodeName)||e.contentEditable==`false`)return!1;t=P(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`){if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1}else e=n,t=i<0?Ft(e):0}else return!1}}function Ft(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function It(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=Ft(e)}else if(e.parentNode&&!zt(e))t=P(e),e=e.parentNode;else return null}}function Lt(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable==`false`)return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!zt(e))t=P(e)+1,e=e.parentNode;else return null}}function Rt(e,t,n){for(let r=t==0,i=t==Ft(e);r||i;){if(e==n)return!0;let t=P(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==Ft(e)}}function zt(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var Bt=function(e){return e.focusNode&&Mt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Vt(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function Ht(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function Ut(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Ft(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Ft(r.startContainer),r.startOffset)}}}var Wt=typeof navigator<`u`?navigator:null,Gt=typeof document<`u`?document:null,Kt=Wt&&Wt.userAgent||``,qt=/Edge\/(\d+)/.exec(Kt),Jt=/MSIE \d/.exec(Kt),Yt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Kt),F=!!(Jt||Yt||qt),Xt=Jt?document.documentMode:Yt?+Yt[1]:qt?+qt[1]:0,Zt=!F&&/gecko\/(\d+)/i.test(Kt);Zt&&+(/Firefox\/(\d+)/.exec(Kt)||[0,0])[1];var Qt=!F&&/Chrome\/(\d+)/.exec(Kt),I=!!Qt,$t=Qt?+Qt[1]:0,L=!F&&!!Wt&&/Apple Computer/.test(Wt.vendor),en=L&&(/Mobile\/\w+/.test(Kt)||!!Wt&&Wt.maxTouchPoints>2),tn=en||(Wt?/Mac/.test(Wt.platform):!1),nn=Wt?/Win/.test(Wt.platform):!1,rn=/Android \d/.test(Kt),an=!!Gt&&`webkitFontSmoothing`in Gt.documentElement.style,on=an?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function sn(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function cn(e,t){return typeof e==`number`?e:e[t]}function ln(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function un(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=Ot(o);continue}let e=o,n=e==a.body,s=n?sn(a):ln(e),c=0,l=0;if(t.top<s.top+cn(r,`top`)?l=-(s.top-t.top+cn(i,`top`)):t.bottom>s.bottom-cn(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+cn(i,`top`)-s.top:t.bottom-s.bottom+cn(i,`bottom`)),t.left<s.left+cn(r,`left`)?c=-(s.left-t.left+cn(i,`left`)):t.right>s.right-cn(r,`right`)&&(c=t.right-s.right+cn(i,`right`)),c||l){if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:Ot(o)}}function dn(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o<Math.min(innerHeight,t.bottom);o+=5){let t=e.root.elementFromPoint(a,o);if(!t||t==e.dom||!e.dom.contains(t))continue;let s=t.getBoundingClientRect();if(s.top>=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:fn(e.dom)}}function fn(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Ot(r));return t}function pn({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;mn(n,r==0?0:r-t)}function mn(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:a}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var hn=null;function gn(e){if(e.setActive)return e.setActive();if(hn)return e.focus(hn);let t=fn(e);e.focus(hn==null?{get preventScroll(){return hn={preventScroll:!0},!0}}:void 0),hn||(hn=!1,mn(t,0))}function _n(e,t){let n,r=2e8,i,a=0,o=t.top,s=t.top,c,l;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(u.nodeType==1)e=u.getClientRects();else if(u.nodeType==3)e=At(u).getClientRects();else continue;for(let f=0;f<e.length;f++){let p=e[f];if(p.top<=o&&p.bottom>=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=u,r=e,i=e&&n.nodeType==3?{left:p.right<t.left?p.right:p.left,top:t.top}:t,u.nodeType==1&&e&&(a=d+ +(t.left>=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?vn(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:_n(n,i)}function vn(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(e,a+1),r.setStart(e,a);let n=En(r,1);if(n.top!=n.bottom&&yn(t,n)){i={node:e,offset:a+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function yn(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function bn(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function xn(e,t,n){let{node:r,offset:i}=_n(t,n),a=-1;if(r.nodeType==1&&!r.firstChild){let e=r.getBoundingClientRect();a=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function Sn(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right<r.left||o.bottom<r.top)&&(i=t.posAfter),a=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}function Cn(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let n=e.childNodes[a];if(n.nodeType==1){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(yn(t,i))return Cn(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function wn(e,t){let n=e.dom.ownerDocument,r,i=0,a=Ut(n,t.left,t.top);a&&({node:r,offset:i}=a);let o=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!o||!e.dom.contains(o.nodeType==1?o:o.parentNode)){let n=e.dom.getBoundingClientRect();if(!yn(t,n)||(o=Cn(e.dom,t,n),!o))return null}if(L)for(let e=o;r&&e;e=Ot(e))e.draggable&&(r=void 0);if(o=bn(o,t),r){if(Zt&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let e=r.childNodes[i],n;e.nodeName==`IMG`&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&i++}let n;an&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=Sn(e,r,i,t))}s??=xn(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function Tn(e){return e.top<e.bottom||e.left<e.right}function En(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(Tn(e))return e}return Array.prototype.find.call(n,Tn)||e.getBoundingClientRect()}var Dn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function On(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=an||Zt;if(r.nodeType==3){if(o&&(Dn.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=En(At(r,i,i),n);if(Zt&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=En(At(r,i-1,i-1),-1);if(t.top==e.top){let n=En(At(r,i,i+1),-1);if(n.top!=e.top)return kn(n,n.left<t.left)}}return e}{let e=i,t=i,a=n<0?1:-1;return n<0&&!i?(t++,a=-1):n>=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,kn(En(At(r,e,t),a),a<0)}}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Ft(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return An(e.getBoundingClientRect(),!1)}if(a==null&&i<Ft(r)){let e=r.childNodes[i];if(e.nodeType==1)return An(e.getBoundingClientRect(),!0)}return An(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==Ft(r))){let e=r.childNodes[i-1],t=e.nodeType==3?At(e,Ft(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return kn(En(t,1),!1)}if(a==null&&i<Ft(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?At(e,0,+!o):e.nodeType==1?e:null:null;if(t)return kn(En(t,-1),!0)}return kn(En(r.nodeType==3?At(r):r,-n),n>=0)}function kn(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function An(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function jn(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function Mn(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return jn(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=On(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=At(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var Nn=/[\u0590-\u08ac]/;function Pn(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!Nn.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:jn(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var Fn=null,In=null,Ln=!1;function Rn(e,t,n){return Fn==t&&In==n?Ln:(Fn=t,In=n,Ln=n==`up`||n==`down`?Mn(e,t,n):Pn(e,t,n))}var zn=0,Bn=1,Vn=2,Hn=3,Un=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=zn,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)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(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.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(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>P(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node)){if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],a=t+i.size;if(a>e||i instanceof Xn){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof Wn&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?P(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,!(!e||e.dom.parentNode==this.contentDOM);n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?P(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let a=n,o=0;;o++){let n=this.children[o],s=a+n.size;if(r==-1&&e<=s){let i=a+n.border;if(e>=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=P(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=P(n.dom);break}t+=n.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw RangeError(`No node after pos `+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),a=Math.max(e,t);for(let o=0,s=0;o<this.children.length;o++){let c=this.children[o],l=s+c.size;if(i>s&&a<l)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=l}let o=this.domFromPos(e,e?-1:1),s=t==e?o:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),l=n.domSelectionRange(),u=!1;if((Zt||L)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
37
+ `),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:P(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(Zt&&l.focusNode&&l.focusNode!=s.node&&l.focusNode.nodeType==1){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&L)&&Mt(o.node,o.offset,l.anchorNode,l.anchorOffset)&&Mt(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&Zt)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?Vn:Bn,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Hn:i.markDirty(e-r,t-r);return}i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Vn:Hn}n=a}this.dirty=Vn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Vn:Bn;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Wn=class extends Un{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==zn&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||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}},Gn=class extends Un{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},Kn=class e extends Un{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=_.u.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Hn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Hn&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=zn){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=zn}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=pr(a,n,o,r)),t>0&&(a=pr(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},qn=class e extends Un{constructor(e,t,n,r,i,a,o,s,c){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=_.u.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=ir(u,r,n),l?c=new Zn(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new Yn(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(e.preserveWhitespace=`full`),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>_.d.empty)}return e}matchesNode(e,t,n){return this.dirty==zn&&e.eq(this.node)&&ar(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new sr(this,a&&a.node,e);ur(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?_.f.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==Vn)&&(a&&this.protectLocalComposition(e,a),Qn(this.contentDOM,this.children,e),en&&dr(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof k)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=fr(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;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 a=new Gn(this,i,t,r);e.input.compositionNodes.push(a),this.children=pr(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==Hn||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=zn}updateOuterDeco(e){if(ar(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=nr(this.dom,this.nodeDOM,tr(this.outerDeco,this.node,t),tr(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function Jn(e,t,n,r,i){ir(r,t,e);let a=new qn(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var Yn=class e extends qn{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==Hn||this.dirty!=zn&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=zn||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=zn,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Hn)}get domAtom(){return!1}isText(e){return this.node.text==e}},Xn=class extends Un{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==zn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},Zn=class extends qn{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==Hn)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Qn(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=or(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof Kn){let t=r?r.previousSibling:e.lastChild;Qn(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=or(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var $n=function(e){e&&(this.nodeName=e)};$n.prototype=Object.create(null);var er=[new $n];function tr(e,t,n){if(e.length==0)return er;let r=n?er[0]:new $n,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new $n(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new $n(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function nr(e,t,n,r){if(n==er&&r==er)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName?i=t:(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=er[0],i=t)}rr(i,o||er[0],a)}return i}function rr(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function ir(e,t,n){return nr(e,e,er,tr(t,n,e.nodeType!=1))}function ar(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function or(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var sr=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=cr(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=zn,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.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 t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;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=Kn.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==Hn&&a.dom==a.contentDOM&&(a.dirty=Vn),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof qn){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=Hn&&ar(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Vn,u.updateChildren(r,a+1),u.dirty=zn),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ar(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=qn.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=qn.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new Wn(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Kn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Yn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((L||I)&&e&&e.dom.contentEditable==`false`&&this.addHackNode(`IMG`,t),this.addHackNode(`BR`,this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new Xn(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function cr(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];outer:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof Kn)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function lr(e,t){return e.type.side-t.type.side}function ur(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u){if(d){d.sort(lr);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c)}let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function dr(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function fr(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function pr(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function mr(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(Bt(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&A.isSelectable(e)&&i.parent&&!(e.isInline&&Rt(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new A(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=Tr(e,u,s,n)}return l}function hr(e){return e.editable?e.hasFocus():Dr(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function gr(e,t=!1){let n=e.state.selection;if(Cr(e,n),hr(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&I){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Mt(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)Sr(e);else{let{anchor:r,head:i}=n,a,o;_r&&!(n instanceof k)&&(n.$from.parent.inlineContent||(a=vr(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=vr(e,n.to))),e.docView.setSelection(r,i,e,t),_r&&(a&&br(a),o&&br(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&xr(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var _r=L||I&&$t<63;function vr(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(L&&i&&i.contentEditable==`false`)return yr(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return yr(i);if(a)return yr(a)}}function yr(e){return e.contentEditable=`true`,L&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function br(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function xr(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!hr(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function Sr(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,P(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&F&&Xt<=11&&(n.disabled=!0,n.disabled=!1)}function Cr(e,t){if(t instanceof A){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(wr(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else wr(e)}function wr(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function Tr(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||k.between(t,n,r)}function Er(e){return e.editable&&!e.hasFocus()?!1:Dr(e)}function Dr(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Or(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Mt(t.node,t.offset,n.anchorNode,n.anchorOffset)}function kr(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&O.findFrom(a,t)}function Ar(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function jr(e,t,n){let r=e.state.selection;if(r instanceof k){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Ar(e,new k(r.$anchor,a))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=kr(e.state,t);return n&&n instanceof A?Ar(e,n):!1}if(!(tn&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?A.isSelectable(i)?Ar(e,new A(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):an?Ar(e,new k(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof A&&r.node.isInline)return Ar(e,new k(t>0?r.$to:r.$from));else{let n=kr(e.state,t);return n?Ar(e,n):!1}}function Mr(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Nr(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function Pr(e,t){return t<0?Fr(e):Ir(e)}function Fr(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(Zt&&n.nodeType==1&&r<Mr(n)&&Nr(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(Nr(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(Lr(n))break;else{let t=n.previousSibling;for(;t&&Nr(t,-1);)i=n.parentNode,a=P(t),t=t.previousSibling;if(t)n=t,r=Mr(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?Br(e,n,r):i&&Br(e,i,a)}function Ir(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=Mr(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(Nr(e,1))a=n,o=++r;else break}else if(Lr(n))break;else{let t=n.nextSibling;for(;t&&Nr(t,1);)a=t.parentNode,o=P(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=Mr(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&Br(e,a,o)}function Lr(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Rr(e,t){for(;e&&t==e.childNodes.length&&!zt(e);)t=P(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=0}}function zr(e,t){for(;e&&!t&&!zt(e);)t=P(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function Br(e,t,n){if(t.nodeType!=3){let e,r;(r=Rr(t,n))?(t=r,n=0):(e=zr(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Bt(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&gr(e)},50)}function Vr(e,t){let n=e.state.doc.resolve(t);if(!(I||nn)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-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(t<n.end()){let n=e.coordsAtPos(t+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 getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function Hr(e,t,n){let r=e.state.selection;if(r instanceof k&&!r.empty||n.indexOf(`s`)>-1||tn&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=kr(e.state,t);if(n&&n instanceof A)return Ar(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof M?O.near(n,t):O.findFrom(n,t);return o?Ar(e,o):!1}return!1}function Ur(e,t){if(!(e.state.selection instanceof k))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function Wr(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Gr(e){if(!L||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;Wr(e,n,`true`),setTimeout(()=>Wr(e,n,`false`),20)}return!1}function Kr(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function qr(e,t){let n=t.keyCode,r=Kr(t);if(n==8||tn&&n==72&&r==`c`)return Ur(e,-1)||Pr(e,-1);if(n==46&&!t.shiftKey||tn&&n==68&&r==`c`)return Ur(e,1)||Pr(e,1);if(n==13||n==27)return!0;if(n==37||tn&&n==66&&r==`c`){let t=n==37?Vr(e,e.state.selection.from)==`ltr`?-1:1:-1;return jr(e,t,r)||Pr(e,t)}if(n==39||tn&&n==70&&r==`c`){let t=n==39?Vr(e,e.state.selection.from)==`ltr`?1:-1:1;return jr(e,t,r)||Pr(e,t)}return n==38||tn&&n==80&&r==`c`?Hr(e,-1,r)||Pr(e,-1):n==40||tn&&n==78&&r==`c`?Gr(e)||Hr(e,1,r)||Pr(e,1):!(r!=(tn?`m`:`c`)||n!=66&&n!=73&&n!=89&&n!=90)}function Jr(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||_.u.fromSchema(e.state.schema),s=ai(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=ri[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
30
38
 
31
- `),slice:t}}function Jr(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new h.v(h.d.from(e.state.schema.text(t.replace(/\r\n?/g,`
32
- `))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=h.u.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=si(n),rn&&ci(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||h.l.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Yr.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=li(ti(s,+u[1],+u[2]),u[4]);else if(s=h.v.maxOpen(Xr(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=ti(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var Yr=/^(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 Xr(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&Qr(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=$r(a[a.length-1],i.length));let n=Zr(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return h.d.from(a)}return e}function Zr(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,h.d.from(e));return e}function Qr(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=Qr(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(h.d.from(Zr(n,e,i+1))))}}function $r(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,$r(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(h.d.empty,!0);return e.copy(n.append(r))}function ei(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=ei(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(h.d.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function ti(e,t,n){return t<e.openStart&&(e=new h.v(ei(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new h.v(ei(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var ni={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},ri=null;function ii(){return ri||=document.implementation.createHTMLDocument(`title`)}var ai=null;function oi(e){let t=window.trustedTypes;return t?(ai||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),ai.createHTML(e)):e}function si(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=ii().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&ni[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=oi(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function ci(e){let t=e.querySelectorAll(F?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function li(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=h.d.from(t.create(r[e+1],i)),a++,o++}return new h.v(i,a,o)}var L={},R={},ui={touchstart:!0,touchmove:!0},di=class{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 fi(e){for(let t in L){let n=L[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{_i(e,t)&&!gi(e,t)&&(e.editable||!(t.type in R))&&n(e,t)},ui[t]?{passive:!0}:void 0)}I&&e.dom.addEventListener(`input`,()=>null),hi(e)}function pi(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function mi(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function hi(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>gi(e,t))})}function gi(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function _i(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function vi(e,t){!gi(e,t)&&L[t.type]&&(e.editable||!(t.type in R))&&L[t.type](e,t)}R.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Mi(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(nn&&F&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),$t&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,Bt(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||Kr(e,n)?n.preventDefault():pi(e,`key`)},R.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},R.keypress=(e,t)=>{let n=t;if(Mi(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||en&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof k)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function yi(e){return{left:e.clientX,top:e.clientY}}function bi(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function xi(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function Si(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function Ci(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&A.isSelectable(r)?(Si(e,new A(n),`pointer`),!0):!1}function wi(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof A&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(A.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(Si(e,A.create(e.state.doc,i),`pointer`),!0)}function Ti(e,t,n,r,i){return xi(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?wi(e,n):Ci(e,n))}function Ei(e,t,n,r){return xi(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Di(e,t,n,r){return xi(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Oi(e,n,r)}function Oi(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(Si(e,k.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)Si(e,k.create(r,a+1,a+1+n.content.size),`pointer`);else if(A.isSelectable(n))Si(e,A.create(r,a),`pointer`);else continue;return!0}}function ki(e){return zi(e)}var Ai=en?`metaKey`:`ctrlKey`;L.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=ki(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&bi(n,e.input.lastClick)&&!n[Ai]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(yi(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new ji(e,o,n,!!r)):(a==`doubleClick`?Ei:Di)(e,o.pos,o.inside,n)?n.preventDefault():pi(e,`pointer`))};var ji=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Ai],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof A&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Xt&&!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()),e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this)),pi(e,`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(()=>hr(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(yi(e))),this.updateAllowDefault(e),this.allowDefault||!t?pi(this.view,`pointer`):Ti(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||I&&this.mightDrag&&!this.mightDrag.node.isAtom||F&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Si(this.view,O.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):pi(this.view,`pointer`)}move(e){this.updateAllowDefault(e),pi(this.view,`pointer`),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};L.touchstart=e=>{e.input.lastTouch=Date.now(),ki(e),pi(e,`pointer`)},L.touchmove=e=>{e.input.lastTouch=Date.now(),pi(e,`pointer`)},L.contextmenu=e=>ki(e);function Mi(e,t){return e.composing?!0:I&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Ni=nn?5e3:-1;R.compositionstart=R.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof k&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||F&&tn&&Pi(e)))e.markCursor=e.state.storedMarks||n.marks(),zi(e,!0),e.markCursor=null;else if(zi(e,!t.selection.empty),Xt&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}Fi(e,Ni)};function Pi(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}R.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Fi(e,20))};function Fi(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>zi(e),t))}function Ii(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Ri());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Li(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Ft(t.focusNode,t.focusOffset),r=It(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function Ri(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function zi(e,t=!1){if(!(nn&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Ii(e),t||e.docView&&e.docView.dirty){let n=pr(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Bi(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var Vi=P&&Yt<15||$t&&an<604;L.copy=R.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Vi?null:n.clipboardData,{dom:o,text:s}=qr(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Bi(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Hi(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Ui(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.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=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Wi(e,r.value,null,i,t):Wi(e,r.textContent,r.innerHTML,i,t)},50)}function Wi(e,t,n,r,i){let a=Jr(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||h.v.empty)))return!0;if(!a)return!1;let o=Hi(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function Gi(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}R.paste=(e,t)=>{let n=t;if(e.composing&&!nn)return;let r=Vi?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Wi(e,Gi(r),r.getData(`text/html`),i,n)?n.preventDefault():Ui(e,n)};var Ki=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},qi=en?`altKey`:`ctrlKey`;function Ji(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[qi]:!n}L.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(yi(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof A?i.to-1:i.to))){if(r&&r.mightDrag)o=A.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=A.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=qr(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!F||Qt>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Vi?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Vi||n.dataTransfer.setData(`text/plain`,c),e.dragging=new Ki(l,Ji(e,n),o)},L.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},R.dragover=R.dragenter=(e,t)=>t.preventDefault(),R.drop=(e,t)=>{try{Yi(e,t,e.dragging)}finally{e.dragging=null}};function Yi(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(yi(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=Jr(e,Gi(t.dataTransfer),Vi?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&Ji(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||h.v.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?Ve(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&A.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new A(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(wr(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}L.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&hr(e)},20))},L.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},L.beforeinput=(e,t)=>{if(F&&nn&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,Bt(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in R)L[e]=R[e];function Xi(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var Zi=class e{constructor(e,t){this.toDOM=e,this.spec=t||ta,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new z(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Xi(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Qi=class e{constructor(e,t){this.attrs=e,this.spec=t||ta}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new z(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&Xi(this.attrs,t.attrs)&&Xi(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},$i=class e{constructor(e,t){this.attrs=e,this.spec=t||ta}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new z(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&Xi(this.attrs,t.attrs)&&Xi(this.spec,t.spec)}destroy(){}},z=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new Zi(n,r))}static inline(t,n,r,i){return new e(t,n,new Qi(r,i))}static node(t,n,r,i){return new e(t,n,new $i(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Qi}get widget(){return this.type instanceof Zi}},ea=[],ta={},B=class e{constructor(e,t){this.local=e.length?e:ea,this.children=t.length?t:ea}static create(e,t){return t.length?ca(t,e,0,ta):V}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==V||e.maps.length==0?this:this.mapInner(e,t,0,0,n||ta)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?ra(this.children,o||[],t,n,r,i,a):o?new e(o.sort(la),ea):V}add(t,n){return n.length?this==V?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=oa(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,ca(s,e,o+1,ta)),a+=3}});let o=ia(a?sa(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(la):this.local,i||this.children)}remove(e){return e.length==0||this==V?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==V?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):V}forChild(t,n){if(this==V)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof Qi){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(la),ea);return r?new na([t,r]):t}return r||V}eq(t){if(this==t)return!0;if(!(t instanceof e)||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(e){return ua(this.localsInner(e))}localsInner(e){if(this==V)return ea;if(e.inlineContent||!this.local.some(Qi.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof Qi||t.push(this.local[e]);return t}forEachSet(e){e(this)}};B.empty=new B([],[]),B.removeOverlap=ua;var V=B.empty,na=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,ta));return e.from(r)}forChild(t,n){if(n.isLeaf)return B.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=V&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||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(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?ua(n?t:t.sort(la)):ea}static from(t){switch(t.length){case 0:return V;case 1:return t[0];default:return new e(t.every(e=>e instanceof B)?t:t.reduce((e,t)=>e.concat(t instanceof B?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function ra(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==V?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=ca(aa(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new B(t.sort(la),s)}function ia(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new z(i.from+t,i.to+t,i.type))}return n}function aa(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function oa(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function sa(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function ca(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=oa(e,t,o+n);if(s){a=!0;let e=ca(s,t,n+o+1,r);e!=V&&i.push(o,o+t.nodeSize,e)}});let o=ia(a?sa(e):e,-n).sort(la);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new B(o,i):V}function la(e,t){return e.from-t.from||e.to-t.to}function ua(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),da(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),da(t,i,r.copy(a.from,r.to)));break}}}return t}function da(e,t,n){for(;t<e.length&&la(n,e[t])>0;)t++;e.splice(t,0,n)}function fa(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=V&&t.push(r)}),e.cursorWrapper&&t.push(B.create(e.state.doc,[e.cursorWrapper.deco])),na.from(t)}var pa={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ma=P&&Yt<=11,ha=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},ga=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ha,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);P&&Yt<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():I&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),ma&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.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,pa)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);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(Tr(this.view)){if(this.suppressingSelectionUpdates)return hr(this.view);if(P&&Yt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&jt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=Dt(n))t.add(n);for(let r=e.anchorNode;r;r=Dt(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Tr(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(Xt&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Sa(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&zt(n)&&(c=pr(e))&&c.eq(O.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,hr(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),ya(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Ca(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||hr(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(P&&Yt<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?N(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?N(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},_a=new WeakMap,va=!1;function ya(e){if(!_a.has(e)&&(_a.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=Xt,va)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.`),va=!0}}function ba(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return jt(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function xa(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return ba(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?ba(e,n):null}function Sa(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Ca(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function wa(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,u=c.anchorNode;if(u&&e.dom.contains(u.nodeType==1?u:u.parentNode)&&(l=[{node:u,offset:c.anchorOffset}],zt(c)||l.push({node:c.focusNode,offset:c.focusOffset})),F&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||h.l.fromSchema(e.state.schema),p=d.resolve(o),m=null,g=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:Ta,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:g,sel:m,from:o,to:s}}function Ta(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(I&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||I&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var Ea=/^(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 Da(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=pr(e,t);if(n&&!e.state.selection.eq(n)){if(F&&nn&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,Bt(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=wa(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=Ma(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,($t&&e.input.lastIOSEnter>Date.now()-225||nn)&&i.some(e=>e.nodeType==1&&!Ea.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,Bt(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof k&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Oa(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof k&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),P&&Yt<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),ee=u.resolve(m.start),te=h.sameParent(g)&&h.parent.inlineContent&&ee.end()>=m.endA;if(($t&&e.input.lastIOSEnter>Date.now()-225&&(!te||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!te&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,Bt(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&Aa(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,Bt(8,`Backspace`)))){nn&&F&&e.domObserver.suppressSelectionUpdates();return}F&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),nn&&!te&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,Bt(13,`Enter`))})},20));let _=m.start,v=m.endA,y=t=>{let n=t||e.state.tr.replace(_,v,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Oa(e,n.doc,l.sel);t&&!(F&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==_||t.head==n.mapping.map(v)-1)||P&&t.empty&&t.head==_)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},ne;if(te)if(h.pos==g.pos){P&&Yt<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>hr(e),20));let t=y(e.state.tr.delete(_,v)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(ne=ka(h.parent.content.cut(h.parentOffset,g.parentOffset),ee.parent.content.cut(ee.parentOffset,m.endA-ee.start())))){let t=y(e.state.tr);ne.type==`add`?t.addMark(_,v,ne.mark):t.removeMark(_,v,ne.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>y(e.state.tr.insertText(t,_,v));e.someProp(`handleTextInput`,r=>r(e,_,v,t,n))||e.dispatch(n())}else e.dispatch(y());else e.dispatch(y())}function Oa(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:wr(e,t.resolve(n.anchor),t.resolve(n.head))}function ka(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(h.d.from(l).eq(e))return{mark:s,type:o}}function Aa(e,t,n,r,i){if(n-t<=i.pos-r.pos||ja(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(ja(a,!0,!0));return!o.parent.isTextblock||o.pos>n||ja(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function ja(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Ma(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&Na(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&Na(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function Na(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var Pa=class{constructor(e,t){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 di,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Va),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=La(this),Ia(this),this.nodeViews=za(this),this.docView=qn(this.state.doc,Fa(this),fa(this),this.dom,this),this.domObserver=new ga(this,(e,t,n,r)=>Da(this,e,t,n,r)),this.domObserver.start(),fi(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&hi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Va),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Ii(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=za(this);Ba(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&hi(this),this.editable=La(this),Ia(this);let o=fa(this),s=Fa(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&un(this);if(i){this.domObserver.stop();let t=l&&(P||F)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Ra(n.selection,e.selection);if(l){let n=F?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Li(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=qn(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Dr(this))?hr(this,t):(Sr(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&fn(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof A){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ln(this,t.getBoundingClientRect(),e)}else ln(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new Ki(e.slice,e.move,r<0?void 0:A.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(P){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable==`false`)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&hn(this.dom),hr(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Cn(this,e)}coordsAtPos(e,t=1){return Dn(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Ln(this,t||this.state,e)}pasteHTML(e,t){return Wi(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return Wi(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return qr(this,e)}destroy(){this.docView&&(mi(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],fa(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,At())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return vi(this,e)}domSelectionRange(){let e=this.domSelection();return e?I&&this.root.nodeType===11&&Vt(this.dom.ownerDocument)==this.dom&&xa(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Pa.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Fa(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[z.node(0,e.state.doc.content.size,t)]}function Ia(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:z.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function La(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Ra(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function za(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function Ba(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function Va(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var Ha={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:`'`},Ua={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Wa=typeof navigator<`u`&&/Mac/.test(navigator.platform),Ga=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),H=0;H<10;H++)Ha[48+H]=Ha[96+H]=String(H);for(var H=1;H<=24;H++)Ha[H+111]=`F`+H;for(var H=65;H<=90;H++)Ha[H]=String.fromCharCode(H+32),Ua[H]=String.fromCharCode(H);for(var Ka in Ha)Ua.hasOwnProperty(Ka)||(Ua[Ka]=Ha[Ka]);function qa(e){var t=!(Wa&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Ga&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Ua:Ha)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var Ja=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ya=typeof navigator<`u`&&/Win/.test(navigator.platform);function Xa(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))Ja?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function Za(e){let t=Object.create(null);for(let n in e)t[Xa(n)]=e[n];return t}function Qa(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function U(e){return new M({props:{handleKeyDown:$a(e)}})}function $a(e){let t=Za(e);return function(e,n){let r=qa(n),i,a=t[Qa(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[Qa(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Ya&&n.ctrlKey&&n.altKey)&&(i=Ha[n.keyCode])&&i!=r){let r=t[Qa(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var eo=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function to(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var no=(e,t,n)=>{let r=to(e,n);if(!r)return!1;let i=ao(r);if(!i){let n=r.blockRange(),i=n&&Ee(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(bo(e,i,t,-1))return!0;if(r.parent.content.size==0&&(ro(a,`end`)||A.isSelectable(a)))for(let n=r.depth;;n--){let o=He(e.doc,r.before(n),r.after(n),h.v.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(ro(a,`end`)?O.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):A.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1};function ro(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var io=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=ao(r)}let o=a&&a.nodeBefore;return!o||!A.isSelectable(o)?!1:(t&&t(e.tr.setSelection(A.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function ao(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function oo(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var so=(e,t,n)=>{let r=oo(e,n);if(!r)return!1;let i=lo(r);if(!i)return!1;let a=i.nodeAfter;if(bo(e,i,t,1))return!0;if(r.parent.content.size==0&&(ro(a,`start`)||A.isSelectable(a))){let n=He(e.doc,r.before(),r.after(),h.v.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(ro(a,`start`)?O.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):A.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},co=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=lo(r)}let o=a&&a.nodeAfter;return!o||!A.isSelectable(o)?!1:(t&&t(e.tr.setSelection(A.create(e.doc,a.pos)).scrollIntoView()),!0)};function lo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var uo=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
33
- `).scrollIntoView()),!0)};function fo(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var po=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=fo(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(O.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},mo=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof j||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=fo(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(k.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},ho=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Pe(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Ee(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function go(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof A&&t.selection.node.isBlock)return!r.parentOffset||!Pe(t.doc,r.pos)?!1:(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,s,c=!1,l=!1;for(let t=r.depth;;t--)if(r.node(t).isBlock){c=r.end(t)==r.pos+(r.depth-t),l=r.start(t)==r.pos-(r.depth-t),s=fo(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(i.parent,c,r);a.unshift(n||(c&&s?{type:s}:null)),o=t;break}else{if(t==1)return!1;a.unshift(null)}let u=t.tr;(t.selection instanceof k||t.selection instanceof j)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=Pe(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,Pe(u.doc,d,a.length,a)),!f)return!1;if(u.split(d,a.length,a),!c&&l&&r.node(o).type!=s){let e=u.mapping.map(r.before(o)),t=u.doc.resolve(e);s&&r.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&u.setNodeMarkup(u.mapping.map(r.before(o)),s)}return n&&n(u.scrollIntoView()),!0}}var _o=go(),vo=(e,t)=>(t&&t(e.tr.setSelection(new j(e.doc))),!0);function yo(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||Ie(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function bo(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&yo(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=h.d.empty;for(let e=o.length-1;e>=0;e--)s=h.d.from(o[e].create(null,s));s=h.d.from(i.copy(s));let c=e.tr.step(new T(t.pos-1,r,t.pos,r,new h.v(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&Ie(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:O.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&Ee(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&ro(a,`start`,!0)&&ro(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=h.d.empty;for(let e=o.length-1;e>=0;e--)r=h.d.from(o[e].copy(r));n(e.tr.step(new T(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new h.v(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function xo(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(k.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var So=xo(-1),Co=xo(1);function wo(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:a,$to:o}=t[i],s=a.depth==0?e.inlineContent&&e.type.allowsMarkType(n):!1;if(e.nodesBetween(a.pos,o.pos,(e,t)=>{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function To(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new ot(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new ot(r,i))}return t}function Eo(e,t=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,a=!(n&&n.includeWhitespace);return function(n,o){let{empty:s,$cursor:c,ranges:l}=n.selection;if(s&&!c||!wo(n.doc,l,e,i))return!1;if(o)if(c)e.isInSet(n.storedMarks||c.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let s,c=n.tr;i||(l=To(l)),s=r?!l.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!l.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,a)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!a&&a.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<l.length;n++){let{$from:r,$to:i}=l[n];if(!s)c.removeMark(r.pos,i.pos,e);else{let n=r.pos,o=i.pos,s=r.nodeAfter,l=i.nodeBefore,u=a&&s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+u<o&&(n+=u,o-=d),c.addMark(n,o,e.create(t))}}o(c.scrollIntoView())}return!0}}function Do(e,t){return n=>{if(!n.isGeneric)return e(n);let r=[];for(let e=0;e<n.mapping.maps.length;e++){let t=n.mapping.maps[e];for(let e=0;e<r.length;e++)r[e]=t.map(r[e]);t.forEach((e,t,n,i)=>r.push(n,i))}let i=[];for(let e=0;e<r.length;e+=2){let a=r[e],o=r[e+1],s=n.doc.resolve(a),c=s.sharedDepth(o),l=s.node(c);for(let e=s.indexAfter(c),n=s.after(c+1);n<=o;++e){let r=l.maybeChild(e);if(!r)break;if(e&&i.indexOf(n)==-1){let a=l.child(e-1);a.type==r.type&&t(a,r)&&i.push(n)}n+=r.nodeSize}}i.sort((e,t)=>e-t);for(let e=i.length-1;e>=0;e--)Ie(n.doc,i[e])&&n.join(i[e]);e(n)}}function Oo(e,t){let n=Array.isArray(t)?e=>t.indexOf(e.type.name)>-1:t;return(t,r,i)=>e(t,r&&Do(r,n),i)}function ko(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var Ao=ko(eo,no,io),jo=ko(eo,so,co),Mo={Enter:ko(uo,mo,ho,_o),"Mod-Enter":po,Backspace:Ao,"Mod-Backspace":Ao,"Shift-Backspace":Ao,Delete:jo,"Mod-Delete":jo,"Mod-a":vo},No={"Ctrl-h":Mo.Backspace,"Alt-Backspace":Mo[`Mod-Backspace`],"Ctrl-d":Mo.Delete,"Ctrl-Alt-Backspace":Mo[`Mod-Delete`],"Alt-Delete":Mo[`Mod-Delete`],"Alt-d":Mo[`Mod-Delete`],"Ctrl-a":So,"Ctrl-e":Co};for(let e in Mo)No[e]=Mo[e];var Po=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?No:Mo,Fo=`.ProseMirror{word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0;position:relative}.ProseMirror pre{white-space:pre-wrap}.ProseMirror li{position:relative}.ProseMirror-hideselection ::selection{background:0 0}.ProseMirror-hideselection ::selection{background:0 0}.ProseMirror-hideselection{caret-color:#0000}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";pointer-events:none;border:2px solid #8cf;position:absolute;inset:-2px -2px -2px -32px}img.ProseMirror-separator{border:none!important;margin:0!important;display:inline!important}`;function Io(e={}){return new M({view(t){return new Lo(t,e)}})}var Lo=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.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`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=Ve(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},W=class e extends O{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):O.near(r)}content(){return h.v.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new Ro(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Bo(e)||!Vo(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!A.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};W.prototype.visible=!1,W.findFrom=W.findGapCursorFrom,O.jsonID(`gapcursor`,W);var Ro=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return W.valid(t)?new W(t):O.near(t)}};function zo(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Bo(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||zo(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Vo(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||zo(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Ho(){return new M({props:{decorations:qo,createSelectionBetween(e,t,n){return t.pos==n.pos&&W.valid(n)?new W(n):null},handleClick:Go,handleKeyDown:Uo,handleDOMEvents:{beforeinput:Ko}}})}var Uo=$a({ArrowLeft:Wo(`horiz`,-1),ArrowRight:Wo(`horiz`,1),ArrowUp:Wo(`vert`,-1),ArrowDown:Wo(`vert`,1)});function Wo(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof k){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=W.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new W(c))),!0):!1}}function Go(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!W.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&A.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new W(r))),!0)}function Ko(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof W))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=h.d.empty;for(let e=r.length-1;e>=0;e--)i=h.d.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new h.v(i,0,0));return a.setSelection(k.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function qo(e){if(!(e.selection instanceof W))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,B.create(e.doc,[z.widget(e.selection.head,t,{key:`gapcursor`})])}function Jo(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}}var Yo=`[data-class=ui-select]{min-inline-size:120px;margin-block:-4px}.ui-divider{block-size:20px}.ui-button-group{gap:4px;display:flex}.ui-tooltip,.ui-menu{--_popup-display:contents;display:contents}.ui-tooltip-wrapper{display:contents}`,Xo=class{constructor(e){this.plugin=new M({state:{init:()=>e,apply:(e,t)=>{let n=e.getMeta(this.plugin);return n===void 0?t:n}}})}getValue(e){return this.plugin.getState(e.state)}setValue(e,t){e.dispatchTransaction(e.tr.setMeta(this.plugin,t))}},Zo=`.ProseMirror{box-sizing:border-box;padding:var(--editor-padding-block) var(--editor-padding-inline);outline:none;flex:1 0 0}.ProseMirror-selectednode{--focus-stroke-gap-color:transparent;--focus-border-radius:2px;outline:none;position:relative}.ProseMirror-selectednode:after{box-shadow:0 0 0 4px color-mix(in sRGB, var(--focus-stroke-color,var(--vvd-color-cta-500)), transparent 85%), inset 0 0 0 3px var(--focus-stroke-gap-color,currentColor);outline:1px solid var(--focus-stroke-color,var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset,0px));border-radius:var(--focus-border-radius,inherit);block-size:calc(100% + var(--focus-block-size-addition,4px));content:"";inline-size:calc(100% + var(--focus-block-size-addition,4px));display:block;position:absolute;inset-block-start:50%;inset-inline-start:50%;transform:translate(-50%,-50%)}.editor--disabled .ProseMirror{color:var(--vvd-color-neutral-300);cursor:not-allowed}`,Qo=class extends h.r{constructor(...e){super(...e),this.name=`RteForeignHtmlFeature`}getPlugins(e){return[this.contribution(new M({props:{transformPastedHTML:t=>e.foreignHtmlParser[h.c].transform(t),clipboardParser:e.foreignHtmlParser[h.c].parser,clipboardSerializer:e.foreignHtmlSerializer[h.c].serializer}}))]}},$o=e=>{if(e.parentOffset!==e.parent.content.size)return null;let t=e.nodeBefore;return t&&t.isInline&&t.isAtom&&!t.isText?{}:null},es=e=>{let t=e.nodeAfter;return t&&t.isInline&&t.isAtom&&!t.isText?{afterCursor:!0}:null};function ts(e){let t=document.createElement(`span`);t.textContent=`​`;for(let[n,r]of Object.entries(e))t.style.setProperty(n,r);return t}var ns=class extends h.r{constructor(...e){super(...e),this.name=`RteCursorFix`}getPlugins(e){let t=[$o,es];for(let n of Object.values(e.schema.marks)){let e=n.spec;e.cursorFix&&t.push(e.cursorFix)}return[this.contribution(new M({props:{decorations:e=>{let{$cursor:n}=e.selection;if(!n)return null;let r=[],i={},a=!1,o=!1;for(let r of t){let t=r(n,e);t&&(t.style&&Object.assign(i,t.style),t.afterCursor?o=!0:a=!0)}return a&&r.push(z.widget(n.pos,()=>ts(i),{side:-1})),o&&r.push(z.widget(n.pos,()=>ts(i),{side:1})),r.length===0?null:B.create(e.doc,r)}}}))]}};h.a(ns);var rs=new M({state:{init(){return null},apply(e,t){return e.getMeta(rs)||t}}}),is=class extends h.r{constructor(...e){super(...e),this.name=`RteCore`,this.disabled=new Xo(!1),this.scrollThreshold=void 0,this.scrollMargin=void 0}getStyles(){return[this.contribution(Fo),this.contribution(Zo),this.contribution(Yo)]}getPlugins(e){let t=go((t,n,r)=>{if(!n)return{type:t.type,attrs:t.attrs};let i=Jo(r.node(r.depth-1).contentMatchAt(r.indexAfter(r.depth-1)));return i?{type:i,attrs:e.textblockAttrs.extractFromNode(t)}:null}),n=ko(uo,mo,ho,(e,n)=>t(e,n&&(t=>{let r=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();r&&t.ensureMarks(r),n(t)})));return[this.contribution(this.disabled.plugin),this.contribution(new M({props:{editable:()=>!this.disabled.getValue(e),handleDOMEvents:{click:(t,n)=>this.disabled.getValue(e)?(n.preventDefault(),!0):!1}},view:t=>{let n=t.dom.getRootNode().querySelector(`.popovers`),r=()=>{let r=this.disabled.getValue(e);n.classList.toggle(`popovers--disabled`,r),t.dom.parentElement.classList.toggle(`editor--disabled`,r)};return r(),{update:()=>{r()}}}})),this.contribution(U({...Po,Enter:n,"Shift-Enter":n})),this.contribution(Io()),this.contribution(Ho()),this.contribution(rs)]}getFeatures(){return[this,new Qo,new ns]}};h.a(is);var{entries:as,setPrototypeOf:ss,isFrozen:cs,getPrototypeOf:ls,getOwnPropertyDescriptor:us}=Object,{freeze:G,seal:ds,create:fs}=Object,{apply:ps,construct:ms}=typeof Reflect<`u`&&Reflect;G||=function(e){return e},ds||=function(e){return e},ps||=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return e.apply(t,r)},ms||=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)};var hs=Y(Array.prototype.forEach),gs=Y(Array.prototype.lastIndexOf),_s=Y(Array.prototype.pop),vs=Y(Array.prototype.push),ys=Y(Array.prototype.splice),K=Array.isArray,bs=Y(String.prototype.toLowerCase),xs=Y(String.prototype.toString),Ss=Y(String.prototype.match),Cs=Y(String.prototype.replace),ws=Y(String.prototype.indexOf),Ts=Y(String.prototype.trim),Es=Y(Number.prototype.toString),Ds=Y(Boolean.prototype.toString),Os=typeof BigInt>`u`?null:Y(BigInt.prototype.toString),ks=typeof Symbol>`u`?null:Y(Symbol.prototype.toString),q=Y(Object.prototype.hasOwnProperty),As=Y(Object.prototype.toString),J=Y(RegExp.prototype.test),js=Ms(TypeError);function Y(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return ps(e,t,r)}}function Ms(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return ms(e,n)}}function X(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:bs;if(ss&&ss(e,null),!K(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(cs(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Ns(e){for(let t=0;t<e.length;t++)q(e,t)||(e[t]=null);return e}function Z(e){let t=fs(null);for(let[n,r]of as(e))q(e,n)&&(K(r)?t[n]=Ns(r):r&&typeof r==`object`&&r.constructor===Object?t[n]=Z(r):t[n]=r);return t}function Ps(e){switch(typeof e){case`string`:return e;case`number`:return Es(e);case`boolean`:return Ds(e);case`bigint`:return Os?Os(e):`0`;case`symbol`:return ks?ks(e):`Symbol()`;case`undefined`:return As(e);case`function`:case`object`:{if(e===null)return As(e);let t=e,n=Fs(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:As(e)}return As(e)}default:return As(e)}}function Fs(e,t){for(;e!==null;){let n=us(e,t);if(n){if(n.get)return Y(n.get);if(typeof n.value==`function`)return Y(n.value)}e=ls(e)}function n(){return null}return n}function Is(e){try{return J(e,``),!0}catch{return!1}}var Ls=G(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Rs=G(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),zs=G([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Bs=G([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Vs=G(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),Hs=G([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Us=G([`#text`]),Ws=G(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Gs=G(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Ks=G(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),qs=G([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Js=ds(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ys=ds(/<%[\w\W]*|[\w\W]*%>/gm),Xs=ds(/\$\{[\w\W]*/gm),Zs=ds(/^data-[\-\w.\u00B7-\uFFFF]+$/),Qs=ds(/^aria-[\-\w]+$/),$s=ds(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ec=ds(/^(?:\w+script|data):/i),tc=ds(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),nc=ds(/^html$/i),rc=ds(/^[a-z][.\w]*(-[.\w]+)+$/i),ic=Object.freeze({__proto__:null,ARIA_ATTR:Qs,ATTR_WHITESPACE:tc,CUSTOM_ELEMENT:rc,DATA_ATTR:Zs,DOCTYPE_NAME:nc,ERB_EXPR:Ys,IS_ALLOWED_URI:$s,IS_SCRIPT_OR_DATA:ec,MUSTACHE_EXPR:Js,TMPLIT_EXPR:Xs}),ac={element:1,text:3,progressingInstruction:7,comment:8,document:9},oc=function(){return typeof window>`u`?null:window},sc=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},cc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function lc(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:oc(),t=e=>lc(e);if(t.version=`3.4.2`,t.removed=[],!e||!e.document||e.document.nodeType!==ac.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e,r=n,i=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:s,Element:c,NodeFilter:l,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:f,trustedTypes:p}=e,m=c.prototype,h=Fs(m,`cloneNode`),g=Fs(m,`remove`),ee=Fs(m,`nextSibling`),te=Fs(m,`childNodes`),_=Fs(m,`parentNode`);if(typeof o==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let v,y=``,{implementation:ne,createNodeIterator:re,createDocumentFragment:ie,getElementsByTagName:ae}=n,{importNode:oe}=r,b=cc();t.isSupported=typeof as==`function`&&typeof _==`function`&&ne&&ne.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:se,ERB_EXPR:ce,TMPLIT_EXPR:le,DATA_ATTR:ue,ARIA_ATTR:de,IS_SCRIPT_OR_DATA:fe,ATTR_WHITESPACE:pe,CUSTOM_ELEMENT:me}=ic,{IS_ALLOWED_URI:he}=ic,x=null,S=X({},[...Ls,...Rs,...zs,...Vs,...Us]),C=null,ge=X({},[...Ws,...Gs,...Ks,...qs]),w=Object.seal(fs(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),_e=null,ve=null,ye=Object.seal(fs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),be=!0,T=!0,xe=!1,Se=!0,Ce=!1,we=!0,Te=!1,Ee=!1,De=!1,Oe=!1,ke=!1,Ae=!1,je=!0,Me=!1,Ne=`user-content-`,Pe=!0,Fe=!1,Ie={},Le=null,Re=X({},[`annotation-xml`,`audio`,`colgroup`,`desc`,`foreignobject`,`head`,`iframe`,`math`,`mi`,`mn`,`mo`,`ms`,`mtext`,`noembed`,`noframes`,`noscript`,`plaintext`,`script`,`style`,`svg`,`template`,`thead`,`title`,`video`,`xmp`]),ze=null,Be=X({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ve=null,He=X({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ue=`http://www.w3.org/1998/Math/MathML`,We=`http://www.w3.org/2000/svg`,E=`http://www.w3.org/1999/xhtml`,Ge=E,Ke=!1,qe=null,Je=X({},[Ue,We,E],xs),Ye=X({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Xe=X({},[`annotation-xml`]),Ze=X({},[`title`,`style`,`font`,`a`,`script`]),Qe=null,$e=[`application/xhtml+xml`,`text/html`],D=null,et=null,tt=n.createElement(`form`),nt=function(e){return e instanceof RegExp||e instanceof Function},rt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(et&&et===e)return;(!e||typeof e!=`object`)&&(e={}),e=Z(e),Qe=$e.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,D=Qe===`application/xhtml+xml`?xs:bs,x=q(e,`ALLOWED_TAGS`)&&K(e.ALLOWED_TAGS)?X({},e.ALLOWED_TAGS,D):S,C=q(e,`ALLOWED_ATTR`)&&K(e.ALLOWED_ATTR)?X({},e.ALLOWED_ATTR,D):ge,qe=q(e,`ALLOWED_NAMESPACES`)&&K(e.ALLOWED_NAMESPACES)?X({},e.ALLOWED_NAMESPACES,xs):Je,Ve=q(e,`ADD_URI_SAFE_ATTR`)&&K(e.ADD_URI_SAFE_ATTR)?X(Z(He),e.ADD_URI_SAFE_ATTR,D):He,ze=q(e,`ADD_DATA_URI_TAGS`)&&K(e.ADD_DATA_URI_TAGS)?X(Z(Be),e.ADD_DATA_URI_TAGS,D):Be,Le=q(e,`FORBID_CONTENTS`)&&K(e.FORBID_CONTENTS)?X({},e.FORBID_CONTENTS,D):Re,_e=q(e,`FORBID_TAGS`)&&K(e.FORBID_TAGS)?X({},e.FORBID_TAGS,D):Z({}),ve=q(e,`FORBID_ATTR`)&&K(e.FORBID_ATTR)?X({},e.FORBID_ATTR,D):Z({}),Ie=q(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Z(e.USE_PROFILES):e.USE_PROFILES:!1,be=e.ALLOW_ARIA_ATTR!==!1,T=e.ALLOW_DATA_ATTR!==!1,xe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Se=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ce=e.SAFE_FOR_TEMPLATES||!1,we=e.SAFE_FOR_XML!==!1,Te=e.WHOLE_DOCUMENT||!1,Oe=e.RETURN_DOM||!1,ke=e.RETURN_DOM_FRAGMENT||!1,Ae=e.RETURN_TRUSTED_TYPE||!1,De=e.FORCE_BODY||!1,je=e.SANITIZE_DOM!==!1,Me=e.SANITIZE_NAMED_PROPS||!1,Pe=e.KEEP_CONTENT!==!1,Fe=e.IN_PLACE||!1,he=Is(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:$s,Ge=typeof e.NAMESPACE==`string`?e.NAMESPACE:E,Ye=q(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?Z(e.MATHML_TEXT_INTEGRATION_POINTS):X({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Xe=q(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?Z(e.HTML_INTEGRATION_POINTS):X({},[`annotation-xml`]);let t=q(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?Z(e.CUSTOM_ELEMENT_HANDLING):fs(null);if(w=fs(null),q(t,`tagNameCheck`)&&nt(t.tagNameCheck)&&(w.tagNameCheck=t.tagNameCheck),q(t,`attributeNameCheck`)&&nt(t.attributeNameCheck)&&(w.attributeNameCheck=t.attributeNameCheck),q(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(w.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),Ce&&(T=!1),ke&&(Oe=!0),Ie&&(x=X({},Us),C=fs(null),Ie.html===!0&&(X(x,Ls),X(C,Ws)),Ie.svg===!0&&(X(x,Rs),X(C,Gs),X(C,qs)),Ie.svgFilters===!0&&(X(x,zs),X(C,Gs),X(C,qs)),Ie.mathMl===!0&&(X(x,Vs),X(C,Ks),X(C,qs))),ye.tagCheck=null,ye.attributeCheck=null,q(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?ye.tagCheck=e.ADD_TAGS:K(e.ADD_TAGS)&&(x===S&&(x=Z(x)),X(x,e.ADD_TAGS,D))),q(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?ye.attributeCheck=e.ADD_ATTR:K(e.ADD_ATTR)&&(C===ge&&(C=Z(C)),X(C,e.ADD_ATTR,D))),q(e,`ADD_URI_SAFE_ATTR`)&&K(e.ADD_URI_SAFE_ATTR)&&X(Ve,e.ADD_URI_SAFE_ATTR,D),q(e,`FORBID_CONTENTS`)&&K(e.FORBID_CONTENTS)&&(Le===Re&&(Le=Z(Le)),X(Le,e.FORBID_CONTENTS,D)),q(e,`ADD_FORBID_CONTENTS`)&&K(e.ADD_FORBID_CONTENTS)&&(Le===Re&&(Le=Z(Le)),X(Le,e.ADD_FORBID_CONTENTS,D)),Pe&&(x[`#text`]=!0),Te&&X(x,[`html`,`head`,`body`]),x.table&&(X(x,[`tbody`]),delete _e.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw js(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw js(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);v=e.TRUSTED_TYPES_POLICY,y=v.createHTML(``)}else v===void 0&&(v=sc(p,i)),v!==null&&typeof y==`string`&&(y=v.createHTML(``));G&&G(e),et=e},it=X({},[...Rs,...zs,...Bs]),at=X({},[...Vs,...Hs]),O=function(e){let t=_(e);(!t||!t.tagName)&&(t={namespaceURI:Ge,tagName:`template`});let n=bs(e.tagName),r=bs(t.tagName);return qe[e.namespaceURI]?e.namespaceURI===We?t.namespaceURI===E?n===`svg`:t.namespaceURI===Ue?n===`svg`&&(r===`annotation-xml`||Ye[r]):!!it[n]:e.namespaceURI===Ue?t.namespaceURI===E?n===`math`:t.namespaceURI===We?n===`math`&&Xe[r]:!!at[n]:e.namespaceURI===E?t.namespaceURI===We&&!Xe[r]||t.namespaceURI===Ue&&!Ye[r]?!1:!at[n]&&(Ze[n]||!it[n]):!!(Qe===`application/xhtml+xml`&&qe[e.namespaceURI]):!1},ot=function(e){vs(t.removed,{element:e});try{_(e).removeChild(e)}catch{g(e)}},st=function(e,n){try{vs(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{vs(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Oe||ke)try{ot(n)}catch{}else try{n.setAttribute(e,``)}catch{}},ct=function(e){let t=null,r=null;if(De)e=`<remove></remove>`+e;else{let t=Ss(e,/^[\r\n\t ]+/);r=t&&t[0]}Qe===`application/xhtml+xml`&&Ge===E&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=v?v.createHTML(e):e;if(Ge===E)try{t=new f().parseFromString(i,Qe)}catch{}if(!t||!t.documentElement){t=ne.createDocument(Ge,`template`,null);try{t.documentElement.innerHTML=Ke?y:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ge===E?ae.call(t,Te?`html`:`body`)[0]:Te?t.documentElement:a},k=function(e){return re.call(e.ownerDocument||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},lt=function(e){return e instanceof d&&(typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||!(e.attributes instanceof u)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`)},A=function(e){return typeof s==`function`&&e instanceof s};function ut(e,n,r){hs(e,e=>{e.call(t,n,r,et)})}let j=function(e){let n=null;if(ut(b.beforeSanitizeElements,e,null),lt(e))return ot(e),!0;let r=D(e.nodeName);if(ut(b.uponSanitizeElement,e,{tagName:r,allowedTags:x}),we&&e.hasChildNodes()&&!A(e.firstElementChild)&&J(/<[/\w!]/g,e.innerHTML)&&J(/<[/\w!]/g,e.textContent)||we&&e.namespaceURI===E&&r===`style`&&A(e.firstElementChild)||e.nodeType===ac.progressingInstruction||we&&e.nodeType===ac.comment&&J(/<[/\w]/g,e.data))return ot(e),!0;if(_e[r]||!(ye.tagCheck instanceof Function&&ye.tagCheck(r))&&!x[r]){if(!_e[r]&&pt(r)&&(w.tagNameCheck instanceof RegExp&&J(w.tagNameCheck,r)||w.tagNameCheck instanceof Function&&w.tagNameCheck(r)))return!1;if(Pe&&!Le[r]){let t=_(e)||e.parentNode,n=te(e)||e.childNodes;if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=h(n[i],!0);t.insertBefore(r,ee(e))}}}return ot(e),!0}return e instanceof c&&!O(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&J(/<\/no(script|embed|frames)/i,e.innerHTML)?(ot(e),!0):(Ce&&e.nodeType===ac.text&&(n=e.textContent,hs([se,ce,le],e=>{n=Cs(n,e,` `)}),e.textContent!==n&&(vs(t.removed,{element:e.cloneNode()}),e.textContent=n)),ut(b.afterSanitizeElements,e,null),!1)},dt=function(e,t,r){if(ve[t]||je&&(t===`id`||t===`name`)&&(r in n||r in tt))return!1;let i=C[t]||ye.attributeCheck instanceof Function&&ye.attributeCheck(t,e);if(!(T&&!ve[t]&&J(ue,t))&&!(be&&J(de,t))){if(!i||ve[t]){if(!(pt(e)&&(w.tagNameCheck instanceof RegExp&&J(w.tagNameCheck,e)||w.tagNameCheck instanceof Function&&w.tagNameCheck(e))&&(w.attributeNameCheck instanceof RegExp&&J(w.attributeNameCheck,t)||w.attributeNameCheck instanceof Function&&w.attributeNameCheck(t,e))||t===`is`&&w.allowCustomizedBuiltInElements&&(w.tagNameCheck instanceof RegExp&&J(w.tagNameCheck,r)||w.tagNameCheck instanceof Function&&w.tagNameCheck(r))))return!1}else if(!Ve[t]&&!J(he,Cs(r,pe,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&ws(r,`data:`)===0&&ze[e])&&!(xe&&!J(fe,Cs(r,pe,``)))&&r)return!1}return!0},ft=X({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),pt=function(e){return!ft[bs(e)]&&J(me,e)},mt=function(e){ut(b.beforeSanitizeAttributes,e,null);let{attributes:n}=e;if(!n||lt(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:C,forceKeepAttr:void 0},i=n.length;for(;i--;){let{name:a,namespaceURI:o,value:s}=n[i],c=D(a),l=s,u=a===`value`?l:Ts(l);if(r.attrName=c,r.attrValue=u,r.keepAttr=!0,r.forceKeepAttr=void 0,ut(b.uponSanitizeAttribute,e,r),u=r.attrValue,Me&&(c===`id`||c===`name`)&&ws(u,Ne)!==0&&(st(a,e),u=Ne+u),we&&J(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)){st(a,e);continue}if(c===`attributename`&&Ss(u,`href`)){st(a,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){st(a,e);continue}if(!Se&&J(/\/>/i,u)){st(a,e);continue}Ce&&hs([se,ce,le],e=>{u=Cs(u,e,` `)});let d=D(e.nodeName);if(!dt(d,c,u)){st(a,e);continue}if(v&&typeof p==`object`&&typeof p.getAttributeType==`function`&&!o)switch(p.getAttributeType(d,c)){case`TrustedHTML`:u=v.createHTML(u);break;case`TrustedScriptURL`:u=v.createScriptURL(u);break}if(u!==l)try{o?e.setAttributeNS(o,a,u):e.setAttribute(a,u),lt(e)?ot(e):_s(t.removed)}catch{st(a,e)}}ut(b.afterSanitizeAttributes,e,null)},ht=function(e){let t=null,n=k(e);for(ut(b.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)ut(b.uponSanitizeShadowNode,t,null),j(t),mt(t),t.content instanceof a&&ht(t.content);ut(b.afterSanitizeShadowDOM,e,null)};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,o=null,c=null,l=null;if(Ke=!e,Ke&&(e=`<!-->`),typeof e!=`string`&&!A(e)&&(e=Ps(e),typeof e!=`string`))throw js(`dirty is not a string, aborting`);if(!t.isSupported)return e;if(Ee||rt(n),t.removed=[],typeof e==`string`&&(Fe=!1),Fe){let t=e.nodeName;if(typeof t==`string`){let e=D(t);if(!x[e]||_e[e])throw js(`root node is forbidden and cannot be sanitized in-place`)}}else if(e instanceof s)i=ct(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===ac.element&&o.nodeName===`BODY`||o.nodeName===`HTML`?i=o:i.appendChild(o);else{if(!Oe&&!Ce&&!Te&&e.indexOf(`<`)===-1)return v&&Ae?v.createHTML(e):e;if(i=ct(e),!i)return Oe?null:Ae?y:``}i&&De&&ot(i.firstChild);let u=k(Fe?e:i);for(;c=u.nextNode();)j(c),mt(c),c.content instanceof a&&ht(c.content);if(Fe)return e;if(Oe){if(Ce){i.normalize();let e=i.innerHTML;hs([se,ce,le],t=>{e=Cs(e,t,` `)}),i.innerHTML=e}if(ke)for(l=ie.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(C.shadowroot||C.shadowrootmode)&&(l=oe.call(r,l,!0)),l}let d=Te?i.outerHTML:i.innerHTML;return Te&&x[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&J(nc,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
34
- `+d),Ce&&hs([se,ce,le],e=>{d=Cs(d,e,` `)}),v&&Ae?v.createHTML(d):d},t.setConfig=function(){rt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),Ee=!0},t.clearConfig=function(){et=null,Ee=!1},t.isValidAttribute=function(e,t,n){return et||rt({}),dt(D(e),D(t),n)},t.addHook=function(e,t){typeof t==`function`&&vs(b[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=gs(b[e],t);return n===-1?void 0:ys(b[e],n,1)[0]}return _s(b[e])},t.removeHooks=function(e){b[e]=[]},t.removeAllHooks=function(){b=cc()},t}var uc=lc(),dc=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,fc=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|blob):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,pc=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,mc={ALLOWED_URI_REGEXP:fc},hc=e=>{if(!dc.test(e.replace(pc,``)))return``;let t=document.createElement(`a`);return t.setAttribute(`href`,e),uc.sanitize(t,{RETURN_DOM:!0,...mc}).querySelector(`a`).getAttribute(`href`)??``},gc=e=>{let t=document.createElement(`img`);return t.setAttribute(`src`,e),uc.sanitize(t,{RETURN_DOM:!0,...mc}).querySelector(`img`).getAttribute(`src`)??``},_c=e=>e.replace(/[;!].*/,``),vc=e=>({...e}),yc=e=>({nodes:Object.fromEntries(Object.keys(e.nodes).map(t=>[t,(e.nodes[t].spec.parseDOM??[]).map(vc)])),marks:Object.fromEntries(Object.keys(e.marks).map(t=>[t,(e.marks[t].spec.parseDOM??[]).map(vc)]))}),bc=class{constructor(e,t){this[h.c]=new xc(e[h.c],t)}parseDocument(e,t){return this[h.c].parser.parse(this.parseHtml(e,t),{preserveWhitespace:!0}).toJSON()}parseFragment(e,t){return this[h.c].parser.parseSlice(this.parseHtml(e,t),{preserveWhitespace:!0}).content.toJSON()??[]}parseHtml(e,t){let n=uc.sanitize(e,{RETURN_DOM:!0,...mc}),r=document.createDocumentFragment();return r.appendChild(n),t?.modifyDom?.(r),r}},xc=class{constructor(e,t){let n=yc(e.schema);t?.modifyParseRules?.(n),this.parser=Sc(e.schema,n)}transform(e){return uc.sanitize(e)}},Sc=(e,{marks:t,nodes:n})=>{let r=[],i=e=>e.priority??50;function a(e){let t=0;for(;t<r.length;t++){let n=r[t];if(i(n)<i(e))break}r.splice(t,0,e)}for(let e in t)t[e]?.forEach(t=>{a(t=vc(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)});for(let e in n)n[e]?.forEach(t=>{a(t=vc(t)),t.node||t.ignore||t.mark||(t.node=e)});return r.push({tag:`br`,closeParent:!0}),new h.l(e,r)},Cc=class{constructor(e,t){this[h.c]=new wc(e[h.c],t)}serializeDocument(e,t){return this[h.c].serializeFragment(e.content,t)}serializeFragment(e,t){return this[h.c].serializeFragment(e,t)}},wc=class e{constructor(t,n){this.config=t;let r=e.domSerializersFromSchema(t.schema);Object.assign(r.nodes,n?.serializers?.nodes??{}),Object.assign(r.marks,n?.serializers?.marks??{}),this.serializer=new h.u(r.nodes,r.marks)}static domSerializersFromSchema(e){let t={nodes:{},marks:{}};for(let n in e.marks){let r=e.marks[n].spec.toDOM;r&&(t.marks[n]=r)}for(let n in e.nodes){let r=e.nodes[n].spec.serializeToDOM??e.nodes[n].spec.toDOM;r&&(t.nodes[n]=r)}return t.nodes.text=e=>document.createTextNode(e.text),t}serializeFragment(e,t){let n=h.d.fromJSON(this.config.schema,e),r=this.serializer.serializeFragment(n),i=document.createDocumentFragment();i.appendChild(r),t?.modifyDom?.(i);let a=document.createElement(`div`);return a.appendChild(i),a.innerHTML}},Tc=(e,t)=>{let n=e.topNodeType.createAndFill(null,t?h.d.fromJSON(e,t.content):null);if(!n)throw Error(`Document could not be parsed`);return n.check(),n},Ec=class{constructor(e,t){this.options=t,this.feature=(e,t)=>this[h.c].getPublicInterface(e,t),this[h.c]=new Dc(this,e,t)}getDocument(){return this[h.c].state.doc.toJSON()}reset(e){this[h.c].reset(e)}replaceSelection(e,t){let{state:n,tr:r,schema:i,dispatchTransaction:a}=this[h.c];r.replaceSelection(new h.v(h.d.fromJSON(i,e),0,0)),r.doc.check();let o=r.doc.resolve(r.mapping.map(n.selection.from)),s=r.doc.resolve(r.selection.to),[c,l]=t?.cursorPlacement===`start`?[o,s]:[s,o];t?.selectContent?r.setSelection(n.selection instanceof j?new j(r.doc):k.between(l,c)):r.setSelection(k.between(c,c)),a(r)}replaceDocument(e,t){let{state:n,tr:r,schema:i,dispatchTransaction:a}=this[h.c];r.replaceWith(0,n.doc.content.size,Tc(i,e)),t?.selectContent?r.setSelection(new j(r.doc)):t?.cursorPlacement===`end`?r.setSelection(k.atEnd(r.doc)):r.setSelection(k.atStart(r.doc)),a(r)}scrollIntoView(){let e=this[h.c];e.view&&e.dispatchTransaction(e.tr.scrollIntoView())}},Dc=class{getFeature(e){let t=this.config.featureMap.get(e);if(!t)throw Error(`Feature not found: ${e}`);return t}getPublicInterface(e,t){let n=this.config.featureFacadesMap.get(e);if(!n||n.length===0)throw Error(`Feature not found`);if(n[0].featureId!==void 0){if(t===void 0)throw Error(`No featureId provided for multi-instance feature.`);let e=n.find(e=>e.featureId===t);if(!e)throw Error(`Feature with id "${t}" not found`);return e.getPublicInterface(this)}if(t!==void 0)throw Error(`Feature does not support featureId`);return n[0].getPublicInterface(this)}constructor(e,n,r){this.options=r,this.view=null,this.dispatchTransaction=e=>{let t=this.state;return this.state=this.state.apply(e),this.view?.updateState(this.state),t.doc!==this.state.doc&&this.options?.onChange?.(),this.state},this.facade=e;let i=n[h.c];this.config=i,this.schema=i.schema,this.textblockAttrs=i.textblockAttrs,this.features=i.features,this.foreignHtmlParser=r?.foreignHtmlParser??new bc(n),this.foreignHtmlSerializer=r?.foreignHtmlSerializer??new Cc(n),this.styles=new t.w(h.s(i.features.flatMap(e=>e.getStyles()))),this.initState(r?.initialDocument)}initState(e){this.state=St.create({doc:Tc(this.schema,e),schema:this.config.schema,plugins:h.s(this.config.features.flatMap(e=>e.getPlugins(this)))})}reset(e){let t=rs.getState(this.state);this.initState(e),this.updateHostState(t),this.view?.updateState(this.state)}createView(e){let t=this.config.featureMap.get(`RteCore`);this.view=new Pa(t=>{t.part=`editor`,e.appendChild(t)},{state:this.state,dispatchTransaction:this.dispatchTransaction,...t?.scrollThreshold!==void 0&&{scrollThreshold:t.scrollThreshold},...t?.scrollMargin!==void 0&&{scrollMargin:t.scrollMargin}})}destroyViewIfNeeded(){this.view&&=(this.view.destroy(),null)}createComponent(e){return document.createElement(this.hostState().ctx.tagFor(e,!0))}getLocale(){return this.hostState().locale}get tr(){return this.state.tr}hostState(){let e=rs.getState(this.state);if(!e)throw Error(`No host state available`);return e}updateHostState(e){this.dispatchTransaction(this.tr.setMeta(rs,e))}},Oc=class{constructor(e){this.specs=e,this.attrs={};for(let t of e)this.attrs[t.name]={default:t.default}}fromDOM(e){return Object.assign({},...this.specs.map(t=>({[t.name]:t.fromDOM(e)})))}getStyle(e){return this.specs.flatMap(t=>t.toStyles(e)).join(`; `)}getDOMAttrsProperties(e){return this.specs.length?{style:this.getStyle(e)}:{}}getDOMAttrs(e){return this.specs.length?[this.getDOMAttrsProperties(e)]:[]}extractFromNode(e){return Object.assign({},...Object.keys(this.attrs).map(t=>({[t]:e.attrs[t]})))}},kc=class{constructor(e){this.specs=e}getAllowedMarksForNode(e){return this.specs.filter(t=>!t.onNodeName||t.onNodeName===e).map(e=>e.markName)}getReferencedNodeNames(){return new Set(this.specs.map(e=>e.onNodeName).filter(Boolean))}},Ac=(e,t)=>{let n=t.config[h.c].schema,r=e=>n.marks[e.type].rank,i=(e,t)=>{if(e.type!==t.type)return!1;let n=e.attrs,r=t.attrs;if(n===r)return!0;if(!n||!r)return!1;let i=Object.keys(n),a=Object.keys(r);if(i.length!==a.length)return!1;for(let e of i)if(n[e]!==r[e])return!1;return!0},a=e=>{let n=[],o=[],s=[n];for(let n of e){let e=[...n.marks??[]].sort((e,t)=>r(e)-r(t)),c=0,l=0;for(;c<o.length&&l<e.length&&i(o[c],e[l]);)c++,l++;for(;o.length>c;)o.pop(),s.pop();for(;l<e.length;){let n=e[l],r=[];s[s.length-1].push({type:`mark`,mark:n,children:{type:`fragment`,content:r,[h.c]:t},[h.c]:t}),o.push(n),s.push(r),l++}s[s.length-1].push({type:`node`,node:n,children:a(n.content??[]),[h.c]:t})}return{type:`fragment`,content:n,[h.c]:t}};return{type:`node`,node:e,children:a(e.content),[h.c]:t}},jc=class{constructor(e){this[h.c]=new Mc(e)}instantiateEditor(e){return new Ec(this,e)}instantiateView(e,t){return Ac(e,{config:this,options:{...t}})}},Mc=class{constructor(e){let t=e=>e.flatMap(e=>e.getFeatures().flatMap(n=>n===e?e:t([n])));this.features=t(e.map(h.o)),this.featureMap=new Map;for(let e of this.features){if(this.featureMap.has(e.name))throw Error(`Duplicate feature: ${e.name}`);this.featureMap.set(e.name,e)}this.featureFacadesMap=new Map;for(let t of e){let e=t.constructor,n=h.o(t),r=this.featureFacadesMap.get(e);r?r.push(n):this.featureFacadesMap.set(e,[n])}if(!this.featureMap.has(`RteBase`))throw Error(`RteBase feature is required`);if(this.featureMap.has(`RteLinkFeature`)&&!this.featureMap.has(`RteToolbarFeature`))throw Error(`RteToolbarFeature is required for RteLinkFeature`);this.textblockAttrs=new Oc(h.s(this.features.flatMap(e=>e.getTextblockAttrs()))),this.textblockMarks=new kc(h.s(this.features.flatMap(e=>e.getTextblockMarks())));let n=h.s(this.features.flatMap(e=>e.getSchema(this.textblockAttrs,this.textblockMarks))),r={nodes:{},marks:{}};for(let e of n)Object.assign(r.nodes,e.nodes??{}),Object.assign(r.marks,e.marks??{});for(let e of this.textblockMarks.getReferencedNodeNames())if(!(e in r.nodes))throw Error(`Unknown node "${e}"`);this.schema=new h._(r)}},Nc=200,Q=function(){};Q.prototype.append=function(e){return e.length?(e=Q.from(e),!this.length&&e||e.length<Nc&&this.leafAppend(e)||this.length<Nc&&e.leafPrepend(this)||this.appendInner(e)):this},Q.prototype.prepend=function(e){return e.length?Q.from(e).append(this):this},Q.prototype.appendInner=function(e){return new Fc(this,e)},Q.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Q.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Q.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Q.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Q.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},Q.from=function(e){return e instanceof Q?e:e&&e.length?new Pc(e):Q.empty};var Pc=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Nc)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Nc)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Q);Q.empty=new Pc([]);var Fc=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Q),Ic=500,Lc=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new zc(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new zc(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new zc(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>Vc&&(s=Rc(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new he;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new zc(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new zc(i,o,l))}else r.push(new zc(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new zc(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>Ic&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new zc(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(Q.from(i.reverse()),a)}};Lc.empty=new Lc(Q.empty,0);function Rc(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var zc=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},Bc=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},Vc=20;function Hc(e,t,n,r){let i=n.getMeta(Zc),a;if(i)return i.historyState;n.getMeta(Qc)&&(e=new Bc(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Zc))return o.getMeta(Zc).redo?new Bc(e.done.addTransform(n,void 0,r,Yc(t)),e.undone,Wc(n.mapping.maps),e.prevTime,e.prevComposition):new Bc(e.done,e.undone.addTransform(n,void 0,r,Yc(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Uc(n,e.prevRanges)),s=o?Gc(e.prevRanges,n.mapping):Wc(n.mapping.maps);return new Bc(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,Yc(t)),Lc.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new Bc(e.done.rebased(n,a),e.undone.rebased(n,a),Gc(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new Bc(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Gc(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Uc(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function Wc(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function Gc(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function Kc(e,t,n){let r=Yc(t),i=Zc.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new Bc(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(Zc,{redo:n,historyState:c})}var qc=!1,Jc=null;function Yc(e){let t=e.plugins;if(Jc!=t){qc=!1,Jc=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){qc=!0;break}}return qc}function Xc(e){return e.setMeta(Qc,!0)}var Zc=new Et(`history`),Qc=new Et(`closeHistory`);function $c(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new M({key:Zc,state:{init(){return new Bc(Lc.empty,Lc.empty,null,0,-1)},apply(t,n,r){return Hc(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?tl:n==`historyRedo`?nl:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function el(e,t){return(n,r)=>{let i=Zc.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=Kc(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var tl=el(!1,!0),nl=el(!0,!0),rl=e=>typeof e==`function`,il=(e,t,n)=>[e,t,n],al=class{constructor(e,t,n){this.view=e,this.rte=t,this.props=n,this.bindings=[]}evalProp(e){return rl(e)?e(this):e}bindProp(e,t){if(e!==void 0)if(rl(e)){let n=()=>t(e(this));this.bindings.push(n),n()}else t(e)}updateBindings(){for(let e of this.bindings)e()}shouldReturnFocusToEditor(){return this.evalProp(this.props.shouldReturnFocusToEditor)}bindToEl(e,t={},n=[],r=[]){for(let n in t)this.bindProp(t[n],t=>{e[n]=t});for(let[t,r,i]of n)r&&e.addEventListener(t,i(r));for(let t of r)e.appendChild(t)}},ol=(e,t)=>{let n=document.createElement(`div`);return e.bindToEl(n,{className:t.className,slot:t.slot},[],t.children),n},sl=(e,t)=>{let n=document.createElement(`a`);return e.bindToEl(n,{href:t.href,target:t.target,rel:t.rel,className:t.className},[],t.children),n},cl=new WeakMap,ll=(e,t)=>{let n=e.rte.createComponent(s.r);n.setAttribute(`exportparts`,`vvd-theme-alternate`),e.bindToEl(n,{className:`ui-tooltip`,text:t.label,placement:e.props.popupPlacement}),e.bindProp(t.enabled,e=>{e||(n.open=!1),n.anchor=e?t.anchor:void 0});let r=ol(e,{className:`ui-tooltip-wrapper`,slot:t.slot,children:[t.anchor,n]});return cl.set(r,t.anchor),r},$=(e,t)=>{let n=()=>e.evalProp(t.variant)??`toolbar`,r=()=>n()===`toolbar`?`super-condensed`:`condensed`,i=()=>n()===`popover-primary`?`outlined`:`ghost-light`,o=()=>n()===`toolbar-menu`||n()===`popover`?`filled`:i(),s=()=>e.evalProp(t.active)?o():i(),c=()=>e.evalProp(t.connotation)??(n()===`toolbar-menu`&&e.evalProp(t.active)?`cta`:void 0),l=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),u=e.rte.createComponent(a.i);return e.bindToEl(u,{size:r,appearance:s,disabled:l,icon:t.icon,autofocus:t.autofocus,connotation:c,[t.icon?`ariaLabel`:`label`]:t.label,pressed:()=>!!e.evalProp(t.active),ariaPressed:t.active===void 0?void 0:()=>e.evalProp(t.active)?`true`:`false`},[il(`click`,t.onClick,t=>()=>{!t()&&e.shouldReturnFocusToEditor()&&e.view.focus()})]),ll(e,{enabled:()=>!!(e.evalProp(t.icon)&&!e.evalProp(t.noTooltip)&&!l()),label:t.label,anchor:u,slot:t.slot})},ul=(e,t)=>{let n=e.rte.createComponent(ee.r);e.bindToEl(n,{className:`ui-menu`,autoDismiss:!0,ariaLabel:t.label,anchor:cl.get(t.trigger)??t.trigger,placement:e.props.popupPlacement,offset:()=>e.evalProp(e.props.menuOffset)??null},[],t.children);let r=document.createDocumentFragment();return r.appendChild(t.trigger),r.appendChild(n),r},dl=(e,t)=>{let n=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),r=e.rte.createComponent(g.i);return e.bindToEl(r,{text:t.text,checked:t.checked,disabled:n,controlType:`radio`,checkedAppearance:`tick-only`},[il(`change`,t.onSelect,n=>()=>{r.checked&&!r.disabled&&e.evalProp(t.checked)!==r.checked&&(n(),e.shouldReturnFocusToEditor()&&e.view.focus())})]),r},fl=(e,t)=>ol(e,{slot:t.slot,className:`ui-button-group`,children:t.children});function pl(e,t){let{from:n,$from:r,to:i,empty:a}=e.selection;return a?!!t.isInSet(e.storedMarks||r.marks()):e.doc.rangeHasMark(n,i,t)}var ml=(e,t)=>$(e,{label:t.label,icon:t.icon,active:()=>pl(e.view.state,t.markType),disabled:()=>!Eo(t.markType)(e.view.state),onClick:()=>{Eo(t.markType)(e.view.state,e.view.dispatch)}}),hl=(e,t)=>{let n=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),r=e.rte.createComponent(u.t);return e.bindToEl(r,{value:t.value,text:t.text,disabled:n}),r},gl=(e,t)=>{let n=()=>!!e.evalProp(e.props.disabled),r=e.rte.createComponent(f.r);r.setAttribute(`data-class`,`ui-select`),e.bindToEl(r,{placeholder:` `,ariaLabel:t.label,appearance:`ghost`,disabled:n},[il(`change`,t.onSelect,t=>()=>{let n=r.value;n&&(t(n),e.shouldReturnFocusToEditor()&&e.view.focus())})],t.children),queueMicrotask(()=>{e.bindProp(t.value,e=>r.value=e)});let i=!1;return r.addEventListener(`vwc-popup:open`,()=>{i=!0,e.updateBindings()}),r.addEventListener(`vwc-popup:close`,()=>{i=!1,e.updateBindings()}),ll(e,{enabled:()=>!i&&!n(),label:t.label,anchor:r})},_l=e=>{let t=e.rte.createComponent(m.t);return e.bindToEl(t,{className:`ui-divider`,orientation:`vertical`}),t},vl=(e,t)=>{let n=e.rte.createComponent(l.r);return e.bindToEl(n,{label:t.label,value:t.value,placeholder:t.placeholder,slot:t.slot,autofocus:t.autofocus,type:t.type,helperText:t.helperText},[il(`input`,t.onInput,e=>()=>{e(n.value)})]),n},yl=(e,t)=>{let n=document.createTextNode(``);return e.bindToEl(n,{textContent:t.text}),n},bl=(e,t)=>{let n=document.createElement(`slot`);n.name=t.name;let r=null,i=[];function a(){for(let{el:e,type:t,handler:n}of i)e.removeEventListener(t,n);i.length=0,r=null}for(let[n,i]of Object.entries(t.assignedProps))e.bindProp(i,e=>{r&&(r[n]=e)});function o(n){for(let[r,i]of Object.entries(t.assignedProps))n[r]=e.evalProp(i);for(let[r,a]of Object.entries(t.assignedEvents)){let t=t=>{a(t),e.shouldReturnFocusToEditor()&&e.view.focus()};n.addEventListener(r,t),i.push({el:n,type:r,handler:t})}}let s=()=>{let e=n.assignedElements({flatten:!0})[0];e!==r&&(a(),e&&(r=e,o(e)))};return n.addEventListener(`slotchange`,s),queueMicrotask(s),n},xl=class extends h.r{constructor(e){super(),this.config=e,this.name=`RteHistoryFeature`}getPlugins(){return[this.contribution($c()),this.contribution(U({"Mod-z":tl,"Ctrl-y":nl,"Cmd-Z":nl}))]}getToolbarItems(){return this.config.showToolbarButtons?[this.contribution({section:`history`,render:e=>$(e,{label:e=>e.rte.getLocale().richTextEditor.undo,icon:`undo-line`,disabled:e=>!tl(e.view.state),onClick:()=>{let{state:t,dispatch:n}=e.view;tl(t,n)}})},1),this.contribution({section:`history`,render:e=>$(e,{label:e=>e.rte.getLocale().richTextEditor.redo,icon:`redo-line`,disabled:e=>!nl(e.view.state),onClick:()=>{let{state:t,dispatch:n}=e.view;nl(t,n)}})},2)]:[]}},Sl=`h1,h2,h3,p{all:unset;display:block}h1:first-child,h2:first-child,h3:first-child,p:first-child{margin-block-start:0}h1:last-child,h2:last-child,h3:last-child,p:last-child{margin-block-end:0}p{font:var(--vvd-typography-base);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:16px;line-height:20px}.heading-step-1{font:var(--vvd-typography-heading-4);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:24px 12px;line-height:28px}.heading-step-2{font:var(--vvd-typography-heading-3);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:24px 12px;line-height:36px}.heading-step-3{font:var(--vvd-typography-heading-2);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:32px 16px;line-height:42px}`,Cl=class extends h.r{constructor(e){super(),this.enabledBlocks=e,this.name=`RteBasicTextBlocks`}getStyles(){return[this.contribution(Sl)]}getSchema(e,t){let n={};this.enabledBlocks.paragraph&&(n.paragraph={group:`block`,content:`inline*`,attrs:{...e.attrs},parseDOM:[{tag:`p`,getAttrs:t=>e.fromDOM(t)}],marks:t.getAllowedMarksForNode(`paragraph`).join(` `),toDOM(t){return[`p`,{part:`node--paragraph`,...e.getDOMAttrsProperties(t)},0]},serializeToDOM(t){return[`p`,...e.getDOMAttrs(t),0]}});let r=0;for(let i of[3,2,1]){let a=`heading${i}`,o=`h${i}`;if(!this.enabledBlocks[a])continue;r++;let s=r;n[a]={group:`block`,content:`inline*`,attrs:{...e.attrs},parseDOM:[{tag:o,getAttrs:t=>e.fromDOM(t)}],marks:t.getAllowedMarksForNode(a).join(` `),defining:!0,toDOM(t){return[o,{class:`heading-step-${s}`,part:`node--${a}`,...e.getDOMAttrsProperties(t)},0]},serializeToDOM(t){return[o,...e.getDOMAttrs(t),0]}}}return[this.contribution({nodes:n})]}getPlugins(e){let t={};this.enabledBlocks.paragraph&&(t[`Mod-Alt-0`]=this.setBlockType(e,`paragraph`));for(let n of[1,2,3]){let r=`heading${n}`;this.enabledBlocks[r]&&(t[`Mod-Alt-${n}`]=this.setBlockType(e,r))}return[this.contribution(U(t))]}getCurrentBlockType(e){let{$from:t,$to:n}=e.selection,r=t.depth===0?e.doc.childAfter(t.pos).node:t.node(1);return r!==(n.depth===0?e.doc.childBefore(n.pos).node:n.node(1))||!(r.type.name in this.enabledBlocks)?null:r.type.name}setBlockType(e,t){return(n,r)=>{let{from:i,to:a}=n.selection,o=n.tr,s=!1;return n.doc.nodesBetween(i,a,(r,i)=>(r.type.name in this.enabledBlocks&&(s=!0,o.setBlockType(i,i+r.nodeSize,n.schema.nodes[t],t=>e.textblockAttrs.extractFromNode(t))),!1)),s?(r?.(o),!0):!1}}},wl=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?Tl(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function Tl(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var El=500;function Dl({rules:e}){let t=new M({state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return Ol(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&Ol(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function Ol(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t),c=s.parent.textBetween(Math.max(0,s.parentOffset-El),s.parentOffset,null,``)+r;for(let l=0;l<i.length;l++){let u=i[l];if(!u.inCodeMark&&s.marks().some(e=>e.type.spec.code))continue;if(s.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode===`only`)continue;let d=u.match.exec(c);if(!d||d[0].length<r.length)continue;let f=t-(d[0].length-r.length);if(!u.inCodeMark){let e=!1;if(o.doc.nodesBetween(f,s.pos,t=>{t.isInline&&t.marks.some(e=>e.type.spec.code)&&(e=!0)}),e)continue}let p=u.handler(o,d,f,n);if(p)return u.undoable&&p.setMeta(a,{transform:p,from:t,to:n,text:r}),e.dispatch(p),!0}return!1}var kl=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let n=e.tr,r=a.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(a.text){let t=n.doc.resolve(a.from).marks();n.replaceWith(a.from,a.to,e.schema.text(a.text,t))}else n.delete(a.from,a.to);t(n)}return!0}}return!1};new wl(/--$/,`—`,{inCodeMark:!1}),new wl(/\.\.\.$/,`…`,{inCodeMark:!1}),new wl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new wl(/"$/,`”`,{inCodeMark:!1}),new wl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new wl(/'$/,`’`,{inCodeMark:!1});var Al=e=>e.parent.textBetween(0,e.parentOffset,void 0,``),jl=class extends h.r{constructor(...e){super(...e),this.name=`RteInputRulesFeature`}getPlugins(e){let t=h.s(e.config.features.flatMap(t=>t.getInputRules(e)));if(t.length===0)return[];let n=[],r=t.map(e=>e.rule);n.push(this.contribution(Dl({rules:r}))),n.push(this.contribution(U({Backspace:kl}),h.i.high));let i=t.filter(e=>e.enterHandler).map(e=>e.enterHandler);return i.length>0&&n.push(this.contribution(U({Enter:(e,t)=>{let{$cursor:n}=e.selection;if(!n)return!1;let r=Al(n);for(let{regex:a,handler:o}of i){let i=a.exec(r);if(!i)continue;let s=n.pos-n.parentOffset+i.index,c=o(e,i,s,s+i[0].length);c&&t?.(c);break}return!1}}),h.i.highest)),n}},Ml=class extends h.r{constructor(e){super(),this.config=e,this.name=`RteBase`}getSchema(){return[this.contribution({nodes:{doc:{content:this.config?.singleBlock?`block`:`block+`},text:{group:`inline`}}})]}getFeatures(){return[this,new is,new xl({showToolbarButtons:this.config?.historyToolbarButtons??!0}),new Cl({heading1:this.config?.heading1??!1,heading2:this.config?.heading2??!1,heading3:this.config?.heading3??!1,paragraph:this.config?.paragraph??!0}),new jl]}getPublicInterface(e){let t=e.getFeature(`RteCore`);return{get disabled(){return t.disabled.getValue(e)},set disabled(n){t.disabled.setValue(e,n)},get scrollThreshold(){return t.scrollThreshold},set scrollThreshold(n){t.scrollThreshold=n,e.view?.setProps({scrollThreshold:n})},get scrollMargin(){return t.scrollMargin},set scrollMargin(n){t.scrollMargin=n,e.view?.setProps({scrollMargin:n})}}}},Nl=h.a(Ml),Pl=class extends h.r{constructor(e){super(),this.config=e,this.name=`RteTextBlockPickerFeature`}getToolbarItems(e){let t=e.getFeature(`RteBasicTextBlocks`);return[this.contribution({section:`font`,render:n=>gl(n,{label:()=>n.rte.getLocale().richTextEditor.paragraphStyles,value:e=>t.getCurrentBlockType(e.view.state)??``,onSelect:r=>{let{state:i,dispatch:a}=n.view;t.setBlockType(e,r)(i,a)},children:this.config.options.map(r=>hl(n,{text:r.label,value:r.node,disabled:()=>!t.setBlockType(e,r.node)(n.view.state)}))})},1)]}},Fl=h.a(Pl),Il=`.toolbar{background-color:var(--vvd-color-neutral-50);flex-wrap:wrap;align-items:center;gap:8px;padding:4px;display:flex}.toolbar--hidden{display:none}`,Ll=class extends h.r{constructor(e){super(),this.config=e,this.name=`RteToolbarFeature`,this.hidden=new Xo(!1)}getStyles(){return[this.contribution(Il)]}getPlugins(e){let t=[`history`,`font`,`text-style`,`textblock`,`insert`],n=new Map(t.map(e=>[e,[]]));for(let t of h.s(e.features.flatMap(t=>t.getToolbarItems(e))))n.get(t.section).push(t);let r=e.getFeature(`RteCore`);return[this.contribution(this.hidden.plugin),this.contribution(new M({view:i=>{let a=!1,o=new al(i,e,{popupPlacement:this.config?.popupDirection===`outward`?`bottom`:`top`,menuOffset:8,disabled:()=>r.disabled.getValue(e),shouldReturnFocusToEditor:()=>a}),s=i.dom.getRootNode().querySelector(`.toolbar`),c=-1/0,l=()=>{i.hasFocus()&&(a=!0),c=Date.now()},u=()=>{Date.now()-c>250&&(a=!1)},d=e=>{s.contains(e.relatedTarget)||(a=!1)};s.addEventListener(`mousedown`,l,{capture:!0}),s.addEventListener(`focusin`,u),s.addEventListener(`focusout`,d),o.bindProp(()=>this.hidden.getValue(e),e=>{s.classList.toggle(`toolbar--hidden`,e)});let f=!1;for(let e of t){let t=n.get(e);t.length&&f&&(s.appendChild(_l(o)),f=!1);for(let e of t)s.appendChild(e.render(o)),f=!0}return{update(){o.updateBindings()},destroy(){s.innerHTML=``,s.removeEventListener(`mousedown`,l,{capture:!0}),s.removeEventListener(`focusin`,u),s.removeEventListener(`focusout`,d),a=!1}}}}))]}getPublicInterface(e){let t=this.hidden;return{get hidden(){return t.getValue(e)},set hidden(n){t.setValue(e,n)}}}},Rl=h.a(Ll),zl=`.placeholder{display:contents}.placeholder:before{color:var(--vvd-color-neutral-600);content:attr(data-placeholder);font-size:var(--placeholder-font-size,inherit);inset-inline:var(--editor-padding-inline);line-height:inherit;pointer-events:none;position:absolute}.editor--disabled .placeholder:before{color:var(--vvd-color-neutral-300)}`,Bl=class extends h.r{constructor(e){super(),this.config=e,this.name=`RtePlaceholderFeature`}getStyles(){return[this.contribution(zl)]}getPlugins(){let e=new M({props:{decorations:e=>{if(e.doc.nodeSize===4){let t=e.schema.marks.fontSize?.isInSet(e.storedMarks??[])?.attrs.size;return B.create(e.doc,[z.widget(1,()=>{let e=document.createElement(`span`);return e.className=`placeholder`,e.dataset.placeholder=this.config.text,t&&e.style.setProperty(`--placeholder-font-size`,t),e})])}return null}}});return[this.contribution(e)]}},Vl=h.a(Bl),Hl=class extends h.r{constructor(...e){super(...e),this.name=`RteHardBreakFeature`}getSchema(){return[this.contribution({nodes:{hardBreak:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return[`br`]}}}})]}getPlugins(e){return[this.contribution(U({"Shift-Enter":(e,t)=>{let n=e.storedMarks||e.selection.$from.marks(),r=e.tr.replaceSelectionWith(e.schema.nodes.hardBreak.create(),!0).scrollIntoView();return n.length&&r.setStoredMarks(n),t?.(r),!0}}),h.i.high)]}},Ul=h.a(Hl),Wl=Symbol(`mixedFontSize`),Gl=class extends h.r{constructor(e){if(super(),this.config=e,this.name=`RteFontSizePickerFeature`,this.fontSizes=e.options,e.onBlocks){this.defaultFontSizeForNode={};for(let t of e.onBlocks)this.defaultFontSizeForNode[t.node]=t.defaultSize??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:`fontSize`,onNodeName:e.node})):[this.contribution({markName:`fontSize`})]}getSchema(){return[this.contribution({marks:{fontSize:{attrs:{size:{validate:`string`}},parseDOM:[{tag:`span[style*='font-size']`,getAttrs:e=>{let t=e.getAttribute(`style`).match(/font-size:\s*([^;]+)/)?.[1]?.trim();return t?{size:t}:!1}}],toDOM:e=>[`span`,{style:`font-size: ${_c(e.attrs.size)};`},0],cursorFix:(e,t)=>{let n=t.storedMarks;if(!n)return null;let r=n.find(e=>e.type.name===`fontSize`);if(r)return{style:{"font-size":r.attrs.size}};if(n.length===0){let t=this.defaultFontSizeForNode?.[e.parent.type.name];if(t)return{style:{"font-size":t}}}return null}}}})]}getPlugins(){return[this.contribution(U({"Mod-Shift-.":this.adjustFontSize(-1),"Mod-Shift-,":this.adjustFontSize(1)}))]}getToolbarItems(e){return[this.contribution({section:`font`,render:t=>ul(t,{label:()=>e.getLocale().richTextEditor.textSize,trigger:$(t,{label:()=>e.getLocale().richTextEditor.textSize,icon:`text-size-line`}),children:this.fontSizes.map(e=>dl(t,{text:e.label,checked:()=>this.getFontSizeFromSelection(t.view.state)===e.size,disabled:()=>!this.setFontSize(e.size)(t.view.state),onSelect:()=>{let{state:n,dispatch:r}=t.view;this.setFontSize(e.size)(n,r)}}))})},2)]}getFontSizeFromSelection(e){let{from:t,to:n,$from:r,empty:i}=e.selection,{fontSize:a}=e.schema.marks;if(i){let t=this.defaultFontSizeForNode?.[r.parent.type.name]??null;return a.isInSet(e.storedMarks||r.marks())?.attrs.size??t}let o=null,s=e=>{o===null?o=e??null:e!==o&&(o=Wl)};return e.doc.nodesBetween(t,n,(e,t,n)=>o===Wl?!1:e.isLeaf?(s(a.isInSet(e.marks)?.attrs.size??(n&&this.defaultFontSizeForNode?.[n.type.name])),!0):(e.type.allowsMarkType(a)&&e.childCount===0&&s(this.defaultFontSizeForNode?.[e.type.name]),!0)),o}setFontSize(e){return(t,n)=>{let{from:r,to:i,empty:a,$from:o}=t.selection,{fontSize:s}=t.schema.marks;if(!Eo(s,{size:e})(t))return!1;let c=t.tr;if(a){let n=(t.storedMarks||[]).filter(e=>e.type!==s);e!==this.defaultFontSizeForNode?.[o.parent.type.name]&&n.push(s.create({size:e})),c.setStoredMarks(n)}else c.addMark(r,i,s.create({size:e})),c.doc.nodesBetween(r,i,(e,t,n)=>{if(!e.isInline)return;let r=s.isInSet(e.marks),i=this.defaultFontSizeForNode?.[n.type.name];r&&r.attrs.size===i&&c.step(new _e(t,t+e.nodeSize,r))});return n?.(c.scrollIntoView()),!0}}adjustFontSize(e){return(t,n)=>{let r=this.getFontSizeFromSelection(t);if(r===null||r===Wl)return!1;let i=this.fontSizes.findIndex(e=>e.size===r)+e;return i<0||i>=this.fontSizes.length?!1:this.setFontSize(this.fontSizes[i].size)(t,n)}}},Kl=h.a(Gl),ql=[`p`,0],Jl=[`blockquote`,0],Yl=[`hr`],Xl=[`pre`,[`code`,0]],Zl=[`br`],Ql={doc:{content:`block+`},paragraph:{content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM(){return ql}},blockquote:{content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM(){return Jl}},horizontal_rule:{group:`block`,parseDOM:[{tag:`hr`}],toDOM(){return Yl}},heading:{attrs:{level:{default:1,validate:`number`}},content:`inline*`,group:`block`,defining:!0,parseDOM:[{tag:`h1`,attrs:{level:1}},{tag:`h2`,attrs:{level:2}},{tag:`h3`,attrs:{level:3}},{tag:`h4`,attrs:{level:4}},{tag:`h5`,attrs:{level:5}},{tag:`h6`,attrs:{level:6}}],toDOM(e){return[`h`+e.attrs.level,0]}},code_block:{content:`text*`,marks:``,group:`block`,code:!0,defining:!0,parseDOM:[{tag:`pre`,preserveWhitespace:`full`}],toDOM(){return Xl}},text:{group:`inline`},image:{inline:!0,attrs:{src:{validate:`string`},alt:{default:null,validate:`string|null`},title:{default:null,validate:`string|null`}},group:`inline`,draggable:!0,parseDOM:[{tag:`img[src]`,getAttrs(e){return{src:e.getAttribute(`src`),title:e.getAttribute(`title`),alt:e.getAttribute(`alt`)}}}],toDOM(e){let{src:t,alt:n,title:r}=e.attrs;return[`img`,{src:t,alt:n,title:r}]}},hard_break:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return Zl}}},$l=[`em`,0],eu=[`strong`,0],tu=[`code`,0],nu={link:{attrs:{href:{validate:`string`},title:{default:null,validate:`string|null`}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM(e){let{href:t,title:n}=e.attrs;return[`a`,{href:t,title:n},0]}},em:{parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style=italic`},{style:`font-style=normal`,clearMark:e=>e.type.name==`em`}],toDOM(){return $l}},strong:{parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!=`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name==`strong`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM(){return eu}},code:{code:!0,parseDOM:[{tag:`code`}],toDOM(){return tu}}};new h._({nodes:Ql,marks:nu});var ru=class extends h.r{constructor(e){super(),this.config=e}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:this.markName,onNodeName:e.node})):[this.contribution({markName:this.markName})]}},iu=class extends ru{constructor(...e){super(...e),this.name=`RteBoldFeature`,this.markName=`bold`}getSchema(){return[this.contribution({marks:{bold:nu.strong}})]}getPlugins(e){return[this.contribution(U({"Mod-b":Eo(e.schema.marks.bold)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>ml(t,{label:()=>t.rte.getLocale().richTextEditor.bold,icon:`bold-line`,markType:e.schema.marks.bold})},1)]}},au=h.a(iu),ou=class extends ru{constructor(...e){super(...e),this.name=`RteItalicFeature`,this.markName=`italic`}getSchema(){return[this.contribution({marks:{italic:nu.em}})]}getPlugins(e){return[this.contribution(U({"Mod-i":Eo(e.schema.marks.italic)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>ml(t,{label:()=>t.rte.getLocale().richTextEditor.italic,icon:`italic-line`,markType:e.schema.marks.italic})},2)]}},su=h.a(ou),cu=class extends ru{constructor(...e){super(...e),this.name=`RteUnderlineFeature`,this.markName=`underline`}getSchema(){return[this.contribution({marks:{underline:{parseDOM:[{tag:`u`}],toDOM(){return[`u`,0]}}}})]}getPlugins(e){return[this.contribution(U({"Mod-u":Eo(e.schema.marks.underline)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>ml(t,{label:()=>t.rte.getLocale().richTextEditor.underline,icon:`underline-line`,markType:e.schema.marks.underline})},3)]}},lu=h.a(cu),uu=class extends ru{constructor(...e){super(...e),this.name=`RteStrikethroughFeature`,this.markName=`strikethrough`}getSchema(){return[this.contribution({marks:{strikethrough:{parseDOM:[{tag:`s`},{tag:`del`}],toDOM(){return[`s`,0]}}}})]}getPlugins(e){return[this.contribution(U({"Alt-Shift-5":Eo(e.schema.marks.strikethrough),"Cmd-Shift-X":Eo(e.schema.marks.strikethrough)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>ml(t,{label:()=>t.rte.getLocale().richTextEditor.strikethrough,icon:`strikethrough-line`,markType:e.schema.marks.strikethrough})},4)]}},du=h.a(uu),fu=`tt{font:var(--vvd-typography-base-code);font-variant-ligatures:unset;font-feature-settings:unset;font-size:unset;font-weight:unset;line-height:unset}`,pu=class extends ru{constructor(...e){super(...e),this.name=`RteMonospaceFeature`,this.markName=`monospace`}getStyles(){return[this.contribution(fu)]}getSchema(){return[this.contribution({marks:{monospace:{parseDOM:[{tag:`tt`},{tag:`code`}],toDOM(){return[`tt`,0]}}}})]}getPlugins(e){return[this.contribution(U({"Mod-M":Eo(e.schema.marks.monospace)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>ml(t,{label:()=>t.rte.getLocale().richTextEditor.monospace,icon:`monospace-line`,markType:e.schema.marks.monospace})},5)]}},mu=h.a(pu);function hu(e,t,n){for(let r=0;r<t.length;r++){let{$from:i,$to:a}=t[r],o=i.depth==0?e.type.allowsMarkType(n):!1;if(e.nodesBetween(i.pos,a.pos,e=>o?!1:(o=e.inlineContent&&e.type.allowsMarkType(n),!0)),o)return!0}return!1}var gu=Symbol(`mixedColor`),_u=class extends h.r{constructor(e){if(super(),this.config=e,this.name=`RteTextColorPicker`,e?.onBlocks){this.defaultColorForNode={};for(let t of e.onBlocks)this.defaultColorForNode[t.node]=t.defaultColor??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:`textColor`,onNodeName:e.node})):[this.contribution({markName:`textColor`})]}getSchema(){return[this.contribution({marks:{textColor:{attrs:{color:{validate:`string`}},parseDOM:[{tag:`span[data-text-color]`,getAttrs:e=>({color:e.getAttribute(`data-text-color`)})},{style:`color`,getAttrs:e=>({color:e})}],toDOM(e){let{color:t}=e.attrs;return[`span`,{style:`color: ${_c(t)};`,"data-text-color":t},0]},inclusive:!0}}})]}getToolbarItems(){return[this.contribution({section:`text-style`,render:e=>{let t=$(e,{label:()=>e.rte.getLocale().richTextEditor.textColor,disabled:()=>!this.setColor(`any`)(e.view.state),icon:`textcolor-line`}),n=t.firstElementChild;return ol(e,{children:[t,bl(e,{name:`text-color-picker`,assignedProps:{anchor:n,value:()=>this.getSelectionColor(e.view.state)||``},assignedEvents:{change:t=>{let n=t.currentTarget.value;this.setColor(n)(e.view.state,e.view.dispatch)}}})]})}},6)]}getSelectionColor(e){let{selection:t}=e,{textColor:n}=e.schema.marks,{from:r,to:i,$from:a,empty:o}=t;if(o){let t=this.defaultColorForNode?.[a.parent.type.name]??null;return n.isInSet(e.storedMarks||a.marks())?.attrs.color??t}let s=null,c=e=>{s===null?s=e??null:e!==s&&(s=gu)};return e.doc.nodesBetween(r,i,(e,t,r)=>s===gu?!1:e.isLeaf?(c(n.isInSet(e.marks)?.attrs.color??(r&&this.defaultColorForNode?.[r.type.name])),!0):(e.type.allowsMarkType(n)&&e.childCount===0&&c(this.defaultColorForNode?.[e.type.name]),!0)),s===gu?null:s}setColor(e){return(t,n)=>{let{textColor:r}=t.schema.marks,{from:i,to:a,empty:o,$from:s}=t.selection;if(!hu(t.doc,t.selection.ranges,r))return!1;let c=t.tr;if(o){let n=(t.storedMarks||[]).filter(e=>e.type!==r);e!==this.defaultColorForNode?.[s.parent.type.name]&&n.push(r.create({color:e})),c.setStoredMarks(n)}else c.addMark(i,a,r.create({color:e})),c.doc.nodesBetween(i,a,(e,t,n)=>{if(!e.isInline)return;let i=r.isInSet(e.marks),a=this.defaultColorForNode?.[n.type.name];i&&i.attrs.color===a&&c.step(new _e(t,t+e.nodeSize,i))});return n?.(c.scrollIntoView()),!0}}},vu=h.a(_u),yu=`.rich-text ul,.rich-text ol{padding-inline-start:1.5em}.rich-text li{list-style-position:inside}`,bu=e=>e.parentOffset===0,xu=e=>e.nodeSize===2,Su=e=>e.depth-1,Cu=e=>e.depth-2,wu=e=>e.parent,Tu=e=>e.node(Su(e)),Eu=e=>e.depth>2,Du=(e,t)=>e.index(t)===0,Ou=(e,t)=>e.index(t)===e.node(t).childCount-1,ku=(e,t)=>{let n=e.node(t),r=e.index(t);return n.maybeChild(r-1)},Au=(e,t)=>{let n=e.node(t),r=e.index(t);return n.maybeChild(r+1)},ju=e=>{let{$from:t,$to:n}=e;if(e instanceof j){let r=k.between(e.$from,e.$to);t=r.$from,n=r.$to}return{$from:t,$to:n}},Mu=(e,t)=>e.sameParent(t)?e.node(-1):e.node(e.sharedDepth(t.pos)),Nu=e=>{let{$cursor:t}=e.selection;return t?.parent.type===e.schema.nodes.listItem?t:null},Pu=(e,t,n,r)=>{let i,a=!0;return e.doc.nodesBetween(t.pos,n.pos,t=>{t.type.isInGroup(`list`)&&(i=t.type),t.type===e.schema.nodes.listItem&&i!==r&&(a=!1)}),a},Fu=(e,t,n)=>Eu(t)?(Iu(t,n),!0):Lu(e,t,n),Iu=(e,t)=>{let n=new h.h(e.doc.resolve(e.before()),e.doc.resolve(e.after()),e.depth-1);t.lift(n,e.depth-2)},Lu=(e,t,n)=>{let r=Tu(t),i=t.index(Cu(t)),a=Jo(t.node(Cu(t)).contentMatchAt(i+1));if(!a)return!1;let o=Du(t,Su(t)),s=Ou(t,Su(t));return n.step(new T(t.before()-+!!o,t.after()+ +!!s,t.start(),t.end(),new h.v((o?h.d.empty:h.d.from(r.copy(h.d.empty))).append(h.d.from(a.create(e.textblockAttrs.extractFromNode(wu(t))))).append(s?h.d.empty:h.d.from(r.copy(h.d.empty))),+!o,+!s),+!o+1)),!0},Ru=(e,t,n,r)=>{n.parent.type===e.schema.nodes.listItem?zu(t,n,r):Bu(e,t,n,r)},zu=(e,t,n)=>{let r=ku(t,Su(t))?.type===e,i=Au(t,Su(t))?.type===e,a=+!!r,o=+!!i;n.step(new T(t.before()-+!!r,t.after()+ +!!i,t.before(),t.after(),new h.v(h.d.from(e.create(null,[])),a,o),1-a))},Bu=(e,t,n,r)=>{r.step(new T(n.before(),n.after(),n.start(),n.end(),new h.v(h.d.from(t.create(null,[e.schema.nodes.listItem.create(e.textblockAttrs.extractFromNode(n.parent))])),0,0),2))},Vu=class extends h.r{constructor(e){if(super(),this.config=e,this.name=`RteListFeature`,!e.bulletList&&!e.numberedList)throw Error(`RteListFeature requires at least one of bulletList or numberedList to be enabled`)}getStyles(){return[this.contribution(yu)]}getSchema(e){return[this.contribution({nodes:{listItem:{content:`inline*`,attrs:e.attrs,defining:!0,parseDOM:[{tag:`li`,getAttrs:t=>e.fromDOM(t)}],toDOM(t){return[`li`,...e.getDOMAttrs(t),0]}},...this.config.bulletList?{bulletList:{group:`block list`,content:`(listItem | list)+`,parseDOM:[{tag:`ul`}],toDOM(){return[`ul`,0]}}}:{},...this.config.numberedList?{numberedList:{group:`block list`,content:`(listItem | list)+`,parseDOM:[{tag:`ol`}],toDOM(){return[`ol`,0]}}}:{}}})]}getPlugins(e){return this.rte=e,[this.contribution(U({Enter:(e,t)=>{let n=Nu(e);if(n&&xu(wu(n))){let r=e.tr;return Fu(this.rte,n,r)?(t?.(r.scrollIntoView()),!0):!1}return!1},Backspace:(e,t)=>{let n=Nu(e);if(n&&bu(n)){if(Du(n,Su(n))&&ku(n,Cu(n))?.type===Tu(n).type)return!1;let r=e.tr;return Fu(this.rte,n,r)?(t?.(r.scrollIntoView()),!0):!1}return!1},Tab:(e,t)=>{let n=Nu(e);if(n&&bu(n)){let r=e.tr;return zu(Tu(n).type,n,r),t?.(r.scrollIntoView()),!0}return!1},"Shift-Tab":(e,t)=>{let n=Nu(e);if(n&&bu(n)&&Eu(n)){let r=e.tr;return Iu(n,r),t?.(r.scrollIntoView()),!0}return!1},...this.config.bulletList?{"Mod-Shift-8":this.toggleList(e.schema.nodes.bulletList)}:{},...this.config.numberedList?{"Mod-Shift-7":this.toggleList(e.schema.nodes.numberedList)}:{}}),h.i.high)]}getToolbarItems(e){let t=[];return this.config.bulletList&&t.push(this.contribution({section:`textblock`,render:t=>$(t,{label:()=>t.rte.getLocale().richTextEditor.bulletList,icon:`bullet-list-2-line`,active:()=>this.isSelectionInList(e.schema.nodes.bulletList,t.rte.state),onClick:()=>{let{state:n,dispatch:r}=t.view;this.toggleList(e.schema.nodes.bulletList)(n,r)}})},1)),this.config.numberedList&&t.push(this.contribution({section:`textblock`,render:t=>$(t,{label:()=>t.rte.getLocale().richTextEditor.numberedList,icon:`list-numbered-line`,active:()=>this.isSelectionInList(e.schema.nodes.numberedList,t.rte.state),onClick:()=>{let{state:n,dispatch:r}=t.view;this.toggleList(e.schema.nodes.numberedList)(n,r)}})},2)),t}toggleList(e){return Oo((t,n)=>{let{$from:r,$to:i}=ju(t.selection);if(Mu(r,i).type.isInGroup(`list`))if(Pu(t,r,i,e)){let e=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(n,r)=>{if(n.type===t.schema.nodes.listItem){let t=e.doc.resolve(e.mapping.map(r+1));Fu(this.rte,t,e)}}),n?.(e.scrollIntoView()),!0}else{let a=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(t,n)=>{t.type.isInGroup(`list`)&&t.type!==e&&a.setNodeMarkup(n,e,t.attrs)}),n?.(a.scrollIntoView()),!0}else{let a=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(t,n)=>{if(!t.isTextblock)return;let r=a.doc.resolve(a.mapping.map(n+1));Ru(this.rte,e,r,a)}),n?.(a.scrollIntoView()),!0}},(t,n)=>t.type===e&&n.type===e)}isSelectionInList(e,t){let{$from:n,$to:r}=ju(t.selection);return Mu(n,r).type.isInGroup(`list`)?Pu(t,n,r,e):!1}},Hu=h.a(Vu),Uu=[{value:`left`,icon:`align-left-line`,label:`left`},{value:`center`,icon:`align-center-line`,label:`center`},{value:`right`,icon:`align-right-line`,label:`right`}],Wu=e=>Uu.find(t=>t.value===e)?.value??`left`,Gu=class extends h.r{constructor(...e){super(...e),this.name=`RteAlignmentFeature`}getTextblockAttrs(){return[this.contribution({name:`textAlign`,default:`left`,fromDOM(e){return Wu(e.style.textAlign)},toStyles(e){return[`text-align: ${Wu(e.attrs.textAlign)}`]}})]}getPlugins(){return[this.contribution(U({"Mod-L":this.setAlignment(`left`),"Mod-E":this.setAlignment(`center`),"Mod-R":this.setAlignment(`right`)}))]}getToolbarItems(){return[this.contribution({section:`textblock`,render:e=>ul(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,trigger:$(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,icon:()=>{let t=this.getAlignmentFromSelection(e.view.state);return Uu.find(e=>e.value===t)?.icon??`align-left-line`}}),children:[fl(e,{slot:`header`,children:Uu.map((t,n)=>$(e,{icon:t.icon,label:()=>e.rte.getLocale().richTextEditor.alignments[t.label],noTooltip:!0,variant:`toolbar-menu`,autofocus:()=>{let r=this.getAlignmentFromSelection(e.view.state);return(r===`mixed`||r===null)&&n===0?!0:t.value===r},active:()=>this.getAlignmentFromSelection(e.view.state)===t.value,disabled:()=>this.getAlignmentFromSelection(e.view.state)===null,onClick:()=>{let{state:n,dispatch:r}=e.view;this.setAlignment(t.value)(n,r)}}))})]})},3)]}getAlignmentFromSelection(e){let{selection:t}=e,{from:n,to:r}=t,i=null;return e.doc.nodesBetween(n,r,e=>{i!==`mixed`&&e.type.isTextblock&&(i?i!==e.attrs.textAlign&&(i=`mixed`):i=e.attrs.textAlign)}),i}setAlignment(e){return(t,n)=>{let{tr:r,selection:i}=t,{from:a,to:o}=i;return t.doc.nodesBetween(a,o,(t,n)=>{t.type.isTextblock&&r.setNodeMarkup(n,t.type,{...t.attrs,textAlign:e})}),n?.(r.scrollIntoView()),!0}}},Ku=h.a(Gu),qu=`.link-popover{flex-direction:column;gap:8px;inline-size:450px;padding:16px;display:flex}.link-popover-header{justify-content:space-between;align-items:center;display:flex}.link-popover-label{color:var(--vvd-color-neutral-600);font:var(--vvd-typography-base-condensed)}.link-popover-content{flex-direction:column;gap:16px;display:flex}.link,.rich-text a[href],.link:visited,.rich-text a[href]:visited{color:var(--vvd-color-cta-600)}.link:hover,.rich-text a[href]:hover{color:var(--vvd-color-cta-500)}.link:active,.rich-text a[href]:active{color:var(--vvd-color-cta-400)}.link-action-bar{justify-content:end;gap:8px;display:flex}.link-toolbar-menu{flex-direction:column;gap:16px;inline-size:368px;padding:8px;display:flex}`,Ju=`(?:https?://|www\\.)[^\\s<]+`;function Yu(e,t,n,r){if(e.doc.rangeHasMark(n,n+1,e.schema.marks.link))return null;let i=t.replace(/[.,;:!?) ]+$/,``),a=i.startsWith(`www.`)?`https://${i}`:i,o=e.schema.marks.link.create({href:a}),s=n+i.length,c=t.slice(i.length),l=e.tr.addMark(n,s,o);return c&&l.replaceWith(s,r,e.schema.text(c)),l}var Xu=class extends h.r{constructor(...e){super(...e),this.name=`RteLinkFeature`,this.removeLink=(e,t)=>{let n=e.tr,r=this.getCurrentLink(e);return n.removeMark(r.start,r.end,e.schema.marks.link),t?.(n.scrollIntoView()),!0}}getStyles(){return[this.contribution(qu)]}getSchema(){return[this.contribution({marks:{link:{attrs:{href:{validate:`string`}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`)}}}],toDOM(e){let{href:t}=e.attrs;return[`a`,{href:hc(t)},0]}}}},h.i.high)]}getTextblockMarks(){return[this.contribution({markName:`link`})]}getInputRules(){let e=RegExp(`${Ju}$`);return[this.contribution({rule:new wl(RegExp(`${Ju} $`),(e,t,n,r)=>Yu(e,t[0],n,r)),enterHandler:{regex:e,handler:(e,t,n,r)=>Yu(e,t[0],n,r)}})]}getPlugins(e){let t=()=>(this.toolbarMenu.open=!0,!0),n;return[this.contribution(new M({props:{decorations:e=>{let t=this.getCurrentLink(e);if(t){let n=z.inline(t.start,t.end,{id:`current-link`});return B.create(e.doc,[n])}return null}},view:t=>{let r=new al(t,e,{popupPlacement:`bottom`,shouldReturnFocusToEditor:!0});n=e.createComponent(re),n.anchorId=`current-link`;let i=ol(r,{className:`link-popover`,children:[ol(r,{className:`link-popover-header`,children:[ol(r,{className:`link-popover-label`,children:[yl(r,{text:()=>this.getCurrentLink(r.view.state)?.text||``})]}),$(r,{icon:`close-line`,label:()=>r.rte.getLocale().richTextEditor.close,noTooltip:!0,onClick:()=>{n.dismiss()}})]}),ol(r,{className:`link-popover-content`,children:[sl(r,{className:`link`,href:()=>this.getCurrentLink(r.view.state)?.href||``,target:`_blank`,rel:`noopener`,children:[yl(r,{text:()=>this.getCurrentLink(r.view.state)?.href||``})]}),ol(r,{className:`link-action-bar`,children:[$(r,{icon:`delete-line`,label:()=>r.rte.getLocale().richTextEditor.delete,connotation:`alert`,variant:`popover`,noTooltip:!0,onClick:()=>{let{state:e,dispatch:t}=r.view;this.removeLink(e,t)}}),$(r,{icon:`edit-line`,label:()=>r.rte.getLocale().richTextEditor.edit,variant:`popover`,noTooltip:!0,onClick:()=>(this.toolbarMenu.open=!0,n.requestOpenState(!1),!0)})]})]})]});return n.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(n),{update:e=>{let t=e.state;r.updateBindings();let i=this.getCurrentLink(t);n.requestOpenState(!!i)},destroy:()=>{n.remove()}}}})),this.contribution(U({Escape:e=>this.getCurrentLink(e)?(n?.dismiss(),!0):!1,"Mod-k":t}))]}getToolbarItems(e){let t=e=>{let{from:t,to:n}=e.selection;return t===n?``:e.doc.textBetween(t,n,` `)},n=e=>{try{return new URL(e),!0}catch{return!1}};return[this.contribution({section:`insert`,render:r=>{let i=vl(r,{label:()=>r.rte.getLocale().richTextEditor.linkText,placeholder:()=>r.rte.getLocale().richTextEditor.linkTextPlaceholder,slot:`header`,autofocus:!0,value:()=>this.getCurrentLink(r.view.state)?.text||t(r.view.state)||``,onInput:()=>{s()}}),a=vl(r,{label:()=>r.rte.getLocale().richTextEditor.linkUrl,type:`url`,placeholder:()=>r.rte.getLocale().richTextEditor.linkUrlPlaceholder,helperText:()=>r.rte.getLocale().richTextEditor.linkUrlHelperText,slot:`header`,value:()=>this.getCurrentLink(r.view.state)?.href||``,onInput:()=>{s()}}),o=$(r,{label:()=>r.rte.getLocale().richTextEditor.apply,variant:`popover-primary`,disabled:()=>{let e=this.getCurrentLink(r.view.state);return!(e&&e.text.length&&n(e.href))},onClick:()=>{let{state:t,dispatch:n}=r.view;this.insertLink(e,a.value,i.value)(t,n),this.toolbarMenu.open=!1}}),s=()=>{o.querySelector(`[data-vvd-component="button"]`).disabled=!(i.value.length&&n(a.value))},c=ul(r,{label:()=>r.rte.getLocale().richTextEditor.hyperlink,trigger:$(r,{label:()=>r.rte.getLocale().richTextEditor.hyperlink,icon:`link-line`}),children:[ol(r,{className:`link-toolbar-menu`,slot:`header`,children:[i,a,ol(r,{className:`link-action-bar`,slot:`header`,children:[$(r,{label:()=>r.rte.getLocale().richTextEditor.cancel,variant:`popover`,onClick:()=>{this.toolbarMenu.open=!1}}),o]})]})]});return this.toolbarMenu=c.lastElementChild,c}},1)]}getCurrentLink(e){let t=e.selection;if(!(t instanceof k))return null;let n=e.schema.marks.link,{$from:r,$to:i}=t,a=e.selection.empty?r.marks():r.nodeAfter?.marks??[],o=n.isInSet(a)?.attrs.href;if(!o)return null;let s=e=>n.isInSet(e.marks)?.attrs.href===o,c=null,l=[];e.doc.nodesBetween(r.start(),i.end(),(e,t)=>{if(!e.isText)return!0;let n=t+e.nodeSize;return s(e)?c?c.end=n:(c={start:t,end:n},l.push(c)):c=null,!1});let u=l.find(e=>e.start<=t.from&&e.end>=t.to);return u?{text:e.doc.textBetween(u.start,u.end,` `),href:o,start:u.start,end:u.end}:null}insertLink(e,t,n){return(r,i)=>{let{from:a,to:o}=r.selection,s=r.tr,c=this.getCurrentLink(r);return c&&(a=c.start,o=c.end),s.insertText(n,a,o),s.addMark(a,a+n.length,e.schema.marks.link.create({href:t})),i?.(s.scrollIntoView()),!0}}},Zu=h.a(Xu),Qu=`.inline-image-wrapper{vertical-align:text-bottom;display:inline-block}.inline-image{block-size:auto;display:block}.inline-image-popover{align-items:center;gap:4px;padding:8px;display:flex}.inline-image-placeholder{color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);font-feature-settings:normal;font-variant-ligatures:normal;overflow-wrap:normal;pointer-events:none;white-space:normal}`,$u=e=>e!==null&&!!e.next,ed=1,td=()=>ed++,nd=class{constructor(e,t,n,r){this.view=t,this.getPos=n,this.config=r,this.content=null,this.dom=document.createElement(`div`),this.dom.className=`inline-image-wrapper`,this.imageUrl=e.attrs.imageUrl,this.img=document.createElement(`img`),this.initializeImg(e);let i=this.config.resolveUrl?this.config.resolveUrl(this.imageUrl):this.imageUrl,a=$u(i)?null:i;this.handleResolvedUrl(a),$u(i)&&this.handleResolvedUrlGenerator(i)}setContent(e,{onDestroy:t,allowPopover:n}={}){this.content?.remove(),this.onContentDestroy?.(),this.content=e,e&&(this.onContentDestroy=t,this.dom.appendChild(e)),re.setBlockPopover(this.dom,!n)}async handleResolvedUrlGenerator(e){let t=e[Symbol.asyncIterator](),n;do n=await t.next(),this.handleResolvedUrl(n.value);while(!n.done)}handleResolvedUrl(e){if(typeof e==`string`)this.renderImg(e);else if(e?.type===`placeholder`){let t=`inline-image-placeholder-${td()}`,n=document.createElement(`slot`);n.className=`inline-image-placeholder`,n.name=t;let r=e.create?.(t),i=this.view.dom.getRootNode().host;h.t(i,`inline-image-placeholder`,t,{url:this.imageUrl}),this.setContent(n,{onDestroy:()=>{h.t(i,`inline-image-placeholder`,t,h.n),r?.()}})}else this.setContent(null)}initializeImg(e){this.img.className=`inline-image`,this.update(e),this.img.addEventListener(`load`,()=>{let e=this.getPos();if(e){let{state:t,dispatch:n}=this.view,r=t.doc.nodeAt(e);if(!r||r.attrs.naturalWidth===this.img.naturalWidth&&r.attrs.naturalHeight===this.img.naturalHeight)return;let i=t.tr;i.setNodeAttribute(e,`naturalWidth`,this.img.naturalWidth),i.setNodeAttribute(e,`naturalHeight`,this.img.naturalHeight),i.setMeta(`addToHistory`,!1),n(i)}})}renderImg(e){this.img.src=gc(e),this.setContent(this.img,{allowPopover:!0})}update(e){return this.img.alt=e.attrs.alt,this.img.width=e.attrs.naturalWidth,this.img.height=e.attrs.naturalHeight,this.img.style.maxWidth=e.attrs.size,!0}destroy(){this.setContent(null)}},rd=class extends h.r{constructor(e={}){super(),this.config=e,this.name=`RteInlineImageFeature`}getStyles(){return[this.contribution(Qu)]}getSchema(){return[this.contribution({nodes:{inlineImage:{inline:!0,group:`inline`,selectable:!0,atom:!0,attrs:{imageUrl:{validate:`string`},alt:{validate:`string`,default:``},size:{validate:`string|null`,default:null},naturalWidth:{validate:`number|null`,default:null},naturalHeight:{validate:`number|null`,default:null}},parseDOM:[{tag:`img[src],img[data-src]`,getAttrs:e=>{let t=e=>{let t=parseInt(e??``,10);return isNaN(t)?null:t},n=e.getAttribute(`data-src`)??e.getAttribute(`src`),r=this.config.parseUrlFromHtml?this.config.parseUrlFromHtml(n):n;return r===null?!1:{imageUrl:r,alt:e.getAttribute(`alt`)||``,size:e.style.maxWidth||null,naturalWidth:t(e.getAttribute(`width`)),naturalHeight:t(e.getAttribute(`height`))}}}],toDOM:e=>{let{imageUrl:t,alt:n,size:r,naturalWidth:i,naturalHeight:a}=e.attrs,o=this.config.serializeUrlToHtml?this.config.serializeUrlToHtml(t):t;if(o===null)return document.createTextNode(``);let s={src:gc(o),"data-src":o,alt:n};return r&&(s.style=`max-width: ${_c(r)}; height: auto;`),i&&(s.width=i),a&&(s.height=a),[`img`,s]}}}})]}getPlugins(e){let t;return[this.contribution(new M({props:{nodeViews:{inlineImage:(e,t,n)=>new nd(e,t,n,this.config)}},view:n=>{let r=new al(n,e,{popupPlacement:`bottom`,shouldReturnFocusToEditor:!0});t=e.createComponent(re),t.kind=`imageOptions`,t.offset=4;let i=ol(r,{className:`inline-image-popover`,children:[$(r,{label:()=>r.rte.getLocale().richTextEditor.imageSizes.small,variant:`popover`,active:()=>this.getSelectedImageSize(r.view.state)===`small`,onClick:()=>{this.setSelectedImageSize(`small`)(r.view.state,r.view.dispatch)}}),_l(r),$(r,{label:()=>r.rte.getLocale().richTextEditor.imageSizes.fit,variant:`popover`,active:()=>this.getSelectedImageSize(r.view.state)===`fit`,onClick:()=>{this.setSelectedImageSize(`fit`)(r.view.state,r.view.dispatch)}}),_l(r),$(r,{label:()=>r.rte.getLocale().richTextEditor.imageSizes.original,variant:`popover`,active:()=>this.getSelectedImageSize(r.view.state)===`original`,onClick:()=>{this.setSelectedImageSize(`original`)(r.view.state,r.view.dispatch)}})]});return t.appendChild(i),n.dom.getRootNode().querySelector(`.popovers`).appendChild(t),{update:e=>{r.updateBindings();let n=this.getSelectedInlineImage(e.state);n?(t.anchorEl=e.nodeDOM(n.pos),t.requestOpenState(!0)):(t.anchorEl=void 0,t.requestOpenState(!1))},destroy:()=>{t.remove()}}}})),this.contribution(U({Escape:e=>this.getSelectedInlineImage(e)?(t?.dismiss(),!0):!1}))]}calculateSmallWidth(e){return`${Math.min(300,e/2)}px`}getSelectedInlineImage(e){let t=e.selection;return t instanceof A&&t.node.type===e.schema.nodes.inlineImage?{pos:t.from,node:t.node}:null}setSelectedImageSize(e){return(t,n)=>{let r=this.getSelectedInlineImage(t);if(!r)return!1;let{naturalWidth:i}=r.node.attrs;if(e===`small`&&i===null)return!1;let a=t.tr;return a.setNodeAttribute(r.pos,`size`,e===`small`?this.calculateSmallWidth(i):e===`fit`?`100%`:null),n?.(a.scrollIntoView()),!0}}getSelectedImageSize(e){let t=this.getSelectedInlineImage(e);if(!t)return null;let{size:n,naturalWidth:r}=t.node.attrs;return r!==null&&n===this.calculateSmallWidth(r)?`small`:n===`100%`?`fit`:n===null?`original`:null}},id=h.a(rd),ad=async e=>{try{return{type:`ok`,result:await e}}catch(e){return{type:`error`,error:e}}},od=class extends h.r{constructor(e){super(),this.config=e,this.name=`RteFileHandlerFeature`}getPlugins(e){let t=new M({state:{init(){return B.empty},apply(e,n){n=n.map(e.mapping,e.doc);let r=e.getMeta(t);if(r&&r.add){let t=document.createElement(`placeholder`),i=z.widget(r.add.pos,t,{id:r.add.id,relaxedSide:!0});n=n.add(e.doc,[i])}else r&&r.remove&&(n=n.remove(n.find(void 0,void 0,e=>e.id==r.remove.id)));return n}},props:{decorations(e){return this.getState(e)}}}),n=(e,n)=>{let r=c.n();return e.setMeta(t,{add:{id:r,pos:n}}),{getPos:e=>{let n=t.getState(e).find(void 0,void 0,e=>e.id==r);return n.length?n[0].from:null},remove:e=>{e.setMeta(t,{remove:{id:r}})}}},r=(t,n,r)=>{if(r.type===`selection`){let r=h.v.fromJSON(e.schema,{content:n});t.replaceSelection(r)}else{let i=h.d.fromJSON(e.schema,n);t.insert(r.pos,i)}},i=(e,t)=>{let n=this.config.handleFiles(e);n!==null&&(n instanceof Promise?o(n,t):a(n,t))},a=(t,n)=>{let i=e.state.tr;r(i,t,n),e.dispatchTransaction(i)},o=async(t,i)=>{let a=e.state.tr;i.type===`selection`&&!a.selection.empty&&a.deleteSelection();let o=n(a,i.type===`selection`?a.selection.from:i.pos);e.dispatchTransaction(a);let s=await ad(t),c=o.getPos(e.state),l=e.state.tr;o.remove(l),c!==null&&s.type===`ok`&&r(l,s.result,{type:`pos`,pos:c}),e.dispatchTransaction(l),s.type===`error`&&console.error(`Error in handleFiles handler:`,s.error)};return[this.contribution(t),this.contribution(new M({props:{handlePaste:(e,t)=>{let n=Array.from(t.clipboardData.files);return n.length?(i(n,{type:`selection`}),!0):!1},handleDrop:(e,t)=>{let n=Array.from(t.dataTransfer.files);if(!n.length)return!1;let r=e.posAtCoords({left:t.clientX,top:t.clientY}).pos;if(e.dragging&&e.dragging.slice){let t=Ve(e.state.doc,r,e.dragging.slice);t!=null&&(r=t)}return i(n,{type:`pos`,pos:r}),!0}}}))]}},sd=h.a(od),cd=class extends h.r{constructor(e){super(),this.config=e,this.name=`RteDebugFeature`}getPlugins(){let e=new WeakMap,t=!1,n=n=>{e.get(n)===void 0&&(t=this.config.onViewportDragOver?.(n)??!1)},r=e=>{this.config.onViewportDrop?.(e),this.config.onViewportDragFinish?.()},i=()=>{this.config.onViewportDragFinish?.()},a=!1,o=()=>{a=!0,window.setTimeout(()=>a=!1,0)},s=()=>{a||this.config.onViewportDragFinish?.()};return[this.contribution(new M({view:e=>{let t=e.root.host.editorViewportElement;return t.addEventListener(`dragover`,n),t.addEventListener(`drop`,r),t.addEventListener(`dragend`,i),t.addEventListener(`dragenter`,o),t.addEventListener(`dragleave`,s),{destroy(){t.removeEventListener(`dragover`,n),t.removeEventListener(`drop`,r),t.removeEventListener(`dragend`,i),t.removeEventListener(`dragenter`,o),t.removeEventListener(`dragleave`,s)}}}})),this.contribution(new M({props:{handleDOMEvents:{dragover:(n,r)=>{let i=this.config.onViewportDragOver?.(r)??!1;return e.set(r,i),t=i,i?(r.stopImmediatePropagation(),r.preventDefault(),!0):!1},drop:()=>t}}}),h.i.high)]}},ld=h.a(cd),ud=class extends h.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteToolbarButtonFeature[${e}]`}getToolbarItems(){return[this.contribution({section:`insert`,render:e=>$(e,{label:this.options.label,icon:this.options.icon,onClick:()=>{this.executeAction(e)}})},2+(this.options.order??0)/(2**53-1))]}executeAction(e){let{action:t}=this.options;switch(t.type){case`insert-text`:{let{state:n,dispatch:r}=e.view,{from:i,to:a}=n.selection;r(n.tr.insertText(t.text,i,a));break}}}},dd=h.a(ud),fd=e=>typeof e==`object`&&!!e&&`next`in e,pd=class{constructor(e,t,n){this.dom=document.createElement(`span`),this.dom.className=`atom-wrapper`,this.dom.setAttribute(`part`,`node--${n}`);let r=t.resolveValue?t.resolveValue(e.attrs.value):e.attrs.value;fd(r)?(this.dom.textContent=``,this.handleResolvedGenerator(r)):this.dom.textContent=r??``}async handleResolvedGenerator(e){let t=e[Symbol.asyncIterator](),n;do n=await t.next(),this.dom.textContent=n.value??``;while(!n.done)}},md=class extends h.r{constructor(e,t={}){super(),this.atomName=e,this.config=t,this.name=`RteAtomFeature[${e}]`}getSchema(){let e={inline:!0,group:`inline`,selectable:!0,atom:!0,attrs:{value:{validate:`string`}},parseDOM:[{tag:`span[data-atom-type="${this.atomName}"][data-value]`,getAttrs:e=>({value:e.getAttribute(`data-value`)})}],toDOM:e=>{let t=this.config.serializeValueToHtml?this.config.serializeValueToHtml(e.attrs.value):e.attrs.value;return t===null?document.createDocumentFragment():[`span`,{part:`node--${this.atomName}`},t]},serializeToDOM:e=>{let t=this.config.serializeValueToHtml?this.config.serializeValueToHtml(e.attrs.value):e.attrs.value;return t===null?document.createTextNode(``):[`span`,{"data-atom-type":this.atomName,"data-value":e.attrs.value},t]}};return[this.contribution({nodes:{[this.atomName]:e}})]}getPlugins(e){return[this.contribution(new M({props:{nodeViews:{[this.atomName]:e=>new pd(e,this.config,this.atomName)}}}))]}},hd=h.a(md),gd=class extends h.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteInputRuleFeature[${e}]`}getInputRules(e){let t=`(?:${this.options.pattern.source})`,n=(t,n,r,i)=>{let a=this.options.handler(n);return a?t.tr.replaceWith(r,i,h.d.fromJSON(e.schema,a)):null},r={rule:new wl(this.options.matchAfterWhitespace?RegExp(`${t} $`):RegExp(`${t}$`),n)};return this.options.matchAfterWhitespace&&(r.enterHandler={regex:RegExp(`${t}$`),handler:n}),[this.contribution(r)]}},_d=h.a(gd);function vd(e,t){return(n,r)=>e(t)}var yd=class extends h.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteKeyboardShortcutsFeature[${e}]`}getPlugins(e){let t={};for(let[n,r]of Object.entries(this.options.shortcuts))t[n]=vd(r,e.facade);return[this.contribution(U(t),h.i.high)]}},bd=h.a(yd),xd=`.suggest-popover{flex-direction:column;gap:2px;max-block-size:408px;min-inline-size:128px;max-inline-size:248px;padding:4px;display:flex}.suggest-loading-widget{vertical-align:middle;white-space:normal;align-items:center;margin-inline-start:2px;display:inline-flex}.suggest-empty-message{color:var(--vvd-color-neutral-300);font:var(--vvd-typography-base);text-align:center;justify-content:center;align-items:center;min-block-size:40px;display:flex}`,Sd=e=>!!(e?.suggestions&&!e.dismissed),Cd=e=>Sd(e)&&e.suggestions.items.length>0;function wd(e,t){let{$cursor:n}=e.selection;if(!n)return null;let r=Al(n),i=t.exec(r);if(!i)return null;let a=n.pos-n.parentOffset;return{text:i[0],groups:[...i],start:a+i.index,end:a+i.index+i[0].length}}var Td=(e,t,n)=>{let{state:r}=e;e.dispatch(Xc(r.tr));let i=e.state.tr;i.replaceWith(t.start,t.end,h.d.fromJSON(e.state.schema,n));let a=i.mapping.map(t.end);i.setSelection(k.create(i.doc,a)),e.dispatch(i.scrollIntoView())},Ed=class extends h.r{selectSuggestion(e,t,n){let r=this.options.select(n);Td(e,t.match,r),e.focus()}async startLoadingSuggestions(e,t){let n=++this.loadGeneration,r=await this.options.load(e);n===this.loadGeneration&&t({type:`load`,generation:n,suggestions:r})}constructor(e,t){super(),this.featureId=e,this.options=t,this.pluginKey=new Et(`suggest`),this.loadGeneration=0,this.name=`RteSuggestFeature[${e}]`}getStyles(){return[this.contribution(xd)]}getPlugins(e){let t=t=>e.state.tr.setMeta(this.pluginKey,t),n=n=>e.dispatchTransaction(t(n)),r=new M({key:this.pluginKey,state:{init:()=>null,apply:(t,r,a,o)=>{let s=wd(o,this.options.pattern);if(!s||!r&&!t.docChanged)return null;if(r?.dismissed)return r;let c=n=>n?r?.loadingDecoration.find().length??0?r.loadingDecoration.map(t.mapping,t.doc):B.create(t.doc,[z.widget(s.end,()=>{let t=document.createElement(`span`);t.className=`suggest-loading-widget`;let n=e.createComponent(i.r);return n.size=-6,t.appendChild(n),t},{ignoreSelection:!0,side:1})]):B.empty,l=t.getMeta(this.pluginKey);if(r&&l)switch(l.type){case`load`:return{...r,suggestions:{generation:l.generation,items:l.suggestions,selectedIndex:0,visibleFocus:!1},loadingDecoration:c(!1)};case`navigate`:{if(!r.suggestions?.items.length)return r;if(!r.suggestions.visibleFocus)return{...r,suggestions:{...r.suggestions,visibleFocus:!0}};let e=Math.max(0,Math.min(r.suggestions.items.length-1,r.suggestions.selectedIndex+(l.action===`up`?-1:1)));return{...r,suggestions:{...r.suggestions,selectedIndex:e}}}case`dismiss`:return{...r,dismissed:!0,loadingDecoration:B.empty}}if(!r)return this.startLoadingSuggestions(s.groups,n),{match:s,loadingDecoration:c(!0)};let u=s.groups[0]!==r.match.groups[0];return u&&this.startLoadingSuggestions(s.groups,n),{...r,match:s,suggestions:r.suggestions?{...r.suggestions,visibleFocus:!1}:void 0,loadingDecoration:c(u)}}},props:{decorations:e=>{let t=this.pluginKey.getState(e);return t?t.loadingDecoration.add(e.doc,[z.inline(t.match.start,t.match.end,{id:`suggest-anchor-${this.featureId}`})]):null}},view:t=>{let n=new al(t,e,{popupPlacement:`bottom`,shouldReturnFocusToEditor:!0}),r=e.createComponent(re);r.anchorId=`suggest-anchor-${this.featureId}`,r.kind=`autocomplete`,r.offset=4;let i=ol(n,{className:`suggest-popover`,children:[]});r.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(r);let a=`${this.featureId}-suggestions-empty`,o=t.dom.getRootNode().host,s=!1,c=e=>{!s&&e&&h.t(o,`suggestions-empty-state`,a,{id:this.featureId}),s&&!e&&h.t(o,`suggestions-empty-state`,a,h.n),s=e},l=r=>{i.innerHTML=``;let o=r.suggestions,s=o.items.length===0;if(c(s),s){let t=document.createElement(`slot`);t.name=a,t.textContent=e.getLocale().richTextEditor.suggestNoResults,i.appendChild(ol(n,{className:`suggest-empty-message`,children:[t]}));return}for(let[n,a]of o.items.entries()){let s=e.createComponent(u.t);s.text=a.text,s.textSecondary=a.textSecondary,n===o.selectedIndex&&(s.selected=!0,o.visibleFocus&&(s._highlighted=!0),queueMicrotask(()=>{s.scrollIntoView({block:`nearest`})})),s.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),this.selectSuggestion(t,r,a)}),i.appendChild(s)}};return{update:e=>{n.updateBindings();let t=this.pluginKey.getState(e.state),i=Sd(t);r.requestOpenState(i),i?l(t):c(!1)},destroy:()=>{c(!1),r.remove()}}}});return[this.contribution(r),this.contribution(U({ArrowUp:(e,n)=>Cd(this.pluginKey.getState(e))?(n?.(t({type:`navigate`,action:`up`})),!0):!1,ArrowDown:(e,n)=>Cd(this.pluginKey.getState(e))?(n?.(t({type:`navigate`,action:`down`})),!0):!1,Enter:(e,t,n)=>{let r=this.pluginKey.getState(e);if(!Cd(r))return!1;let i=r.suggestions.items[r.suggestions.selectedIndex];return n&&this.selectSuggestion(n,r,i),!0},Escape:(e,n)=>Sd(this.pluginKey.getState(e))?(n?.(t({type:`dismiss`})),!0):!1}),h.i.high)]}},Dd=h.a(Ed),Od=e=>e.textBetween(0,e.content.size,void 0,` `).length,kd=class extends h.r{constructor(e){super(),this.config=e,this.name=`RteCharacterCountFeature`}getPlugins(){let e=this.config?.limit;return e===void 0?[]:[this.contribution(new M({filterTransaction:(t,n)=>{if(!t.docChanged)return!0;let r=Od(n.doc),i=Od(t.doc);if(i<=e)return!0;if(r>e)return i<=r;if(!t.getMeta(`paste`))return!1;let a=t.selection.$head.pos,o=a-(i-e),s=a;return t.deleteRange(o,s),Od(t.doc)<=e}}))]}getPublicInterface(e){let t=this.config?.limit;return{get characters(){return Od(e.state.doc)},get limit(){return t}}}},Ad=h.a(kd),jd=t.u(`rich-text-editor`,_,v,[p.t,f.n,d.t,a.t,s.n,ee.t,g.t,l.n,ie,i.t],{styles:te,shadowOptions:{delegatesFocus:!0}});t.d(jd)(),exports.RteAlignmentFeature=Ku,exports.RteAtomFeature=hd,exports.RteBase=Nl,exports.RteBoldFeature=au,exports.RteCharacterCountFeature=Ad,exports.RteConfig=jc,exports.RteDropHandlerFeature=ld,exports.RteFileHandlerFeature=sd,exports.RteFontSizePickerFeature=Kl,exports.RteHardBreakFeature=Ul,exports.RteHtmlParser=bc,exports.RteHtmlSerializer=Cc,exports.RteInlineImageFeature=id,exports.RteInputRuleFeature=_d,exports.RteItalicFeature=su,exports.RteKeyboardShortcutsFeature=bd,exports.RteLinkFeature=Zu,exports.RteListFeature=Hu,exports.RteMonospaceFeature=mu,exports.RtePlaceholderFeature=Vl,exports.RteStrikethroughFeature=du,exports.RteSuggestFeature=Dd,exports.RteTextBlockPickerFeature=Fl,exports.RteTextColorPickerFeature=vu,exports.RteToolbarButtonFeature=dd,exports.RteToolbarFeature=Rl,exports.RteUnderlineFeature=lu;
39
+ `),slice:t}}function Yr(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new _.v(_.d.from(e.state.schema.text(t.replace(/\r\n?/g,`
40
+ `))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=_.u.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=ci(n),an&&li(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||_.l.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Xr.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=ui(ni(s,+u[1],+u[2]),u[4]);else if(s=_.v.maxOpen(Zr(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=ni(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var Xr=/^(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 Zr(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&$r(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=ei(a[a.length-1],i.length));let n=Qr(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return _.d.from(a)}return e}function Qr(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,_.d.from(e));return e}function $r(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=$r(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(_.d.from(Qr(n,e,i+1))))}}function ei(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,ei(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(_.d.empty,!0);return e.copy(n.append(r))}function ti(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=ti(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(_.d.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function ni(e,t,n){return t<e.openStart&&(e=new _.v(ti(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new _.v(ti(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var ri={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},ii=null;function ai(){return ii||=document.implementation.createHTMLDocument(`title`)}var oi=null;function si(e){let t=window.trustedTypes;return t?(oi||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),oi.createHTML(e)):e}function ci(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=ai().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&ri[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=si(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function li(e){let t=e.querySelectorAll(I?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function ui(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=_.d.from(t.create(r[e+1],i)),a++,o++}return new _.v(i,a,o)}var R={},z={},di={touchstart:!0,touchmove:!0},fi=class{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 pi(e){for(let t in R){let n=R[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{vi(e,t)&&!_i(e,t)&&(e.editable||!(t.type in z))&&n(e,t)},di[t]?{passive:!0}:void 0)}L&&e.dom.addEventListener(`input`,()=>null),gi(e)}function mi(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function hi(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function gi(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>_i(e,t))})}function _i(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function vi(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function yi(e,t){!_i(e,t)&&R[t.type]&&(e.editable||!(t.type in z))&&R[t.type](e,t)}z.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Ni(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(rn&&I&&n.keyCode==13))){if(n.keyCode!=229&&e.domObserver.forceFlush(),en&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,Vt(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||qr(e,n)?n.preventDefault():mi(e,`key`)}},z.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},z.keypress=(e,t)=>{let n=t;if(Ni(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||tn&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof k)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function bi(e){return{left:e.clientX,top:e.clientY}}function xi(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Si(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function Ci(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function wi(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&A.isSelectable(r)?(Ci(e,new A(n),`pointer`),!0):!1}function Ti(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof A&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(A.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i!=null&&(Ci(e,A.create(e.state.doc,i),`pointer`),!0)}function Ei(e,t,n,r,i){return Si(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?Ti(e,n):wi(e,n))}function Di(e,t,n,r){return Si(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Oi(e,t,n,r){return Si(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||ki(e,n,r)}function ki(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(Ci(e,k.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)Ci(e,k.create(r,a+1,a+1+n.content.size),`pointer`);else if(A.isSelectable(n))Ci(e,A.create(r,a),`pointer`);else continue;return!0}}function Ai(e){return Bi(e)}var ji=tn?`metaKey`:`ctrlKey`;R.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Ai(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&xi(n,e.input.lastClick)&&!n[ji]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(bi(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Mi(e,o,n,!!r)):(a==`doubleClick`?Di:Oi)(e,o.pos,o.inside,n)?n.preventDefault():mi(e,`pointer`))};var Mi=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[ji],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof A&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Zt&&!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()),e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this)),mi(e,`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(()=>gr(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(bi(e))),this.updateAllowDefault(e),this.allowDefault||!t?mi(this.view,`pointer`):Ei(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||L&&this.mightDrag&&!this.mightDrag.node.isAtom||I&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ci(this.view,O.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):mi(this.view,`pointer`)}move(e){this.updateAllowDefault(e),mi(this.view,`pointer`),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};R.touchstart=e=>{e.input.lastTouch=Date.now(),Ai(e),mi(e,`pointer`)},R.touchmove=e=>{e.input.lastTouch=Date.now(),mi(e,`pointer`)},R.contextmenu=e=>Ai(e);function Ni(e,t){return e.composing?!0:L&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Pi=rn?5e3:-1;z.compositionstart=z.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof k&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||I&&nn&&Fi(e)))e.markCursor=e.state.storedMarks||n.marks(),Bi(e,!0),e.markCursor=null;else if(Bi(e,!t.selection.empty),Zt&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}Ii(e,Pi)};function Fi(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}z.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Ii(e,20))};function Ii(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Bi(e),t))}function Li(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=zi());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Ri(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=It(t.focusNode,t.focusOffset),r=Lt(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function zi(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function Bi(e,t=!1){if(!(rn&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Li(e),t||e.docView&&e.docView.dirty){let n=mr(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Vi(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var Hi=F&&Xt<15||en&&on<604;R.copy=z.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Hi?null:n.clipboardData,{dom:o,text:s}=Jr(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Vi(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Ui(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Wi(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.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=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Gi(e,r.value,null,i,t):Gi(e,r.textContent,r.innerHTML,i,t)},50)}function Gi(e,t,n,r,i){let a=Yr(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||_.v.empty)))return!0;if(!a)return!1;let o=Ui(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function Ki(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}z.paste=(e,t)=>{let n=t;if(e.composing&&!rn)return;let r=Hi?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Gi(e,Ki(r),r.getData(`text/html`),i,n)?n.preventDefault():Wi(e,n)};var qi=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Ji=tn?`altKey`:`ctrlKey`;function Yi(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[Ji]:!n}R.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(bi(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof A?i.to-1:i.to))){if(r&&r.mightDrag)o=A.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=A.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Jr(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!I||$t>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Hi?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Hi||n.dataTransfer.setData(`text/plain`,c),e.dragging=new qi(l,Yi(e,n),o)},R.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},z.dragover=z.dragenter=(e,t)=>t.preventDefault(),z.drop=(e,t)=>{try{Xi(e,t,e.dragging)}finally{e.dragging=null}};function Xi(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(bi(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=Yr(e,Ki(t.dataTransfer),Hi?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&Yi(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||_.v.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?Ve(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&A.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new A(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(Tr(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}R.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&gr(e)},20))},R.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},R.beforeinput=(e,t)=>{if(I&&rn&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,Vt(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in z)R[e]=z[e];function Zi(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var Qi=class e{constructor(e,t){this.toDOM=e,this.spec=t||na,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new B(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Zi(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},$i=class e{constructor(e,t){this.attrs=e,this.spec=t||na}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new B(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&Zi(this.attrs,t.attrs)&&Zi(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},ea=class e{constructor(e,t){this.attrs=e,this.spec=t||na}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new B(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&Zi(this.attrs,t.attrs)&&Zi(this.spec,t.spec)}destroy(){}},B=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new Qi(n,r))}static inline(t,n,r,i){return new e(t,n,new $i(r,i))}static node(t,n,r,i){return new e(t,n,new ea(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof $i}get widget(){return this.type instanceof Qi}},ta=[],na={},V=class e{constructor(e,t){this.local=e.length?e:ta,this.children=t.length?t:ta}static create(e,t){return t.length?la(t,e,0,na):H}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==H||e.maps.length==0?this:this.mapInner(e,t,0,0,n||na)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?ia(this.children,o||[],t,n,r,i,a):o?new e(o.sort(ua),ta):H}add(t,n){return n.length?this==H?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=sa(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,la(s,e,o+1,na)),a+=3}});let o=aa(a?ca(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(ua):this.local,i||this.children)}remove(e){return e.length==0||this==H?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==H?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):H}forChild(t,n){if(this==H)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof $i){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(ua),ta);return r?new ra([t,r]):t}return r||H}eq(t){if(this==t)return!0;if(!(t instanceof e)||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(e){return da(this.localsInner(e))}localsInner(e){if(this==H)return ta;if(e.inlineContent||!this.local.some($i.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof $i||t.push(this.local[e]);return t}forEachSet(e){e(this)}};V.empty=new V([],[]),V.removeOverlap=da;var H=V.empty,ra=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,na));return e.from(r)}forChild(t,n){if(n.isLeaf)return V.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=H&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||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(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length){if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}}return t?da(n?t:t.sort(ua)):ta}static from(t){switch(t.length){case 0:return H;case 1:return t[0];default:return new e(t.every(e=>e instanceof V)?t:t.reduce((e,t)=>e.concat(t instanceof V?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function ia(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==H?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=la(oa(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new V(t.sort(ua),s)}function aa(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new B(i.from+t,i.to+t,i.type))}return n}function oa(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function sa(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function ca(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function la(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=sa(e,t,o+n);if(s){a=!0;let e=la(s,t,n+o+1,r);e!=H&&i.push(o,o+t.nodeSize,e)}});let o=aa(a?ca(e):e,-n).sort(ua);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new V(o,i):H}function ua(e,t){return e.from-t.from||e.to-t.to}function da(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),fa(t,i+1,a.copy(r.to,a.to)));continue}a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),fa(t,i,r.copy(a.from,r.to)));break}}return t}function fa(e,t,n){for(;t<e.length&&ua(n,e[t])>0;)t++;e.splice(t,0,n)}function pa(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=H&&t.push(r)}),e.cursorWrapper&&t.push(V.create(e.state.doc,[e.cursorWrapper.deco])),ra.from(t)}var ma={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ha=F&&Xt<=11,ga=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},_a=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ga,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);F&&Xt<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():L&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),ha&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.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,ma)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);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(Er(this.view)){if(this.suppressingSelectionUpdates)return gr(this.view);if(F&&Xt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Mt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=Ot(n))t.add(n);for(let r=e.anchorNode;r;r=Ot(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Er(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(Zt&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Ca(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Bt(n)&&(c=mr(e))&&c.eq(O.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,gr(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),ba(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,wa(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||gr(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(F&&Xt<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?P(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?P(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}return e.type==`attributes`?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},va=new WeakMap,ya=!1;function ba(e){if(!va.has(e)&&(va.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=Zt,ya)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.`),ya=!0}}function xa(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return Mt(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Sa(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return xa(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?xa(e,n):null}function Ca(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function wa(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function Ta(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,u=c.anchorNode;if(u&&e.dom.contains(u.nodeType==1?u:u.parentNode)&&(l=[{node:u,offset:c.anchorOffset}],Bt(c)||l.push({node:c.focusNode,offset:c.focusOffset})),I&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||_.l.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace!=`pre`||`full`,findPositions:l,ruleFromNode:Ea,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function Ea(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(L&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}if(e.parentNode.lastChild==e||L&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var Da=/^(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 Oa(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=mr(e,t);if(n&&!e.state.selection.eq(n)){if(I&&rn&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,Vt(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=Ta(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=Na(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(en&&e.input.lastIOSEnter>Date.now()-225||rn)&&i.some(e=>e.nodeType==1&&!Da.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,Vt(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m){if(r&&c instanceof k&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=ka(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof k&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),F&&Xt<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),ee=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((en&&e.input.lastIOSEnter>Date.now()-225&&(!ee||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!ee&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,Vt(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&ja(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,Vt(8,`Backspace`)))){rn&&I&&e.domObserver.suppressSelectionUpdates();return}I&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),rn&&!ee&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,Vt(13,`Enter`))})},20));let v=m.start,te=m.endA,y=t=>{let n=t||e.state.tr.replace(v,te,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=ka(e,n.doc,l.sel);t&&!(I&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==v||t.head==n.mapping.map(te)-1)||F&&t.empty&&t.head==v)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},ne;if(ee){if(h.pos==g.pos){F&&Xt<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>gr(e),20));let t=y(e.state.tr.delete(v,te)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(ne=Aa(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=y(e.state.tr);ne.type==`add`?t.addMark(v,te,ne.mark):t.removeMark(v,te,ne.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>y(e.state.tr.insertText(t,v,te));e.someProp(`handleTextInput`,r=>r(e,v,te,t,n))||e.dispatch(n())}else e.dispatch(y())}else e.dispatch(y())}function ka(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Tr(e,t.resolve(n.anchor),t.resolve(n.head))}function Aa(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(_.d.from(l).eq(e))return{mark:s,type:o}}function ja(e,t,n,r,i){if(n-t<=i.pos-r.pos||Ma(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(Ma(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Ma(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Ma(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Na(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&Pa(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&Pa(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function Pa(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var Fa=class{constructor(e,t){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 fi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ha),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Ra(this),La(this),this.nodeViews=Ba(this),this.docView=Jn(this.state.doc,Ia(this),pa(this),this.dom,this),this.domObserver=new _a(this,(e,t,n,r)=>Oa(this,e,t,n,r)),this.domObserver.start(),pi(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&gi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ha),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Li(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Ba(this);Va(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&gi(this),this.editable=Ra(this),La(this);let o=pa(this),s=Ia(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&dn(this);if(i){this.domObserver.stop();let t=l&&(F||I)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&za(n.selection,e.selection);if(l){let n=I?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Ri(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=Jn(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Or(this))?gr(this,t):(Cr(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&pn(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this))){if(this.state.selection instanceof A){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&un(this,t.getBoundingClientRect(),e)}else un(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new qi(e.slice,e.move,r<0?void 0:A.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(F){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable==`false`)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&gn(this.dom),gr(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return wn(this,e)}coordsAtPos(e,t=1){return On(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Rn(this,t||this.state,e)}pasteHTML(e,t){return Gi(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return Gi(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Jr(this,e)}destroy(){this.docView&&(hi(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],pa(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,jt())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return yi(this,e)}domSelectionRange(){let e=this.domSelection();return e?L&&this.root.nodeType===11&&Ht(this.dom.ownerDocument)==this.dom&&Sa(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Fa.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Ia(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[B.node(0,e.state.doc.content.size,t)]}function La(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:B.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Ra(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function za(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function Ba(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function Va(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function Ha(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var Ua={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:`'`},Wa={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Ga=typeof navigator<`u`&&/Mac/.test(navigator.platform),Ka=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),U=0;U<10;U++)Ua[48+U]=Ua[96+U]=String(U);for(var U=1;U<=24;U++)Ua[U+111]=`F`+U;for(var U=65;U<=90;U++)Ua[U]=String.fromCharCode(U+32),Wa[U]=String.fromCharCode(U);for(var qa in Ua)Wa.hasOwnProperty(qa)||(Wa[qa]=Ua[qa]);function Ja(e){var t=!(Ga&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Ka&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Wa:Ua)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var Ya=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Xa=typeof navigator<`u`&&/Win/.test(navigator.platform);function Za(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))Ya?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function Qa(e){let t=Object.create(null);for(let n in e)t[Za(n)]=e[n];return t}function $a(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function W(e){return new N({props:{handleKeyDown:eo(e)}})}function eo(e){let t=Qa(e);return function(e,n){let r=Ja(n),i,a=t[$a(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[$a(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Xa&&n.ctrlKey&&n.altKey)&&(i=Ua[n.keyCode])&&i!=r){let r=t[$a(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var to=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function no(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var ro=(e,t,n)=>{let r=no(e,n);if(!r)return!1;let i=oo(r);if(!i){let n=r.blockRange(),i=n&&Ee(n);return i!=null&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(xo(e,i,t,-1))return!0;if(r.parent.content.size==0&&(io(a,`end`)||A.isSelectable(a)))for(let n=r.depth;;n--){let o=He(e.doc,r.before(n),r.after(n),_.v.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(io(a,`end`)?O.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):A.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1};function io(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var ao=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=oo(r)}let o=a&&a.nodeBefore;return!o||!A.isSelectable(o)?!1:(t&&t(e.tr.setSelection(A.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function oo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function so(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var co=(e,t,n)=>{let r=so(e,n);if(!r)return!1;let i=uo(r);if(!i)return!1;let a=i.nodeAfter;if(xo(e,i,t,1))return!0;if(r.parent.content.size==0&&(io(a,`start`)||A.isSelectable(a))){let n=He(e.doc,r.before(),r.after(),_.v.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(io(a,`start`)?O.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):A.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},lo=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=uo(r)}let o=a&&a.nodeAfter;return!o||!A.isSelectable(o)?!1:(t&&t(e.tr.setSelection(A.create(e.doc,a.pos)).scrollIntoView()),!0)};function uo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var fo=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
41
+ `).scrollIntoView()),!0)};function po(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var mo=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=po(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(O.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},ho=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof M||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=po(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(k.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},go=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Pe(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Ee(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function _o(e){return(t,n)=>{if(t.selection instanceof A&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!Pe(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof k||t.selection instanceof M)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=po(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=Pe(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,Pe(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var vo=_o(),yo=(e,t)=>(t&&t(e.tr.setSelection(new M(e.doc))),!0);function bo(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||Ie(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function xo(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&bo(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=_.d.empty;for(let e=o.length-1;e>=0;e--)s=_.d.from(o[e].create(null,s));s=_.d.from(i.copy(s));let c=e.tr.step(new T(t.pos-1,r,t.pos,r,new _.v(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&Ie(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:O.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&Ee(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&io(a,`start`,!0)&&io(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=_.d.empty;for(let e=o.length-1;e>=0;e--)r=_.d.from(o[e].copy(r));n(e.tr.step(new T(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new _.v(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function So(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(k.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var Co=So(-1),wo=So(1);function To(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:a,$to:o}=t[i],s=a.depth==0&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(a.pos,o.pos,(e,t)=>{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function Eo(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new ct(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new ct(r,i))}return t}function Do(e,t=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,a=!(n&&n.includeWhitespace);return function(n,o){let{empty:s,$cursor:c,ranges:l}=n.selection;if(s&&!c||!To(n.doc,l,e,i))return!1;if(o){if(c)e.isInSet(n.storedMarks||c.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let s,c=n.tr;i||(l=Eo(l)),s=r?!l.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!l.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,a)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!a&&a.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<l.length;n++){let{$from:r,$to:i}=l[n];if(!s)c.removeMark(r.pos,i.pos,e);else{let n=r.pos,o=i.pos,s=r.nodeAfter,l=i.nodeBefore,u=a&&s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+u<o&&(n+=u,o-=d),c.addMark(n,o,e.create(t))}}o(c.scrollIntoView())}}return!0}}function Oo(e,t){return n=>{if(!n.isGeneric)return e(n);let r=[];for(let e=0;e<n.mapping.maps.length;e++){let t=n.mapping.maps[e];for(let e=0;e<r.length;e++)r[e]=t.map(r[e]);t.forEach((e,t,n,i)=>r.push(n,i))}let i=[];for(let e=0;e<r.length;e+=2){let a=r[e],o=r[e+1],s=n.doc.resolve(a),c=s.sharedDepth(o),l=s.node(c);for(let e=s.indexAfter(c),n=s.after(c+1);n<=o;++e){let r=l.maybeChild(e);if(!r)break;if(e&&i.indexOf(n)==-1){let a=l.child(e-1);a.type==r.type&&t(a,r)&&i.push(n)}n+=r.nodeSize}}i.sort((e,t)=>e-t);for(let e=i.length-1;e>=0;e--)Ie(n.doc,i[e])&&n.join(i[e]);e(n)}}function ko(e,t){let n=Array.isArray(t)?e=>t.indexOf(e.type.name)>-1:t;return(t,r,i)=>e(t,r&&Oo(r,n),i)}function Ao(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var jo=Ao(to,ro,ao),Mo=Ao(to,co,lo),No={Enter:Ao(fo,ho,go,vo),"Mod-Enter":mo,Backspace:jo,"Mod-Backspace":jo,"Shift-Backspace":jo,Delete:Mo,"Mod-Delete":Mo,"Mod-a":yo},Po={"Ctrl-h":No.Backspace,"Alt-Backspace":No[`Mod-Backspace`],"Ctrl-d":No.Delete,"Ctrl-Alt-Backspace":No[`Mod-Delete`],"Alt-Delete":No[`Mod-Delete`],"Alt-d":No[`Mod-Delete`],"Ctrl-a":Co,"Ctrl-e":wo};for(let e in No)Po[e]=No[e];var Fo=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?Po:No,Io=`.ProseMirror{word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0;position:relative}.ProseMirror pre{white-space:pre-wrap}.ProseMirror li{position:relative}.ProseMirror-hideselection ::selection{background:0 0}.ProseMirror-hideselection ::selection{background:0 0}.ProseMirror-hideselection{caret-color:#0000}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";pointer-events:none;border:2px solid #8cf;position:absolute;inset:-2px -2px -2px -32px}img.ProseMirror-separator{border:none!important;margin:0!important;display:inline!important}`;function Lo(e={}){return new N({view(t){return new Ro(t,e)}})}var Ro=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc){if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.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`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=Ve(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},G=class e extends O{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):O.near(r)}content(){return _.v.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new zo(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Vo(e)||!Ho(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!A.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};G.prototype.visible=!1,G.findFrom=G.findGapCursorFrom,O.jsonID(`gapcursor`,G);var zo=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return G.valid(t)?new G(t):O.near(t)}};function Bo(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Vo(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||Bo(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Ho(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||Bo(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Uo(){return new N({props:{decorations:Jo,createSelectionBetween(e,t,n){return t.pos==n.pos&&G.valid(n)?new G(n):null},handleClick:Ko,handleKeyDown:Wo,handleDOMEvents:{beforeinput:qo}}})}var Wo=eo({ArrowLeft:Go(`horiz`,-1),ArrowRight:Go(`horiz`,1),ArrowUp:Go(`vert`,-1),ArrowDown:Go(`vert`,1)});function Go(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof k){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=G.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new G(c))),!0):!1}}function Ko(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!G.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&A.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new G(r))),!0)}function qo(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof G))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=_.d.empty;for(let e=r.length-1;e>=0;e--)i=_.d.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new _.v(i,0,0));return a.setSelection(k.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function Jo(e){if(!(e.selection instanceof G))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,V.create(e.doc,[B.widget(e.selection.head,t,{key:`gapcursor`})])}function Yo(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}}var Xo=`[data-class=ui-select]{min-inline-size:120px;margin-block:-4px}.ui-divider{block-size:20px}.ui-button-group{gap:4px;display:flex}.ui-tooltip,.ui-menu{--_popup-display:contents;display:contents}.ui-tooltip-wrapper{display:contents}`,Zo=class{constructor(e){this.plugin=new N({state:{init:()=>e,apply:(e,t)=>{let n=e.getMeta(this.plugin);return n===void 0?t:n}}})}getValue(e){return this.plugin.getState(e.state)}setValue(e,t){e.dispatchTransaction(e.tr.setMeta(this.plugin,t))}},Qo=`.ProseMirror{box-sizing:border-box;padding:var(--editor-padding-block) var(--editor-padding-inline);outline:none;flex:1 0 0}.ProseMirror-selectednode{--focus-stroke-gap-color:transparent;--focus-border-radius:2px;outline:none;position:relative}.ProseMirror-selectednode:after{box-shadow:0 0 0 4px color-mix(in sRGB, var(--focus-stroke-color,var(--vvd-color-cta-500)), transparent 85%), inset 0 0 0 3px var(--focus-stroke-gap-color,currentColor);outline:1px solid var(--focus-stroke-color,var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset,0px));border-radius:var(--focus-border-radius,inherit);block-size:calc(100% + var(--focus-block-size-addition,4px));content:"";inline-size:calc(100% + var(--focus-block-size-addition,4px));display:block;position:absolute;inset-block-start:50%;inset-inline-start:50%;transform:translate(-50%,-50%)}.editor--disabled .ProseMirror{color:var(--_appearance-color-text,var(--vvd-color-neutral-300));cursor:not-allowed}`,$o=class extends _.r{constructor(...e){super(...e),this.name=`RteForeignHtmlFeature`}getPlugins(e){return[this.contribution(new N({props:{transformPastedHTML:t=>e.foreignHtmlParser[_.c].transform(t),clipboardParser:e.foreignHtmlParser[_.c].parser,clipboardSerializer:e.foreignHtmlSerializer[_.c].serializer}}))]}},es=e=>{if(e.parentOffset!==e.parent.content.size)return null;let t=e.nodeBefore;return t&&t.isInline&&t.isAtom&&!t.isText?{}:null},ts=e=>{let t=e.nodeAfter;return t&&t.isInline&&t.isAtom&&!t.isText?{afterCursor:!0}:null};function ns(e){let t=document.createElement(`span`);t.textContent=`​`;for(let[n,r]of Object.entries(e))t.style.setProperty(n,r);return t}var rs=class extends _.r{constructor(...e){super(...e),this.name=`RteCursorFix`}getPlugins(e){let t=[es,ts];for(let n of Object.values(e.schema.marks)){let e=n.spec;e.cursorFix&&t.push(e.cursorFix)}return[this.contribution(new N({props:{decorations:e=>{let{$cursor:n}=e.selection;if(!n)return null;let r=[],i={},a=!1,o=!1;for(let r of t){let t=r(n,e);t&&(t.style&&Object.assign(i,t.style),t.afterCursor?o=!0:a=!0)}return a&&r.push(B.widget(n.pos,()=>ns(i),{side:-1})),o&&r.push(B.widget(n.pos,()=>ns(i),{side:1})),r.length===0?null:V.create(e.doc,r)}}}))]}};_.a(rs);var is=new N({state:{init(){return null},apply(e,t){return e.getMeta(is)||t}}}),as=class extends _.r{constructor(...e){super(...e),this.name=`RteCore`,this.disabled=new Zo(!1),this.scrollThreshold=void 0,this.scrollMargin=void 0}getStyles(){return[this.contribution(Io),this.contribution(Qo),this.contribution(Xo)]}getPlugins(e){let t=_o((t,n,r)=>{if(!n)return{type:t.type,attrs:t.attrs};let i=Yo(r.node(r.depth-1).contentMatchAt(r.indexAfter(r.depth-1)));return i?{type:i,attrs:e.textblockAttrs.extractFromNode(t)}:null}),n=Ao(fo,ho,go,(e,n)=>t(e,n&&(t=>{let r=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();r&&t.ensureMarks(r),n(t)})));return[this.contribution(this.disabled.plugin),this.contribution(new N({props:{editable:()=>!this.disabled.getValue(e),handleDOMEvents:{click:(t,n)=>this.disabled.getValue(e)?(n.preventDefault(),!0):!1}},view:t=>{let n=t.dom.getRootNode().querySelector(`.popovers`),r=()=>{let r=this.disabled.getValue(e);n.classList.toggle(`popovers--disabled`,r),t.dom.parentElement.classList.toggle(`editor--disabled`,r),e.onDisabledChanged?.(r)};return r(),{update:()=>{r()}}}})),this.contribution(W({...Fo,Enter:n,"Shift-Enter":n})),this.contribution(Lo()),this.contribution(Uo()),this.contribution(is)]}getFeatures(){return[this,new $o,new rs]}};_.a(as);function ss(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function cs(e){if(Array.isArray(e))return e}function ls(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function us(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
42
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ds(e,t){return cs(e)||ls(e,t)||fs(e,t)||us()}function fs(e,t){if(e){if(typeof e==`string`)return ss(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ss(e,t):void 0}}var ps=Object.entries,ms=Object.setPrototypeOf,hs=Object.isFrozen,gs=Object.getPrototypeOf,_s=Object.getOwnPropertyDescriptor,K=Object.freeze,q=Object.seal,vs=Object.create,ys=typeof Reflect<`u`&&Reflect,bs=ys.apply,xs=ys.construct;K||=function(e){return e},q||=function(e){return e},bs||=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return e.apply(t,r)},xs||=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)};var Ss=X(Array.prototype.forEach),Cs=X(Array.prototype.lastIndexOf),ws=X(Array.prototype.pop),Ts=X(Array.prototype.push),Es=X(Array.prototype.splice),Ds=Array.isArray,Os=X(String.prototype.toLowerCase),ks=X(String.prototype.toString),As=X(String.prototype.match),js=X(String.prototype.replace),Ms=X(String.prototype.indexOf),Ns=X(String.prototype.trim),Ps=X(Number.prototype.toString),Fs=X(Boolean.prototype.toString),Is=typeof BigInt>`u`?null:X(BigInt.prototype.toString),Ls=typeof Symbol>`u`?null:X(Symbol.prototype.toString),J=X(Object.prototype.hasOwnProperty),Rs=X(Object.prototype.toString),Y=X(RegExp.prototype.test),zs=Bs(TypeError);function X(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return bs(e,t,r)}}function Bs(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return xs(e,n)}}function Z(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Os;if(ms&&ms(e,null),!Ds(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(hs(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Vs(e){for(let t=0;t<e.length;t++)J(e,t)||(e[t]=null);return e}function Hs(e){let t=vs(null);for(let r of ps(e)){var n=ds(r,2);let i=n[0],a=n[1];J(e,i)&&(t[i]=Ds(a)?Vs(a):a&&typeof a==`object`&&a.constructor===Object?Hs(a):a)}return t}function Us(e){switch(typeof e){case`string`:return e;case`number`:return Ps(e);case`boolean`:return Fs(e);case`bigint`:return Is?Is(e):`0`;case`symbol`:return Ls?Ls(e):`Symbol()`;case`undefined`:return Rs(e);case`function`:case`object`:{if(e===null)return Rs(e);let t=e,n=Ws(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Rs(e)}return Rs(e)}default:return Rs(e)}}function Ws(e,t){for(;e!==null;){let n=_s(e,t);if(n){if(n.get)return X(n.get);if(typeof n.value==`function`)return X(n.value)}e=gs(e)}function n(){return null}return n}function Gs(e){try{return Y(e,``),!0}catch{return!1}}var Ks=K(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),qs=K(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Js=K([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Ys=K([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Xs=K(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),Zs=K([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Qs=K([`#text`]),$s=K(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),ec=K(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),tc=K(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),nc=K([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),rc=q(/{{[\w\W]*|^[\w\W]*}}/g),ic=q(/<%[\w\W]*|^[\w\W]*%>/g),ac=q(/\${[\w\W]*/g),oc=q(/^data-[\-\w.\u00B7-\uFFFF]+$/),sc=q(/^aria-[\-\w]+$/),cc=q(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),lc=q(/^(?:\w+script|data):/i),uc=q(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),dc=q(/^html$/i),fc=q(/^[a-z][.\w]*(-[.\w]+)+$/i),pc=q(/<[/\w!]/g),mc=q(/<[/\w]/g),hc=q(/<\/no(script|embed|frames)/i),gc=q(/\/>/i),_c={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},vc=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],yc=K(Z({},vc)),bc=function(){let e={};return Ss(vc,t=>{e[t]=q(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),K(e)}(),xc=function(){return typeof window>`u`?null:window},Sc=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Cc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},wc=function(e,t,n,r){return J(e,t)&&Ds(e[t])?Z(r.base?Hs(r.base):{},e[t],r.transform):n},Tc=function(e,t,n){let r=J(e,t)?e[t]:void 0;return r&&typeof r==`object`?Hs(r):n()};function Ec(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:xc(),t=e=>Ec(e);if(t.version=`3.4.14`,t.removed=[],!e||!e.document||e.document.nodeType!==_c.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Ws(d,`cloneNode`),p=Ws(d,`remove`),m=Ws(d,`nextSibling`),h=Ws(d,`childNodes`),g=Ws(d,`parentNode`),_=Ws(d,`shadowRoot`),ee=Ws(d,`attributes`),v=o&&o.prototype?Ws(o.prototype,`nodeType`):null,te=o&&o.prototype?Ws(o.prototype,`nodeName`):null,y=o&&o.prototype?Ws(o.prototype,`ownerDocument`):null,ne=function(e){return v?v(e):e.nodeType},re=function(e){return te?te(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let b,x=``,ie,ae=!1,oe=0,se=function(){if(oe>0)throw zs(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},ce=function(e){se(),oe++;try{return b.createHTML(e)}finally{oe--}},le=function(e){se(),oe++;try{return b.createScriptURL(e)}finally{oe--}},ue=function(){return ae||=(ie=Sc(u,i),!0),ie},de=n,fe=de.implementation,pe=de.createNodeIterator,me=de.createDocumentFragment,he=de.getElementsByTagName,ge=r.importNode,S=Cc();t.isSupported=typeof ps==`function`&&typeof g==`function`&&fe&&fe.createHTMLDocument!==void 0;let C=rc,w=ic,_e=ac,ve=oc,ye=sc,be=lc,xe=uc,Se=fc,T=cc,E=null,Ce=Z({},[...Ks,...qs,...Js,...Xs,...Qs]),D=null,we=Z({},[...$s,...ec,...tc,...nc]),Te=Object.seal(vs(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ee=null,De=null,Oe=Object.seal(vs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ke=!0,Ae=!0,je=!1,Me=!0,Ne=!1,Pe=!0,Fe=!1,Ie=!1,Le=null,Re=null,ze=!1,Be=!1,Ve=!1,He=!1,Ue=!0,We=!1,Ge=`user-content-`,Ke=!0,qe=!1,Je={},Ye=null,Xe=Z({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Ze=null,Qe=Z({},[`audio`,`video`,`img`,`source`,`image`,`track`]),$e=null,et=Z({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),tt=`http://www.w3.org/1998/Math/MathML`,nt=`http://www.w3.org/2000/svg`,rt=`http://www.w3.org/1999/xhtml`,it=rt,at=!1,ot=null,st=Z({},[tt,nt,rt],ks),O=K([`mi`,`mo`,`mn`,`ms`,`mtext`]),ct=Z({},O),lt=K([`annotation-xml`]),ut=Z({},lt),k=Z({},[`title`,`style`,`font`,`a`,`script`]),dt=null,A=[`application/xhtml+xml`,`text/html`],j=null,M=null,ft=n.createElement(`form`),pt=function(e){return e instanceof RegExp||e instanceof Function},mt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(M&&M===e)return;(!e||typeof e!=`object`)&&(e={}),e=Hs(e),dt=A.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,j=dt===`application/xhtml+xml`?ks:Os,E=wc(e,`ALLOWED_TAGS`,Ce,{transform:j}),D=wc(e,`ALLOWED_ATTR`,we,{transform:j}),ot=wc(e,`ALLOWED_NAMESPACES`,st,{transform:ks}),$e=wc(e,`ADD_URI_SAFE_ATTR`,et,{transform:j,base:et}),Ze=wc(e,`ADD_DATA_URI_TAGS`,Qe,{transform:j,base:Qe}),Ye=wc(e,`FORBID_CONTENTS`,Xe,{transform:j}),Ee=wc(e,`FORBID_TAGS`,Hs({}),{transform:j}),De=wc(e,`FORBID_ATTR`,Hs({}),{transform:j}),Je=J(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Hs(e.USE_PROFILES):e.USE_PROFILES:!1,ke=e.ALLOW_ARIA_ATTR!==!1,Ae=e.ALLOW_DATA_ATTR!==!1,je=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Me=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ne=e.SAFE_FOR_TEMPLATES||!1,Pe=e.SAFE_FOR_XML!==!1,Fe=e.WHOLE_DOCUMENT||!1,Be=e.RETURN_DOM||!1,Ve=e.RETURN_DOM_FRAGMENT||!1,He=e.RETURN_TRUSTED_TYPE||!1,ze=e.FORCE_BODY||!1,Ue=e.SANITIZE_DOM!==!1,We=e.SANITIZE_NAMED_PROPS||!1,Ke=e.KEEP_CONTENT!==!1,qe=e.IN_PLACE||!1,T=Gs(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:cc,it=typeof e.NAMESPACE==`string`?e.NAMESPACE:rt,ct=Tc(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>Z({},O)),ut=Tc(e,`HTML_INTEGRATION_POINTS`,()=>Z({},lt));let t=Tc(e,`CUSTOM_ELEMENT_HANDLING`,()=>vs(null));if(Te=vs(null),J(t,`tagNameCheck`)&&pt(t.tagNameCheck)&&(Te.tagNameCheck=t.tagNameCheck),J(t,`attributeNameCheck`)&&pt(t.attributeNameCheck)&&(Te.attributeNameCheck=t.attributeNameCheck),J(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(Te.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),q(Te),Ne&&(Ae=!1),Ve&&(Be=!0),Je&&(E=Z({},Qs),D=vs(null),Je.html===!0&&(Z(E,Ks),Z(D,$s)),Je.svg===!0&&(Z(E,qs),Z(D,ec),Z(D,nc)),Je.svgFilters===!0&&(Z(E,Js),Z(D,ec),Z(D,nc)),Je.mathMl===!0&&(Z(E,Xs),Z(D,tc),Z(D,nc))),Oe.tagCheck=null,Oe.attributeCheck=null,J(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?Oe.tagCheck=e.ADD_TAGS:Ds(e.ADD_TAGS)&&(E===Ce&&(E=Hs(E)),Z(E,e.ADD_TAGS,j))),J(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?Oe.attributeCheck=e.ADD_ATTR:Ds(e.ADD_ATTR)&&(D===we&&(D=Hs(D)),Z(D,e.ADD_ATTR,j))),J(e,`ADD_FORBID_CONTENTS`)&&Ds(e.ADD_FORBID_CONTENTS)&&(Ye===Xe&&(Ye=Hs(Ye)),Z(Ye,e.ADD_FORBID_CONTENTS,j)),Ke&&(E[`#text`]=!0),Fe&&Z(E,[`html`,`head`,`body`]),E.table&&(Z(E,[`tbody`]),delete Ee.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw zs(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw zs(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=b;b=e.TRUSTED_TYPES_POLICY;try{x=ce(``)}catch(e){throw b=t,e}}else e.TRUSTED_TYPES_POLICY===null?(b=void 0,x=``):(b===void 0&&(b=ue()),b&&typeof x==`string`&&(x=ce(``)));K&&K(e),M=e},ht=Z({},[...qs,...Js,...Ys]),gt=Z({},[...Xs,...Zs]),_t=function(e,t,n){return t.namespaceURI===rt?e===`svg`:t.namespaceURI===tt?e===`svg`&&(n===`annotation-xml`||ct[n]):!!ht[e]},vt=function(e,t,n){return t.namespaceURI===rt?e===`math`:t.namespaceURI===nt?e===`math`&&ut[n]:!!gt[e]},yt=function(e,t,n){return t.namespaceURI===nt&&!ut[n]||t.namespaceURI===tt&&!ct[n]?!1:!gt[e]&&(k[e]||!ht[e])},bt=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:it,tagName:`template`});let n=Os(e.tagName),r=Os(t.tagName);return ot[e.namespaceURI]?e.namespaceURI===nt?_t(n,t,r):e.namespaceURI===tt?vt(n,t,r):e.namespaceURI===rt?yt(n,t,r):!!(dt===`application/xhtml+xml`&&ot[e.namespaceURI]):!1},xt=function(e){Ts(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw zs(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},St=function(e,t,n){try{e.removeAttributeNode(t)}catch{try{e.removeAttribute(n)}catch{}}},Ct=function(e){Tt(e);let t=h(e);if(t){let e=[];Ss(t,t=>{Ts(e,t)}),Ss(e,e=>{try{p(e)}catch{}})}let n=ee(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&St(e,r,i)}},wt=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}Ts(t.removed,{attribute:r||null,from:n});try{r?n.removeAttributeNode(r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Be||Ve)try{xt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},N=function(e){let t=ee(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||D[j(i)]||St(e,r,i)}},Tt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();ne(e)===_c.element&&N(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},Et=function(e,t){return Pe?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Dt=function(e){if(!Pe)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=ne(e);if(n===_c.processingInstruction||n===_c.comment&&Y(mc,e.data)){try{p(e)}catch{}continue}if(n===_c.element){let t=e,n=j(re(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Et(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=h(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},P=function(e){let t=null,r=null;if(ze)e=`<remove></remove>`+e;else{let t=As(e,/^[\r\n\t ]+/);r=t&&t[0]}dt===`application/xhtml+xml`&&it===rt&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=b?ce(e):e;if(it===rt)try{t=new l().parseFromString(i,dt)}catch{}if(!t||!t.documentElement){t=fe.createDocument(it,`template`,null);try{t.documentElement.innerHTML=at?x:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),it===rt?he.call(t,Fe?`html`:`body`)[0]:Fe?t.documentElement:a},Ot=function(e){let t=y?y(e):e.ownerDocument;return pe.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},kt=function(e){return e=js(e,C,` `),e=js(e,w,` `),e=js(e,_e,` `),e},At=function(e){e.normalize();let t=y?y(e):e.ownerDocument,n=pe.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=kt(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&Ss(i,e=>{Mt(e.content)&&At(e.content)})},jt=function(e){let t=te?te(e):null;return typeof t!=`string`||j(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==ee(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==v(e)||e.childNodes!==h(e)},Mt=function(e){if(!v||typeof e!=`object`||!e)return!1;try{return v(e)===_c.documentFragment}catch{return!1}},Nt=function(e){if(!v||typeof e!=`object`||!e)return!1;try{return typeof v(e)==`number`}catch{return!1}};function Pt(e,n,r){e.length!==0&&Ss(e,e=>{e.call(t,n,r,M)})}let Ft=function(e,t){return!!(Pe&&e.hasChildNodes()&&!Nt(e.firstElementChild)&&Y(pc,e.textContent)&&Y(pc,e.innerHTML)||Pe&&e.namespaceURI===rt&&yc[t]&&(Nt(e.firstElementChild)||typeof e.textContent==`string`&&Y(bc[t],e.textContent))||e.nodeType===_c.processingInstruction||Pe&&e.nodeType===_c.comment&&Y(mc,e.data))},It=function(e,t){if(e instanceof RegExp)return Y(e,t);if(e instanceof Function){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return!!e(t,...r)}return!1},Lt=function(e,t,n){if(!Ee[t]&&Ut(t)&&It(Te.tagNameCheck,t))return!1;if(Ke&&!Ye[t]){let t=g(e),r=h(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,m(e))}}}return xt(e),!0},Rt=function(e,t,n,r){return e.length===0?t:t===n||t===r?Hs(t):t},zt=function(e,t){return e===t||g(e)!==null?!1:(qe&&Tt(e),!0)},Bt=function(e,n){if(Pt(S.beforeSanitizeElements,e,null),zt(e,n))return!0;if(jt(e))return xt(e),!0;let r=j(re(e));if(E=Rt(S.uponSanitizeElement,E,Ce,Le),Pt(S.uponSanitizeElement,e,{tagName:r,allowedTags:E}),zt(e,n))return!0;if(Ft(e,r))return xt(e),!0;if(Ee[r]||!(Oe.tagCheck instanceof Function&&Oe.tagCheck(r))&&!E[r]){let t=Lt(e,r,n);return t===!1&&Pt(S.afterSanitizeElements,e,null),t}if(ne(e)===_c.element&&!bt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Y(hc,e.innerHTML))return xt(e),!0;if(Ne&&e.nodeType===_c.text){let n=kt(e.textContent);e.textContent!==n&&(Ts(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Pt(S.afterSanitizeElements,e,null),!1},Vt=function(e,t,r){if(De[t]||Et(t,e)||Ue&&(t===`id`||t===`name`)&&(r in n||r in ft))return!1;let i=D[t]||Oe.attributeCheck instanceof Function&&Oe.attributeCheck(t,e);return Ae&&Y(ve,t)||ke&&Y(ye,t)?!0:i?$e[t]||Y(T,js(r,xe,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Ms(r,`data:`)===0&&Ze[e]||je&&!Y(be,js(r,xe,``))?!0:!r:Ut(e)&&It(Te.tagNameCheck,e)&&It(Te.attributeNameCheck,t,e)||t===`is`&&Te.allowCustomizedBuiltInElements&&It(Te.tagNameCheck,r)},Ht=Z({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Ut=function(e){return!Ht[Os(e)]&&Y(Se,e)},Wt=function(e,t,n,r){if(b&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ce(r);case`TrustedScriptURL`:return le(r)}return r},Gt=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),jt(e)?xt(e):ws(t.removed)}catch{wt(n,e)}},Kt=function(e){Pt(S.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||jt(e))return;D=Rt(S.uponSanitizeAttribute,D,we,Re);let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:D,forceKeepAttr:void 0},r=t.length,i=j(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=j(o),u=c,d=o===`value`?u:Ns(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,Pt(S.uponSanitizeAttribute,e,n),d=n.attrValue,We&&(l===`id`||l===`name`)&&Ms(d,Ge)!==0&&(wt(o,e,a),d=Ge+d),Pe&&Y(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){wt(o,e,a);continue}if(l===`attributename`&&As(d,`href`)){wt(o,e,a);continue}if(!n.forceKeepAttr){if(!n.keepAttr){wt(o,e,a);continue}if(!Me&&Y(gc,d)){wt(o,e,a);continue}if(Ne&&(d=kt(d)),!Vt(i,l,d)){wt(o,e,a);continue}d=Wt(i,l,s,d),d!==u&&Gt(e,o,s,d)}}Pt(S.afterSanitizeAttributes,e,null)},qt=function(e){let t=null,n=Ot(e);for(Pt(S.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Pt(S.uponSanitizeShadowNode,t,null),Bt(t,e),Kt(t),Mt(t.content)&&qt(t.content),ne(t)===_c.element){let e=_(t);Mt(e)&&(Jt(e),qt(e))}Pt(S.afterSanitizeShadowDOM,e,null)},Jt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){qt(e.shadow);continue}let n=e.node,r=ne(n)===_c.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=te?te(n):null;if(typeof e==`string`&&j(e)===`template`){let e=n.content;Mt(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);Mt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(at=!e,at&&(e=`<!-->`),typeof e!=`string`&&!Nt(e)&&(e=Us(e),typeof e!=`string`))throw zs(`dirty is not a string, aborting`);if(!t.isSupported)return e;Ie?(E=Le,D=Re):mt(n),(S.uponSanitizeElement.length>0||S.uponSanitizeAttribute.length>0)&&(E=Hs(E)),S.uponSanitizeAttribute.length>0&&(D=Hs(D)),t.removed=[];let c=qe&&typeof e!=`string`&&Nt(e);if(c){Dt(e);let t=re(e);if(typeof t==`string`){let n=j(t);if(!E[n]||Ee[n])throw Ct(e),zs(`root node is forbidden and cannot be sanitized in-place`)}if(jt(e))throw Ct(e),zs(`root node is clobbered and cannot be sanitized in-place`);try{Jt(e)}catch(t){throw Ct(e),t}}else if(Nt(e))i=P(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===_c.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Jt(a);else{if(!Be&&!Ne&&!Fe&&e.indexOf(`<`)===-1)return b&&He?ce(e):e;if(i=P(e),!i)return Be?null:He?x:``}i&&ze&&xt(i.firstChild);let l=c?e:i;try{let e=Ot(l);for(;o=e.nextNode();)Bt(o,l),Kt(o),Mt(o.content)&&qt(o.content)}catch(n){throw c&&(Ct(e),Ss(t.removed,e=>{e.element&&Tt(e.element)})),n}if(c)return Ss(t.removed,e=>{e.element&&Tt(e.element)}),Ne&&At(e),e;if(Be){if(Ne&&At(i),Ve)for(s=me.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(D.shadowroot||D.shadowrootmode)&&(s=ge.call(r,s,!0)),s}let u=Fe?i.outerHTML:i.innerHTML;return Fe&&E[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Y(dc,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
43
+ `+u),Ne&&(u=kt(u)),b&&He?ce(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};mt(e),Ie=!0,Le=E,Re=D},t.clearConfig=function(){M=null,Ie=!1,Le=null,Re=null,b=ie,x=``},t.isValidAttribute=function(e,t,n){M||mt({});let r=j(e),i=j(t);return Vt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&J(S,e)&&Ts(S[e],t)},t.removeHook=function(e,t){if(J(S,e)){if(t!==void 0){let n=Cs(S[e],t);return n===-1?void 0:Es(S[e],n,1)[0]}return ws(S[e])}},t.removeHooks=function(e){J(S,e)&&(S[e]=[])},t.removeAllHooks=function(){S=Cc()},t}var Dc=Ec(),Oc=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,kc=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|blob):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,Ac=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,jc={ALLOWED_URI_REGEXP:kc},Mc=e=>{if(!Oc.test(e.replace(Ac,``)))return``;let t=document.createElement(`a`);return t.setAttribute(`href`,e),Dc.sanitize(t,{RETURN_DOM:!0,...jc}).querySelector(`a`).getAttribute(`href`)??``},Nc=e=>{let t=document.createElement(`img`);return t.setAttribute(`src`,e),Dc.sanitize(t,{RETURN_DOM:!0,...jc}).querySelector(`img`).getAttribute(`src`)??``},Pc=e=>e.replace(/[;!].*/,``),Fc=e=>({...e}),Ic=e=>({nodes:Object.fromEntries(Object.keys(e.nodes).map(t=>[t,(e.nodes[t].spec.parseDOM??[]).map(Fc)])),marks:Object.fromEntries(Object.keys(e.marks).map(t=>[t,(e.marks[t].spec.parseDOM??[]).map(Fc)]))}),Lc=class{constructor(e,t){this[_.c]=new Rc(e[_.c],t)}parseDocument(e,t){return this[_.c].parser.parse(this.parseHtml(e,t),{preserveWhitespace:!0}).toJSON()}parseFragment(e,t){return this[_.c].parser.parseSlice(this.parseHtml(e,t),{preserveWhitespace:!0}).content.toJSON()??[]}parseHtml(e,t){let n=Dc.sanitize(e,{RETURN_DOM:!0,...jc}),r=document.createDocumentFragment();return r.appendChild(n),t?.modifyDom?.(r),r}},Rc=class{constructor(e,t){let n=Ic(e.schema);t?.modifyParseRules?.(n),this.parser=zc(e.schema,n)}transform(e){return Dc.sanitize(e)}},zc=(e,{marks:t,nodes:n})=>{let r=[],i=e=>e.priority??50;function a(e){let t=0;for(;t<r.length;t++){let n=r[t];if(i(n)<i(e))break}r.splice(t,0,e)}for(let e in t)t[e]?.forEach(t=>{a(t=Fc(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)});for(let e in n)n[e]?.forEach(t=>{a(t=Fc(t)),t.node||t.ignore||t.mark||(t.node=e)});return r.push({tag:`br`,closeParent:!0}),new _.l(e,r)},Bc=class{constructor(e,t){this[_.c]=new Vc(e[_.c],t)}serializeDocument(e,t){return this[_.c].serializeFragment(e.content,t)}serializeFragment(e,t){return this[_.c].serializeFragment(e,t)}},Vc=class e{constructor(t,n){this.config=t;let r=e.domSerializersFromSchema(t.schema);Object.assign(r.nodes,n?.serializers?.nodes??{}),Object.assign(r.marks,n?.serializers?.marks??{}),this.serializer=new _.u(r.nodes,r.marks)}static domSerializersFromSchema(e){let t={nodes:{},marks:{}};for(let n in e.marks){let r=e.marks[n].spec.toDOM;r&&(t.marks[n]=r)}for(let n in e.nodes){let r=e.nodes[n].spec.serializeToDOM??e.nodes[n].spec.toDOM;r&&(t.nodes[n]=r)}return t.nodes.text=e=>document.createTextNode(e.text),t}serializeFragment(e,t){let n=_.d.fromJSON(this.config.schema,e),r=this.serializer.serializeFragment(n),i=document.createDocumentFragment();i.appendChild(r),t?.modifyDom?.(i);let a=document.createElement(`div`);return a.appendChild(i),a.innerHTML}},Hc=(e,t)=>{let n=e.topNodeType.createAndFill(null,t?_.d.fromJSON(e,t.content):null);if(!n)throw Error(`Document could not be parsed`);return n.check(),n},Uc=class{constructor(e,t){this.options=t,this.feature=(e,t)=>this[_.c].getPublicInterface(e,t),this[_.c]=new Wc(this,e,t)}getDocument(){return this[_.c].state.doc.toJSON()}reset(e){this[_.c].reset(e)}replaceSelection(e,t){let{state:n,tr:r,schema:i,dispatchTransaction:a}=this[_.c];r.replaceSelection(new _.v(_.d.fromJSON(i,e),0,0)),r.doc.check();let o=r.doc.resolve(r.mapping.map(n.selection.from)),s=r.doc.resolve(r.selection.to),[c,l]=t?.cursorPlacement===`start`?[o,s]:[s,o];t?.selectContent?r.setSelection(n.selection instanceof M?new M(r.doc):k.between(l,c)):r.setSelection(k.between(c,c)),a(r)}replaceDocument(e,t){let{state:n,tr:r,schema:i,dispatchTransaction:a}=this[_.c];r.replaceWith(0,n.doc.content.size,Hc(i,e)),t?.selectContent?r.setSelection(new M(r.doc)):t?.cursorPlacement===`end`?r.setSelection(k.atEnd(r.doc)):r.setSelection(k.atStart(r.doc)),a(r)}scrollIntoView(){let e=this[_.c];e.view&&e.dispatchTransaction(e.tr.scrollIntoView())}},Wc=class{getFeature(e){let t=this.config.featureMap.get(e);if(!t)throw Error(`Feature not found: ${e}`);return t}getPublicInterface(e,t){let n=this.config.featureFacadesMap.get(e);if(!n||n.length===0)throw Error(`Feature not found`);if(n[0].featureId!==void 0){if(t===void 0)throw Error(`No featureId provided for multi-instance feature.`);let e=n.find(e=>e.featureId===t);if(!e)throw Error(`Feature with id "${t}" not found`);return e.getPublicInterface(this)}if(t!==void 0)throw Error(`Feature does not support featureId`);return n[0].getPublicInterface(this)}constructor(e,n,r){this.options=r,this.view=null,this.onDisabledChanged=null,this.dispatchTransaction=e=>{let t=this.state;return this.state=this.state.apply(e),this.view?.updateState(this.state),t.doc!==this.state.doc&&this.options?.onChange?.(),this.state},this.facade=e;let i=n[_.c];this.config=i,this.schema=i.schema,this.textblockAttrs=i.textblockAttrs,this.features=i.features,this.foreignHtmlParser=r?.foreignHtmlParser??new Lc(n),this.foreignHtmlSerializer=r?.foreignHtmlSerializer??new Bc(n),this.styles=new t.w(_.s(i.features.flatMap(e=>e.getStyles()))),this.initState(r?.initialDocument)}initState(e){this.state=Ct.create({doc:Hc(this.schema,e),schema:this.config.schema,plugins:_.s(this.config.features.flatMap(e=>e.getPlugins(this)))})}reset(e){let t=is.getState(this.state);this.initState(e),this.updateHostState(t),this.view?.updateState(this.state)}createView(e){let t=this.config.featureMap.get(`RteCore`);this.view=new Fa({mount:e},{state:this.state,dispatchTransaction:this.dispatchTransaction,...t?.scrollThreshold!==void 0&&{scrollThreshold:t.scrollThreshold},...t?.scrollMargin!==void 0&&{scrollMargin:t.scrollMargin}})}destroyViewIfNeeded(){this.view&&=(this.view.destroy(),null)}createComponent(e){return document.createElement(this.hostState().ctx.tagFor(e,!0))}getLocale(){return this.hostState().locale}get tr(){return this.state.tr}hostState(){let e=is.getState(this.state);if(!e)throw Error(`No host state available`);return e}updateHostState(e){this.dispatchTransaction(this.tr.setMeta(is,e))}},Gc=class{constructor(e){this.specs=e,this.attrs={};for(let t of e)this.attrs[t.name]={default:t.default}}fromDOM(e){return Object.assign({},...this.specs.map(t=>({[t.name]:t.fromDOM(e)})))}getStyle(e){return this.specs.flatMap(t=>t.toStyles(e)).join(`; `)}getDOMAttrsProperties(e){return this.specs.length?{style:this.getStyle(e)}:{}}getDOMAttrs(e){return this.specs.length?[this.getDOMAttrsProperties(e)]:[]}extractFromNode(e){return Object.assign({},...Object.keys(this.attrs).map(t=>({[t]:e.attrs[t]})))}},Kc=class{constructor(e){this.specs=e}getAllowedMarksForNode(e){return this.specs.filter(t=>!t.onNodeName||t.onNodeName===e).map(e=>e.markName)}getReferencedNodeNames(){return new Set(this.specs.map(e=>e.onNodeName).filter(Boolean))}},qc=(e,t)=>{let n=t.config[_.c].schema,r=e=>n.marks[e.type].rank,i=(e,t)=>{if(e.type!==t.type)return!1;let n=e.attrs,r=t.attrs;if(n===r)return!0;if(!n||!r)return!1;let i=Object.keys(n),a=Object.keys(r);if(i.length!==a.length)return!1;for(let e of i)if(n[e]!==r[e])return!1;return!0},a=e=>{let n=[],o=[],s=[n];for(let n of e){let e=[...n.marks??[]].sort((e,t)=>r(e)-r(t)),c=0,l=0;for(;c<o.length&&l<e.length&&i(o[c],e[l]);)c++,l++;for(;o.length>c;)o.pop(),s.pop();for(;l<e.length;){let n=e[l],r=[];s[s.length-1].push({type:`mark`,mark:n,children:{type:`fragment`,content:r,[_.c]:t},[_.c]:t}),o.push(n),s.push(r),l++}s[s.length-1].push({type:`node`,node:n,children:a(n.content??[]),[_.c]:t})}return{type:`fragment`,content:n,[_.c]:t}};return{type:`node`,node:e,children:a(e.content),[_.c]:t}},Jc=class{constructor(e){this[_.c]=new Yc(e)}instantiateEditor(e){return new Uc(this,e)}instantiateView(e,t){return qc(e,{config:this,options:{...t}})}},Yc=class{constructor(e){let t=e=>e.flatMap(e=>e.getFeatures().flatMap(n=>n===e?e:t([n])));this.features=t(e.map(_.o)),this.featureMap=new Map;for(let e of this.features){if(this.featureMap.has(e.name))throw Error(`Duplicate feature: ${e.name}`);this.featureMap.set(e.name,e)}this.featureFacadesMap=new Map;for(let t of e){let e=t.constructor,n=_.o(t),r=this.featureFacadesMap.get(e);r?r.push(n):this.featureFacadesMap.set(e,[n])}if(!this.featureMap.has(`RteBase`))throw Error(`RteBase feature is required`);if(this.featureMap.has(`RteLinkFeature`)&&!this.featureMap.has(`RteToolbarFeature`))throw Error(`RteToolbarFeature is required for RteLinkFeature`);this.textblockAttrs=new Gc(_.s(this.features.flatMap(e=>e.getTextblockAttrs()))),this.textblockMarks=new Kc(_.s(this.features.flatMap(e=>e.getTextblockMarks())));let n=_.s(this.features.flatMap(e=>e.getSchema(this.textblockAttrs,this.textblockMarks))),r={nodes:{},marks:{}};for(let e of n)Object.assign(r.nodes,e.nodes??{}),Object.assign(r.marks,e.marks??{});for(let e of this.textblockMarks.getReferencedNodeNames())if(!(e in r.nodes))throw Error(`Unknown node "${e}"`);this.schema=new _._(r)}},Xc=200,Q=function(){};Q.prototype.append=function(e){return e.length?(e=Q.from(e),!this.length&&e||e.length<Xc&&this.leafAppend(e)||this.length<Xc&&e.leafPrepend(this)||this.appendInner(e)):this},Q.prototype.prepend=function(e){return e.length?Q.from(e).append(this):this},Q.prototype.appendInner=function(e){return new Qc(this,e)},Q.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?Q.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Q.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Q.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Q.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},Q.from=function(e){return e instanceof Q?e:e&&e.length?new Zc(e):Q.empty};var Zc=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Xc)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Xc)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Q);Q.empty=new Zc([]);var Qc=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Q),$c=500,el=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new nl(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new nl(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new nl(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>il&&(s=tl(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new ge;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new nl(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new nl(i,o,l))}else r.push(new nl(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new nl(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>$c&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new nl(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(Q.from(i.reverse()),a)}};el.empty=new el(Q.empty,0);function tl(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var nl=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},rl=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},il=20;function al(e,t,n,r){let i=n.getMeta(ml),a;if(i)return i.historyState;n.getMeta(hl)&&(e=new rl(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(ml))return o.getMeta(ml).redo?new rl(e.done.addTransform(n,void 0,r,fl(t)),e.undone,sl(n.mapping.maps),e.prevTime,e.prevComposition):new rl(e.done,e.undone.addTransform(n,void 0,r,fl(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!ol(n,e.prevRanges)),s=o?cl(e.prevRanges,n.mapping):sl(n.mapping.maps);return new rl(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,fl(t)),el.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new rl(e.done.rebased(n,a),e.undone.rebased(n,a),cl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new rl(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),cl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function ol(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function sl(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function cl(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function ll(e,t,n){let r=fl(t),i=ml.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new rl(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(ml,{redo:n,historyState:c})}var ul=!1,dl=null;function fl(e){let t=e.plugins;if(dl!=t){ul=!1,dl=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){ul=!0;break}}return ul}function pl(e){return e.setMeta(hl,!0)}var ml=new Dt(`history`),hl=new Dt(`closeHistory`);function gl(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new N({key:ml,state:{init(){return new rl(el.empty,el.empty,null,0,-1)},apply(t,n,r){return al(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?vl:n==`historyRedo`?yl:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function _l(e,t){return(n,r)=>{let i=ml.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=ll(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var vl=_l(!1,!0),yl=_l(!0,!0),bl=e=>typeof e==`function`,xl=(e,t,n)=>[e,t,n],Sl=class{constructor(e,t,n){this.view=e,this.rte=t,this.props=n,this.bindings=[]}evalProp(e){return bl(e)?e(this):e}bindProp(e,t){if(e!==void 0){if(bl(e)){let n=()=>t(e(this));this.bindings.push(n),n()}else t(e)}}updateBindings(){for(let e of this.bindings)e()}shouldReturnFocusToEditor(){return this.evalProp(this.props.shouldReturnFocusToEditor)}bindToEl(e,t={},n=[],r=[]){for(let n in t)this.bindProp(t[n],t=>{e[n]=t});for(let[t,r,i]of n)r&&e.addEventListener(t,i(r));for(let t of r)e.appendChild(t)}},Cl=(e,t)=>{let n=document.createElement(`div`);return e.bindToEl(n,{className:t.className,slot:t.slot},[],t.children),n},wl=(e,t)=>{let n=document.createElement(`a`);return e.bindToEl(n,{href:t.href,target:t.target,rel:t.rel,className:t.className},[],t.children),n},Tl=new WeakMap,El=(e,t)=>{let n=e.rte.createComponent(l.r);n.setAttribute(`exportparts`,`vvd-theme-alternate`),e.bindToEl(n,{className:`ui-tooltip`,text:t.label,placement:e.props.popupPlacement}),e.bindProp(t.enabled,e=>{e||(n.open=!1),n.anchor=e?t.anchor:void 0});let r=Cl(e,{className:`ui-tooltip-wrapper`,slot:t.slot,children:[t.anchor,n]});return Tl.set(r,t.anchor),r},$=(e,t)=>{let n=()=>e.evalProp(t.variant)??`toolbar`,r=()=>n()===`toolbar`?`super-condensed`:`condensed`,i=()=>n()===`popover-primary`?`outlined`:`ghost-light`,a=()=>n()===`toolbar-menu`||n()===`popover`?`filled`:i(),o=()=>e.evalProp(t.active)?a():i(),c=()=>e.evalProp(t.connotation)??(n()===`toolbar-menu`&&e.evalProp(t.active)?`cta`:void 0),l=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),u=!!(t.icon??t.dynamicIcon),d=()=>{let n=e.evalProp(t.dynamicIcon);return n===void 0?e.evalProp(t.icon):`${n}-${e.evalProp(t.active)?`solid`:`line`}`},f=e.rte.createComponent(s.i);return e.bindToEl(f,{size:r,appearance:o,disabled:l,icon:d,autofocus:t.autofocus,connotation:c,[u?`ariaLabel`:`label`]:t.label,pressed:()=>!!e.evalProp(t.active),ariaPressed:t.active===void 0?void 0:()=>e.evalProp(t.active)?`true`:`false`},[xl(`click`,t.onClick,t=>()=>{!t()&&e.shouldReturnFocusToEditor()&&e.view.focus()})]),El(e,{enabled:()=>u&&!e.evalProp(t.noTooltip)&&!l(),label:t.label,anchor:f,slot:t.slot})},Dl=(e,t)=>{let n=e.rte.createComponent(v.r);e.bindToEl(n,{className:`ui-menu`,autoDismiss:!0,ariaLabel:t.label,anchor:Tl.get(t.trigger)??t.trigger,placement:e.props.popupPlacement,offset:()=>e.evalProp(e.props.menuOffset)??null},[],t.children);let r=document.createDocumentFragment();return r.appendChild(t.trigger),r.appendChild(n),r},Ol=(e,t)=>{let n=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),r=e.rte.createComponent(ee.i);return e.bindToEl(r,{text:t.text,checked:t.checked,disabled:n,controlType:`radio`,checkedAppearance:`tick-only`},[xl(`change`,t.onSelect,n=>()=>{r.checked&&!r.disabled&&e.evalProp(t.checked)!==r.checked&&(n(),e.shouldReturnFocusToEditor()&&e.view.focus())})]),r},kl=(e,t)=>Cl(e,{slot:t.slot,className:`ui-button-group`,children:t.children});function Al(e,t){let{from:n,$from:r,to:i,empty:a}=e.selection;return a?!!t.isInSet(e.storedMarks||r.marks()):e.doc.rangeHasMark(n,i,t)}var jl=(e,t)=>$(e,{label:t.label,dynamicIcon:t.dynamicIcon,active:()=>Al(e.view.state,t.markType),disabled:()=>!Do(t.markType)(e.view.state),onClick:()=>{Do(t.markType)(e.view.state,e.view.dispatch)}}),Ml=(e,t)=>{let n=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),r=e.rte.createComponent(f.t);return e.bindToEl(r,{value:t.value,text:t.text,disabled:n}),r},Nl=(e,t)=>{let n=()=>!!e.evalProp(e.props.disabled),r=e.rte.createComponent(m.r);r.setAttribute(`data-class`,`ui-select`),e.bindToEl(r,{placeholder:` `,ariaLabel:t.label,appearance:`ghost`,disabled:n},[xl(`change`,t.onSelect,t=>()=>{let n=r.value;n&&(t(n),e.shouldReturnFocusToEditor()&&e.view.focus())})],t.children),queueMicrotask(()=>{e.bindProp(t.value,e=>r.value=e)});let i=!1;return r.addEventListener(`vwc-popup:open`,()=>{i=!0,e.updateBindings()}),r.addEventListener(`vwc-popup:close`,()=>{i=!1,e.updateBindings()}),El(e,{enabled:()=>!i&&!n(),label:t.label,anchor:r})},Pl=e=>{let t=e.rte.createComponent(g.t);return e.bindToEl(t,{className:`ui-divider`,orientation:`vertical`}),t},Fl=(e,t)=>{let n=e.rte.createComponent(d.r);return e.bindToEl(n,{label:t.label,value:t.value,placeholder:t.placeholder,slot:t.slot,autofocus:t.autofocus,type:t.type,helperText:t.helperText},[xl(`input`,t.onInput,e=>()=>{e(n.value)})]),n},Il=(e,t)=>{let n=document.createTextNode(``);return e.bindToEl(n,{textContent:t.text}),n},Ll=(e,t)=>{let n=document.createElement(`slot`);n.name=t.name;let r=null,i=[];function a(){for(let{el:e,type:t,handler:n}of i)e.removeEventListener(t,n);i.length=0,r=null}for(let[n,i]of Object.entries(t.assignedProps))e.bindProp(i,e=>{r&&(r[n]=e)});function o(n){for(let[r,i]of Object.entries(t.assignedProps))n[r]=e.evalProp(i);for(let[r,a]of Object.entries(t.assignedEvents)){let t=t=>{a(t),e.shouldReturnFocusToEditor()&&e.view.focus()};n.addEventListener(r,t),i.push({el:n,type:r,handler:t})}}let s=()=>{let e=n.assignedElements({flatten:!0})[0];e!==r&&(a(),e&&(r=e,o(e)))};return n.addEventListener(`slotchange`,s),queueMicrotask(s),n},Rl=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteHistoryFeature`}getPlugins(){return[this.contribution(gl()),this.contribution(W({"Mod-z":vl,"Ctrl-y":yl,"Cmd-Z":yl}))]}getToolbarItems(){return this.config.showToolbarButtons?[this.contribution({section:`history`,render:e=>$(e,{label:e=>e.rte.getLocale().richTextEditor.undo,icon:`undo-line`,disabled:e=>!vl(e.view.state),onClick:()=>{let{state:t,dispatch:n}=e.view;vl(t,n)}})},1),this.contribution({section:`history`,render:e=>$(e,{label:e=>e.rte.getLocale().richTextEditor.redo,icon:`redo-line`,disabled:e=>!yl(e.view.state),onClick:()=>{let{state:t,dispatch:n}=e.view;yl(t,n)}})},2)]:[]}},zl=`h1,h2,h3,p{all:unset;display:block}h1:first-child,h2:first-child,h3:first-child,p:first-child{margin-block-start:0}h1:last-child,h2:last-child,h3:last-child,p:last-child{margin-block-end:0}p{font:var(--vvd-typography-base);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:16px;line-height:20px}.heading-step-1{font:var(--vvd-typography-heading-4);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:24px 12px;line-height:28px}.heading-step-2{font:var(--vvd-typography-heading-3);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:24px 12px;line-height:36px}.heading-step-3{font:var(--vvd-typography-heading-2);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:32px 16px;line-height:42px}`,Bl=class extends _.r{constructor(e){super(),this.enabledBlocks=e,this.name=`RteBasicTextBlocks`}getStyles(){return[this.contribution(zl)]}getSchema(e,t){let n={};this.enabledBlocks.paragraph&&(n.paragraph={group:`block`,content:`inline*`,attrs:{...e.attrs},parseDOM:[{tag:`p`,getAttrs:t=>e.fromDOM(t)}],marks:t.getAllowedMarksForNode(`paragraph`).join(` `),toDOM(t){return[`p`,{part:`node--paragraph`,...e.getDOMAttrsProperties(t)},0]},serializeToDOM(t){return[`p`,...e.getDOMAttrs(t),0]}});let r=0;for(let i of[3,2,1]){let a=`heading${i}`,o=`h${i}`;if(!this.enabledBlocks[a])continue;r++;let s=r;n[a]={group:`block`,content:`inline*`,attrs:{...e.attrs},parseDOM:[{tag:o,getAttrs:t=>e.fromDOM(t)}],marks:t.getAllowedMarksForNode(a).join(` `),defining:!0,toDOM(t){return[o,{class:`heading-step-${s}`,part:`node--${a}`,...e.getDOMAttrsProperties(t)},0]},serializeToDOM(t){return[o,...e.getDOMAttrs(t),0]}}}return[this.contribution({nodes:n})]}getPlugins(e){let t={};this.enabledBlocks.paragraph&&(t[`Mod-Alt-0`]=this.setBlockType(e,`paragraph`));for(let n of[1,2,3]){let r=`heading${n}`;this.enabledBlocks[r]&&(t[`Mod-Alt-${n}`]=this.setBlockType(e,r))}return[this.contribution(W(t))]}getCurrentBlockType(e){let{$from:t,$to:n}=e.selection,r=t.depth===0?e.doc.childAfter(t.pos).node:t.node(1);return r!==(n.depth===0?e.doc.childBefore(n.pos).node:n.node(1))||!(r.type.name in this.enabledBlocks)?null:r.type.name}setBlockType(e,t){return(n,r)=>{let{from:i,to:a}=n.selection,o=n.tr,s=!1;return n.doc.nodesBetween(i,a,(r,i)=>(r.type.name in this.enabledBlocks&&(s=!0,o.setBlockType(i,i+r.nodeSize,n.schema.nodes[t],t=>e.textblockAttrs.extractFromNode(t))),!1)),s?(r?.(o),!0):!1}}},Vl=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?Hl(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function Hl(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var Ul=500;function Wl({rules:e}){let t=new N({state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return Gl(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&Gl(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function Gl(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t),c=s.parent.textBetween(Math.max(0,s.parentOffset-Ul),s.parentOffset,null,``)+r;for(let l=0;l<i.length;l++){let u=i[l];if(!u.inCodeMark&&s.marks().some(e=>e.type.spec.code))continue;if(s.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode===`only`)continue;let d=u.match.exec(c);if(!d||d[0].length<r.length)continue;let f=t-(d[0].length-r.length);if(!u.inCodeMark){let e=!1;if(o.doc.nodesBetween(f,s.pos,t=>{t.isInline&&t.marks.some(e=>e.type.spec.code)&&(e=!0)}),e)continue}let p=u.handler(o,d,f,n);if(p)return u.undoable&&p.setMeta(a,{transform:p,from:t,to:n,text:r}),e.dispatch(p),!0}return!1}var Kl=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let n=e.tr,r=a.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(a.text){let t=n.doc.resolve(a.from).marks();n.replaceWith(a.from,a.to,e.schema.text(a.text,t))}else n.delete(a.from,a.to);t(n)}return!0}}return!1};new Vl(/--$/,`—`,{inCodeMark:!1}),new Vl(/\.\.\.$/,`…`,{inCodeMark:!1}),new Vl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new Vl(/"$/,`”`,{inCodeMark:!1}),new Vl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new Vl(/'$/,`’`,{inCodeMark:!1});var ql=e=>e.parent.textBetween(0,e.parentOffset,void 0,``),Jl=class extends _.r{constructor(...e){super(...e),this.name=`RteInputRulesFeature`}getPlugins(e){let t=_.s(e.config.features.flatMap(t=>t.getInputRules(e)));if(t.length===0)return[];let n=[],r=t.map(e=>e.rule);n.push(this.contribution(Wl({rules:r}))),n.push(this.contribution(W({Backspace:Kl}),_.i.high));let i=t.filter(e=>e.enterHandler).map(e=>e.enterHandler);return i.length>0&&n.push(this.contribution(W({Enter:(e,t)=>{let{$cursor:n}=e.selection;if(!n)return!1;let r=ql(n);for(let{regex:a,handler:o}of i){let i=a.exec(r);if(!i)continue;let s=n.pos-n.parentOffset+i.index,c=o(e,i,s,s+i[0].length);c&&t?.(c);break}return!1}}),_.i.highest)),n}},Yl=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteBase`}getSchema(){return[this.contribution({nodes:{doc:{content:this.config?.singleBlock?`block`:`block+`},text:{group:`inline`}}})]}getFeatures(){return[this,new as,new Rl({showToolbarButtons:this.config?.historyToolbarButtons??!0}),new Bl({heading1:this.config?.heading1??!1,heading2:this.config?.heading2??!1,heading3:this.config?.heading3??!1,paragraph:this.config?.paragraph??!0}),new Jl]}getPublicInterface(e){let t=e.getFeature(`RteCore`);return{get disabled(){return t.disabled.getValue(e)},set disabled(n){t.disabled.setValue(e,n)},get scrollThreshold(){return t.scrollThreshold},set scrollThreshold(n){t.scrollThreshold=n,e.view?.setProps({scrollThreshold:n})},get scrollMargin(){return t.scrollMargin},set scrollMargin(n){t.scrollMargin=n,e.view?.setProps({scrollMargin:n})}}}},Xl=_.a(Yl),Zl=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteTextBlockPickerFeature`}getToolbarItems(e){let t=e.getFeature(`RteBasicTextBlocks`);return[this.contribution({section:`font`,render:n=>Nl(n,{label:()=>n.rte.getLocale().richTextEditor.paragraphStyles,value:e=>t.getCurrentBlockType(e.view.state)??``,onSelect:r=>{let{state:i,dispatch:a}=n.view;t.setBlockType(e,r)(i,a)},children:this.config.options.map(r=>Ml(n,{text:r.label,value:r.node,disabled:()=>!t.setBlockType(e,r.node)(n.view.state)}))})},1)]}},Ql=_.a(Zl),$l=`.toolbar{background-color:var(--vvd-color-neutral-50);flex-wrap:wrap;align-items:center;gap:8px;padding:4px;display:flex}.toolbar--hidden{display:none}`,eu=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteToolbarFeature`,this.hidden=new Zo(!1)}getStyles(){return[this.contribution($l)]}getPlugins(e){let t=[`history`,`font`,`text-style`,`textblock`,`insert`],n=new Map(t.map(e=>[e,[]]));for(let t of _.s(e.features.flatMap(t=>t.getToolbarItems(e))))n.get(t.section).push(t);let r=e.getFeature(`RteCore`);return[this.contribution(this.hidden.plugin),this.contribution(new N({view:i=>{let a=!1,o=new Sl(i,e,{popupPlacement:this.config?.popupDirection===`outward`?`bottom`:`top`,menuOffset:8,disabled:()=>r.disabled.getValue(e),shouldReturnFocusToEditor:()=>a}),s=i.dom.getRootNode().querySelector(`.toolbar`),c=-1/0,l=()=>{i.hasFocus()&&(a=!0),c=Date.now()},u=()=>{Date.now()-c>250&&(a=!1)},d=e=>{s.contains(e.relatedTarget)||(a=!1)};s.addEventListener(`mousedown`,l,{capture:!0}),s.addEventListener(`focusin`,u),s.addEventListener(`focusout`,d),o.bindProp(()=>this.hidden.getValue(e),e=>{s.classList.toggle(`toolbar--hidden`,e)});let f=!1;for(let e of t){let t=n.get(e);t.length&&f&&(s.appendChild(Pl(o)),f=!1);for(let e of t)s.appendChild(e.render(o)),f=!0}return{update(){o.updateBindings()},destroy(){s.innerHTML=``,s.removeEventListener(`mousedown`,l,{capture:!0}),s.removeEventListener(`focusin`,u),s.removeEventListener(`focusout`,d),a=!1}}}}))]}getPublicInterface(e){let t=this.hidden;return{get hidden(){return t.getValue(e)},set hidden(n){t.setValue(e,n)}}}},tu=_.a(eu),nu=`.placeholder{display:contents}.placeholder:before{color:var(--vvd-color-neutral-600);content:attr(data-placeholder);font-size:var(--placeholder-font-size,inherit);inset-inline:var(--editor-padding-inline);line-height:inherit;pointer-events:none;position:absolute}.editor--disabled .placeholder:before{color:var(--vvd-color-neutral-300)}`,ru=class extends _.r{constructor(e){super(),this.config=e,this.name=`RtePlaceholderFeature`}getStyles(){return[this.contribution(nu)]}getPlugins(){let e=new N({props:{decorations:e=>{if(e.doc.nodeSize===4){let t=e.schema.marks.fontSize?.isInSet(e.storedMarks??[])?.attrs.size;return V.create(e.doc,[B.widget(1,()=>{let e=document.createElement(`span`);return e.className=`placeholder`,e.dataset.placeholder=this.config.text,t&&e.style.setProperty(`--placeholder-font-size`,t),e})])}return null}}});return[this.contribution(e)]}},iu=_.a(ru),au=class extends _.r{constructor(...e){super(...e),this.name=`RteHardBreakFeature`}getSchema(){return[this.contribution({nodes:{hardBreak:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return[`br`]}}}})]}getPlugins(e){return[this.contribution(W({"Shift-Enter":(e,t)=>{let n=e.storedMarks||e.selection.$from.marks(),r=e.tr.replaceSelectionWith(e.schema.nodes.hardBreak.create(),!0).scrollIntoView();return n.length&&r.setStoredMarks(n),t?.(r),!0}}),_.i.high)]}},ou=_.a(au),su=Symbol(`mixedFontSize`),cu=class extends _.r{constructor(e){if(super(),this.config=e,this.name=`RteFontSizePickerFeature`,this.fontSizes=e.options,e.onBlocks){this.defaultFontSizeForNode={};for(let t of e.onBlocks)this.defaultFontSizeForNode[t.node]=t.defaultSize??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:`fontSize`,onNodeName:e.node})):[this.contribution({markName:`fontSize`})]}getSchema(){return[this.contribution({marks:{fontSize:{attrs:{size:{validate:`string`}},parseDOM:[{tag:`span[style*='font-size']`,getAttrs:e=>{let t=e.getAttribute(`style`).match(/font-size:\s*([^;]+)/)?.[1]?.trim();return t?{size:t}:!1}}],toDOM:e=>[`span`,{style:`font-size: ${Pc(e.attrs.size)};`},0],cursorFix:(e,t)=>{let n=t.storedMarks;if(!n)return null;let r=n.find(e=>e.type.name===`fontSize`);if(r)return{style:{"font-size":r.attrs.size}};if(n.length===0){let t=this.defaultFontSizeForNode?.[e.parent.type.name];if(t)return{style:{"font-size":t}}}return null}}}})]}getPlugins(){return[this.contribution(W({"Mod-Shift-.":this.adjustFontSize(-1),"Mod-Shift-,":this.adjustFontSize(1)}))]}getToolbarItems(e){return[this.contribution({section:`font`,render:t=>Dl(t,{label:()=>e.getLocale().richTextEditor.textSize,trigger:$(t,{label:()=>e.getLocale().richTextEditor.textSize,icon:`text-size-line`}),children:this.fontSizes.map(e=>Ol(t,{text:e.label,checked:()=>this.getFontSizeFromSelection(t.view.state)===e.size,disabled:()=>!this.setFontSize(e.size)(t.view.state),onSelect:()=>{let{state:n,dispatch:r}=t.view;this.setFontSize(e.size)(n,r)}}))})},2)]}getFontSizeFromSelection(e){let{from:t,to:n,$from:r,empty:i}=e.selection,{fontSize:a}=e.schema.marks;if(i){let t=this.defaultFontSizeForNode?.[r.parent.type.name]??null;return a.isInSet(e.storedMarks||r.marks())?.attrs.size??t}let o=null,s=e=>{o===null?o=e??null:e!==o&&(o=su)};return e.doc.nodesBetween(t,n,(e,t,n)=>o===su?!1:e.isLeaf?(s(a.isInSet(e.marks)?.attrs.size??(n&&this.defaultFontSizeForNode?.[n.type.name])),!0):(e.type.allowsMarkType(a)&&e.childCount===0&&s(this.defaultFontSizeForNode?.[e.type.name]),!0)),o}setFontSize(e){return(t,n)=>{let{from:r,to:i,empty:a,$from:o}=t.selection,{fontSize:s}=t.schema.marks;if(!Do(s,{size:e})(t))return!1;let c=t.tr;if(a){let n=(t.storedMarks||[]).filter(e=>e.type!==s);e!==this.defaultFontSizeForNode?.[o.parent.type.name]&&n.push(s.create({size:e})),c.setStoredMarks(n)}else c.addMark(r,i,s.create({size:e})),c.doc.nodesBetween(r,i,(e,t,n)=>{if(!e.isInline)return;let r=s.isInSet(e.marks),i=this.defaultFontSizeForNode?.[n.type.name];r&&r.attrs.size===i&&c.step(new ye(t,t+e.nodeSize,r))});return n?.(c.scrollIntoView()),!0}}adjustFontSize(e){return(t,n)=>{let r=this.getFontSizeFromSelection(t);if(r===null||r===su)return!1;let i=this.fontSizes.findIndex(e=>e.size===r)+e;return i<0||i>=this.fontSizes.length?!1:this.setFontSize(this.fontSizes[i].size)(t,n)}}},lu=_.a(cu),uu=[`p`,0],du=[`blockquote`,0],fu=[`hr`],pu=[`pre`,[`code`,0]],mu=[`br`],hu={doc:{content:`block+`},paragraph:{content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM(){return uu}},blockquote:{content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM(){return du}},horizontal_rule:{group:`block`,parseDOM:[{tag:`hr`}],toDOM(){return fu}},heading:{attrs:{level:{default:1,validate:`number`}},content:`inline*`,group:`block`,defining:!0,parseDOM:[{tag:`h1`,attrs:{level:1}},{tag:`h2`,attrs:{level:2}},{tag:`h3`,attrs:{level:3}},{tag:`h4`,attrs:{level:4}},{tag:`h5`,attrs:{level:5}},{tag:`h6`,attrs:{level:6}}],toDOM(e){return[`h`+e.attrs.level,0]}},code_block:{content:`text*`,marks:``,group:`block`,code:!0,defining:!0,parseDOM:[{tag:`pre`,preserveWhitespace:`full`}],toDOM(){return pu}},text:{group:`inline`},image:{inline:!0,attrs:{src:{validate:`string`},alt:{default:null,validate:`string|null`},title:{default:null,validate:`string|null`}},group:`inline`,draggable:!0,parseDOM:[{tag:`img[src]`,getAttrs(e){return{src:e.getAttribute(`src`),title:e.getAttribute(`title`),alt:e.getAttribute(`alt`)}}}],toDOM(e){let{src:t,alt:n,title:r}=e.attrs;return[`img`,{src:t,alt:n,title:r}]}},hard_break:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return mu}}},gu=[`em`,0],_u=[`strong`,0],vu=[`code`,0],yu={link:{attrs:{href:{validate:`string`},title:{default:null,validate:`string|null`}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM(e){let{href:t,title:n}=e.attrs;return[`a`,{href:t,title:n},0]}},em:{parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style=italic`},{style:`font-style=normal`,clearMark:e=>e.type.name==`em`}],toDOM(){return gu}},strong:{parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!=`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name==`strong`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM(){return _u}},code:{code:!0,parseDOM:[{tag:`code`}],toDOM(){return vu}}};new _._({nodes:hu,marks:yu});var bu=class extends _.r{constructor(e){super(),this.config=e}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:this.markName,onNodeName:e.node})):[this.contribution({markName:this.markName})]}},xu=class extends bu{constructor(...e){super(...e),this.name=`RteBoldFeature`,this.markName=`bold`}getSchema(){return[this.contribution({marks:{bold:yu.strong}})]}getPlugins(e){return[this.contribution(W({"Mod-b":Do(e.schema.marks.bold)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>jl(t,{label:()=>t.rte.getLocale().richTextEditor.bold,dynamicIcon:`bold`,markType:e.schema.marks.bold})},1)]}},Su=_.a(xu),Cu=class extends bu{constructor(...e){super(...e),this.name=`RteItalicFeature`,this.markName=`italic`}getSchema(){return[this.contribution({marks:{italic:yu.em}})]}getPlugins(e){return[this.contribution(W({"Mod-i":Do(e.schema.marks.italic)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>jl(t,{label:()=>t.rte.getLocale().richTextEditor.italic,dynamicIcon:`italic`,markType:e.schema.marks.italic})},2)]}},wu=_.a(Cu),Tu=class extends bu{constructor(...e){super(...e),this.name=`RteUnderlineFeature`,this.markName=`underline`}getSchema(){return[this.contribution({marks:{underline:{parseDOM:[{tag:`u`}],toDOM(){return[`u`,0]}}}})]}getPlugins(e){return[this.contribution(W({"Mod-u":Do(e.schema.marks.underline)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>jl(t,{label:()=>t.rte.getLocale().richTextEditor.underline,dynamicIcon:`underline`,markType:e.schema.marks.underline})},3)]}},Eu=_.a(Tu),Du=class extends bu{constructor(...e){super(...e),this.name=`RteStrikethroughFeature`,this.markName=`strikethrough`}getSchema(){return[this.contribution({marks:{strikethrough:{parseDOM:[{tag:`s`},{tag:`del`}],toDOM(){return[`s`,0]}}}})]}getPlugins(e){return[this.contribution(W({"Alt-Shift-5":Do(e.schema.marks.strikethrough),"Cmd-Shift-X":Do(e.schema.marks.strikethrough)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>jl(t,{label:()=>t.rte.getLocale().richTextEditor.strikethrough,dynamicIcon:`strikethrough`,markType:e.schema.marks.strikethrough})},4)]}},Ou=_.a(Du),ku=`tt{font:var(--vvd-typography-base-code);font-variant-ligatures:unset;font-feature-settings:unset;font-size:unset;font-weight:unset;line-height:unset}`,Au=class extends bu{constructor(...e){super(...e),this.name=`RteMonospaceFeature`,this.markName=`monospace`}getStyles(){return[this.contribution(ku)]}getSchema(){return[this.contribution({marks:{monospace:{parseDOM:[{tag:`tt`},{tag:`code`}],toDOM(){return[`tt`,0]}}}})]}getPlugins(e){return[this.contribution(W({"Mod-M":Do(e.schema.marks.monospace)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>jl(t,{label:()=>t.rte.getLocale().richTextEditor.monospace,dynamicIcon:`monospace`,markType:e.schema.marks.monospace})},5)]}},ju=_.a(Au);function Mu(e,t,n){for(let r=0;r<t.length;r++){let{$from:i,$to:a}=t[r],o=i.depth==0&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,a.pos,e=>!o&&(o=e.inlineContent&&e.type.allowsMarkType(n),!0)),o)return!0}return!1}var Nu=Symbol(`mixedColor`),Pu=class extends _.r{constructor(e){if(super(),this.config=e,this.name=`RteTextColorPicker`,e?.onBlocks){this.defaultColorForNode={};for(let t of e.onBlocks)this.defaultColorForNode[t.node]=t.defaultColor??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:`textColor`,onNodeName:e.node})):[this.contribution({markName:`textColor`})]}getSchema(){return[this.contribution({marks:{textColor:{attrs:{color:{validate:`string`}},parseDOM:[{tag:`span[data-text-color]`,getAttrs:e=>({color:e.getAttribute(`data-text-color`)})},{style:`color`,getAttrs:e=>({color:e})}],toDOM(e){let{color:t}=e.attrs;return[`span`,{style:`color: ${Pc(t)};`,"data-text-color":t},0]},inclusive:!0}}})]}getToolbarItems(){return[this.contribution({section:`text-style`,render:e=>{let t=$(e,{label:()=>e.rte.getLocale().richTextEditor.textColor,disabled:()=>!this.setColor(`any`)(e.view.state),icon:`textcolor-line`}),n=t.firstElementChild;return Cl(e,{children:[t,Ll(e,{name:`text-color-picker`,assignedProps:{anchor:n,value:()=>this.getSelectionColor(e.view.state)||``},assignedEvents:{change:t=>{let n=t.currentTarget.value;this.setColor(n)(e.view.state,e.view.dispatch)}}})]})}},6)]}getSelectionColor(e){let{selection:t}=e,{textColor:n}=e.schema.marks,{from:r,to:i,$from:a,empty:o}=t;if(o){let t=this.defaultColorForNode?.[a.parent.type.name]??null;return n.isInSet(e.storedMarks||a.marks())?.attrs.color??t}let s=null,c=e=>{s===null?s=e??null:e!==s&&(s=Nu)};return e.doc.nodesBetween(r,i,(e,t,r)=>s===Nu?!1:e.isLeaf?(c(n.isInSet(e.marks)?.attrs.color??(r&&this.defaultColorForNode?.[r.type.name])),!0):(e.type.allowsMarkType(n)&&e.childCount===0&&c(this.defaultColorForNode?.[e.type.name]),!0)),s===Nu?null:s}setColor(e){return(t,n)=>{let{textColor:r}=t.schema.marks,{from:i,to:a,empty:o,$from:s}=t.selection;if(!Mu(t.doc,t.selection.ranges,r))return!1;let c=t.tr;if(o){let n=(t.storedMarks||[]).filter(e=>e.type!==r);e!==this.defaultColorForNode?.[s.parent.type.name]&&n.push(r.create({color:e})),c.setStoredMarks(n)}else c.addMark(i,a,r.create({color:e})),c.doc.nodesBetween(i,a,(e,t,n)=>{if(!e.isInline)return;let i=r.isInSet(e.marks),a=this.defaultColorForNode?.[n.type.name];i&&i.attrs.color===a&&c.step(new ye(t,t+e.nodeSize,i))});return n?.(c.scrollIntoView()),!0}}},Fu=_.a(Pu),Iu=`.rich-text ul,.rich-text ol{padding-inline-start:1.5em}.rich-text li{list-style-position:inside}`,Lu=e=>e.parentOffset===0,Ru=e=>e.nodeSize===2,zu=e=>e.depth-1,Bu=e=>e.depth-2,Vu=e=>e.parent,Hu=e=>e.node(zu(e)),Uu=e=>e.depth>2,Wu=(e,t)=>e.index(t)===0,Gu=(e,t)=>e.index(t)===e.node(t).childCount-1,Ku=(e,t)=>{let n=e.node(t),r=e.index(t);return n.maybeChild(r-1)},qu=(e,t)=>{let n=e.node(t),r=e.index(t);return n.maybeChild(r+1)},Ju=e=>{let{$from:t,$to:n}=e;if(e instanceof M){let r=k.between(e.$from,e.$to);t=r.$from,n=r.$to}return{$from:t,$to:n}},Yu=(e,t)=>e.sameParent(t)?e.node(-1):e.node(e.sharedDepth(t.pos)),Xu=e=>{let{$cursor:t}=e.selection;return t?.parent.type===e.schema.nodes.listItem?t:null},Zu=(e,t,n,r)=>{let i,a=!0;return e.doc.nodesBetween(t.pos,n.pos,t=>{t.type.isInGroup(`list`)&&(i=t.type),t.type===e.schema.nodes.listItem&&i!==r&&(a=!1)}),a},Qu=(e,t,n)=>Uu(t)?($u(t,n),!0):ed(e,t,n),$u=(e,t)=>{let n=new _.h(e.doc.resolve(e.before()),e.doc.resolve(e.after()),e.depth-1);t.lift(n,e.depth-2)},ed=(e,t,n)=>{let r=Hu(t),i=t.index(Bu(t)),a=Yo(t.node(Bu(t)).contentMatchAt(i+1));if(!a)return!1;let o=Wu(t,zu(t)),s=Gu(t,zu(t));return n.step(new T(t.before()-+!!o,t.after()+ +!!s,t.start(),t.end(),new _.v((o?_.d.empty:_.d.from(r.copy(_.d.empty))).append(_.d.from(a.create(e.textblockAttrs.extractFromNode(Vu(t))))).append(s?_.d.empty:_.d.from(r.copy(_.d.empty))),+!o,+!s),+!o+1)),!0},td=(e,t,n,r)=>{n.parent.type===e.schema.nodes.listItem?nd(t,n,r):rd(e,t,n,r)},nd=(e,t,n)=>{let r=Ku(t,zu(t))?.type===e,i=qu(t,zu(t))?.type===e,a=+!!r,o=+!!i;n.step(new T(t.before()-+!!r,t.after()+ +!!i,t.before(),t.after(),new _.v(_.d.from(e.create(null,[])),a,o),1-a))},rd=(e,t,n,r)=>{r.step(new T(n.before(),n.after(),n.start(),n.end(),new _.v(_.d.from(t.create(null,[e.schema.nodes.listItem.create(e.textblockAttrs.extractFromNode(n.parent))])),0,0),2))},id=class extends _.r{constructor(e){if(super(),this.config=e,this.name=`RteListFeature`,!e.bulletList&&!e.numberedList)throw Error(`RteListFeature requires at least one of bulletList or numberedList to be enabled`)}getStyles(){return[this.contribution(Iu)]}getSchema(e){return[this.contribution({nodes:{listItem:{content:`inline*`,attrs:e.attrs,defining:!0,parseDOM:[{tag:`li`,getAttrs:t=>e.fromDOM(t)}],toDOM(t){return[`li`,...e.getDOMAttrs(t),0]}},...this.config.bulletList?{bulletList:{group:`block list`,content:`(listItem | list)+`,parseDOM:[{tag:`ul`}],toDOM(){return[`ul`,0]}}}:{},...this.config.numberedList?{numberedList:{group:`block list`,content:`(listItem | list)+`,parseDOM:[{tag:`ol`}],toDOM(){return[`ol`,0]}}}:{}}})]}getPlugins(e){return this.rte=e,[this.contribution(W({Enter:(e,t)=>{let n=Xu(e);if(n&&Ru(Vu(n))){let r=e.tr;return Qu(this.rte,n,r)?(t?.(r.scrollIntoView()),!0):!1}return!1},Backspace:(e,t)=>{let n=Xu(e);if(n&&Lu(n)){if(Wu(n,zu(n))&&Ku(n,Bu(n))?.type===Hu(n).type)return!1;let r=e.tr;return Qu(this.rte,n,r)?(t?.(r.scrollIntoView()),!0):!1}return!1},Tab:(e,t)=>{let n=Xu(e);if(n&&Lu(n)){let r=e.tr;return nd(Hu(n).type,n,r),t?.(r.scrollIntoView()),!0}return!1},"Shift-Tab":(e,t)=>{let n=Xu(e);if(n&&Lu(n)&&Uu(n)){let r=e.tr;return $u(n,r),t?.(r.scrollIntoView()),!0}return!1},...this.config.bulletList?{"Mod-Shift-8":this.toggleList(e.schema.nodes.bulletList)}:{},...this.config.numberedList?{"Mod-Shift-7":this.toggleList(e.schema.nodes.numberedList)}:{}}),_.i.high)]}getToolbarItems(e){let t=[];return this.config.bulletList&&t.push(this.contribution({section:`textblock`,render:t=>$(t,{label:()=>t.rte.getLocale().richTextEditor.bulletList,dynamicIcon:`bullet-list-2`,active:()=>this.isSelectionInList(e.schema.nodes.bulletList,t.rte.state),onClick:()=>{let{state:n,dispatch:r}=t.view;this.toggleList(e.schema.nodes.bulletList)(n,r)}})},1)),this.config.numberedList&&t.push(this.contribution({section:`textblock`,render:t=>$(t,{label:()=>t.rte.getLocale().richTextEditor.numberedList,dynamicIcon:`list-numbered`,active:()=>this.isSelectionInList(e.schema.nodes.numberedList,t.rte.state),onClick:()=>{let{state:n,dispatch:r}=t.view;this.toggleList(e.schema.nodes.numberedList)(n,r)}})},2)),t}toggleList(e){return ko((t,n)=>{let{$from:r,$to:i}=Ju(t.selection);if(Yu(r,i).type.isInGroup(`list`)){if(Zu(t,r,i,e)){let e=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(n,r)=>{if(n.type===t.schema.nodes.listItem){let t=e.doc.resolve(e.mapping.map(r+1));Qu(this.rte,t,e)}}),n?.(e.scrollIntoView()),!0}{let a=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(t,n)=>{t.type.isInGroup(`list`)&&t.type!==e&&a.setNodeMarkup(n,e,t.attrs)}),n?.(a.scrollIntoView()),!0}}{let a=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(t,n)=>{if(!t.isTextblock)return;let r=a.doc.resolve(a.mapping.map(n+1));td(this.rte,e,r,a)}),n?.(a.scrollIntoView()),!0}},(t,n)=>t.type===e&&n.type===e)}isSelectionInList(e,t){let{$from:n,$to:r}=Ju(t.selection);return Yu(n,r).type.isInGroup(`list`)?Zu(t,n,r,e):!1}},ad=_.a(id),od=[{value:`left`,icon:`align-left`,label:`left`},{value:`center`,icon:`align-center`,label:`center`},{value:`right`,icon:`align-right`,label:`right`}],sd=e=>od.find(t=>t.value===e)?.value??`left`,cd=class extends _.r{constructor(...e){super(...e),this.name=`RteAlignmentFeature`}getTextblockAttrs(){return[this.contribution({name:`textAlign`,default:`left`,fromDOM(e){return sd(e.style.textAlign)},toStyles(e){return[`text-align: ${sd(e.attrs.textAlign)}`]}})]}getPlugins(){return[this.contribution(W({"Mod-L":this.setAlignment(`left`),"Mod-E":this.setAlignment(`center`),"Mod-R":this.setAlignment(`right`)}))]}getToolbarItems(){return[this.contribution({section:`textblock`,render:e=>Dl(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,trigger:$(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,icon:()=>{let t=this.getAlignmentFromSelection(e.view.state);return`${od.find(e=>e.value===t)?.icon??`align-left`}-line`}}),children:[kl(e,{slot:`header`,children:od.map((t,n)=>$(e,{dynamicIcon:t.icon,label:()=>e.rte.getLocale().richTextEditor.alignments[t.label],noTooltip:!0,variant:`toolbar-menu`,autofocus:()=>{let r=this.getAlignmentFromSelection(e.view.state);return(r===`mixed`||r===null)&&n===0||t.value===r},active:()=>this.getAlignmentFromSelection(e.view.state)===t.value,disabled:()=>this.getAlignmentFromSelection(e.view.state)===null,onClick:()=>{let{state:n,dispatch:r}=e.view;this.setAlignment(t.value)(n,r)}}))})]})},3)]}getAlignmentFromSelection(e){let{selection:t}=e,{from:n,to:r}=t,i=null;return e.doc.nodesBetween(n,r,e=>{i!==`mixed`&&e.type.isTextblock&&(i?i!==e.attrs.textAlign&&(i=`mixed`):i=e.attrs.textAlign)}),i}setAlignment(e){return(t,n)=>{let{tr:r,selection:i}=t,{from:a,to:o}=i;return t.doc.nodesBetween(a,o,(t,n)=>{t.type.isTextblock&&r.setNodeMarkup(n,t.type,{...t.attrs,textAlign:e})}),n?.(r.scrollIntoView()),!0}}},ld=_.a(cd),ud=`.link-popover{flex-direction:column;gap:8px;inline-size:450px;padding:16px;display:flex}.link-popover-header{justify-content:space-between;align-items:center;display:flex}.link-popover-label{color:var(--vvd-color-neutral-600);font:var(--vvd-typography-base-condensed)}.link-popover-content{flex-direction:column;gap:16px;display:flex}.link,.rich-text a[href],.link:visited,.rich-text a[href]:visited{color:var(--vvd-color-cta-600)}.link:hover,.rich-text a[href]:hover{color:var(--vvd-color-cta-500)}.link:active,.rich-text a[href]:active{color:var(--vvd-color-cta-400)}.link-action-bar{justify-content:end;gap:8px;display:flex}.link-toolbar-menu{flex-direction:column;gap:16px;inline-size:368px;padding:8px;display:flex}`,dd=`(?:https?://|www\\.)[^\\s<]+`;function fd(e,t,n,r){if(e.doc.rangeHasMark(n,n+1,e.schema.marks.link))return null;let i=t.replace(/[.,;:!?) ]+$/,``),a=i.startsWith(`www.`)?`https://${i}`:i,o=e.schema.marks.link.create({href:a}),s=n+i.length,c=t.slice(i.length),l=e.tr.addMark(n,s,o);return c&&l.replaceWith(s,r,e.schema.text(c)),l}var pd=class extends _.r{constructor(...e){super(...e),this.name=`RteLinkFeature`,this.removeLink=(e,t)=>{let n=e.tr,r=this.getCurrentLink(e);return n.removeMark(r.start,r.end,e.schema.marks.link),t?.(n.scrollIntoView()),!0}}getStyles(){return[this.contribution(ud)]}getSchema(){return[this.contribution({marks:{link:{attrs:{href:{validate:`string`}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`)}}}],toDOM(e){let{href:t}=e.attrs;return[`a`,{href:Mc(t)},0]}}}},_.i.high)]}getTextblockMarks(){return[this.contribution({markName:`link`})]}getInputRules(){let e=RegExp(`${dd}$`);return[this.contribution({rule:new Vl(RegExp(`${dd} $`),(e,t,n,r)=>fd(e,t[0],n,r)),enterHandler:{regex:e,handler:(e,t,n,r)=>fd(e,t[0],n,r)}})]}getPlugins(e){let t=()=>(this.toolbarMenu.open=!0,!0),n;return[this.contribution(new N({props:{decorations:e=>{let t=this.getCurrentLink(e);if(t){let n=B.inline(t.start,t.end,{id:`current-link`});return V.create(e.doc,[n])}return null}},view:t=>{let r=new Sl(t,e,{popupPlacement:`bottom`,shouldReturnFocusToEditor:!0});n=e.createComponent(x),n.anchorId=`current-link`;let i=Cl(r,{className:`link-popover`,children:[Cl(r,{className:`link-popover-header`,children:[Cl(r,{className:`link-popover-label`,children:[Il(r,{text:()=>this.getCurrentLink(r.view.state)?.text||``})]}),$(r,{icon:`close-line`,label:()=>r.rte.getLocale().richTextEditor.close,noTooltip:!0,onClick:()=>{n.dismiss()}})]}),Cl(r,{className:`link-popover-content`,children:[wl(r,{className:`link`,href:()=>this.getCurrentLink(r.view.state)?.href||``,target:`_blank`,rel:`noopener`,children:[Il(r,{text:()=>this.getCurrentLink(r.view.state)?.href||``})]}),Cl(r,{className:`link-action-bar`,children:[$(r,{icon:`delete-line`,label:()=>r.rte.getLocale().richTextEditor.delete,connotation:`alert`,variant:`popover`,noTooltip:!0,onClick:()=>{let{state:e,dispatch:t}=r.view;this.removeLink(e,t)}}),$(r,{icon:`edit-line`,label:()=>r.rte.getLocale().richTextEditor.edit,variant:`popover`,noTooltip:!0,onClick:()=>(this.toolbarMenu.open=!0,n.requestOpenState(!1),!0)})]})]})]});return n.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(n),{update:e=>{let t=e.state;r.updateBindings();let i=this.getCurrentLink(t);n.requestOpenState(!!i)},destroy:()=>{n.remove()}}}})),this.contribution(W({Escape:e=>this.getCurrentLink(e)?(n?.dismiss(),!0):!1,"Mod-k":t}))]}getToolbarItems(e){let t=e=>{let{from:t,to:n}=e.selection;return t===n?``:e.doc.textBetween(t,n,` `)},n=e=>{try{return new URL(e),!0}catch{return!1}};return[this.contribution({section:`insert`,render:r=>{let i=Fl(r,{label:()=>r.rte.getLocale().richTextEditor.linkText,placeholder:()=>r.rte.getLocale().richTextEditor.linkTextPlaceholder,slot:`header`,autofocus:!0,value:()=>this.getCurrentLink(r.view.state)?.text||t(r.view.state)||``,onInput:()=>{s()}}),a=Fl(r,{label:()=>r.rte.getLocale().richTextEditor.linkUrl,type:`url`,placeholder:()=>r.rte.getLocale().richTextEditor.linkUrlPlaceholder,helperText:()=>r.rte.getLocale().richTextEditor.linkUrlHelperText,slot:`header`,value:()=>this.getCurrentLink(r.view.state)?.href||``,onInput:()=>{s()}}),o=$(r,{label:()=>r.rte.getLocale().richTextEditor.apply,variant:`popover-primary`,disabled:()=>{let e=this.getCurrentLink(r.view.state);return!(e&&e.text.length&&n(e.href))},onClick:()=>{let{state:t,dispatch:n}=r.view;this.insertLink(e,a.value,i.value)(t,n),this.toolbarMenu.open=!1}}),s=()=>{o.querySelector(`[data-vvd-component="button"]`).disabled=!(i.value.length&&n(a.value))},c=Dl(r,{label:()=>r.rte.getLocale().richTextEditor.hyperlink,trigger:$(r,{label:()=>r.rte.getLocale().richTextEditor.hyperlink,icon:`link-line`}),children:[Cl(r,{className:`link-toolbar-menu`,slot:`header`,children:[i,a,Cl(r,{className:`link-action-bar`,slot:`header`,children:[$(r,{label:()=>r.rte.getLocale().richTextEditor.cancel,variant:`popover`,onClick:()=>{this.toolbarMenu.open=!1}}),o]})]})]});return this.toolbarMenu=c.lastElementChild,c}},1)]}getCurrentLink(e){let t=e.selection;if(!(t instanceof k))return null;let n=e.schema.marks.link,{$from:r,$to:i}=t,a=e.selection.empty?r.marks():r.nodeAfter?.marks??[],o=n.isInSet(a)?.attrs.href;if(!o)return null;let s=e=>n.isInSet(e.marks)?.attrs.href===o,c=null,l=[];e.doc.nodesBetween(r.start(),i.end(),(e,t)=>{if(!e.isText)return!0;let n=t+e.nodeSize;return s(e)?c?c.end=n:(c={start:t,end:n},l.push(c)):c=null,!1});let u=l.find(e=>e.start<=t.from&&e.end>=t.to);return u?{text:e.doc.textBetween(u.start,u.end,` `),href:o,start:u.start,end:u.end}:null}insertLink(e,t,n){return(r,i)=>{let{from:a,to:o}=r.selection,s=r.tr,c=this.getCurrentLink(r);return c&&(a=c.start,o=c.end),s.insertText(n,a,o),s.addMark(a,a+n.length,e.schema.marks.link.create({href:t})),i?.(s.scrollIntoView()),!0}}},md=_.a(pd),hd=`.inline-image-wrapper{vertical-align:text-bottom;display:inline-block}.inline-image{block-size:auto;display:block}.inline-image-popover{align-items:center;gap:4px;padding:8px;display:flex}.inline-image-placeholder{color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);font-feature-settings:normal;font-variant-ligatures:normal;overflow-wrap:normal;pointer-events:none;white-space:normal}`,gd=e=>e!==null&&!!e.next,_d=1,vd=()=>_d++,yd=class{constructor(e,t,n,r){this.view=t,this.getPos=n,this.config=r,this.content=null,this.dom=document.createElement(`div`),this.dom.className=`inline-image-wrapper`,this.imageUrl=e.attrs.imageUrl,this.img=document.createElement(`img`),this.initializeImg(e);let i=this.config.resolveUrl?this.config.resolveUrl(this.imageUrl):this.imageUrl,a=gd(i)?null:i;this.handleResolvedUrl(a),gd(i)&&this.handleResolvedUrlGenerator(i)}setContent(e,{onDestroy:t,allowPopover:n}={}){this.content?.remove(),this.onContentDestroy?.(),this.content=e,e&&(this.onContentDestroy=t,this.dom.appendChild(e)),x.setBlockPopover(this.dom,!n)}async handleResolvedUrlGenerator(e){let t=e[Symbol.asyncIterator](),n;do n=await t.next(),this.handleResolvedUrl(n.value);while(!n.done)}handleResolvedUrl(e){if(typeof e==`string`)this.renderImg(e);else if(e?.type===`placeholder`){let t=`inline-image-placeholder-${vd()}`,n=document.createElement(`slot`);n.className=`inline-image-placeholder`,n.name=t;let r=e.create?.(t),i=this.view.dom.getRootNode().host;_.t(i,`inline-image-placeholder`,t,{url:this.imageUrl}),this.setContent(n,{onDestroy:()=>{_.t(i,`inline-image-placeholder`,t,_.n),r?.()}})}else this.setContent(null)}initializeImg(e){this.img.className=`inline-image`,this.update(e),this.img.addEventListener(`load`,()=>{let e=this.getPos();if(e){let{state:t,dispatch:n}=this.view,r=t.doc.nodeAt(e);if(!r||r.attrs.naturalWidth===this.img.naturalWidth&&r.attrs.naturalHeight===this.img.naturalHeight)return;let i=t.tr;i.setNodeAttribute(e,`naturalWidth`,this.img.naturalWidth),i.setNodeAttribute(e,`naturalHeight`,this.img.naturalHeight),i.setMeta(`addToHistory`,!1),n(i)}})}renderImg(e){this.img.src=Nc(e),this.setContent(this.img,{allowPopover:!0})}update(e){return this.img.alt=e.attrs.alt,this.img.width=e.attrs.naturalWidth,this.img.height=e.attrs.naturalHeight,this.img.style.maxWidth=e.attrs.size,!0}destroy(){this.setContent(null)}},bd=class extends _.r{constructor(e={}){super(),this.config=e,this.name=`RteInlineImageFeature`}getStyles(){return[this.contribution(hd)]}getSchema(){return[this.contribution({nodes:{inlineImage:{inline:!0,group:`inline`,selectable:!0,atom:!0,attrs:{imageUrl:{validate:`string`},alt:{validate:`string`,default:``},size:{validate:`string|null`,default:null},naturalWidth:{validate:`number|null`,default:null},naturalHeight:{validate:`number|null`,default:null}},parseDOM:[{tag:`img[src],img[data-src]`,getAttrs:e=>{let t=e=>{let t=parseInt(e??``,10);return isNaN(t)?null:t},n=e.getAttribute(`data-src`)??e.getAttribute(`src`),r=this.config.parseUrlFromHtml?this.config.parseUrlFromHtml(n):n;return r!==null&&{imageUrl:r,alt:e.getAttribute(`alt`)||``,size:e.style.maxWidth||null,naturalWidth:t(e.getAttribute(`width`)),naturalHeight:t(e.getAttribute(`height`))}}}],toDOM:e=>{let{imageUrl:t,alt:n,size:r,naturalWidth:i,naturalHeight:a}=e.attrs,o=this.config.serializeUrlToHtml?this.config.serializeUrlToHtml(t):t;if(o===null)return document.createTextNode(``);let s={src:Nc(o),"data-src":o,alt:n};return r&&(s.style=`max-width: ${Pc(r)}; height: auto;`),i&&(s.width=i),a&&(s.height=a),[`img`,s]}}}})]}getPlugins(e){let t;return[this.contribution(new N({props:{nodeViews:{inlineImage:(e,t,n)=>new yd(e,t,n,this.config)}},view:n=>{let r=new Sl(n,e,{popupPlacement:`bottom`,shouldReturnFocusToEditor:!0});t=e.createComponent(x),t.kind=`imageOptions`,t.offset=4;let i=Cl(r,{className:`inline-image-popover`,children:[$(r,{label:()=>r.rte.getLocale().richTextEditor.imageSizes.small,variant:`popover`,active:()=>this.getSelectedImageSize(r.view.state)===`small`,onClick:()=>{this.setSelectedImageSize(`small`)(r.view.state,r.view.dispatch)}}),Pl(r),$(r,{label:()=>r.rte.getLocale().richTextEditor.imageSizes.fit,variant:`popover`,active:()=>this.getSelectedImageSize(r.view.state)===`fit`,onClick:()=>{this.setSelectedImageSize(`fit`)(r.view.state,r.view.dispatch)}}),Pl(r),$(r,{label:()=>r.rte.getLocale().richTextEditor.imageSizes.original,variant:`popover`,active:()=>this.getSelectedImageSize(r.view.state)===`original`,onClick:()=>{this.setSelectedImageSize(`original`)(r.view.state,r.view.dispatch)}})]});return t.appendChild(i),n.dom.getRootNode().querySelector(`.popovers`).appendChild(t),{update:e=>{r.updateBindings();let n=this.getSelectedInlineImage(e.state);n?(t.anchorEl=e.nodeDOM(n.pos),t.requestOpenState(!0)):(t.anchorEl=void 0,t.requestOpenState(!1))},destroy:()=>{t.remove()}}}})),this.contribution(W({Escape:e=>this.getSelectedInlineImage(e)?(t?.dismiss(),!0):!1}))]}calculateSmallWidth(e){return`${Math.min(300,e/2)}px`}getSelectedInlineImage(e){let t=e.selection;return t instanceof A&&t.node.type===e.schema.nodes.inlineImage?{pos:t.from,node:t.node}:null}setSelectedImageSize(e){return(t,n)=>{let r=this.getSelectedInlineImage(t);if(!r)return!1;let{naturalWidth:i}=r.node.attrs;if(e===`small`&&i===null)return!1;let a=t.tr;return a.setNodeAttribute(r.pos,`size`,e===`small`?this.calculateSmallWidth(i):e===`fit`?`100%`:null),n?.(a.scrollIntoView()),!0}}getSelectedImageSize(e){let t=this.getSelectedInlineImage(e);if(!t)return null;let{size:n,naturalWidth:r}=t.node.attrs;return r!==null&&n===this.calculateSmallWidth(r)?`small`:n===`100%`?`fit`:n===null?`original`:null}},xd=_.a(bd),Sd=async e=>{try{return{type:`ok`,result:await e}}catch(e){return{type:`error`,error:e}}},Cd=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteFileHandlerFeature`}getPlugins(e){let t=new N({state:{init(){return V.empty},apply(e,n){n=n.map(e.mapping,e.doc);let r=e.getMeta(t);if(r&&r.add){let t=document.createElement(`placeholder`),i=B.widget(r.add.pos,t,{id:r.add.id,relaxedSide:!0});n=n.add(e.doc,[i])}else r&&r.remove&&(n=n.remove(n.find(void 0,void 0,e=>e.id==r.remove.id)));return n}},props:{decorations(e){return this.getState(e)}}}),n=(e,n)=>{let r=u.n();return e.setMeta(t,{add:{id:r,pos:n}}),{getPos:e=>{let n=t.getState(e).find(void 0,void 0,e=>e.id==r);return n.length?n[0].from:null},remove:e=>{e.setMeta(t,{remove:{id:r}})}}},r=(t,n,r)=>{if(r.type===`selection`){let r=_.v.fromJSON(e.schema,{content:n});t.replaceSelection(r)}else{let i=_.d.fromJSON(e.schema,n);t.insert(r.pos,i)}},i=(e,t)=>{let n=this.config.handleFiles(e);n!==null&&(n instanceof Promise?o(n,t):a(n,t))},a=(t,n)=>{let i=e.state.tr;r(i,t,n),e.dispatchTransaction(i)},o=async(t,i)=>{let a=e.state.tr;i.type===`selection`&&!a.selection.empty&&a.deleteSelection();let o=i.type===`selection`?a.selection.from:i.pos,s=n(a,o);e.dispatchTransaction(a);let c=await Sd(t),l=s.getPos(e.state),u=e.state.tr;s.remove(u),l!==null&&c.type===`ok`&&r(u,c.result,{type:`pos`,pos:l}),e.dispatchTransaction(u),c.type===`error`&&console.error(`Error in handleFiles handler:`,c.error)};return[this.contribution(t),this.contribution(new N({props:{handlePaste:(e,t)=>{let n=Array.from(t.clipboardData.files);return n.length?(i(n,{type:`selection`}),!0):!1},handleDrop:(e,t)=>{let n=Array.from(t.dataTransfer.files);if(!n.length)return!1;let r=e.posAtCoords({left:t.clientX,top:t.clientY}).pos;if(e.dragging&&e.dragging.slice){let t=Ve(e.state.doc,r,e.dragging.slice);t!=null&&(r=t)}return i(n,{type:`pos`,pos:r}),!0}}}))]}},wd=_.a(Cd),Td=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteDebugFeature`}getPlugins(){let e=new WeakMap,t=!1,n=n=>{e.get(n)===void 0&&(t=this.config.onViewportDragOver?.(n)??!1)},r=e=>{this.config.onViewportDrop?.(e),this.config.onViewportDragFinish?.()},i=()=>{this.config.onViewportDragFinish?.()},a=!1,o=()=>{a=!0,window.setTimeout(()=>a=!1,0)},s=()=>{a||this.config.onViewportDragFinish?.()};return[this.contribution(new N({view:e=>{let t=e.root.host.editorViewportElement;return t.addEventListener(`dragover`,n),t.addEventListener(`drop`,r),t.addEventListener(`dragend`,i),t.addEventListener(`dragenter`,o),t.addEventListener(`dragleave`,s),{destroy(){t.removeEventListener(`dragover`,n),t.removeEventListener(`drop`,r),t.removeEventListener(`dragend`,i),t.removeEventListener(`dragenter`,o),t.removeEventListener(`dragleave`,s)}}}})),this.contribution(new N({props:{handleDOMEvents:{dragover:(n,r)=>{let i=this.config.onViewportDragOver?.(r)??!1;return e.set(r,i),t=i,i?(r.stopImmediatePropagation(),r.preventDefault(),!0):!1},drop:()=>t}}}),_.i.high)]}},Ed=_.a(Td),Dd=class extends _.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteToolbarButtonFeature[${e}]`}getToolbarItems(){return[this.contribution({section:`insert`,render:e=>$(e,{label:this.options.label,icon:this.options.icon,onClick:()=>{this.executeAction(e)}})},2+(this.options.order??0)/(2**53-1))]}executeAction(e){let{action:t}=this.options;switch(t.type){case`insert-text`:{let{state:n,dispatch:r}=e.view,{from:i,to:a}=n.selection;r(n.tr.insertText(t.text,i,a));break}}}},Od=_.a(Dd),kd=e=>typeof e==`object`&&!!e&&`next`in e,Ad=/^[a-zA-Z0-9-]+$/,jd=e=>e==null?{text:``,variant:[]}:typeof e==`string`?{text:e,variant:[]}:{text:e.text,variant:(e.variant??[]).filter(e=>Ad.test(e)?!0:(console.warn(`[rich-text-editor] Ignoring invalid atom variant "${e}".`),!1))},Md=(e,t)=>[`node--${e}`,...t.map(e=>`atom-variant--${e}`)].join(` `),Nd=class{constructor(e,t,n){this.atomName=n,this.dom=document.createElement(`span`),this.dom.className=`atom-wrapper`;let r=t.resolveValue?t.resolveValue(e.attrs.value):e.attrs.value;kd(r)?(this.render(null),this.handleResolvedGenerator(r)):this.render(r)}render(e){let{text:t,variant:n}=jd(e);this.dom.textContent!==t&&(this.dom.textContent=t);let r=Md(this.atomName,n);this.dom.getAttribute(`part`)!==r&&this.dom.setAttribute(`part`,r)}async handleResolvedGenerator(e){let t=e[Symbol.asyncIterator]();try{let e;do e=await t.next(),this.render(e.value??null);while(!e.done)}catch(e){this.render(null),console.warn(`[rich-text-editor] Error while resolving atom value:`,e)}}},Pd=class extends _.r{constructor(e,t={}){super(),this.atomName=e,this.config=t,this.name=`RteAtomFeature[${e}]`}getSchema(){let e={inline:!0,group:`inline`,selectable:!0,atom:!0,attrs:{value:{validate:`string`}},parseDOM:[{tag:`span[data-atom-type="${this.atomName}"][data-value]`,getAttrs:e=>({value:e.getAttribute(`data-value`)})}],toDOM:e=>{let t=this.config.serializeValueToHtml?this.config.serializeValueToHtml(e.attrs.value):e.attrs.value;return t===null?document.createDocumentFragment():[`span`,{part:Md(this.atomName,[])},t]},serializeToDOM:e=>{let t=this.config.serializeValueToHtml?this.config.serializeValueToHtml(e.attrs.value):e.attrs.value;return t===null?document.createTextNode(``):[`span`,{"data-atom-type":this.atomName,"data-value":e.attrs.value},t]}};return[this.contribution({nodes:{[this.atomName]:e}})]}getPlugins(e){return[this.contribution(new N({props:{nodeViews:{[this.atomName]:e=>new Nd(e,this.config,this.atomName)}}}))]}},Fd=_.a(Pd),Id=class extends _.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteInputRuleFeature[${e}]`}getInputRules(e){let t=`(?:${this.options.pattern.source})`,n=(t,n,r,i)=>{let a=this.options.handler(n);return a?t.tr.replaceWith(r,i,_.d.fromJSON(e.schema,a)):null},r={rule:new Vl(this.options.matchAfterWhitespace?RegExp(`${t} $`):RegExp(`${t}$`),n)};return this.options.matchAfterWhitespace&&(r.enterHandler={regex:RegExp(`${t}$`),handler:n}),[this.contribution(r)]}},Ld=_.a(Id);function Rd(e,t){return(n,r)=>e(t)}var zd=class extends _.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteKeyboardShortcutsFeature[${e}]`}getPlugins(e){let t={};for(let[n,r]of Object.entries(this.options.shortcuts))t[n]=Rd(r,e.facade);return[this.contribution(W(t),_.i.high)]}},Bd=_.a(zd),Vd=`.suggest-popover{flex-direction:column;gap:2px;max-block-size:408px;min-inline-size:128px;max-inline-size:248px;padding:4px;display:flex}.suggest-loading-widget{vertical-align:middle;white-space:normal;align-items:center;margin-inline-start:2px;display:inline-flex}.suggest-empty-message{color:var(--vvd-color-neutral-300);font:var(--vvd-typography-base);text-align:center;justify-content:center;align-items:center;min-block-size:40px;display:flex}`,Hd=e=>!!(e?.suggestions&&!e.dismissed),Ud=e=>Hd(e)&&e.suggestions.items.length>0;function Wd(e,t){let{$cursor:n}=e.selection;if(!n)return null;let r=ql(n),i=t.exec(r);if(!i)return null;let a=n.pos-n.parentOffset;return{text:i[0],groups:[...i],start:a+i.index,end:a+i.index+i[0].length}}var Gd=(e,t,n)=>{let{state:r}=e;e.dispatch(pl(r.tr));let i=e.state.tr;i.replaceWith(t.start,t.end,_.d.fromJSON(e.state.schema,n));let a=i.mapping.map(t.end);i.setSelection(k.create(i.doc,a)),e.dispatch(i.scrollIntoView())},Kd=class extends _.r{selectSuggestion(e,t,n){let r=this.options.select(n);Gd(e,t.match,r),e.focus()}async startLoadingSuggestions(e,t){let n=++this.loadGeneration,r=await this.options.load(e);n===this.loadGeneration&&t({type:`load`,generation:n,suggestions:r})}constructor(e,t){super(),this.featureId=e,this.options=t,this.pluginKey=new Dt(`suggest`),this.loadGeneration=0,this.name=`RteSuggestFeature[${e}]`}getStyles(){return[this.contribution(Vd)]}getPlugins(e){let t=t=>e.state.tr.setMeta(this.pluginKey,t),n=n=>e.dispatchTransaction(t(n)),r=new N({key:this.pluginKey,state:{init:()=>null,apply:(t,r,i,o)=>{let s=Wd(o,this.options.pattern);if(!s||!r&&!t.docChanged)return null;if(r?.dismissed)return r;let c=n=>n?r?.loadingDecoration.find().length??0?r.loadingDecoration.map(t.mapping,t.doc):V.create(t.doc,[B.widget(s.end,()=>{let t=document.createElement(`span`);t.className=`suggest-loading-widget`;let n=e.createComponent(a.r);return n.size=-6,t.appendChild(n),t},{ignoreSelection:!0,side:1})]):V.empty,l=t.getMeta(this.pluginKey);if(r&&l)switch(l.type){case`load`:return{...r,suggestions:{generation:l.generation,items:l.suggestions,selectedIndex:0,visibleFocus:!1},loadingDecoration:c(!1)};case`navigate`:{if(!r.suggestions?.items.length)return r;if(!r.suggestions.visibleFocus)return{...r,suggestions:{...r.suggestions,visibleFocus:!0}};let e=Math.max(0,Math.min(r.suggestions.items.length-1,r.suggestions.selectedIndex+(l.action===`up`?-1:1)));return{...r,suggestions:{...r.suggestions,selectedIndex:e}}}case`dismiss`:return{...r,dismissed:!0,loadingDecoration:V.empty}}if(!r)return this.startLoadingSuggestions(s.groups,n),{match:s,loadingDecoration:c(!0)};let u=s.groups[0]!==r.match.groups[0];return u&&this.startLoadingSuggestions(s.groups,n),{...r,match:s,suggestions:r.suggestions?{...r.suggestions,visibleFocus:!1}:void 0,loadingDecoration:c(u)}}},props:{decorations:e=>{let t=this.pluginKey.getState(e);return t?t.loadingDecoration.add(e.doc,[B.inline(t.match.start,t.match.end,{id:`suggest-anchor-${this.featureId}`})]):null}},view:t=>{let n=new Sl(t,e,{popupPlacement:`bottom`,shouldReturnFocusToEditor:!0}),r=e.createComponent(x);r.anchorId=`suggest-anchor-${this.featureId}`,r.kind=`autocomplete`,r.offset=4;let i=Cl(n,{className:`suggest-popover`,children:[]});r.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(r);let a=`${this.featureId}-suggestions-empty`,o=t.dom.getRootNode().host,s=!1,c=e=>{!s&&e&&_.t(o,`suggestions-empty-state`,a,{id:this.featureId}),s&&!e&&_.t(o,`suggestions-empty-state`,a,_.n),s=e},l=r=>{i.innerHTML=``;let o=r.suggestions,s=o.items.length===0;if(c(s),s){let t=document.createElement(`slot`);t.name=a,t.textContent=e.getLocale().richTextEditor.suggestNoResults,i.appendChild(Cl(n,{className:`suggest-empty-message`,children:[t]}));return}for(let[n,a]of o.items.entries()){let s=e.createComponent(f.t);s.text=a.text,s.textSecondary=a.textSecondary,n===o.selectedIndex&&(s.selected=!0,o.visibleFocus&&(s._highlighted=!0),queueMicrotask(()=>{s.scrollIntoView({block:`nearest`})})),s.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),this.selectSuggestion(t,r,a)}),i.appendChild(s)}};return{update:e=>{n.updateBindings();let t=this.pluginKey.getState(e.state),i=Hd(t);r.requestOpenState(i),i?l(t):c(!1)},destroy:()=>{c(!1),r.remove()}}}});return[this.contribution(r),this.contribution(W({ArrowUp:(e,n)=>Ud(this.pluginKey.getState(e))?(n?.(t({type:`navigate`,action:`up`})),!0):!1,ArrowDown:(e,n)=>Ud(this.pluginKey.getState(e))?(n?.(t({type:`navigate`,action:`down`})),!0):!1,Enter:(e,t,n)=>{let r=this.pluginKey.getState(e);if(!Ud(r))return!1;let i=r.suggestions.items[r.suggestions.selectedIndex];return n&&this.selectSuggestion(n,r,i),!0},Escape:(e,n)=>Hd(this.pluginKey.getState(e))?(n?.(t({type:`dismiss`})),!0):!1}),_.i.high)]}},qd=_.a(Kd),Jd=e=>e.textBetween(0,e.content.size,void 0,` `).length,Yd=class extends _.r{constructor(e){super(),this.config=e,this.name=`RteCharacterCountFeature`}getPlugins(){let e=this.config?.limit;return e===void 0?[]:[this.contribution(new N({filterTransaction:(t,n)=>{if(!t.docChanged)return!0;let r=Jd(n.doc),i=Jd(t.doc);if(i<=e)return!0;if(r>e)return i<=r;if(!t.getMeta(`paste`))return!1;let a=t.selection.$head.pos,o=a-(i-e),s=a;return t.deleteRange(o,s),Jd(t.doc)<=e}}))]}getPublicInterface(e){let t=this.config?.limit;return{get characters(){return Jd(e.state.doc)},get limit(){return t}}}},Xd=_.a(Yd),Zd=t.u(`rich-text-editor`,y,ne,[h.t,m.n,p.t,s.t,l.n,v.t,ee.t,d.n,ie,a.t],{styles:te,shadowOptions:{delegatesFocus:!0}});t.d(Zd)(),exports.RteAlignmentFeature=ld,exports.RteAtomFeature=Fd,exports.RteBase=Xl,exports.RteBoldFeature=Su,exports.RteCharacterCountFeature=Xd,exports.RteConfig=Jc,exports.RteDropHandlerFeature=Ed,exports.RteFileHandlerFeature=wd,exports.RteFontSizePickerFeature=lu,exports.RteHardBreakFeature=ou,exports.RteHtmlParser=Lc,exports.RteHtmlSerializer=Bc,exports.RteInlineImageFeature=xd,exports.RteInputRuleFeature=Ld,exports.RteItalicFeature=wu,exports.RteKeyboardShortcutsFeature=Bd,exports.RteLinkFeature=md,exports.RteListFeature=ad,exports.RteMonospaceFeature=ju,exports.RtePlaceholderFeature=iu,exports.RteStrikethroughFeature=Ou,exports.RteSuggestFeature=qd,exports.RteTextBlockPickerFeature=Ql,exports.RteTextColorPickerFeature=Fu,exports.RteToolbarButtonFeature=Od,exports.RteToolbarFeature=tu,exports.RteUnderlineFeature=Eu;