@vonage/vivid 5.16.0 → 5.18.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 (564) hide show
  1. package/accordion/definition.cjs +6 -6
  2. package/accordion/definition.js +1 -1
  3. package/accordion/index.cjs +1 -1
  4. package/accordion/index.js +2 -2
  5. package/accordion-item/definition.cjs +5 -5
  6. package/accordion-item/definition.js +1 -1
  7. package/accordion-item/index.cjs +1 -1
  8. package/accordion-item/index.js +2 -2
  9. package/action-group/index.cjs +3 -3
  10. package/action-group/index.js +5 -5
  11. package/alert/definition.cjs +5 -5
  12. package/alert/definition.js +1 -1
  13. package/alert/index.cjs +3 -3
  14. package/alert/index.js +15 -14
  15. package/audio-player/definition.cjs +5 -5
  16. package/audio-player/definition.js +1 -1
  17. package/audio-player/index.cjs +16 -16
  18. package/audio-player/index.js +29 -28
  19. package/avatar/definition.cjs +5 -5
  20. package/avatar/definition.js +1 -1
  21. package/avatar/index.cjs +4 -4
  22. package/avatar/index.js +12 -11
  23. package/badge/definition.cjs +5 -5
  24. package/badge/definition.js +1 -1
  25. package/badge/index.cjs +1 -4
  26. package/badge/index.js +4 -20
  27. package/banner/definition.cjs +5 -5
  28. package/banner/definition.js +1 -1
  29. package/banner/index.cjs +3 -3
  30. package/banner/index.js +14 -13
  31. package/breadcrumb-item/definition.cjs +4 -4
  32. package/breadcrumb-item/definition.js +1 -1
  33. package/breadcrumb-item/index.cjs +1 -1
  34. package/breadcrumb-item/index.js +1 -0
  35. package/bundled/affix.cjs +1 -1
  36. package/bundled/affix.js +5 -5
  37. package/bundled/base-color-picker.cjs +2 -2
  38. package/bundled/base-color-picker.js +5 -5
  39. package/bundled/button.cjs +1 -1
  40. package/bundled/button.js +2 -2
  41. package/bundled/calendar-picker.template.cjs +2 -2
  42. package/bundled/calendar-picker.template.js +498 -498
  43. package/bundled/definition10.cjs +18 -30
  44. package/bundled/definition10.js +53 -155
  45. package/bundled/definition11.cjs +10 -19
  46. package/bundled/definition11.js +25 -74
  47. package/bundled/definition12.cjs +72 -18
  48. package/bundled/definition12.js +171 -107
  49. package/bundled/definition13.cjs +18 -17
  50. package/bundled/definition13.js +46 -66
  51. package/bundled/definition14.cjs +5 -10
  52. package/bundled/definition14.js +9 -27
  53. package/bundled/definition15.cjs +17 -71
  54. package/bundled/definition15.js +64 -181
  55. package/bundled/definition16.cjs +12 -4
  56. package/bundled/definition16.js +79 -14
  57. package/bundled/definition17.cjs +19 -13
  58. package/bundled/definition17.js +118 -69
  59. package/bundled/definition18.cjs +87 -12
  60. package/bundled/definition18.js +409 -52
  61. package/bundled/definition19.cjs +5 -87
  62. package/bundled/definition19.js +14 -422
  63. package/bundled/definition2.cjs +3 -14
  64. package/bundled/definition2.js +16 -49
  65. package/bundled/definition20.cjs +30 -5
  66. package/bundled/definition20.js +159 -9
  67. package/bundled/definition21.cjs +28 -19
  68. package/bundled/definition21.js +164 -47
  69. package/bundled/definition22.cjs +4 -24
  70. package/bundled/definition22.js +18 -88
  71. package/bundled/definition23.cjs +12 -0
  72. package/bundled/definition23.js +37 -0
  73. package/bundled/definition24.cjs +39 -0
  74. package/bundled/definition24.js +72 -0
  75. package/bundled/definition3.cjs +1 -1
  76. package/bundled/definition3.js +24 -21
  77. package/bundled/definition4.cjs +23 -38
  78. package/bundled/definition4.js +81 -63
  79. package/bundled/definition5.cjs +2 -2
  80. package/bundled/definition5.js +5 -5
  81. package/bundled/definition6.cjs +11 -11
  82. package/bundled/definition6.js +57 -41
  83. package/bundled/definition9.cjs +12 -30
  84. package/bundled/definition9.js +55 -148
  85. package/bundled/divider.cjs +1 -1
  86. package/bundled/divider.js +5 -5
  87. package/bundled/listbox.cjs +1 -1
  88. package/bundled/listbox.js +1 -1
  89. package/bundled/localized.cjs +1 -1
  90. package/bundled/localized.js +1 -0
  91. package/bundled/mixins.cjs +5 -5
  92. package/bundled/mixins.js +49 -49
  93. package/bundled/numberConverter.cjs +12 -0
  94. package/bundled/numberConverter.js +38 -0
  95. package/bundled/picker-field.template.cjs +8 -7
  96. package/bundled/picker-field.template.js +16 -15
  97. package/bundled/slider.template.cjs +7 -7
  98. package/bundled/slider.template.js +12 -12
  99. package/bundled/slottable-request.cjs +1 -1
  100. package/bundled/slottable-request.js +8 -38
  101. package/bundled/time-selection-picker.template.cjs +4 -4
  102. package/bundled/time-selection-picker.template.js +35 -35
  103. package/bundled/utils.cjs +1 -0
  104. package/bundled/utils.js +1420 -0
  105. package/bundled/vivid-element.cjs +1 -1
  106. package/bundled/vivid-element.js +1 -1
  107. package/button/definition.cjs +5 -5
  108. package/button/definition.js +1 -1
  109. package/button/index.cjs +1 -1
  110. package/button/index.js +1 -1
  111. package/calendar/index.cjs +11 -11
  112. package/calendar/index.js +30 -237
  113. package/calendar-event/index.cjs +3 -3
  114. package/calendar-event/index.js +4 -4
  115. package/card/definition.cjs +5 -5
  116. package/card/definition.js +1 -1
  117. package/card/index.cjs +15 -12
  118. package/card/index.js +17 -13
  119. package/checkbox/definition.cjs +5 -5
  120. package/checkbox/definition.js +1 -1
  121. package/checkbox/index.cjs +1 -1
  122. package/checkbox/index.js +2 -2
  123. package/color-picker/definition.cjs +5 -5
  124. package/color-picker/definition.js +2 -2
  125. package/color-picker/index.cjs +10 -10
  126. package/color-picker/index.js +58 -57
  127. package/combobox/definition.cjs +5 -5
  128. package/combobox/definition.js +2 -2
  129. package/combobox/index.cjs +9 -8
  130. package/combobox/index.js +40 -35
  131. package/contextual-help/definition.cjs +5 -5
  132. package/contextual-help/definition.js +2 -2
  133. package/contextual-help/index.cjs +1 -1
  134. package/contextual-help/index.js +2 -2
  135. package/country/definition.cjs +5 -5
  136. package/country/definition.js +1 -1
  137. package/country/index.cjs +1 -12
  138. package/country/index.js +4 -1216
  139. package/country-group/definition.cjs +6 -0
  140. package/country-group/definition.js +3 -0
  141. package/country-group/index.cjs +43 -0
  142. package/country-group/index.js +166 -0
  143. package/custom-elements.json +1274 -200
  144. package/data-grid/definition.cjs +9 -9
  145. package/data-grid/definition.js +2 -2
  146. package/data-grid/index.cjs +18 -18
  147. package/data-grid/index.js +260 -262
  148. package/date-picker/definition.cjs +5 -5
  149. package/date-picker/definition.js +2 -2
  150. package/date-picker/index.cjs +1 -1
  151. package/date-picker/index.js +13 -13
  152. package/date-range-picker/definition.cjs +5 -5
  153. package/date-range-picker/definition.js +2 -2
  154. package/date-range-picker/index.cjs +1 -1
  155. package/date-range-picker/index.js +8 -8
  156. package/date-time-picker/definition.cjs +5 -5
  157. package/date-time-picker/definition.js +2 -2
  158. package/date-time-picker/index.cjs +4 -4
  159. package/date-time-picker/index.js +25 -25
  160. package/dial-pad/definition.cjs +5 -5
  161. package/dial-pad/definition.js +2 -2
  162. package/dial-pad/index.cjs +6 -5
  163. package/dial-pad/index.js +14 -12
  164. package/dialog/definition.cjs +5 -5
  165. package/dialog/definition.js +2 -2
  166. package/dialog/index.cjs +6 -6
  167. package/dialog/index.js +17 -16
  168. package/divider/definition.cjs +1 -1
  169. package/divider/definition.js +1 -1
  170. package/divider/index.cjs +1 -1
  171. package/divider/index.js +1 -1
  172. package/empty-state/definition.cjs +5 -5
  173. package/empty-state/definition.js +2 -2
  174. package/empty-state/index.cjs +2 -2
  175. package/empty-state/index.js +6 -5
  176. package/fab/definition.cjs +5 -5
  177. package/fab/definition.js +2 -2
  178. package/fab/index.cjs +4 -4
  179. package/fab/index.js +13 -12
  180. package/file-picker/definition.cjs +5 -5
  181. package/file-picker/definition.js +2 -2
  182. package/file-picker/index.cjs +20 -17
  183. package/file-picker/index.js +40 -36
  184. package/flag/definition.cjs +6 -0
  185. package/flag/definition.js +3 -0
  186. package/flag/index.cjs +10 -0
  187. package/flag/index.js +61 -0
  188. package/header/definition.cjs +1 -1
  189. package/header/definition.js +1 -1
  190. package/header/index.cjs +4 -4
  191. package/header/index.js +5 -5
  192. package/icon/definition.cjs +1 -0
  193. package/icon/definition.js +1 -0
  194. package/icon/index.cjs +1 -1
  195. package/icon/index.js +1 -0
  196. package/index.cjs +204 -192
  197. package/index.js +55 -52
  198. package/layout/definition.cjs +1 -1
  199. package/layout/definition.js +1 -1
  200. package/lib/button/button.d.ts +1 -0
  201. package/lib/combobox/combobox.d.ts +0 -3
  202. package/lib/components.d.ts +2 -0
  203. package/lib/country/countries-data.d.ts +1 -0
  204. package/lib/country/{country-code-to-flag-icon.d.ts → utils.d.ts} +0 -3
  205. package/lib/country-group/country-group.d.ts +829 -0
  206. package/lib/country-group/country-group.template.d.ts +3 -0
  207. package/lib/country-group/definition.d.ts +3 -0
  208. package/lib/country-group/index.d.ts +1 -0
  209. package/lib/country-group/locale.d.ts +3 -0
  210. package/lib/date-picker/date-picker.d.ts +4 -0
  211. package/lib/date-range-picker/date-range-picker.d.ts +2 -0
  212. package/lib/date-time-picker/date-time-picker.d.ts +4 -4
  213. package/lib/dial-pad/dial-pad.d.ts +6 -2
  214. package/lib/dialog/dialog.d.ts +0 -1
  215. package/lib/flag/definition.d.ts +3 -0
  216. package/lib/flag/flag.d.ts +8 -0
  217. package/lib/flag/flag.template.d.ts +3 -0
  218. package/lib/flag/index.d.ts +1 -0
  219. package/lib/icon/icon.d.ts +1 -2
  220. package/lib/menu/menu.d.ts +0 -1
  221. package/lib/option/option.d.ts +0 -1
  222. package/lib/rich-text-editor/rte/exports.d.ts +1 -0
  223. package/lib/rich-text-editor/rte/features/alignment.d.ts +1 -1
  224. package/lib/rich-text-editor/rte/features/character-count.d.ts +21 -0
  225. package/lib/rich-text-editor/rte/features/font-size-picker.d.ts +1 -1
  226. package/lib/rich-text-editor/rte/features/internal/basic-text-blocks.d.ts +1 -1
  227. package/lib/rich-text-editor/rte/features/keyboard-shortcuts.d.ts +1 -1
  228. package/lib/rich-text-editor/rte/features/text-color-picker.d.ts +1 -1
  229. package/lib/rich-text-editor/rte/public-interface.d.ts +6 -0
  230. package/lib/searchable-select/option-tag.d.ts +3 -2
  231. package/lib/searchable-select/searchable-select.d.ts +3 -1
  232. package/lib/table/definition.d.ts +2 -1
  233. package/lib/table/table-header-cell.d.ts +3 -0
  234. package/lib/table/table-sorting-button.d.ts +415 -0
  235. package/lib/table/table-sorting-button.template.d.ts +3 -0
  236. package/lib/tag-name-map.d.ts +2 -1
  237. package/lib/time-picker/time-picker.d.ts +2 -0
  238. package/locales/de-DE.cjs +5 -178
  239. package/locales/de-DE.js +3 -179
  240. package/locales/en-GB.cjs +5 -9
  241. package/locales/en-GB.js +3 -10
  242. package/locales/en-US.cjs +269 -2
  243. package/locales/en-US.js +266 -1
  244. package/locales/ja-JP.cjs +5 -171
  245. package/locales/ja-JP.js +3 -172
  246. package/locales/zh-CN.cjs +5 -172
  247. package/locales/zh-CN.js +3 -173
  248. package/menu/definition.cjs +5 -5
  249. package/menu/definition.js +1 -1
  250. package/menu/index.cjs +1 -1
  251. package/menu/index.js +2 -2
  252. package/menu-item/definition.cjs +6 -6
  253. package/menu-item/definition.js +1 -1
  254. package/menu-item/index.cjs +1 -1
  255. package/menu-item/index.js +2 -2
  256. package/nav/definition.cjs +1 -1
  257. package/nav/definition.js +1 -1
  258. package/nav-disclosure/definition.cjs +5 -5
  259. package/nav-disclosure/definition.js +2 -2
  260. package/nav-disclosure/index.cjs +4 -4
  261. package/nav-disclosure/index.js +13 -12
  262. package/nav-item/definition.cjs +5 -5
  263. package/nav-item/definition.js +2 -2
  264. package/nav-item/index.cjs +2 -2
  265. package/nav-item/index.js +12 -11
  266. package/note/definition.cjs +5 -5
  267. package/note/definition.js +2 -2
  268. package/note/index.cjs +3 -3
  269. package/note/index.js +11 -10
  270. package/number-field/definition.cjs +5 -5
  271. package/number-field/definition.js +2 -2
  272. package/number-field/index.cjs +4 -4
  273. package/number-field/index.js +29 -28
  274. package/option/definition.cjs +5 -5
  275. package/option/definition.js +2 -2
  276. package/option/index.cjs +1 -1
  277. package/option/index.js +2 -2
  278. package/package.json +9 -10
  279. package/pagination/definition.cjs +5 -5
  280. package/pagination/definition.js +2 -2
  281. package/pagination/index.cjs +3 -3
  282. package/pagination/index.js +16 -16
  283. package/popover/definition.cjs +5 -5
  284. package/popover/definition.js +2 -2
  285. package/popover/index.cjs +7 -7
  286. package/popover/index.js +12 -11
  287. package/popup/definition.cjs +4 -4
  288. package/popup/definition.js +1 -1
  289. package/popup/index.cjs +1 -1
  290. package/popup/index.js +1 -1
  291. package/progress/definition.cjs +1 -1
  292. package/progress/definition.js +1 -1
  293. package/progress/index.cjs +2 -2
  294. package/progress/index.js +5 -5
  295. package/radio/definition.cjs +1 -1
  296. package/radio/definition.js +1 -1
  297. package/radio/index.cjs +1 -1
  298. package/radio/index.js +1 -1
  299. package/radio-group/definition.cjs +5 -5
  300. package/radio-group/definition.js +2 -2
  301. package/radio-group/index.cjs +4 -4
  302. package/radio-group/index.js +11 -11
  303. package/range-slider/definition.cjs +5 -5
  304. package/range-slider/definition.js +2 -2
  305. package/range-slider/index.cjs +4 -4
  306. package/range-slider/index.js +39 -36
  307. package/rich-text-editor/definition.cjs +32 -31
  308. package/rich-text-editor/definition.js +3 -3
  309. package/rich-text-editor/index.cjs +13 -13
  310. package/rich-text-editor/index.js +1887 -1830
  311. package/rich-text-view/definition.cjs +1 -1
  312. package/rich-text-view/definition.js +1 -1
  313. package/rich-text-view/index.cjs +1 -1
  314. package/rich-text-view/index.js +8 -8
  315. package/searchable-select/definition.cjs +4 -4
  316. package/searchable-select/definition.js +2 -2
  317. package/searchable-select/index.cjs +15 -13
  318. package/searchable-select/index.js +75 -72
  319. package/select/definition.cjs +5 -5
  320. package/select/definition.js +2 -2
  321. package/select/index.cjs +1 -1
  322. package/select/index.js +2 -2
  323. package/selectable-box/definition.cjs +5 -5
  324. package/selectable-box/definition.js +2 -2
  325. package/selectable-box/index.cjs +7 -7
  326. package/selectable-box/index.js +12 -12
  327. package/shared/foundation/test-utilities/fixture.d.ts +1 -1
  328. package/shared/icon/utils.d.ts +1 -0
  329. package/shared/localization/Locale.d.ts +2 -0
  330. package/shared/patterns/linkable.d.ts +1 -1
  331. package/shared/picker-field/mixins/calendar-picker.d.ts +1 -0
  332. package/shared/picker-field/mixins/calendar-picker.template.d.ts +1 -0
  333. package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +1 -0
  334. package/shared/picker-field/mixins/single-date-picker.d.ts +1 -0
  335. package/shared/picker-field/mixins/single-value-picker.d.ts +1 -0
  336. package/shared/picker-field/mixins/time-selection-picker.d.ts +1 -0
  337. package/shared/picker-field/mixins/time-selection-picker.template.d.ts +2 -0
  338. package/shared/picker-field/picker-field.d.ts +2 -0
  339. package/side-drawer/definition.cjs +1 -1
  340. package/side-drawer/definition.js +1 -1
  341. package/simple-color-picker/definition.cjs +5 -5
  342. package/simple-color-picker/definition.js +2 -2
  343. package/simple-color-picker/index.cjs +3 -3
  344. package/simple-color-picker/index.js +15 -14
  345. package/slider/definition.cjs +5 -5
  346. package/slider/definition.js +1 -1
  347. package/slider/index.cjs +1 -1
  348. package/slider/index.js +1 -1
  349. package/split-button/definition.cjs +5 -5
  350. package/split-button/definition.js +2 -2
  351. package/split-button/index.cjs +6 -6
  352. package/split-button/index.js +17 -16
  353. package/status/definition.cjs +5 -5
  354. package/status/definition.js +2 -2
  355. package/status/index.cjs +2 -2
  356. package/status/index.js +11 -10
  357. package/switch/definition.cjs +5 -5
  358. package/switch/definition.js +2 -2
  359. package/switch/index.cjs +4 -4
  360. package/switch/index.js +11 -10
  361. package/tab/definition.cjs +5 -5
  362. package/tab/definition.js +2 -2
  363. package/tab/index.cjs +1 -1
  364. package/tab/index.js +2 -2
  365. package/tab-panel/definition.cjs +1 -1
  366. package/tab-panel/definition.js +1 -1
  367. package/tab-panel/index.cjs +1 -1
  368. package/tab-panel/index.js +1 -1
  369. package/table/definition.cjs +4 -1
  370. package/table/definition.js +3 -2
  371. package/table/index.cjs +19 -10
  372. package/table/index.js +70 -21
  373. package/tabs/definition.cjs +6 -6
  374. package/tabs/definition.js +2 -2
  375. package/tabs/index.cjs +2 -2
  376. package/tabs/index.js +5 -5
  377. package/tag/definition.cjs +5 -5
  378. package/tag/definition.js +2 -2
  379. package/tag/index.cjs +8 -8
  380. package/tag/index.js +14 -13
  381. package/tag-group/definition.cjs +1 -1
  382. package/tag-group/definition.js +1 -1
  383. package/tag-group/index.cjs +3 -3
  384. package/tag-group/index.js +5 -5
  385. package/text-area/definition.cjs +5 -5
  386. package/text-area/definition.js +2 -2
  387. package/text-area/index.cjs +2 -2
  388. package/text-area/index.js +13 -13
  389. package/text-field/definition.cjs +5 -5
  390. package/text-field/definition.js +2 -2
  391. package/text-field/index.cjs +1 -1
  392. package/text-field/index.js +2 -2
  393. package/time-picker/definition.cjs +4 -4
  394. package/time-picker/definition.js +2 -2
  395. package/time-picker/index.cjs +1 -1
  396. package/time-picker/index.js +2 -2
  397. package/toggletip/definition.cjs +5 -5
  398. package/toggletip/definition.js +2 -2
  399. package/toggletip/index.cjs +1 -1
  400. package/toggletip/index.js +2 -2
  401. package/tooltip/definition.cjs +5 -5
  402. package/tooltip/definition.js +2 -2
  403. package/tooltip/index.cjs +1 -1
  404. package/tooltip/index.js +2 -2
  405. package/tree-item/definition.cjs +5 -5
  406. package/tree-item/definition.js +2 -2
  407. package/tree-item/index.cjs +1 -1
  408. package/tree-item/index.js +2 -2
  409. package/tree-view/definition.cjs +5 -5
  410. package/tree-view/definition.js +2 -2
  411. package/tree-view/index.cjs +3 -3
  412. package/tree-view/index.js +18 -18
  413. package/unbundled/button.cjs +2 -2
  414. package/unbundled/button.js +2 -2
  415. package/unbundled/calendar-picker.template.cjs +4347 -9
  416. package/unbundled/calendar-picker.template.js +4345 -7
  417. package/unbundled/chunk.cjs +0 -22
  418. package/unbundled/definition11.cjs +6 -0
  419. package/unbundled/definition11.js +6 -0
  420. package/unbundled/definition13.cjs +1 -8
  421. package/unbundled/definition13.js +1 -8
  422. package/unbundled/definition14.cjs +3 -2
  423. package/unbundled/definition14.js +3 -2
  424. package/unbundled/definition2.cjs +5 -75
  425. package/unbundled/definition2.js +1 -71
  426. package/unbundled/definition21.cjs +1 -2
  427. package/unbundled/definition21.js +1 -2
  428. package/unbundled/definition22.cjs +7 -2
  429. package/unbundled/definition22.js +7 -2
  430. package/unbundled/definition24.cjs +98 -979
  431. package/unbundled/definition24.js +93 -974
  432. package/unbundled/definition25.cjs +37 -322
  433. package/unbundled/definition25.js +33 -318
  434. package/unbundled/definition26.cjs +317 -91
  435. package/unbundled/definition26.js +313 -87
  436. package/unbundled/definition27.cjs +94 -192
  437. package/unbundled/definition27.js +91 -183
  438. package/unbundled/definition28.cjs +388 -395
  439. package/unbundled/definition28.js +388 -395
  440. package/unbundled/definition29.cjs +189 -110
  441. package/unbundled/definition29.js +180 -107
  442. package/unbundled/definition30.cjs +520 -36
  443. package/unbundled/definition30.js +519 -35
  444. package/unbundled/definition31.cjs +2 -1189
  445. package/unbundled/definition31.js +1 -1188
  446. package/unbundled/definition32.cjs +207 -1835
  447. package/unbundled/definition32.js +203 -1807
  448. package/unbundled/definition33.cjs +85 -228
  449. package/unbundled/definition33.js +82 -165
  450. package/unbundled/definition34.cjs +1887 -25
  451. package/unbundled/definition34.js +1857 -24
  452. package/unbundled/definition35.cjs +315 -121
  453. package/unbundled/definition35.js +236 -114
  454. package/unbundled/definition36.cjs +25 -405
  455. package/unbundled/definition36.js +22 -397
  456. package/unbundled/definition37.cjs +49 -140
  457. package/unbundled/definition37.js +46 -137
  458. package/unbundled/definition38.cjs +346 -329
  459. package/unbundled/definition38.js +343 -326
  460. package/unbundled/definition39.cjs +183 -234
  461. package/unbundled/definition39.js +181 -232
  462. package/unbundled/definition40.cjs +377 -47
  463. package/unbundled/definition40.js +372 -42
  464. package/unbundled/definition41.cjs +256 -57
  465. package/unbundled/definition41.js +255 -56
  466. package/unbundled/definition42.cjs +45 -421
  467. package/unbundled/definition42.js +41 -417
  468. package/unbundled/definition43.cjs +63 -49
  469. package/unbundled/definition43.js +61 -47
  470. package/unbundled/definition44.cjs +438 -30
  471. package/unbundled/definition44.js +434 -25
  472. package/unbundled/definition45.cjs +46 -84
  473. package/unbundled/definition45.js +43 -81
  474. package/unbundled/definition46.cjs +29 -54
  475. package/unbundled/definition46.js +24 -50
  476. package/unbundled/definition47.cjs +93 -21
  477. package/unbundled/definition47.js +91 -16
  478. package/unbundled/definition48.cjs +49 -33
  479. package/unbundled/definition48.js +46 -30
  480. package/unbundled/definition49.cjs +22 -347
  481. package/unbundled/definition49.js +16 -344
  482. package/unbundled/definition50.cjs +34 -211
  483. package/unbundled/definition50.js +30 -207
  484. package/unbundled/definition51.cjs +282 -242
  485. package/unbundled/definition51.js +275 -235
  486. package/unbundled/definition52.cjs +211 -51
  487. package/unbundled/definition52.js +209 -48
  488. package/unbundled/definition53.cjs +275 -131
  489. package/unbundled/definition53.js +272 -127
  490. package/unbundled/definition54.cjs +50 -261
  491. package/unbundled/definition54.js +48 -260
  492. package/unbundled/definition55.cjs +126 -443
  493. package/unbundled/definition55.js +123 -441
  494. package/unbundled/definition56.cjs +238 -12669
  495. package/unbundled/definition56.js +232 -12506
  496. package/unbundled/definition57.cjs +408 -729
  497. package/unbundled/definition57.js +406 -727
  498. package/unbundled/definition58.cjs +3619 -106
  499. package/unbundled/definition58.js +3449 -99
  500. package/unbundled/definition59.cjs +625 -868
  501. package/unbundled/definition59.js +620 -863
  502. package/unbundled/definition60.cjs +106 -108
  503. package/unbundled/definition60.js +102 -104
  504. package/unbundled/definition61.cjs +1040 -71
  505. package/unbundled/definition61.js +1035 -65
  506. package/unbundled/definition62.cjs +105 -169
  507. package/unbundled/definition62.js +101 -165
  508. package/unbundled/definition63.cjs +70 -113
  509. package/unbundled/definition63.js +65 -109
  510. package/unbundled/definition64.cjs +181 -53
  511. package/unbundled/definition64.js +178 -50
  512. package/unbundled/definition65.cjs +109 -76
  513. package/unbundled/definition65.js +109 -75
  514. package/unbundled/definition66.cjs +58 -21
  515. package/unbundled/definition66.js +55 -15
  516. package/unbundled/definition67.cjs +81 -74
  517. package/unbundled/definition67.js +79 -73
  518. package/unbundled/definition68.cjs +19 -344
  519. package/unbundled/definition68.js +14 -335
  520. package/unbundled/definition69.cjs +88 -26
  521. package/unbundled/definition69.js +85 -22
  522. package/unbundled/definition7.cjs +18 -3
  523. package/unbundled/definition7.js +18 -3
  524. package/unbundled/definition70.cjs +330 -111
  525. package/unbundled/definition70.js +320 -108
  526. package/unbundled/definition71.cjs +26 -271
  527. package/unbundled/definition71.js +21 -267
  528. package/unbundled/definition72.cjs +134 -28
  529. package/unbundled/definition72.js +125 -26
  530. package/unbundled/definition73.cjs +245 -113
  531. package/unbundled/definition73.js +242 -104
  532. package/unbundled/definition74.cjs +28 -212
  533. package/unbundled/definition74.js +26 -202
  534. package/unbundled/definition75.cjs +120 -52190
  535. package/unbundled/definition75.js +112 -52188
  536. package/unbundled/definition76.cjs +232 -0
  537. package/unbundled/definition76.js +213 -0
  538. package/unbundled/definition77.cjs +533 -0
  539. package/unbundled/definition77.js +513 -0
  540. package/unbundled/listbox.cjs +1 -1
  541. package/unbundled/listbox.js +1 -1
  542. package/unbundled/localized.cjs +2 -2
  543. package/unbundled/localized.js +1 -1
  544. package/unbundled/numberConverter.cjs +91 -0
  545. package/unbundled/numberConverter.js +74 -0
  546. package/unbundled/picker-field.template.cjs +3 -1
  547. package/unbundled/picker-field.template.js +3 -1
  548. package/unbundled/slottable-request.cjs +2 -3168
  549. package/unbundled/slottable-request.js +3 -3097
  550. package/unbundled/time-selection-picker.template.cjs +1 -1
  551. package/unbundled/time-selection-picker.template.js +1 -1
  552. package/unbundled/utils.cjs +1439 -0
  553. package/unbundled/utils.js +1428 -0
  554. package/unbundled/vivid-element.cjs +1 -1
  555. package/unbundled/vivid-element.js +1 -1
  556. package/video-player/definition.cjs +1 -1
  557. package/video-player/definition.js +1 -1
  558. package/video-player/index.cjs +3 -3
  559. package/video-player/index.js +9 -9
  560. package/vivid.api.json +860 -409
  561. package/unbundled/chunk.js +0 -33
  562. package/unbundled/en-US.cjs +0 -447
  563. package/unbundled/en-US.js +0 -443
  564. /package/{lib/icon/icon.placeholder.d.ts → shared/icon/icon-placeholder.d.ts} +0 -0
@@ -1,11 +1,4 @@
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`);require(`../bundled/definition2.cjs`);const 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/definition10.cjs`),l=require(`../bundled/divider.cjs`),u=require(`../bundled/mixins.cjs`),d=require(`../bundled/definition12.cjs`),f=require(`../bundled/definition15.cjs`),p=require(`../bundled/definition16.cjs`),m=require(`../bundled/slottable-request.cjs`),h=require(`../bundled/definition18.cjs`),g=require(`../bundled/definition19.cjs`);var ee=`:host{flex-direction:column;display:flex}.rte{flex-direction:column;block-size:100%;min-block-size:0;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{--editor-padding-inline:var(--rich-text-editor-padding-inline,16px);--editor-padding-block:var(--rich-text-editor-padding-block,8px);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}`,te=65535,_=2**16;function v(e,t){return e+t*_}function y(e){return e&te}function ne(e){return(e-(e&te))/_}var re=1,ie=2,ae=4,oe=8,b=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&oe)>0}get deletedBefore(){return(this.delInfo&(re|ae))>0}get deletedAfter(){return(this.delInfo&(ie|ae))>0}get deletedAcross(){return(this.delInfo&ae)>0}},se=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=y(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+ne(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:v(o/3,e-s),f=e==s?ie:e==u?re:ae;return(t<0?e!=s:e!=u)&&(f|=oe),new b(a,f,d)}r+=l-c}return n?e+r:new b(e+r,0,null)}touches(e,t){let n=0,r=y(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])}};se.empty=new se([]);var ce=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 b(e,r,null)}},le=Object.create(null),x=class{getMap(){return se.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=le[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in le)throw RangeError(`Duplicate use of step JSON ID `+e);return le[e]=t,t.prototype.jsonID=e,t}},S=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 m.v)return e.fail(t.message);throw t}}};function ue(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(ue(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return m.p.fromArray(r)}var de=class e extends x{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 m.b(ue(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 S.fromReplace(e,this.from,this.to,i)}invert(){return new fe(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))}};x.jsonID(`addMark`,de);var fe=class e extends x{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 m.b(ue(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return S.fromReplace(e,this.from,this.to,n)}invert(){return new de(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))}};x.jsonID(`removeMark`,fe);var pe=class e extends x{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return S.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return S.fromReplace(e,this.pos,this.pos+1,new m.b(m.p.from(n),0,t.isLeaf?0:1))}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 C(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))}};x.jsonID(`addNodeMark`,pe);var C=class e extends x{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return S.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return S.fromReplace(e,this.pos,this.pos+1,new m.b(m.p.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new pe(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))}};x.jsonID(`removeNodeMark`,C);var me=class e extends x{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&he(e,this.from,this.to)?S.fail(`Structure replace would overwrite content`):S.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new se([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.from,1),r=t.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new e(n.pos,Math.max(n.pos,r.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?m.b.empty:new m.b(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?m.b.empty:new m.b(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,m.b.fromJSON(t,n.slice),!!n.structure)}};x.jsonID(`replace`,me);var w=class e extends x{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&&(he(e,this.from,this.gapFrom)||he(e,this.gapTo,this.to)))return S.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return S.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?S.fromReplace(e,this.from,this.to,n):S.fail(`Content does not fit in gap`)}getMap(){return new se([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,m.b.fromJSON(t,n.slice),n.insert,!!n.structure)}};x.jsonID(`replaceAround`,w);function he(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 T(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 fe(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new de(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function ge(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 m.h){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 fe(t.from,t.to,t.style)))}function _e(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 me(s,l,m.b.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new fe(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 m.b(m.p.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new me(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(m.p.empty,!0);e.replace(s,s,new m.b(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function ve(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function ye(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||!ve(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function be(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=m.p.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=m.p.from(r.node(e).copy(u)),d++):c--;let f=m.p.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=m.p.from(i.node(e).copy(f)),p++):l++;e.step(new w(c,l,o,s,new m.b(u.append(f),d,p),u.size-d,!0))}function xe(e,t,n){let r=m.p.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=m.p.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new w(i,a,i,a,new m.b(r,0,0),n.length,!0))}function Se(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)&&Te(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&&we(e,t,n,a),_e(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 w(c,l,c+1,l-1,new m.b(m.p.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Ce(e,t,n,a),!1}})}function Ce(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 we(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(`
2
- `))}})}function Te(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Ee(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 w(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new m.b(m.p.from(o),0,0),1,!0))}function De(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 Oe(e,t,n=1,r){let i=e.doc.resolve(t),a=m.p.empty,o=m.p.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=m.p.from(i.node(e).copy(a));let t=r&&r[s];o=m.p.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new me(t,t,new m.b(a.append(o),n,n),!0))}function ke(e,t){let n=e.resolve(t),r=n.index();return je(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Ae(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 je(e,t){return!!(e&&t&&!e.isLeaf&&Ae(e,t))}function Me(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);we(e,r.node(),r.before(),s)}o.inlineContent&&_e(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 me(l,c.map(t+n,-1),m.b.empty,!0)),r===!0){let t=e.doc.resolve(l);Ce(e,t.node(),t.before(),e.steps.length)}return e}function Ne(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 Pe(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?1: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 Fe(e,t,n=t,r=m.b.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return Ie(i,a,r)?new me(t,n,r):new Le(i,a,r).fit()}function Ie(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var Le=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=m.p.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=m.p.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 m.b(i,a,o);return e>-1?new w(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new me(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=Be(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(m.p.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=Be(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new m.b(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=Be(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new m.b(Re(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new m.b(Re(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(Ve(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=ze(this.placed,t,m.p.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?m.b.empty:new m.b(Re(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new m.b(Re(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||!He(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=He(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=He(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=ze(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=ze(this.placed,this.depth,m.p.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(m.p.empty,!0);e.childCount&&(this.placed=ze(this.placed,this.frontier.length,e))}};function Re(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Re(e.firstChild.content,t-1,n)))}function ze(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(ze(e.lastChild.content,t-1,n)))}function Be(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Ve(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Ve(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(m.p.empty,!0)))),e.copy(r)}function He(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&&!Ue(n,a.content,o)?s:null}function Ue(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function We(e){return e.spec.defining||e.spec.definingForContent}function Ge(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(Ie(i,a,r))return e.step(new me(t,n,r));let o=Ye(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=We(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 m.b(Ke(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 Ke(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(Ke(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(m.p.empty,!0))}return e}function qe(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Ne(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new m.b(m.p.from(r),0,0))}function Je(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),a=Ye(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 Ye(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 Xe=class e extends x{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 S.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 S.fromReplace(e,this.pos,this.pos+1,new m.b(m.p.from(r),0,t.isLeaf?0:1))}getMap(){return se.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)}};x.jsonID(`attr`,Xe);var Ze=class e extends x{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 S.ok(n)}getMap(){return se.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)}};x.jsonID(`docAttr`,Ze);var Qe=class extends Error{};Qe=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},Qe.prototype=Object.create(Error.prototype),Qe.prototype.constructor=Qe,Qe.prototype.name=`TransformError`;var $e=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ce}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Qe(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=m.b.empty){let r=Fe(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new m.b(m.p.from(n),0,0))}delete(e,t){return this.replace(e,t,m.b.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Ge(this,e,t,n),this}replaceRangeWith(e,t,n){return qe(this,e,t,n),this}deleteRange(e,t){return Je(this,e,t),this}lift(e,t){return be(this,e,t),this}join(e,t=1){return Me(this,e,t),this}wrap(e,t){return xe(this,e,t),this}setBlockType(e,t=e,n,r=null){return Se(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return Ee(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Xe(e,t,n)),this}setDocAttribute(e,t){return this.step(new Ze(e,t)),this}addNodeMark(e,t){return this.step(new pe(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof m.m)t.isInSet(n.marks)&&this.step(new C(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new C(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 Oe(this,e,t,n),this}addMark(e,t,n){return T(this,e,t,n),this}removeMark(e,t,n){return ge(this,e,t,n),this}clearIncompatible(e,t,n){return _e(this,e,t,n),this}},E=Object.create(null),D=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new et(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=m.b.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?m.b.empty:t),o==0&&st(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),st(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new O(e):ot(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?ot(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):ot(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 A(e.node(0))}static atStart(e){return ot(e,e,0,0,1)||new A(e)}static atEnd(e){return ot(e,e,e.content.size,e.childCount,-1)||new A(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=E[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in E)throw RangeError(`Duplicate use of selection JSON ID `+e);return E[e]=t,t.prototype.jsonID=e,t}getBookmark(){return O.between(this.$anchor,this.$head).getBookmark()}};D.prototype.visible=!0;var et=class{constructor(e,t){this.$from=e,this.$to=t}},tt=!1;function nt(e){!tt&&!e.parent.inlineContent&&(tt=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var O=class e extends D{constructor(e,t=e){nt(e),nt(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 D.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=m.b.empty){if(super.replace(e,t),t==m.b.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 rt(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=D.findFrom(n,r,!0)||D.findFrom(n,-r,!0);if(e)n=e.$head;else return D.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(D.findFrom(t,-r,!0)||D.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};D.jsonID(`text`,O);var rt=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 O.between(e.resolve(this.anchor),e.resolve(this.head))}},k=class e extends D{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?D.near(a):new e(a)}content(){return new m.b(m.p.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 it(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}};k.prototype.visible=!1,D.jsonID(`node`,k);var it=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new rt(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&k.isSelectable(n)?new k(t):D.near(t)}},A=class e extends D{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=m.b.empty){if(t==m.b.empty){e.delete(0,e.doc.content.size);let t=D.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 at}};D.jsonID(`all`,A);var at={map(){return this},resolve(e){return new A(e)}};function ot(e,t,n,r,i,a=!1){if(t.inlineContent)return O.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=ot(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&k.isSelectable(r))return k.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function st(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof me||i instanceof w))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(D.near(e.doc.resolve(o),n))}var ct=1,j=2,lt=4,ut=class extends $e{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|ct)&~j,this.storedMarks=null,this}get selectionSet(){return(this.updated&ct)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=j,this}ensureMarks(e){return m.m.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&j)>0}addStep(e,t){super.addStep(e,t),this.updated&=~j,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)||m.m.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(D.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|=lt,this}get scrolledIntoView(){return(this.updated&lt)>0}};function dt(e,t){return!t||!e?e:e.bind(t)}var ft=class{constructor(e,t,n){this.name=e,this.init=dt(t.init,n),this.apply=dt(t.apply,n)}},pt=[new ft(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new ft(`selection`,{init(e,t){return e.selection||D.atStart(t.doc)},apply(e){return e.selection}}),new ft(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new ft(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],mt=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=pt.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 ft(e.key,e.spec.state,e))})}},ht=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 ut(this)}static create(t){let n=new mt(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 mt(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 mt(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=m.g.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=D.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 gt(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=gt(i,t,{})),n[r]=i}return n}var M=class{constructor(e){this.spec=e,this.props={},e.props&&gt(e.props,this,this.props),this.key=e.key?e.key.key:vt(`plugin`)}getState(e){return e[this.key]}},_t=Object.create(null);function vt(e){return e in _t?e+`$`+ ++_t[e]:(_t[e]=0,e+`$`)}var yt=class{constructor(e=`key`){this.key=vt(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},bt=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},xt=null,St=function(e,t,n){let r=xt||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Ct=function(){xt=null},wt=function(e,t,n,r){return n&&(Et(e,t,n,r,-1)||Et(e,t,n,r,1))},Tt=/^(img|br|input|textarea|hr)$/i;function Et(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Dt(e))){let n=e.parentNode;if(!n||n.nodeType!=1||jt(e)||Tt.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?Dt(e):0}else return!1}}function Dt(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Ot(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=Dt(e)}else if(e.parentNode&&!jt(e))t=N(e),e=e.parentNode;else return null}}function kt(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&&!jt(e))t=N(e)+1,e=e.parentNode;else return null}}function At(e,t,n){for(let r=t==0,i=t==Dt(e);r||i;){if(e==n)return!0;let t=N(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==Dt(e)}}function jt(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 Mt=function(e){return e.focusNode&&wt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Nt(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function Pt(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function Ft(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Dt(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Dt(r.startContainer),r.startOffset)}}}var It=typeof navigator<`u`?navigator:null,Lt=typeof document<`u`?document:null,Rt=It&&It.userAgent||``,zt=/Edge\/(\d+)/.exec(Rt),Bt=/MSIE \d/.exec(Rt),Vt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Rt),P=!!(Bt||Vt||zt),Ht=Bt?document.documentMode:Vt?+Vt[1]:zt?+zt[1]:0,F=!P&&/gecko\/(\d+)/i.test(Rt);F&&+(/Firefox\/(\d+)/.exec(Rt)||[0,0])[1];var Ut=!P&&/Chrome\/(\d+)/.exec(Rt),I=!!Ut,Wt=Ut?+Ut[1]:0,L=!P&&!!It&&/Apple Computer/.test(It.vendor),Gt=L&&(/Mobile\/\w+/.test(Rt)||!!It&&It.maxTouchPoints>2),R=Gt||(It?/Mac/.test(It.platform):!1),Kt=It?/Win/.test(It.platform):!1,qt=/Android \d/.test(Rt),Jt=!!Lt&&`webkitFontSmoothing`in Lt.documentElement.style,Yt=Jt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Xt(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 Zt(e,t){return typeof e==`number`?e:e[t]}function Qt(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 $t(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=bt(o);continue}let e=o,n=e==a.body,s=n?Xt(a):Qt(e),c=0,l=0;if(t.top<s.top+Zt(r,`top`)?l=-(s.top-t.top+Zt(i,`top`)):t.bottom>s.bottom-Zt(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+Zt(i,`top`)-s.top:t.bottom-s.bottom+Zt(i,`bottom`)),t.left<s.left+Zt(r,`left`)?c=-(s.left-t.left+Zt(i,`left`)):t.right>s.right-Zt(r,`right`)&&(c=t.right-s.right+Zt(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:bt(o)}}function en(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:tn(e.dom)}}function tn(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=bt(r));return t}function nn({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;rn(n,r==0?0:r-t)}function rn(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 an=null;function on(e){if(e.setActive)return e.setActive();if(an)return e.focus(an);let t=tn(e);e.focus(an==null?{get preventScroll(){return an={preventScroll:!0},!0}}:void 0),an||(an=!1,rn(t,0))}function sn(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=St(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?1:0));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?cn(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:sn(n,i)}function cn(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=gn(r,1);if(n.top!=n.bottom&&ln(t,n)){i={node:e,offset:a+(t.left>=(n.left+n.right)/2?1:0)};break}}return r.detach(),i||{node:e,offset:0}}function ln(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function un(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function dn(e,t,n){let{node:r,offset:i}=sn(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 fn(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 pn(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(ln(t,i))return pn(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function mn(e,t){let n=e.dom.ownerDocument,r,i=0,a=Ft(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(!ln(t,n)||(o=pn(e.dom,t,n),!o))return null}if(L)for(let e=o;r&&e;e=bt(e))e.draggable&&(r=void 0);if(o=un(o,t),r){if(F&&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;Jt&&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=fn(e,r,i,t))}s??=dn(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function hn(e){return e.top<e.bottom||e.left<e.right}function gn(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(hn(e))return e}return Array.prototype.find.call(n,hn)||e.getBoundingClientRect()}var _n=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function vn(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=Jt||F;if(r.nodeType==3)if(o&&(_n.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=gn(St(r,i,i),n);if(F&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=gn(St(r,i-1,i-1),-1);if(t.top==e.top){let n=gn(St(r,i,i+1),-1);if(n.top!=e.top)return yn(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++,yn(gn(St(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Dt(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return bn(e.getBoundingClientRect(),!1)}if(a==null&&i<Dt(r)){let e=r.childNodes[i];if(e.nodeType==1)return bn(e.getBoundingClientRect(),!0)}return bn(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==Dt(r))){let e=r.childNodes[i-1],t=e.nodeType==3?St(e,Dt(e)-(o?0:1)):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return yn(gn(t,1),!1)}if(a==null&&i<Dt(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?St(e,0,o?0:1):e.nodeType==1?e:null:null;if(t)return yn(gn(t,-1),!0)}return yn(gn(r.nodeType==3?St(r):r,-n),n>=0)}function yn(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 bn(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 xn(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 Sn(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return xn(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=vn(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=St(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 Cn=/[\u0590-\u08ac]/;function wn(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?!Cn.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:xn(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 Tn=null,En=null,Dn=!1;function On(e,t,n){return Tn==t&&En==n?Dn:(Tn=t,En=n,Dn=n==`up`||n==`down`?Sn(e,t,n):wn(e,t,n))}var kn=0,An=1,jn=2,Mn=3,Nn=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=kn,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 Bn){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 Pn&&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((F||L)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
3
- `),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(F&&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)&&wt(o.node,o.offset,l.anchorNode,l.anchorOffset)&&wt(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&F)){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?jn:An,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Mn:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?jn:Mn}n=a}this.dirty=jn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?jn:An;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Pn=class extends Nn{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==kn&&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}},Fn=class extends Nn{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}},In=class e extends Nn{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=m.f.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&Mn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Mn&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=kn){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=kn}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=rr(a,n,o,r)),t>0&&(a=rr(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()}},Ln=class e extends Nn{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=m.f.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=Jn(u,r,n),l?c=new Vn(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new zn(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=()=>m.p.empty)}return e}matchesNode(e,t,n){return this.dirty==kn&&e.eq(this.node)&&Yn(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}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 Zn(this,a&&a.node,e);er(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?m.m.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==jn)&&(a&&this.protectLocalComposition(e,a),Hn(this.contentDOM,this.children,e),Gt&&tr(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof O)||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=nr(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 Fn(this,i,t,r);e.input.compositionNodes.push(a),this.children=rr(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==Mn||!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=kn}updateOuterDeco(e){if(Yn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Kn(this.dom,this.nodeDOM,Gn(this.outerDeco,this.node,t),Gn(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 Rn(e,t,n,r,i){Jn(r,t,e);let a=new Ln(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var zn=class e extends Ln{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==Mn||this.dirty!=kn&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=kn||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=kn,!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=Mn)}get domAtom(){return!1}isText(e){return this.node.text==e}},Bn=class extends Nn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==kn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},Vn=class extends Ln{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==Mn)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 Hn(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=Xn(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof In){let t=r?r.previousSibling:e.lastChild;Hn(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=Xn(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var Un=function(e){e&&(this.nodeName=e)};Un.prototype=Object.create(null);var Wn=[new Un];function Gn(e,t,n){if(e.length==0)return Wn;let r=n?Wn[0]:new Un,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new Un(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new Un(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 Kn(e,t,n,r){if(n==Wn&&r==Wn)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=Wn[0],i=t)}qn(i,o||Wn[0],a)}return i}function qn(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 Jn(e,t,n){return Kn(e,e,Wn,Gn(t,n,e.nodeType!=1))}function Yn(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 Xn(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var Zn=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Qn(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=kn,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=In.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==Mn&&a.dom==a.contentDOM&&(a.dirty=jn),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 Ln){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!=Mn&&Yn(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=jn,u.updateChildren(r,a+1),u.dirty=kn),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)||!Yn(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=Ln.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=Ln.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 Pn(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 In;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof zn)||/\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 Bn(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 Qn(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 In)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 $n(e,t){return e.type.side-t.type.side}function er(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($n);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 tr(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 nr(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 rr(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 ir(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(Mt(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&k.isSelectable(e)&&i.parent&&!(e.isInline&&At(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new k(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=hr(e,u,s,n)}return l}function ar(e){return e.editable?e.hasFocus():_r(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function or(e,t=!1){let n=e.state.selection;if(pr(e,n),ar(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&I){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&wt(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)fr(e);else{let{anchor:r,head:i}=n,a,o;sr&&!(n instanceof O)&&(n.$from.parent.inlineContent||(a=cr(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=cr(e,n.to))),e.docView.setSelection(r,i,e,t),sr&&(a&&ur(a),o&&ur(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&dr(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var sr=L||I&&Wt<63;function cr(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 lr(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return lr(i);if(a)return lr(a)}}function lr(e){return e.contentEditable=`true`,L&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ur(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function dr(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(()=>{(!ar(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function fr(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&&Ht<=11&&(n.disabled=!0,n.disabled=!1)}function pr(e,t){if(t instanceof k){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(mr(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else mr(e)}function mr(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function hr(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||O.between(t,n,r)}function gr(e){return e.editable&&!e.hasFocus()?!1:_r(e)}function _r(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 vr(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return wt(t.node,t.offset,n.anchorNode,n.anchorOffset)}function yr(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&&D.findFrom(a,t)}function br(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function xr(e,t,n){let r=e.state.selection;if(r instanceof O){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 br(e,new O(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=yr(e.state,t);return n&&n instanceof k?br(e,n):!1}else if(!(R&&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?k.isSelectable(i)?br(e,new k(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):Jt?br(e,new O(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof k&&r.node.isInline)return br(e,new O(t>0?r.$to:r.$from));else{let n=yr(e.state,t);return n?br(e,n):!1}}function Sr(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Cr(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function wr(e,t){return t<0?Tr(e):Er(e)}function Tr(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(F&&n.nodeType==1&&r<Sr(n)&&Cr(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(Cr(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(Dr(n))break;else{let t=n.previousSibling;for(;t&&Cr(t,-1);)i=n.parentNode,a=N(t),t=t.previousSibling;if(t)n=t,r=Sr(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?Ar(e,n,r):i&&Ar(e,i,a)}function Er(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=Sr(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(Cr(e,1))a=n,o=++r;else break}else if(Dr(n))break;else{let t=n.nextSibling;for(;t&&Cr(t,1);)a=t.parentNode,o=N(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=Sr(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&Ar(e,a,o)}function Dr(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Or(e,t){for(;e&&t==e.childNodes.length&&!jt(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 kr(e,t){for(;e&&!t&&!jt(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 Ar(e,t,n){if(t.nodeType!=3){let e,r;(r=Or(t,n))?(t=r,n=0):(e=kr(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Mt(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&&or(e)},50)}function jr(e,t){let n=e.state.doc.resolve(t);if(!(I||Kt)&&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 Mr(e,t,n){let r=e.state.selection;if(r instanceof O&&!r.empty||n.indexOf(`s`)>-1||R&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=yr(e.state,t);if(n&&n instanceof k)return br(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof A?D.near(n,t):D.findFrom(n,t);return o?br(e,o):!1}return!1}function Nr(e,t){if(!(e.state.selection instanceof O))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 Pr(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Fr(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;Pr(e,n,`true`),setTimeout(()=>Pr(e,n,`false`),20)}return!1}function Ir(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function Lr(e,t){let n=t.keyCode,r=Ir(t);if(n==8||R&&n==72&&r==`c`)return Nr(e,-1)||wr(e,-1);if(n==46&&!t.shiftKey||R&&n==68&&r==`c`)return Nr(e,1)||wr(e,1);if(n==13||n==27)return!0;if(n==37||R&&n==66&&r==`c`){let t=n==37?jr(e,e.state.selection.from)==`ltr`?-1:1:-1;return xr(e,t,r)||wr(e,t)}else if(n==39||R&&n==70&&r==`c`){let t=n==39?jr(e,e.state.selection.from)==`ltr`?1:-1:1;return xr(e,t,r)||wr(e,t)}else if(n==38||R&&n==80&&r==`c`)return Mr(e,-1,r)||wr(e,-1);else if(n==40||R&&n==78&&r==`c`)return Fr(e)||Mr(e,1,r)||wr(e,1);else if(r==(R?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function Rr(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`)||m.f.fromSchema(e.state.schema),s=Yr(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=qr[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,`
4
-
5
- `),slice:t}}function zr(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 m.b(m.p.from(e.state.schema.text(t.replace(/\r\n?/g,`
6
- `))),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=m.f.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=Qr(n),Jt&&$r(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`)||m.d.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Br.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=ei(Kr(s,+u[1],+u[2]),u[4]);else if(s=m.b.maxOpen(Vr(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=Kr(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var Br=/^(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 Vr(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&&Ur(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=Wr(a[a.length-1],i.length));let n=Hr(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return m.p.from(a)}return e}function Hr(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,m.p.from(e));return e}function Ur(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=Ur(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(m.p.from(Hr(n,e,i+1))))}}function Wr(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Wr(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(m.p.empty,!0);return e.copy(n.append(r))}function Gr(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=Gr(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(m.p.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function Kr(e,t,n){return t<e.openStart&&(e=new m.b(Gr(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new m.b(Gr(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var qr={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},Jr=null;function Yr(){return Jr||=document.implementation.createHTMLDocument(`title`)}var Xr=null;function Zr(e){let t=window.trustedTypes;return t?(Xr||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),Xr.createHTML(e)):e}function Qr(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Yr().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&qr[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=Zr(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function $r(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 ei(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=m.p.from(t.create(r[e+1],i)),a++,o++}return new m.b(i,a,o)}var z={},B={},ti={touchstart:!0,touchmove:!0},ni=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 ri(e){for(let t in z){let n=z[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{ci(e,t)&&!si(e,t)&&(e.editable||!(t.type in B))&&n(e,t)},ti[t]?{passive:!0}:void 0)}L&&e.dom.addEventListener(`input`,()=>null),oi(e)}function ii(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function ai(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 oi(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>si(e,t))})}function si(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function ci(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 li(e,t){!si(e,t)&&z[t.type]&&(e.editable||!(t.type in B))&&z[t.type](e,t)}B.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Ci(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(qt&&I&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),Gt&&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,Nt(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||Lr(e,n)?n.preventDefault():ii(e,`key`)},B.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},B.keypress=(e,t)=>{let n=t;if(Ci(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||R&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof O)||!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 ui(e){return{left:e.clientX,top:e.clientY}}function di(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function fi(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 pi(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 mi(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&k.isSelectable(r)?(pi(e,new k(n),`pointer`),!0):!1}function hi(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof k&&(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(k.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:(pi(e,k.create(e.state.doc,i),`pointer`),!0)}function gi(e,t,n,r,i){return fi(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?hi(e,n):mi(e,n))}function _i(e,t,n,r){return fi(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function vi(e,t,n,r){return fi(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||yi(e,n,r)}function yi(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(pi(e,O.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)pi(e,O.create(r,a+1,a+1+n.content.size),`pointer`);else if(k.isSelectable(n))pi(e,k.create(r,a),`pointer`);else continue;return!0}}function bi(e){return Ai(e)}var xi=R?`metaKey`:`ctrlKey`;z.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=bi(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&di(n,e.input.lastClick)&&!n[xi]&&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(ui(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Si(e,o,n,!!r)):(a==`doubleClick`?_i:vi)(e,o.pos,o.inside,n)?n.preventDefault():ii(e,`pointer`))};var Si=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[xi],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 k&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&F&&!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)),ii(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(()=>or(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(ui(e))),this.updateAllowDefault(e),this.allowDefault||!t?ii(this.view,`pointer`):gi(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)?(pi(this.view,D.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):ii(this.view,`pointer`)}move(e){this.updateAllowDefault(e),ii(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)}};z.touchstart=e=>{e.input.lastTouch=Date.now(),bi(e),ii(e,`pointer`)},z.touchmove=e=>{e.input.lastTouch=Date.now(),ii(e,`pointer`)},z.contextmenu=e=>bi(e);function Ci(e,t){return e.composing?!0:L&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var wi=qt?5e3:-1;B.compositionstart=B.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof O&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||I&&Kt&&Ti(e)))e.markCursor=e.state.storedMarks||n.marks(),Ai(e,!0),e.markCursor=null;else if(Ai(e,!t.selection.empty),F&&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}Ei(e,wi)};function Ti(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`}B.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++,Ei(e,20))};function Ei(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Ai(e),t))}function Di(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=ki());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Oi(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Ot(t.focusNode,t.focusOffset),r=kt(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 ki(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function Ai(e,t=!1){if(!(qt&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Di(e),t||e.docView&&e.docView.dirty){let n=ir(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 ji(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 Mi=P&&Ht<15||Gt&&Yt<604;z.copy=B.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Mi?null:n.clipboardData,{dom:o,text:s}=Rr(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):ji(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Ni(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Pi(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?Fi(e,r.value,null,i,t):Fi(e,r.textContent,r.innerHTML,i,t)},50)}function Fi(e,t,n,r,i){let a=zr(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||m.b.empty)))return!0;if(!a)return!1;let o=Ni(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 Ii(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,` `):``}B.paste=(e,t)=>{let n=t;if(e.composing&&!qt)return;let r=Mi?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Fi(e,Ii(r),r.getData(`text/html`),i,n)?n.preventDefault():Pi(e,n)};var Li=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Ri=R?`altKey`:`ctrlKey`;function zi(e,t){return e.someProp(`dragCopies`,e=>!e(t))??!t[Ri]}z.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(ui(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof k?i.to-1:i.to))){if(r&&r.mightDrag)o=k.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=k.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Rr(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!I||Wt>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Mi?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Mi||n.dataTransfer.setData(`text/plain`,c),e.dragging=new Li(l,zi(e,n),o)},z.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},B.dragover=B.dragenter=(e,t)=>t.preventDefault(),B.drop=(e,t)=>{try{Bi(e,t,e.dragging)}finally{e.dragging=null}};function Bi(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(ui(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=zr(e,Ii(t.dataTransfer),Mi?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&zi(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||m.b.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?Pe(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&&k.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new k(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(hr(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}z.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())&&or(e)},20))},z.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)},z.beforeinput=(e,t)=>{if(I&&qt&&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,Nt(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 B)z[e]=B[e];function Vi(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 Hi=class e{constructor(e,t){this.toDOM=e,this.spec=t||Ki,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 V(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&&Vi(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Ui=class e{constructor(e,t){this.attrs=e,this.spec=t||Ki}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 V(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&Vi(this.attrs,t.attrs)&&Vi(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},Wi=class e{constructor(e,t){this.attrs=e,this.spec=t||Ki}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 V(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&&Vi(this.attrs,t.attrs)&&Vi(this.spec,t.spec)}destroy(){}},V=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 Hi(n,r))}static inline(t,n,r,i){return new e(t,n,new Ui(r,i))}static node(t,n,r,i){return new e(t,n,new Wi(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ui}get widget(){return this.type instanceof Hi}},Gi=[],Ki={},H=class e{constructor(e,t){this.local=e.length?e:Gi,this.children=t.length?t:Gi}static create(e,t){return t.length?$i(t,e,0,Ki):U}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==U||e.maps.length==0?this:this.mapInner(e,t,0,0,n||Ki)}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?Ji(this.children,o||[],t,n,r,i,a):o?new e(o.sort(ea),Gi):U}add(t,n){return n.length?this==U?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=Zi(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,$i(s,e,o+1,Ki)),a+=3}});let o=Yi(a?Qi(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(ea):this.local,i||this.children)}remove(e){return e.length==0||this==U?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==U?(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):U}forChild(t,n){if(this==U)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 Ui){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(ea),Gi);return r?new qi([t,r]):t}return r||U}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 ta(this.localsInner(e))}localsInner(e){if(this==U)return Gi;if(e.inlineContent||!this.local.some(Ui.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof Ui||t.push(this.local[e]);return t}forEachSet(e){e(this)}};H.empty=new H([],[]),H.removeOverlap=ta;var U=H.empty,qi=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,Ki));return e.from(r)}forChild(t,n){if(n.isLeaf)return H.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=U&&(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?ta(n?t:t.sort(ea)):Gi}static from(t){switch(t.length){case 0:return U;case 1:return t[0];default:return new e(t.every(e=>e instanceof H)?t:t.reduce((e,t)=>e.concat(t instanceof H?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Ji(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==U?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=$i(Xi(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 H(t.sort(ea),s)}function Yi(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 V(i.from+t,i.to+t,i.type))}return n}function Xi(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 Zi(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 Qi(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function $i(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=Zi(e,t,o+n);if(s){a=!0;let e=$i(s,t,n+o+1,r);e!=U&&i.push(o,o+t.nodeSize,e)}});let o=Yi(a?Qi(e):e,-n).sort(ea);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 H(o,i):U}function ea(e,t){return e.from-t.from||e.to-t.to}function ta(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),na(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),na(t,i,r.copy(a.from,r.to)));break}}}return t}function na(e,t,n){for(;t<e.length&&ea(n,e[t])>0;)t++;e.splice(t,0,n)}function ra(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=U&&t.push(r)}),e.cursorWrapper&&t.push(H.create(e.state.doc,[e.cursorWrapper.deco])),qi.from(t)}var ia={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},aa=P&&Ht<=11,oa=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}},sa=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new oa,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&&Ht<=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()}),aa&&(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,ia)),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(gr(this.view)){if(this.suppressingSelectionUpdates)return or(this.view);if(P&&Ht<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&wt(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=bt(n))t.add(n);for(let r=e.anchorNode;r;r=bt(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)&&gr(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;t&&t.nodeType==1&&t.contentEditable==`false`&&e.parentNode.removeChild(e)}}else if(F&&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||pa(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&&Mt(n)&&(c=ir(e))&&c.eq(D.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,or(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),ua(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,ma(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||or(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&&Ht<=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}}},ca=new WeakMap,la=!1;function ua(e){if(!ca.has(e)&&(ca.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=F,la)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.`),la=!0}}function da(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return wt(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function fa(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return da(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?da(e,n):null}function pa(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 ma(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 ha(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}],Mt(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`)||m.d.fromSchema(e.state.schema),p=d.resolve(o),h=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:ga,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,h={anchor:e+o,head:t+o}}return{doc:g,sel:h,from:o,to:s}}function ga(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}}else 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 _a=/^(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 va(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=ir(e,t);if(n&&!e.state.selection.eq(n)){if(I&&qt&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,Nt(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=ha(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=Ca(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(Gt&&e.input.lastIOSEnter>Date.now()-225||qt)&&i.some(e=>e.nodeType==1&&!_a.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,Nt(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof O&&!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=ya(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 O&&(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&&Ht<=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((Gt&&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,Nt(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&xa(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,Nt(8,`Backspace`)))){qt&&I&&e.domObserver.suppressSelectionUpdates();return}I&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),qt&&!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,Nt(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=ya(e,n.doc,l.sel);t&&!(I&&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&&Ht<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>or(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=ba(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?0:1)){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 ya(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:hr(e,t.resolve(n.anchor),t.resolve(n.head))}function ba(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(m.p.from(l).eq(e))return{mark:s,type:o}}function xa(e,t,n,r,i){if(n-t<=i.pos-r.pos||Sa(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(Sa(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Sa(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Sa(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 Ca(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&&wa(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&&wa(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function wa(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 Ta=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 ni,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ma),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=Oa(this),Da(this),this.nodeViews=Aa(this),this.docView=Rn(this.state.doc,Ea(this),ra(this),this.dom,this),this.domObserver=new sa(this,(e,t,n,r)=>va(this,e,t,n,r)),this.domObserver.start(),ri(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&&oi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ma),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&&(Di(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=Aa(this);ja(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&oi(this),this.editable=Oa(this),Da(this);let o=ra(this),s=Ea(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&&en(this);if(i){this.domObserver.stop();let t=l&&(P||I)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&ka(n.selection,e.selection);if(l){let n=I?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Oi(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=Rn(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())&&vr(this))?or(this,t):(pr(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&&nn(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 k){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&$t(this,t.getBoundingClientRect(),e)}else $t(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(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&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new Li(e.slice,e.move,r<0?void 0:k.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&&on(this.dom),or(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 mn(this,e)}coordsAtPos(e,t=1){return vn(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 On(this,t||this.state,e)}pasteHTML(e,t){return Fi(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return Fi(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Rr(this,e)}destroy(){this.docView&&(ai(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ra(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ct())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return li(this,e)}domSelectionRange(){let e=this.domSelection();return e?L&&this.root.nodeType===11&&Pt(this.dom.ownerDocument)==this.dom&&fa(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Ta.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Ea(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`,[V.node(0,e.state.doc.content.size,t)]}function Da(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:V.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Oa(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function ka(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 Aa(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 ja(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 Ma(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 Na=(e,t)=>{let n=t.config[m.r].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,[m.r]:t},[m.r]:t}),o.push(n),s.push(r),l++}s[s.length-1].push({type:`node`,node:n,children:a(n.content??[]),[m.r]:t})}return{type:`fragment`,content:n,[m.r]:t}};return{type:`node`,node:e,children:a(e.content),[m.r]:t}},Pa=class{constructor(e){this[m.r]=new Fa(e)}instantiateEditor(e){return new tl(this,e)}instantiateView(e,t){return Na(e,{config:this,options:{...t}})}},Fa=class{constructor(e){let t=e=>e.flatMap(e=>e.getFeatures().flatMap(n=>n===e?e:t([n])));this.features=t(e.map(m.s)),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=m.s(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 m.u(m.c(this.features.flatMap(e=>e.getTextblockAttrs()))),this.textblockMarks=new m.l(m.c(this.features.flatMap(e=>e.getTextblockMarks())));let n=m.c(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 m.y(r)}},Ia={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:`'`},La={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Ra=typeof navigator<`u`&&/Mac/.test(navigator.platform),za=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),W=0;W<10;W++)Ia[48+W]=Ia[96+W]=String(W);for(var W=1;W<=24;W++)Ia[W+111]=`F`+W;for(var W=65;W<=90;W++)Ia[W]=String.fromCharCode(W+32),La[W]=String.fromCharCode(W);for(var Ba in Ia)La.hasOwnProperty(Ba)||(La[Ba]=Ia[Ba]);function Va(e){var t=!(Ra&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||za&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?La:Ia)[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 Ha=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ua=typeof navigator<`u`&&/Win/.test(navigator.platform);function Wa(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))Ha?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 Ga(e){let t=Object.create(null);for(let n in e)t[Wa(n)]=e[n];return t}function Ka(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 G(e){return new M({props:{handleKeyDown:qa(e)}})}function qa(e){let t=Ga(e);return function(e,n){let r=Va(n),i,a=t[Ka(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[Ka(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Ua&&n.ctrlKey&&n.altKey)&&(i=Ia[n.keyCode])&&i!=r){let r=t[Ka(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var Ja=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Ya(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var Xa=(e,t,n)=>{let r=Ya(e,n);if(!r)return!1;let i=$a(r);if(!i){let n=r.blockRange(),i=n&&ye(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(mo(e,i,t,-1))return!0;if(r.parent.content.size==0&&(Za(a,`end`)||k.isSelectable(a)))for(let n=r.depth;;n--){let o=Fe(e.doc,r.before(n),r.after(n),m.b.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(Za(a,`end`)?D.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):k.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 Za(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 Qa=(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=$a(r)}let o=a&&a.nodeBefore;return!o||!k.isSelectable(o)?!1:(t&&t(e.tr.setSelection(k.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function $a(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 eo(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var to=(e,t,n)=>{let r=eo(e,n);if(!r)return!1;let i=ro(r);if(!i)return!1;let a=i.nodeAfter;if(mo(e,i,t,1))return!0;if(r.parent.content.size==0&&(Za(a,`start`)||k.isSelectable(a))){let n=Fe(e.doc,r.before(),r.after(),m.b.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(Za(a,`start`)?D.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):k.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},no=(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=ro(r)}let o=a&&a.nodeAfter;return!o||!k.isSelectable(o)?!1:(t&&t(e.tr.setSelection(k.create(e.doc,a.pos)).scrollIntoView()),!0)};function ro(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 io=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
7
- `).scrollIntoView()),!0)};function ao(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 oo=(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=ao(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(D.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},so=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof A||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=ao(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(O.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},co=(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(De(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&ye(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function lo(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof k&&t.selection.node.isBlock)return!r.parentOffset||!De(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=ao(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 O||t.selection instanceof A)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=De(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,De(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 uo=lo(),fo=(e,t)=>(t&&t(e.tr.setSelection(new A(e.doc))),!0);function po(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||ke(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function mo(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&po(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=m.p.empty;for(let e=o.length-1;e>=0;e--)s=m.p.from(o[e].create(null,s));s=m.p.from(i.copy(s));let c=e.tr.step(new w(t.pos-1,r,t.pos,r,new m.b(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&ke(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:D.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&ye(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&Za(a,`start`,!0)&&Za(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=m.p.empty;for(let e=o.length-1;e>=0;e--)r=m.p.from(o[e].copy(r));n(e.tr.step(new w(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new m.b(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function ho(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(O.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var go=ho(-1),_o=ho(1);function vo(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 yo(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 et(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new et(r,i))}return t}function bo(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||!vo(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=yo(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 xo(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--)ke(n.doc,i[e])&&n.join(i[e]);e(n)}}function So(e,t){let n=Array.isArray(t)?e=>t.indexOf(e.type.name)>-1:t;return(t,r,i)=>e(t,r&&xo(r,n),i)}function Co(...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 wo=Co(Ja,Xa,Qa),To=Co(Ja,to,no),Eo={Enter:Co(io,so,co,uo),"Mod-Enter":oo,Backspace:wo,"Mod-Backspace":wo,"Shift-Backspace":wo,Delete:To,"Mod-Delete":To,"Mod-a":fo},Do={"Ctrl-h":Eo.Backspace,"Alt-Backspace":Eo[`Mod-Backspace`],"Ctrl-d":Eo.Delete,"Ctrl-Alt-Backspace":Eo[`Mod-Delete`],"Alt-Delete":Eo[`Mod-Delete`],"Alt-d":Eo[`Mod-Delete`],"Ctrl-a":go,"Ctrl-e":_o};for(let e in Eo)Do[e]=Eo[e];var Oo=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?Do:Eo,ko=`.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 Ao(e={}){return new M({view(t){return new jo(t,e)}})}var jo=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=Pe(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)}},K=class e extends D{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):D.near(r)}content(){return m.b.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 Mo(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Po(e)||!Fo(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&&!k.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}}};K.prototype.visible=!1,K.findFrom=K.findGapCursorFrom,D.jsonID(`gapcursor`,K);var Mo=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 K.valid(t)?new K(t):D.near(t)}};function No(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Po(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||No(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Fo(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||No(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Io(){return new M({props:{decorations:Vo,createSelectionBetween(e,t,n){return t.pos==n.pos&&K.valid(n)?new K(n):null},handleClick:zo,handleKeyDown:Lo,handleDOMEvents:{beforeinput:Bo}}})}var Lo=qa({ArrowLeft:Ro(`horiz`,-1),ArrowRight:Ro(`horiz`,1),ArrowUp:Ro(`vert`,-1),ArrowDown:Ro(`vert`,1)});function Ro(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 O){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=K.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new K(c))),!0):!1}}function zo(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!K.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&k.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new K(r))),!0)}function Bo(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof K))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=m.p.empty;for(let e=r.length-1;e>=0;e--)i=m.p.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new m.b(i,0,0));return a.setSelection(O.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function Vo(e){if(!(e.selection instanceof K))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,H.create(e.doc,[V.widget(e.selection.head,t,{key:`gapcursor`})])}function Ho(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}throw Error(`No default textblock found.`)}var Uo=`[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}`,Wo=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))}},Go=`.ProseMirror{padding:var(--editor-padding-block) var(--editor-padding-inline);outline:none;flex:1}.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%)}`,Ko=200,q=function(){};q.prototype.append=function(e){return e.length?(e=q.from(e),!this.length&&e||e.length<Ko&&this.leafAppend(e)||this.length<Ko&&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 Jo(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 qo(e):q.empty};var qo=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<=Ko)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Ko)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 qo([]);var Jo=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),Yo=500,Xo=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 Qo(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 Qo(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 Qo(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>es&&(s=Zo(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new ce;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 Qo(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 Qo(i,o,l))}else r.push(new Qo(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new Qo(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>Yo&&(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 Qo(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)}};Xo.empty=new Xo(q.empty,0);function Zo(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var Qo=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)}}},$o=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},es=20;function ts(e,t,n,r){let i=n.getMeta(ds),a;if(i)return i.historyState;n.getMeta(fs)&&(e=new $o(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(ds))return o.getMeta(ds).redo?new $o(e.done.addTransform(n,void 0,r,ls(t)),e.undone,rs(n.mapping.maps),e.prevTime,e.prevComposition):new $o(e.done,e.undone.addTransform(n,void 0,r,ls(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||!ns(n,e.prevRanges)),s=o?is(e.prevRanges,n.mapping):rs(n.mapping.maps);return new $o(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,ls(t)),Xo.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new $o(e.done.rebased(n,a),e.undone.rebased(n,a),is(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new $o(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),is(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function ns(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 rs(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 is(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 as(e,t,n){let r=ls(t),i=ds.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 $o(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(ds,{redo:n,historyState:c})}var ss=!1,cs=null;function ls(e){let t=e.plugins;if(cs!=t){ss=!1,cs=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){ss=!0;break}}return ss}function us(e){return e.setMeta(fs,!0)}var ds=new yt(`history`),fs=new yt(`closeHistory`);function ps(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new M({key:ds,state:{init(){return new $o(Xo.empty,Xo.empty,null,0,-1)},apply(t,n,r){return ts(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?hs:n==`historyRedo`?gs:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function ms(e,t){return(n,r)=>{let i=ds.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=as(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var hs=ms(!1,!0),gs=ms(!0,!0),_s=e=>typeof e==`function`,vs=(e,t,n)=>[e,t,n],ys=class{constructor(e,t,n){this.view=e,this.rte=t,this.props=n,this.bindings=[]}evalProp(e){return _s(e)?e(this):e}bindProp(e,t){if(e!==void 0)if(_s(e)){let n=()=>t(e(this));this.bindings.push(n),n()}else t(e)}updateBindings(){for(let e of this.bindings)e()}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)}},J=(e,t)=>{let n=document.createElement(`div`);return e.bindToEl(n,{className:t.className,slot:t.slot},[],t.children),n},bs=(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},xs=new WeakMap,Ss=(e,t)=>{let n=e.rte.createComponent(h.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=J(e,{className:`ui-tooltip-wrapper`,slot:t.slot,children:[t.anchor,n]});return xs.set(r,t.anchor),r},Y=(e,t)=>{let n=()=>e.evalProp(t.variant)??`toolbar`,r=()=>n()===`toolbar`?`super-condensed`:`condensed`,i=()=>n()===`popover-primary`?`outlined`:`ghost-light`,o=()=>e.evalProp(t.active)?`filled`:i(),s=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),c=e.rte.createComponent(a.i);return e.bindToEl(c,{size:r,appearance:o,disabled:s,icon:t.icon,autofocus:t.autofocus,connotation:t.connotation,[t.icon?`ariaLabel`:`label`]:t.label},[vs(`click`,t.onClick,t=>()=>{t()||e.view.focus()})]),Ss(e,{enabled:()=>!!(e.evalProp(t.icon)&&!e.evalProp(t.noTooltip)&&!s()),label:t.label,anchor:c,slot:t.slot})},Cs=(e,t)=>{let n=e.rte.createComponent(c.r);e.bindToEl(n,{className:`ui-menu`,autoDismiss:!0,ariaLabel:t.label,anchor:xs.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},ws=(e,t)=>{let n=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),r=e.rte.createComponent(s.i);return e.bindToEl(r,{text:t.text,checked:t.checked,disabled:n,controlType:`radio`,checkedAppearance:`tick-only`},[vs(`change`,t.onSelect,n=>()=>{r.checked&&!r.disabled&&e.evalProp(t.checked)!==r.checked&&(n(),e.view.focus())})]),r},Ts=(e,t)=>J(e,{className:`ui-button-group`,children:t.children});function Es(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 Ds=(e,t)=>Y(e,{label:t.label,icon:t.icon,active:()=>Es(e.view.state,t.markType),disabled:()=>!bo(t.markType)(e.view.state),onClick:()=>{bo(t.markType)(e.view.state,e.view.dispatch)}}),Os=(e,t)=>{let n=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),r=e.rte.createComponent(d.r);return e.bindToEl(r,{value:t.value,text:t.text,disabled:n}),r},ks=(e,t)=>{let n=()=>!!e.evalProp(e.props.disabled),r=e.rte.createComponent(g.r);r.setAttribute(`data-class`,`ui-select`),e.bindToEl(r,{placeholder:` `,ariaLabel:t.label,appearance:`ghost`,disabled:n},[vs(`change`,t.onSelect,t=>()=>{let n=r.value;n&&(t(n),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()}),Ss(e,{enabled:()=>!i&&!n(),label:t.label,anchor:r})},As=e=>{let t=e.rte.createComponent(l.t);return e.bindToEl(t,{className:`ui-divider`,orientation:`vertical`}),t},js=(e,t)=>{let n=e.rte.createComponent(f.r);return e.bindToEl(n,{label:t.label,value:t.value,placeholder:t.placeholder,slot:t.slot,autofocus:t.autofocus,type:t.type},[vs(`input`,t.onInput,e=>()=>{e(n.value)})]),n},Ms=(e,t)=>{let n=document.createTextNode(``);return e.bindToEl(n,{textContent:t.text}),n},Ns=(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.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},Ps=class extends m.i{constructor(...e){super(...e),this.name=`RteHistoryFeature`}getPlugins(){return[this.contribution(ps()),this.contribution(G({"Mod-z":hs,"Ctrl-y":gs,"Cmd-Z":gs}))]}getToolbarItems(){return[this.contribution({section:`history`,render:e=>Y(e,{label:e=>e.rte.getLocale().richTextEditor.undo,icon:`undo-line`,disabled:e=>!hs(e.view.state),onClick:()=>{let{state:t,dispatch:n}=e.view;hs(t,n)}})},1),this.contribution({section:`history`,render:e=>Y(e,{label:e=>e.rte.getLocale().richTextEditor.redo,icon:`redo-line`,disabled:e=>!gs(e.view.state),onClick:()=>{let{state:t,dispatch:n}=e.view;gs(t,n)}})},2)]}},Fs=class extends m.i{constructor(...e){super(...e),this.name=`RteForeignHtmlFeature`}getPlugins(e){return[this.contribution(new M({props:{transformPastedHTML:t=>e.foreignHtmlParser[m.r].transform(t),clipboardParser:e.foreignHtmlParser[m.r].parser,clipboardSerializer:e.foreignHtmlSerializer[m.r].serializer}}))]}},Is=e=>{if(e.parentOffset!==e.parent.content.size)return null;let t=e.nodeBefore;return t&&t.isInline&&t.isAtom&&!t.isText?{}:null},Ls=class extends m.i{constructor(...e){super(...e),this.name=`RteCursorFix`}getPlugins(e){let t=[Is];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=null;for(let i of t){let t=i(n,e);t&&Object.assign(r??={},t)}return r?H.create(e.doc,[V.widget(n.pos,()=>{let e=document.createElement(`span`);e.textContent=`​`;for(let[t,n]of Object.entries(r))e.style.setProperty(t,n);return e},{side:-1})]):null}}}))]}};m.o(Ls);var Rs=new M({state:{init(){return null},apply(e,t){return e.getMeta(Rs)||t}}}),zs=class extends m.i{constructor(...e){super(...e),this.name=`RteCore`,this.disabled=new Wo(!1)}getStyles(){return[this.contribution(ko),this.contribution(Go),this.contribution(Uo)]}getPlugins(e){let t=Co(io,so,co,lo((t,n,r)=>n?{type:Ho(r.node(r.depth-1).contentMatchAt(r.indexAfter(r.depth-1))),attrs:e.textblockAttrs.extractFromNode(t)}:{type:t.type,attrs:t.attrs}));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=()=>{n.classList.toggle(`popovers--disabled`,this.disabled.getValue(e))};return r(),{update:()=>{r()}}}})),this.contribution(G({...Oo,Enter:t,"Shift-Enter":t})),this.contribution(Ao()),this.contribution(Io()),this.contribution(Rs)]}getFeatures(){return[this,new Ps,new Fs,new Ls]}};m.o(zs);var{entries:Bs,setPrototypeOf:Vs,isFrozen:Hs,getPrototypeOf:Us,getOwnPropertyDescriptor:Ws}=Object,{freeze:X,seal:Gs,create:Ks}=Object,{apply:qs,construct:Js}=typeof Reflect<`u`&&Reflect;X||=function(e){return e},Gs||=function(e){return e},qs||=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)},Js||=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 Ys=Q(Array.prototype.forEach),Xs=Q(Array.prototype.lastIndexOf),Zs=Q(Array.prototype.pop),Qs=Q(Array.prototype.push),$s=Q(Array.prototype.splice),ec=Q(String.prototype.toLowerCase),tc=Q(String.prototype.toString),nc=Q(String.prototype.match),rc=Q(String.prototype.replace),ic=Q(String.prototype.indexOf),ac=Q(String.prototype.trim),oc=Q(Object.prototype.hasOwnProperty),Z=Q(RegExp.prototype.test),sc=cc(TypeError);function Q(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 qs(e,t,r)}}function cc(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return Js(e,n)}}function $(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ec;Vs&&Vs(e,null);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 lc(e){for(let t=0;t<e.length;t++)oc(e,t)||(e[t]=null);return e}function uc(e){let t=Ks(null);for(let[n,r]of Bs(e))oc(e,n)&&(Array.isArray(r)?t[n]=lc(r):r&&typeof r==`object`&&r.constructor===Object?t[n]=uc(r):t[n]=r);return t}function dc(e,t){for(;e!==null;){let n=Ws(e,t);if(n){if(n.get)return Q(n.get);if(typeof n.value==`function`)return Q(n.value)}e=Us(e)}function n(){return null}return n}var fc=X(`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(`.`)),pc=X(`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(`.`)),mc=X([`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`]),hc=X([`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`]),gc=X(`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(`.`)),_c=X([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),vc=X([`#text`]),yc=X(`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.slot`.split(`.`)),bc=X(`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(`.`)),xc=X(`accent.accentunder.align.bevelled.close.columnsalign.columnlines.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lspace.lquote.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Sc=X([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Cc=Gs(/\{\{[\w\W]*|[\w\W]*\}\}/gm),wc=Gs(/<%[\w\W]*|[\w\W]*%>/gm),Tc=Gs(/\$\{[\w\W]*/gm),Ec=Gs(/^data-[\-\w.\u00B7-\uFFFF]+$/),Dc=Gs(/^aria-[\-\w]+$/),Oc=Gs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),kc=Gs(/^(?:\w+script|data):/i),Ac=Gs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),jc=Gs(/^html$/i),Mc=Gs(/^[a-z][.\w]*(-[.\w]+)+$/i),Nc=Object.freeze({__proto__:null,ARIA_ATTR:Dc,ATTR_WHITESPACE:Ac,CUSTOM_ELEMENT:Mc,DATA_ATTR:Ec,DOCTYPE_NAME:jc,ERB_EXPR:wc,IS_ALLOWED_URI:Oc,IS_SCRIPT_OR_DATA:kc,MUSTACHE_EXPR:Cc,TMPLIT_EXPR:Tc}),Pc={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Fc=function(){return typeof window>`u`?null:window},Ic=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}},Lc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Rc(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Fc(),t=e=>Rc(e);if(t.version=`3.3.1`,t.removed=[],!e||!e.document||e.document.nodeType!==Pc.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=dc(m,`cloneNode`),g=dc(m,`remove`),ee=dc(m,`nextSibling`),te=dc(m,`childNodes`),_=dc(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=Lc();t.isSupported=typeof Bs==`function`&&typeof _==`function`&&ne&&ne.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:se,ERB_EXPR:ce,TMPLIT_EXPR:le,DATA_ATTR:x,ARIA_ATTR:S,IS_SCRIPT_OR_DATA:ue,ATTR_WHITESPACE:de,CUSTOM_ELEMENT:fe}=Nc,{IS_ALLOWED_URI:pe}=Nc,C=null,me=$({},[...fc,...pc,...mc,...gc,...vc]),w=null,he=$({},[...yc,...bc,...xc,...Sc]),T=Object.seal(Ks(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}})),ge=null,_e=null,ve=Object.seal(Ks(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ye=!0,be=!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=!0,Pe=!1,Fe={},Ie=null,Le=$({},[`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`]),Re=null,ze=$({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Be=null,Ve=$({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),He=`http://www.w3.org/1998/Math/MathML`,Ue=`http://www.w3.org/2000/svg`,We=`http://www.w3.org/1999/xhtml`,Ge=We,Ke=!1,qe=null,Je=$({},[He,Ue,We],tc),Ye=$({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Xe=$({},[`annotation-xml`]),Ze=$({},[`title`,`style`,`font`,`a`,`script`]),Qe=null,$e=[`application/xhtml+xml`,`text/html`],E=null,D=null,et=n.createElement(`form`),tt=function(e){return e instanceof RegExp||e instanceof Function},nt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(D&&D===e)){if((!e||typeof e!=`object`)&&(e={}),e=uc(e),Qe=$e.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,E=Qe===`application/xhtml+xml`?tc:ec,C=oc(e,`ALLOWED_TAGS`)?$({},e.ALLOWED_TAGS,E):me,w=oc(e,`ALLOWED_ATTR`)?$({},e.ALLOWED_ATTR,E):he,qe=oc(e,`ALLOWED_NAMESPACES`)?$({},e.ALLOWED_NAMESPACES,tc):Je,Be=oc(e,`ADD_URI_SAFE_ATTR`)?$(uc(Ve),e.ADD_URI_SAFE_ATTR,E):Ve,Re=oc(e,`ADD_DATA_URI_TAGS`)?$(uc(ze),e.ADD_DATA_URI_TAGS,E):ze,Ie=oc(e,`FORBID_CONTENTS`)?$({},e.FORBID_CONTENTS,E):Le,ge=oc(e,`FORBID_TAGS`)?$({},e.FORBID_TAGS,E):uc({}),_e=oc(e,`FORBID_ATTR`)?$({},e.FORBID_ATTR,E):uc({}),Fe=oc(e,`USE_PROFILES`)?e.USE_PROFILES:!1,ye=e.ALLOW_ARIA_ATTR!==!1,be=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,Ne=e.KEEP_CONTENT!==!1,Pe=e.IN_PLACE||!1,pe=e.ALLOWED_URI_REGEXP||Oc,Ge=e.NAMESPACE||We,Ye=e.MATHML_TEXT_INTEGRATION_POINTS||Ye,Xe=e.HTML_INTEGRATION_POINTS||Xe,T=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&tt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(T.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&tt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(T.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements==`boolean`&&(T.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ce&&(be=!1),ke&&(Oe=!0),Fe&&(C=$({},vc),w=[],Fe.html===!0&&($(C,fc),$(w,yc)),Fe.svg===!0&&($(C,pc),$(w,bc),$(w,Sc)),Fe.svgFilters===!0&&($(C,mc),$(w,bc),$(w,Sc)),Fe.mathMl===!0&&($(C,gc),$(w,xc),$(w,Sc))),e.ADD_TAGS&&(typeof e.ADD_TAGS==`function`?ve.tagCheck=e.ADD_TAGS:(C===me&&(C=uc(C)),$(C,e.ADD_TAGS,E))),e.ADD_ATTR&&(typeof e.ADD_ATTR==`function`?ve.attributeCheck=e.ADD_ATTR:(w===he&&(w=uc(w)),$(w,e.ADD_ATTR,E))),e.ADD_URI_SAFE_ATTR&&$(Be,e.ADD_URI_SAFE_ATTR,E),e.FORBID_CONTENTS&&(Ie===Le&&(Ie=uc(Ie)),$(Ie,e.FORBID_CONTENTS,E)),e.ADD_FORBID_CONTENTS&&(Ie===Le&&(Ie=uc(Ie)),$(Ie,e.ADD_FORBID_CONTENTS,E)),Ne&&(C[`#text`]=!0),Te&&$(C,[`html`,`head`,`body`]),C.table&&($(C,[`tbody`]),delete ge.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw sc(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw sc(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);v=e.TRUSTED_TYPES_POLICY,y=v.createHTML(``)}else v===void 0&&(v=Ic(p,i)),v!==null&&typeof y==`string`&&(y=v.createHTML(``));X&&X(e),D=e}},O=$({},[...pc,...mc,...hc]),rt=$({},[...gc,..._c]),k=function(e){let t=_(e);(!t||!t.tagName)&&(t={namespaceURI:Ge,tagName:`template`});let n=ec(e.tagName),r=ec(t.tagName);return qe[e.namespaceURI]?e.namespaceURI===Ue?t.namespaceURI===We?n===`svg`:t.namespaceURI===He?n===`svg`&&(r===`annotation-xml`||Ye[r]):!!O[n]:e.namespaceURI===He?t.namespaceURI===We?n===`math`:t.namespaceURI===Ue?n===`math`&&Xe[r]:!!rt[n]:e.namespaceURI===We?t.namespaceURI===Ue&&!Xe[r]||t.namespaceURI===He&&!Ye[r]?!1:!rt[n]&&(Ze[n]||!O[n]):!!(Qe===`application/xhtml+xml`&&qe[e.namespaceURI]):!1},it=function(e){Qs(t.removed,{element:e});try{_(e).removeChild(e)}catch{g(e)}},A=function(e,n){try{Qs(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{Qs(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Oe||ke)try{it(n)}catch{}else try{n.setAttribute(e,``)}catch{}},at=function(e){let t=null,r=null;if(De)e=`<remove></remove>`+e;else{let t=nc(e,/^[\r\n\t ]+/);r=t&&t[0]}Qe===`application/xhtml+xml`&&Ge===We&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=v?v.createHTML(e):e;if(Ge===We)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===We?ae.call(t,Te?`html`:`body`)[0]:Te?t.documentElement:a},ot=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)},st=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`)},ct=function(e){return typeof s==`function`&&e instanceof s};function j(e,n,r){Ys(e,e=>{e.call(t,n,r,D)})}let lt=function(e){let n=null;if(j(b.beforeSanitizeElements,e,null),st(e))return it(e),!0;let r=E(e.nodeName);if(j(b.uponSanitizeElement,e,{tagName:r,allowedTags:C}),we&&e.hasChildNodes()&&!ct(e.firstElementChild)&&Z(/<[/\w!]/g,e.innerHTML)&&Z(/<[/\w!]/g,e.textContent)||e.nodeType===Pc.progressingInstruction||we&&e.nodeType===Pc.comment&&Z(/<[/\w]/g,e.data))return it(e),!0;if(!(ve.tagCheck instanceof Function&&ve.tagCheck(r))&&(!C[r]||ge[r])){if(!ge[r]&&dt(r)&&(T.tagNameCheck instanceof RegExp&&Z(T.tagNameCheck,r)||T.tagNameCheck instanceof Function&&T.tagNameCheck(r)))return!1;if(Ne&&!Ie[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);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,ee(e))}}}return it(e),!0}return e instanceof c&&!k(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Z(/<\/no(script|embed|frames)/i,e.innerHTML)?(it(e),!0):(Ce&&e.nodeType===Pc.text&&(n=e.textContent,Ys([se,ce,le],e=>{n=rc(n,e,` `)}),e.textContent!==n&&(Qs(t.removed,{element:e.cloneNode()}),e.textContent=n)),j(b.afterSanitizeElements,e,null),!1)},ut=function(e,t,r){if(je&&(t===`id`||t===`name`)&&(r in n||r in et))return!1;if(!(be&&!_e[t]&&Z(x,t))&&!(ye&&Z(S,t))&&!(ve.attributeCheck instanceof Function&&ve.attributeCheck(t,e))){if(!w[t]||_e[t]){if(!(dt(e)&&(T.tagNameCheck instanceof RegExp&&Z(T.tagNameCheck,e)||T.tagNameCheck instanceof Function&&T.tagNameCheck(e))&&(T.attributeNameCheck instanceof RegExp&&Z(T.attributeNameCheck,t)||T.attributeNameCheck instanceof Function&&T.attributeNameCheck(t,e))||t===`is`&&T.allowCustomizedBuiltInElements&&(T.tagNameCheck instanceof RegExp&&Z(T.tagNameCheck,r)||T.tagNameCheck instanceof Function&&T.tagNameCheck(r))))return!1}else if(!Be[t]&&!Z(pe,rc(r,de,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&ic(r,`data:`)===0&&Re[e])&&!(xe&&!Z(ue,rc(r,de,``)))&&r)return!1}return!0},dt=function(e){return e!==`annotation-xml`&&nc(e,fe)},ft=function(e){j(b.beforeSanitizeAttributes,e,null);let{attributes:n}=e;if(!n||st(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:w,forceKeepAttr:void 0},i=n.length;for(;i--;){let{name:a,namespaceURI:o,value:s}=n[i],c=E(a),l=s,u=a===`value`?l:ac(l);if(r.attrName=c,r.attrValue=u,r.keepAttr=!0,r.forceKeepAttr=void 0,j(b.uponSanitizeAttribute,e,r),u=r.attrValue,Me&&(c===`id`||c===`name`)&&(A(a,e),u=`user-content-`+u),we&&Z(/((--!?|])>)|<\/(style|title|textarea)/i,u)){A(a,e);continue}if(c===`attributename`&&nc(u,`href`)){A(a,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){A(a,e);continue}if(!Se&&Z(/\/>/i,u)){A(a,e);continue}Ce&&Ys([se,ce,le],e=>{u=rc(u,e,` `)});let d=E(e.nodeName);if(!ut(d,c,u)){A(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),st(e)?it(e):Zs(t.removed)}catch{A(a,e)}}j(b.afterSanitizeAttributes,e,null)},pt=function e(t){let n=null,r=ot(t);for(j(b.beforeSanitizeShadowDOM,t,null);n=r.nextNode();)j(b.uponSanitizeShadowNode,n,null),lt(n),ft(n),n.content instanceof a&&e(n.content);j(b.afterSanitizeShadowDOM,t,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`&&!ct(e))if(typeof e.toString==`function`){if(e=e.toString(),typeof e!=`string`)throw sc(`dirty is not a string, aborting`)}else throw sc(`toString is not a function`);if(!t.isSupported)return e;if(Ee||nt(n),t.removed=[],typeof e==`string`&&(Pe=!1),Pe){if(e.nodeName){let t=E(e.nodeName);if(!C[t]||ge[t])throw sc(`root node is forbidden and cannot be sanitized in-place`)}}else if(e instanceof s)i=at(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===Pc.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=at(e),!i)return Oe?null:Ae?y:``}i&&De&&it(i.firstChild);let u=ot(Pe?e:i);for(;c=u.nextNode();)lt(c),ft(c),c.content instanceof a&&pt(c.content);if(Pe)return e;if(Oe){if(ke)for(l=ie.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(w.shadowroot||w.shadowrootmode)&&(l=oe.call(r,l,!0)),l}let d=Te?i.outerHTML:i.innerHTML;return Te&&C[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Z(jc,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
8
- `+d),Ce&&Ys([se,ce,le],e=>{d=rc(d,e,` `)}),v&&Ae?v.createHTML(d):d},t.setConfig=function(){nt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),Ee=!0},t.clearConfig=function(){D=null,Ee=!1},t.isValidAttribute=function(e,t,n){return D||nt({}),ut(E(e),E(t),n)},t.addHook=function(e,t){typeof t==`function`&&Qs(b[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=Xs(b[e],t);return n===-1?void 0:$s(b[e],n,1)[0]}return Zs(b[e])},t.removeHooks=function(e){b[e]=[]},t.removeAllHooks=function(){b=Lc()},t}var zc=Rc(),Bc=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,Vc=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|blob):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,Hc=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,Uc={ALLOWED_URI_REGEXP:Vc},Wc=e=>{if(!Bc.test(e.replace(Hc,``)))return``;let t=document.createElement(`a`);return t.setAttribute(`href`,e),zc.sanitize(t,{RETURN_DOM:!0,...Uc}).querySelector(`a`).getAttribute(`href`)??``},Gc=e=>{let t=document.createElement(`img`);return t.setAttribute(`src`,e),zc.sanitize(t,{RETURN_DOM:!0,...Uc}).querySelector(`img`).getAttribute(`src`)??``},Kc=e=>e.replace(/[;!].*/,``),qc=e=>({...e}),Jc=e=>({nodes:Object.fromEntries(Object.keys(e.nodes).map(t=>[t,(e.nodes[t].spec.parseDOM??[]).map(qc)])),marks:Object.fromEntries(Object.keys(e.marks).map(t=>[t,(e.marks[t].spec.parseDOM??[]).map(qc)]))}),Yc=class{constructor(e,t){this[m.r]=new Xc(e[m.r],t)}parseDocument(e,t){return this[m.r].parser.parse(this.parseHtml(e,t),{preserveWhitespace:!0}).toJSON()}parseFragment(e,t){return this[m.r].parser.parseSlice(this.parseHtml(e,t),{preserveWhitespace:!0}).content.toJSON()??[]}parseHtml(e,t){let n=zc.sanitize(e,{RETURN_DOM:!0,...Uc}),r=document.createDocumentFragment();return r.appendChild(n),t?.modifyDom?.(r),r}},Xc=class{constructor(e,t){let n=Jc(e.schema);t?.modifyParseRules?.(n),this.parser=Zc(e.schema,n)}transform(e){return zc.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=qc(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)});for(let e in n)n[e]?.forEach(t=>{a(t=qc(t)),t.node||t.ignore||t.mark||(t.node=e)});return new m.d(e,r)},Qc=class{constructor(e,t){this[m.r]=new $c(e[m.r],t)}serializeDocument(e,t){return this[m.r].serializeFragment(e.content,t)}serializeFragment(e,t){return this[m.r].serializeFragment(e,t)}},$c=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 m.f(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=m.p.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}},el=(e,t)=>{let n=e.topNodeType.createAndFill(null,t?m.p.fromJSON(e,t.content):null);if(!n)throw Error(`Document could not be parsed`);return n.check(),n},tl=class{constructor(e,t){this.options=t,this.feature=(e,t)=>this[m.r].getPublicInterface(e,t),this[m.r]=new nl(this,e,t)}getDocument(){return this[m.r].state.doc.toJSON()}reset(e){this[m.r].reset(e)}replaceSelection(e,t){let{state:n,tr:r,schema:i,dispatchTransaction:a}=this[m.r];r.replaceSelection(new m.b(m.p.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 A?new A(r.doc):O.between(l,c)):r.setSelection(O.between(c,c)),a(r)}replaceDocument(e,t){let{state:n,tr:r,schema:i,dispatchTransaction:a}=this[m.r];r.replaceWith(0,n.doc.content.size,el(i,e)),t?.selectContent?r.setSelection(new A(r.doc)):t?.cursorPlacement===`end`?r.setSelection(O.atEnd(r.doc)):r.setSelection(O.atStart(r.doc)),a(r)}},nl=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[m.r];this.config=i,this.schema=i.schema,this.textblockAttrs=i.textblockAttrs,this.features=i.features,this.foreignHtmlParser=r?.foreignHtmlParser??new Yc(n),this.foreignHtmlSerializer=r?.foreignHtmlSerializer??new Qc(n),this.styles=new t.y(m.c(i.features.flatMap(e=>e.getStyles()))),this.initState(r?.initialDocument)}initState(e){this.state=ht.create({doc:el(this.schema,e),schema:this.config.schema,plugins:m.c(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){this.view=new Ta(e,{state:this.state,dispatchTransaction:this.dispatchTransaction})}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))}},rl=class extends e.n(t.t){instanceChanged(e){e?.[m.r].destroyViewIfNeeded(),this._initViewIfNeeded(),e?.[m.r].styles.removeStylesFrom(this.shadowRoot),this.instance?.[m.r].styles.addStylesTo(this.shadowRoot)}_initViewIfNeeded(){let e=this.instance?.[m.r];e&&this.$fastController.isConnected&&!e.view&&(this._syncStateIfNeeded(),e.createView(this._editorEl))}_destroyViewIfNeeded(){this.instance?.[m.r].destroyViewIfNeeded()}connectedCallback(){super.connectedCallback(),this._initViewIfNeeded()}disconnectedCallback(){super.disconnectedCallback(),this._destroyViewIfNeeded()}localeChanged(){this._syncStateIfNeeded()}_syncStateIfNeeded(){this.instance?.[m.r].updateHostState({locale:this.locale,ctx:this._ctx})}};r.t([t.T],rl.prototype,`instance`,void 0);var il=e=>t.d`<template :_ctx="${()=>e}">
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`);require(`../bundled/numberConverter.cjs`);const 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/mixins.cjs`),l=require(`../bundled/definition12.cjs`),u=require(`../bundled/definition17.cjs`),d=require(`../bundled/definition18.cjs`),f=require(`../bundled/definition19.cjs`),p=require(`../bundled/divider.cjs`),m=require(`../bundled/slottable-request.cjs`),h=require(`../bundled/definition20.cjs`),g=require(`../bundled/definition21.cjs`);var ee=`:host{display:block}.rte{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{--editor-padding-inline:var(--rich-text-editor-padding-inline,16px);--editor-padding-block:var(--rich-text-editor-padding-block,8px);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}`,te=class extends e.n(t.t){instanceChanged(e){e?.[m.c].destroyViewIfNeeded(),this._initViewIfNeeded(),e?.[m.c].styles.removeStylesFrom(this.shadowRoot),this.instance?.[m.c].styles.addStylesTo(this.shadowRoot)}_initViewIfNeeded(){let e=this.instance?.[m.c];e&&this.$fastController.isConnected&&!e.view&&(this._syncStateIfNeeded(),e.createView(this._editorEl))}_destroyViewIfNeeded(){this.instance?.[m.c].destroyViewIfNeeded()}connectedCallback(){super.connectedCallback(),this._initViewIfNeeded()}disconnectedCallback(){super.disconnectedCallback(),this._destroyViewIfNeeded()}localeChanged(){this._syncStateIfNeeded()}_syncStateIfNeeded(){this.instance?.[m.c].updateHostState({locale:this.locale,ctx:this._ctx})}};r.t([t.T],te.prototype,`instance`,void 0);var _=e=>t.d`<template :_ctx="${()=>e}">
9
2
  <div class="rte">
10
3
  <div class="editor-viewport" ${n.t(`editorViewportElement`)}>
11
4
  <div class="editor-scroll-area">
@@ -18,14 +11,21 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
18
11
  <slot name="status"></slot>
19
12
  <div class="toolbar"></div>
20
13
  </div>
21
- </template>`,al={default:{placement:void 0,placementStrategy:o.r.AutoPlacementHorizontal,strategy:`absolute`},autocomplete:{placement:`bottom-start`,placementStrategy:o.r.Flip,strategy:`fixed`}},ol=e=>{let n=e.tagFor(o.i);return t.d`<${n}
14
+ </template>`,v={default:{placement:void 0,placementStrategy:o.r.AutoPlacementHorizontal,strategy:`absolute`},autocomplete:{placement:`bottom-start`,placementStrategy:o.r.Flip,strategy:`fixed`}},ne=e=>{let n=e.tagFor(o.i);return t.d`<${n}
22
15
  :anchor="${e=>e.anchorEl}"
23
- :placement="${e=>al[e.kind].placement}"
24
- :placementStrategy="${e=>al[e.kind].placementStrategy}"
16
+ :placement="${e=>v[e.kind].placement}"
17
+ :placementStrategy="${e=>v[e.kind].placementStrategy}"
25
18
  :open="${e=>e.open}"
26
19
  :offset="${e=>e.offset}"
27
- :strategy="${e=>al[e.kind].strategy}"
20
+ :strategy="${e=>v[e.kind].strategy}"
28
21
  exportparts="vvd-theme-alternate"
29
22
  >
30
23
  <slot></slot>
31
- </${n}>`},sl=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)}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.T],sl.prototype,`kind`,void 0),r.t([t.T],sl.prototype,`offset`,void 0),r.t([t.T],sl.prototype,`anchorBlocksPopover`,void 0),r.t([t.T],sl.prototype,`anchorEl`,void 0),r.t([t.T],sl.prototype,`anchorId`,void 0),r.t([t.T],sl.prototype,`requestedOpenState`,void 0),r.t([t.E],sl.prototype,`open`,null);var cl=t.o(`rich-text-editor-popover`,sl,ol,[o.t],{}),ll=`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}`,ul=class extends m.i{constructor(e){super(),this.enabledBlocks=e,this.name=`RteBasicTextBlocks`}getStyles(){return[this.contribution(ll)]}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(G(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}}},dl=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?fl(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function fl(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 pl=500;function ml({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 hl(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&hl(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function hl(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-pl),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 gl=(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 dl(/--$/,`—`,{inCodeMark:!1}),new dl(/\.\.\.$/,`…`,{inCodeMark:!1}),new dl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new dl(/"$/,`”`,{inCodeMark:!1}),new dl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new dl(/'$/,`’`,{inCodeMark:!1});var _l=e=>e.parent.textBetween(0,e.parentOffset,void 0,``),vl=class extends m.i{constructor(...e){super(...e),this.name=`RteInputRulesFeature`}getPlugins(e){let t=m.c(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(ml({rules:r}))),n.push(this.contribution(G({Backspace:gl}),m.a.high));let i=t.filter(e=>e.enterHandler).map(e=>e.enterHandler);return i.length>0&&n.push(this.contribution(G({Enter:(e,t)=>{let{$cursor:n}=e.selection;if(!n)return!1;let r=_l(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}}),m.a.highest)),n}},yl=class extends m.i{constructor(e){super(),this.config=e,this.name=`RteBase`}getSchema(){return[this.contribution({nodes:{doc:{content:`block+`},text:{group:`inline`}}})]}getFeatures(){return[this,new zs,new ul({heading1:this.config?.heading1??!1,heading2:this.config?.heading2??!1,heading3:this.config?.heading3??!1,paragraph:this.config?.paragraph??!0}),new vl]}getPublicInterface(e){let t=e.getFeature(`RteCore`);return{get disabled(){return t.disabled.getValue(e)},set disabled(n){t.disabled.setValue(e,n)}}}},bl=m.o(yl),xl=class extends m.i{constructor(e){super(),this.config=e,this.name=`RteTextBlockPickerFeature`}getToolbarItems(e){let t=e.getFeature(`RteBasicTextBlocks`);return[this.contribution({section:`font`,render:n=>ks(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=>Os(n,{text:r.label,value:r.node,disabled:()=>!t.setBlockType(e,r.node)(n.view.state)}))})},1)]}},Sl=m.o(xl),Cl=`.toolbar{background-color:var(--vvd-color-neutral-50);flex-wrap:wrap;align-items:center;gap:8px;padding:4px;display:flex}.toolbar--hidden{display:none}`,wl=class extends m.i{constructor(e){super(),this.config=e,this.name=`RteToolbarFeature`,this.hidden=new Wo(!1)}getStyles(){return[this.contribution(Cl)]}getPlugins(e){let t=[`history`,`font`,`text-style`,`textblock`,`insert`],n=new Map(t.map(e=>[e,[]]));for(let t of m.c(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=new ys(i,e,{popupPlacement:this.config?.popupDirection===`outward`?`bottom`:`top`,menuOffset:8,disabled:()=>r.disabled.getValue(e)}),o=i.dom.getRootNode().querySelector(`.toolbar`);a.bindProp(()=>this.hidden.getValue(e),e=>{o.classList.toggle(`toolbar--hidden`,e)});let s=!1;for(let e of t){let t=n.get(e);t.length&&s&&(o.appendChild(As(a)),s=!1);for(let e of t)o.appendChild(e.render(a)),s=!0}return{update(){a.updateBindings()},destroy(){o.innerHTML=``}}}}))]}getPublicInterface(e){let t=this.hidden;return{get hidden(){return t.getValue(e)},set hidden(n){t.setValue(e,n)}}}},Tl=m.o(wl),El=`.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}`,Dl=class extends m.i{constructor(e){super(),this.config=e,this.name=`RtePlaceholderFeature`}getStyles(){return[this.contribution(El)]}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 H.create(e.doc,[V.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)]}},Ol=m.o(Dl),kl=class extends m.i{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){let t=(e,t)=>(t?.(e.tr.replaceSelectionWith(e.schema.nodes.hardBreak.create(),!0).scrollIntoView()),!0),n={"Shift-Enter":t};return[this.contribution(G(n),m.a.high)]}},Al=m.o(kl),jl=Symbol(`mixedFontSize`),Ml=class extends m.i{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: ${Kc(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{"font-size":r.attrs.size};if(n.length===0){let t=this.defaultFontSizeForNode?.[e.parent.type.name];if(t)return{"font-size":t}}return null}}}})]}getPlugins(){return[this.contribution(G({"Mod-Shift-.":this.adjustFontSize(-1),"Mod-Shift-,":this.adjustFontSize(1)}))]}getToolbarItems(e){return[this.contribution({section:`font`,render:t=>Cs(t,{label:()=>e.getLocale().richTextEditor.textSize,trigger:Y(t,{label:()=>e.getLocale().richTextEditor.textSize,icon:`text-size-line`}),children:this.fontSizes.map(e=>ws(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=jl)};return e.doc.nodesBetween(t,n,(e,t,n)=>o===jl?!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(!bo(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 fe(t,t+e.nodeSize,r))});return n?.(c.scrollIntoView()),!0}}adjustFontSize(e){return(t,n)=>{let r=this.getFontSizeFromSelection(t);if(r===null||r===jl)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)}}},Nl=m.o(Ml),Pl=[`p`,0],Fl=[`blockquote`,0],Il=[`hr`],Ll=[`pre`,[`code`,0]],Rl=[`br`],zl={doc:{content:`block+`},paragraph:{content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM(){return Pl}},blockquote:{content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM(){return Fl}},horizontal_rule:{group:`block`,parseDOM:[{tag:`hr`}],toDOM(){return Il}},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 Ll}},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 Rl}}},Bl=[`em`,0],Vl=[`strong`,0],Hl=[`code`,0],Ul={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 Bl}},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 Vl}},code:{code:!0,parseDOM:[{tag:`code`}],toDOM(){return Hl}}};new m.y({nodes:zl,marks:Ul});var Wl=class extends m.i{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})]}},Gl=class extends Wl{constructor(...e){super(...e),this.name=`RteBoldFeature`,this.markName=`bold`}getSchema(){return[this.contribution({marks:{bold:Ul.strong}})]}getPlugins(e){return[this.contribution(G({"Mod-b":bo(e.schema.marks.bold)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Ds(t,{label:()=>t.rte.getLocale().richTextEditor.bold,icon:`bold-line`,markType:e.schema.marks.bold})},1)]}},Kl=m.o(Gl),ql=class extends Wl{constructor(...e){super(...e),this.name=`RteItalicFeature`,this.markName=`italic`}getSchema(){return[this.contribution({marks:{italic:Ul.em}})]}getPlugins(e){return[this.contribution(G({"Mod-i":bo(e.schema.marks.italic)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Ds(t,{label:()=>t.rte.getLocale().richTextEditor.italic,icon:`italic-line`,markType:e.schema.marks.italic})},2)]}},Jl=m.o(ql),Yl=class extends Wl{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(G({"Mod-u":bo(e.schema.marks.underline)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Ds(t,{label:()=>t.rte.getLocale().richTextEditor.underline,icon:`underline-line`,markType:e.schema.marks.underline})},3)]}},Xl=m.o(Yl),Zl=class extends Wl{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(G({"Alt-Shift-5":bo(e.schema.marks.strikethrough),"Cmd-Shift-X":bo(e.schema.marks.strikethrough)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Ds(t,{label:()=>t.rte.getLocale().richTextEditor.strikethrough,icon:`strikethrough-line`,markType:e.schema.marks.strikethrough})},4)]}},Ql=m.o(Zl),$l=`tt{font:var(--vvd-typography-base-code);font-variant-ligatures:unset;font-feature-settings:unset;font-size:unset;font-weight:unset;line-height:unset}`,eu=class extends Wl{constructor(...e){super(...e),this.name=`RteMonospaceFeature`,this.markName=`monospace`}getStyles(){return[this.contribution($l)]}getSchema(){return[this.contribution({marks:{monospace:{parseDOM:[{tag:`tt`},{tag:`code`}],toDOM(){return[`tt`,0]}}}})]}getPlugins(e){return[this.contribution(G({"Mod-M":bo(e.schema.marks.monospace)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>Ds(t,{label:()=>t.rte.getLocale().richTextEditor.monospace,icon:`monospace-line`,markType:e.schema.marks.monospace})},5)]}},tu=m.o(eu);function nu(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 ru=Symbol(`mixedColor`),iu=class extends m.i{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: ${Kc(t)};`,"data-text-color":t},0]},inclusive:!0}}})]}getToolbarItems(){return[this.contribution({section:`text-style`,render:e=>{let t=Y(e,{label:()=>e.rte.getLocale().richTextEditor.textColor,disabled:()=>!this.setColor(`any`)(e.view.state),icon:`textcolor-line`}),n=t.firstElementChild;return J(e,{children:[t,Ns(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=ru)};return e.doc.nodesBetween(r,i,(e,t,r)=>s===ru?!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===ru?null:s}setColor(e){return(t,n)=>{let{textColor:r}=t.schema.marks,{from:i,to:a,empty:o,$from:s}=t.selection;if(!nu(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 fe(t,t+e.nodeSize,i))});return n?.(c.scrollIntoView()),!0}}},au=m.o(iu),ou=`.rich-text ul,.rich-text ol{padding-inline-start:1.5em}.rich-text li{list-style-position:inside}`,su=e=>e.parentOffset===0,cu=e=>e.nodeSize===2,lu=e=>e.depth-1,uu=e=>e.depth-2,du=e=>e.parent,fu=e=>e.node(lu(e)),pu=e=>e.depth>2,mu=(e,t)=>e.index(t)===0,hu=(e,t)=>e.index(t)===e.node(t).childCount-1,gu=(e,t)=>{let n=e.node(t),r=e.index(t);return n.maybeChild(r-1)},_u=(e,t)=>{let n=e.node(t),r=e.index(t);return n.maybeChild(r+1)},vu=e=>{let{$from:t,$to:n}=e;if(e instanceof A){let r=O.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)),bu=e=>{let{$cursor:t}=e.selection;return t?.parent.type===e.schema.nodes.listItem?t:null},xu=(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},Su=(e,t,n)=>{pu(t)?Cu(t,n):wu(e,t,n)},Cu=(e,t)=>{let n=new m._(e.doc.resolve(e.before()),e.doc.resolve(e.after()),e.depth-1);t.lift(n,e.depth-2)},wu=(e,t,n)=>{let r=fu(t),i=t.index(uu(t)),a=Ho(t.node(uu(t)).contentMatchAt(i+1)),o=mu(t,lu(t)),s=hu(t,lu(t));n.step(new w(t.before()-(o?1:0),t.after()+(s?1:0),t.start(),t.end(),new m.b((o?m.p.empty:m.p.from(r.copy(m.p.empty))).append(m.p.from(a.create(e.textblockAttrs.extractFromNode(du(t))))).append(s?m.p.empty:m.p.from(r.copy(m.p.empty))),o?0:1,s?0:1),(o?0:1)+1))},Tu=(e,t,n,r)=>{n.parent.type===e.schema.nodes.listItem?Eu(t,n,r):Du(e,t,n,r)},Eu=(e,t,n)=>{let r=gu(t,lu(t))?.type===e,i=_u(t,lu(t))?.type===e,a=r?1:0,o=i?1:0;n.step(new w(t.before()-(r?1:0),t.after()+(i?1:0),t.before(),t.after(),new m.b(m.p.from(e.create(null,[])),a,o),1-a))},Du=(e,t,n,r)=>{r.step(new w(n.before(),n.after(),n.start(),n.end(),new m.b(m.p.from(t.create(null,[e.schema.nodes.listItem.create(e.textblockAttrs.extractFromNode(n.parent))])),0,0),2))},Ou=class extends m.i{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(ou)]}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){this.rte=e;let t=(e,t)=>{let n=bu(e);if(n&&su(n)){let r=e.tr;return Eu(fu(n).type,n,r),t?.(r.scrollIntoView()),!0}return!1},n=(e,t)=>{let n=bu(e);if(n&&su(n)&&pu(n)){let r=e.tr;return Cu(n,r),t?.(r.scrollIntoView()),!0}return!1};return[this.contribution(G({Enter:(e,t)=>{let n=bu(e);if(n&&cu(du(n))){let r=e.tr;return Su(this.rte,n,r),t?.(r.scrollIntoView()),!0}return!1},Backspace:(e,t)=>{let n=bu(e);if(n&&su(n)){if(mu(n,lu(n))&&gu(n,uu(n))?.type===fu(n).type)return!1;let r=e.tr;return Su(this.rte,n,r),t?.(r.scrollIntoView()),!0}return!1},Tab:t,"Shift-Tab":n,...this.config.bulletList?{"Mod-Shift-8":this.toggleList(e.schema.nodes.bulletList)}:{},...this.config.numberedList?{"Mod-Shift-7":this.toggleList(e.schema.nodes.numberedList)}:{}}),m.a.high)]}getToolbarItems(e){let t=[];return this.config.bulletList&&t.push(this.contribution({section:`textblock`,render:t=>Y(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=>Y(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 So((t,n)=>{let{$from:r,$to:i}=vu(t.selection);if(yu(r,i).type.isInGroup(`list`))if(xu(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));Su(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));Tu(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}=vu(t.selection);return yu(n,r).type.isInGroup(`list`)?xu(t,n,r,e):!1}},ku=m.o(Ou),Au=[{value:`left`,icon:`align-left-line`,label:`left`},{value:`center`,icon:`align-center-line`,label:`center`},{value:`right`,icon:`align-right-line`,label:`right`}],ju=e=>Au.find(t=>t.value===e)?.value??`left`,Mu=class extends m.i{constructor(...e){super(...e),this.name=`RteAlignmentFeature`}getTextblockAttrs(){return[this.contribution({name:`textAlign`,default:`left`,fromDOM(e){return ju(e.style.textAlign)},toStyles(e){return[`text-align: ${ju(e.attrs.textAlign)}`]}})]}getPlugins(){return[this.contribution(G({"Mod-L":this.setAlignment(`left`),"Mod-E":this.setAlignment(`center`),"Mod-R":this.setAlignment(`right`)}))]}getToolbarItems(){return[this.contribution({section:`textblock`,render:e=>Cs(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,trigger:Y(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,icon:()=>{let t=this.getAlignmentFromSelection(e.view.state);return Au.find(e=>e.value===t)?.icon??`align-left-line`}}),children:[Ts(e,{children:Au.map((t,n)=>Y(e,{icon:t.icon,label:()=>e.rte.getLocale().richTextEditor.alignments[t.label],slot:`header`,noTooltip:!0,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}}},Nu=m.o(Mu),Pu=`.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}`,Fu=`(?:https?://|www\\.)[^\\s<]+`;function Iu(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 Lu=class extends m.i{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(Pu)]}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:Wc(t)},0]}}}},m.a.high)]}getTextblockMarks(){return[this.contribution({markName:`link`})]}getInputRules(){let e=RegExp(`${Fu}$`);return[this.contribution({rule:new dl(RegExp(`${Fu} $`),(e,t,n,r)=>Iu(e,t[0],n,r)),enterHandler:{regex:e,handler:(e,t,n,r)=>Iu(e,t[0],n,r)}})]}getPlugins(e){let t=()=>(this.toolbarMenu.open=!0,!0);return[this.contribution(new M({props:{decorations:e=>{let t=this.getCurrentLink(e);if(t){let n=V.inline(t.start,t.end,{id:`current-link`});return H.create(e.doc,[n])}return null}},view:t=>{let n=new ys(t,e,{popupPlacement:`bottom`}),r=e.createComponent(sl);r.anchorId=`current-link`;let i=J(n,{className:`link-popover`,children:[J(n,{className:`link-popover-header`,children:[J(n,{className:`link-popover-label`,children:[Ms(n,{text:()=>this.getCurrentLink(n.view.state)?.text||``})]}),Y(n,{icon:`close-line`,label:()=>n.rte.getLocale().richTextEditor.close,noTooltip:!0,onClick:()=>{r.requestOpenState(!1)}})]}),J(n,{className:`link-popover-content`,children:[bs(n,{className:`link`,href:()=>this.getCurrentLink(n.view.state)?.href||``,target:`_blank`,rel:`noopener`,children:[Ms(n,{text:()=>this.getCurrentLink(n.view.state)?.href||``})]}),J(n,{className:`link-action-bar`,children:[Y(n,{icon:`delete-line`,label:()=>n.rte.getLocale().richTextEditor.delete,connotation:`alert`,variant:`popover`,noTooltip:!0,onClick:()=>{let{state:e,dispatch:t}=n.view;this.removeLink(e,t)}}),Y(n,{icon:`edit-line`,label:()=>n.rte.getLocale().richTextEditor.edit,variant:`popover`,noTooltip:!0,onClick:()=>(this.toolbarMenu.open=!0,r.requestOpenState(!1),!0)})]})]})]});return r.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(r),{update:e=>{let t=e.state;n.updateBindings();let i=this.getCurrentLink(t);r.requestOpenState(!!i)},destroy:()=>{r.remove()}}}})),this.contribution(G({"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=js(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=js(r,{label:()=>r.rte.getLocale().richTextEditor.linkUrl,type:`url`,placeholder:()=>r.rte.getLocale().richTextEditor.linkUrlPlaceholder,slot:`header`,value:()=>this.getCurrentLink(r.view.state)?.href||``,onInput:()=>{s()}}),o=Y(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)}}),s=()=>{o.querySelector(`[data-vvd-component="button"]`).disabled=!(i.value.length&&n(a.value))},c=Cs(r,{label:()=>r.rte.getLocale().richTextEditor.hyperlink,trigger:Y(r,{label:()=>r.rte.getLocale().richTextEditor.hyperlink,icon:`link-line`}),children:[J(r,{className:`link-toolbar-menu`,slot:`header`,children:[i,a,J(r,{className:`link-action-bar`,slot:`header`,children:[Y(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 O))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=-1,l=-1,u=!0;return e.doc.nodesBetween(r.start(),i.end(),(e,n)=>{if(!e.isText)return!0;let r=n+e.nodeSize;return s(e)?(c===-1&&(c=n),l=r):r>t.from&&n<t.to&&(u=!1),!1}),!u||c===-1?null:{text:e.doc.textBetween(c,l,` `),href:o,start:c,end:l}}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}}},Ru=m.o(Lu),zu=`.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}`,Bu=e=>e!==null&&!!e.next,Vu=1,Hu=()=>Vu++,Uu=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=Bu(i)?null:i;this.handleResolvedUrl(a),Bu(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)),sl.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-${Hu()}`,n=document.createElement(`slot`);n.className=`inline-image-placeholder`,n.name=t;let r=e.create?.(t),i=this.view.dom.getRootNode().host;m.t(i,`inline-image-placeholder`,t,{url:this.imageUrl}),this.setContent(n,{onDestroy:()=>{m.t(i,`inline-image-placeholder`,t,m.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)}},Wu=class extends m.i{constructor(e={}){super(),this.config=e,this.name=`RteInlineImageFeature`}getStyles(){return[this.contribution(zu)]}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: ${Kc(r)}; height: auto;`),i&&(s.width=i),a&&(s.height=a),[`img`,s]}}}})]}getPlugins(e){return[this.contribution(new M({props:{nodeViews:{inlineImage:(e,t,n)=>new Uu(e,t,n,this.config)}},view:t=>{let n=new ys(t,e,{popupPlacement:`bottom`}),r=e.createComponent(sl);r.offset=4;let i=J(n,{className:`inline-image-popover`,children:[Y(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.small,variant:`popover`,active:()=>this.getSelectedImageSize(n.view.state)===`small`,onClick:()=>{this.setSelectedImageSize(`small`)(n.view.state,n.view.dispatch)}}),As(n),Y(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.fit,variant:`popover`,active:()=>this.getSelectedImageSize(n.view.state)===`fit`,onClick:()=>{this.setSelectedImageSize(`fit`)(n.view.state,n.view.dispatch)}}),As(n),Y(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.original,variant:`popover`,active:()=>this.getSelectedImageSize(n.view.state)===`original`,onClick:()=>{this.setSelectedImageSize(`original`)(n.view.state,n.view.dispatch)}})]});return r.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(r),{update:e=>{n.updateBindings();let t=this.getSelectedInlineImage(e.state);t?(r.anchorEl=e.nodeDOM(t.pos),r.requestOpenState(!0)):(r.anchorEl=void 0,r.requestOpenState(!1))},destroy:()=>{r.remove()}}}}))]}calculateSmallWidth(e){return Math.min(300,e/2)+`px`}getSelectedInlineImage(e){let t=e.selection;return t instanceof k&&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}},Gu=m.o(Wu),Ku=async e=>{try{return{type:`ok`,result:await e}}catch(e){return{type:`error`,error:e}}},qu=class extends m.i{constructor(e){super(),this.config=e,this.name=`RteFileHandlerFeature`}getPlugins(e){let t=new M({state:{init(){return H.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=V.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.r();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=m.b.fromJSON(e.schema,{content:n});t.replaceSelection(r)}else{let i=m.p.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 Ku(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,n,r)=>{let a=Array.from(t.dataTransfer.files);if(!a.length)return!1;let o=e.posAtCoords({left:t.clientX,top:t.clientY}).pos;if(e.dragging&&e.dragging.slice){let t=Pe(e.state.doc,o,e.dragging.slice);t!=null&&(o=t)}return i(a,{type:`pos`,pos:o}),!0}}}))]}},Ju=m.o(qu),Yu=class extends m.i{constructor(e){super(),this.config=e,this.name=`RteDebugFeature`}getPlugins(e){let t=new WeakMap,n=!1,r=e=>{t.get(e)===void 0&&(n=this.config.onViewportDragOver?.(e)??!1)},i=e=>{this.config.onViewportDrop?.(e),this.config.onViewportDragFinish?.()},a=()=>{this.config.onViewportDragFinish?.()},o=!1,s=()=>{o=!0,window.setTimeout(()=>o=!1,0)},c=()=>{o||this.config.onViewportDragFinish?.()};return[this.contribution(new M({view:e=>{let t=e.root.host.editorViewportElement;return t.addEventListener(`dragover`,r),t.addEventListener(`drop`,i),t.addEventListener(`dragend`,a),t.addEventListener(`dragenter`,s),t.addEventListener(`dragleave`,c),{destroy(){t.removeEventListener(`dragover`,r),t.removeEventListener(`drop`,i),t.removeEventListener(`dragend`,a),t.removeEventListener(`dragenter`,s),t.removeEventListener(`dragleave`,c)}}}})),this.contribution(new M({props:{handleDOMEvents:{dragover:(e,r)=>{let i=this.config.onViewportDragOver?.(r)??!1;return t.set(r,i),n=i,i?(r.stopImmediatePropagation(),r.preventDefault(),!0):!1},drop:(e,t)=>n}}}),m.a.high)]}},Xu=m.o(Yu),Zu=class extends m.i{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteToolbarButtonFeature[${e}]`}getToolbarItems(){return[this.contribution({section:`insert`,render:e=>Y(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}}}},Qu=m.o(Zu),$u=e=>typeof e==`object`&&!!e&&`next`in e,ed=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;$u(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)}},td=class extends m.i{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 ed(e,this.config,this.atomName)}}}))]}},nd=m.o(td),rd=class extends m.i{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,m.p.fromJSON(e.schema,a)):null},r={rule:new dl(this.options.matchAfterWhitespace?RegExp(`${t} $`):RegExp(`${t}$`),n)};return this.options.matchAfterWhitespace&&(r.enterHandler={regex:RegExp(`${t}$`),handler:n}),[this.contribution(r)]}},id=m.o(rd);function ad(e,t){return e.length===0?(t,n)=>e():(n,r)=>e(t)}var od=class extends m.i{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]=ad(r,e.facade);return[this.contribution(G(t),m.a.high)]}},sd=m.o(od),cd=`.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}.suggest-item--visible-focus{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));--focus-stroke-gap-color:transparent}`,ld=e=>!!(e?.suggestions&&!e.dismissed),ud=e=>ld(e)&&e.suggestions.items.length>0;function dd(e,t){let{$cursor:n}=e.selection;if(!n)return null;let r=_l(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 fd=(e,t,n)=>{let{state:r}=e;e.dispatch(us(r.tr));let i=e.state.tr;i.replaceWith(t.start,t.end,m.p.fromJSON(e.state.schema,n));let a=i.mapping.map(t.end);i.setSelection(O.create(i.doc,a)),e.dispatch(i.scrollIntoView())},pd=class extends m.i{selectSuggestion(e,t,n){let r=this.options.select(n);fd(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 yt(`suggest`),this.loadGeneration=0,this.name=`RteSuggestFeature[${e}]`}getStyles(){return[this.contribution(cd)]}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=dd(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):H.create(t.doc,[V.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})]):H.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:H.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,[V.inline(t.match.start,t.match.end,{id:`suggest-anchor-${this.featureId}`})]):null}},view:t=>{let n=new ys(t,e,{popupPlacement:`bottom`}),r=e.createComponent(sl);r.anchorId=`suggest-anchor-${this.featureId}`,r.kind=`autocomplete`,r.offset=4;let i=J(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&&m.t(o,`suggestions-empty-state`,a,{id:this.featureId}),s&&!e&&m.t(o,`suggestions-empty-state`,a,m.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(J(n,{className:`suggest-empty-message`,children:[t]}));return}for(let[n,a]of o.items.entries()){let s=e.createComponent(d.r);s.text=a.text,s.textSecondary=a.textSecondary,n===o.selectedIndex&&(s._highlighted=!0,s.dataset.highlighted=`true`,o.visibleFocus&&s.classList.add(`suggest-item--visible-focus`),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=ld(t);r.requestOpenState(i),i?l(t):c(!1)},destroy:()=>{c(!1),r.remove()}}}});return[this.contribution(r),this.contribution(G({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)=>ld(this.pluginKey.getState(e))?(n?.(t({type:`dismiss`})),!0):!1}),m.a.high)]}},md=m.o(pd),hd=t.o(`rich-text-editor`,rl,il,[p.t,g.n,d.t,a.t,h.n,c.t,s.t,f.n,cl,i.t],{styles:ee,shadowOptions:{delegatesFocus:!0}});t.s(hd)(),exports.RteAlignmentFeature=Nu,exports.RteAtomFeature=nd,exports.RteBase=bl,exports.RteBoldFeature=Kl,exports.RteConfig=Pa,exports.RteDropHandlerFeature=Xu,exports.RteFileHandlerFeature=Ju,exports.RteFontSizePickerFeature=Nl,exports.RteHardBreakFeature=Al,exports.RteHtmlParser=Yc,exports.RteHtmlSerializer=Qc,exports.RteInlineImageFeature=Gu,exports.RteInputRuleFeature=id,exports.RteItalicFeature=Jl,exports.RteKeyboardShortcutsFeature=sd,exports.RteLinkFeature=Ru,exports.RteListFeature=ku,exports.RteMonospaceFeature=tu,exports.RtePlaceholderFeature=Ol,exports.RteStrikethroughFeature=Ql,exports.RteSuggestFeature=md,exports.RteTextBlockPickerFeature=Sl,exports.RteTextColorPickerFeature=au,exports.RteToolbarButtonFeature=Qu,exports.RteToolbarFeature=Tl,exports.RteUnderlineFeature=Xl;
24
+ </${n}>`},y=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)}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.T],y.prototype,`kind`,void 0),r.t([t.T],y.prototype,`offset`,void 0),r.t([t.T],y.prototype,`anchorBlocksPopover`,void 0),r.t([t.T],y.prototype,`anchorEl`,void 0),r.t([t.T],y.prototype,`anchorId`,void 0),r.t([t.T],y.prototype,`requestedOpenState`,void 0),r.t([t.E],y.prototype,`open`,null);var re=t.o(`rich-text-editor-popover`,y,ne,[o.t],{}),ie=65535,ae=2**16;function oe(e,t){return e+t*ae}function b(e){return e&ie}function se(e){return(e-(e&ie))/ae}var ce=1,le=2,ue=4,de=8,fe=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&de)>0}get deletedBefore(){return(this.delInfo&(ce|ue))>0}get deletedAfter(){return(this.delInfo&(le|ue))>0}get deletedAcross(){return(this.delInfo&ue)>0}},pe=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=b(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+se(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:oe(o/3,e-s),f=e==s?le:e==u?ce:ue;return(t<0?e!=s:e!=u)&&(f|=de),new fe(a,f,d)}r+=l-c}return n?e+r:new fe(e+r,0,null)}touches(e,t){let n=0,r=b(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])}};pe.empty=new pe([]);var me=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 fe(e,r,null)}},he=Object.create(null),x=class{getMap(){return pe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=he[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in he)throw RangeError(`Duplicate use of step JSON ID `+e);return he[e]=t,t.prototype.jsonID=e,t}},S=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 m.g)return e.fail(t.message);throw t}}};function C(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(C(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return m.d.fromArray(r)}var ge=class e extends x{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 m.v(C(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 S.fromReplace(e,this.from,this.to,i)}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:`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))}};x.jsonID(`addMark`,ge);var w=class e extends x{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 m.v(C(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return S.fromReplace(e,this.from,this.to,n)}invert(){return new ge(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))}};x.jsonID(`removeMark`,w);var _e=class e extends x{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return S.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return S.fromReplace(e,this.pos,this.pos+1,new m.v(m.d.from(n),0,t.isLeaf?0:1))}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 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:`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))}};x.jsonID(`addNodeMark`,_e);var ve=class e extends x{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return S.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return S.fromReplace(e,this.pos,this.pos+1,new m.v(m.d.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new _e(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))}};x.jsonID(`removeNodeMark`,ve);var T=class e extends x{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&ye(e,this.from,this.to)?S.fail(`Structure replace would overwrite content`):S.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new pe([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.from,1),r=t.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new e(n.pos,Math.max(n.pos,r.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?m.v.empty:new m.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?m.v.empty:new m.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,m.v.fromJSON(t,n.slice),!!n.structure)}};x.jsonID(`replace`,T);var E=class e extends x{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&&(ye(e,this.from,this.gapFrom)||ye(e,this.gapTo,this.to)))return S.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return S.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?S.fromReplace(e,this.from,this.to,n):S.fail(`Content does not fit in gap`)}getMap(){return new pe([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,m.v.fromJSON(t,n.slice),n.insert,!!n.structure)}};x.jsonID(`replaceAround`,E);function ye(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 be(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 w(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new ge(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function xe(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 m.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 w(t.from,t.to,t.style)))}function Se(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 T(s,l,m.v.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new w(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 m.v(m.d.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new T(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(m.d.empty,!0);e.replace(s,s,new m.v(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Ce(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function we(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||!Ce(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function Te(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=m.d.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=m.d.from(r.node(e).copy(u)),d++):c--;let f=m.d.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=m.d.from(i.node(e).copy(f)),p++):l++;e.step(new E(c,l,o,s,new m.v(u.append(f),d,p),u.size-d,!0))}function Ee(e,t,n){let r=m.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=m.d.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new E(i,a,i,a,new m.v(r,0,0),n.length,!0))}function De(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)&&Ae(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&&ke(e,t,n,a),Se(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 E(c,l,c+1,l-1,new m.v(m.d.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Oe(e,t,n,a),!1}})}function Oe(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 ke(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(`
25
+ `))}})}function Ae(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function je(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 E(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new m.v(m.d.from(o),0,0),1,!0))}function Me(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 Ne(e,t,n=1,r){let i=e.doc.resolve(t),a=m.d.empty,o=m.d.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=m.d.from(i.node(e).copy(a));let t=r&&r[s];o=m.d.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new T(t,t,new m.v(a.append(o),n,n),!0))}function Pe(e,t){let n=e.resolve(t),r=n.index();return Ie(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Fe(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 Ie(e,t){return!!(e&&t&&!e.isLeaf&&Fe(e,t))}function Le(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);ke(e,r.node(),r.before(),s)}o.inlineContent&&Se(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 T(l,c.map(t+n,-1),m.v.empty,!0)),r===!0){let t=e.doc.resolve(l);Oe(e,t.node(),t.before(),e.steps.length)}return e}function Re(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 ze(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?1: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 Be(e,t,n=t,r=m.v.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return Ve(i,a,r)?new T(t,n,r):new He(i,a,r).fit()}function Ve(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var He=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=m.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=m.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 m.v(i,a,o);return e>-1?new E(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new T(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=We(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(m.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=We(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new m.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=We(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new m.v(D(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new m.v(D(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(Ge(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=Ue(this.placed,t,m.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?m.v.empty:new m.v(D(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new m.v(D(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||!Ke(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=Ke(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=Ke(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=Ue(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=Ue(this.placed,this.depth,m.d.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(m.d.empty,!0);e.childCount&&(this.placed=Ue(this.placed,this.frontier.length,e))}};function D(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(D(e.firstChild.content,t-1,n)))}function Ue(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Ue(e.lastChild.content,t-1,n)))}function We(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Ge(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Ge(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(m.d.empty,!0)))),e.copy(r)}function Ke(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&&!qe(n,a.content,o)?s:null}function qe(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function Je(e){return e.spec.defining||e.spec.definingForContent}function Ye(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(Ve(i,a,r))return e.step(new T(t,n,r));let o=Qe(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=Je(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 m.v(Xe(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 Xe(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(Xe(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(m.d.empty,!0))}return e}function Ze(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Re(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new m.v(m.d.from(r),0,0))}function O(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),a=Qe(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 Qe(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 $e=class e extends x{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 S.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 S.fromReplace(e,this.pos,this.pos+1,new m.v(m.d.from(r),0,t.isLeaf?0:1))}getMap(){return pe.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)}};x.jsonID(`attr`,$e);var et=class e extends x{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 S.ok(n)}getMap(){return pe.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)}};x.jsonID(`docAttr`,et);var tt=class extends Error{};tt=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},tt.prototype=Object.create(Error.prototype),tt.prototype.constructor=tt,tt.prototype.name=`TransformError`;var nt=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new me}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new tt(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=m.v.empty){let r=Be(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new m.v(m.d.from(n),0,0))}delete(e,t){return this.replace(e,t,m.v.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Ye(this,e,t,n),this}replaceRangeWith(e,t,n){return Ze(this,e,t,n),this}deleteRange(e,t){return O(this,e,t),this}lift(e,t){return Te(this,e,t),this}join(e,t=1){return Le(this,e,t),this}wrap(e,t){return Ee(this,e,t),this}setBlockType(e,t=e,n,r=null){return De(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return je(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new $e(e,t,n)),this}setDocAttribute(e,t){return this.step(new et(e,t)),this}addNodeMark(e,t){return this.step(new _e(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof m.f)t.isInSet(n.marks)&&this.step(new ve(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new ve(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 Ne(this,e,t,n),this}addMark(e,t,n){return be(this,e,t,n),this}removeMark(e,t,n){return xe(this,e,t,n),this}clearIncompatible(e,t,n){return Se(this,e,t,n),this}},rt=Object.create(null),k=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new it(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=m.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?m.v.empty:t),o==0&&dt(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),dt(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new A(e):ut(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?ut(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):ut(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 ut(e,e,0,0,1)||new M(e)}static atEnd(e){return ut(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=rt[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in rt)throw RangeError(`Duplicate use of selection JSON ID `+e);return rt[e]=t,t.prototype.jsonID=e,t}getBookmark(){return A.between(this.$anchor,this.$head).getBookmark()}};k.prototype.visible=!0;var it=class{constructor(e,t){this.$from=e,this.$to=t}},at=!1;function ot(e){!at&&!e.parent.inlineContent&&(at=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var A=class e extends k{constructor(e,t=e){ot(e),ot(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 k.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=m.v.empty){if(super.replace(e,t),t==m.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 st(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=k.findFrom(n,r,!0)||k.findFrom(n,-r,!0);if(e)n=e.$head;else return k.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(k.findFrom(t,-r,!0)||k.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};k.jsonID(`text`,A);var st=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 A.between(e.resolve(this.anchor),e.resolve(this.head))}},j=class e extends k{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?k.near(a):new e(a)}content(){return new m.v(m.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 ct(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}};j.prototype.visible=!1,k.jsonID(`node`,j);var ct=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new st(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&j.isSelectable(n)?new j(t):k.near(t)}},M=class e extends k{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=m.v.empty){if(t==m.v.empty){e.delete(0,e.doc.content.size);let t=k.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 lt}};k.jsonID(`all`,M);var lt={map(){return this},resolve(e){return new M(e)}};function ut(e,t,n,r,i,a=!1){if(t.inlineContent)return A.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=ut(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&j.isSelectable(r))return j.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function dt(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof T||i instanceof E))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(k.near(e.doc.resolve(o),n))}var ft=1,pt=2,mt=4,ht=class extends nt{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|ft)&~pt,this.storedMarks=null,this}get selectionSet(){return(this.updated&ft)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=pt,this}ensureMarks(e){return m.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&pt)>0}addStep(e,t){super.addStep(e,t),this.updated&=~pt,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)||m.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(k.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|=mt,this}get scrolledIntoView(){return(this.updated&mt)>0}};function gt(e,t){return!t||!e?e:e.bind(t)}var _t=class{constructor(e,t,n){this.name=e,this.init=gt(t.init,n),this.apply=gt(t.apply,n)}},vt=[new _t(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new _t(`selection`,{init(e,t){return e.selection||k.atStart(t.doc)},apply(e){return e.selection}}),new _t(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new _t(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],yt=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=vt.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 _t(e.key,e.spec.state,e))})}},bt=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 ht(this)}static create(t){let n=new yt(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 yt(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 yt(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=m.m.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=k.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 xt(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=xt(i,t,{})),n[r]=i}return n}var N=class{constructor(e){this.spec=e,this.props={},e.props&&xt(e.props,this,this.props),this.key=e.key?e.key.key:Ct(`plugin`)}getState(e){return e[this.key]}},St=Object.create(null);function Ct(e){return e in St?e+`$`+ ++St[e]:(St[e]=0,e+`$`)}var wt=class{constructor(e=`key`){this.key=Ct(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},Tt=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},Et=null,Dt=function(e,t,n){let r=Et||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Ot=function(){Et=null},kt=function(e,t,n,r){return n&&(jt(e,t,n,r,-1)||jt(e,t,n,r,1))},At=/^(img|br|input|textarea|hr)$/i;function jt(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:F(e))){let n=e.parentNode;if(!n||n.nodeType!=1||Ft(e)||At.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?F(e):0}else return!1}}function F(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Mt(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=F(e)}else if(e.parentNode&&!Ft(e))t=P(e),e=e.parentNode;else return null}}function Nt(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&&!Ft(e))t=P(e)+1,e=e.parentNode;else return null}}function Pt(e,t,n){for(let r=t==0,i=t==F(e);r||i;){if(e==n)return!0;let t=P(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==F(e)}}function Ft(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 It=function(e){return e.focusNode&&kt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Lt(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function Rt(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function zt(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(F(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(F(r.startContainer),r.startOffset)}}}var Bt=typeof navigator<`u`?navigator:null,Vt=typeof document<`u`?document:null,Ht=Bt&&Bt.userAgent||``,Ut=/Edge\/(\d+)/.exec(Ht),Wt=/MSIE \d/.exec(Ht),Gt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ht),I=!!(Wt||Gt||Ut),Kt=Wt?document.documentMode:Gt?+Gt[1]:Ut?+Ut[1]:0,qt=!I&&/gecko\/(\d+)/i.test(Ht);qt&&+(/Firefox\/(\d+)/.exec(Ht)||[0,0])[1];var Jt=!I&&/Chrome\/(\d+)/.exec(Ht),L=!!Jt,Yt=Jt?+Jt[1]:0,R=!I&&!!Bt&&/Apple Computer/.test(Bt.vendor),Xt=R&&(/Mobile\/\w+/.test(Ht)||!!Bt&&Bt.maxTouchPoints>2),Zt=Xt||(Bt?/Mac/.test(Bt.platform):!1),Qt=Bt?/Win/.test(Bt.platform):!1,$t=/Android \d/.test(Ht),en=!!Vt&&`webkitFontSmoothing`in Vt.documentElement.style,tn=en?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function nn(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 rn(e,t){return typeof e==`number`?e:e[t]}function an(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 on(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=Tt(o);continue}let e=o,n=e==a.body,s=n?nn(a):an(e),c=0,l=0;if(t.top<s.top+rn(r,`top`)?l=-(s.top-t.top+rn(i,`top`)):t.bottom>s.bottom-rn(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+rn(i,`top`)-s.top:t.bottom-s.bottom+rn(i,`bottom`)),t.left<s.left+rn(r,`left`)?c=-(s.left-t.left+rn(i,`left`)):t.right>s.right-rn(r,`right`)&&(c=t.right-s.right+rn(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:Tt(o)}}function sn(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:cn(e.dom)}}function cn(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Tt(r));return t}function ln({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;un(n,r==0?0:r-t)}function un(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 dn=null;function fn(e){if(e.setActive)return e.setActive();if(dn)return e.focus(dn);let t=cn(e);e.focus(dn==null?{get preventScroll(){return dn={preventScroll:!0},!0}}:void 0),dn||(dn=!1,un(t,0))}function pn(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=Dt(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?1:0));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?mn(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:pn(n,i)}function mn(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=Sn(r,1);if(n.top!=n.bottom&&hn(t,n)){i={node:e,offset:a+(t.left>=(n.left+n.right)/2?1:0)};break}}return r.detach(),i||{node:e,offset:0}}function hn(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function gn(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function _n(e,t,n){let{node:r,offset:i}=pn(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 vn(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 yn(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(hn(t,i))return yn(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function bn(e,t){let n=e.dom.ownerDocument,r,i=0,a=zt(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(!hn(t,n)||(o=yn(e.dom,t,n),!o))return null}if(R)for(let e=o;r&&e;e=Tt(e))e.draggable&&(r=void 0);if(o=gn(o,t),r){if(qt&&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;en&&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=vn(e,r,i,t))}s??=_n(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function xn(e){return e.top<e.bottom||e.left<e.right}function Sn(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(xn(e))return e}return Array.prototype.find.call(n,xn)||e.getBoundingClientRect()}var Cn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function wn(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=en||qt;if(r.nodeType==3)if(o&&(Cn.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=Sn(Dt(r,i,i),n);if(qt&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=Sn(Dt(r,i-1,i-1),-1);if(t.top==e.top){let n=Sn(Dt(r,i,i+1),-1);if(n.top!=e.top)return Tn(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++,Tn(Sn(Dt(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==F(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return En(e.getBoundingClientRect(),!1)}if(a==null&&i<F(r)){let e=r.childNodes[i];if(e.nodeType==1)return En(e.getBoundingClientRect(),!0)}return En(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==F(r))){let e=r.childNodes[i-1],t=e.nodeType==3?Dt(e,F(e)-(o?0:1)):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return Tn(Sn(t,1),!1)}if(a==null&&i<F(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?Dt(e,0,o?0:1):e.nodeType==1?e:null:null;if(t)return Tn(Sn(t,-1),!0)}return Tn(Sn(r.nodeType==3?Dt(r):r,-n),n>=0)}function Tn(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 En(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 Dn(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 On(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return Dn(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=wn(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=Dt(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 kn=/[\u0590-\u08ac]/;function An(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?!kn.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:Dn(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 jn=null,Mn=null,Nn=!1;function Pn(e,t,n){return jn==t&&Mn==n?Nn:(jn=t,Mn=n,Nn=n==`up`||n==`down`?On(e,t,n):An(e,t,n))}var Fn=0,In=1,Ln=2,Rn=3,zn=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=Fn,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>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 Kn){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 Bn&&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}}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?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((qt||R)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
26
+ `),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(qt&&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&&R)&&kt(o.node,o.offset,l.anchorNode,l.anchorOffset)&&kt(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&qt)){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?Ln:In,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Rn:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ln:Rn}n=a}this.dirty=Ln}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Ln:In;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Bn=class extends zn{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==Fn&&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}},Vn=class extends zn{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}},Hn=class e extends zn{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=m.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&Rn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Rn&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Fn){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=Fn}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=lr(a,n,o,r)),t>0&&(a=lr(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()}},Un=class e extends zn{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=m.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=er(u,r,n),l?c=new qn(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new Gn(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=()=>m.d.empty)}return e}matchesNode(e,t,n){return this.dirty==Fn&&e.eq(this.node)&&tr(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}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 rr(this,a&&a.node,e);or(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?m.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==Ln)&&(a&&this.protectLocalComposition(e,a),Jn(this.contentDOM,this.children,e),Xt&&sr(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof A)||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=cr(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 Vn(this,i,t,r);e.input.compositionNodes.push(a),this.children=lr(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==Rn||!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=Fn}updateOuterDeco(e){if(tr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Qn(this.dom,this.nodeDOM,Zn(this.outerDeco,this.node,t),Zn(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 Wn(e,t,n,r,i){er(r,t,e);let a=new Un(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var Gn=class e extends Un{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==Rn||this.dirty!=Fn&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Fn||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=Fn,!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=Rn)}get domAtom(){return!1}isText(e){return this.node.text==e}},Kn=class extends zn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Fn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},qn=class extends Un{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==Rn)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 Jn(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=nr(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof Hn){let t=r?r.previousSibling:e.lastChild;Jn(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=nr(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var Yn=function(e){e&&(this.nodeName=e)};Yn.prototype=Object.create(null);var Xn=[new Yn];function Zn(e,t,n){if(e.length==0)return Xn;let r=n?Xn[0]:new Yn,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new Yn(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new Yn(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 Qn(e,t,n,r){if(n==Xn&&r==Xn)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=Xn[0],i=t)}$n(i,o||Xn[0],a)}return i}function $n(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 er(e,t,n){return Qn(e,e,Xn,Zn(t,n,e.nodeType!=1))}function tr(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 nr(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var rr=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=ir(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=Fn,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=Hn.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==Rn&&a.dom==a.contentDOM&&(a.dirty=Ln),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 Un){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!=Rn&&tr(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=Ln,u.updateChildren(r,a+1),u.dirty=Fn),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)||!tr(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=Un.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=Un.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 Bn(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 Hn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Gn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((R||L)&&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 Kn(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 ir(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 Hn)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 ar(e,t){return e.type.side-t.type.side}function or(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(ar);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 sr(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 cr(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 lr(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 ur(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(It(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&j.isSelectable(e)&&i.parent&&!(e.isInline&&Pt(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new j(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=xr(e,u,s,n)}return l}function dr(e){return e.editable?e.hasFocus():Cr(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function fr(e,t=!1){let n=e.state.selection;if(yr(e,n),dr(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&L){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&kt(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)vr(e);else{let{anchor:r,head:i}=n,a,o;pr&&!(n instanceof A)&&(n.$from.parent.inlineContent||(a=mr(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=mr(e,n.to))),e.docView.setSelection(r,i,e,t),pr&&(a&&gr(a),o&&gr(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&_r(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var pr=R||L&&Yt<63;function mr(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(R&&i&&i.contentEditable==`false`)return hr(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return hr(i);if(a)return hr(a)}}function hr(e){return e.contentEditable=`true`,R&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function gr(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function _r(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(()=>{(!dr(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function vr(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&&I&&Kt<=11&&(n.disabled=!0,n.disabled=!1)}function yr(e,t){if(t instanceof j){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(br(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else br(e)}function br(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function xr(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||A.between(t,n,r)}function Sr(e){return e.editable&&!e.hasFocus()?!1:Cr(e)}function Cr(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 wr(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return kt(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Tr(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&&k.findFrom(a,t)}function Er(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Dr(e,t,n){let r=e.state.selection;if(r instanceof A){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 Er(e,new A(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=Tr(e.state,t);return n&&n instanceof j?Er(e,n):!1}else if(!(Zt&&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?j.isSelectable(i)?Er(e,new j(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):en?Er(e,new A(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof j&&r.node.isInline)return Er(e,new A(t>0?r.$to:r.$from));else{let n=Tr(e.state,t);return n?Er(e,n):!1}}function Or(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function kr(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function Ar(e,t){return t<0?jr(e):Mr(e)}function jr(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(qt&&n.nodeType==1&&r<Or(n)&&kr(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(kr(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(Nr(n))break;else{let t=n.previousSibling;for(;t&&kr(t,-1);)i=n.parentNode,a=P(t),t=t.previousSibling;if(t)n=t,r=Or(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?Ir(e,n,r):i&&Ir(e,i,a)}function Mr(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=Or(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(kr(e,1))a=n,o=++r;else break}else if(Nr(n))break;else{let t=n.nextSibling;for(;t&&kr(t,1);)a=t.parentNode,o=P(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=Or(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&Ir(e,a,o)}function Nr(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Pr(e,t){for(;e&&t==e.childNodes.length&&!Ft(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 Fr(e,t){for(;e&&!t&&!Ft(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 Ir(e,t,n){if(t.nodeType!=3){let e,r;(r=Pr(t,n))?(t=r,n=0):(e=Fr(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(It(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&&fr(e)},50)}function Lr(e,t){let n=e.state.doc.resolve(t);if(!(L||Qt)&&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 Rr(e,t,n){let r=e.state.selection;if(r instanceof A&&!r.empty||n.indexOf(`s`)>-1||Zt&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=Tr(e.state,t);if(n&&n instanceof j)return Er(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof M?k.near(n,t):k.findFrom(n,t);return o?Er(e,o):!1}return!1}function zr(e,t){if(!(e.state.selection instanceof A))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 Br(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Vr(e){if(!R||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;Br(e,n,`true`),setTimeout(()=>Br(e,n,`false`),20)}return!1}function Hr(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function Ur(e,t){let n=t.keyCode,r=Hr(t);if(n==8||Zt&&n==72&&r==`c`)return zr(e,-1)||Ar(e,-1);if(n==46&&!t.shiftKey||Zt&&n==68&&r==`c`)return zr(e,1)||Ar(e,1);if(n==13||n==27)return!0;if(n==37||Zt&&n==66&&r==`c`){let t=n==37?Lr(e,e.state.selection.from)==`ltr`?-1:1:-1;return Dr(e,t,r)||Ar(e,t)}else if(n==39||Zt&&n==70&&r==`c`){let t=n==39?Lr(e,e.state.selection.from)==`ltr`?1:-1:1;return Dr(e,t,r)||Ar(e,t)}else if(n==38||Zt&&n==80&&r==`c`)return Rr(e,-1,r)||Ar(e,-1);else if(n==40||Zt&&n==78&&r==`c`)return Vr(e)||Rr(e,1,r)||Ar(e,1);else if(r==(Zt?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function Wr(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`)||m.u.fromSchema(e.state.schema),s=ti(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=$r[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,`
27
+
28
+ `),slice:t}}function Gr(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 m.v(m.d.from(e.state.schema.text(t.replace(/\r\n?/g,`
29
+ `))),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=m.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=ii(n),en&&ai(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`)||m.l.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Kr.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=oi(Qr(s,+u[1],+u[2]),u[4]);else if(s=m.v.maxOpen(qr(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=Qr(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var Kr=/^(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 qr(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&&Yr(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=Xr(a[a.length-1],i.length));let n=Jr(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return m.d.from(a)}return e}function Jr(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,m.d.from(e));return e}function Yr(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=Yr(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(m.d.from(Jr(n,e,i+1))))}}function Xr(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Xr(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(m.d.empty,!0);return e.copy(n.append(r))}function Zr(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=Zr(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(m.d.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function Qr(e,t,n){return t<e.openStart&&(e=new m.v(Zr(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new m.v(Zr(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var $r={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},ei=null;function ti(){return ei||=document.implementation.createHTMLDocument(`title`)}var ni=null;function ri(e){let t=window.trustedTypes;return t?(ni||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),ni.createHTML(e)):e}function ii(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=ti().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&$r[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=ri(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function ai(e){let t=e.querySelectorAll(L?`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 oi(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=m.d.from(t.create(r[e+1],i)),a++,o++}return new m.v(i,a,o)}var z={},B={},si={touchstart:!0,touchmove:!0},ci=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 li(e){for(let t in z){let n=z[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{mi(e,t)&&!pi(e,t)&&(e.editable||!(t.type in B))&&n(e,t)},si[t]?{passive:!0}:void 0)}R&&e.dom.addEventListener(`input`,()=>null),fi(e)}function ui(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function di(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 fi(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>pi(e,t))})}function pi(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function mi(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 hi(e,t){!pi(e,t)&&z[t.type]&&(e.editable||!(t.type in B))&&z[t.type](e,t)}B.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!ki(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!($t&&L&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),Xt&&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,Lt(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||Ur(e,n)?n.preventDefault():ui(e,`key`)},B.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},B.keypress=(e,t)=>{let n=t;if(ki(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Zt&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof A)||!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 gi(e){return{left:e.clientX,top:e.clientY}}function _i(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function vi(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 yi(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 bi(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&j.isSelectable(r)?(yi(e,new j(n),`pointer`),!0):!1}function xi(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof j&&(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(j.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:(yi(e,j.create(e.state.doc,i),`pointer`),!0)}function Si(e,t,n,r,i){return vi(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?xi(e,n):bi(e,n))}function Ci(e,t,n,r){return vi(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function wi(e,t,n,r){return vi(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Ti(e,n,r)}function Ti(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(yi(e,A.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)yi(e,A.create(r,a+1,a+1+n.content.size),`pointer`);else if(j.isSelectable(n))yi(e,j.create(r,a),`pointer`);else continue;return!0}}function Ei(e){return Ii(e)}var Di=Zt?`metaKey`:`ctrlKey`;z.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Ei(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&_i(n,e.input.lastClick)&&!n[Di]&&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(gi(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Oi(e,o,n,!!r)):(a==`doubleClick`?Ci:wi)(e,o.pos,o.inside,n)?n.preventDefault():ui(e,`pointer`))};var Oi=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[Di],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 j&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&qt&&!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)),ui(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(()=>fr(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(gi(e))),this.updateAllowDefault(e),this.allowDefault||!t?ui(this.view,`pointer`):Si(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||R&&this.mightDrag&&!this.mightDrag.node.isAtom||L&&!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)?(yi(this.view,k.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):ui(this.view,`pointer`)}move(e){this.updateAllowDefault(e),ui(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)}};z.touchstart=e=>{e.input.lastTouch=Date.now(),Ei(e),ui(e,`pointer`)},z.touchmove=e=>{e.input.lastTouch=Date.now(),ui(e,`pointer`)},z.contextmenu=e=>Ei(e);function ki(e,t){return e.composing?!0:R&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Ai=$t?5e3:-1;B.compositionstart=B.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof A&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||L&&Qt&&ji(e)))e.markCursor=e.state.storedMarks||n.marks(),Ii(e,!0),e.markCursor=null;else if(Ii(e,!t.selection.empty),qt&&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}Mi(e,Ai)};function ji(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`}B.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++,Mi(e,20))};function Mi(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Ii(e),t))}function Ni(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Fi());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Pi(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Mt(t.focusNode,t.focusOffset),r=Nt(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 Fi(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function Ii(e,t=!1){if(!($t&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Ni(e),t||e.docView&&e.docView.dirty){let n=ur(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 Li(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 Ri=I&&Kt<15||Xt&&tn<604;z.copy=B.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Ri?null:n.clipboardData,{dom:o,text:s}=Wr(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Li(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function zi(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Bi(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?Vi(e,r.value,null,i,t):Vi(e,r.textContent,r.innerHTML,i,t)},50)}function Vi(e,t,n,r,i){let a=Gr(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||m.v.empty)))return!0;if(!a)return!1;let o=zi(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 Hi(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,` `):``}B.paste=(e,t)=>{let n=t;if(e.composing&&!$t)return;let r=Ri?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Vi(e,Hi(r),r.getData(`text/html`),i,n)?n.preventDefault():Bi(e,n)};var Ui=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Wi=Zt?`altKey`:`ctrlKey`;function Gi(e,t){return e.someProp(`dragCopies`,e=>!e(t))??!t[Wi]}z.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(gi(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof j?i.to-1:i.to))){if(r&&r.mightDrag)o=j.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=j.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Wr(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!L||Yt>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ri?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Ri||n.dataTransfer.setData(`text/plain`,c),e.dragging=new Ui(l,Gi(e,n),o)},z.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},B.dragover=B.dragenter=(e,t)=>t.preventDefault(),B.drop=(e,t)=>{try{Ki(e,t,e.dragging)}finally{e.dragging=null}};function Ki(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(gi(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=Gr(e,Hi(t.dataTransfer),Ri?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&Gi(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||m.v.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?ze(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&&j.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new j(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(xr(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}z.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())&&fr(e)},20))},z.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)},z.beforeinput=(e,t)=>{if(L&&$t&&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,Lt(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 B)z[e]=B[e];function qi(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 Ji=class e{constructor(e,t){this.toDOM=e,this.spec=t||Qi,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 V(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&&qi(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Yi=class e{constructor(e,t){this.attrs=e,this.spec=t||Qi}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 V(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&qi(this.attrs,t.attrs)&&qi(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},Xi=class e{constructor(e,t){this.attrs=e,this.spec=t||Qi}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 V(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&&qi(this.attrs,t.attrs)&&qi(this.spec,t.spec)}destroy(){}},V=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 Ji(n,r))}static inline(t,n,r,i){return new e(t,n,new Yi(r,i))}static node(t,n,r,i){return new e(t,n,new Xi(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Yi}get widget(){return this.type instanceof Ji}},Zi=[],Qi={},H=class e{constructor(e,t){this.local=e.length?e:Zi,this.children=t.length?t:Zi}static create(e,t){return t.length?aa(t,e,0,Qi):U}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==U||e.maps.length==0?this:this.mapInner(e,t,0,0,n||Qi)}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?ea(this.children,o||[],t,n,r,i,a):o?new e(o.sort(oa),Zi):U}add(t,n){return n.length?this==U?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=ra(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,aa(s,e,o+1,Qi)),a+=3}});let o=ta(a?ia(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(oa):this.local,i||this.children)}remove(e){return e.length==0||this==U?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==U?(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):U}forChild(t,n){if(this==U)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 Yi){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(oa),Zi);return r?new $i([t,r]):t}return r||U}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 sa(this.localsInner(e))}localsInner(e){if(this==U)return Zi;if(e.inlineContent||!this.local.some(Yi.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof Yi||t.push(this.local[e]);return t}forEachSet(e){e(this)}};H.empty=new H([],[]),H.removeOverlap=sa;var U=H.empty,$i=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,Qi));return e.from(r)}forChild(t,n){if(n.isLeaf)return H.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=U&&(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?sa(n?t:t.sort(oa)):Zi}static from(t){switch(t.length){case 0:return U;case 1:return t[0];default:return new e(t.every(e=>e instanceof H)?t:t.reduce((e,t)=>e.concat(t instanceof H?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function ea(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==U?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=aa(na(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 H(t.sort(oa),s)}function ta(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 V(i.from+t,i.to+t,i.type))}return n}function na(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 ra(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 ia(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function aa(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=ra(e,t,o+n);if(s){a=!0;let e=aa(s,t,n+o+1,r);e!=U&&i.push(o,o+t.nodeSize,e)}});let o=ta(a?ia(e):e,-n).sort(oa);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 H(o,i):U}function oa(e,t){return e.from-t.from||e.to-t.to}function sa(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),ca(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),ca(t,i,r.copy(a.from,r.to)));break}}}return t}function ca(e,t,n){for(;t<e.length&&oa(n,e[t])>0;)t++;e.splice(t,0,n)}function la(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=U&&t.push(r)}),e.cursorWrapper&&t.push(H.create(e.state.doc,[e.cursorWrapper.deco])),$i.from(t)}var ua={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},da=I&&Kt<=11,fa=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}},pa=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new fa,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]);I&&Kt<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():R&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),da&&(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,ua)),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(Sr(this.view)){if(this.suppressingSelectionUpdates)return fr(this.view);if(I&&Kt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&kt(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=Tt(n))t.add(n);for(let r=e.anchorNode;r;r=Tt(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)&&Sr(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;t&&t.nodeType==1&&t.contentEditable==`false`&&e.parentNode.removeChild(e)}}else if(qt&&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||ya(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&&It(n)&&(c=ur(e))&&c.eq(k.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,fr(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),ga(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,ba(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||fr(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(I&&Kt<=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)}}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}}},ma=new WeakMap,ha=!1;function ga(e){if(!ma.has(e)&&(ma.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=qt,ha)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.`),ha=!0}}function _a(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return kt(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function va(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return _a(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?_a(e,n):null}function ya(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 ba(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 xa(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}],It(c)||l.push({node:c.focusNode,offset:c.focusOffset})),L&&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`)||m.l.fromSchema(e.state.schema),p=d.resolve(o),h=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:Sa,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,h={anchor:e+o,head:t+o}}return{doc:g,sel:h,from:o,to:s}}function Sa(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(R&&/^(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||R&&/^(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 Ca=/^(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 wa(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=ur(e,t);if(n&&!e.state.selection.eq(n)){if(L&&$t&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,Lt(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=xa(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=ka(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(Xt&&e.input.lastIOSEnter>Date.now()-225||$t)&&i.some(e=>e.nodeType==1&&!Ca.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,Lt(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof A&&!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=Ta(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 A&&(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)),I&&Kt<=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((Xt&&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,Lt(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&Da(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,Lt(8,`Backspace`)))){$t&&L&&e.domObserver.suppressSelectionUpdates();return}L&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),$t&&!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,Lt(13,`Enter`))})},20));let _=m.start,v=m.endA,ne=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=Ta(e,n.doc,l.sel);t&&!(L&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==_||t.head==n.mapping.map(v)-1)||I&&t.empty&&t.head==_)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},y;if(te)if(h.pos==g.pos){I&&Kt<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>fr(e),20));let t=ne(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&&(y=Ea(h.parent.content.cut(h.parentOffset,g.parentOffset),ee.parent.content.cut(ee.parentOffset,m.endA-ee.start())))){let t=ne(e.state.tr);y.type==`add`?t.addMark(_,v,y.mark):t.removeMark(_,v,y.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-(g.textOffset?0:1)){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>ne(e.state.tr.insertText(t,_,v));e.someProp(`handleTextInput`,r=>r(e,_,v,t,n))||e.dispatch(n())}else e.dispatch(ne());else e.dispatch(ne())}function Ta(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:xr(e,t.resolve(n.anchor),t.resolve(n.head))}function Ea(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(m.d.from(l).eq(e))return{mark:s,type:o}}function Da(e,t,n,r,i){if(n-t<=i.pos-r.pos||Oa(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(Oa(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Oa(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Oa(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 ka(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&&Aa(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&&Aa(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function Aa(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 ja=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 ci,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ra),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=Pa(this),Na(this),this.nodeViews=Ia(this),this.docView=Wn(this.state.doc,Ma(this),la(this),this.dom,this),this.domObserver=new pa(this,(e,t,n,r)=>wa(this,e,t,n,r)),this.domObserver.start(),li(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&&fi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ra),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&&(Ni(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=Ia(this);La(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&fi(this),this.editable=Pa(this),Na(this);let o=la(this),s=Ma(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&&sn(this);if(i){this.domObserver.stop();let t=l&&(I||L)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Fa(n.selection,e.selection);if(l){let n=L?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Pi(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=Wn(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())&&wr(this))?fr(this,t):(yr(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&&ln(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 j){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&on(this,t.getBoundingClientRect(),e)}else on(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(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&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new Ui(e.slice,e.move,r<0?void 0:j.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(I){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&&fn(this.dom),fr(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 bn(this,e)}coordsAtPos(e,t=1){return wn(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 Pn(this,t||this.state,e)}pasteHTML(e,t){return Vi(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return Vi(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Wr(this,e)}destroy(){this.docView&&(di(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],la(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ot())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return hi(this,e)}domSelectionRange(){let e=this.domSelection();return e?R&&this.root.nodeType===11&&Rt(this.dom.ownerDocument)==this.dom&&va(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};ja.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Ma(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`,[V.node(0,e.state.doc.content.size,t)]}function Na(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:V.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Pa(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Fa(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 Ia(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 La(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 Ra(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 za={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:`'`},Ba={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Va=typeof navigator<`u`&&/Mac/.test(navigator.platform),Ha=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),W=0;W<10;W++)za[48+W]=za[96+W]=String(W);for(var W=1;W<=24;W++)za[W+111]=`F`+W;for(var W=65;W<=90;W++)za[W]=String.fromCharCode(W+32),Ba[W]=String.fromCharCode(W);for(var Ua in za)Ba.hasOwnProperty(Ua)||(Ba[Ua]=za[Ua]);function Wa(e){var t=!(Va&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Ha&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Ba:za)[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 Ga=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ka=typeof navigator<`u`&&/Win/.test(navigator.platform);function qa(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))Ga?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 Ja(e){let t=Object.create(null);for(let n in e)t[qa(n)]=e[n];return t}function Ya(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 G(e){return new N({props:{handleKeyDown:Xa(e)}})}function Xa(e){let t=Ja(e);return function(e,n){let r=Wa(n),i,a=t[Ya(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[Ya(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Ka&&n.ctrlKey&&n.altKey)&&(i=za[n.keyCode])&&i!=r){let r=t[Ya(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var Za=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Qa(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var $a=(e,t,n)=>{let r=Qa(e,n);if(!r)return!1;let i=no(r);if(!i){let n=r.blockRange(),i=n&&we(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(_o(e,i,t,-1))return!0;if(r.parent.content.size==0&&(eo(a,`end`)||j.isSelectable(a)))for(let n=r.depth;;n--){let o=Be(e.doc,r.before(n),r.after(n),m.v.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(eo(a,`end`)?k.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):j.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 eo(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 to=(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=no(r)}let o=a&&a.nodeBefore;return!o||!j.isSelectable(o)?!1:(t&&t(e.tr.setSelection(j.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function no(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 ro(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var io=(e,t,n)=>{let r=ro(e,n);if(!r)return!1;let i=oo(r);if(!i)return!1;let a=i.nodeAfter;if(_o(e,i,t,1))return!0;if(r.parent.content.size==0&&(eo(a,`start`)||j.isSelectable(a))){let n=Be(e.doc,r.before(),r.after(),m.v.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(eo(a,`start`)?k.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):j.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},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(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=oo(r)}let o=a&&a.nodeAfter;return!o||!j.isSelectable(o)?!1:(t&&t(e.tr.setSelection(j.create(e.doc,a.pos)).scrollIntoView()),!0)};function oo(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 so=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
30
+ `).scrollIntoView()),!0)};function co(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 lo=(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=co(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(k.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},uo=(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=co(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(A.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},fo=(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(Me(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&we(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function po(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof j&&t.selection.node.isBlock)return!r.parentOffset||!Me(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=co(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 A||t.selection instanceof M)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=Me(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,Me(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 mo=po(),ho=(e,t)=>(t&&t(e.tr.setSelection(new M(e.doc))),!0);function go(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||Pe(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function _o(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&go(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=m.d.empty;for(let e=o.length-1;e>=0;e--)s=m.d.from(o[e].create(null,s));s=m.d.from(i.copy(s));let c=e.tr.step(new E(t.pos-1,r,t.pos,r,new m.v(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&Pe(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:k.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&we(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&eo(a,`start`,!0)&&eo(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=m.d.empty;for(let e=o.length-1;e>=0;e--)r=m.d.from(o[e].copy(r));n(e.tr.step(new E(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new m.v(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function vo(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(A.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var yo=vo(-1),bo=vo(1);function xo(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 So(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 it(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new it(r,i))}return t}function Co(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||!xo(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=So(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 wo(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--)Pe(n.doc,i[e])&&n.join(i[e]);e(n)}}function To(e,t){let n=Array.isArray(t)?e=>t.indexOf(e.type.name)>-1:t;return(t,r,i)=>e(t,r&&wo(r,n),i)}function Eo(...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 Do=Eo(Za,$a,to),Oo=Eo(Za,io,ao),ko={Enter:Eo(so,uo,fo,mo),"Mod-Enter":lo,Backspace:Do,"Mod-Backspace":Do,"Shift-Backspace":Do,Delete:Oo,"Mod-Delete":Oo,"Mod-a":ho},Ao={"Ctrl-h":ko.Backspace,"Alt-Backspace":ko[`Mod-Backspace`],"Ctrl-d":ko.Delete,"Ctrl-Alt-Backspace":ko[`Mod-Delete`],"Alt-Delete":ko[`Mod-Delete`],"Alt-d":ko[`Mod-Delete`],"Ctrl-a":yo,"Ctrl-e":bo};for(let e in ko)Ao[e]=ko[e];var jo=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?Ao:ko,Mo=`.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 No(e={}){return new N({view(t){return new Po(t,e)}})}var Po=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=ze(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)}},K=class e extends k{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):k.near(r)}content(){return m.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 Fo(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Lo(e)||!Ro(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&&!j.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}}};K.prototype.visible=!1,K.findFrom=K.findGapCursorFrom,k.jsonID(`gapcursor`,K);var Fo=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 K.valid(t)?new K(t):k.near(t)}};function Io(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Lo(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||Io(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Ro(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||Io(e.type))return!0;if(e.inlineContent)return!1}}return!0}function zo(){return new N({props:{decorations:Wo,createSelectionBetween(e,t,n){return t.pos==n.pos&&K.valid(n)?new K(n):null},handleClick:Ho,handleKeyDown:Bo,handleDOMEvents:{beforeinput:Uo}}})}var Bo=Xa({ArrowLeft:Vo(`horiz`,-1),ArrowRight:Vo(`horiz`,1),ArrowUp:Vo(`vert`,-1),ArrowDown:Vo(`vert`,1)});function Vo(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 A){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=K.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new K(c))),!0):!1}}function Ho(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!K.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&j.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new K(r))),!0)}function Uo(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof K))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=m.d.empty;for(let e=r.length-1;e>=0;e--)i=m.d.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new m.v(i,0,0));return a.setSelection(A.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function Wo(e){if(!(e.selection instanceof K))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,H.create(e.doc,[V.widget(e.selection.head,t,{key:`gapcursor`})])}function Go(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}throw Error(`No default textblock found.`)}var Ko=`[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}`,qo=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))}},Jo=`.ProseMirror{padding:var(--editor-padding-block) var(--editor-padding-inline);outline:none;flex:1}.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%)}`,Yo=200,q=function(){};q.prototype.append=function(e){return e.length?(e=q.from(e),!this.length&&e||e.length<Yo&&this.leafAppend(e)||this.length<Yo&&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 Zo(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 Xo(e):q.empty};var Xo=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<=Yo)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Yo)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 Xo([]);var Zo=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),Qo=500,$o=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 ts(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 ts(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 ts(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>rs&&(s=es(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new me;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 ts(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 ts(i,o,l))}else r.push(new ts(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new ts(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>Qo&&(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 ts(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)}};$o.empty=new $o(q.empty,0);function es(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var ts=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)}}},ns=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},rs=20;function is(e,t,n,r){let i=n.getMeta(ms),a;if(i)return i.historyState;n.getMeta(hs)&&(e=new ns(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(ms))return o.getMeta(ms).redo?new ns(e.done.addTransform(n,void 0,r,fs(t)),e.undone,ss(n.mapping.maps),e.prevTime,e.prevComposition):new ns(e.done,e.undone.addTransform(n,void 0,r,fs(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||!as(n,e.prevRanges)),s=o?cs(e.prevRanges,n.mapping):ss(n.mapping.maps);return new ns(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,fs(t)),$o.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new ns(e.done.rebased(n,a),e.undone.rebased(n,a),cs(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new ns(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),cs(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function as(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 ss(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 cs(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 ls(e,t,n){let r=fs(t),i=ms.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 ns(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(ms,{redo:n,historyState:c})}var us=!1,ds=null;function fs(e){let t=e.plugins;if(ds!=t){us=!1,ds=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){us=!0;break}}return us}function ps(e){return e.setMeta(hs,!0)}var ms=new wt(`history`),hs=new wt(`closeHistory`);function gs(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new N({key:ms,state:{init(){return new ns($o.empty,$o.empty,null,0,-1)},apply(t,n,r){return is(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?vs:n==`historyRedo`?ys:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function _s(e,t){return(n,r)=>{let i=ms.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=ls(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var vs=_s(!1,!0),ys=_s(!0,!0),bs=e=>typeof e==`function`,xs=(e,t,n)=>[e,t,n],Ss=class{constructor(e,t,n){this.view=e,this.rte=t,this.props=n,this.bindings=[]}evalProp(e){return bs(e)?e(this):e}bindProp(e,t){if(e!==void 0)if(bs(e)){let n=()=>t(e(this));this.bindings.push(n),n()}else t(e)}updateBindings(){for(let e of this.bindings)e()}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)}},J=(e,t)=>{let n=document.createElement(`div`);return e.bindToEl(n,{className:t.className,slot:t.slot},[],t.children),n},Cs=(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},ws=new WeakMap,Ts=(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=J(e,{className:`ui-tooltip-wrapper`,slot:t.slot,children:[t.anchor,n]});return ws.set(r,t.anchor),r},Y=(e,t)=>{let n=()=>e.evalProp(t.variant)??`toolbar`,r=()=>n()===`toolbar`?`super-condensed`:`condensed`,i=()=>n()===`popover-primary`?`outlined`:`ghost-light`,o=()=>e.evalProp(t.active)?`filled`:i(),s=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),c=e.rte.createComponent(a.i);return e.bindToEl(c,{size:r,appearance:o,disabled:s,icon:t.icon,autofocus:t.autofocus,connotation:t.connotation,[t.icon?`ariaLabel`:`label`]:t.label},[xs(`click`,t.onClick,t=>()=>{t()||e.view.focus()})]),Ts(e,{enabled:()=>!!(e.evalProp(t.icon)&&!e.evalProp(t.noTooltip)&&!s()),label:t.label,anchor:c,slot:t.slot})},Es=(e,t)=>{let n=e.rte.createComponent(g.r);e.bindToEl(n,{className:`ui-menu`,autoDismiss:!0,ariaLabel:t.label,anchor:ws.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},Ds=(e,t)=>{let n=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),r=e.rte.createComponent(h.i);return e.bindToEl(r,{text:t.text,checked:t.checked,disabled:n,controlType:`radio`,checkedAppearance:`tick-only`},[xs(`change`,t.onSelect,n=>()=>{r.checked&&!r.disabled&&e.evalProp(t.checked)!==r.checked&&(n(),e.view.focus())})]),r},Os=(e,t)=>J(e,{className:`ui-button-group`,children:t.children});function ks(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 As=(e,t)=>Y(e,{label:t.label,icon:t.icon,active:()=>ks(e.view.state,t.markType),disabled:()=>!Co(t.markType)(e.view.state),onClick:()=>{Co(t.markType)(e.view.state,e.view.dispatch)}}),js=(e,t)=>{let n=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),r=e.rte.createComponent(u.r);return e.bindToEl(r,{value:t.value,text:t.text,disabled:n}),r},Ms=(e,t)=>{let n=()=>!!e.evalProp(e.props.disabled),r=e.rte.createComponent(d.r);r.setAttribute(`data-class`,`ui-select`),e.bindToEl(r,{placeholder:` `,ariaLabel:t.label,appearance:`ghost`,disabled:n},[xs(`change`,t.onSelect,t=>()=>{let n=r.value;n&&(t(n),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()}),Ts(e,{enabled:()=>!i&&!n(),label:t.label,anchor:r})},Ns=e=>{let t=e.rte.createComponent(p.t);return e.bindToEl(t,{className:`ui-divider`,orientation:`vertical`}),t},Ps=(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},[xs(`input`,t.onInput,e=>()=>{e(n.value)})]),n},Fs=(e,t)=>{let n=document.createTextNode(``);return e.bindToEl(n,{textContent:t.text}),n},Is=(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.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},Ls=class extends m.r{constructor(...e){super(...e),this.name=`RteHistoryFeature`}getPlugins(){return[this.contribution(gs()),this.contribution(G({"Mod-z":vs,"Ctrl-y":ys,"Cmd-Z":ys}))]}getToolbarItems(){return[this.contribution({section:`history`,render:e=>Y(e,{label:e=>e.rte.getLocale().richTextEditor.undo,icon:`undo-line`,disabled:e=>!vs(e.view.state),onClick:()=>{let{state:t,dispatch:n}=e.view;vs(t,n)}})},1),this.contribution({section:`history`,render:e=>Y(e,{label:e=>e.rte.getLocale().richTextEditor.redo,icon:`redo-line`,disabled:e=>!ys(e.view.state),onClick:()=>{let{state:t,dispatch:n}=e.view;ys(t,n)}})},2)]}},Rs=class extends m.r{constructor(...e){super(...e),this.name=`RteForeignHtmlFeature`}getPlugins(e){return[this.contribution(new N({props:{transformPastedHTML:t=>e.foreignHtmlParser[m.c].transform(t),clipboardParser:e.foreignHtmlParser[m.c].parser,clipboardSerializer:e.foreignHtmlSerializer[m.c].serializer}}))]}},zs=e=>{if(e.parentOffset!==e.parent.content.size)return null;let t=e.nodeBefore;return t&&t.isInline&&t.isAtom&&!t.isText?{}:null},Bs=class extends m.r{constructor(...e){super(...e),this.name=`RteCursorFix`}getPlugins(e){let t=[zs];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=null;for(let i of t){let t=i(n,e);t&&Object.assign(r??={},t)}return r?H.create(e.doc,[V.widget(n.pos,()=>{let e=document.createElement(`span`);e.textContent=`​`;for(let[t,n]of Object.entries(r))e.style.setProperty(t,n);return e},{side:-1})]):null}}}))]}};m.a(Bs);var Vs=new N({state:{init(){return null},apply(e,t){return e.getMeta(Vs)||t}}}),Hs=class extends m.r{constructor(...e){super(...e),this.name=`RteCore`,this.disabled=new qo(!1)}getStyles(){return[this.contribution(Mo),this.contribution(Jo),this.contribution(Ko)]}getPlugins(e){let t=Eo(so,uo,fo,po((t,n,r)=>n?{type:Go(r.node(r.depth-1).contentMatchAt(r.indexAfter(r.depth-1))),attrs:e.textblockAttrs.extractFromNode(t)}:{type:t.type,attrs:t.attrs}));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=()=>{n.classList.toggle(`popovers--disabled`,this.disabled.getValue(e))};return r(),{update:()=>{r()}}}})),this.contribution(G({...jo,Enter:t,"Shift-Enter":t})),this.contribution(No()),this.contribution(zo()),this.contribution(Vs)]}getFeatures(){return[this,new Ls,new Rs,new Bs]}};m.a(Hs);var{entries:Us,setPrototypeOf:Ws,isFrozen:Gs,getPrototypeOf:Ks,getOwnPropertyDescriptor:qs}=Object,{freeze:X,seal:Js,create:Ys}=Object,{apply:Xs,construct:Zs}=typeof Reflect<`u`&&Reflect;X||=function(e){return e},Js||=function(e){return e},Xs||=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)},Zs||=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 Qs=Q(Array.prototype.forEach),$s=Q(Array.prototype.lastIndexOf),ec=Q(Array.prototype.pop),tc=Q(Array.prototype.push),nc=Q(Array.prototype.splice),rc=Q(String.prototype.toLowerCase),ic=Q(String.prototype.toString),ac=Q(String.prototype.match),oc=Q(String.prototype.replace),sc=Q(String.prototype.indexOf),cc=Q(String.prototype.trim),lc=Q(Object.prototype.hasOwnProperty),Z=Q(RegExp.prototype.test),uc=dc(TypeError);function Q(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 Xs(e,t,r)}}function dc(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return Zs(e,n)}}function $(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:rc;Ws&&Ws(e,null);let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(Gs(t)||(t[r]=e),i=e)}e[i]=!0}return e}function fc(e){for(let t=0;t<e.length;t++)lc(e,t)||(e[t]=null);return e}function pc(e){let t=Ys(null);for(let[n,r]of Us(e))lc(e,n)&&(Array.isArray(r)?t[n]=fc(r):r&&typeof r==`object`&&r.constructor===Object?t[n]=pc(r):t[n]=r);return t}function mc(e,t){for(;e!==null;){let n=qs(e,t);if(n){if(n.get)return Q(n.get);if(typeof n.value==`function`)return Q(n.value)}e=Ks(e)}function n(){return null}return n}var hc=X(`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(`.`)),gc=X(`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(`.`)),_c=X([`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`]),vc=X([`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`]),yc=X(`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(`.`)),bc=X([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),xc=X([`#text`]),Sc=X(`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.slot`.split(`.`)),Cc=X(`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(`.`)),wc=X(`accent.accentunder.align.bevelled.close.columnsalign.columnlines.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lspace.lquote.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Tc=X([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Ec=Js(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Dc=Js(/<%[\w\W]*|[\w\W]*%>/gm),Oc=Js(/\$\{[\w\W]*/gm),kc=Js(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ac=Js(/^aria-[\-\w]+$/),jc=Js(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Mc=Js(/^(?:\w+script|data):/i),Nc=Js(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pc=Js(/^html$/i),Fc=Js(/^[a-z][.\w]*(-[.\w]+)+$/i),Ic=Object.freeze({__proto__:null,ARIA_ATTR:Ac,ATTR_WHITESPACE:Nc,CUSTOM_ELEMENT:Fc,DATA_ATTR:kc,DOCTYPE_NAME:Pc,ERB_EXPR:Dc,IS_ALLOWED_URI:jc,IS_SCRIPT_OR_DATA:Mc,MUSTACHE_EXPR:Ec,TMPLIT_EXPR:Oc}),Lc={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Rc=function(){return typeof window>`u`?null:window},zc=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}},Bc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Vc(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Rc(),t=e=>Vc(e);if(t.version=`3.3.1`,t.removed=[],!e||!e.document||e.document.nodeType!==Lc.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=mc(m,`cloneNode`),g=mc(m,`remove`),ee=mc(m,`nextSibling`),te=mc(m,`childNodes`),_=mc(m,`parentNode`);if(typeof o==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let v,ne=``,{implementation:y,createNodeIterator:re,createDocumentFragment:ie,getElementsByTagName:ae}=n,{importNode:oe}=r,b=Bc();t.isSupported=typeof Us==`function`&&typeof _==`function`&&y&&y.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=$({},[...hc,...gc,..._c,...yc,...xc]),C=null,ge=$({},[...Sc,...Cc,...wc,...Tc]),w=Object.seal(Ys(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,T=Object.seal(Ys(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),E=!0,ye=!0,be=!1,xe=!0,Se=!1,Ce=!0,we=!1,Te=!1,Ee=!1,De=!1,Oe=!1,ke=!1,Ae=!0,je=!1,Me=!0,Ne=!1,Pe={},Fe=null,Ie=$({},[`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`]),Le=null,Re=$({},[`audio`,`video`,`img`,`source`,`image`,`track`]),ze=null,Be=$({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ve=`http://www.w3.org/1998/Math/MathML`,He=`http://www.w3.org/2000/svg`,D=`http://www.w3.org/1999/xhtml`,Ue=D,We=!1,Ge=null,Ke=$({},[Ve,He,D],ic),qe=$({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Je=$({},[`annotation-xml`]),Ye=$({},[`title`,`style`,`font`,`a`,`script`]),Xe=null,Ze=[`application/xhtml+xml`,`text/html`],O=null,Qe=null,$e=n.createElement(`form`),et=function(e){return e instanceof RegExp||e instanceof Function},tt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Qe&&Qe===e)){if((!e||typeof e!=`object`)&&(e={}),e=pc(e),Xe=Ze.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,O=Xe===`application/xhtml+xml`?ic:rc,x=lc(e,`ALLOWED_TAGS`)?$({},e.ALLOWED_TAGS,O):S,C=lc(e,`ALLOWED_ATTR`)?$({},e.ALLOWED_ATTR,O):ge,Ge=lc(e,`ALLOWED_NAMESPACES`)?$({},e.ALLOWED_NAMESPACES,ic):Ke,ze=lc(e,`ADD_URI_SAFE_ATTR`)?$(pc(Be),e.ADD_URI_SAFE_ATTR,O):Be,Le=lc(e,`ADD_DATA_URI_TAGS`)?$(pc(Re),e.ADD_DATA_URI_TAGS,O):Re,Fe=lc(e,`FORBID_CONTENTS`)?$({},e.FORBID_CONTENTS,O):Ie,_e=lc(e,`FORBID_TAGS`)?$({},e.FORBID_TAGS,O):pc({}),ve=lc(e,`FORBID_ATTR`)?$({},e.FORBID_ATTR,O):pc({}),Pe=lc(e,`USE_PROFILES`)?e.USE_PROFILES:!1,E=e.ALLOW_ARIA_ATTR!==!1,ye=e.ALLOW_DATA_ATTR!==!1,be=e.ALLOW_UNKNOWN_PROTOCOLS||!1,xe=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Se=e.SAFE_FOR_TEMPLATES||!1,Ce=e.SAFE_FOR_XML!==!1,we=e.WHOLE_DOCUMENT||!1,De=e.RETURN_DOM||!1,Oe=e.RETURN_DOM_FRAGMENT||!1,ke=e.RETURN_TRUSTED_TYPE||!1,Ee=e.FORCE_BODY||!1,Ae=e.SANITIZE_DOM!==!1,je=e.SANITIZE_NAMED_PROPS||!1,Me=e.KEEP_CONTENT!==!1,Ne=e.IN_PLACE||!1,he=e.ALLOWED_URI_REGEXP||jc,Ue=e.NAMESPACE||D,qe=e.MATHML_TEXT_INTEGRATION_POINTS||qe,Je=e.HTML_INTEGRATION_POINTS||Je,w=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&et(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(w.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&et(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(w.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements==`boolean`&&(w.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Se&&(ye=!1),Oe&&(De=!0),Pe&&(x=$({},xc),C=[],Pe.html===!0&&($(x,hc),$(C,Sc)),Pe.svg===!0&&($(x,gc),$(C,Cc),$(C,Tc)),Pe.svgFilters===!0&&($(x,_c),$(C,Cc),$(C,Tc)),Pe.mathMl===!0&&($(x,yc),$(C,wc),$(C,Tc))),e.ADD_TAGS&&(typeof e.ADD_TAGS==`function`?T.tagCheck=e.ADD_TAGS:(x===S&&(x=pc(x)),$(x,e.ADD_TAGS,O))),e.ADD_ATTR&&(typeof e.ADD_ATTR==`function`?T.attributeCheck=e.ADD_ATTR:(C===ge&&(C=pc(C)),$(C,e.ADD_ATTR,O))),e.ADD_URI_SAFE_ATTR&&$(ze,e.ADD_URI_SAFE_ATTR,O),e.FORBID_CONTENTS&&(Fe===Ie&&(Fe=pc(Fe)),$(Fe,e.FORBID_CONTENTS,O)),e.ADD_FORBID_CONTENTS&&(Fe===Ie&&(Fe=pc(Fe)),$(Fe,e.ADD_FORBID_CONTENTS,O)),Me&&(x[`#text`]=!0),we&&$(x,[`html`,`head`,`body`]),x.table&&($(x,[`tbody`]),delete _e.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw uc(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw uc(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);v=e.TRUSTED_TYPES_POLICY,ne=v.createHTML(``)}else v===void 0&&(v=zc(p,i)),v!==null&&typeof ne==`string`&&(ne=v.createHTML(``));X&&X(e),Qe=e}},nt=$({},[...gc,..._c,...vc]),rt=$({},[...yc,...bc]),k=function(e){let t=_(e);(!t||!t.tagName)&&(t={namespaceURI:Ue,tagName:`template`});let n=rc(e.tagName),r=rc(t.tagName);return Ge[e.namespaceURI]?e.namespaceURI===He?t.namespaceURI===D?n===`svg`:t.namespaceURI===Ve?n===`svg`&&(r===`annotation-xml`||qe[r]):!!nt[n]:e.namespaceURI===Ve?t.namespaceURI===D?n===`math`:t.namespaceURI===He?n===`math`&&Je[r]:!!rt[n]:e.namespaceURI===D?t.namespaceURI===He&&!Je[r]||t.namespaceURI===Ve&&!qe[r]?!1:!rt[n]&&(Ye[n]||!nt[n]):!!(Xe===`application/xhtml+xml`&&Ge[e.namespaceURI]):!1},it=function(e){tc(t.removed,{element:e});try{_(e).removeChild(e)}catch{g(e)}},at=function(e,n){try{tc(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{tc(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(De||Oe)try{it(n)}catch{}else try{n.setAttribute(e,``)}catch{}},ot=function(e){let t=null,r=null;if(Ee)e=`<remove></remove>`+e;else{let t=ac(e,/^[\r\n\t ]+/);r=t&&t[0]}Xe===`application/xhtml+xml`&&Ue===D&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=v?v.createHTML(e):e;if(Ue===D)try{t=new f().parseFromString(i,Xe)}catch{}if(!t||!t.documentElement){t=y.createDocument(Ue,`template`,null);try{t.documentElement.innerHTML=We?ne:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ue===D?ae.call(t,we?`html`:`body`)[0]:we?t.documentElement:a},A=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)},st=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`)},j=function(e){return typeof s==`function`&&e instanceof s};function ct(e,n,r){Qs(e,e=>{e.call(t,n,r,Qe)})}let M=function(e){let n=null;if(ct(b.beforeSanitizeElements,e,null),st(e))return it(e),!0;let r=O(e.nodeName);if(ct(b.uponSanitizeElement,e,{tagName:r,allowedTags:x}),Ce&&e.hasChildNodes()&&!j(e.firstElementChild)&&Z(/<[/\w!]/g,e.innerHTML)&&Z(/<[/\w!]/g,e.textContent)||e.nodeType===Lc.progressingInstruction||Ce&&e.nodeType===Lc.comment&&Z(/<[/\w]/g,e.data))return it(e),!0;if(!(T.tagCheck instanceof Function&&T.tagCheck(r))&&(!x[r]||_e[r])){if(!_e[r]&&ut(r)&&(w.tagNameCheck instanceof RegExp&&Z(w.tagNameCheck,r)||w.tagNameCheck instanceof Function&&w.tagNameCheck(r)))return!1;if(Me&&!Fe[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);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,ee(e))}}}return it(e),!0}return e instanceof c&&!k(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Z(/<\/no(script|embed|frames)/i,e.innerHTML)?(it(e),!0):(Se&&e.nodeType===Lc.text&&(n=e.textContent,Qs([se,ce,le],e=>{n=oc(n,e,` `)}),e.textContent!==n&&(tc(t.removed,{element:e.cloneNode()}),e.textContent=n)),ct(b.afterSanitizeElements,e,null),!1)},lt=function(e,t,r){if(Ae&&(t===`id`||t===`name`)&&(r in n||r in $e))return!1;if(!(ye&&!ve[t]&&Z(ue,t))&&!(E&&Z(de,t))&&!(T.attributeCheck instanceof Function&&T.attributeCheck(t,e))){if(!C[t]||ve[t]){if(!(ut(e)&&(w.tagNameCheck instanceof RegExp&&Z(w.tagNameCheck,e)||w.tagNameCheck instanceof Function&&w.tagNameCheck(e))&&(w.attributeNameCheck instanceof RegExp&&Z(w.attributeNameCheck,t)||w.attributeNameCheck instanceof Function&&w.attributeNameCheck(t,e))||t===`is`&&w.allowCustomizedBuiltInElements&&(w.tagNameCheck instanceof RegExp&&Z(w.tagNameCheck,r)||w.tagNameCheck instanceof Function&&w.tagNameCheck(r))))return!1}else if(!ze[t]&&!Z(he,oc(r,pe,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&sc(r,`data:`)===0&&Le[e])&&!(be&&!Z(fe,oc(r,pe,``)))&&r)return!1}return!0},ut=function(e){return e!==`annotation-xml`&&ac(e,me)},dt=function(e){ct(b.beforeSanitizeAttributes,e,null);let{attributes:n}=e;if(!n||st(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=O(a),l=s,u=a===`value`?l:cc(l);if(r.attrName=c,r.attrValue=u,r.keepAttr=!0,r.forceKeepAttr=void 0,ct(b.uponSanitizeAttribute,e,r),u=r.attrValue,je&&(c===`id`||c===`name`)&&(at(a,e),u=`user-content-`+u),Ce&&Z(/((--!?|])>)|<\/(style|title|textarea)/i,u)){at(a,e);continue}if(c===`attributename`&&ac(u,`href`)){at(a,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){at(a,e);continue}if(!xe&&Z(/\/>/i,u)){at(a,e);continue}Se&&Qs([se,ce,le],e=>{u=oc(u,e,` `)});let d=O(e.nodeName);if(!lt(d,c,u)){at(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),st(e)?it(e):ec(t.removed)}catch{at(a,e)}}ct(b.afterSanitizeAttributes,e,null)},ft=function e(t){let n=null,r=A(t);for(ct(b.beforeSanitizeShadowDOM,t,null);n=r.nextNode();)ct(b.uponSanitizeShadowNode,n,null),M(n),dt(n),n.content instanceof a&&e(n.content);ct(b.afterSanitizeShadowDOM,t,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(We=!e,We&&(e=`<!-->`),typeof e!=`string`&&!j(e))if(typeof e.toString==`function`){if(e=e.toString(),typeof e!=`string`)throw uc(`dirty is not a string, aborting`)}else throw uc(`toString is not a function`);if(!t.isSupported)return e;if(Te||tt(n),t.removed=[],typeof e==`string`&&(Ne=!1),Ne){if(e.nodeName){let t=O(e.nodeName);if(!x[t]||_e[t])throw uc(`root node is forbidden and cannot be sanitized in-place`)}}else if(e instanceof s)i=ot(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===Lc.element&&o.nodeName===`BODY`||o.nodeName===`HTML`?i=o:i.appendChild(o);else{if(!De&&!Se&&!we&&e.indexOf(`<`)===-1)return v&&ke?v.createHTML(e):e;if(i=ot(e),!i)return De?null:ke?ne:``}i&&Ee&&it(i.firstChild);let u=A(Ne?e:i);for(;c=u.nextNode();)M(c),dt(c),c.content instanceof a&&ft(c.content);if(Ne)return e;if(De){if(Oe)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=we?i.outerHTML:i.innerHTML;return we&&x[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Z(Pc,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
31
+ `+d),Se&&Qs([se,ce,le],e=>{d=oc(d,e,` `)}),v&&ke?v.createHTML(d):d},t.setConfig=function(){tt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),Te=!0},t.clearConfig=function(){Qe=null,Te=!1},t.isValidAttribute=function(e,t,n){return Qe||tt({}),lt(O(e),O(t),n)},t.addHook=function(e,t){typeof t==`function`&&tc(b[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=$s(b[e],t);return n===-1?void 0:nc(b[e],n,1)[0]}return ec(b[e])},t.removeHooks=function(e){b[e]=[]},t.removeAllHooks=function(){b=Bc()},t}var Hc=Vc(),Uc=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,Wc=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|blob):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,Gc=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,Kc={ALLOWED_URI_REGEXP:Wc},qc=e=>{if(!Uc.test(e.replace(Gc,``)))return``;let t=document.createElement(`a`);return t.setAttribute(`href`,e),Hc.sanitize(t,{RETURN_DOM:!0,...Kc}).querySelector(`a`).getAttribute(`href`)??``},Jc=e=>{let t=document.createElement(`img`);return t.setAttribute(`src`,e),Hc.sanitize(t,{RETURN_DOM:!0,...Kc}).querySelector(`img`).getAttribute(`src`)??``},Yc=e=>e.replace(/[;!].*/,``),Xc=e=>({...e}),Zc=e=>({nodes:Object.fromEntries(Object.keys(e.nodes).map(t=>[t,(e.nodes[t].spec.parseDOM??[]).map(Xc)])),marks:Object.fromEntries(Object.keys(e.marks).map(t=>[t,(e.marks[t].spec.parseDOM??[]).map(Xc)]))}),Qc=class{constructor(e,t){this[m.c]=new $c(e[m.c],t)}parseDocument(e,t){return this[m.c].parser.parse(this.parseHtml(e,t),{preserveWhitespace:!0}).toJSON()}parseFragment(e,t){return this[m.c].parser.parseSlice(this.parseHtml(e,t),{preserveWhitespace:!0}).content.toJSON()??[]}parseHtml(e,t){let n=Hc.sanitize(e,{RETURN_DOM:!0,...Kc}),r=document.createDocumentFragment();return r.appendChild(n),t?.modifyDom?.(r),r}},$c=class{constructor(e,t){let n=Zc(e.schema);t?.modifyParseRules?.(n),this.parser=el(e.schema,n)}transform(e){return Hc.sanitize(e)}},el=(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=Xc(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)});for(let e in n)n[e]?.forEach(t=>{a(t=Xc(t)),t.node||t.ignore||t.mark||(t.node=e)});return new m.l(e,r)},tl=class{constructor(e,t){this[m.c]=new nl(e[m.c],t)}serializeDocument(e,t){return this[m.c].serializeFragment(e.content,t)}serializeFragment(e,t){return this[m.c].serializeFragment(e,t)}},nl=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 m.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=m.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}},rl=(e,t)=>{let n=e.topNodeType.createAndFill(null,t?m.d.fromJSON(e,t.content):null);if(!n)throw Error(`Document could not be parsed`);return n.check(),n},il=class{constructor(e,t){this.options=t,this.feature=(e,t)=>this[m.c].getPublicInterface(e,t),this[m.c]=new al(this,e,t)}getDocument(){return this[m.c].state.doc.toJSON()}reset(e){this[m.c].reset(e)}replaceSelection(e,t){let{state:n,tr:r,schema:i,dispatchTransaction:a}=this[m.c];r.replaceSelection(new m.v(m.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):A.between(l,c)):r.setSelection(A.between(c,c)),a(r)}replaceDocument(e,t){let{state:n,tr:r,schema:i,dispatchTransaction:a}=this[m.c];r.replaceWith(0,n.doc.content.size,rl(i,e)),t?.selectContent?r.setSelection(new M(r.doc)):t?.cursorPlacement===`end`?r.setSelection(A.atEnd(r.doc)):r.setSelection(A.atStart(r.doc)),a(r)}},al=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[m.c];this.config=i,this.schema=i.schema,this.textblockAttrs=i.textblockAttrs,this.features=i.features,this.foreignHtmlParser=r?.foreignHtmlParser??new Qc(n),this.foreignHtmlSerializer=r?.foreignHtmlSerializer??new tl(n),this.styles=new t.y(m.s(i.features.flatMap(e=>e.getStyles()))),this.initState(r?.initialDocument)}initState(e){this.state=bt.create({doc:rl(this.schema,e),schema:this.config.schema,plugins:m.s(this.config.features.flatMap(e=>e.getPlugins(this)))})}reset(e){let t=Vs.getState(this.state);this.initState(e),this.updateHostState(t),this.view?.updateState(this.state)}createView(e){this.view=new ja(e,{state:this.state,dispatchTransaction:this.dispatchTransaction})}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=Vs.getState(this.state);if(!e)throw Error(`No host state available`);return e}updateHostState(e){this.dispatchTransaction(this.tr.setMeta(Vs,e))}},ol=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]})))}},sl=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))}},cl=(e,t)=>{let n=t.config[m.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,[m.c]:t},[m.c]:t}),o.push(n),s.push(r),l++}s[s.length-1].push({type:`node`,node:n,children:a(n.content??[]),[m.c]:t})}return{type:`fragment`,content:n,[m.c]:t}};return{type:`node`,node:e,children:a(e.content),[m.c]:t}},ll=class{constructor(e){this[m.c]=new ul(e)}instantiateEditor(e){return new il(this,e)}instantiateView(e,t){return cl(e,{config:this,options:{...t}})}},ul=class{constructor(e){let t=e=>e.flatMap(e=>e.getFeatures().flatMap(n=>n===e?e:t([n])));this.features=t(e.map(m.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=m.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 ol(m.s(this.features.flatMap(e=>e.getTextblockAttrs()))),this.textblockMarks=new sl(m.s(this.features.flatMap(e=>e.getTextblockMarks())));let n=m.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 m._(r)}},dl=`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}`,fl=class extends m.r{constructor(e){super(),this.enabledBlocks=e,this.name=`RteBasicTextBlocks`}getStyles(){return[this.contribution(dl)]}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(G(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}}},pl=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?ml(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function ml(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 hl=500;function gl({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 _l(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&_l(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function _l(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-hl),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 vl=(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 pl(/--$/,`—`,{inCodeMark:!1}),new pl(/\.\.\.$/,`…`,{inCodeMark:!1}),new pl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new pl(/"$/,`”`,{inCodeMark:!1}),new pl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new pl(/'$/,`’`,{inCodeMark:!1});var yl=e=>e.parent.textBetween(0,e.parentOffset,void 0,``),bl=class extends m.r{constructor(...e){super(...e),this.name=`RteInputRulesFeature`}getPlugins(e){let t=m.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(gl({rules:r}))),n.push(this.contribution(G({Backspace:vl}),m.i.high));let i=t.filter(e=>e.enterHandler).map(e=>e.enterHandler);return i.length>0&&n.push(this.contribution(G({Enter:(e,t)=>{let{$cursor:n}=e.selection;if(!n)return!1;let r=yl(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}}),m.i.highest)),n}},xl=class extends m.r{constructor(e){super(),this.config=e,this.name=`RteBase`}getSchema(){return[this.contribution({nodes:{doc:{content:`block+`},text:{group:`inline`}}})]}getFeatures(){return[this,new Hs,new fl({heading1:this.config?.heading1??!1,heading2:this.config?.heading2??!1,heading3:this.config?.heading3??!1,paragraph:this.config?.paragraph??!0}),new bl]}getPublicInterface(e){let t=e.getFeature(`RteCore`);return{get disabled(){return t.disabled.getValue(e)},set disabled(n){t.disabled.setValue(e,n)}}}},Sl=m.a(xl),Cl=class extends m.r{constructor(e){super(),this.config=e,this.name=`RteTextBlockPickerFeature`}getToolbarItems(e){let t=e.getFeature(`RteBasicTextBlocks`);return[this.contribution({section:`font`,render:n=>Ms(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=>js(n,{text:r.label,value:r.node,disabled:()=>!t.setBlockType(e,r.node)(n.view.state)}))})},1)]}},wl=m.a(Cl),Tl=`.toolbar{background-color:var(--vvd-color-neutral-50);flex-wrap:wrap;align-items:center;gap:8px;padding:4px;display:flex}.toolbar--hidden{display:none}`,El=class extends m.r{constructor(e){super(),this.config=e,this.name=`RteToolbarFeature`,this.hidden=new qo(!1)}getStyles(){return[this.contribution(Tl)]}getPlugins(e){let t=[`history`,`font`,`text-style`,`textblock`,`insert`],n=new Map(t.map(e=>[e,[]]));for(let t of m.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=new Ss(i,e,{popupPlacement:this.config?.popupDirection===`outward`?`bottom`:`top`,menuOffset:8,disabled:()=>r.disabled.getValue(e)}),o=i.dom.getRootNode().querySelector(`.toolbar`);a.bindProp(()=>this.hidden.getValue(e),e=>{o.classList.toggle(`toolbar--hidden`,e)});let s=!1;for(let e of t){let t=n.get(e);t.length&&s&&(o.appendChild(Ns(a)),s=!1);for(let e of t)o.appendChild(e.render(a)),s=!0}return{update(){a.updateBindings()},destroy(){o.innerHTML=``}}}}))]}getPublicInterface(e){let t=this.hidden;return{get hidden(){return t.getValue(e)},set hidden(n){t.setValue(e,n)}}}},Dl=m.a(El),Ol=`.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}`,kl=class extends m.r{constructor(e){super(),this.config=e,this.name=`RtePlaceholderFeature`}getStyles(){return[this.contribution(Ol)]}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 H.create(e.doc,[V.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)]}},Al=m.a(kl),jl=class extends m.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){let t=(e,t)=>(t?.(e.tr.replaceSelectionWith(e.schema.nodes.hardBreak.create(),!0).scrollIntoView()),!0),n={"Shift-Enter":t};return[this.contribution(G(n),m.i.high)]}},Ml=m.a(jl),Nl=Symbol(`mixedFontSize`),Pl=class extends m.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: ${Yc(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{"font-size":r.attrs.size};if(n.length===0){let t=this.defaultFontSizeForNode?.[e.parent.type.name];if(t)return{"font-size":t}}return null}}}})]}getPlugins(){return[this.contribution(G({"Mod-Shift-.":this.adjustFontSize(-1),"Mod-Shift-,":this.adjustFontSize(1)}))]}getToolbarItems(e){return[this.contribution({section:`font`,render:t=>Es(t,{label:()=>e.getLocale().richTextEditor.textSize,trigger:Y(t,{label:()=>e.getLocale().richTextEditor.textSize,icon:`text-size-line`}),children:this.fontSizes.map(e=>Ds(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=Nl)};return e.doc.nodesBetween(t,n,(e,t,n)=>o===Nl?!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(!Co(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 w(t,t+e.nodeSize,r))});return n?.(c.scrollIntoView()),!0}}adjustFontSize(e){return(t,n)=>{let r=this.getFontSizeFromSelection(t);if(r===null||r===Nl)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)}}},Fl=m.a(Pl),Il=[`p`,0],Ll=[`blockquote`,0],Rl=[`hr`],zl=[`pre`,[`code`,0]],Bl=[`br`],Vl={doc:{content:`block+`},paragraph:{content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM(){return Il}},blockquote:{content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM(){return Ll}},horizontal_rule:{group:`block`,parseDOM:[{tag:`hr`}],toDOM(){return Rl}},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 zl}},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 Bl}}},Hl=[`em`,0],Ul=[`strong`,0],Wl=[`code`,0],Gl={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 Hl}},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 Ul}},code:{code:!0,parseDOM:[{tag:`code`}],toDOM(){return Wl}}};new m._({nodes:Vl,marks:Gl});var Kl=class extends m.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})]}},ql=class extends Kl{constructor(...e){super(...e),this.name=`RteBoldFeature`,this.markName=`bold`}getSchema(){return[this.contribution({marks:{bold:Gl.strong}})]}getPlugins(e){return[this.contribution(G({"Mod-b":Co(e.schema.marks.bold)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>As(t,{label:()=>t.rte.getLocale().richTextEditor.bold,icon:`bold-line`,markType:e.schema.marks.bold})},1)]}},Jl=m.a(ql),Yl=class extends Kl{constructor(...e){super(...e),this.name=`RteItalicFeature`,this.markName=`italic`}getSchema(){return[this.contribution({marks:{italic:Gl.em}})]}getPlugins(e){return[this.contribution(G({"Mod-i":Co(e.schema.marks.italic)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>As(t,{label:()=>t.rte.getLocale().richTextEditor.italic,icon:`italic-line`,markType:e.schema.marks.italic})},2)]}},Xl=m.a(Yl),Zl=class extends Kl{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(G({"Mod-u":Co(e.schema.marks.underline)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>As(t,{label:()=>t.rte.getLocale().richTextEditor.underline,icon:`underline-line`,markType:e.schema.marks.underline})},3)]}},Ql=m.a(Zl),$l=class extends Kl{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(G({"Alt-Shift-5":Co(e.schema.marks.strikethrough),"Cmd-Shift-X":Co(e.schema.marks.strikethrough)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>As(t,{label:()=>t.rte.getLocale().richTextEditor.strikethrough,icon:`strikethrough-line`,markType:e.schema.marks.strikethrough})},4)]}},eu=m.a($l),tu=`tt{font:var(--vvd-typography-base-code);font-variant-ligatures:unset;font-feature-settings:unset;font-size:unset;font-weight:unset;line-height:unset}`,nu=class extends Kl{constructor(...e){super(...e),this.name=`RteMonospaceFeature`,this.markName=`monospace`}getStyles(){return[this.contribution(tu)]}getSchema(){return[this.contribution({marks:{monospace:{parseDOM:[{tag:`tt`},{tag:`code`}],toDOM(){return[`tt`,0]}}}})]}getPlugins(e){return[this.contribution(G({"Mod-M":Co(e.schema.marks.monospace)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>As(t,{label:()=>t.rte.getLocale().richTextEditor.monospace,icon:`monospace-line`,markType:e.schema.marks.monospace})},5)]}},ru=m.a(nu);function iu(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 au=Symbol(`mixedColor`),ou=class extends m.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: ${Yc(t)};`,"data-text-color":t},0]},inclusive:!0}}})]}getToolbarItems(){return[this.contribution({section:`text-style`,render:e=>{let t=Y(e,{label:()=>e.rte.getLocale().richTextEditor.textColor,disabled:()=>!this.setColor(`any`)(e.view.state),icon:`textcolor-line`}),n=t.firstElementChild;return J(e,{children:[t,Is(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=au)};return e.doc.nodesBetween(r,i,(e,t,r)=>s===au?!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===au?null:s}setColor(e){return(t,n)=>{let{textColor:r}=t.schema.marks,{from:i,to:a,empty:o,$from:s}=t.selection;if(!iu(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 w(t,t+e.nodeSize,i))});return n?.(c.scrollIntoView()),!0}}},su=m.a(ou),cu=`.rich-text ul,.rich-text ol{padding-inline-start:1.5em}.rich-text li{list-style-position:inside}`,lu=e=>e.parentOffset===0,uu=e=>e.nodeSize===2,du=e=>e.depth-1,fu=e=>e.depth-2,pu=e=>e.parent,mu=e=>e.node(du(e)),hu=e=>e.depth>2,gu=(e,t)=>e.index(t)===0,_u=(e,t)=>e.index(t)===e.node(t).childCount-1,vu=(e,t)=>{let n=e.node(t),r=e.index(t);return n.maybeChild(r-1)},yu=(e,t)=>{let n=e.node(t),r=e.index(t);return n.maybeChild(r+1)},bu=e=>{let{$from:t,$to:n}=e;if(e instanceof M){let r=A.between(e.$from,e.$to);t=r.$from,n=r.$to}return{$from:t,$to:n}},xu=(e,t)=>e.sameParent(t)?e.node(-1):e.node(e.sharedDepth(t.pos)),Su=e=>{let{$cursor:t}=e.selection;return t?.parent.type===e.schema.nodes.listItem?t:null},Cu=(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},wu=(e,t,n)=>{hu(t)?Tu(t,n):Eu(e,t,n)},Tu=(e,t)=>{let n=new m.h(e.doc.resolve(e.before()),e.doc.resolve(e.after()),e.depth-1);t.lift(n,e.depth-2)},Eu=(e,t,n)=>{let r=mu(t),i=t.index(fu(t)),a=Go(t.node(fu(t)).contentMatchAt(i+1)),o=gu(t,du(t)),s=_u(t,du(t));n.step(new E(t.before()-(o?1:0),t.after()+(s?1:0),t.start(),t.end(),new m.v((o?m.d.empty:m.d.from(r.copy(m.d.empty))).append(m.d.from(a.create(e.textblockAttrs.extractFromNode(pu(t))))).append(s?m.d.empty:m.d.from(r.copy(m.d.empty))),o?0:1,s?0:1),(o?0:1)+1))},Du=(e,t,n,r)=>{n.parent.type===e.schema.nodes.listItem?Ou(t,n,r):ku(e,t,n,r)},Ou=(e,t,n)=>{let r=vu(t,du(t))?.type===e,i=yu(t,du(t))?.type===e,a=r?1:0,o=i?1:0;n.step(new E(t.before()-(r?1:0),t.after()+(i?1:0),t.before(),t.after(),new m.v(m.d.from(e.create(null,[])),a,o),1-a))},ku=(e,t,n,r)=>{r.step(new E(n.before(),n.after(),n.start(),n.end(),new m.v(m.d.from(t.create(null,[e.schema.nodes.listItem.create(e.textblockAttrs.extractFromNode(n.parent))])),0,0),2))},Au=class extends m.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(cu)]}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){this.rte=e;let t=(e,t)=>{let n=Su(e);if(n&&lu(n)){let r=e.tr;return Ou(mu(n).type,n,r),t?.(r.scrollIntoView()),!0}return!1},n=(e,t)=>{let n=Su(e);if(n&&lu(n)&&hu(n)){let r=e.tr;return Tu(n,r),t?.(r.scrollIntoView()),!0}return!1};return[this.contribution(G({Enter:(e,t)=>{let n=Su(e);if(n&&uu(pu(n))){let r=e.tr;return wu(this.rte,n,r),t?.(r.scrollIntoView()),!0}return!1},Backspace:(e,t)=>{let n=Su(e);if(n&&lu(n)){if(gu(n,du(n))&&vu(n,fu(n))?.type===mu(n).type)return!1;let r=e.tr;return wu(this.rte,n,r),t?.(r.scrollIntoView()),!0}return!1},Tab:t,"Shift-Tab":n,...this.config.bulletList?{"Mod-Shift-8":this.toggleList(e.schema.nodes.bulletList)}:{},...this.config.numberedList?{"Mod-Shift-7":this.toggleList(e.schema.nodes.numberedList)}:{}}),m.i.high)]}getToolbarItems(e){let t=[];return this.config.bulletList&&t.push(this.contribution({section:`textblock`,render:t=>Y(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=>Y(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 To((t,n)=>{let{$from:r,$to:i}=bu(t.selection);if(xu(r,i).type.isInGroup(`list`))if(Cu(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));wu(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));Du(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}=bu(t.selection);return xu(n,r).type.isInGroup(`list`)?Cu(t,n,r,e):!1}},ju=m.a(Au),Mu=[{value:`left`,icon:`align-left-line`,label:`left`},{value:`center`,icon:`align-center-line`,label:`center`},{value:`right`,icon:`align-right-line`,label:`right`}],Nu=e=>Mu.find(t=>t.value===e)?.value??`left`,Pu=class extends m.r{constructor(...e){super(...e),this.name=`RteAlignmentFeature`}getTextblockAttrs(){return[this.contribution({name:`textAlign`,default:`left`,fromDOM(e){return Nu(e.style.textAlign)},toStyles(e){return[`text-align: ${Nu(e.attrs.textAlign)}`]}})]}getPlugins(){return[this.contribution(G({"Mod-L":this.setAlignment(`left`),"Mod-E":this.setAlignment(`center`),"Mod-R":this.setAlignment(`right`)}))]}getToolbarItems(){return[this.contribution({section:`textblock`,render:e=>Es(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,trigger:Y(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,icon:()=>{let t=this.getAlignmentFromSelection(e.view.state);return Mu.find(e=>e.value===t)?.icon??`align-left-line`}}),children:[Os(e,{children:Mu.map((t,n)=>Y(e,{icon:t.icon,label:()=>e.rte.getLocale().richTextEditor.alignments[t.label],slot:`header`,noTooltip:!0,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}}},Fu=m.a(Pu),Iu=`.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}`,Lu=`(?:https?://|www\\.)[^\\s<]+`;function Ru(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 zu=class extends m.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(Iu)]}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:qc(t)},0]}}}},m.i.high)]}getTextblockMarks(){return[this.contribution({markName:`link`})]}getInputRules(){let e=RegExp(`${Lu}$`);return[this.contribution({rule:new pl(RegExp(`${Lu} $`),(e,t,n,r)=>Ru(e,t[0],n,r)),enterHandler:{regex:e,handler:(e,t,n,r)=>Ru(e,t[0],n,r)}})]}getPlugins(e){let t=()=>(this.toolbarMenu.open=!0,!0);return[this.contribution(new N({props:{decorations:e=>{let t=this.getCurrentLink(e);if(t){let n=V.inline(t.start,t.end,{id:`current-link`});return H.create(e.doc,[n])}return null}},view:t=>{let n=new Ss(t,e,{popupPlacement:`bottom`}),r=e.createComponent(y);r.anchorId=`current-link`;let i=J(n,{className:`link-popover`,children:[J(n,{className:`link-popover-header`,children:[J(n,{className:`link-popover-label`,children:[Fs(n,{text:()=>this.getCurrentLink(n.view.state)?.text||``})]}),Y(n,{icon:`close-line`,label:()=>n.rte.getLocale().richTextEditor.close,noTooltip:!0,onClick:()=>{r.requestOpenState(!1)}})]}),J(n,{className:`link-popover-content`,children:[Cs(n,{className:`link`,href:()=>this.getCurrentLink(n.view.state)?.href||``,target:`_blank`,rel:`noopener`,children:[Fs(n,{text:()=>this.getCurrentLink(n.view.state)?.href||``})]}),J(n,{className:`link-action-bar`,children:[Y(n,{icon:`delete-line`,label:()=>n.rte.getLocale().richTextEditor.delete,connotation:`alert`,variant:`popover`,noTooltip:!0,onClick:()=>{let{state:e,dispatch:t}=n.view;this.removeLink(e,t)}}),Y(n,{icon:`edit-line`,label:()=>n.rte.getLocale().richTextEditor.edit,variant:`popover`,noTooltip:!0,onClick:()=>(this.toolbarMenu.open=!0,r.requestOpenState(!1),!0)})]})]})]});return r.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(r),{update:e=>{let t=e.state;n.updateBindings();let i=this.getCurrentLink(t);r.requestOpenState(!!i)},destroy:()=>{r.remove()}}}})),this.contribution(G({"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=Ps(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=Ps(r,{label:()=>r.rte.getLocale().richTextEditor.linkUrl,type:`url`,placeholder:()=>r.rte.getLocale().richTextEditor.linkUrlPlaceholder,slot:`header`,value:()=>this.getCurrentLink(r.view.state)?.href||``,onInput:()=>{s()}}),o=Y(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)}}),s=()=>{o.querySelector(`[data-vvd-component="button"]`).disabled=!(i.value.length&&n(a.value))},c=Es(r,{label:()=>r.rte.getLocale().richTextEditor.hyperlink,trigger:Y(r,{label:()=>r.rte.getLocale().richTextEditor.hyperlink,icon:`link-line`}),children:[J(r,{className:`link-toolbar-menu`,slot:`header`,children:[i,a,J(r,{className:`link-action-bar`,slot:`header`,children:[Y(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 A))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=-1,l=-1,u=!0;return e.doc.nodesBetween(r.start(),i.end(),(e,n)=>{if(!e.isText)return!0;let r=n+e.nodeSize;return s(e)?(c===-1&&(c=n),l=r):r>t.from&&n<t.to&&(u=!1),!1}),!u||c===-1?null:{text:e.doc.textBetween(c,l,` `),href:o,start:c,end:l}}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}}},Bu=m.a(zu),Vu=`.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}`,Hu=e=>e!==null&&!!e.next,Uu=1,Wu=()=>Uu++,Gu=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=Hu(i)?null:i;this.handleResolvedUrl(a),Hu(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)),y.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-${Wu()}`,n=document.createElement(`slot`);n.className=`inline-image-placeholder`,n.name=t;let r=e.create?.(t),i=this.view.dom.getRootNode().host;m.t(i,`inline-image-placeholder`,t,{url:this.imageUrl}),this.setContent(n,{onDestroy:()=>{m.t(i,`inline-image-placeholder`,t,m.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=Jc(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)}},Ku=class extends m.r{constructor(e={}){super(),this.config=e,this.name=`RteInlineImageFeature`}getStyles(){return[this.contribution(Vu)]}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:Jc(o),"data-src":o,alt:n};return r&&(s.style=`max-width: ${Yc(r)}; height: auto;`),i&&(s.width=i),a&&(s.height=a),[`img`,s]}}}})]}getPlugins(e){return[this.contribution(new N({props:{nodeViews:{inlineImage:(e,t,n)=>new Gu(e,t,n,this.config)}},view:t=>{let n=new Ss(t,e,{popupPlacement:`bottom`}),r=e.createComponent(y);r.offset=4;let i=J(n,{className:`inline-image-popover`,children:[Y(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.small,variant:`popover`,active:()=>this.getSelectedImageSize(n.view.state)===`small`,onClick:()=>{this.setSelectedImageSize(`small`)(n.view.state,n.view.dispatch)}}),Ns(n),Y(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.fit,variant:`popover`,active:()=>this.getSelectedImageSize(n.view.state)===`fit`,onClick:()=>{this.setSelectedImageSize(`fit`)(n.view.state,n.view.dispatch)}}),Ns(n),Y(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.original,variant:`popover`,active:()=>this.getSelectedImageSize(n.view.state)===`original`,onClick:()=>{this.setSelectedImageSize(`original`)(n.view.state,n.view.dispatch)}})]});return r.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(r),{update:e=>{n.updateBindings();let t=this.getSelectedInlineImage(e.state);t?(r.anchorEl=e.nodeDOM(t.pos),r.requestOpenState(!0)):(r.anchorEl=void 0,r.requestOpenState(!1))},destroy:()=>{r.remove()}}}}))]}calculateSmallWidth(e){return Math.min(300,e/2)+`px`}getSelectedInlineImage(e){let t=e.selection;return t instanceof j&&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}},qu=m.a(Ku),Ju=async e=>{try{return{type:`ok`,result:await e}}catch(e){return{type:`error`,error:e}}},Yu=class extends m.r{constructor(e){super(),this.config=e,this.name=`RteFileHandlerFeature`}getPlugins(e){let t=new N({state:{init(){return H.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=V.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.i();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=m.v.fromJSON(e.schema,{content:n});t.replaceSelection(r)}else{let i=m.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 Ju(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 N({props:{handlePaste:(e,t)=>{let n=Array.from(t.clipboardData.files);return n.length?(i(n,{type:`selection`}),!0):!1},handleDrop:(e,t,n,r)=>{let a=Array.from(t.dataTransfer.files);if(!a.length)return!1;let o=e.posAtCoords({left:t.clientX,top:t.clientY}).pos;if(e.dragging&&e.dragging.slice){let t=ze(e.state.doc,o,e.dragging.slice);t!=null&&(o=t)}return i(a,{type:`pos`,pos:o}),!0}}}))]}},Xu=m.a(Yu),Zu=class extends m.r{constructor(e){super(),this.config=e,this.name=`RteDebugFeature`}getPlugins(e){let t=new WeakMap,n=!1,r=e=>{t.get(e)===void 0&&(n=this.config.onViewportDragOver?.(e)??!1)},i=e=>{this.config.onViewportDrop?.(e),this.config.onViewportDragFinish?.()},a=()=>{this.config.onViewportDragFinish?.()},o=!1,s=()=>{o=!0,window.setTimeout(()=>o=!1,0)},c=()=>{o||this.config.onViewportDragFinish?.()};return[this.contribution(new N({view:e=>{let t=e.root.host.editorViewportElement;return t.addEventListener(`dragover`,r),t.addEventListener(`drop`,i),t.addEventListener(`dragend`,a),t.addEventListener(`dragenter`,s),t.addEventListener(`dragleave`,c),{destroy(){t.removeEventListener(`dragover`,r),t.removeEventListener(`drop`,i),t.removeEventListener(`dragend`,a),t.removeEventListener(`dragenter`,s),t.removeEventListener(`dragleave`,c)}}}})),this.contribution(new N({props:{handleDOMEvents:{dragover:(e,r)=>{let i=this.config.onViewportDragOver?.(r)??!1;return t.set(r,i),n=i,i?(r.stopImmediatePropagation(),r.preventDefault(),!0):!1},drop:(e,t)=>n}}}),m.i.high)]}},Qu=m.a(Zu),$u=class extends m.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteToolbarButtonFeature[${e}]`}getToolbarItems(){return[this.contribution({section:`insert`,render:e=>Y(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}}}},ed=m.a($u),td=e=>typeof e==`object`&&!!e&&`next`in e,nd=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;td(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)}},rd=class extends m.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 N({props:{nodeViews:{[this.atomName]:e=>new nd(e,this.config,this.atomName)}}}))]}},id=m.a(rd),ad=class extends m.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,m.d.fromJSON(e.schema,a)):null},r={rule:new pl(this.options.matchAfterWhitespace?RegExp(`${t} $`):RegExp(`${t}$`),n)};return this.options.matchAfterWhitespace&&(r.enterHandler={regex:RegExp(`${t}$`),handler:n}),[this.contribution(r)]}},od=m.a(ad);function sd(e,t){return e.length===0?(t,n)=>e():(n,r)=>e(t)}var cd=class extends m.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]=sd(r,e.facade);return[this.contribution(G(t),m.i.high)]}},ld=m.a(cd),ud=`.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}.suggest-item--visible-focus{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));--focus-stroke-gap-color:transparent}`,dd=e=>!!(e?.suggestions&&!e.dismissed),fd=e=>dd(e)&&e.suggestions.items.length>0;function pd(e,t){let{$cursor:n}=e.selection;if(!n)return null;let r=yl(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 md=(e,t,n)=>{let{state:r}=e;e.dispatch(ps(r.tr));let i=e.state.tr;i.replaceWith(t.start,t.end,m.d.fromJSON(e.state.schema,n));let a=i.mapping.map(t.end);i.setSelection(A.create(i.doc,a)),e.dispatch(i.scrollIntoView())},hd=class extends m.r{selectSuggestion(e,t,n){let r=this.options.select(n);md(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 wt(`suggest`),this.loadGeneration=0,this.name=`RteSuggestFeature[${e}]`}getStyles(){return[this.contribution(ud)]}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,a,o)=>{let s=pd(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):H.create(t.doc,[V.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})]):H.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:H.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,[V.inline(t.match.start,t.match.end,{id:`suggest-anchor-${this.featureId}`})]):null}},view:t=>{let n=new Ss(t,e,{popupPlacement:`bottom`}),r=e.createComponent(y);r.anchorId=`suggest-anchor-${this.featureId}`,r.kind=`autocomplete`,r.offset=4;let i=J(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&&m.t(o,`suggestions-empty-state`,a,{id:this.featureId}),s&&!e&&m.t(o,`suggestions-empty-state`,a,m.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(J(n,{className:`suggest-empty-message`,children:[t]}));return}for(let[n,a]of o.items.entries()){let s=e.createComponent(u.r);s.text=a.text,s.textSecondary=a.textSecondary,n===o.selectedIndex&&(s._highlighted=!0,s.dataset.highlighted=`true`,o.visibleFocus&&s.classList.add(`suggest-item--visible-focus`),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=dd(t);r.requestOpenState(i),i?l(t):c(!1)},destroy:()=>{c(!1),r.remove()}}}});return[this.contribution(r),this.contribution(G({ArrowUp:(e,n)=>fd(this.pluginKey.getState(e))?(n?.(t({type:`navigate`,action:`up`})),!0):!1,ArrowDown:(e,n)=>fd(this.pluginKey.getState(e))?(n?.(t({type:`navigate`,action:`down`})),!0):!1,Enter:(e,t,n)=>{let r=this.pluginKey.getState(e);if(!fd(r))return!1;let i=r.suggestions.items[r.suggestions.selectedIndex];return n&&this.selectSuggestion(n,r,i),!0},Escape:(e,n)=>dd(this.pluginKey.getState(e))?(n?.(t({type:`dismiss`})),!0):!1}),m.i.high)]}},gd=m.a(hd),_d=e=>e.textBetween(0,e.content.size,void 0,` `).length,vd=class extends m.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=_d(n.doc),i=_d(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),_d(t.doc)<=e}}))]}getPublicInterface(e){let t=this.config?.limit;return{get characters(){return _d(e.state.doc)},get limit(){return t}}}},yd=m.a(vd),bd=t.o(`rich-text-editor`,te,_,[f.t,d.n,u.t,a.t,s.n,g.t,h.t,l.n,re,i.t],{styles:ee,shadowOptions:{delegatesFocus:!0}});t.s(bd)(),exports.RteAlignmentFeature=Fu,exports.RteAtomFeature=id,exports.RteBase=Sl,exports.RteBoldFeature=Jl,exports.RteCharacterCountFeature=yd,exports.RteConfig=ll,exports.RteDropHandlerFeature=Qu,exports.RteFileHandlerFeature=Xu,exports.RteFontSizePickerFeature=Fl,exports.RteHardBreakFeature=Ml,exports.RteHtmlParser=Qc,exports.RteHtmlSerializer=tl,exports.RteInlineImageFeature=qu,exports.RteInputRuleFeature=od,exports.RteItalicFeature=Xl,exports.RteKeyboardShortcutsFeature=ld,exports.RteLinkFeature=Bu,exports.RteListFeature=ju,exports.RteMonospaceFeature=ru,exports.RtePlaceholderFeature=Al,exports.RteStrikethroughFeature=eu,exports.RteSuggestFeature=gd,exports.RteTextBlockPickerFeature=wl,exports.RteTextColorPickerFeature=su,exports.RteToolbarButtonFeature=ed,exports.RteToolbarFeature=Dl,exports.RteUnderlineFeature=Ql;