@metamorph-labs/polymorph 1.0.18 → 1.0.19

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 (319) hide show
  1. package/CHANGELOG.md +242 -0
  2. package/dist/design/systems/desktop.json +1 -1
  3. package/dist/design/systems/dew.json +1 -1
  4. package/dist/design/systems/flint.json +1 -1
  5. package/dist/design/systems/glassmorphic.json +1 -1
  6. package/dist/design/systems/harbor.json +1 -1
  7. package/dist/design/systems/journal.json +1 -1
  8. package/dist/design/systems/pastel.json +1 -1
  9. package/dist/design/systems/pebble.json +1 -1
  10. package/dist/design/systems/plain.json +1 -1
  11. package/dist/design/systems/pop.json +1 -1
  12. package/dist/design/systems/press.json +1 -1
  13. package/dist/packages/angular-ui/src/ai/ArtifactPane.ts +15 -4
  14. package/dist/packages/angular-ui/src/ai/PromptInput.ts +3 -1
  15. package/dist/packages/angular-ui/src/archetypes/Dashboard.ts +38 -20
  16. package/dist/packages/angular-ui/src/archetypes/dashboard.states.ts +52 -0
  17. package/dist/packages/angular-ui/src/controls/ColorInput.ts +62 -34
  18. package/dist/packages/angular-ui/src/controls/Combobox.ts +28 -7
  19. package/dist/packages/angular-ui/src/controls/DatePicker.ts +12 -11
  20. package/dist/packages/angular-ui/src/controls/DateRangePicker.ts +22 -17
  21. package/dist/packages/angular-ui/src/controls/DateRangePickerRangeCalendar.ts +3 -2
  22. package/dist/packages/angular-ui/src/controls/FileUpload.ts +18 -12
  23. package/dist/packages/angular-ui/src/controls/FileUploadRow.ts +24 -4
  24. package/dist/packages/angular-ui/src/controls/MultiSelect.ts +49 -12
  25. package/dist/packages/angular-ui/src/controls/NumberInput.ts +27 -3
  26. package/dist/packages/angular-ui/src/controls/PhoneInput.ts +9 -5
  27. package/dist/packages/angular-ui/src/controls/Select.ts +36 -7
  28. package/dist/packages/angular-ui/src/controls/TagInput.ts +61 -7
  29. package/dist/packages/angular-ui/src/controls/TimeInput.ts +15 -1
  30. package/dist/packages/angular-ui/src/controls/select.states.ts +79 -58
  31. package/dist/packages/angular-ui/src/overlays/Command.ts +50 -13
  32. package/dist/packages/angular-ui/src/overlays/CommandPanel.ts +11 -7
  33. package/dist/packages/angular-ui/src/overlays/ToastViewport.ts +1 -1
  34. package/dist/packages/angular-ui/src/structure/CodeBlock.ts +18 -4
  35. package/dist/packages/angular-ui/src/structure/Stat.ts +295 -84
  36. package/dist/packages/angular-ui/src/structure/stat.states.ts +116 -0
  37. package/dist/packages/cli/src/agents.js +4 -3
  38. package/dist/packages/cli/src/apply.js +43 -18
  39. package/dist/packages/cli/src/check.js +4 -0
  40. package/dist/packages/cli/src/cli.js +6 -2
  41. package/dist/packages/cli/src/elements.js +12 -2
  42. package/dist/packages/cli/src/emit.js +43 -8
  43. package/dist/packages/cli/src/readings.js +29 -3
  44. package/dist/packages/cli/src/skills/bridge.js +1197 -0
  45. package/dist/packages/cli/src/skills/facts.js +190 -0
  46. package/dist/packages/cli/src/skills/native.js +1580 -0
  47. package/dist/packages/cli/src/skills/rules.js +199 -0
  48. package/dist/packages/cli/src/skills/runtime.js +1020 -0
  49. package/dist/packages/cli/src/skills/screen-charts.js +334 -0
  50. package/dist/packages/cli/src/skills/screen-chat.js +247 -0
  51. package/dist/packages/cli/src/skills/screen-code.js +565 -0
  52. package/dist/packages/cli/src/skills/screen-rich-text.js +305 -0
  53. package/dist/packages/cli/src/skills/screen.js +378 -0
  54. package/dist/packages/cli/src/skills/setup-packages.js +307 -0
  55. package/dist/packages/cli/src/skills/setup.js +125 -0
  56. package/dist/packages/cli/src/skills/theme-documents.js +351 -0
  57. package/dist/packages/cli/src/skills/theme.js +208 -0
  58. package/dist/packages/cli/src/skills.js +13 -794
  59. package/dist/packages/cli/src/theme.js +42 -1
  60. package/dist/packages/cli/src/tool-verbs.js +19 -4
  61. package/dist/packages/cli/src/verbs.js +28 -2
  62. package/dist/packages/elements-ui/dist/cdn/chunks/{AppShellUserCard-0eCCnnN_.js → AppShellUserCard-XT4br4fr.js} +1 -1
  63. package/dist/packages/elements-ui/dist/cdn/chunks/{AreaChart-DftfzLG0.js → AreaChart-CXNFfbJ8.js} +1 -1
  64. package/dist/packages/elements-ui/dist/cdn/chunks/ArtifactPane-Pr9_K2uM.js +1 -0
  65. package/dist/packages/elements-ui/dist/cdn/chunks/{Avatar-DcdMgxgY.js → Avatar-3WXoBPLv.js} +1 -1
  66. package/dist/packages/elements-ui/dist/cdn/chunks/{Avatar-DcuvZwe7.js → Avatar-BKqjM8qW.js} +1 -1
  67. package/dist/packages/elements-ui/dist/cdn/chunks/{AvatarButton-D5XKVduu.js → AvatarButton-BasMQCSM.js} +1 -1
  68. package/dist/packages/elements-ui/dist/cdn/chunks/{AvatarGroup-DgFwJUNO.js → AvatarGroup-COch2-O0.js} +1 -1
  69. package/dist/packages/elements-ui/dist/cdn/chunks/{BarChart-myuR0aHc.js → BarChart-ugae8zfr.js} +1 -1
  70. package/dist/packages/elements-ui/dist/cdn/chunks/{ChatMessage-CgQ1h_JP.js → ChatMessage-Bx4yrF2x.js} +1 -1
  71. package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-B_e5ma3K.js +1 -0
  72. package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-Fgtr48Vb.js +1 -0
  73. package/dist/packages/elements-ui/dist/cdn/chunks/ColorInput-CD7rsWRp.js +1 -0
  74. package/dist/packages/elements-ui/dist/cdn/chunks/Combobox-CUw7z6TS.js +1 -0
  75. package/dist/packages/elements-ui/dist/cdn/chunks/{Combobox-DB2FT7so.js → Combobox-hWIFU9X_.js} +1 -1
  76. package/dist/packages/elements-ui/dist/cdn/chunks/Command-BXgqRd3I.js +1 -0
  77. package/dist/packages/elements-ui/dist/cdn/chunks/{ConfirmDialog-BtQOAHY2.js → ConfirmDialog-CAaBRKxl.js} +1 -1
  78. package/dist/packages/elements-ui/dist/cdn/chunks/{Dashboard-ChMPH4_Q.js → Dashboard-DwNw5Wnd.js} +1 -1
  79. package/dist/packages/elements-ui/dist/cdn/chunks/DatePicker-DjqtswQR.js +1 -0
  80. package/dist/packages/elements-ui/dist/cdn/chunks/DateRangePicker-LsXFHOzm.js +1 -0
  81. package/dist/packages/elements-ui/dist/cdn/chunks/{DonutChart-BEK89BeL.js → DonutChart-DYXx6eTe.js} +1 -1
  82. package/dist/packages/elements-ui/dist/cdn/chunks/FileUpload-3gbZTSSx.js +1 -0
  83. package/dist/packages/elements-ui/dist/cdn/chunks/{FormField-PlLLDKqc.js → FormField-Bvw4cLBc.js} +1 -1
  84. package/dist/packages/elements-ui/dist/cdn/chunks/{FormField-C6L3vYp4.js → FormField-DzhcinED.js} +1 -1
  85. package/dist/packages/elements-ui/dist/cdn/chunks/{FunnelChart-DVQz_gad.js → FunnelChart-D24XhrGw.js} +1 -1
  86. package/dist/packages/elements-ui/dist/cdn/chunks/{Heading-fAcu6Vrw.js → Heading-Cvfyu8pc.js} +1 -1
  87. package/dist/packages/elements-ui/dist/cdn/chunks/{Heading-CgzEi9OQ.js → Heading-XDJzlwt9.js} +1 -1
  88. package/dist/packages/elements-ui/dist/cdn/chunks/{Heatmap-BRwR-n-V.js → Heatmap-BQoUS6gY.js} +1 -1
  89. package/dist/packages/elements-ui/dist/cdn/chunks/{Hero-CV2YWeb4.js → Hero-CXuuFceS.js} +1 -1
  90. package/dist/packages/elements-ui/dist/cdn/chunks/{Histogram-CCYwlinB.js → Histogram-DW_ZPHpR.js} +1 -1
  91. package/dist/packages/elements-ui/dist/cdn/chunks/{LineChart-BH6Pq1P1.js → LineChart-kf-zlNWe.js} +1 -1
  92. package/dist/packages/elements-ui/dist/cdn/chunks/{Markdown-DmZEch4i.js → Markdown-C3rjhIbt.js} +1 -1
  93. package/dist/packages/elements-ui/dist/cdn/chunks/ModeSwitch-DQ86CK9h.js +1 -0
  94. package/dist/packages/elements-ui/dist/cdn/chunks/MultiSelect-DbSx9QtV.js +1 -0
  95. package/dist/packages/elements-ui/dist/cdn/chunks/NumberInput-B4ZZOGLl.js +7 -0
  96. package/dist/packages/elements-ui/dist/cdn/chunks/PhoneInput-BsMfbNi6.js +210 -0
  97. package/dist/packages/elements-ui/dist/cdn/chunks/PromptInput-l_-zAXSZ.js +1 -0
  98. package/dist/packages/elements-ui/dist/cdn/chunks/{RadarChart-Coje7Sb0.js → RadarChart-CwJAWRki.js} +1 -1
  99. package/dist/packages/elements-ui/dist/cdn/chunks/{RichTextContent-CufjptHF.js → RichTextContent-D51UfuWk.js} +1 -1
  100. package/dist/packages/elements-ui/dist/cdn/chunks/{RichTextInput-Dz7yBFUA.js → RichTextInput-B32fN_p9.js} +3 -3
  101. package/dist/packages/elements-ui/dist/cdn/chunks/{ScatterChart-Do5tQTC5.js → ScatterChart-Mps7l5-i.js} +1 -1
  102. package/dist/packages/elements-ui/dist/cdn/chunks/Select-CpsRP0NR.js +1 -0
  103. package/dist/packages/elements-ui/dist/cdn/chunks/Stat-CXR6bP7X.js +1 -0
  104. package/dist/packages/elements-ui/dist/cdn/chunks/Stat-DGcx2ZZq.js +1 -0
  105. package/dist/packages/elements-ui/dist/cdn/chunks/TagInput-BhkLU4gE.js +1 -0
  106. package/dist/packages/elements-ui/dist/cdn/chunks/TimeInput-r2jNTOLN.js +1 -0
  107. package/dist/packages/elements-ui/dist/cdn/chunks/{Toast-CAYGbn7g.js → Toast-BTfcZn0I.js} +1 -1
  108. package/dist/packages/elements-ui/dist/cdn/chunks/{ToastViewport-CFslglYc.js → ToastViewport-BBQMRCQT.js} +1 -1
  109. package/dist/packages/elements-ui/dist/cdn/chunks/{ToolCall-DUCoKsoE.js → ToolCall-DNU5kk9_.js} +1 -1
  110. package/dist/packages/elements-ui/dist/cdn/chunks/{Treemap-Bh3ruYGJ.js → Treemap-BV8TlZHB.js} +1 -1
  111. package/dist/packages/elements-ui/dist/cdn/chunks/agent-DfOqpL9c.js +1 -0
  112. package/dist/packages/elements-ui/dist/cdn/chunks/api-DJBiUXxK.js +4 -0
  113. package/dist/packages/elements-ui/dist/cdn/chunks/avatar.module-D4YdFevY.js +1 -0
  114. package/dist/packages/elements-ui/dist/cdn/chunks/cap-DA71oFHt.js +1 -0
  115. package/dist/packages/elements-ui/dist/cdn/chunks/{cartesian-I5uPfyqv.js → cartesian-CEn2lJCc.js} +1 -1
  116. package/dist/packages/elements-ui/dist/cdn/chunks/{chart-annotations.module-xUExw4pu.js → chart-annotations.module-hA_KO_Pe.js} +1 -1
  117. package/dist/packages/elements-ui/dist/cdn/chunks/chart-brush.module-C_8txUW5.js +1 -0
  118. package/dist/packages/elements-ui/dist/cdn/chunks/chart-twin.module-BpfyTQ9R.js +1 -0
  119. package/dist/packages/elements-ui/dist/cdn/chunks/check-CHvc4yHL.js +1 -0
  120. package/dist/packages/elements-ui/dist/cdn/chunks/css-vars-DeZ4TCna.js +1 -0
  121. package/dist/packages/elements-ui/dist/cdn/chunks/draw-BiQ3Of6N.js +1 -0
  122. package/dist/packages/elements-ui/dist/cdn/chunks/drawing-nhJNBahV.js +1 -0
  123. package/dist/packages/elements-ui/dist/cdn/chunks/field-labels-Df5HuYC5.js +1 -0
  124. package/dist/packages/elements-ui/dist/cdn/chunks/frame-CtTY4oCn.js +1 -0
  125. package/dist/packages/elements-ui/dist/cdn/chunks/on-call-YKLF3-FH.js +1 -0
  126. package/dist/packages/elements-ui/dist/cdn/chunks/runtime-QRQ3CjZg.js +1 -0
  127. package/dist/packages/elements-ui/dist/cdn/chunks/series-uUg6_JtL.js +1 -0
  128. package/dist/packages/elements-ui/dist/cdn/chunks/src-XnWjGSDr.js +67 -0
  129. package/dist/packages/elements-ui/dist/cdn/chunks/toast-pwGvxH2T.js +1 -0
  130. package/dist/packages/elements-ui/dist/cdn/chunks/urls-Qks0KJ_p.js +6 -0
  131. package/dist/packages/elements-ui/dist/cdn/chunks/webmcp-Dro53ATH.js +1 -0
  132. package/dist/packages/elements-ui/dist/cdn/polymorph-all.js +52 -50
  133. package/dist/packages/elements-ui/dist/cdn/polymorph.css +1 -1
  134. package/dist/packages/elements-ui/dist/cdn/polymorph.js +1 -1
  135. package/dist/packages/elements-ui/dist/cdn/prepaint.js +1 -1
  136. package/dist/packages/elements-ui/dist/cdn/themes/desktop.css +5 -4
  137. package/dist/packages/elements-ui/dist/cdn/themes/dew.css +5 -4
  138. package/dist/packages/elements-ui/dist/cdn/themes/flint.css +5 -4
  139. package/dist/packages/elements-ui/dist/cdn/themes/glassmorphic.css +5 -4
  140. package/dist/packages/elements-ui/dist/cdn/themes/harbor.css +5 -4
  141. package/dist/packages/elements-ui/dist/cdn/themes/journal.css +5 -4
  142. package/dist/packages/elements-ui/dist/cdn/themes/pastel.css +5 -4
  143. package/dist/packages/elements-ui/dist/cdn/themes/pebble.css +5 -4
  144. package/dist/packages/elements-ui/dist/cdn/themes/plain.css +5 -4
  145. package/dist/packages/elements-ui/dist/cdn/themes/pop.css +5 -4
  146. package/dist/packages/elements-ui/dist/cdn/themes/press.css +5 -4
  147. package/dist/packages/elements-ui/dist/cdn/themes/terminal.css +5 -4
  148. package/dist/packages/elements-ui/src/ai/ArtifactPane.ts +2 -0
  149. package/dist/packages/elements-ui/src/archetypes/dashboard.states.ts +9 -0
  150. package/dist/packages/elements-ui/src/controls/ColorInput.ts +2 -0
  151. package/dist/packages/elements-ui/src/controls/NumberInput.ts +2 -0
  152. package/dist/packages/elements-ui/src/controls/TagInput.ts +4 -0
  153. package/dist/packages/elements-ui/src/controls/TimeInput.ts +2 -0
  154. package/dist/packages/elements-ui/src/controls/select.states.ts +10 -0
  155. package/dist/packages/elements-ui/src/overlays/Command.ts +2 -0
  156. package/dist/packages/elements-ui/src/structure/CodeBlock.ts +5 -2
  157. package/dist/packages/elements-ui/src/structure/Stat.ts +6 -0
  158. package/dist/packages/elements-ui/src/structure/stat.states.ts +33 -0
  159. package/dist/packages/mcp/src/propose.js +92 -15
  160. package/dist/packages/mcp/src/server.js +19 -8
  161. package/dist/packages/mcp/src/tools.js +80 -5
  162. package/dist/packages/mcp/src/write.js +95 -13
  163. package/dist/packages/react-ui/src/ai/ArtifactPane.tsx +5 -2
  164. package/dist/packages/react-ui/src/ai/PromptInput.tsx +5 -2
  165. package/dist/packages/react-ui/src/archetypes/dashboard.states.tsx +28 -0
  166. package/dist/packages/react-ui/src/controls/ColorInput.tsx +69 -13
  167. package/dist/packages/react-ui/src/controls/Combobox.tsx +13 -5
  168. package/dist/packages/react-ui/src/controls/DatePicker.tsx +3 -0
  169. package/dist/packages/react-ui/src/controls/DateRangePicker.tsx +22 -5
  170. package/dist/packages/react-ui/src/controls/FileUpload.tsx +2 -0
  171. package/dist/packages/react-ui/src/controls/MultiSelect.tsx +30 -6
  172. package/dist/packages/react-ui/src/controls/NumberInput.tsx +19 -1
  173. package/dist/packages/react-ui/src/controls/PhoneInput.tsx +3 -3
  174. package/dist/packages/react-ui/src/controls/Select.tsx +59 -23
  175. package/dist/packages/react-ui/src/controls/TagInput.tsx +43 -10
  176. package/dist/packages/react-ui/src/controls/TimeInput.tsx +10 -0
  177. package/dist/packages/react-ui/src/controls/date-segments.tsx +16 -0
  178. package/dist/packages/react-ui/src/controls/select.states.tsx +13 -0
  179. package/dist/packages/react-ui/src/overlays/Command.tsx +23 -2
  180. package/dist/packages/react-ui/src/overlays/Toaster.tsx +2 -2
  181. package/dist/packages/react-ui/src/structure/CodeBlock.tsx +7 -3
  182. package/dist/packages/react-ui/src/structure/Stat.tsx +90 -13
  183. package/dist/packages/react-ui/src/structure/stat.states.tsx +68 -0
  184. package/dist/packages/recipes/src/ai/artifact-pane.module.css +4 -4
  185. package/dist/packages/recipes/src/controls/rich-text-input.module.css +1 -1
  186. package/dist/packages/recipes/src/structure/avatar.module.css +3 -1
  187. package/dist/packages/recipes/src/structure/heading.module.css +5 -4
  188. package/dist/packages/recipes/src/structure/hero.module.css +3 -1
  189. package/dist/packages/recipes/src/structure/stat.module.css +7 -0
  190. package/dist/packages/registry/src/card.js +4 -3
  191. package/dist/packages/registry/src/frameworks.js +28 -1
  192. package/dist/packages/registry/src/runtime-card.js +300 -0
  193. package/dist/packages/registry/src/runtime-members.js +176 -0
  194. package/dist/packages/registry/src/screen-table.js +166 -0
  195. package/dist/packages/rules/package.js +1 -1
  196. package/dist/packages/solid-ui/src/ai/ArtifactPane.tsx +11 -3
  197. package/dist/packages/solid-ui/src/ai/PromptInput.tsx +3 -1
  198. package/dist/packages/solid-ui/src/archetypes/Dashboard.tsx +3 -0
  199. package/dist/packages/solid-ui/src/archetypes/dashboard.states.tsx +39 -0
  200. package/dist/packages/solid-ui/src/controls/ColorInput.tsx +38 -17
  201. package/dist/packages/solid-ui/src/controls/Combobox.tsx +27 -6
  202. package/dist/packages/solid-ui/src/controls/DatePicker.tsx +12 -11
  203. package/dist/packages/solid-ui/src/controls/DateRangePicker.tsx +21 -16
  204. package/dist/packages/solid-ui/src/controls/DateRangePickerRangeCalendar.tsx +3 -4
  205. package/dist/packages/solid-ui/src/controls/FileUpload.tsx +1 -0
  206. package/dist/packages/solid-ui/src/controls/FileUploadRow.tsx +6 -0
  207. package/dist/packages/solid-ui/src/controls/MultiSelect.tsx +51 -11
  208. package/dist/packages/solid-ui/src/controls/NumberInput.tsx +21 -2
  209. package/dist/packages/solid-ui/src/controls/PhoneInput.tsx +8 -4
  210. package/dist/packages/solid-ui/src/controls/Select.tsx +37 -6
  211. package/dist/packages/solid-ui/src/controls/TagInput.tsx +26 -5
  212. package/dist/packages/solid-ui/src/controls/TimeInput.tsx +10 -1
  213. package/dist/packages/solid-ui/src/controls/select.states.tsx +18 -0
  214. package/dist/packages/solid-ui/src/overlays/Command.tsx +15 -2
  215. package/dist/packages/solid-ui/src/overlays/CommandPanel.tsx +7 -7
  216. package/dist/packages/solid-ui/src/overlays/ToastViewport.tsx +1 -1
  217. package/dist/packages/solid-ui/src/structure/CodeBlock.tsx +9 -5
  218. package/dist/packages/solid-ui/src/structure/Stat.tsx +86 -25
  219. package/dist/packages/solid-ui/src/structure/stat.states.tsx +73 -0
  220. package/dist/packages/svelte-ui/src/ai/ArtifactPane.svelte +8 -2
  221. package/dist/packages/svelte-ui/src/ai/PromptInput.svelte +3 -1
  222. package/dist/packages/svelte-ui/src/archetypes/Dashboard.svelte +3 -0
  223. package/dist/packages/svelte-ui/src/archetypes/dashboard.states.svelte +2 -0
  224. package/dist/packages/svelte-ui/src/controls/ColorInput.svelte +29 -8
  225. package/dist/packages/svelte-ui/src/controls/Combobox.svelte +26 -5
  226. package/dist/packages/svelte-ui/src/controls/DatePicker.svelte +7 -5
  227. package/dist/packages/svelte-ui/src/controls/DateRangePicker.svelte +15 -9
  228. package/dist/packages/svelte-ui/src/controls/DateRangePickerRangeCalendar.svelte +3 -2
  229. package/dist/packages/svelte-ui/src/controls/FileUpload.svelte +1 -0
  230. package/dist/packages/svelte-ui/src/controls/FileUploadRow.svelte +8 -1
  231. package/dist/packages/svelte-ui/src/controls/MultiSelect.svelte +36 -10
  232. package/dist/packages/svelte-ui/src/controls/NumberInput.svelte +14 -1
  233. package/dist/packages/svelte-ui/src/controls/PhoneInput.svelte +3 -3
  234. package/dist/packages/svelte-ui/src/controls/Select.svelte +20 -6
  235. package/dist/packages/svelte-ui/src/controls/TagInput.svelte +21 -3
  236. package/dist/packages/svelte-ui/src/controls/TimeInput.svelte +11 -1
  237. package/dist/packages/svelte-ui/src/controls/select.states.svelte +26 -24
  238. package/dist/packages/svelte-ui/src/overlays/Command.svelte +13 -1
  239. package/dist/packages/svelte-ui/src/overlays/CommandPanel.svelte +11 -6
  240. package/dist/packages/svelte-ui/src/overlays/ToastViewport.svelte +1 -1
  241. package/dist/packages/svelte-ui/src/structure/CodeBlock.svelte +7 -2
  242. package/dist/packages/svelte-ui/src/structure/Stat.svelte +70 -17
  243. package/dist/packages/svelte-ui/src/structure/stat.states.svelte +27 -0
  244. package/dist/packages/theme/src/admit.js +6 -3
  245. package/dist/packages/theme/src/color/resolve.js +19 -2
  246. package/dist/packages/theme/src/derive.js +13 -6
  247. package/dist/packages/theme/src/emit.js +1 -1
  248. package/dist/packages/theme/src/runtime.js +58 -0
  249. package/dist/packages/theme/src/seeds.js +30 -4
  250. package/dist/packages/theme/src/systems.js +1 -1
  251. package/dist/packages/theme/src/tokens.js +15 -6
  252. package/dist/packages/vue-ui/src/ai/ArtifactPane.vue +11 -2
  253. package/dist/packages/vue-ui/src/ai/PromptInput.vue +3 -1
  254. package/dist/packages/vue-ui/src/archetypes/Dashboard.vue +3 -0
  255. package/dist/packages/vue-ui/src/archetypes/dashboard.states.ts +49 -0
  256. package/dist/packages/vue-ui/src/controls/ColorInput.vue +33 -12
  257. package/dist/packages/vue-ui/src/controls/Combobox.vue +26 -5
  258. package/dist/packages/vue-ui/src/controls/DatePicker.vue +12 -11
  259. package/dist/packages/vue-ui/src/controls/DateRangePicker.vue +20 -15
  260. package/dist/packages/vue-ui/src/controls/DateRangePickerRangeCalendar.vue +3 -4
  261. package/dist/packages/vue-ui/src/controls/FileUpload.vue +1 -0
  262. package/dist/packages/vue-ui/src/controls/FileUploadRow.vue +6 -0
  263. package/dist/packages/vue-ui/src/controls/MultiSelect.vue +37 -10
  264. package/dist/packages/vue-ui/src/controls/NumberInput.vue +17 -1
  265. package/dist/packages/vue-ui/src/controls/PhoneInput.vue +7 -3
  266. package/dist/packages/vue-ui/src/controls/Select.vue +22 -7
  267. package/dist/packages/vue-ui/src/controls/TagInput.vue +21 -3
  268. package/dist/packages/vue-ui/src/controls/TimeInput.vue +10 -1
  269. package/dist/packages/vue-ui/src/controls/select.states.ts +17 -0
  270. package/dist/packages/vue-ui/src/overlays/Command.vue +13 -1
  271. package/dist/packages/vue-ui/src/overlays/CommandPanel.vue +7 -7
  272. package/dist/packages/vue-ui/src/overlays/ToastViewport.vue +1 -1
  273. package/dist/packages/vue-ui/src/structure/CodeBlock.vue +7 -2
  274. package/dist/packages/vue-ui/src/structure/Stat.vue +71 -18
  275. package/dist/packages/vue-ui/src/structure/stat.states.ts +67 -0
  276. package/dist/platforms/android/ui/src/generated/kotlin/dev/polymorph/ui/Contracts.kt +144 -33
  277. package/dist/platforms/android/ui/src/generated/kotlin/dev/polymorph/ui/Members.kt +17 -7
  278. package/dist/platforms/ios/Sources/PolymorphUI/Generated/Contracts.swift +204 -31
  279. package/dist/registry/registry.json +371 -75
  280. package/dist/screen/assets/{screen-CuQbskb8.css → screen-B22PTPwF.css} +1 -1
  281. package/dist/screen/assets/screen-Cpbh7XMb.js +372 -0
  282. package/dist/screen/screen.html +3 -3
  283. package/package.json +1 -1
  284. package/dist/packages/elements-ui/dist/cdn/chunks/ArtifactPane-DsmRlr6d.js +0 -1
  285. package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-BqP8HZKM.js +0 -1
  286. package/dist/packages/elements-ui/dist/cdn/chunks/CodeBlock-D8VARz0a.js +0 -1
  287. package/dist/packages/elements-ui/dist/cdn/chunks/ColorInput-BrzZOVeL.js +0 -1
  288. package/dist/packages/elements-ui/dist/cdn/chunks/Combobox-BiUq0h-w.js +0 -1
  289. package/dist/packages/elements-ui/dist/cdn/chunks/Command-hmxVRdFg.js +0 -1
  290. package/dist/packages/elements-ui/dist/cdn/chunks/DatePicker-C8prGbJ2.js +0 -1
  291. package/dist/packages/elements-ui/dist/cdn/chunks/DateRangePicker-CO1ioqwN.js +0 -1
  292. package/dist/packages/elements-ui/dist/cdn/chunks/FileUpload-HPQe-ttb.js +0 -1
  293. package/dist/packages/elements-ui/dist/cdn/chunks/ModeSwitch-CerqbGv3.js +0 -1
  294. package/dist/packages/elements-ui/dist/cdn/chunks/MultiSelect-CQq7jPgI.js +0 -1
  295. package/dist/packages/elements-ui/dist/cdn/chunks/NumberInput-Dre9GwBy.js +0 -7
  296. package/dist/packages/elements-ui/dist/cdn/chunks/PhoneInput-D6_J6Es_.js +0 -210
  297. package/dist/packages/elements-ui/dist/cdn/chunks/PromptInput-BXcsUQ5W.js +0 -1
  298. package/dist/packages/elements-ui/dist/cdn/chunks/Select-DxGQgv2q.js +0 -1
  299. package/dist/packages/elements-ui/dist/cdn/chunks/Stat-FsMUWigK.js +0 -1
  300. package/dist/packages/elements-ui/dist/cdn/chunks/Stat-WS8v6BQv.js +0 -1
  301. package/dist/packages/elements-ui/dist/cdn/chunks/TagInput-D-uIQEGS.js +0 -1
  302. package/dist/packages/elements-ui/dist/cdn/chunks/TimeInput-Dho571vA.js +0 -1
  303. package/dist/packages/elements-ui/dist/cdn/chunks/agent-DBDk4wLH.js +0 -1
  304. package/dist/packages/elements-ui/dist/cdn/chunks/api-B9sGZiYn.js +0 -4
  305. package/dist/packages/elements-ui/dist/cdn/chunks/avatar.module-CQwnWhWo.js +0 -1
  306. package/dist/packages/elements-ui/dist/cdn/chunks/cap-Ct4k7zNC.js +0 -1
  307. package/dist/packages/elements-ui/dist/cdn/chunks/chart-brush.module-DycBfben.js +0 -1
  308. package/dist/packages/elements-ui/dist/cdn/chunks/chart-twin.module-Cks7VwS5.js +0 -1
  309. package/dist/packages/elements-ui/dist/cdn/chunks/check-dOfCSYFA.js +0 -1
  310. package/dist/packages/elements-ui/dist/cdn/chunks/draw-DclRgiWM.js +0 -1
  311. package/dist/packages/elements-ui/dist/cdn/chunks/drawing-DjkZr0z8.js +0 -1
  312. package/dist/packages/elements-ui/dist/cdn/chunks/frame-BSvl4y47.js +0 -1
  313. package/dist/packages/elements-ui/dist/cdn/chunks/on-call-Jk1sYJc_.js +0 -1
  314. package/dist/packages/elements-ui/dist/cdn/chunks/receivers-BpRfF6dV.js +0 -4
  315. package/dist/packages/elements-ui/dist/cdn/chunks/series-C_1TNd2n.js +0 -1
  316. package/dist/packages/elements-ui/dist/cdn/chunks/src-Bub3C9YP.js +0 -67
  317. package/dist/packages/elements-ui/dist/cdn/chunks/toast-AarMGYJn.js +0 -1
  318. package/dist/packages/elements-ui/dist/cdn/chunks/webmcp-eEPzSqph.js +0 -1
  319. package/dist/screen/assets/screen-Clj2u6_s.js +0 -372
@@ -1,4 +1,4 @@
1
- import{a as e,l as t,n,o as r,s as i,u as a}from"./Icon-BjPIXI8I.js";import{B as o,C as s,F as c,I as l,J as u,L as d,N as f,P as p,Q as m,V as h,W as g,Y as _,et as ee,n as v,nt as y,rt as b,v as x,z as te}from"./element-CqIhTGKu.js";import{o as ne,r as re}from"./agent-Dt8YlN7n.js";import{t as ie}from"./composition-ChkgUGQ-.js";import{A as ae,B as oe,C as se,D as S,F as ce,I as le,L as ue,M as de,N as fe,O as C,P as pe,R as me,S as he,T as ge,V as _e,_ as ve,b as ye,c as be,d as xe,f as Se,g as w,h as Ce,i as we,j as Te,k as Ee,l as De,m as Oe,o as ke,p as Ae,s as je,t as Me,u as Ne,v as Pe,w as Fe,y as Ie,z as Le}from"./selection-bar.module-D4ISvYkQ.js";import{n as Re,r as ze,t as Be}from"./keyed-DOTZ3iez.js";import{n as T}from"./effects-BBm2yMRe.js";import{n as Ve}from"./presence-qi-0xFxa.js";import"./src-C2HZtjku.js";import{t as E}from"./Button-BJ5X73pv.js";import{t as He}from"./Separator-DEthKrfy.js";import{t as Ue}from"./Skeleton-BSq15Cez.js";import{t as We}from"./Input-YafcZQc5.js";import{t as Ge}from"./Popover-DD5KtkxE.js";import{t as Ke}from"./FormField-C6L3vYp4.js";import{t as qe}from"./Menu-IOiOO-OD.js";var Je=`a[href], button, input, select, textarea, [contenteditable="true"]`;function Ye(e){let t=e.ownerDocument.getSelection();return t===null||t.isCollapsed||t.rangeCount===0?!1:t.getRangeAt(0).intersectsNode(e)}function Xe(e,t,n=()=>!0){if(e==null)return()=>{};let r=e.ownerDocument,i=(e.getAttribute(`aria-labelledby`)??``).split(/\s+/).filter(Boolean).map(e=>r.getElementById(e)).filter(t=>t!==null&&!t.contains(e)),a=e=>{let r=e.currentTarget,i=e.target;if(e.defaultPrevented||e.button!==0||!n()||!(r instanceof Element)||!(i instanceof Element))return;let a=i.closest(Je);a!==null&&r.contains(a)||Ye(r)||t()};for(let e of i)e.addEventListener(`click`,a);return()=>{for(let e of i)e.removeEventListener(`click`,a)}}function Ze(e,t,n=[]){if(!(t instanceof Node))return!1;if(e.contains(t)||n.some(e=>e?.contains(t)===!0))return!0;for(let n=t instanceof Element?t:t.parentElement;n!==null;n=n.parentElement){if(n.id===``)continue;let t=n.id.replace(/["\\]/g,`\\$&`);if(e.querySelector(`[aria-controls~="${t}"]`)!==null)return!0}return!1}function Qe(e,t){let n=e.ownerDocument,r=n=>Ze(e,n,t.panels?.()??[]),i=r(n.activeElement),a=0;i&&t.entered();let o=e=>{a+=1;let n=r(e.target);n!==i&&(i=n,n?t.entered():t.left())},s=e=>{if(!i||e.relatedTarget!==null)return;a+=1;let o=a;queueMicrotask(()=>{a!==o||!i||r(n.activeElement)||(i=!1,t.left())})};return n.addEventListener(`focusin`,o,!0),n.addEventListener(`focusout`,s,!0),()=>{n.removeEventListener(`focusin`,o,!0),n.removeEventListener(`focusout`,s,!0)}}function $e(e,t){let n=e.ownerDocument,r=n=>{let r=n.target;r instanceof Element&&r.tagName===`FORM`&&r.contains(e)&&t()};return n.addEventListener(`reset`,r,!0),()=>n.removeEventListener(`reset`,r,!0)}var et=new Set([`bold`,`italic`,`strike`,`code`,`link`]);function tt(e,t){return e.map(e=>{if(Ee(e)!==`text`)return e;let n=S(e,`marks`);if(!Array.isArray(n))return e;let r=n.filter(e=>{let n=Ee(e);return n===null||!et.has(n)||t.has(n)});return r.length===n.length?e:{...e,marks:r}})}function nt(e,t){let n=[];for(let r of e){let e=r;switch(Ee(r)){case`paragraph`:n.push({...e,content:tt(S(e,`content`),t)});break;case`heading`:{let r=tt(S(e,`content`),t);n.push(t.has(`heading`)?{...e,content:r}:{type:`paragraph`,content:r});break}case`list`:{let r=S(e,`ordered`)===!0?`orderedList`:`bulletList`,i=S(e,`items`);if(t.has(r))n.push({...e,items:i.map(e=>({...e,content:nt(S(e,`content`),t)}))});else for(let e of i)n.push(...nt(S(e,`content`),t));break}case`blockquote`:{let r=nt(S(e,`content`),t);t.has(`blockquote`)?n.push({...e,content:r}):n.push(...r);break}case`codeBlock`:n.push(t.has(`codeBlock`)?r:Ie(ve(S(e,`text`))));break;default:n.push(r)}}return n}function rt(e,t){let n=w(e);if(n!==null)return n;let r=new Set(Array.isArray(t)?t:[]),i=Pe(e);return Pe({...i,blocks:nt(i.blocks,r)})}var it=200,D=function(){};D.prototype.append=function(e){return e.length?(e=D.from(e),!this.length&&e||e.length<it&&this.leafAppend(e)||this.length<it&&e.leafPrepend(this)||this.appendInner(e)):this},D.prototype.prepend=function(e){return e.length?D.from(e).append(this):this},D.prototype.appendInner=function(e){return new ot(this,e)},D.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?D.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},D.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},D.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)},D.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},D.from=function(e){return e instanceof D?e:e&&e.length?new at(e):D.empty};var at=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<=it)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=it)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}(D);D.empty=new at([]);var ot=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}(D);function O(e){this.content=e}O.prototype={constructor:O,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new O(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new O(n)},addToStart:function(e,t){return new O([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new O(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new O(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=O.from(e),e.size?new O(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=O.from(e),e.size?new O(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=O.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},O.from=function(e){if(e instanceof O)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new O(t)};function k(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&lt(e.charCodeAt(r-1))&&ct(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=k(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function st(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&lt(e.charCodeAt(i-1))&&ct(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=st(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function ct(e){return e>=56320&&e<57344}function lt(e){return e>=55296&&e<56320}var A=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return k(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return st(this,e,t,n)}findIndex(e){if(e==0)return ut(0,e);if(e==this.size)return ut(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?ut(t+1,i):ut(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};A.empty=new A([],0);var j={index:0,offset:0};function ut(e,t){return j.index=e,j.offset=t,j}function dt(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!dt(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!dt(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var M=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&dt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};M.none=[];var ft=class extends Error{},N=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=pt(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(P(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(A.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};N.empty=new N(A.empty,0,0);function P(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(P(a.content,t-i-1,n-i-1)))}function pt(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=pt(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function mt(e,t,n){if(n.openStart>e.depth)throw new ft(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ft(`Inconsistent open depths`);return ht(e,t,n,0)}function ht(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=ht(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return F(a,xt(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return F(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=St(n,e);return F(a,bt(e,i,o,t,r))}}function gt(e,t){if(!t.type.compatibleContent(e.type))throw new ft(`Cannot join `+t.type.name+` onto `+e.type.name)}function _t(e,t,n){let r=e.node(n);return gt(r,t.node(n)),r}function vt(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function yt(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(vt(e.nodeAfter,r),a++));for(let e=a;e<o;e++)vt(i.child(e),r);t&&t.depth==n&&t.textOffset&&vt(t.nodeBefore,r)}function F(e,t){if(!e.type.validContent(t))throw new ft(`Invalid content for node `+e.type.name);return e.copy(t)}function bt(e,t,n,r,i){let a=e.depth>i&&_t(e,t,i+1),o=r.depth>i&&_t(n,r,i+1),s=[];return yt(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(gt(a,o),vt(F(a,bt(e,t,n,r,i+1)),s)):(a&&vt(F(a,xt(e,t,i+1)),s),yt(t,n,i,s),o&&vt(F(o,xt(n,r,i+1)),s)),yt(r,null,i,s),new A(s)}function xt(e,t,n){let r=[];return yt(null,e,n,r),e.depth>n&&vt(F(_t(e,t,n+1),xt(e,t,n+1)),r),yt(t,null,n,r),new A(r)}function St(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(A.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Ct=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return M.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Dt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Et.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Et.set(t,r=new wt);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Tt,i}},wt=class{constructor(){this.elts=[],this.i=0}},Tt=12,Et=new WeakMap,Dt=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Ot=Object.create(null),kt=class e{constructor(e,t,n,r=M.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||A.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&dt(this.attrs,t||e.defaultAttrs||Ot)&&M.sameSet(this.marks,n||M.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return N.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new N(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return mt(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ct.resolveCached(this,e)}resolveNoCache(e){return Ct.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Mt(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=A.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Nt(this.type.attrs,this.attrs,`node`,this.type.name);let e=M.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];Nt(n.type.attrs,n.attrs,`mark`,n.type.name),e=n.addToSet(e)}if(!M.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=A.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}};kt.prototype.text=void 0;var At=(()=>{let{stack:e}=Error(`/`);if(!e||!/\n\s*at\s/.test(e))return e=>e;let t=Object.create(null);return e=>(t[e],e)})(),jt=class e extends kt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Mt(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return At(this.text.slice(e,t))}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(At(this.text.slice(e,t)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Mt(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}function Nt(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}var Pt=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Ft(t,n);if(r.next==null)return e.empty;let i=It(r);r.next&&r.err(`Unexpected trailing text`);let a=I(Ut(i));return Kt(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return A.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
1
+ import{a as e,l as t,n,o as r,s as i,u as a}from"./Icon-BjPIXI8I.js";import{B as o,C as s,F as c,I as l,J as u,L as d,N as f,P as p,Q as m,V as h,W as g,Y as _,et as ee,n as v,nt as y,rt as b,v as x,z as te}from"./element-CqIhTGKu.js";import{o as ne,r as re}from"./agent-Dt8YlN7n.js";import{t as ie}from"./composition-ChkgUGQ-.js";import{A as ae,B as oe,C as se,D as S,F as ce,I as le,L as ue,M as de,N as fe,O as C,P as pe,R as me,S as he,T as ge,V as _e,_ as ve,b as ye,c as be,d as xe,f as Se,g as w,h as Ce,i as we,j as Te,k as Ee,l as De,m as Oe,o as ke,p as Ae,s as je,t as Me,u as Ne,v as Pe,w as Fe,y as Ie,z as Le}from"./selection-bar.module-D4ISvYkQ.js";import{n as Re,r as ze,t as Be}from"./keyed-DOTZ3iez.js";import{n as T}from"./effects-BBm2yMRe.js";import{n as Ve}from"./presence-qi-0xFxa.js";import"./src-C2HZtjku.js";import{t as E}from"./Button-BJ5X73pv.js";import{t as He}from"./Separator-DEthKrfy.js";import{t as Ue}from"./Skeleton-BSq15Cez.js";import{t as We}from"./Input-YafcZQc5.js";import{t as Ge}from"./Popover-DD5KtkxE.js";import{t as Ke}from"./FormField-DzhcinED.js";import{t as qe}from"./Menu-IOiOO-OD.js";var Je=`a[href], button, input, select, textarea, [contenteditable="true"]`;function Ye(e){let t=e.ownerDocument.getSelection();return t===null||t.isCollapsed||t.rangeCount===0?!1:t.getRangeAt(0).intersectsNode(e)}function Xe(e,t,n=()=>!0){if(e==null)return()=>{};let r=e.ownerDocument,i=(e.getAttribute(`aria-labelledby`)??``).split(/\s+/).filter(Boolean).map(e=>r.getElementById(e)).filter(t=>t!==null&&!t.contains(e)),a=e=>{let r=e.currentTarget,i=e.target;if(e.defaultPrevented||e.button!==0||!n()||!(r instanceof Element)||!(i instanceof Element))return;let a=i.closest(Je);a!==null&&r.contains(a)||Ye(r)||t()};for(let e of i)e.addEventListener(`click`,a);return()=>{for(let e of i)e.removeEventListener(`click`,a)}}function Ze(e,t,n=[]){if(!(t instanceof Node))return!1;if(e.contains(t)||n.some(e=>e?.contains(t)===!0))return!0;for(let n=t instanceof Element?t:t.parentElement;n!==null;n=n.parentElement){if(n.id===``)continue;let t=n.id.replace(/["\\]/g,`\\$&`);if(e.querySelector(`[aria-controls~="${t}"]`)!==null)return!0}return!1}function Qe(e,t){let n=e.ownerDocument,r=n=>Ze(e,n,t.panels?.()??[]),i=r(n.activeElement),a=0;i&&t.entered();let o=e=>{a+=1;let n=r(e.target);n!==i&&(i=n,n?t.entered():t.left())},s=e=>{if(!i||e.relatedTarget!==null)return;a+=1;let o=a;queueMicrotask(()=>{a!==o||!i||r(n.activeElement)||(i=!1,t.left())})};return n.addEventListener(`focusin`,o,!0),n.addEventListener(`focusout`,s,!0),()=>{n.removeEventListener(`focusin`,o,!0),n.removeEventListener(`focusout`,s,!0)}}function $e(e,t){let n=e.ownerDocument,r=n=>{let r=n.target;r instanceof Element&&r.tagName===`FORM`&&r.contains(e)&&t()};return n.addEventListener(`reset`,r,!0),()=>n.removeEventListener(`reset`,r,!0)}var et=new Set([`bold`,`italic`,`strike`,`code`,`link`]);function tt(e,t){return e.map(e=>{if(Ee(e)!==`text`)return e;let n=S(e,`marks`);if(!Array.isArray(n))return e;let r=n.filter(e=>{let n=Ee(e);return n===null||!et.has(n)||t.has(n)});return r.length===n.length?e:{...e,marks:r}})}function nt(e,t){let n=[];for(let r of e){let e=r;switch(Ee(r)){case`paragraph`:n.push({...e,content:tt(S(e,`content`),t)});break;case`heading`:{let r=tt(S(e,`content`),t);n.push(t.has(`heading`)?{...e,content:r}:{type:`paragraph`,content:r});break}case`list`:{let r=S(e,`ordered`)===!0?`orderedList`:`bulletList`,i=S(e,`items`);if(t.has(r))n.push({...e,items:i.map(e=>({...e,content:nt(S(e,`content`),t)}))});else for(let e of i)n.push(...nt(S(e,`content`),t));break}case`blockquote`:{let r=nt(S(e,`content`),t);t.has(`blockquote`)?n.push({...e,content:r}):n.push(...r);break}case`codeBlock`:n.push(t.has(`codeBlock`)?r:Ie(ve(S(e,`text`))));break;default:n.push(r)}}return n}function rt(e,t){let n=w(e);if(n!==null)return n;let r=new Set(Array.isArray(t)?t:[]),i=Pe(e);return Pe({...i,blocks:nt(i.blocks,r)})}var it=200,D=function(){};D.prototype.append=function(e){return e.length?(e=D.from(e),!this.length&&e||e.length<it&&this.leafAppend(e)||this.length<it&&e.leafPrepend(this)||this.appendInner(e)):this},D.prototype.prepend=function(e){return e.length?D.from(e).append(this):this},D.prototype.appendInner=function(e){return new ot(this,e)},D.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?D.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},D.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},D.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)},D.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},D.from=function(e){return e instanceof D?e:e&&e.length?new at(e):D.empty};var at=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<=it)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=it)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}(D);D.empty=new at([]);var ot=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}(D);function O(e){this.content=e}O.prototype={constructor:O,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new O(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new O(n)},addToStart:function(e,t){return new O([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new O(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new O(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=O.from(e),e.size?new O(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=O.from(e),e.size?new O(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=O.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},O.from=function(e){if(e instanceof O)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new O(t)};function k(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&lt(e.charCodeAt(r-1))&&ct(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=k(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function st(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&lt(e.charCodeAt(i-1))&&ct(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=st(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function ct(e){return e>=56320&&e<57344}function lt(e){return e>=55296&&e<56320}var A=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return k(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return st(this,e,t,n)}findIndex(e){if(e==0)return ut(0,e);if(e==this.size)return ut(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?ut(t+1,i):ut(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};A.empty=new A([],0);var j={index:0,offset:0};function ut(e,t){return j.index=e,j.offset=t,j}function dt(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!dt(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!dt(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var M=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&dt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};M.none=[];var ft=class extends Error{},N=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=pt(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(P(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(A.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};N.empty=new N(A.empty,0,0);function P(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(P(a.content,t-i-1,n-i-1)))}function pt(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=pt(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function mt(e,t,n){if(n.openStart>e.depth)throw new ft(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ft(`Inconsistent open depths`);return ht(e,t,n,0)}function ht(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=ht(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return F(a,xt(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return F(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=St(n,e);return F(a,bt(e,i,o,t,r))}}function gt(e,t){if(!t.type.compatibleContent(e.type))throw new ft(`Cannot join `+t.type.name+` onto `+e.type.name)}function _t(e,t,n){let r=e.node(n);return gt(r,t.node(n)),r}function vt(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function yt(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(vt(e.nodeAfter,r),a++));for(let e=a;e<o;e++)vt(i.child(e),r);t&&t.depth==n&&t.textOffset&&vt(t.nodeBefore,r)}function F(e,t){if(!e.type.validContent(t))throw new ft(`Invalid content for node `+e.type.name);return e.copy(t)}function bt(e,t,n,r,i){let a=e.depth>i&&_t(e,t,i+1),o=r.depth>i&&_t(n,r,i+1),s=[];return yt(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(gt(a,o),vt(F(a,bt(e,t,n,r,i+1)),s)):(a&&vt(F(a,xt(e,t,i+1)),s),yt(t,n,i,s),o&&vt(F(o,xt(n,r,i+1)),s)),yt(r,null,i,s),new A(s)}function xt(e,t,n){let r=[];return yt(null,e,n,r),e.depth>n&&vt(F(_t(e,t,n+1),xt(e,t,n+1)),r),yt(t,null,n,r),new A(r)}function St(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(A.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Ct=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return M.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Dt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Et.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Et.set(t,r=new wt);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Tt,i}},wt=class{constructor(){this.elts=[],this.i=0}},Tt=12,Et=new WeakMap,Dt=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Ot=Object.create(null),kt=class e{constructor(e,t,n,r=M.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||A.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&dt(this.attrs,t||e.defaultAttrs||Ot)&&M.sameSet(this.marks,n||M.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return N.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new N(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return mt(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ct.resolveCached(this,e)}resolveNoCache(e){return Ct.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Mt(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=A.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Nt(this.type.attrs,this.attrs,`node`,this.type.name);let e=M.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];Nt(n.type.attrs,n.attrs,`mark`,n.type.name),e=n.addToSet(e)}if(!M.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=A.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}};kt.prototype.text=void 0;var At=(()=>{let{stack:e}=Error(`/`);if(!e||!/\n\s*at\s/.test(e))return e=>e;let t=Object.create(null);return e=>(t[e],e)})(),jt=class e extends kt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Mt(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return At(this.text.slice(e,t))}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(At(this.text.slice(e,t)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Mt(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}function Nt(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}var Pt=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Ft(t,n);if(r.next==null)return e.empty;let i=It(r);r.next&&r.err(`Unexpected trailing text`);let a=I(Ut(i));return Kt(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return A.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
2
2
  `)}};Pt.empty=new Pt(!0);var Ft=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function It(e){let t=[];do t.push(Lt(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function Lt(e){let t=[];do t.push(Rt(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function Rt(e){let t=Ht(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=Bt(e,t);else break;return t}function zt(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function Bt(e,t){let n=zt(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:zt(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function Vt(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function Ht(e){if(e.eat(`(`)){let t=It(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=Vt(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function Ut(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function Wt(e,t){return t-e}function Gt(e,t){let n=[];return r(t),n.sort(Wt);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function I(e){let t=Object.create(null);return n(Gt(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Gt(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Pt(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Wt);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Kt(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function qt(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Jt(e,t){let n=Object.create(null);for(let r in e){let i=e[r],a=t&&t[r];if(a===void 0)if(i.hasDefault)a=i.default;else throw RangeError(`No value supplied for attribute `+r);else i.validate&&i.validate(a);n[r]=a}return n}function Yt(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Qt(e,r,t[r]);return n}var Xt=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Yt(e,n.attrs),this.defaultAttrs=qt(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Pt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Jt(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new kt(this,this.computeAttrs(e),A.from(t),M.setFrom(n))}createChecked(e=null,t,n){return t=A.from(t),this.checkContent(t),new kt(this,this.computeAttrs(e),t,M.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=A.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(A.empty,!0);return i?new kt(this,e,t.append(i),M.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:M.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Zt(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Qt=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Zt(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},$t=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Yt(e,r.attrs),this.excluded=null;let i=qt(this.attrs);this.instance=i?new M(this,i):null}create(e=null){return!e&&this.instance?this.instance:new M(this,Jt(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}},en=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=O.from(e.nodes),t.marks=O.from(e.marks||{}),this.nodes=Xt.compile(this.spec.nodes,this),this.marks=$t.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=Pt.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?tn(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:tn(this,n.split(` `))}this.nodeFromJSON=e=>kt.fromJSON(this,e),this.markFromJSON=e=>M.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof Xt))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new jt(n,n.defaultAttrs,e,M.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function tn(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function nn(e){return e.tag!=null}function rn(e){return e.style!=null}var an=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(nn(e))this.tags.push(e);else if(rn(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new pn(this,t,!1);return n.addAll(e,M.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new pn(this,t,!0);return n.addAll(e,M.none,t.from,t.to),N.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(hn(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=gn(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=gn(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},on={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},sn={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},cn={ol:!0,ul:!0},L=1,ln=2,un=4;function dn(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?L:0)|(t===`full`?ln:0)}var fn=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=M.none,this.match=i||(a&un?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(A.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&L)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=A.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(A.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!on.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},pn=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=dn(null,t.preserveWhitespace,0)|(n?un:0);i=r?new fn(r.type,r.attrs,M.none,!0,t.topMatch||r.type.contentMatch,a):n?new fn(null,null,M.none,!0,null,a):new fn(e.schema.topNodeType,null,M.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&ln?`full`:this.localPreserveWS||(r.options&L)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
3
3
  `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;cn.hasOwnProperty(a)&&this.parser.normalizeLists&&mn(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:sn.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(on.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
4
  `),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=M.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):_n(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=dn(e,i,a.options);a.options&un&&a.content.length==0&&(o|=un);let s=M.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):_n(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new fn(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=L);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function mn(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&cn.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function hn(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function gn(e){let t={};for(let n in e)t[n]=e[n];return t}function _n(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var vn=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=bn(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return bn(t).createTextNode(e.text);let{dom:n,contentDOM:r}=wn(bn(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&wn(bn(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:wn(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=yn(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return yn(e.marks)}};function yn(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function bn(e){return e.document||window.document}var xn=new WeakMap;function Sn(e){let t=xn.get(e);return t===void 0&&xn.set(e,t=Cn(e)),t}function Cn(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function wn(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=Sn(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=wn(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Tn=65535,En=2**16;function Dn(e,t){return e+t*En}function On(e){return e&Tn}function kn(e){return(e-(e&Tn))/En}var An=1,jn=2,Mn=4,Nn=8,Pn=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Nn)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&Mn)>0}},Fn=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=On(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+kn(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:Dn(o/3,e-s),f=0;return c&&(f|=e==s?jn:e==u?An:Mn,(t<0?e!=s:e!=u)&&(f|=Nn)),new Pn(a,f,d)}r+=l-c}return n?e+r:new Pn(e+r,0,null)}touches(e,t){let n=0,r=On(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])}};Fn.empty=new Fn([]);var In=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=e.from,n=this._maps.length;t<e.to;t++){let r=e.getMirror(t);r!=null&&(r=r<t&&r>=e.from?n+(r-e.from):void 0),this.appendMap(e._maps[t],r)}}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.to-1,n=this._maps.length+e._maps.length;t>=e.from;t--){let r=e.getMirror(t);r!=null&&(r=r>t&&r<e.to?n-(r-e.from)-1:void 0),this.appendMap(e._maps[t].invert(),r)}}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 Pn(e,r,null)}},Ln=Object.create(null),R=class{getMap(){return Fn.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=Ln[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Ln)throw RangeError(`Duplicate use of step JSON ID `+e);return Ln[e]=t,t.prototype.jsonID=e,t}},z=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 ft)return e.fail(t.message);throw t}}};function Rn(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(Rn(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return A.fromArray(r)}var zn=class e extends R{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 N(Rn(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 z.fromReplace(e,this.from,this.to,i)}invert(t){let n=[];return t.nodesBetween(this.from,this.to,(t,r)=>{if(t.isInline&&t.isAtom){let i=this.mark.addToSet(t.marks);if(!M.sameSet(i,t.marks)){let a=Math.max(this.from,r),o=Math.min(this.to,r+t.nodeSize);Vn(Bn,a,o,this.mark,n);for(let r of t.marks)r.isInSet(i)||Vn(e,a,o,r,n)}}}),n.length==1?n[0]:new Hn(n)}map(t){let n=t.map(this.from,1),r=t.map(this.to,-1);return n>=r?null:new e(n,r,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))}};R.jsonID(`addMark`,zn);var Bn=class e extends R{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 N(Rn(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return z.fromReplace(e,this.from,this.to,n)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(e,n)=>{e.isInline&&e.isAtom&&this.mark.isInSet(e.marks)&&Vn(zn,Math.max(this.from,n),Math.min(this.to,n+e.nodeSize),this.mark,t)}),t.length==1?t[0]:new Hn(t)}map(t){let n=t.map(this.from,1),r=t.map(this.to,-1);return n>=r?null:new e(n,r,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))}};R.jsonID(`removeMark`,Bn);function Vn(e,t,n,r,i){let a=i.length?i[i.length-1]:null;a&&a instanceof e&&a.to==t&&a.mark.eq(r)?i[i.length-1]=new e(a.from,n,r):i.push(new e(t,n,r))}var Hn=class e extends R{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let n=t.apply(e);if(!n.doc)return n;e=n.doc}return new z(e,null)}invert(t){return new e(this.steps.map(e=>e.invert(t)))}map(t){let n=[];for(let e of this.steps){let r=e.map(t);r&&n.push(r)}return n.length?new e(n):null}toJSON(){return{stepType:`markSet`,steps:this.steps.map(e=>e.toJSON())}}static fromJSON(t,n){if(!Array.isArray(n.steps)||!n.steps.every(e=>e.stepType==`addMark`||e.stepType==`removeMark`))throw RangeError(`Invalid JSON for MarkSetStep`);return new e(n.steps.map(e=>R.fromJSON(t,e)))}};R.jsonID(`markSet`,Hn);var Un=class e extends R{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return z.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return z.fromReplace(e,this.pos,this.pos+1,new N(A.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new Wn(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))}};R.jsonID(`addNodeMark`,Un);var Wn=class e extends R{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return z.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return z.fromReplace(e,this.pos,this.pos+1,new N(A.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Un(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))}};R.jsonID(`removeNodeMark`,Wn);var Gn=class e extends R{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Kn(e,this.from,this.to)?z.fail(`Structure replace would overwrite content`):z.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Fn([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?N.empty:new N(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?N.empty:new N(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,N.fromJSON(t,n.slice),!!n.structure)}};Gn.MAP_BIAS=1,R.jsonID(`replace`,Gn);var B=class e extends R{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&&(Kn(e,this.from,this.gapFrom)||Kn(e,this.gapTo,this.to)))return z.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return z.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?z.fromReplace(e,this.from,this.to,n):z.fail(`Content does not fit in gap`)}getMap(){return new Fn([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||i>a?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,N.fromJSON(t,n.slice),n.insert,!!n.structure)}};R.jsonID(`replaceAround`,B);function Kn(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 qn(e,t,n,r){let i=[];e.doc.nodesBetween(t,n,(e,a,o)=>{if(!e.isInline)return;let s=e.marks;!r.isInSet(s)&&o.type.allowsMarkType(r.type)&&Vn(zn,Math.max(a,t),Math.min(a+e.nodeSize,n),r,i)}),i.forEach(t=>e.step(t))}function Jn(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline||!e.isAtom)return;a++;let s=null;if(r instanceof $t){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 Bn(t.from,t.to,t.style)))}function Yn(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 Gn(s,l,N.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new Bn(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 N(A.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new Gn(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(A.empty,!0);e.replace(s,s,new N(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Xn(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Zn(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||!Xn(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function Qn(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=A.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=A.from(r.node(e).copy(u)),d++):c--;let f=A.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=A.from(i.node(e).copy(f)),p++):l++;e.step(new B(c,l,o,s,new N(u.append(f),d,p),u.size-d,!0))}function $n(e,t,n=null,r=e){let i=tr(e,t),a=i&&nr(r,t);return a?i.map(er).concat({type:t,attrs:n}).concat(a.map(er)):null}function er(e){return{type:e,attrs:null}}function tr(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function nr(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function rr(e,t,n){let r=A.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=A.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new B(i,a,i,a,new N(r,0,0),n.length,!0))}function ir(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)&&sr(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&&or(e,t,n,a),Yn(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 B(c,l,c+1,l-1,new N(A.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&ar(e,t,n,a),!1}})}function ar(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 or(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(`
@@ -6,7 +6,7 @@ import{a as e,l as t,n,o as r,s as i,u as a}from"./Icon-BjPIXI8I.js";import{B as
6
6
 
7
7
  `),slice:t}}function jo(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 N(A.from(e.state.schema.text(t.replace(/\r\n?/g,`
8
8
  `))),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=vn.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=Uo(n),oa&&Wo(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&&!K(e);)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||an.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Mo.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=Go(Ro(s,+u[1],+u[2]),u[4]);else if(s=N.maxOpen(No(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=Ro(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,r)}),s}var Mo=/^(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 No(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&&Fo(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=Io(a[a.length-1],i.length));let n=Po(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return A.from(a)}return e}function Po(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,A.from(e));return e}function Fo(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=Fo(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(A.from(Po(n,e,i+1))))}}function Io(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Io(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(A.empty,!0);return e.copy(n.append(r))}function Lo(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=Lo(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(A.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function Ro(e,t,n){return t<e.openStart&&(e=new N(Lo(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new N(Lo(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var zo={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]};function Bo(){return document.implementation.createHTMLDocument(`title`)}var Vo=null;function Ho(e){let t=window.trustedTypes;if(!t)return e;if(!Vo){if(Vo=t.defaultPolicy)try{return Vo.createHTML(e)}catch{}Vo=t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e})}return Vo.createHTML(e)}function Uo(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Bo(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&zo[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>`</`+e+`>`).reverse().join(``)),r.innerHTML=Ho(e),a)for(let e=0;e<a.length;e++)r=r.querySelector(a[e])||r;for(let e=0;e<n.styleSheets.length;e++){let t=n.styleSheets[e];for(let e=0;e<t.rules.length;e++){let n=t.rules[e];if(n instanceof CSSStyleRule){let e=r.querySelectorAll(n.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=n.style.cssText}}}return r}function Wo(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 Go(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()||!t.createAndFill(null,i))break;try{i=A.from(t.create(r[e+1],i))}catch{break}a++,o++}return new N(i,a,o)}var Ko=class e{constructor(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}static from(t){return t instanceof e?t:new e(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset)}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};Ko.null=new Ko(null,0,null,0);var qo=class{constructor(e){this.view=e,this.range=Ko.null,this.active=!1,this.synced=!1,this.suppress=!1,this.currentDocument=null,this.onSelectionChange=this.onSelectionChange.bind(this)}ensureListener(){let e=this.view.dom.ownerDocument;e!=this.currentDocument&&(this.currentDocument&&this.currentDocument.removeEventListener(`selectionchange`,this.onSelectionChange),this.currentDocument=e,e.addEventListener(`selectionchange`,this.onSelectionChange))}destroy(){this.currentDocument&&=(this.currentDocument.removeEventListener(`selectionchange`,this.onSelectionChange),null),this.active=!1,this.range=Ko.null}suppressChanges(){this.suppress=!0,setTimeout(()=>this.suppress=!1,50)}onSelectionChange(){if(this.suppress&&this.view.hasFocus())return this.sync();this.read()&&this.view.domObserver.flush(!1)}readRange(){let{view:e}=this,t=e.dom.isConnected!==!1&&e.domSelection();return t?ta&&e.root.nodeType===11&&Ki(e.dom.ownerDocument)==e.dom?Ko.from(Jo(e,t)||t):Ko.from(t):Ko.null}read(){this.ensureListener();let e=ds(this.view);if(!e){this.active=!1,this.range=Ko.null;return}return this.active=!0,this.range.eq(e)?!1:(this.range=e,this.synced=!1,!0)}sync(e=!1){let{view:t}=this;t.docView&&(this.ensureListener(),t.domObserver.stopped(()=>{cs(t,t.state.selection);let n=t.state.selection;if(Zo(t)){let{desc:r,start:i}=$o(t.docView,n.from,n.to,0);t.cursorWrapper?ss(t):r instanceof Ja&&r.spec.setSelection?r.spec.setSelection(n.anchor-i,n.head-i,t.root):Qo(t,e,r,i),this.synced=this.active=!0}n.visible==t.dom.classList.contains(`ProseMirror-hideselection`)&&(n.visible?t.dom.classList.remove(`ProseMirror-hideselection`):(t.dom.classList.add(`ProseMirror-hideselection`),as(t))),this.range=this.readRange()}))}ignore(e=this.readRange()){this.range=Ko.from(e),this.synced=!0}deactivate(){this.range=Ko.null,this.active=this.synced=!1}};function Jo(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Yo(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?Yo(e,n):null}function Yo(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return Fi(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),new Ko(n,r,i,a)}function Xo(e,t,n=null){let r=e.state.doc;if(!t.focusNode)return null;let i=e.docView.nearestDesc(t.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(Ui(t)){for(c=o;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&U.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&Vi(t.focusNode,t.focusOffset,i.dom))){let e=i.posBefore;l=new U(o==e?s:r.resolve(e))}else if(Zi&&n==`key`&&o>e.state.selection.to&&K(t.focusNode)&&t.focusOffset==t.focusNode.childNodes.length&&i&&i.posAtStart>e.state.selection.to)for(let e=t.focusNode;;e=e.parentNode){if(getComputedStyle(e).overflow!=`visible`){l=V.findFrom(r.resolve(i.posAtStart),1);break}if(e==i.dom||e.nextSibling||!e.parentNode||!K(e.parentNode))break}}else{if(t instanceof e.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let n=o,i=o;for(let r=0;r<t.rangeCount;r++){let a=t.getRangeAt(r);n=Math.min(n,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(n<0)return null;[c,o]=i==e.state.selection.anchor?[i,n]:[n,i],s=r.resolve(o)}else c=e.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let t=n==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=us(e,u,s,t)}return l}function Zo(e){return e.editable?e.hasFocus():fs(e,e.domSel.readRange())&&(!document.activeElement||document.activeElement.contains(e.dom))}function Qo(e,t,n,r){let i=e.state.selection,{anchor:a,head:o}=i,s,c;ts&&!(i instanceof H)&&(i.$from.parent.inlineContent||(s=ns(e,i.from)),!i.empty&&!i.$from.parent.inlineContent&&(c=ns(e,i.to)));let l=n.domFromPos(a-r,a>r?-1:1);es(a,o,l,o==a?l:n.domFromPos(o-r,o>r?-1:1),e,t),ts&&(s&&is(s),c&&is(c))}function $o(e,t,n,r=0){for(let i=0,a=r;i<e.children.length;i++){let r=e.children[i],o=a+r.size;if(t>a&&n<o)return $o(r,t,n,a+r.border);a=o}return{desc:e,start:r}}function es(e,t,n,r,i,a){let o=!1;if((Zi||ta)&&e==t){let{node:e,offset:t}=n;if(q(e)){if(o=!!(t&&e.nodeValue[t-1]==`
9
- `),o&&t==e.nodeValue.length)for(let t=e,i;t;t=t.parentNode){if(i=t.nextSibling){i.nodeName==`BR`&&(n=r={node:i.parentNode,offset:W(i)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];o=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}let s=i.domSel.readRange();if(Zi&&s.focusNode&&s.focusNode!=r.node&&K(s.focusNode)){let e=s.focusNode.childNodes[s.focusOffset];e&&e.contentEditable==`false`&&(a=!0)}!(a||o&&ta)&&Fi(n.node,n.offset,s.anchorNode,s.anchorOffset)&&Fi(r.node,r.offset,s.focusNode,s.focusOffset)||Wi(i.domSelection(),{focusNode:r.node,focusOffset:r.offset,anchorNode:n.node,anchorOffset:n.offset})}var ts=ta||$i&&ea<63;function ns(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(ta&&i&&i.contentEditable==`false`)return rs(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return rs(i);if(a)return rs(a)}}function rs(e){return e.contentEditable=`true`,ta&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function is(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function as(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSel.readRange(),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(()=>{(!Zo(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function ss(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom;n.nodeName==`IMG`?t.collapse(n.parentNode,W(n)+1):t.collapse(n,0)}function cs(e,t){if(t instanceof U){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ls(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ls(e)}function ls(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function us(e,t,n,r){let i=e.someProp(`createSelectionBetween`,r=>r(e,t,n))||H.between(t,n,r);return e.someProp(`adjustSelectionFromDOM`,t=>{i=t(e,i)}),i}function ds(e){if(e.editable&&!e.hasFocus())return null;let t=e.domSel.readRange();return t&&fs(e,t)?t:null}function fs(e,t){if(!t.anchorNode)return!1;try{return Ri(e.dom,t.anchorNode)&&(e.editable||Ri(e.dom,t.focusNode))}catch{return!1}}var ps={},J={},ms={touchstart:!0,touchmove:!0},hs=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,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 gs(e){for(let t in ps){let n=ps[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{xs(e,t)&&(e.input.composing&&(t.type==`keydown`||t.type==`beforeinput`)&&t.isComposing===!1&&Ws(e,!0),!bs(e,t)&&(e.editable||!(t.type in J))&&n(e,t))},ms[t]?{passive:!0}:void 0)}ta&&e.dom.addEventListener(`input`,()=>null),ys(e)}function _s(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function vs(e){e.input.mouseDown&&e.input.mouseDown.done(),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 ys(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>bs(e,t))})}function bs(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function xs(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 Ss(e,t){!bs(e,t)&&ps[t.type]&&(e.editable||!(t.type in J))&&ps[t.type](e,t)}function Cs(e,t){let{input:n}=e;return n.lastKeyDispatched||e.composing?!1:(n.lastKeyDispatched=!0,typeof t==`string`&&(t=Gi(t==`Backspace`?8:13,t)),e.someProp(`handleKeyDown`,n=>n(e,t)))}J.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),e.input.lastKeyDispatched=!1,!(aa&&$i&&n.keyCode==13)){if(na&&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&&(Cs(e,`Enter`),e.input.lastIOSEnter=0)},200);return}n.keyCode!=229&&e.domObserver.forceFlush(!0),Cs(e,n)||ko(e,n)?n.preventDefault():_s(e,`key`)}},J.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},J.keypress=(e,t)=>{let n=t;if(Vs(e)||!n.charCode||n.ctrlKey&&!n.altKey||ra&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof H)||!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 ws(e){return{left:e.clientX,top:e.clientY}}function Ts(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Es(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 Ds(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta(`pointer`,!0),e.dispatch(r)}function Os(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&U.isSelectable(r)?(Ds(e,new U(n)),!0):!1}function ks(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof U&&(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(U.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:(Ds(e,U.create(e.state.doc,i)),!0)}function As(e,t,n,r,i){return Es(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?ks(e,n):Os(e,n))}function js(e,t,n,r){return Es(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Ms(e,t,n,r){return Es(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))}function Ns(e,t,n){if(t==-1)return e.inlineContent?H.create(e,0,e.content.size):null;let r=e.resolve(t);for(let t=r.depth+1;t>0;t--){let i=t>r.depth?r.nodeAfter:r.node(t),a=r.before(t);if(i.inlineContent)return H.create(e,a+1,a+1+i.content.size);if(n&&U.isSelectable(i))return U.create(e,a)}return null}var Ps=/[\w_\u00a1-\uffff]+/g;try{Ps=RegExp(`[\\p{L}\\p{N}_]+`,`gu`)}catch{}function Fs(e,t){let n=e.resolve(t),r=n.node(),i=``,a=t,o=t;for(let e=n.indexAfter(),o=!1;e>0;e--){let s=r.child(e-1);if(!s.text)break;let c=a==t?t-n.posAtIndex(e-1):s.text.length,l=c;for(;l>0;l--)if(/\S/.test(s.text[l-1]))o=!0;else if(o)break;if(i=s.text.slice(l,c)+i,a-=c-l,l||a<t-50)break}for(let e=n.index(),a=!1;e<r.childCount;e++){let s=r.child(e);if(!s.text)break;let c=o==t?t-n.posAtIndex(e):0,l=c;for(;l<s.text.length;l++)if(/\S/.test(s.text[l]))a=!0;else if(a)break;if(i+=s.text.slice(c,l),o+=l-c,l<s.text.length||o>t+50)break}let s=a,c=o;if(Intl.Segmenter){for(let n of new Intl.Segmenter(void 0,{granularity:`word`}).segment(i))if(n.isWordLike){let r=n.index+a,i=r+n.segment.length;if(i<t)s=i;else if(r>t){c=r;break}else return H.create(e,r,i)}}else{Ps.lastIndex=0;for(let n;n=Ps.exec(i);){let r=n.index+a,i=r+n[0].length;if(i<t)s=i;else if(r>t){c=r;break}else return H.create(e,r,i)}}let l=i.slice(s-a,t-a),u=i.slice(t-a,c-a),d=/\S*$/.exec(l)[0].length,f=/^\S*/.exec(u)[0].length;if(d||f)return H.create(e,t-d,t+f);let p=/\s*$/.exec(l)[0].length,m=/^\s*/.exec(u)[0].length;return H.create(e,t-p,t+m)}var Is=ra?`metaKey`:`ctrlKey`;ps.mousedown=(e,t)=>{let n=t,r=Date.now();if(e.input.shiftKey=n.shiftKey,e.input.lastTouch>r-500)return!1;Js(e);let i=`singleClick`;r-e.input.lastClick.time<500&&Ts(n,e.input.lastClick)&&!n[Is]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?i=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(i=`tripleClick`)),e.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:i,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let a=e.posAtCoords(ws(n));if(a)if(n.button==0){if(!e.hasFocus()){_a(e.dom);let t=e.root.activeElement;t&&!t.contains(e.dom)&&t.blur()}(e.input.mouseDown=new Ls(e,a,n,i)).mightDrag||n.preventDefault()}else _s(e,`pointer`)};var Ls=class{constructor(e,t,n,r){this.view=e,this.startPos=t,this.event=n,this.type=r,this.didMove=!1,this.lastPos=-1,this.anchorRange=null,this.startDoc=e.state.doc,this.selectNode=!!n[Is],this.extend=n.shiftKey,this.anchorDoc=this.startDoc;let i=Rs(e);if(this.extend){let t=e.state.selection;this.anchorRange=t instanceof U?{from:t.from,to:t.to}:{from:t.anchor,to:t.anchor};let n=t instanceof U?e.nodeDOM(t.from).getBoundingClientRect():e.coordsAtPos(t.anchor);this.anchorOffset={x:(n.left+n.right)/2-i.x,y:(n.top+n.bottom)/2-i.y}}else this.anchorOffset={x:n.clientX-i.x,y:n.clientY-i.y};if(r==`singleClick`){let{selection:r}=e.state,i,a,o=!1;if(r instanceof U&&r.from<=t.pos&&r.to>=t.pos)a=r.from,i=r.node,o=!0;else 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():-1}if(o||a>-1&&i.type.spec.draggable&&i.type.spec.selectable!==!1){let t=e.docView.descAt(a)?.nodeDOM;this.mightDrag={node:i,elt:t,pos:a,addAttr:!1},t&&!t.draggable&&(this.mightDrag.addAttr=!0,e.domObserver.stopped(()=>t.draggable=!0))}else this.mightDrag=Bs(e,n)}else this.mightDrag=!1;e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this)),this.mightDrag||this.select(this.startPos,!0)}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null),typeof this.mightDrag==`object`&&this.mightDrag.addAttr&&this.view.domObserver.stopped(()=>this.mightDrag.elt.removeAttribute(`draggable`))}maybeRunHandler(e,t){return(this.type==`singleClick`?As:this.type==`doubleClick`?js:Ms)(this.view,e.pos,e.inside,t,this.selectNode)}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.startPos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ws(e))),t&&(this.didMove||this.maybeRunHandler(t,e)||this.select(t,!0),e.preventDefault())}move(e){if(e.buttons==0){this.done();return}if(!this.didMove&&(Math.abs(this.event.x-e.clientX)>8||Math.abs(this.event.y-e.clientY)>8)&&(this.didMove=!0,this.mightDrag=!1),!this.mightDrag){let t=this.view.posAtCoords(ws(e));t&&this.select(t,!1)}e.preventDefault()}select(e,t){if(e.pos==this.lastPos)return;this.lastPos=e.pos;let{view:n}=this,{doc:r}=n.state,i=this.type==`singleClick`?zs(n,r,e):this.type==`doubleClick`?Fs(r,e.pos):Ns(r,e.inside,t);i&&(t&&!this.extend?this.anchorRange=i:(!t||this.extend)&&(r.eq(this.anchorDoc)||this.restoreAnchor(),this.anchorRange&&this.anchorRange.from<i.from?i=us(n,r.resolve(this.anchorRange.from),r.resolve(i.to)):this.anchorRange&&this.anchorRange.to>i.to&&(i=us(n,r.resolve(this.anchorRange.to),r.resolve(i.from)))),i.eq(n.state.selection)||n.dispatch(n.state.tr.setSelection(i).setMeta(`pointer`,!0).scrollIntoView()))}restoreAnchor(){let e=Rs(this.view),t=this.view.posAtCoords({left:this.anchorOffset.x+e.x,top:this.anchorOffset.y+e.y});if(!t)this.anchorRange=null;else{let{doc:e}=this.view.state;this.anchorRange=this.type==`singleClick`?zs(this.view,e,t):this.type==`doubleClick`?Fs(e,t.pos):Ns(e,t.inside,!1),this.anchorDoc=this.view.state.doc}}};function Rs(e){let t=e.dom.getBoundingClientRect();return{x:t.left-e.dom.scrollLeft,y:t.top-e.dom.scrollTop}}function zs(e,t,n){if(n.inside>-1){let e=t.nodeAt(n.inside);if(e.isAtom&&U.isSelectable(e))return U.create(t,n.inside)}let r=t.resolve(n.pos);return us(e,r,r)}function Bs(e,t){let{selection:n}=e.state;if(n.empty)return!1;let r=e.domSelection();if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}ps.touchstart=e=>{e.input.lastTouch=Date.now(),Js(e),_s(e,`pointer`)},ps.touchmove=e=>{e.input.lastTouch=Date.now(),_s(e,`pointer`)},ps.contextmenu=e=>Js(e);function Vs(e,t){return e.composing?!0:ta&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Hs=aa?5e3:-1;J.compositionstart=J.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof H&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||$i&&ia&&Us(e)))e.markCursor=e.state.storedMarks||n.marks(),Js(e,!0),e.markCursor=null;else if(Js(e,!t.selection.empty),Zi&&e.domSel.active&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(let{focusNode:t,focusOffset:n}=e.domSel.range;t&&K(t)&&n!=0;){let r=n<0?t.lastChild:t.childNodes[n-1];if(!r)break;if(q(r)){let t=e.domSelection();t&&t.collapse(r,r.nodeValue.length);break}else t=r,n=-1}e.input.composing=!0}Gs(e,Hs)};function Us(e){let{focusNode:t,focusOffset:n}=e.domSel.range;if(!t||!K(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return K(r)&&r.contentEditable==`false`}J.compositionend=(e,t)=>{e.composing&&Ws(e)};function Ws(e,t=!1){e.input.composing=!1,e.input.compositionEndedAt=Date.now(),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++,t?Js(e):Gs(e,20)}function Gs(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Js(e),t))}function Ks(e){e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());for(let t;t=e.input.compositionNodes.pop();)t.markParentDamage()}function qs(e){let t=e.domSel.range;if(!e.domSel.active||!t.focusNode)return null;let n=zi(t.focusNode,t.focusOffset),r=Bi(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 Js(e,t=!1){if(!(aa&&e.domObserver.flushingSoon>=0)&&(e.domObserver.forceFlush(),Ks(e),t||e.docView&&e.docView.damage)){let n=Xo(e,e.domSel.readRange()),r=e.state.selection;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)}}function Ys(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 Xs=na&&sa<604;ps.copy=J.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Xs?null:n.clipboardData,{dom:o,text:s}=Ao(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Ys(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Zs(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Qs(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?$s(e,r.value,null,i,t):$s(e,r.textContent,r.innerHTML,i,t)},50)}function $s(e,t,n,r,i){let a=jo(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||N.empty)))return!0;if(!a)return!1;let o=Zs(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 ec(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,` `):``}J.paste=(e,t)=>{let n=t;if(e.composing&&!aa)return;let r=Xs?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&$s(e,ec(r),r.getData(`text/html`),i,n)?n.preventDefault():Qs(e,n)};var tc=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},nc=ra?`altKey`:`ctrlKey`;function rc(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[nc]:!n}ps.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(ws(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof U?i.to-1:i.to))){if(r&&typeof r.mightDrag==`object`)o=U.create(e.state.doc,r.mightDrag.pos);else if(n.target&&K(n.target)){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=U.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Ao(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!$i||ea>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Xs?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Xs||n.dataTransfer.setData(`text/plain`,c),e.dragging=new tc(l,rc(e,n),o)},ps.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},J.dragover=J.dragenter=(e,t)=>t.preventDefault(),J.drop=(e,t)=>{try{ic(e,t,e.dragging)}finally{e.dragging=null}};function ic(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(ws(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=jo(e,ec(t.dataTransfer),Xs?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&rc(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||N.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?gr(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&&U.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new U(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(us(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}ps.focus=e=>{if(e.input.lastFocus=Date.now(),!e.focused&&(e.domObserver.stopped(()=>e.dom.classList.add(`ProseMirror-focused`)),e.focused=!0,e.domSel.read(),!e.domSel.synced)){let t=e.domSel.range;setTimeout(()=>{let n=e.domSel.readRange();n&&t.eq(n)&&e.domSel.sync()},20)}},ps.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stopped(()=>e.dom.classList.remove(`ProseMirror-focused`)),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domSel.deactivate(),!1)},ps.beforeinput=(e,t)=>{if(aa&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||e.domObserver.pendingRecords().length||(e.dom.blur(),e.focus(),Cs(e,`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 J)ps[e]=J[e];function ac(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 oc=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}},sc=class e{constructor(e,t){this.toDOM=e,this.spec=t||fc,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 uc(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&&ac(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},cc=class e{constructor(e,t){this.attrs=e,this.spec=t||fc}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 uc(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&ac(this.attrs,t.attrs)&&ac(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},lc=class e{constructor(e,t){this.attrs=e,this.spec=t||fc}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 uc(i.pos-n,a.pos-n,this)}valid(e,t,n){let r=n.nodeAt(t.from);return!!r&&!r.isText&&t.from+r.nodeSize==t.to}eq(t){return this==t||t instanceof e&&ac(this.attrs,t.attrs)&&ac(this.spec,t.spec)}destroy(){}},uc=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 sc(n,r))}static inline(t,n,r,i){return new e(t,n,new cc(r,i))}static node(t,n,r,i){return new e(t,n,new lc(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof cc}get widget(){return this.type instanceof sc}},dc=[],fc={},pc=class e{constructor(e,t){this.local=e.length?e:dc,this.children=t.length?t:dc}static create(e,t){return t.length?bc(t,e,0,fc):Y}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];if(o.from>t)break;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&&!(this.children[a]>=t);a+=3)if(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==Y||e.maps.length==0?this:this.mapInner(e,t,0,0,n||fc)}mapInner(t,n,r,i,a){let o;if(this.local.length){let e=new oc(n.content);for(let s=0;s<this.local.length;s++){let c=this.local[s].map(t,r,i);c&&c.type.valid(n,c,e)?(o||=[]).push(c):a.onRemove&&a.onRemove(this.local[s].spec)}}return this.children.length?hc(this.children,o||[],t,n,r,i,a):o?new e(o.sort(xc),dc):Y}add(t,n){return n.length?this==Y?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=vc(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,bc(s,e,o+1,fc)),a+=3}});let o=gc(a?yc(n):n,-r).sort(xc);if(o.length){let e=new oc(t.content);for(let n=0;n<o.length;n++)o[n].type.valid(t,o[n],e)||o.splice(n--,1)}return new e(o.length?this.local.concat(o).sort(xc):this.local,i||this.children)}remove(e){return e.length==0||this==Y?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==Y?(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):Y}forChild(t,n){if(this==Y)return this;if(n.isLeaf)return e.empty;let r,i,a=0,o=this.children.length/3;for(;a<o;){let e=a+o>>>1,n=e*3,i=this.children[n];if(i<t)a=e+1;else if(i>t)o=e;else{r=this.children[n+2];break}}let s=t+1,c=s+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<c&&t.to>s&&t.type instanceof cc){let e=Math.max(s,t.from)-s,n=Math.min(c,t.to)-s;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(xc),dc);return r?new mc([t,r]):t}return r||Y}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 Sc(this.localsInner(e))}localsInner(e){if(this==Y)return dc;if(e.inlineContent||!this.local.some(cc.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof cc||t.push(this.local[e]);return t}forEachSet(e){e(this)}};pc.empty=new pc([],[]),pc.removeOverlap=Sc;var Y=pc.empty,mc=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,fc));return e.from(r)}forChild(t,n){if(n.isLeaf)return pc.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=Y&&(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?Sc(n?t:t.sort(xc)):dc}static from(t){switch(t.length){case 0:return Y;case 1:return t[0];default:return new e(t.every(e=>e instanceof pc)?t:t.reduce((e,t)=>e.concat(t instanceof pc?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function hc(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==Y?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=bc(_c(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 pc(t.sort(xc),s)}function gc(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 uc(i.from+t,i.to+t,i.type))}return n}function _c(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 vc(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 yc(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function bc(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=vc(e,t,o+n);if(s){a=!0;let e=bc(s,t,n+o+1,r);e!=Y&&i.push(o,o+t.nodeSize,e)}});let o=gc(a?yc(e):e,-n).sort(xc);if(o.length){let e=new oc(t.content);for(let n=0;n<o.length;n++)o[n].type.valid(t,o[n],e)||(r.onRemove&&r.onRemove(o[n].spec),o.splice(n--,1))}return o.length||i.length?new pc(o,i):Y}function xc(e,t){return e.from-t.from||e.to-t.to}function Sc(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),Cc(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),Cc(t,i,r.copy(a.from,r.to)));break}}}return t}function Cc(e,t,n){for(;t<e.length&&xc(n,e[t])>0;)t++;e.splice(t,0,n)}function wc(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=Y&&t.push(r)}),e.cursorWrapper&&t.push(pc.create(e.state.doc,[e.cursorWrapper.deco])),mc.from(t)}function Tc(e,t,n,r){let{node:i,fromOffset:a,toOffset:o,from:s,to:c}=e.docView.parseRange(t,n),l=e.domSel.range,u,d=l.anchorNode;if(d&&Ri(e.dom,d)&&(u=[{node:d,offset:l.anchorOffset}],Ui(l)||u.push({node:l.focusNode,offset:l.focusOffset})),$i&&e.input.lastKeyCode===8)for(let e=o;e>a;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){o=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||an.fromSchema(e.state.schema),m=f.resolve(s),h=null,g=p.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:a,to:o,preserveWhitespace:m.parent.type.whitespace!=`pre`||`full`,findPositions:u,ruleFromNode:Ec(r),context:m});if(u&&u[0].pos!=null){let e=u[0].pos,t=u[1]&&u[1].pos;t??=e,h={anchor:e+s,head:t+s}}return{doc:g,sel:h,from:s,to:c}}var Ec=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName==`BR`&&t.parentNode){if(ta&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(t.parentNode.lastChild==t||ta&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName==`IMG`&&t.getAttribute(`mark-placeholder`))return{ignore:!0};return null},Dc=/^(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 Oc(e,t,n,r,i,a){let o=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=Xo(e,e.domSel.range,t);if(n&&!e.state.selection.eq(n)&&e.domSel.active){if($i&&aa&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&Cs(e,`Enter`))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),o&&r.setMeta(`composition`,o),e.dispatch(r)}return}let s=e.state.doc.resolve(t),c=s.sharedDepth(n);t=s.before(c+1),n=e.state.doc.resolve(n).after(c+1);let l=e.state.selection,u=Tc(e,t,n,a),d=e.state.doc,f=d.slice(u.from,u.to),p,m;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(p=e.state.selection.to,m=`end`):(p=e.state.selection.from,m=`start`),e.input.lastKeyCode=null;let h=Pc(f.content,u.doc.content,u.from,p,m);if(h&&e.input.domChangeCount++,(na&&e.input.lastIOSEnter>Date.now()-225||aa)&&a.some(e=>K(e)&&!Dc.test(e.nodeName))&&(!h||h.endA>=h.endB)&&Cs(e,`Enter`)){e.input.lastIOSEnter=0;return}if(!h)if(i&&l instanceof H&&!l.empty&&l.$head.sameParent(l.$anchor)&&!e.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))h={start:l.from,endA:l.to,endB:l.to};else{if(u.sel){let t=kc(e,e.state.doc,u.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);o&&n.setMeta(`composition`,o),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&h.start==h.endB&&e.state.selection instanceof H&&(h.start>e.state.selection.from&&h.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?h.start=e.state.selection.from:h.endA<e.state.selection.to&&h.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(h.endB+=e.state.selection.to-h.endA,h.endA=e.state.selection.to));let g=u.doc.resolveNoCache(h.start-u.from),_=u.doc.resolveNoCache(h.endB-u.from),ee=d.resolve(h.start),v=g.sameParent(_)&&g.parent.inlineContent&&ee.end()>=h.endA;if((na&&e.input.lastIOSEnter>Date.now()-225&&(!v||a.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&Mc(u.doc,g.pos,_.pos))&&Cs(e,`Enter`)){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>h.start&&(v?h.endA>h.start&&h.endB==h.start:jc(d,h.start,h.endA,g,_))&&Cs(e,`Backspace`)){aa&&$i&&e.domSel.suppressChanges();return}$i&&h.endB==h.start&&(e.input.lastChromeDelete=Date.now()),aa&&!v&&g.start()!=_.start()&&_.parentOffset==0&&g.depth==_.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==h.endA&&(h.endB-=2,_=u.doc.resolveNoCache(h.endB-u.from),setTimeout(()=>Cs(e,`Enter`),20));let y=h.start,b=h.endA,x=t=>{let n=t||e.state.tr.replace(y,b,u.doc.slice(h.start-u.from,h.endB-u.from));if(u.sel){let t=kc(e,n.doc,u.sel);t&&!($i&&e.composing&&t.empty&&(h.start!=h.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1))&&n.setSelection(t)}return o&&n.setMeta(`composition`,o),n.scrollIntoView()},te;if(v)if(g.pos==_.pos){let t=x(e.state.tr.delete(y,b)),n=d.resolve(h.start).marksAcross(d.resolve(h.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(h.endA==h.endB&&(te=Ac(g.parent.content.cut(g.parentOffset,_.parentOffset),ee.parent.content.cut(ee.parentOffset,h.endA-ee.start())))){let t=x(e.state.tr);te.type==`add`?t.addMark(y,b,te.mark):t.removeMark(y,b,te.mark),e.dispatch(t)}else if(g.parent.child(g.index()).isText&&g.index()==_.index()-+!_.textOffset){let t=g.parent.textBetween(g.parentOffset,_.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function kc(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:us(e,t.resolve(n.anchor),t.resolve(n.head))}function Ac(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(A.from(l).eq(e))return{mark:s,type:o}}function jc(e,t,n,r,i){if(n-t<=i.pos-r.pos||Nc(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.inlineContent){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(Nc(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Nc(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Mc(e,t,n){let r=0,i=0;return e.nodesBetween(t,n,(e,a)=>{e.isTextblock&&a>=t&&a<n?r++:(e.isText?/\S/.test(e.text.slice(Math.max(0,t-a),Math.min(e.nodeSize,n-a))):e.isLeaf)&&i++}),i==0&&r==1}function Nc(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 Pc(e,t,n,r,i){let a=e.findDiffStart(t,n),o=n+e.size,s=n+t.size;if(a==null)return null;let{a:c,b:l}=e.findDiffEnd(t,o,s);if(i==`end`){let e=Math.max(0,a-Math.min(c,l));r-=c+e-a}if(c<a&&o<s){let e=r<=a&&r>=c?a-r:0;a-=e,l=a+(l-c),c=a}else if(l<a){let e=r<=a&&r>=l?a-r:0;a-=e,c=a+(c-l),l=a}return{start:a,endA:c,endB:l}}var Fc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ic=class{constructor(e){this.view=e,this.queue=[],this.flushingSoon=-1,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.started=!1,this.observer=new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);ta&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()})}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(e=!1){this.flushingSoon>-1?(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush(!0)):e&&this.flush(!0)}start(){this.observer.takeRecords(),this.observer.observe(this.view.dom,Fc),this.started=!0}stop(){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.started=!1}stopped(e){if(!this.started)return e();this.stop();try{return e()}finally{this.start()}}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=ji(n))t.add(n);for(let r=e.anchorNode;r;r=ji(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:q(n)?n.parentNode:n}))return this.view.domSel.ignore(e),!0}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(e=!0){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]),e&&t.domSel.read();let r=!t.domSel.suppress&&!t.domSel.synced&&!!ds(t)&&!this.ignoreSelectionChange(t.domSel.range),i=-1,a=-1,o=!1,s=[];if(t.editable)for(let e=0;e<n.length;e++){let t=this.registerMutation(n[e],s);t&&(i=i<0?t.from:Math.min(t.from,i),a=a<0?t.to:Math.max(t.to,a),t.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||$i&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&n.some(e=>e.type==`childList`&&e.removedNodes.length))){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&K(t);){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(Zi&&s.length){let e=s.filter(e=>e.nodeName==`BR`);if(e.length==2){let[t,n]=e;t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}else{let{focusNode:n}=t.domSel.range;for(let r of e){let e=r.parentNode;e&&e.nodeName==`LI`&&(!n||Bc(t,n)!=e)&&r.remove()}}}let c=null;i<0&&r&&t.domSel.active&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Ui(t.domSel.range)&&(c=Xo(t,t.domSel.range))&&c.eq(V.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,t.domSel.sync(),t.scrollToSelection()):(i>-1||r)&&(i>-1&&zc(t),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,Vc(t,s)),Oc(this.view,i,a,r,o,s),t.docView&&t.docView.damage?t.updateState(t.state):r&&t.domSel.sync())}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n;for(let t=e.target;t&&!(n=this.view.docView.getDesc(t));t=t.parentNode);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),q(r)&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return n.markDamage(4),{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling,a=r&&r.parentNode==e.target?W(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?W(i):e.target.childNodes.length,c=n.localPosFromDOM(e.target,s,1);return n.markDamage(n.contentDOM?.contains(e.target)?2:4),{from:o,to:c}}else if(e.type==`attributes`)return n.markDamage(4),{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,n.markDamage(n instanceof Ka&&e.target==n.nodeDOM?8:4),{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},Lc=new WeakMap,Rc=!1;function zc(e){if(!Lc.has(e)&&(Lc.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=Zi,Rc)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.`),Rc=!0}}function Bc(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 Vc(e,t){let{focusNode:n,focusOffset:r}=e.domSel.range;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||!K(e)||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)}}var Hc=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 hs,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Yc),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=Gc(this),Wc(this),this.nodeViews=qc(this),this.docView=Ga(this.state.doc,Uc(this),wc(this),this.dom,this),this.domObserver=new Ic(this),this.domSel=new qo(this),this.domObserver.start(),this.domSel.read(),gs(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&&ys(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Yc),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&&(Ks(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=qc(this);Jc(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&ys(this),this.editable=Gc(this),Wc(this);let o=wc(this),s=Uc(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&&fa(this);i&&this.domObserver.stopped(()=>{let t=l&&$i&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Kc(n.selection,e.selection);if(l){let n=$i?this.trackWrites=this.domSel.range.focusNode:null;if(this.composing&&(this.input.compositionNode=qs(this)),r||!this.docView.update(e.doc,s,o,this,-1)){let t=this.docView.outerDeco;this.docView.destroy(),this.docView=Ga(e.doc,s,o,this.dom,this,t)}n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}this.domSel.sync(t)}),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&&ma(u)}scrollToSelection(){let e=this.domSel.range.focusNode;if(!(!e||!this.domSel.active)&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof U){let t=this.docView.domAfterPos(this.state.selection.from);K(t)&&da(this,t.getBoundingClientRect(),e)}else da(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new tc(e.slice,e.move,r<0?void 0:U.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(){return this.root.activeElement==this.dom}focus(){this.editable&&_a(this.dom),this.domSel.sync()}get root(){let e=this.dom.isConnected!==!1;e||(this._root=null);let t=this._root;if(t==null&&e){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 t||document}updateRoot(){this._root=null}posAtCoords(e){return Ta(this,e)}coordsAtPos(e,t=1){return ka(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 za(this,t||this.state,e)}pasteHTML(e,t){return $s(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return $s(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Ao(this,e)}destroy(){this.docView&&(vs(this),this.domSel.destroy(),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],wc(this),this,-1),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Pi())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ss(this,e)}domSelection(){return this.root.getSelection()}};Hc.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Uc(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`,[uc.node(0,e.state.doc.content.size,t)]}function Wc(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:uc.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Gc(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Kc(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 qc(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 Jc(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 Yc(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`)}function Xc(e){return xe(e)}var X={doc:`doc`,paragraph:`paragraph`,heading:`heading`,bulletList:`bulletList`,orderedList:`orderedList`,listItem:`listItem`,blockquote:`blockquote`,codeBlock:`codeBlock`,text:`text`,hardBreak:`hardBreak`,entity:`entity`,unknownBlock:`unknownBlock`,unknownInline:`unknownInline`},Z={link:`link`,bold:`bold`,italic:`italic`,strike:`strike`,code:`code`,annotation:`annotation`,unknown:`unknown`,textFields:`textFields`},Q={default:null};function Zc(e,t){return Math.min(t+e-1,4)}function Qc(e){let t={};for(let[n,r]of Object.entries(e))r!=null&&r!==``&&(t[n]=r);return t}var $c=`data-entity-token`,el=new Map;function tl(e){let t=new Uint8Array(16);globalThis.crypto.getRandomValues(t);let n=Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``);for(el.set(n,e);el.size>500;){let e=el.keys().next().value;if(e===void 0)break;el.delete(e)}return n}function nl(e,t){let n=e===null?void 0:el.get(e);return n!==void 0&&n.kind===t.kind&&n.id===t.id&&n.label===t.label}var rl=`[A-Za-z0-9_+#.-]{1,32}`,il=RegExp(`^${rl}$`);function al(e){let t=(e??``).trim();return il.test(t)?t:``}function ol(e){let t=e.querySelector(`code`);for(let n of[e,t]){if(!n)continue;let e=al(n.getAttribute(`data-language`));if(e)return e;for(let e of Array.from(n.classList)){let t=/^(?:language|lang)-(.+)$/.exec(e),n=t?al(t[1]):``;if(n)return n}}return``}function sl(e){let t=e.trim().toLowerCase();return t===`bold`||t===`bolder`||/^\d+$/.test(t)&&Number(t)>=600}var cl=/mso-list:\s*l(\d+)\s+level(\d+)\s+lfo(\d+)/i,ll=/mso-list:\s*ignore/i,ul=/^\(?(\d+|[a-z]|[ivxlcdm]+)[.)]$/i,dl=e=>e.getAttribute(`style`)??``;function fl(e){let t=cl.exec(dl(e));if(!t)return null;let n=(Array.from(e.querySelectorAll(`span`)).find(e=>ll.test(dl(e)))?.textContent??``).replace(/\s+/g,``),r=ul.test(n),i=/^\(?(\d+)[.)]$/.exec(n),a=i?Number(i[1]):1;return{list:t[3],level:Number(t[2]),ordered:r,start:Number.isSafeInteger(a)?a:1}}var pl=/monospace|menlo|monaco|consolas|courier|mono\b|code\b/i;function ml(e){if(!/^pre(?:-wrap)?$/.test(e.style.whiteSpace)||!pl.test(e.style.fontFamily))return null;let t=Array.from(e.children),n=t.length>0&&t.every(e=>e.tagName===`DIV`||e.tagName===`BR`)?t.map(e=>e.tagName===`BR`?``:e.textContent??``):(e.textContent??``).split(/\r\n?|\n/);return n.length>1?n:null}function hl(e,t){let n=an.fromSchema(t),r=[];return Array.from(e.children).filter(e=>/^T[DH]$/.test(e.tagName)).forEach((e,i)=>{i>0&&r.push(t.text(` `));let a=e.ownerDocument.createElement(`div`);a.append(e.cloneNode(!0));let o=!1,s=e=>e.forEach(e=>{e.isInline?(o&&r.length>0&&r.push(t.text(` `)),o=!1,r.push(e)):(o=!0,s(e.content),o=!0)});s(n.parseSlice(a).content)}),r.every(e=>e.isText&&/^\s*$/.test(e.text??``))?A.empty:A.from(r)}function gl(e,t){let n=t=>e?t(e):void 0;return{paragraph:()=>[`p`,Qc({class:n(e=>e.paragraph)}),0],heading:r=>{let i=r.attrs.level;return[`h${e?Zc(i,t):i}`,Qc({class:n(e=>e.heading[i-1]??``)}),0]},bulletList:()=>[`ul`,Qc({class:n(e=>e.bulletList)}),0],orderedList:e=>{let t=e.attrs.start;return[`ol`,Qc({class:n(e=>e.orderedList),start:t===1?null:String(t)}),0]},listItem:()=>[`li`,Qc({class:n(e=>e.listItem)}),0],blockquote:()=>[`blockquote`,Qc({class:n(e=>e.blockquote)}),0],codeBlock:e=>[`pre`,Qc({class:n(e=>e.codeBlock),"data-language":e.attrs.language}),[`code`,Qc({class:n(e=>e.codeBlockText)}),0]],entity:t=>{let r=t.attrs.kind,i=t.attrs.id,a=t.attrs.label;return[`span`,Qc({class:n(e=>e.entity),"data-entity-kind":r,"data-entity-id":i,[$c]:e?null:tl({kind:r,id:i,label:a}),contenteditable:`false`}),a]},unknown:t=>r=>[t,Qc({class:n(e=>e.unknown),contenteditable:e?`false`:null}),Xc(r.attrs.json)],bold:()=>[`strong`,Qc({class:n(e=>e.bold)}),0],italic:()=>[`em`,Qc({class:n(e=>e.italic)}),0],strike:()=>[`s`,Qc({class:n(e=>e.strike)}),0],code:()=>[`code`,Qc({class:n(e=>e.code)}),0],link:e=>[`a`,Qc({class:n(e=>e.link),href:e}),0]}}function _l(e,t,n){return[{style:e,clearMark:e=>e.type.name===t,getAttrs:e=>n(e)?null:!1}]}function vl(){return{tag:`a[href]`,getAttrs:e=>{let t=ge(e.getAttribute(`href`)??``);return t!==null&&{href:t}}}}function yl(){return[1,2,3,4,5,6].map(e=>({tag:`h${e}`,attrs:{level:Math.min(e,3)}}))}function bl(e){let t=new Set(e.formats),n=gl(e.classes,e.headingLevel),r=new Set(e.entities.map(e=>e.kind)),i={[X.doc]:{attrs:{fields:Q},content:`block+`},[X.paragraph]:{attrs:{fields:Q,wordList:{default:null}},content:`inline*`,group:`block`,parseDOM:[{tag:`p`,priority:60,getAttrs:e=>{let t=fl(e);return t?{wordList:t}:!1}},{tag:`p`},{tag:`span`,ignore:!0,getAttrs:e=>ll.test(dl(e))?null:!1},{tag:`tr`,getContent:(e,t)=>hl(e,t)}],toDOM:n.paragraph}};t.has(`heading`)&&(i[X.heading]={attrs:{level:{default:1,validate:`number`},fields:Q},content:`inline*`,group:`block`,marks:[Z.link,Z.code,Z.annotation,Z.unknown,Z.textFields].filter(e=>e!==Z.link&&e!==Z.code||t.has(e)).join(` `),defining:!0,parseDOM:yl(),toDOM:n.heading}),t.has(`blockquote`)&&(i[X.blockquote]={attrs:{fields:Q},content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM:n.blockquote}),t.has(`codeBlock`)&&(i[X.codeBlock]={attrs:{language:{default:``,validate:`string`},fields:Q},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,parseDOM:[{tag:`pre`,preserveWhitespace:`full`,getAttrs:e=>({language:ol(e)})},{tag:`div`,getAttrs:e=>ml(e)?{language:``}:!1,getContent:(e,t)=>{let n=(ml(e)??[]).join(`
9
+ `),o&&t==e.nodeValue.length)for(let t=e,i;t;t=t.parentNode){if(i=t.nextSibling){i.nodeName==`BR`&&(n=r={node:i.parentNode,offset:W(i)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];o=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}let s=i.domSel.readRange();if(Zi&&s.focusNode&&s.focusNode!=r.node&&K(s.focusNode)){let e=s.focusNode.childNodes[s.focusOffset];e&&e.contentEditable==`false`&&(a=!0)}!(a||o&&ta)&&Fi(n.node,n.offset,s.anchorNode,s.anchorOffset)&&Fi(r.node,r.offset,s.focusNode,s.focusOffset)||Wi(i.domSelection(),{focusNode:r.node,focusOffset:r.offset,anchorNode:n.node,anchorOffset:n.offset})}var ts=ta||$i&&ea<63;function ns(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(ta&&i&&i.contentEditable==`false`)return rs(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return rs(i);if(a)return rs(a)}}function rs(e){return e.contentEditable=`true`,ta&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function is(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function as(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSel.readRange(),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(()=>{(!Zo(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function ss(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom;n.nodeName==`IMG`?t.collapse(n.parentNode,W(n)+1):t.collapse(n,0)}function cs(e,t){if(t instanceof U){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ls(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ls(e)}function ls(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function us(e,t,n,r){let i=e.someProp(`createSelectionBetween`,r=>r(e,t,n))||H.between(t,n,r);return e.someProp(`adjustSelectionFromDOM`,t=>{i=t(e,i)}),i}function ds(e){if(e.editable&&!e.hasFocus())return null;let t=e.domSel.readRange();return t&&fs(e,t)?t:null}function fs(e,t){if(!t.anchorNode)return!1;try{return Ri(e.dom,t.anchorNode)&&(e.editable||Ri(e.dom,t.focusNode))}catch{return!1}}var ps={},J={},ms={touchstart:!0,touchmove:!0},hs=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,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 gs(e){for(let t in ps){let n=ps[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{xs(e,t)&&(e.input.composing&&(t.type==`keydown`||t.type==`beforeinput`)&&t.isComposing===!1&&Ws(e,!0),!bs(e,t)&&(e.editable||!(t.type in J))&&n(e,t))},ms[t]?{passive:!0}:void 0)}ta&&e.dom.addEventListener(`input`,()=>null),ys(e)}function _s(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function vs(e){e.input.mouseDown&&e.input.mouseDown.done(),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 ys(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>bs(e,t))})}function bs(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function xs(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 Ss(e,t){!bs(e,t)&&ps[t.type]&&(e.editable||!(t.type in J))&&ps[t.type](e,t)}function Cs(e,t){let{input:n}=e;return n.lastKeyDispatched||e.composing?!1:(n.lastKeyDispatched=!0,typeof t==`string`&&(t=Gi(t==`Backspace`?8:13,t)),e.someProp(`handleKeyDown`,n=>n(e,t)))}J.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),e.input.lastKeyDispatched=!1,!(aa&&$i&&n.keyCode==13)){if(na&&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&&(Cs(e,`Enter`),e.input.lastIOSEnter=0)},200);return}n.keyCode!=229&&e.domObserver.forceFlush(!0),Cs(e,n)||ko(e,n)?n.preventDefault():_s(e,`key`)}},J.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},J.keypress=(e,t)=>{let n=t;if(Vs(e)||!n.charCode||n.ctrlKey&&!n.altKey||ra&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof H)||!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 ws(e){return{left:e.clientX,top:e.clientY}}function Ts(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Es(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 Ds(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta(`pointer`,!0),e.dispatch(r)}function Os(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&U.isSelectable(r)?(Ds(e,new U(n)),!0):!1}function ks(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof U&&(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(U.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:(Ds(e,U.create(e.state.doc,i)),!0)}function As(e,t,n,r,i){return Es(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?ks(e,n):Os(e,n))}function js(e,t,n,r){return Es(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Ms(e,t,n,r){return Es(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))}function Ns(e,t,n){if(t==-1)return e.inlineContent?H.create(e,0,e.content.size):null;let r=e.resolve(t);for(let t=r.depth+1;t>0;t--){let i=t>r.depth?r.nodeAfter:r.node(t),a=r.before(t);if(i.inlineContent)return H.create(e,a+1,a+1+i.content.size);if(n&&U.isSelectable(i))return U.create(e,a)}return null}var Ps=/[\w_\u00a1-\uffff]+/g;try{Ps=RegExp(`[\\p{L}\\p{N}_]+`,`gu`)}catch{}function Fs(e,t){let n=e.resolve(t),r=n.node(),i=``,a=t,o=t;for(let e=n.indexAfter(),o=!1;e>0;e--){let s=r.child(e-1);if(!s.text)break;let c=a==t?t-n.posAtIndex(e-1):s.text.length,l=c;for(;l>0;l--)if(/\S/.test(s.text[l-1]))o=!0;else if(o)break;if(i=s.text.slice(l,c)+i,a-=c-l,l||a<t-50)break}for(let e=n.index(),a=!1;e<r.childCount;e++){let s=r.child(e);if(!s.text)break;let c=o==t?t-n.posAtIndex(e):0,l=c;for(;l<s.text.length;l++)if(/\S/.test(s.text[l]))a=!0;else if(a)break;if(i+=s.text.slice(c,l),o+=l-c,l<s.text.length||o>t+50)break}let s=a,c=o;if(Intl.Segmenter){for(let n of new Intl.Segmenter(void 0,{granularity:`word`}).segment(i))if(n.isWordLike){let r=n.index+a,i=r+n.segment.length;if(i<t)s=i;else if(r>t){c=r;break}else return H.create(e,r,i)}}else{Ps.lastIndex=0;for(let n;n=Ps.exec(i);){let r=n.index+a,i=r+n[0].length;if(i<t)s=i;else if(r>t){c=r;break}else return H.create(e,r,i)}}let l=i.slice(s-a,t-a),u=i.slice(t-a,c-a),d=/\S*$/.exec(l)[0].length,f=/^\S*/.exec(u)[0].length;if(d||f)return H.create(e,t-d,t+f);let p=/\s*$/.exec(l)[0].length,m=/^\s*/.exec(u)[0].length;return H.create(e,t-p,t+m)}var Is=ra?`metaKey`:`ctrlKey`;ps.mousedown=(e,t)=>{let n=t,r=Date.now();if(e.input.shiftKey=n.shiftKey,e.input.lastTouch>r-500)return!1;Js(e);let i=`singleClick`;r-e.input.lastClick.time<500&&Ts(n,e.input.lastClick)&&!n[Is]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?i=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(i=`tripleClick`)),e.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:i,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let a=e.posAtCoords(ws(n));if(a)if(n.button==0){if(!e.hasFocus()){_a(e.dom);let t=e.root.activeElement;t&&!t.contains(e.dom)&&t.blur()}(e.input.mouseDown=new Ls(e,a,n,i)).mightDrag||n.preventDefault()}else _s(e,`pointer`)};var Ls=class{constructor(e,t,n,r){this.view=e,this.startPos=t,this.event=n,this.type=r,this.didMove=!1,this.lastPos=-1,this.anchorRange=null,this.startDoc=e.state.doc,this.selectNode=!!n[Is],this.extend=n.shiftKey,this.anchorDoc=this.startDoc;let i=Rs(e);if(this.extend){let t=e.state.selection;this.anchorRange=t instanceof U?{from:t.from,to:t.to}:{from:t.anchor,to:t.anchor};let n=t instanceof U?e.nodeDOM(t.from).getBoundingClientRect():e.coordsAtPos(t.anchor);this.anchorOffset={x:(n.left+n.right)/2-i.x,y:(n.top+n.bottom)/2-i.y}}else this.anchorOffset={x:n.clientX-i.x,y:n.clientY-i.y};if(r==`singleClick`){let{selection:r}=e.state,i,a,o=!1;if(r instanceof U&&r.from<=t.pos&&r.to>=t.pos)a=r.from,i=r.node,o=!0;else 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():-1}if(o||a>-1&&i.type.spec.draggable&&i.type.spec.selectable!==!1){let t=e.docView.descAt(a)?.nodeDOM;this.mightDrag={node:i,elt:t,pos:a,addAttr:!1},t&&!t.draggable&&(this.mightDrag.addAttr=!0,e.domObserver.stopped(()=>t.draggable=!0))}else this.mightDrag=Bs(e,n)}else this.mightDrag=!1;e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this)),this.mightDrag||this.select(this.startPos,!0)}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null),typeof this.mightDrag==`object`&&this.mightDrag.addAttr&&this.view.domObserver.stopped(()=>this.mightDrag.elt.removeAttribute(`draggable`))}maybeRunHandler(e,t){return(this.type==`singleClick`?As:this.type==`doubleClick`?js:Ms)(this.view,e.pos,e.inside,t,this.selectNode)}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.startPos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ws(e))),t&&(this.didMove||this.maybeRunHandler(t,e)||this.select(t,!0),e.preventDefault())}move(e){if(e.buttons==0){this.done();return}if(!this.didMove&&(Math.abs(this.event.x-e.clientX)>8||Math.abs(this.event.y-e.clientY)>8)&&(this.didMove=!0,this.mightDrag=!1),!this.mightDrag){let t=this.view.posAtCoords(ws(e));t&&this.select(t,!1)}e.preventDefault()}select(e,t){if(e.pos==this.lastPos)return;this.lastPos=e.pos;let{view:n}=this,{doc:r}=n.state,i=this.type==`singleClick`?zs(n,r,e):this.type==`doubleClick`?Fs(r,e.pos):Ns(r,e.inside,t);i&&(t&&!this.extend?this.anchorRange=i:(!t||this.extend)&&(r.eq(this.anchorDoc)||this.restoreAnchor(),this.anchorRange&&this.anchorRange.from<i.from?i=us(n,r.resolve(this.anchorRange.from),r.resolve(i.to)):this.anchorRange&&this.anchorRange.to>i.to&&(i=us(n,r.resolve(this.anchorRange.to),r.resolve(i.from)))),i.eq(n.state.selection)||n.dispatch(n.state.tr.setSelection(i).setMeta(`pointer`,!0).scrollIntoView()))}restoreAnchor(){let e=Rs(this.view),t=this.view.posAtCoords({left:this.anchorOffset.x+e.x,top:this.anchorOffset.y+e.y});if(!t)this.anchorRange=null;else{let{doc:e}=this.view.state;this.anchorRange=this.type==`singleClick`?zs(this.view,e,t):this.type==`doubleClick`?Fs(e,t.pos):Ns(e,t.inside,!1),this.anchorDoc=this.view.state.doc}}};function Rs(e){let t=e.dom.getBoundingClientRect();return{x:t.left-e.dom.scrollLeft,y:t.top-e.dom.scrollTop}}function zs(e,t,n){if(n.inside>-1){let e=t.nodeAt(n.inside);if(e.isAtom&&U.isSelectable(e))return U.create(t,n.inside)}let r=t.resolve(n.pos);return us(e,r,r)}function Bs(e,t){let{selection:n}=e.state;if(n.empty)return!1;let r=e.domSelection();if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}ps.touchstart=e=>{e.input.lastTouch=Date.now(),Js(e),_s(e,`pointer`)},ps.touchmove=e=>{e.input.lastTouch=Date.now(),_s(e,`pointer`)},ps.contextmenu=e=>Js(e);function Vs(e,t){return e.composing?!0:ta&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Hs=aa?5e3:-1;J.compositionstart=J.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof H&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||$i&&ia&&Us(e)))e.markCursor=e.state.storedMarks||n.marks(),Js(e,!0),e.markCursor=null;else if(Js(e,!t.selection.empty),Zi&&e.domSel.active&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(let{focusNode:t,focusOffset:n}=e.domSel.range;t&&K(t)&&n!=0;){let r=n<0?t.lastChild:t.childNodes[n-1];if(!r)break;if(q(r)){let t=e.domSelection();t&&t.collapse(r,r.nodeValue.length);break}else t=r,n=-1}e.input.composing=!0}Gs(e,Hs)};function Us(e){let{focusNode:t,focusOffset:n}=e.domSel.range;if(!t||!K(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return K(r)&&r.contentEditable==`false`}J.compositionend=(e,t)=>{e.composing&&Ws(e)};function Ws(e,t=!1){e.input.composing=!1,e.input.compositionEndedAt=Date.now(),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++,t?Js(e):Gs(e,20)}function Gs(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Js(e),t))}function Ks(e){e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());for(let t;t=e.input.compositionNodes.pop();)t.markParentDamage()}function qs(e){let t=e.domSel.range;if(!e.domSel.active||!t.focusNode)return null;let n=zi(t.focusNode,t.focusOffset),r=Bi(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 Js(e,t=!1){if(!(aa&&e.domObserver.flushingSoon>=0)&&(e.domObserver.forceFlush(),Ks(e),t||e.docView&&e.docView.damage)){let n=Xo(e,e.domSel.readRange()),r=e.state.selection;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)}}function Ys(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 Xs=na&&sa<604;ps.copy=J.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Xs?null:n.clipboardData,{dom:o,text:s}=Ao(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Ys(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Zs(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Qs(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?$s(e,r.value,null,i,t):$s(e,r.textContent,r.innerHTML,i,t)},50)}function $s(e,t,n,r,i){let a=jo(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||N.empty)))return!0;if(!a)return!1;let o=Zs(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 ec(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,` `):``}J.paste=(e,t)=>{let n=t;if(e.composing&&!aa)return;let r=Xs?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&$s(e,ec(r),r.getData(`text/html`),i,n)?n.preventDefault():Qs(e,n)};var tc=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},nc=ra?`altKey`:`ctrlKey`;function rc(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[nc]:!n}ps.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(ws(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof U?i.to-1:i.to))){if(r&&typeof r.mightDrag==`object`)o=U.create(e.state.doc,r.mightDrag.pos);else if(n.target&&K(n.target)){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=U.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Ao(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!$i||ea>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Xs?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Xs||n.dataTransfer.setData(`text/plain`,c),e.dragging=new tc(l,rc(e,n),o)},ps.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},J.dragover=J.dragenter=(e,t)=>t.preventDefault(),J.drop=(e,t)=>{try{ic(e,t,e.dragging)}finally{e.dragging=null}};function ic(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(ws(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=jo(e,ec(t.dataTransfer),Xs?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&rc(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||N.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?gr(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&&U.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new U(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(us(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}ps.focus=e=>{if(e.input.lastFocus=Date.now(),!e.focused&&(e.domObserver.stopped(()=>e.dom.classList.add(`ProseMirror-focused`)),e.focused=!0,e.domSel.read(),!e.domSel.synced)){let t=e.domSel.range;setTimeout(()=>{let n=e.domSel.readRange();n&&t.eq(n)&&e.domSel.sync()},20)}},ps.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stopped(()=>e.dom.classList.remove(`ProseMirror-focused`)),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domSel.deactivate(),!1)},ps.beforeinput=(e,t)=>{if(aa&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||e.domObserver.pendingRecords().length||(e.dom.blur(),e.focus(),Cs(e,`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 J)ps[e]=J[e];function ac(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 oc=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}},sc=class e{constructor(e,t){this.toDOM=e,this.spec=t||fc,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 uc(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&&ac(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},cc=class e{constructor(e,t){this.attrs=e,this.spec=t||fc}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 uc(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&ac(this.attrs,t.attrs)&&ac(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},lc=class e{constructor(e,t){this.attrs=e,this.spec=t||fc}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 uc(i.pos-n,a.pos-n,this)}valid(e,t,n){let r=n.nodeAt(t.from);return!!r&&!r.isText&&t.from+r.nodeSize==t.to}eq(t){return this==t||t instanceof e&&ac(this.attrs,t.attrs)&&ac(this.spec,t.spec)}destroy(){}},uc=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 sc(n,r))}static inline(t,n,r,i){return new e(t,n,new cc(r,i))}static node(t,n,r,i){return new e(t,n,new lc(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof cc}get widget(){return this.type instanceof sc}},dc=[],fc={},pc=class e{constructor(e,t){this.local=e.length?e:dc,this.children=t.length?t:dc}static create(e,t){return t.length?bc(t,e,0,fc):Y}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];if(o.from>t)break;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&&!(this.children[a]>=t);a+=3)if(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==Y||e.maps.length==0?this:this.mapInner(e,t,0,0,n||fc)}mapInner(t,n,r,i,a){let o;if(this.local.length){let e=new oc(n.content);for(let s=0;s<this.local.length;s++){let c=this.local[s].map(t,r,i);c&&c.type.valid(n,c,e)?(o||=[]).push(c):a.onRemove&&a.onRemove(this.local[s].spec)}}return this.children.length?hc(this.children,o||[],t,n,r,i,a):o?new e(o.sort(xc),dc):Y}add(t,n){return n.length?this==Y?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=vc(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,bc(s,e,o+1,fc)),a+=3}});let o=gc(a?yc(n):n,-r).sort(xc);if(o.length){let e=new oc(t.content);for(let n=0;n<o.length;n++)o[n].type.valid(t,o[n],e)||o.splice(n--,1)}return new e(o.length?this.local.concat(o).sort(xc):this.local,i||this.children)}remove(e){return e.length==0||this==Y?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==Y?(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):Y}forChild(t,n){if(this==Y)return this;if(n.isLeaf)return e.empty;let r,i,a=0,o=this.children.length/3;for(;a<o;){let e=a+o>>>1,n=e*3,i=this.children[n];if(i<t)a=e+1;else if(i>t)o=e;else{r=this.children[n+2];break}}let s=t+1,c=s+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<c&&t.to>s&&t.type instanceof cc){let e=Math.max(s,t.from)-s,n=Math.min(c,t.to)-s;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(xc),dc);return r?new mc([t,r]):t}return r||Y}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 Sc(this.localsInner(e))}localsInner(e){if(this==Y)return dc;if(e.inlineContent||!this.local.some(cc.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof cc||t.push(this.local[e]);return t}forEachSet(e){e(this)}};pc.empty=new pc([],[]),pc.removeOverlap=Sc;var Y=pc.empty,mc=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,fc));return e.from(r)}forChild(t,n){if(n.isLeaf)return pc.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=Y&&(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?Sc(n?t:t.sort(xc)):dc}static from(t){switch(t.length){case 0:return Y;case 1:return t[0];default:return new e(t.every(e=>e instanceof pc)?t:t.reduce((e,t)=>e.concat(t instanceof pc?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function hc(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==Y?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=bc(_c(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 pc(t.sort(xc),s)}function gc(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 uc(i.from+t,i.to+t,i.type))}return n}function _c(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 vc(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 yc(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function bc(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=vc(e,t,o+n);if(s){a=!0;let e=bc(s,t,n+o+1,r);e!=Y&&i.push(o,o+t.nodeSize,e)}});let o=gc(a?yc(e):e,-n).sort(xc);if(o.length){let e=new oc(t.content);for(let n=0;n<o.length;n++)o[n].type.valid(t,o[n],e)||(r.onRemove&&r.onRemove(o[n].spec),o.splice(n--,1))}return o.length||i.length?new pc(o,i):Y}function xc(e,t){return e.from-t.from||e.to-t.to}function Sc(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),Cc(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),Cc(t,i,r.copy(a.from,r.to)));break}}}return t}function Cc(e,t,n){for(;t<e.length&&xc(n,e[t])>0;)t++;e.splice(t,0,n)}function wc(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=Y&&t.push(r)}),e.cursorWrapper&&t.push(pc.create(e.state.doc,[e.cursorWrapper.deco])),mc.from(t)}function Tc(e,t,n,r){let{node:i,fromOffset:a,toOffset:o,from:s,to:c}=e.docView.parseRange(t,n),l=e.domSel.range,u,d=l.anchorNode;if(d&&Ri(e.dom,d)&&(u=[{node:d,offset:l.anchorOffset}],Ui(l)||u.push({node:l.focusNode,offset:l.focusOffset})),$i&&e.input.lastKeyCode===8)for(let e=o;e>a;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){o=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||an.fromSchema(e.state.schema),m=f.resolve(s),h=null,g=p.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:a,to:o,preserveWhitespace:m.parent.type.whitespace!=`pre`||`full`,findPositions:u,ruleFromNode:Ec(r),context:m});if(u&&u[0].pos!=null){let e=u[0].pos,t=u[1]&&u[1].pos;t??=e,h={anchor:e+s,head:t+s}}return{doc:g,sel:h,from:s,to:c}}var Ec=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName==`BR`&&t.parentNode){if(ta&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(t.parentNode.lastChild==t||ta&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName==`IMG`&&t.getAttribute(`mark-placeholder`))return{ignore:!0};return null},Dc=/^(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 Oc(e,t,n,r,i,a){let o=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=Xo(e,e.domSel.range,t);if(n&&!e.state.selection.eq(n)&&e.domSel.active){if($i&&aa&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&Cs(e,`Enter`))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),o&&r.setMeta(`composition`,o),e.dispatch(r)}return}let s=e.state.doc.resolve(t),c=s.sharedDepth(n);t=s.before(c+1),n=e.state.doc.resolve(n).after(c+1);let l=e.state.selection,u=Tc(e,t,n,a),d=e.state.doc,f=d.slice(u.from,u.to),p,m;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(p=e.state.selection.to,m=`end`):(p=e.state.selection.from,m=`start`),e.input.lastKeyCode=null;let h=Pc(f.content,u.doc.content,u.from,p,m);if(h&&e.input.domChangeCount++,(na&&e.input.lastIOSEnter>Date.now()-225||aa)&&a.some(e=>K(e)&&!Dc.test(e.nodeName))&&(!h||h.endA>=h.endB)&&Cs(e,`Enter`)){e.input.lastIOSEnter=0;return}if(!h)if(i&&l instanceof H&&!l.empty&&l.$head.sameParent(l.$anchor)&&!e.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))h={start:l.from,endA:l.to,endB:l.to};else{if(u.sel){let t=kc(e,e.state.doc,u.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);o&&n.setMeta(`composition`,o),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&h.start==h.endB&&e.state.selection instanceof H&&(h.start>e.state.selection.from&&h.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?h.start=e.state.selection.from:h.endA<e.state.selection.to&&h.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(h.endB+=e.state.selection.to-h.endA,h.endA=e.state.selection.to));let g=u.doc.resolveNoCache(h.start-u.from),_=u.doc.resolveNoCache(h.endB-u.from),ee=d.resolve(h.start),v=g.sameParent(_)&&g.parent.inlineContent&&ee.end()>=h.endA;if((na&&e.input.lastIOSEnter>Date.now()-225&&(!v||a.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&Mc(u.doc,g.pos,_.pos))&&Cs(e,`Enter`)){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>h.start&&(v?h.endA>h.start&&h.endB==h.start:jc(d,h.start,h.endA,g,_))&&Cs(e,`Backspace`)){aa&&$i&&e.domSel.suppressChanges();return}$i&&h.endB==h.start&&(e.input.lastChromeDelete=Date.now()),aa&&!v&&g.start()!=_.start()&&_.parentOffset==0&&g.depth==_.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==h.endA&&(h.endB-=2,_=u.doc.resolveNoCache(h.endB-u.from),setTimeout(()=>Cs(e,`Enter`),20));let y=h.start,b=h.endA,x=t=>{let n=t||e.state.tr.replace(y,b,u.doc.slice(h.start-u.from,h.endB-u.from));if(u.sel){let t=kc(e,n.doc,u.sel);t&&!($i&&e.composing&&t.empty&&(h.start!=h.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1))&&n.setSelection(t)}return o&&n.setMeta(`composition`,o),n.scrollIntoView()},te;if(v)if(g.pos==_.pos){let t=x(e.state.tr.delete(y,b)),n=d.resolve(h.start).marksAcross(d.resolve(h.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(h.endA==h.endB&&(te=Ac(g.parent.content.cut(g.parentOffset,_.parentOffset),ee.parent.content.cut(ee.parentOffset,h.endA-ee.start())))){let t=x(e.state.tr);te.type==`add`?t.addMark(y,b,te.mark):t.removeMark(y,b,te.mark),e.dispatch(t)}else if(g.parent.child(g.index()).isText&&g.index()==_.index()-+!_.textOffset){let t=g.parent.textBetween(g.parentOffset,_.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function kc(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:us(e,t.resolve(n.anchor),t.resolve(n.head))}function Ac(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(A.from(l).eq(e))return{mark:s,type:o}}function jc(e,t,n,r,i){if(n-t<=i.pos-r.pos||Nc(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.inlineContent){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(Nc(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Nc(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Mc(e,t,n){let r=0,i=0;return e.nodesBetween(t,n,(e,a)=>{e.isTextblock&&a>=t&&a<n?r++:(e.isText?/\S/.test(e.text.slice(Math.max(0,t-a),Math.min(e.nodeSize,n-a))):e.isLeaf)&&i++}),i==0&&r==1}function Nc(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 Pc(e,t,n,r,i){let a=e.findDiffStart(t,n),o=n+e.size,s=n+t.size;if(a==null)return null;let{a:c,b:l}=e.findDiffEnd(t,o,s);if(i==`end`){let e=Math.max(0,a-Math.min(c,l));r-=c+e-a}if(c<a&&o<s){let e=r<=a&&r>=c?a-r:0;a-=e,l=a+(l-c),c=a}else if(l<a){let e=r<=a&&r>=l?a-r:0;a-=e,c=a+(c-l),l=a}return{start:a,endA:c,endB:l}}var Fc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ic=class{constructor(e){this.view=e,this.queue=[],this.flushingSoon=-1,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.started=!1,this.observer=new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);ta&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()})}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(e=!1){this.flushingSoon>-1?(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush(!0)):e&&this.flush(!0)}start(){this.observer.takeRecords(),this.observer.observe(this.view.dom,Fc),this.started=!0}stop(){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.started=!1}stopped(e){if(!this.started)return e();this.stop();try{return e()}finally{this.start()}}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=ji(n))t.add(n);for(let r=e.anchorNode;r;r=ji(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:q(n)?n.parentNode:n}))return this.view.domSel.ignore(e),!0}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(e=!0){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]),e&&t.domSel.read();let r=!t.domSel.suppress&&!t.domSel.synced&&!!ds(t)&&!this.ignoreSelectionChange(t.domSel.range),i=-1,a=-1,o=!1,s=[];if(t.editable)for(let e=0;e<n.length;e++){let t=this.registerMutation(n[e],s);t&&(i=i<0?t.from:Math.min(t.from,i),a=a<0?t.to:Math.max(t.to,a),t.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||$i&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&n.some(e=>e.type==`childList`&&e.removedNodes.length))){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&K(t);){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(Zi&&s.length){let e=s.filter(e=>e.nodeName==`BR`);if(e.length==2){let[t,n]=e;t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}else{let{focusNode:n}=t.domSel.range;for(let r of e){let e=r.parentNode;e&&e.nodeName==`LI`&&(!n||Bc(t,n)!=e)&&r.remove()}}}let c=null;i<0&&r&&t.domSel.active&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Ui(t.domSel.range)&&(c=Xo(t,t.domSel.range))&&c.eq(V.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,t.domSel.sync(),t.scrollToSelection()):(i>-1||r)&&(i>-1&&zc(t),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,Vc(t,s)),Oc(this.view,i,a,r,o,s),t.docView&&t.docView.damage?t.updateState(t.state):r&&t.domSel.sync())}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n;for(let t=e.target;t&&!(n=this.view.docView.getDesc(t));t=t.parentNode);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),q(r)&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return n.markDamage(4),{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling,a=r&&r.parentNode==e.target?W(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?W(i):e.target.childNodes.length,c=n.localPosFromDOM(e.target,s,1);return n.markDamage(n.contentDOM?.contains(e.target)?2:4),{from:o,to:c}}else if(e.type==`attributes`)return n.markDamage(4),{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,n.markDamage(n instanceof Ka&&e.target==n.nodeDOM?8:4),{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},Lc=new WeakMap,Rc=!1;function zc(e){if(!Lc.has(e)&&(Lc.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=Zi,Rc)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.`),Rc=!0}}function Bc(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 Vc(e,t){let{focusNode:n,focusOffset:r}=e.domSel.range;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||!K(e)||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)}}var Hc=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 hs,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Yc),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=Gc(this),Wc(this),this.nodeViews=qc(this),this.docView=Ga(this.state.doc,Uc(this),wc(this),this.dom,this),this.domObserver=new Ic(this),this.domSel=new qo(this),this.domObserver.start(),this.domSel.read(),gs(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&&ys(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Yc),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&&(Ks(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=qc(this);Jc(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&ys(this),this.editable=Gc(this),Wc(this);let o=wc(this),s=Uc(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&&fa(this);i&&this.domObserver.stopped(()=>{let t=l&&$i&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Kc(n.selection,e.selection);if(l){let n=$i?this.trackWrites=this.domSel.range.focusNode:null;if(this.composing&&(this.input.compositionNode=qs(this)),r||!this.docView.update(e.doc,s,o,this,-1)){let t=this.docView.outerDeco;this.docView.destroy(),this.docView=Ga(e.doc,s,o,this.dom,this,t)}n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}this.domSel.sync(t)}),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&&ma(u)}scrollToSelection(){let e=this.domSel.range.focusNode;if(!(!e||!this.domSel.active)&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof U){let t=this.docView.domAfterPos(this.state.selection.from);K(t)&&da(this,t.getBoundingClientRect(),e)}else da(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new tc(e.slice,e.move,r<0?void 0:U.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(){return this.root.activeElement==this.dom}focus(){this.editable&&_a(this.dom),this.domSel.sync()}get root(){let e=this.dom.isConnected!==!1;e||(this._root=null);let t=this._root;if(t==null&&e){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 t||document}updateRoot(){this._root=null}posAtCoords(e){return Ta(this,e)}coordsAtPos(e,t=1){return ka(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 za(this,t||this.state,e)}pasteHTML(e,t){return $s(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return $s(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Ao(this,e)}destroy(){this.docView&&(vs(this),this.domSel.destroy(),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],wc(this),this,-1),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Pi())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ss(this,e)}domSelection(){return this.root.getSelection()}};Hc.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Uc(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`,[uc.node(0,e.state.doc.content.size,t)]}function Wc(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:uc.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Gc(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Kc(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 qc(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 Jc(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 Yc(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`)}function Xc(e){return xe(e)}var X={doc:`doc`,paragraph:`paragraph`,heading:`heading`,bulletList:`bulletList`,orderedList:`orderedList`,listItem:`listItem`,blockquote:`blockquote`,codeBlock:`codeBlock`,text:`text`,hardBreak:`hardBreak`,entity:`entity`,unknownBlock:`unknownBlock`,unknownInline:`unknownInline`},Z={link:`link`,bold:`bold`,italic:`italic`,strike:`strike`,code:`code`,annotation:`annotation`,unknown:`unknown`,textFields:`textFields`},Q={default:null};function Zc(e,t){return Math.min(t+e-1,4)}function Qc(e){let t={};for(let[n,r]of Object.entries(e))r!=null&&r!==``&&(t[n]=r);return t}var $c=`data-entity-token`,el=new Map;function tl(e){let t=new Uint8Array(16);globalThis.crypto.getRandomValues(t);let n=Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``);for(el.set(n,e);el.size>500;){let e=el.keys().next().value;if(e===void 0)break;el.delete(e)}return n}function nl(e,t){let n=e===null?void 0:el.get(e);return n!==void 0&&n.kind===t.kind&&n.id===t.id&&n.label===t.label}var rl=`[A-Za-z0-9_+#.-]{1,32}`,il=RegExp(`^${rl}$`);function al(e){let t=(e??``).trim();return il.test(t)?t:``}function ol(e){let t=e.querySelector(`code`);for(let n of[e,t]){if(!n)continue;let e=al(n.getAttribute(`data-language`));if(e)return e;for(let e of Array.from(n.classList)){let t=/^(?:language|lang)-(.+)$/.exec(e),n=t?al(t[1]):``;if(n)return n}}return``}function sl(e){let t=e.trim().toLowerCase();return t===`bold`||t===`bolder`||/^\d+$/.test(t)&&Number(t)>=600}var cl=/mso-list:\s*l(\d+)\s+level(\d+)\s+lfo(\d+)/i,ll=/mso-list:\s*ignore/i,ul=/^\(?(\d+|[a-z]|[ivxlcdm]+)[.)]$/i,dl=e=>e.getAttribute(`style`)??``;function fl(e){let t=cl.exec(dl(e));if(!t)return null;let n=(Array.from(e.querySelectorAll(`span`)).find(e=>ll.test(dl(e)))?.textContent??``).replace(/\s+/g,``),r=ul.test(n),i=/^\(?(\d+)[.)]$/.exec(n),a=i?Number(i[1]):1;return{list:t[3],level:Number(t[2]),ordered:r,start:Number.isSafeInteger(a)?a:1}}var pl=/monospace|menlo|monaco|consolas|courier|mono\b|code\b/i;function ml(e){if(!/^pre(?:-wrap)?$/.test(e.style.whiteSpace)||!pl.test(e.style.fontFamily))return null;let t=Array.from(e.children),n=t.length>0&&t.every(e=>e.tagName===`DIV`||e.tagName===`BR`)?t.map(e=>e.tagName===`BR`?``:e.textContent??``):(e.textContent??``).split(/\r\n?|\n/);return n.length>1?n:null}function hl(e,t){let n=an.fromSchema(t),r=[];return Array.from(e.children).filter(e=>/^T[DH]$/.test(e.tagName)).forEach((e,i)=>{i>0&&r.push(t.text(` `));let a=e.ownerDocument.createElement(`div`);a.append(e.cloneNode(!0));let o=!1,s=e=>e.forEach(e=>{e.isInline?(o&&r.length>0&&r.push(t.text(` `)),o=!1,r.push(e)):(o=!0,s(e.content),o=!0)});s(n.parseSlice(a).content)}),r.every(e=>e.isText&&/^\s*$/.test(e.text??``))?A.empty:A.from(r)}function gl(e,t){let n=t=>e?t(e):void 0;return{paragraph:()=>[`p`,Qc({class:n(e=>e.paragraph)}),0],heading:r=>{let i=r.attrs.level;return[`h${e?Zc(i,t):i}`,Qc({class:n(e=>e.heading[i-1]??``)}),0]},bulletList:()=>[`ul`,Qc({class:n(e=>e.bulletList)}),0],orderedList:e=>{let t=e.attrs.start;return[`ol`,Qc({class:n(e=>e.orderedList),start:t===1?null:String(t)}),0]},listItem:()=>[`li`,Qc({class:n(e=>e.listItem)}),0],blockquote:()=>[`blockquote`,Qc({class:n(e=>e.blockquote)}),0],codeBlock:e=>[`pre`,Qc({class:n(e=>e.codeBlock),"data-language":e.attrs.language}),[`code`,Qc({class:n(e=>e.codeBlockText)}),0]],entity:t=>{let r=t.attrs.kind,i=t.attrs.id,a=t.attrs.label;return[`span`,Qc({class:n(e=>e.entity),"data-entity-kind":r,"data-entity-id":i,[$c]:e?null:tl({kind:r,id:i,label:a}),contenteditable:`false`}),a]},unknown:t=>r=>[t,Qc({class:n(e=>e.unknown),contenteditable:e?`false`:null}),Xc(r.attrs.json)],bold:()=>[`strong`,Qc({class:n(e=>e.bold)}),0],italic:()=>[`em`,Qc({class:n(e=>e.italic)}),0],strike:()=>[`s`,Qc({class:n(e=>e.strike)}),0],code:()=>[`code`,Qc({class:n(e=>e.code)}),0],link:t=>[`a`,Qc({class:n(e=>e.link),href:t,tabindex:e?`-1`:null}),0]}}function _l(e,t,n){return[{style:e,clearMark:e=>e.type.name===t,getAttrs:e=>n(e)?null:!1}]}function vl(){return{tag:`a[href]`,getAttrs:e=>{let t=ge(e.getAttribute(`href`)??``);return t!==null&&{href:t}}}}function yl(){return[1,2,3,4,5,6].map(e=>({tag:`h${e}`,attrs:{level:Math.min(e,3)}}))}function bl(e){let t=new Set(e.formats),n=gl(e.classes,e.headingLevel),r=new Set(e.entities.map(e=>e.kind)),i={[X.doc]:{attrs:{fields:Q},content:`block+`},[X.paragraph]:{attrs:{fields:Q,wordList:{default:null}},content:`inline*`,group:`block`,parseDOM:[{tag:`p`,priority:60,getAttrs:e=>{let t=fl(e);return t?{wordList:t}:!1}},{tag:`p`},{tag:`span`,ignore:!0,getAttrs:e=>ll.test(dl(e))?null:!1},{tag:`tr`,getContent:(e,t)=>hl(e,t)}],toDOM:n.paragraph}};t.has(`heading`)&&(i[X.heading]={attrs:{level:{default:1,validate:`number`},fields:Q},content:`inline*`,group:`block`,marks:[Z.link,Z.code,Z.annotation,Z.unknown,Z.textFields].filter(e=>e!==Z.link&&e!==Z.code||t.has(e)).join(` `),defining:!0,parseDOM:yl(),toDOM:n.heading}),t.has(`blockquote`)&&(i[X.blockquote]={attrs:{fields:Q},content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM:n.blockquote}),t.has(`codeBlock`)&&(i[X.codeBlock]={attrs:{language:{default:``,validate:`string`},fields:Q},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,parseDOM:[{tag:`pre`,preserveWhitespace:`full`,getAttrs:e=>({language:ol(e)})},{tag:`div`,getAttrs:e=>ml(e)?{language:``}:!1,getContent:(e,t)=>{let n=(ml(e)??[]).join(`
10
10
  `);return n===``?A.empty:A.from(t.text(n))}}],toDOM:n.codeBlock});let a=t.has(`bulletList`)||t.has(`orderedList`);t.has(`bulletList`)&&(i[X.bulletList]={attrs:{fields:Q},content:`${X.listItem}+`,group:`block`,parseDOM:[{tag:`ul`}],toDOM:n.bulletList}),t.has(`orderedList`)&&(i[X.orderedList]={attrs:{start:{default:1,validate:`number`},fields:Q},content:`${X.listItem}+`,group:`block`,parseDOM:[{tag:`ol`,getAttrs:e=>{let t=e.getAttribute(`start`)?.trim()??``,n=t===``?1:Number(t);return{start:Number.isSafeInteger(n)&&n>=0?n:1}}}],toDOM:n.orderedList}),a&&(i[X.listItem]={attrs:{fields:Q},content:`${X.paragraph} block*`,defining:!0,parseDOM:[{tag:`li`}],toDOM:n.listItem}),i[X.unknownBlock]={attrs:{json:{}},group:`block`,atom:!0,selectable:!0,toDOM:n.unknown(`div`)},i[X.text]={group:`inline`},i[X.hardBreak]={attrs:{fields:Q},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,leafText:()=>`
11
11
  `,parseDOM:[{tag:`br`}],toDOM:()=>[`br`]},i[X.entity]={attrs:{kind:{validate:`string`},id:{validate:`string`},label:{validate:`string`},fields:Q},inline:!0,group:`inline`,atom:!0,selectable:!0,draggable:!1,leafText:e=>e.attrs.label,parseDOM:[{tag:`span[data-entity-kind][data-entity-id][${$c}]`,getAttrs:e=>{let t={kind:e.getAttribute(`data-entity-kind`)??``,id:e.getAttribute(`data-entity-id`)??``,label:e.textContent??``};return!nl(e.getAttribute(`data-entity-token`),t)||!r.has(t.kind)||t.kind===``||t.id===``||t.label===``?!1:t}}],toDOM:n.entity},i[X.unknownInline]={attrs:{json:{}},inline:!0,group:`inline`,atom:!0,selectable:!0,leafText:e=>Xc(e.attrs.json),toDOM:n.unknown(`span`)};let o={};if(t.has(`link`)&&(o[Z.link]={attrs:{href:{validate:`string`},fields:Q},inclusive:!1,parseDOM:[vl()],toDOM:e=>n.link(e.attrs.href)}),t.has(`bold`)&&(o[Z.bold]={attrs:{fields:Q},parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight&&!sl(e.style.fontWeight)?!1:null},{style:`font-weight`,getAttrs:e=>sl(e)?null:!1},..._l(`font-weight`,Z.bold,e=>!sl(e))],toDOM:n.bold}),t.has(`italic`)&&(o[Z.italic]={attrs:{fields:Q},parseDOM:[{tag:`em`},{tag:`i`},{style:`font-style`,getAttrs:e=>/^(italic|oblique)/i.test(e)?null:!1},..._l(`font-style`,Z.italic,e=>/^normal$/i.test(e))],toDOM:n.italic}),t.has(`strike`)){let e=e=>/line-through/i.test(e)?null:!1;o[Z.strike]={attrs:{fields:Q},parseDOM:[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,getAttrs:e},{style:`text-decoration-line`,getAttrs:e}],toDOM:n.strike}}return t.has(`code`)&&(o[Z.code]={attrs:{fields:Q},excludes:[Z.code,Z.bold,Z.italic,Z.strike].filter(e=>e===Z.code||t.has(e)).join(` `),inclusive:!1,code:!0,parseDOM:[{tag:`code`}],toDOM:n.code}),o[Z.annotation]={attrs:{id:{validate:`string`},fields:Q},inclusive:!1,excludes:``,toDOM:()=>[`span`,0]},o[Z.unknown]={attrs:{json:{}},excludes:``,toDOM:()=>[`span`,0]},o[Z.textFields]={attrs:{fields:{}},toDOM:()=>[`span`,0]},new en({nodes:i,marks:o})}function xl(e){let t=gl(null,1),n={},r={},i={[X.paragraph]:t.paragraph,[X.heading]:t.heading,[X.bulletList]:t.bulletList,[X.orderedList]:t.orderedList,[X.listItem]:t.listItem,[X.blockquote]:t.blockquote,[X.codeBlock]:t.codeBlock,[X.hardBreak]:()=>[`br`],[X.entity]:t.entity,[X.unknownBlock]:e=>[`p`,Xc(e.attrs.json)],[X.unknownInline]:e=>[`span`,Xc(e.attrs.json)]};for(let t of Object.keys(e.nodes)){let e=i[t];e&&(n[t]=e)}let a={[Z.link]:e=>t.link(e.attrs.href),[Z.bold]:t.bold,[Z.italic]:t.italic,[Z.strike]:t.strike,[Z.code]:t.code,[Z.unknown]:()=>[`span`,0],[Z.textFields]:()=>[`span`,0]};for(let t of Object.keys(e.marks)){let e=a[t];e&&(r[t]=e)}return new vn(n,r)}var Sl=e=>e.marks[Z.annotation],Cl=e=>e.isText||e.type.name===X.entity,wl=(e,t)=>e<t?-1:+(e>t);function Tl(e,t){let n=new Set;for(let r of e.marks)r.type===t&&n.add(r.attrs.id);return n}var El={type:`break`};function Dl(e){switch(e.type.name){case X.hardBreak:return we(El);case X.entity:return we({type:`entity`,label:e.attrs.label});case X.unknownInline:case X.unknownBlock:return we(e.attrs.json);default:return``}}function Ol(e){let{doc:t,selection:n}=e,r=t.textBetween(0,n.from,``,Dl),i=ke(r);return n.empty?{start:i,end:i}:{start:i,end:ke(r+t.textBetween(n.from,n.to,``,Dl))}}function kl(e,t,n,r){let i=e.resolve(t),a=t;if(i.parent.inlineContent){let e=i.parent;if(e.type.allowsMarkType(n)){let t=i.textOffset>0;if(r)for(let t=i.index();t<e.childCount;t+=1){let n=e.child(t);if(Cl(n))return n}else for(let n=t?i.index():i.index()-1;n>=0;--n){let t=e.child(n);if(Cl(t))return t}}a=r?i.end():i.start()}let o=null,s=(e,t,i)=>r&&o?!1:e.isInline?((r?t>=a:t+e.nodeSize<=a)&&Cl(e)&&i?.type.allowsMarkType(n)&&(o=e),!1):!0;return r?e.nodesBetween(a,e.content.size,s):e.nodesBetween(0,a,s),o}function Al(e,t,n=t){let r=Sl(e.type.schema),i=e.resolve(t).parent;if(!i.inlineContent||!i.type.allowsMarkType(r))return[];let a=kl(e,n,r,!0),o=a?a.marks.filter(e=>e.type===r):[];if(o.length===0)return[];let s=kl(e,t,r,!1);if(!s)return[];let c=Tl(s,r);return o.filter(e=>c.has(e.attrs.id))}function jl(e,t){let n=e.filter(e=>e.type.name!==Z.annotation);for(let e of t)n=e.addToSet(n);return n}function Ml(e,t,n,r){if(t>=n)return!1;let i=Sl(e.doc.type.schema),a=new Set(r.map(e=>e.attrs.id)),o=!1;if(e.doc.nodesBetween(t,n,(e,t,n)=>{if(o||!e.isInline)return!o;if(!Cl(e)||!n?.type.allowsMarkType(i))return o=i.isInSet(e.marks)!==void 0,!1;let r=Tl(e,i);return o=r.size!==a.size||[...r].some(e=>!a.has(e)),!1}),!o)return!1;e.removeMark(t,n,i);for(let i of r)e.addMark(t,n,i);return!0}function Nl(e){let t=1/0,n=-1/0;return e.mapping.maps.forEach((r,i)=>{let a=e.mapping.slice(i+1);r.forEach((e,r,i,o)=>{o<=i||(t=Math.min(t,a.map(i,-1)),n=Math.max(n,a.map(o,1)))})}),t<n?{from:t,to:n}:null}function Pl(e,t,n){let r=new Map;if(!e.type.allowsMarkType(n))return r;let i=new Map;return e.forEach((e,a)=>{if(!Cl(e))return;let o=t+a,s=o+e.nodeSize,c=Tl(e,n);for(let e of i.keys())c.has(e)||i.delete(e);for(let e of c){let t=i.get(e);if(t)t.to=s;else{let t={from:o,to:s};i.set(e,t);let n=r.get(e);n?n.push(t):r.set(e,[t])}}}),r}function Fl(e){return[...e.keys()].sort((t,n)=>{let r=e.get(t),i=e.get(n);return i.from-r.from||r.to-i.to||wl(t,n)})}function Il(e){let t=Sl(e.schema),{selection:n,doc:r}=e,i=new Map;if(n.empty){let e=Al(r,n.from);if(e.length<2)return e.map(e=>e.attrs.id);let a=n.$from,o=Pl(a.parent,a.start(),t),s=n.from;for(let t of e){let e=t.attrs.id,n=o.get(e)??[];i.set(e,n.find(e=>e.from<=s&&s<=e.to)??n.find(e=>e.from>=s)??n.at(-1)??{from:s,to:s})}return Fl(i)}return r.nodesBetween(n.from,n.to,(e,r)=>{if(!e.isTextblock)return!0;let a=Pl(e,r+1,t);return a.size===0||e.forEach((e,o)=>{let s=r+1+o;if(!(!Cl(e)||s+e.nodeSize<=n.from||s>=n.to))for(let n of Tl(e,t)){if(i.has(n))continue;let e=a.get(n)?.find(e=>e.from<=s&&s<e.to);e&&i.set(n,e)}}),!1}),Fl(i)}function Ll(e,t,n,r,i){let a=Pl(e,t,n);if(a.size===0)return[];let o=[];return e.forEach((e,s)=>{if(!Cl(e))return;let c=t+s,l=new Map;for(let t of Tl(e,n)){if(i!==null&&!i.has(t))continue;let e=a.get(t)?.find(e=>e.from<=c&&c<e.to);e&&l.set(t,e)}for(let t of Fl(l)){let n={nodeName:`mark`,"data-annotation-id":t};r.className&&(n.class=r.className),t===r.active&&(n[`data-active`]=``),o.push(uc.inline(c,c+e.nodeSize,n))}}),o}var Rl=e=>e.drawn===void 0?null:new Set(e.drawn);function zl(e,t){let n=Rl(t);if(n!==null&&n.size===0)return pc.empty;let r=Sl(e.type.schema),i=[];return e.descendants((e,a)=>e.isTextblock?(i.push(...Ll(e,a+1,r,t,n)),!1):!0),i.length>0?pc.create(e,i):pc.empty}function Bl(e,t){let n=[];return e.steps.forEach((r,i)=>{let a=e.mapping.slice(i+1),o=(e,t)=>n.push({from:a.map(e,-1),to:a.map(t,1)});r instanceof zn||r instanceof Bn?r.mark.type===t&&o(r.from,r.to):r instanceof Un||r instanceof Wn?r.mark.type===t&&o(r.pos,r.pos+1):r instanceof Nr||r instanceof Pr||(r instanceof Gn||r instanceof B?r.getMap().forEach((e,t,n,r)=>o(n,r)):o(0,e.docs[i+1]?.content.size??e.doc.content.size))}),n}function Vl(e,t,n,r){let i=Rl(r),a=Sl(t.type.schema),o=new Map,s=t.content.size;for(let e of n){let n=Math.max(0,Math.min(e.from,e.to)-1),r=Math.min(s,Math.max(e.from,e.to)+1);t.nodesBetween(n,r,(e,t)=>e.isTextblock?(o.set(t,e),!1):!0)}if(o.size===0)return e;let c=[],l=[];for(let[t,n]of o){let o=t+1;c.push(...e.find(o,o+n.content.size)),(i===null||i.size>0)&&l.push(...Ll(n,o,a,r,i))}return e.remove(c).add(t,l)}function Hl(e){let t=new oi(`polymorphRichTextAnnotations`),n=null,r=(e,t)=>((n?.doc!==e||n.drawing!==t)&&(n={doc:e,drawing:t,set:zl(e,t)}),n);return new ri({key:t,state:{init:(t,n)=>{let r=e();return{drawing:r,set:zl(n.doc,r)}},apply:(t,n,i,a)=>{let o=e(),s=n.drawing===o?n:r(i.doc,o);if(!t.docChanged)return s===n?n:{drawing:o,set:s.set};let c=Sl(a.schema);return{drawing:o,set:Vl(s.set.map(t.mapping,a.doc),a.doc,Bl(t,c),o)}}},props:{decorations:n=>{let i=t.getState(n);if(!i)return null;let a=e();return i.drawing===a?i.set:r(n.doc,a).set},handleTextInput:(e,t,n,r,i)=>{if(e.composing)return!1;let a=Al(e.state.doc,t,n),o=i();return Ml(o,o.mapping.map(t,-1),o.mapping.map(n,1),a),e.dispatch(o),!0}}})}function Ul(e){return(t,n)=>{let r=Sl(t.schema),{selection:i,doc:a}=t;if(i.empty||typeof e!=`string`||e===``)return!1;let o=[],s=!1;if(a.nodesBetween(i.from,i.to,(t,n,a)=>Cl(t)?a?.type.allowsMarkType(r)?(s=!0,t.marks.some(t=>t.type===r&&t.attrs.id===e)||o.push({from:Math.max(n,i.from),to:Math.min(n+t.nodeSize,i.to)}),!1):!1:!0),!s)return!1;if(n&&o.length>0){let i=t.tr,a=r.create({id:e});for(let{from:e,to:t}of o)i.addMark(e,t,a);n(Si(i))}return!0}}function Wl(e){return(t,n)=>{let r=Sl(t.schema),i=[],a=!1;if(t.doc.descendants(t=>{for(let n of t.marks)n.type!==r||n.attrs.id!==e||(Cl(t)&&(a=!0),n.isInSet(i)||i.push(n));return!0}),!a)return!1;if(n){let e=t.tr;for(let n of i)e.removeMark(0,t.doc.content.size,n);n(Si(e))}return!0}}function Gl(e,t){let n=!1,r=[];return e.forEach(e=>{let i=e;if(e.isInline)t.isInSet(e.marks)&&(i=e.mark(t.removeFromSet(e.marks)));else if(e.content.size>0){let n=Gl(e.content,t);n!==e.content&&(i=e.copy(n))}i!==e&&(n=!0),r.push(i)}),n?A.fromArray(r):e}function Kl(e,t){let n=Gl(e.content,Sl(t));return n===e.content?e:new N(n,e.openStart,e.openEnd)}function ql(e,t){t.descendants((t,n)=>{if(!t.isInline)return!0;let r=n+t.nodeSize;return e.doc.nodesBetween(n,r,(i,a)=>{if(!i.isInline)return!0;if(M.sameSet(i.marks,t.marks))return!1;let o=Math.max(n,a),s=Math.min(r,a+i.nodeSize);e.removeMark(o,s,null);for(let n of t.marks)e.addMark(o,s,n);return!1}),!1})}function Jl(e){if(e.isLeaf)return e.marks.length>0?e.mark(M.none):e;let t=[];return e.forEach(e=>t.push(Jl(e))),e.copy(A.fromArray(t)).mark(M.none)}var Yl=(e,t)=>Jl(e).eq(Jl(t));function Xl(e){let{from:t,to:n,empty:r}=e.state.selection;if(r)return null;let i=e.dom.ownerDocument,a={top:1/0,bottom:-1/0,left:1/0,right:-1/0},o=e=>{a.top=Math.min(a.top,e.top),a.bottom=Math.max(a.bottom,e.bottom),a.left=Math.min(a.left,e.left),a.right=Math.max(a.right,e.right)};try{let r=e.domAtPos(t),s=e.domAtPos(n),c=i.createRange();c.setStart(r.node,r.offset),c.setEnd(s.node,s.offset);let l=c.commonAncestorContainer,u=[];if(l.nodeType===l.TEXT_NODE)u.push(l);else{let e=i.createTreeWalker(l,NodeFilter.SHOW_TEXT);for(let t=e.nextNode();t;t=e.nextNode())c.intersectsNode(t)&&u.push(t)}let d=i.createRange();for(let e of u){d.setStart(e,e===c.startContainer?c.startOffset:0),d.setEnd(e,e===c.endContainer?c.endOffset:e.length);for(let e of Array.from(d.getClientRects()))e.width>0&&o(e)}a.top===1/0&&(o(e.coordsAtPos(t,1)),o(e.coordsAtPos(n,-1)))}catch{return{top:0,bottom:0,left:0,right:0}}return a}var Zl=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Ql(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var $l=(e,t,n)=>{let r=Ql(e,n);if(!r)return!1;let i=nu(r);if(!i){let n=r.blockRange(),i=n&&Zn(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(gu(e,i,t,-1))return!0;if(r.parent.content.size==0&&(eu(a,`end`)||U.isSelectable(a)))for(let n=r.depth;;n--){let o=_r(e.doc,r.before(n),r.after(n),N.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(eu(a,`end`)?V.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):U.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 eu(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 tu=(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=nu(r)}let o=a&&a.nodeBefore;return!o||!U.isSelectable(o)?!1:(t&&t(e.tr.setSelection(U.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function nu(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 ru(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var iu=(e,t,n)=>{let r=ru(e,n);if(!r)return!1;let i=ou(r);if(!i)return!1;let a=i.nodeAfter;if(gu(e,i,t,1))return!0;if(r.parent.content.size==0&&(eu(a,`start`)||U.isSelectable(a))){let n=_r(e.doc,r.before(),r.after(),N.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(eu(a,`start`)?V.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):U.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},au=(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=ou(r)}let o=a&&a.nodeAfter;return!o||!U.isSelectable(o)?!1:(t&&t(e.tr.setSelection(U.create(e.doc,a.pos)).scrollIntoView()),!0)};function ou(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 su=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
12
12
  `).scrollIntoView()),!0)};function cu(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 lu=(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=cu(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(V.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},uu=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof Ur||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=cu(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(H.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},du=(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(lr(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Zn(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function fu(e){return(t,n)=>{if(t.selection instanceof U&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!lr(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof H||t.selection instanceof Ur)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=cu(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=lr(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,lr(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var pu=fu(),mu=(e,t)=>(t&&t(e.tr.setSelection(new Ur(e.doc))),!0);function hu(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||dr(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function gu(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&hu(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=A.empty;for(let e=o.length-1;e>=0;e--)s=A.from(o[e].create(null,s));s=A.from(i.copy(s));let c=e.tr.step(new B(t.pos-1,r,t.pos,r,new N(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&dr(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:V.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&Zn(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&eu(a,`start`,!0)&&eu(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=A.empty;for(let e=o.length-1;e>=0;e--)r=A.from(o[e].copy(r));n(e.tr.step(new B(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new N(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function _u(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(H.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var vu=_u(-1),yu=_u(1);function bu(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&$n(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function xu(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function Su(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:a,$to:o}=t[i],s=a.depth==0&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(a.pos,o.pos,(e,t)=>{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function Cu(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 Rr(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new Rr(r,i))}return t}function wu(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||!Su(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=Cu(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 Tu(...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 Eu=Tu(Zl,$l,tu),Du=Tu(Zl,iu,au),Ou={Enter:Tu(su,uu,du,pu),"Mod-Enter":lu,Backspace:Eu,"Mod-Backspace":Eu,"Shift-Backspace":Eu,Delete:Du,"Mod-Delete":Du,"Mod-a":mu},ku={"Ctrl-h":Ou.Backspace,"Alt-Backspace":Ou[`Mod-Backspace`],"Ctrl-d":Ou.Delete,"Ctrl-Alt-Backspace":Ou[`Mod-Delete`],"Alt-Delete":Ou[`Mod-Delete`],"Alt-d":Ou[`Mod-Delete`],"Ctrl-a":vu,"Ctrl-e":yu};for(let e in Ou)ku[e]=Ou[e];var Au=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?ku:Ou,ju=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?Mu(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function Mu(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 Nu=500;function Pu({rules:e}){let t=new ri({state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return Fu(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&Fu(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function Fu(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t),c=e.state.selection,l=s.parent.textBetween(Math.max(0,s.parentOffset-Nu),s.parentOffset,null,``)+r,u=t==c.from&&n==c.to&&e.state.storedMarks||(t==n?s.marks():s.marksAcross(o.doc.resolve(n))||[]);for(let c=0;c<i.length;c++){let d=i[c];if(!d.inCodeMark&&u.some(e=>e.type.spec.code))continue;if(s.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode===`only`)continue;let f=d.match.exec(l);if(!f||f[0].length<r.length)continue;let p=t-(f[0].length-r.length);if(!d.inCodeMark){let e=!1;if(o.doc.nodesBetween(p,s.pos,t=>{t.isInline&&t.marks.some(e=>e.type.spec.code)&&(e=!0)}),e)continue}let m=d.handler(o,f,p,n,r);if(m)return d.undoable&&m.setMeta(a,{transform:m,from:t,to:n,text:r}),e.dispatch(m),!0}return!1}var Iu=(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 ju(/--$/,`—`,{inCodeMark:!1}),new ju(/\.\.\.$/,`…`,{inCodeMark:!1}),new ju(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new ju(/"$/,`”`,{inCodeMark:!1}),new ju(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new ju(/'$/,`’`,{inCodeMark:!1});function Lu(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let s=r?n.tr:null;return Ru(s,o,e,t)?(r&&r(s.scrollIntoView()),!0):!1}}function Ru(e,t,n,r=null){let i=!1,a=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new Dt(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new Dt(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let s=$n(a,n,r,t);return s?(e&&zu(e,t,s,i,n),!0):!1}function zu(e,t,n,r,i){let a=A.empty;for(let e=n.length-1;e>=0;e--)a=A.from(n[e].type.create(n[e].attrs,a));e.step(new B(t.start-(r?2:0),t.end,t.start,t.end,new N(a,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let s=n.length-o,c=t.start+n.length-(r?2:0),l=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&s&&lr(e.doc,c,s)&&(e.split(c,s),c+=2*s),c+=l.child(n).nodeSize;return e}function Bu(e,t){return e instanceof Xt?t==e:e.indexOf(t)>-1}function Vu(e,t){return function(n,r){let{$from:i,$to:a,node:o}=n.selection;if(o&&o.isBlock||i.depth<2||!i.sameParent(a))return!1;let s=i.node(-1);if(!Bu(e,s.type))return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||!Bu(e,i.node(-3).type)||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let e=A.empty,t=i.index(-1)?1:i.index(-2)?2:3;for(let n=i.depth-t;n>=i.depth-3;n--)e=A.from(i.node(n).copy(e));let a=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;e=e.append(A.from(i.node(-3).type.createAndFill()));let o=i.before(i.depth-(t-1)),s=n.tr.replace(o,i.after(-a),new N(e,4-t,0)),c=-1;s.doc.nodesBetween(o,s.doc.content.size,(e,t)=>{if(c>-1)return!1;e.isTextblock&&e.content.size==0&&(c=t+1)}),c>-1&&s.setSelection(V.near(s.doc.resolve(c))),r(s.scrollIntoView())}return!0}let c=a.pos==i.end()?s.contentMatchAt(0).defaultType:null,l=n.tr.delete(i.pos,a.pos),u=c||t?[t?{type:s.type,attrs:t}:null,c?{type:c}:null]:void 0;return lr(l.doc,i.pos,2,u)?(r&&r(l.split(i.pos,2,u).scrollIntoView()),!0):!1}}function Hu(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&Bu(e,t.firstChild.type));return a?n?Bu(e,r.node(a.depth-1).type)?Uu(t,n,a):Wu(t,n,a):!0:!1}}function Uu(e,t,n){let r=e.tr,i=n.end,a=n.$to.end(n.depth),o=n.parent.child(n.endIndex-1).type;i<a&&(r.step(new B(i-1,a,i,a,new N(A.from(o.create(null,n.parent.copy())),1,0),1,!0)),n=new Dt(r.doc.resolve(n.$from.pos),r.doc.resolve(a),n.depth));let s=Zn(n);if(s==null)return!1;r.lift(n,s);let c=r.doc.resolve(r.mapping.map(i,-1)-1);return dr(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos),t(r.scrollIntoView()),!0}function Wu(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?A.empty:A.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new B(d-+!!s,f+ +!!c,d+1,f-1,new N((s?A.empty:A.from(i.copy(A.empty))).append(c?A.empty:A.from(i.copy(A.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function Gu(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&Bu(e,t.firstChild.type));if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(!Bu(e,c.type))return!1;if(n){let e=c.lastChild&&c.lastChild.type==s.type,r=A.from(e?c.lastChild.lastChild.type.create():null),i=new N(A.from(c.type.create(null,A.from(s.type.create(null,r)))),e?3:1,0),o=a.start,l=a.end;n(t.tr.step(new B(o-(e?3:1),l,o,l,i,1,!0)).scrollIntoView())}return!0}}var Ku=`polymorphRichTextEvent`;function qu(e,t){return(n,r,i)=>e(n,r&&(e=>r(e.setMeta(`polymorphRichTextEvent`,t))),i)}function Ju(e){let t=0;return e.forEach(e=>{if(e.isTextblock||e.isAtom)return;let n=e.type.name===X.listItem?0:1;t=Math.max(t,n+Ju(e))}),t}function Yu(e){return(t,n,r)=>{let i=[];if(!e(t,e=>i.push(e),r))return!1;let a=i[0];return!a||Ju(a.doc)>8?!1:(n?.(a),!0)}}function Xu(e,t){if(!t)return!1;let{from:n,to:r,empty:i}=e.selection;if(i)return!!t.isInSet(e.storedMarks??e.selection.$from.marks());let a=!1,o=!1;return e.doc.nodesBetween(n,r,e=>{e.isText&&(t.isInSet(e.marks)?a=!0:o=!0)}),a&&!o}function Zu(e,t,n,r){let i=!1;return e.nodesBetween(t,n,(e,a,o)=>{if(i)return!1;if(!e.isText||!o?.type.allowsMarkType(r)||r.isInSet(e.marks))return!0;let s=e.text??``;return i=!/^\s*$/.test(s.slice(Math.max(0,t-a),Math.min(s.length,n-a))),!1}),!i}function Qu(e,t){let n=e.marks[t];if(!n)return()=>!1;let r=wu(n);return qu((e,t,i)=>{let{empty:a,ranges:o}=e.selection;if(a||!r(e))return r(e,t,i);if(!t)return!0;let s=!o.every(({$from:t,$to:r})=>Zu(e.doc,t.pos,r.pos,n)),c=e.tr;for(let{$from:e,$to:t}of o){if(!s){c.removeMark(e.pos,t.pos,n);continue}let r=e.pos,i=t.pos,a=e.nodeAfter,o=t.nodeBefore,l=a?.isText?/^\s*/.exec(a.text??``)?.[0].length??0:0,u=o?.isText?/\s*$/.exec(o.text??``)?.[0].length??0:0;r+l<i&&(r+=l,i-=u),c.addMark(r,i,n.create())}return t(c.scrollIntoView()),!0},{type:`toggle`,format:t})}function $u(e){let t=e.selection.$from;for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.name===X.bulletList||n.type.name===X.orderedList)return{node:n,depth:e}}return null}function ed(e,t){let n=e.selection.$from;for(let e=n.depth;e>0;e--)if(n.node(e).type.name===t)return!0;return!1}function td(e){return e.nodes[X.listItem]}function nd(e,t){let n=e.nodes[t],r=td(e);return!n||!r?()=>!1:qu(Yu((e,t,i)=>{let a=$u(e);if(a&&a.node.type===n)return Hu(r)(e,t,i);if(a){if(t){let r=e.selection.$from.before(a.depth),i=n.name===X.orderedList?{start:1}:null;t(e.tr.setNodeMarkup(r,n,i))}return!0}return Lu(n)(e,t,i)}),{type:`toggle`,format:t})}function rd(e){let t=e.nodes[X.blockquote];return t?qu(Yu((e,n)=>{let{$from:r,$to:i}=e.selection;if(ed(e,X.blockquote)){let a=r.blockRange(i,e=>e.type===t),o=a&&Zn(a);return!a||o==null?!1:(n?.(e.tr.lift(a,o).scrollIntoView()),!0)}return bu(t)(e,n)}),{type:`toggle`,format:`blockquote`}):()=>!1}function id(e,t){let{from:n,to:r}=e.selection,i=[];e.doc.nodesBetween(n,r,(e,t)=>e.isTextblock?(e.forEach((e,n)=>{wd(e)&&i.push({pos:t+1+n,node:e})}),!1):!0);for(let{pos:n,node:r}of i.reverse()){let i=r.type.spec.leafText?.(r)??``;i?t.replaceWith(n,n+r.nodeSize,e.schema.text(i)):t.delete(n,n+r.nodeSize)}}function ad(e){let t=e.nodes[X.codeBlock],n=e.nodes[X.paragraph];return t?qu((e,r)=>{if(e.selection.$from.parent.type===t)return xu(n)(e,r);if(!xu(t)(e))return!1;if(r){let n=e.tr;id(e,n),n.setBlockType(n.mapping.map(e.selection.from),n.mapping.map(e.selection.to),t),r(n.scrollIntoView())}return!0},{type:`toggle`,format:`codeBlock`}):()=>!1}function od(e,t){let n=e.nodes[X.heading],r=e.nodes[X.paragraph];return qu(t===0?xu(r):n?xu(n,{level:t}):()=>!1,{type:`heading`,level:t})}function sd(e,t,n){let r=e.doc.resolve(t),i=n.isInSet(r.marks());if(!i)return null;let a=r.parent,o=r.start(),s=-1;for(let e=0;e<a.childCount;e++){let n=a.child(e),r=o;if(o+=n.nodeSize,!i.isInSet(n.marks)){s=-1;continue}if(s<0&&(s=r),s<=t&&t<=o){let t=o;for(let n=e+1;n<a.childCount&&i.isInSet(a.child(n).marks);n++)t+=a.child(n).nodeSize;return{from:s,to:t,mark:i}}}return null}function cd(e){let t=e.schema.marks[Z.link];if(!t)return null;let{from:n,to:r,empty:i,$from:a}=e.selection;if(i){let n=t.isInSet(e.storedMarks??a.marks());return n?n.attrs.href:null}let o;return e.doc.nodesBetween(n,r,e=>{if(!e.isText||o===null)return;let n=t.isInSet(e.marks),r=n?n.attrs.href:null;o===void 0?o=r:o!==r&&(o=null)}),o??null}function ld(e){let t=e.schema.marks[Z.link];if(!t)return!1;let{$from:n,from:r,to:i,empty:a}=e.selection;if(e.selection instanceof U)return!1;if(a)return n.parent.inlineContent&&n.parent.type.allowsMarkType(t);let o=!1;return e.doc.nodesBetween(r,i,e=>o?!1:(e.inlineContent&&e.type.allowsMarkType(t)&&(o=!0),!0)),o}function ud(e,t){let n=e.marks[Z.link];return n?(r,i)=>{let{from:a,to:o,empty:s}=r.selection;if(t===null){if(s){let e=sd(r,a,n);return e?(i?.(r.tr.removeMark(e.from,e.to,n).setMeta(Ku,{type:`link`,active:!1})),!0):!1}return r.doc.rangeHasMark(a,o,n)?(i?.(r.tr.removeMark(a,o,n).setMeta(Ku,{type:`link`,active:!1})),!0):!1}let c=ge(t,{typed:!0});if(c===null||!ld(r))return!1;if(!i)return!0;let l=n.create({href:c}),u=r.tr;if(!s)u.removeMark(a,o,n).addMark(a,o,l);else{let i=sd(r,a,n);if(i)u.removeMark(i.from,i.to,n).addMark(i.from,i.to,l);else{let i=t.trim(),o=l.addToSet(jl(r.storedMarks??r.selection.$from.marks(),Al(r.doc,a)));u.insert(a,e.text(i,o)),u.setSelection(H.create(u.doc,a+i.length)),u.removeStoredMark(n)}}return i(u.scrollIntoView().setMeta(Ku,{type:`link`,active:!0})),!0}:()=>!1}function dd(e){return(t,n)=>{let{$from:r,from:i,to:a}=t.selection;if(!n)return!0;let o=Al(t.doc,i,a);if(r.parent.type.spec.code||!e.includes(`
@@ -15,4 +15,4 @@ import{a as e,l as t,n,o as r,s as i,u as a}from"./Icon-BjPIXI8I.js";import{B as
15
15
  `).forEach((e,n)=>{n>0&&c.push(t.schema.node(X.hardBreak)),e&&c.push(t.schema.text(e,s))}),n(t.tr.replaceSelection(new N(A.from(c),0,0)).scrollIntoView()),!0}}function fd(e,t,n){return(r,i)=>{let a=e=>typeof e==`string`&&e!==``;if(!a(t.kind)||!a(t.id)||!a(t.label))return!1;if(!i)return!0;let o=n?n.from:r.selection.from,s=n?n.to:r.selection.to,c=r.doc.resolve(o);if(!c.parent.inlineContent||c.parent.type.spec.code)return!1;let l=Al(r.doc,o,s),u=jl(c.marks().filter(e=>c.parent.type.allowsMarkType(e.type)),l),d=e.node(X.entity,{kind:t.kind,id:t.id,label:t.label},void 0,l),f=r.tr.replaceWith(o,s,[d,e.text(` `,u)]);return f.setSelection(H.create(f.doc,o+d.nodeSize+1)),i(f.scrollIntoView().setMeta(Ku,{type:`entity`,entity:{type:`entity`,kind:t.kind,id:t.id,label:t.label}})),!0}}var pd=qu(Tu(Iu,Di),{type:`undo`}),md=qu(Oi,{type:`redo`}),hd=(e,t)=>{let{$from:n,empty:r}=e.selection;if(!r||!n.parent.type.spec.code||n.parentOffset!==n.parent.content.size||!n.parent.textContent.endsWith(`
16
16
  `))return!1;let i=e.schema.nodes[X.paragraph],a=n.indexAfter(-1);if(!n.node(-1).canReplaceWith(a,a,i))return!1;if(t){let r=e.tr.delete(n.pos-1,n.pos),a=r.mapping.map(n.after());r.insert(a,i.create()),r.setSelection(H.create(r.doc,a+1)),t(r.scrollIntoView())}return!0};function gd(e){let t=td(e);return(e,n,r)=>{let{$from:i,empty:a}=e.selection;return!t||!a||i.parent.content.size!==0||i.depth<2||i.node(-1).type!==t?!1:Hu(t)(e,n,r)}}var _d=RegExp(`^\`\`\`(${rl})?$`);function vd(e){let t=e.nodes[X.codeBlock];return(e,n)=>{let{$from:r,empty:i}=e.selection,a=r.parent;if(!t||!i||a.type.name!==X.paragraph||r.parentOffset!==a.content.size)return!1;let o=!0;a.forEach(e=>{(!e.isText||e.marks.some(e=>e.type.spec.code))&&(o=!1)});let s=o?_d.exec(a.textContent):null;if(!s||!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),t))return!1;if(n){let i=r.start(),a=e.tr.delete(i,r.pos).setBlockType(i,i,t,{language:s[1]??``}).setMeta(Ku,{type:`format`,format:`codeBlock`,active:!0}),o=e.plugins.find(e=>e.spec.isInputRules);o&&a.setMeta(o,{transform:a,from:r.pos,to:r.pos,text:``}),n(a.scrollIntoView())}return!0}}function yd(e){let t=td(e);return Tu(vd(e),hd,su,...t?[Vu(t),gd(e)]:[],uu,du,pu)}function bd(e){return Tu(su,(t,n)=>{let{$from:r}=t.selection;return r.parent.inlineContent?(n?.(t.tr.replaceSelectionWith(e.nodes[X.hardBreak].create()).scrollIntoView()),!0):!1})}function xd(e){let t=td(e);return t?Yu(Gu(t)):()=>!1}function Sd(e){let t=td(e);if(!t)return()=>!1;let n=Hu(t);return(e,r,i)=>Cd(e,t)&&n(e,r,i)}function Cd(e,t){let{$from:n,$to:r}=e.selection,i=n.blockRange(r,e=>e.childCount>0&&e.firstChild?.type===t);return i!==null&&i.depth>0&&n.node(i.depth-1).type===t}var wd=e=>!!(e&&e.isInline&&e.isAtom&&!e.isText&&e.type.name!==X.hardBreak);function Td(e){return(t,n)=>{let r=t.selection;if(r instanceof U&&wd(r.node))return n?.(t.tr.deleteSelection().scrollIntoView()),!0;if(!(r instanceof H)||!r.empty)return!1;let i=r.$from,a=e<0?i.nodeBefore:i.nodeAfter;if(!wd(a))return!1;let o=e<0?i.pos-a.nodeSize:i.pos;return n?.(t.tr.delete(o,o+a.nodeSize).scrollIntoView()),!0}}function Ed(e){return(t,n)=>{let r=t.selection;if(r instanceof U&&wd(r.node)){let i=e<0?r.from:r.to;return n?.(t.tr.setSelection(H.create(t.doc,i)).scrollIntoView()),!0}if(!(r instanceof H)||!r.empty)return!1;let i=r.$from,a=e<0?i.nodeBefore:i.nodeAfter;if(!wd(a))return!1;let o=i.pos+e*a.nodeSize;return n?.(t.tr.setSelection(H.create(t.doc,o)).scrollIntoView()),!0}}function Dd(e){let t=td(e),n=e.nodes[X.paragraph];return Tu(Iu,Td(-1),Zl,(e,n,r)=>{let{$from:i,empty:a}=e.selection;return!t||!a||i.parentOffset!==0||i.depth<2||i.node(-1).type!==t||i.index(-1)!==0?!1:Hu(t)(e,n,r)},$l,tu,(e,t)=>{let{$from:r,empty:i}=e.selection;return!i||r.parentOffset!==0||r.parent.type===n||!r.parent.isTextblock?!1:xu(n)(e,t)})}var Od=Tu(Td(1),Zl,iu,au),kd=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Ad=e=>Array.isArray(e)?e:[],jd={root:new Set([`format`,`blocks`]),paragraph:new Set([`type`,`content`]),heading:new Set([`type`,`level`,`content`]),list:new Set([`type`,`ordered`,`start`,`items`]),listItem:new Set([`type`,`content`]),blockquote:new Set([`type`,`content`]),codeBlock:new Set([`type`,`language`,`text`]),text:new Set([`type`,`text`,`marks`]),break:new Set([`type`]),entity:new Set([`type`,`kind`,`id`,`label`,`marks`]),link:new Set([`type`,`href`]),annotation:new Set([`type`,`id`]),mark:new Set([`type`])},Md=new Set([Z.link,Z.bold,Z.italic,Z.strike,Z.code,Z.annotation]);function Nd(e,t){let n=jd[t],r=null;for(let t of Object.keys(e))n.has(t)||C(r??={},t,e[t]);return r}function Pd(e,t){if(kd(t))for(let n of Object.keys(t))C(e,n,t[n]);return e}function Fd(e,t,n,r=!1){let i=M.none,a=e=>{e&&n.allowsMarkType(e.type)&&(i=e.addToSet(i))};for(let n of Ad(t.marks)){if(!kd(n)||typeof n.type!=`string`)continue;if(!Md.has(n.type)){a(e.marks[Z.unknown]?.create({json:n})??null);continue}if(n.type===Z.annotation){if(typeof n.id!=`string`||n.id===``)continue;a(e.marks[Z.annotation].create({id:n.id,fields:Nd(n,`annotation`)}));continue}let t=e.marks[n.type];if(!(!t||r))if(n.type===Z.link){if(typeof n.href!=`string`)continue;a(t.create({href:n.href,fields:Nd(n,`link`)}))}else a(t.create({fields:Nd(n,`mark`)}))}if(r)return i;let o=Nd(t,`text`);return o&&a(e.marks[Z.textFields].create({fields:o})),i}function Id(e,t,n){let r=[];for(let i of Ad(t))if(kd(i))switch(i.type){case`text`:if(typeof i.text!=`string`||i.text===``)break;r.push(e.text(i.text,Fd(e,i,n)));break;case`break`:r.push(e.node(X.hardBreak,{fields:Nd(i,`break`)}));break;case`entity`:r.push(e.node(X.entity,{kind:String(i.kind??``),id:String(i.id??``),label:String(i.label??``),fields:Nd(i,`entity`)},void 0,Fd(e,i,n,!0)));break;default:r.push(e.node(X.unknownInline,{json:i}))}return r}function Ld(e,t){let n=[];return t.split(/\r\n?|\n/).forEach((t,r)=>{r>0&&n.push(e.node(X.hardBreak)),t&&n.push(e.text(t))}),n}function Rd(e,t=[],n=null){return e.node(X.paragraph,{fields:n},t)}function zd(e,t){let n=Vd(e,t.content);return n[0]?.type.name!==X.paragraph&&n.unshift(Rd(e)),e.node(X.listItem,{fields:Nd(t,`listItem`)},n)}function Bd(e,t){let n=e.nodes,r=n[X.paragraph];switch(t.type){case`paragraph`:return[Rd(e,Id(e,t.content,r),Nd(t,`paragraph`))];case`heading`:{let i=n[X.heading];if(!i)return[Rd(e,Id(e,t.content,r))];let a=t.level===2||t.level===3?t.level:1;return[i.create({level:a,fields:Nd(t,`heading`)},Id(e,t.content,i))]}case`list`:{let r=n[t.ordered===!0?X.orderedList:X.bulletList],i=Ad(t.items).filter(kd);if(!r)return i.flatMap(t=>Vd(e,t.content));if(i.length===0)return[];let a=Nd(t,`list`),o=typeof t.start==`number`&&Number.isSafeInteger(t.start)&&t.start>=0?t.start:1,s=r.name===X.orderedList?{start:o,fields:a}:{fields:a};return[r.create(s,i.map(t=>zd(e,t)))]}case`blockquote`:{let r=Vd(e,t.content),i=n[X.blockquote];return i?r.length===0?[]:[i.create({fields:Nd(t,`blockquote`)},r)]:r}case`codeBlock`:{let r=typeof t.text==`string`?t.text:``,i=n[X.codeBlock];if(!i)return[Rd(e,Ld(e,r))];let a=typeof t.language==`string`?t.language:``;return[i.create({language:a,fields:Nd(t,`codeBlock`)},r?e.text(r):null)]}default:return[e.node(X.unknownBlock,{json:t})]}}function Vd(e,t){return Ad(t).filter(kd).flatMap(t=>Bd(e,t))}function Hd(e,t){let n=Vd(e,t.blocks);return n.length===0&&n.push(Rd(e)),e.node(X.doc,{fields:Nd(t,`root`)},n)}function Ud(e){let t=e.type.name;return t===Z.unknown?e.attrs.json:t===Z.link?Pd({type:`link`,href:e.attrs.href},e.attrs.fields):t===Z.annotation?Pd({type:`annotation`,id:e.attrs.id},e.attrs.fields):Pd({type:t},e.attrs.fields)}function Wd(e){let t=[],n=null;for(let r of e.marks)r.type.name===Z.textFields?n=r.attrs.fields:t.push(Ud(r));return{marks:t,fields:n}}function Gd(e){return e.marks.filter(e=>e.type.name===Z.annotation||e.type.name===Z.unknown).map(Ud)}function Kd(e){let t=[];return e.forEach(e=>{switch(e.type.name){case X.text:{let{marks:n,fields:r}=Wd(e),i={type:`text`,text:e.text??``};n.length&&(i.marks=n),t.push(Pd(i,r));break}case X.hardBreak:t.push(Pd({type:`break`},e.attrs.fields));break;case X.entity:{let n={type:`entity`,kind:e.attrs.kind,id:e.attrs.id,label:e.attrs.label},r=Gd(e);r.length&&(n.marks=r),t.push(Pd(n,e.attrs.fields));break}case X.unknownInline:t.push(e.attrs.json);break}}),t}function qd(e){let t=e.attrs.fields;switch(e.type.name){case X.heading:return Pd({type:`heading`,level:e.attrs.level,content:Kd(e)},t);case X.bulletList:case X.orderedList:{let n=e.type.name===X.orderedList,r={type:`list`,ordered:n},i=e.attrs.start;n&&i!==void 0&&i!==1&&(r.start=i);let a=[];return e.forEach(e=>a.push(Pd({type:`listItem`,content:Jd(e)},e.attrs.fields))),r.items=a,Pd(r,t)}case X.blockquote:return Pd({type:`blockquote`,content:Jd(e)},t);case X.codeBlock:{let n={type:`codeBlock`},r=e.attrs.language;return r&&(n.language=r),n.text=e.textContent,Pd(n,t)}case X.unknownBlock:return e.attrs.json;default:return Pd({type:`paragraph`,content:Kd(e)},t)}}function Jd(e){let t=[];return e.forEach(e=>t.push(qd(e))),t}function Yd(e){let t=e.firstChild;return e.childCount===1&&t!==null&&t.type.name===X.paragraph&&t.content.size===0&&t.attrs.fields===null}function Xd(e){return Pe(Pd({format:se,blocks:Yd(e)?[]:Jd(e)},e.attrs.fields))}for(var Zd={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:`'`},Qd={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},$d=typeof navigator<`u`&&/Mac/.test(navigator.platform),ef=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),tf=0;tf<10;tf++)Zd[48+tf]=Zd[96+tf]=String(tf);for(var tf=1;tf<=24;tf++)Zd[tf+111]=`F`+tf;for(var tf=65;tf<=90;tf++)Zd[tf]=String.fromCharCode(tf+32),Qd[tf]=String.fromCharCode(tf);for(var nf in Zd)Qd.hasOwnProperty(nf)||(Qd[nf]=Zd[nf]);function rf(e){var t=!($d&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||ef&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Qd:Zd)[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 af=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),of=typeof navigator<`u`&&/Win/.test(navigator.platform);function sf(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))af?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 cf(e){let t=Object.create(null);for(let n in e)t[sf(n)]=e[n];return t}function lf(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 uf(e){let t=cf(e);return function(e,n){let r=rf(n),i,a=t[lf(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[lf(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(of&&n.ctrlKey&&n.altKey)&&(i=Zd[n.keyCode])&&i!=r){let r=t[lf(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var df=[`ArrowDown`,`ArrowUp`,`Enter`,`Tab`,`Escape`],ff=new Set([`Mod-a`,`Ctrl-a`,`Ctrl-e`]),pf=new Set([`Shift`,`Control`,`Alt`,`Meta`]);function mf(e){return e?e.dom.ownerDocument.defaultView?.getComputedStyle(e.dom).direction===`rtl`:!1}function hf(e,t){return e.composing||ie(t)}function gf(e){let t=uf(e);return new ri({props:{handleKeyDown:(e,n)=>!hf(e,n)&&t(e,n)}})}function _f(e,t,n){let r=new Set(t),i=!1,a=new ri({props:{handleKeyDown:(e,t)=>(hf(e,t)||(t.key===`Escape`?i=!0:t.key!==`Tab`&&!pf.has(t.key)&&(i=!1)),!1),handleDOMEvents:{mousedown:()=>(i=!1,!1),blur:()=>(i=!1,!1)}}}),o=e=>(t,n,r)=>!i&&e(t,n,r),s=e=>(t,r,i)=>!n.readOnly()&&e(t,r,i),c={};for(let e of df)c[e]=()=>n.suggestionOpen()?n.onSuggestionKey()?.(e)??!1:!1;let l={"Mod-Enter":()=>{let e=n.onSubmit();return e?(e(),!0):!1}},u={};r.has(`bold`)&&(u[`Mod-b`]=Qu(e,`bold`)),r.has(`italic`)&&(u[`Mod-i`]=Qu(e,`italic`)),r.has(`strike`)&&(u[`Mod-Shift-x`]=Qu(e,`strike`)),r.has(`code`)&&(u[`Mod-e`]=Qu(e,`code`)),r.has(`link`)&&(u[`Mod-k`]=()=>{let e=n.onLinkRequest();return e?(e(),!0):!1}),r.has(`bulletList`)&&(u[`Mod-Shift-8`]=nd(e,`bulletList`)),r.has(`orderedList`)&&(u[`Mod-Shift-7`]=nd(e,`orderedList`)),r.has(`blockquote`)&&(u[`Mod-Shift-9`]=rd(e)),(r.has(`heading`)||r.has(`codeBlock`))&&(u[`Mod-Alt-0`]=od(e,0)),r.has(`heading`)&&(u[`Mod-Alt-1`]=od(e,1),u[`Mod-Alt-2`]=od(e,2),u[`Mod-Alt-3`]=od(e,3)),r.has(`codeBlock`)&&(u[`Mod-Alt-c`]=ad(e));let d={"Mod-z":pd,"Mod-Shift-z":md,"Mod-y":md,Enter:yd(e),"Shift-Enter":bd(e),Backspace:Dd(e),Delete:Od,Tab:o(xd(e)),"Shift-Tab":o(Sd(e))},f={ArrowLeft:(e,t,n)=>Ed(mf(n)?1:-1)(e,t),ArrowRight:(e,t,n)=>Ed(mf(n)?-1:1)(e,t)},p=Object.fromEntries(Object.entries(Au).map(([e,t])=>[e,ff.has(e)?t:s(t)])),m=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,s(t)]));return[a,gf(c),gf(l),gf(m(u)),gf({...m(d),...f}),gf(p)]}var vf=new Set([Z.link,Z.bold,Z.italic,Z.strike,Z.code]),yf=e=>e.type.spec.inclusive===!1&&e.type.name!==Z.annotation;function bf(e,t){let n=!1;return e.descendants((e,r)=>{if(!e.isInline)return!0;if(!wd(e))return!1;for(let i of e.marks)vf.has(i.type.name)&&(t.removeNodeMark(r,i),n=!0);return!1}),n}function xf(e,t){let n=t.$cursor;if(!n||!wd(n.nodeBefore))return null;let r=n.pos,i=n;for(;wd(i.nodeBefore);)r-=i.nodeBefore.nodeSize,i=e.resolve(r);let a=i.marks().filter(e=>e.type.name!==Z.annotation);return a.some(e=>vf.has(e.type.name))?a:null}function Sf(){let e=null;return new ri({view:t=>(e=t,{destroy:()=>{e=null}}),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged),a=r.tr,o=!1;i&&bf(r.doc,a)&&(o=!0,r.storedMarks&&a.setStoredMarks(r.storedMarks));let s=r.selection;if(!r.storedMarks&&!e?.composing&&s instanceof H&&t.some(e=>e.selectionSet||e.docChanged)){let e=xf(a.doc,s);e&&(a.setStoredMarks(e),o=!0)}let c=n.storedMarks;if(c?.some(yf)&&!r.storedMarks&&i){let e=s instanceof H?s.$cursor:null,t=e?.nodeBefore;e&&t?.isText&&c.filter(e=>yf(e)&&e.isInSet(t.marks)).length>0&&(a.setStoredMarks(t.marks),o=!0)}return o?a:null}})}function Cf(e){let t=e.trim();return!t||/\s/.test(t)||!/^(https?:\/\/|mailto:)/i.test(t)?null:ge(t)}function wf(e){return e?Array.from(e.files??[]):[]}function Tf(e){return e?!!(e.getData(`text/plain`).trim()||e.getData(`text/html`).replace(/<[^>]*>/g,``).trim()):!1}function Ef(e,t){let n=[];return t.split(/\r\n?|\n/).forEach((t,r)=>{r>0&&n.push(e.node(X.hardBreak)),t&&n.push(e.text(t))}),e.node(X.paragraph,null,n)}function Df(e,t,n){let r=t.trim()===``?e.node(X.doc,null,[Ef(e,t)]):Hd(e,De(t)),i=n.marks();if(i.length===0)return N.maxOpen(r.content);let a=[];return r.content.forEach(e=>{let t=i.filter(t=>e.type.allowsMarkType(t.type)),n=[];e.forEach(e=>{n.push(e.isText?e.mark(t.reduce((e,t)=>t.addToSet(e),e.marks)):e)}),a.push(e.copy(A.from(n)))}),N.maxOpen(A.from(a))}var Of=e=>e.type.name===X.paragraph?e.attrs.wordList:null;function kf(e,t){let n=e.nodes[t.item.ordered?X.orderedList:X.bulletList],r=e.nodes[X.listItem];if(!n||!r)return t.items.flatMap(e=>[e.paragraph,...e.children]);let i=n.name===X.orderedList&&t.item.start!==1?{start:t.item.start}:null;return[n.create(i,t.items.map(e=>r.create(null,[e.paragraph,...e.children])))]}function Af(e,t){let n=[],r=[],i=()=>{let t=kf(e,r.pop()),i=r.at(-1);i?i.items.at(-1)?.children.push(...t):n.push(...t)};for(let e of t){let t=Of(e),n=e.type.create({...e.attrs,wordList:null},e.content,e.marks);for(;(r.at(-1)?.level??0)>t.level;)i();let a=r.at(-1);a!==void 0&&a.level===t.level&&(a.item.ordered!==t.ordered||r.length===1&&a.item.list!==t.list)&&i(),(r.length===0||(r.at(-1)?.level??0)<t.level)&&r.push({level:t.level,item:t,items:[]}),r.at(-1)?.items.push({paragraph:n,children:[]})}for(;r.length>0;)i();return n}var jf=e=>e.map(e=>e.type.create({...e.attrs,wordList:null},e.content,e.marks));function Mf(e,t,n=null){let r=!1,i=[],a=[],o=()=>{if(a.length===0)return;let t=i.length===0,o=Af(e,a),s=!n||!t||n.contentMatch.matchFragment(A.from(o))!==null;i.push(...s?o:jf(a)),a=[],r=!0};return t.forEach(t=>{if(Of(t)){a.push(t);return}if(o(),t.isTextblock||t.isLeaf){i.push(t);return}let n=Mf(e,t.content,t.type);n!==t.content&&(r=!0),i.push(n===t.content?t:t.copy(n))}),o(),r?A.from(i):t}function Nf(e){try{let t=JSON.parse(e?.getData(`vscode-editor-data`)||`{}`).mode;return typeof t==`string`&&t!==`plaintext`?al(t):``}catch{return``}}function Pf(e,t){let n=!1,r=[];return e.forEach(e=>{let i=e;if(e.type.name===X.codeBlock&&!e.attrs.language)i=e.type.create({...e.attrs,language:t},e.content,e.marks);else if(!e.isTextblock&&!e.isLeaf){let n=Pf(e.content,t);n!==e.content&&(i=e.copy(n))}i!==e&&(n=!0),r.push(i)}),n?A.from(r):e}function Ff(e,t){let n=[],r=(e,t,i)=>{e.forEach((e,a)=>{let o=t+a;if(e.isTextblock||e.isLeaf)return;let s=e.type.name!==X.listItem;if(s&&i>=8){n.push({pos:o,node:e});return}r(e,o+1,s?i+1:i)})};r(e.doc,0,0);for(let{pos:r,node:i}of n.reverse()){let n=Vd(t,Oe(qd(i)));e.replaceWith(r,r+i.nodeSize,n)}return n.length>0}function If(e,t){let n=xl(e),r=Sl(e),i=(e,n)=>{let r=wf(n);return r.length===0||Tf(n)?!1:(e.preventDefault(),t.onFiles()?.(r),!0)},a=!1,o=``;return new ri({appendTransaction:(t,n,i)=>{let o=t.findIndex(e=>{let t=e.getMeta(`uiEvent`);return t===`paste`||t===`drop`});if(o<0)return null;let s=t[o],c=s.getMeta(`uiEvent`)===`drop`,l=c&&a;c&&(a=!1);let u=Nl(s);if(u===null)return null;for(let e of t.slice(o+1))u={from:e.mapping.map(u.from,-1),to:e.mapping.map(u.to,1)};let d=i.tr;l&&d.removeMark(u.from,u.to,r);for(let e of Al(i.doc,u.from,u.to))d.addMark(u.from,u.to,e);return Ff(d,e),d.docChanged?d:null},props:{clipboardSerializer:n,clipboardTextParser:(t,n)=>Df(e,t,n),transformPasted:(t,n)=>{let r=o;if(o=``,n.dragging&&t===n.dragging.slice)return t;let i=Mf(e,t.content),a=i===t.content?t:N.maxOpen(i,!0);if(r){let e=Pf(a.content,r);e!==a.content&&(a=new N(e,a.openStart,a.openEnd))}return Kl(a,e)},handleDOMEvents:{paste:(e,t)=>(o=Nf(t.clipboardData),!1)},handlePaste:(t,n)=>{let r=n.clipboardData;if(i(n,r))return!0;let a=e.marks[Z.link],{state:o}=t;if(a&&r&&!o.selection.empty&&ld(o)){let e=Cf(r.getData(`text/plain`));if(e!==null){let{from:n,to:r}=o.selection;return t.dispatch(o.tr.removeMark(n,r,a).addMark(n,r,a.create({href:e})).setMeta(Ku,{type:`link`,active:!0}).setMeta(`uiEvent`,`paste`)),!0}}return!1},handleDrop:(e,t,n,r)=>(a=!!(e.dragging&&n===e.dragging.slice&&!r),i(t,t.dataTransfer))}})}var Lf={inCodeMark:!1};function Rf(e,t,n,r=()=>null,i=()=>!0){return new ju(e,(e,a,o,s)=>{let c=e.tr.delete(o,s),l=c.doc.resolve(o).blockRange(),u=l&&$n(l,t,r(a));if(!l||!u)return null;c.wrap(l,u);let d=c.doc.resolve(o-1).nodeBefore;return d&&d.type===t&&dr(c.doc,o-1)&&i(a,d)&&c.join(o-1),Ju(c.doc)>8?null:c.setMeta(Ku,n)},Lf)}function zf(e,t,n,r){return new ju(e,(e,i,a,o)=>{let s=e.doc.resolve(a);return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(a,o).setBlockType(a,a,t,n(i)).setMeta(Ku,r):null},Lf)}function Bf(e,t,n,r){return new ju(e,(e,i,a,o)=>{let s=i[1]??``;if(!e.doc.resolve(a).parent.type.allowsMarkType(t))return null;let c=a+n,l=c+s.length,u=e.tr;return u.delete(l,o),u.delete(a,c),u.addMark(a,a+s.length,t.create()),u.removeStoredMark(t),u.setMeta(Ku,r)},Lf)}function Vf(e){let t=[],n=e.nodes,r=e.marks,i=n[X.heading];if(i)for(let e of[1,2,3])t.push(zf(RegExp(`^#{${e}}\\s$`),i,()=>({level:e}),{type:`heading`,level:e}));let a=n[X.bulletList];a&&t.push(Rf(/^\s*[-*]\s$/,a,{type:`format`,format:`bulletList`,active:!0}));let o=n[X.orderedList];o&&t.push(Rf(/^(\d{1,9})\.\s$/,o,{type:`format`,format:`orderedList`,active:!0},e=>({start:Number(e[1])}),(e,t)=>t.childCount+t.attrs.start===Number(e[1])));let s=n[X.blockquote];s&&t.push(Rf(/^\s*>\s$/,s,{type:`format`,format:`blockquote`,active:!0}));let c=n[X.codeBlock];c&&t.push(zf(RegExp(`^\`\`\`(${rl})?\\s$`),c,e=>({language:e[1]??``}),{type:`format`,format:`codeBlock`,active:!0}));let l=r[Z.bold];l&&t.push(Bf(/(?<=^|[^*])\*\*([^*\s](?:[^*]*[^*\s])?)\*\*$/,l,2,{type:`format`,format:`bold`,active:!0}));let u=r[Z.italic];u&&(t.push(Bf(/(?<=^|[^*\w])\*([^*\s](?:[^*]*[^*\s])?)\*$/,u,1,{type:`format`,format:`italic`,active:!0})),t.push(Bf(/(?<=^|[^_\w])_([^_\s](?:[^_]*[^_\s])?)_$/,u,1,{type:`format`,format:`italic`,active:!0})));let d=r[Z.strike];d&&t.push(Bf(/(?<=^|[^~])~~([^~\s](?:[^~]*[^~\s])?)~~$/,d,2,{type:`format`,format:`strike`,active:!0}));let f=r[Z.code];return f&&t.push(Bf(/(?<=^|[^`])`([^`]+)`$/,f,1,{type:`format`,format:`code`,active:!0})),Pu({rules:t})}function Hf(e){return{bold:Qu(e,`bold`),italic:Qu(e,`italic`),strike:Qu(e,`strike`),code:Qu(e,`code`),bulletList:nd(e,`bulletList`),orderedList:nd(e,`orderedList`),blockquote:rd(e),codeBlock:ad(e),headings:[od(e,1),od(e,2),od(e,3)]}}function Uf(e){let{schema:t}=e,n=e.selection.$from,r=e.selection instanceof U?e.selection.node:n.parent,i=$u(e),a=r.type.name===X.heading?r.attrs.level:0;return{bold:Xu(e,t.marks[Z.bold]),italic:Xu(e,t.marks[Z.italic]),strike:Xu(e,t.marks[Z.strike]),code:Xu(e,t.marks[Z.code]),link:cd(e),heading:a,bulletList:i?.node.type.name===X.bulletList,orderedList:i?.node.type.name===X.orderedList,blockquote:ed(e,X.blockquote),codeBlock:r.type.name===X.codeBlock}}function Wf(e,t,n,r){let{selection:i,doc:a}=e,o=i.empty?``:a.textBetween(i.from,i.to,`
17
17
  `,e=>e.type.spec.leafText?.(e)??``),s=(e,n)=>t.has(e)&&n();return{empty:r.empty,length:r.length,focused:r.focused,collapsed:i.empty,selectedText:o,range:Ol(e),annotations:Il(e),active:Uf(e),can:{bold:s(`bold`,()=>n.bold(e)),italic:s(`italic`,()=>n.italic(e)),strike:s(`strike`,()=>n.strike(e)),code:s(`code`,()=>n.code(e)),link:s(`link`,()=>ld(e)),heading:s(`heading`,()=>n.headings.some(t=>t(e))),bulletList:s(`bulletList`,()=>n.bulletList(e)),orderedList:s(`orderedList`,()=>n.orderedList(e)),blockquote:s(`blockquote`,()=>n.blockquote(e)),codeBlock:s(`codeBlock`,()=>n.codeBlock(e)),undo:ki(e)>0,redo:Ai(e)>0},suggestion:r.suggestion}}function Gf(e,t){return e!==null&&JSON.stringify(e)===JSON.stringify(t)}var Kf=new oi(`polymorphRichTextSuggestion`),qf=`dismiss`,Jf=``;function Yf(e,t){let n=e.selection;if(!(n instanceof H)||!n.empty||t.length===0)return null;let r=n.$from,i=r.parent;if(!i.isTextblock||i.type.spec.code)return null;let a=e.schema.marks[Z.code];if(a&&a.isInSet(e.storedMarks??r.marks()))return null;let o=i.textBetween(0,r.parentOffset,void 0,e=>e.type.name===X.hardBreak?`
18
- `:Jf),s=/\S*$/.exec(o),c=s?s[0]:``;if(!c||c.includes(Jf))return null;let l=r.pos-c.length,u=e.schema.marks[Z.link];for(let t of[a,u])if(t&&e.doc.rangeHasMark(l,r.pos,t))return null;for(let{kind:e,trigger:n}of t)if(!(!n||!c.startsWith(n)))return{kind:e,trigger:n,query:c.slice(n.length),from:l,to:r.pos};return null}function Xf(e){return new ri({key:Kf,state:{init:(t,n)=>{let r=Yf(n,e());return{token:r?{...r,key:`1`,dismissed:!1}:null,count:+!!r}},apply:(t,n,r,i)=>{let a=Yf(i,e());if(!a)return n.token?{token:null,count:n.count}:n;let o=n.token,s=o!==null&&t.mapping.map(o.from)===a.from&&o.kind===a.kind,c=t.getMeta(Kf)===qf||s&&o.dismissed;if(s)return{token:{...a,key:o.key,dismissed:c},count:n.count};let l=n.count+1;return{token:{...a,key:String(l),dismissed:c},count:l}}}})}function Zf(){return[Kf,qf]}function Qf(e){return Kf.getState(e)?.token??null}var $f=`polymorphRichTextSilent`,ep=`polymorphRichTextFocus`,tp=`polymorphRichTextApp`;function np(e,t){return t===`start`?V.findFrom(e.resolve(0),1,!0)??V.atStart(e):V.findFrom(e.resolve(e.content.size),-1,!0)??V.atEnd(e)}function rp(e,t){let n=e.resolve(Math.max(0,Math.min(t,e.content.size)));return V.findFrom(n,1,!0)??V.findFrom(n,-1,!0)??V.near(n)}var ip={top:0,bottom:0,left:0,right:0};function ap(e){return new Set(e)}function op(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...n].every(e=>r.has(e))}var sp=e=>e.map(({kind:e,trigger:t})=>JSON.stringify([e,t]));function cp(e){let t=e.element,n=e.headingLevel??2,r=Array.from(t.attributes,e=>[e.name,e.value]),i=[...e.formats],a=[...e.entities],o=e.editable,s=e.readOnly===!0,c=null,l=()=>o&&c===null,u=()=>!l()&&(s||o&&c!==null),d={...e.attributes},f=e.placeholder,p={drawn:e.annotations===void 0?void 0:[...e.annotations],active:e.activeAnnotation,className:e.classes.annotation},m={onChange:e.onChange,onState:e.onState,onEvent:e.onEvent,onSubmit:e.onSubmit,onLinkRequest:e.onLinkRequest,onSuggestionKey:e.onSuggestionKey,onFiles:e.onFiles,onFocus:e.onFocus,onBlur:e.onBlur},h=t.ownerDocument.activeElement===t,g=null,_=null,ee=null,v=!1,y=!1,b,x,te,ne=null,re=null,ie=e=>rt(Ce(e)?ye(e).value:e,i),ae=e=>{if(ne!==null&&ne.doc===e)return ne;let t=Xd(e),n=Se(t,{blockSeparator:``});return ne={doc:e,value:t,text:JSON.stringify(t),length:ke(n),empty:n.trim()===``&&be(t).length===0},ne},oe=e=>{let t=[],n=e.doc.firstChild;f&&n&&e.doc.childCount===1&&n.isTextblock&&n.content.size===0&&t.push(uc.node(0,n.nodeSize,{"data-placeholder":f}));let r=e.selection;return r instanceof U&&r.node.isAtom&&t.push(uc.node(r.from,r.to,{"data-selected":``})),t.length?pc.create(e.doc,t):null},se=new ri({props:{handleDOMEvents:{focus:e=>(v||h||(h=!0,e.dispatch(e.state.tr.setMeta(ep,!0)),m.onFocus?.()),!1),blur:e=>(v||h&&(h=!1,e.dispatch(e.state.tr.setMeta(ep,!1)),m.onBlur?.()),!1),compositionend:()=>(Promise.resolve().then(De),!1),click:(e,t)=>(t.target?.closest?.(`a`)&&t.preventDefault(),!1),auxclick:(e,t)=>(t.target?.closest?.(`a`)&&t.preventDefault(),!1),beforeinput:(e,t)=>{let n=t.inputType??``;return n.startsWith(`format`)?(t.preventDefault(),!0):n===`historyUndo`||n===`historyRedo`?(t.preventDefault(),(n===`historyUndo`?pd:md)(e.state,e.dispatch,e),!0):!1}}}}),S=(e,t)=>u()?(t.preventDefault(),!0):!1,ce=(e,t)=>u()?(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect=`none`),!0):!1,le=new ri({filterTransaction:e=>{if(!u()||!e.docChanged)return!0;let t=e.getMeta(`appendedTransaction`)??e;return t.getMeta(tp)===!0||t.getMeta($f)===!0},props:{handleDOMEvents:{beforeinput:S,paste:S,cut:S,drop:S,dragover:ce,dragenter:ce},handleTextInput:(e,t,n,r)=>{let i=e.state.selection;if(r===``||!(i instanceof U)||i.node.type.name!==X.unknownBlock)return!1;let a=e.state.schema.nodes[X.paragraph];if(a===void 0)return!1;let o=i.to,s=e.state.tr.insert(o,a.create(null,e.state.schema.text(r)));return s.setSelection(H.create(s.doc,o+1+r.length)),e.dispatch(s.scrollIntoView()),!0}}}),ue=()=>[le,..._f(b,i,{suggestionOpen:()=>g?.suggestion!==null&&g?.suggestion!==void 0,onSuggestionKey:()=>m.onSuggestionKey,onSubmit:()=>m.onSubmit,onLinkRequest:()=>m.onLinkRequest,readOnly:u}),Vf(b),Sf(),Ti(),Xf(()=>a),If(b,{onFiles:()=>m.onFiles}),se,Hl(()=>p)],de=t=>{b=bl({formats:i,entities:a,classes:e.classes,headingLevel:n}),x=ap(i),te=Hf(b),c=Ce(t)?t:null;let r=Hd(b,ie(t));return ae(r),ti.create({schema:b,doc:r,selection:np(r,`start`),plugins:ue()})},fe=()=>c??ae(w.state.doc).value,C=e=>{let t=Qf(e);if(!t||t.dismissed||!h||!l())return null;let n=ip;try{let e=w.coordsAtPos(t.from,1);n={top:e.top,bottom:e.bottom,left:e.left,right:e.right}}catch{}return{kind:t.kind,trigger:t.trigger,query:t.query,key:t.key,rect:n}},pe=()=>{let{empty:e,length:t}=ae(w.state.doc);return Wf(w.state,x,te,{empty:e,length:t,focused:h,suggestion:C(w.state)})},me=()=>{if(y)return;let e=pe();Gf(g,e)||(g=e,m.onState?.(e))},he=(e,t,n)=>{let r=m.onEvent;if(!r)return;if(e.type!==`toggle`){r(e);return}let i=Uf(t)[e.format],a=Uf(n)[e.format];i!==a&&r({type:`format`,format:e.format,active:!!a})},ge=e=>{if(y)return;let t=w.state,n=e.getMeta($f)===!0,r=t.apply(e);w.updateState(r);let i=r.doc!==t.doc;if(i&&!n&&c===null){let e=ae(t.doc).text,n=ae(r.doc);n.text!==e&&m.onChange?.(n.value)}me();let a=e.getMeta(Ku);a&&!n&&(i||a.type===`toggle`)&&he(a,t,r),(_||ee)&&!w.composing&&Promise.resolve().then(De)},_e=()=>{let e={};for(let[t,n]of Object.entries(d))n!==void 0&&t!==`contenteditable`&&t!==`class`&&(e[t]=n);return h&&(e[`data-focused`]=``),u()&&(e.inputmode=`none`,e.spellcheck=`false`),e},ve=()=>{for(let[e,n]of Object.entries(d))n===void 0&&t.removeAttribute(e)},xe=de(e.value),w=new Hc({mount:t},{state:xe,editable:()=>o||u(),attributes:_e,decorations:oe,dispatchTransaction:ge});ve(),g=pe();let we=e=>{let t=w.state.doc;if(Yl(t,e)){let t=w.state.tr;if(ql(t,e),t.doc.eq(e)){w.dispatch(t.setMeta(`addToHistory`,!1).setMeta($f,!0));return}}let n=t.content.findDiffStart(e.content);if(n===null)return;let r=t.content.findDiffEnd(e.content),i=r?r.a:t.content.size,a=r?r.b:e.content.size,o=n-Math.min(i,a);o>0&&(i+=o,a+=o);let s=w.state.tr.replace(n,i,e.slice(n,a));s.doc.eq(e)||(s=w.state.tr.replaceWith(0,t.content.size,e.content)),s.setMeta(`addToHistory`,!1).setMeta($f,!0),w.dispatch(s)},Te=e=>{let t=ae(w.state.doc),n=re?.input===e&&re.doc===w.state.doc;if(c===null?e===t.value||n:e===c){re={input:e,doc:w.state.doc};return}let r=c!==null;c=Ce(e)?e:null;let i=Hd(b,ie(e));JSON.stringify(Xd(i))!==t.text&&we(i),re={input:e,doc:w.state.doc},r!==(c!==null)&&(w.setProps({}),me())},Ee=e=>{let t=Qf(w.state),n=t&&!t.dismissed?{from:t.from,to:t.to}:null;je(fd(b,e,n))};function De(){if(!(y||w.composing)){if(_){let e=_;_=null,Te(e)}if(ee){let e=ee;ee=null,Ee(e)}me()}}let Oe=()=>{if(t.ownerDocument.activeElement===t){v=!0;try{t.blur(),t.focus({preventScroll:!0})}finally{v=!1}}},Ae=()=>{let e=fe(),{from:t,to:n}=w.state.selection,r=de(e),i=r;try{let e=n<=r.doc.content.size&&t!==n?H.between(r.doc.resolve(t),r.doc.resolve(n)):rp(r.doc,t);i=r.apply(r.tr.setSelection(e))}catch{i=r}w.updateState(i),me()},je=e=>!y&&c===null&&e(w.state,e=>w.dispatch(e.setMeta(tp,!0)));return{getValue:()=>fe(),setValue(e){if(!y){if(w.composing){_=e;return}Te(e)}},getState:()=>g??pe(),update(e){if(y)return;let{formats:t,entities:n,editable:r}=e;for(let t of Object.keys(e))t.startsWith(`on`)&&(m[t]=e[t]);if(e.attributes!==void 0&&(d={...e.attributes}),`placeholder`in e&&(f=e.placeholder),r!==void 0&&(o=r),`readOnly`in e&&(s=e.readOnly===!0),`annotations`in e||`activeAnnotation`in e){let t=`annotations`in e?e.annotations:p.drawn,n=`activeAnnotation`in e?e.activeAnnotation:p.active;(JSON.stringify(t)!==JSON.stringify(p.drawn)||n!==p.active)&&(p={...p,drawn:t===void 0?void 0:[...t],active:n})}let c=t!==void 0&&!op(t,i)||n!==void 0&&!op(sp(n),sp(a));t!==void 0&&(i=[...t]),n!==void 0&&(a=[...n]),c?Ae():w.setProps({}),ve(),me()},focus(e){y||(e&&w.dispatch(w.state.tr.setSelection(np(w.state.doc,e))),o||u()?w.focus():t.focus({preventScroll:!0}))},toggle(e){return x.has(e)?je(te[e]):!1},setHeading(e){return(e===0?!x.has(`heading`)&&!x.has(`codeBlock`):!x.has(`heading`))?!1:je(od(b,e))},setLink(e){return x.has(`link`)?je(ud(b,e)):!1},undo:()=>je(pd),redo:()=>je(md),insertText(e){je(dd(e))},insertEntity(e){if(!(y||c!==null)){if(w.composing){ee=e,Oe();return}Ee(e)}},annotate:e=>je(Ul(e)),removeAnnotation:e=>je(Wl(e)),selectionRect:()=>y?null:Xl(w),tokenRect:()=>y?null:C(w.state)?.rect??null,dismissSuggestion(){let e=Qf(w.state);if(y||!e||e.dismissed)return;let[t,n]=Zf();w.dispatch(w.state.tr.setMeta(t,n))},clear(){if(y||c!==null||Yd(w.state.doc))return;let e=b.nodes[X.paragraph].create(),t=w.state.tr.replaceWith(0,w.state.doc.content.size,e);t.setSelection(H.create(t.doc,1)),w.dispatch(t.scrollIntoView().setMeta(tp,!0))},destroy(){if(y)return;y=!0,w.destroy();let e=new Map(r);for(let n of Array.from(t.attributes,e=>e.name))e.has(n)||t.removeAttribute(n);for(let[n,r]of e)t.getAttribute(n)!==r&&t.setAttribute(n,r);t.replaceChildren()}}}var $={root:`_root_vzs73_24`,frame:`_frame_vzs73_32 _stateFeedback_lkjqs_17`,toolbar:`_toolbar_vzs73_50`,controls:`_controls_vzs73_59`,group:`_group_vzs73_69`,slot:`_slot_vzs73_75`,viewport:`_viewport_vzs73_87`,surface:`_surface_vzs73_97 _root_1q2y5_16 _root_z92xs_10`,paragraph:`_paragraph_vzs73_177 _text_jx0r4_6`,heading1:`_heading1_vzs73_182 _heading_1t0qx_6`,heading2:`_heading2_vzs73_191 _heading_1t0qx_6`,heading3:`_heading3_vzs73_200 _heading_1t0qx_6`,list:`_list_vzs73_209 _list_1q2y5_20 _list_z92xs_21`,item:`_item_vzs73_213 _item_1q2y5_24 _item_z92xs_31`,quote:`_quote_vzs73_217 _quote_1q2y5_28 _quote_z92xs_44`,codeBlock:`_codeBlock_vzs73_221 _block_1j1lk_6 _focusRing_1hr3n_49`,code:`_code_vzs73_221 _code_hc07h_7`,link:`_link_vzs73_231 _link_1pcjq_13 _focusAround_1hr3n_95`,entity:`_entity_vzs73_237 _entity_1q2y5_53`,unknown:`_unknown_vzs73_242`,annotation:`_annotation_vzs73_257 _annotation_1q2y5_76`,footer:`_footer_vzs73_263`,actions:`_actions_vzs73_271`,count:`_count_vzs73_281`,suggestions:`_suggestions_vzs73_316 _suggestions_1o6qu_156`,listbox:`_listbox_vzs73_348 _listbox_1o6qu_189`,option:`_option_vzs73_352 _option_1o6qu_202 _stateFeedback_lkjqs_17`,glyph:`_glyph_vzs73_356 _glyph_1o6qu_223 _stateFeedback_lkjqs_17`,leading:`_leading_vzs73_361`,text:`_text_vzs73_367 _text_1o6qu_231`,label:`_label_vzs73_371 _label_1o6qu_238`,description:`_description_vzs73_375 _description_1o6qu_245 _stateFeedback_lkjqs_17`,rows:`_rows_vzs73_379 _rows_1o6qu_268`,row:`_row_vzs73_379 _row_1o6qu_268`,empty:`_empty_vzs73_387 _empty_1o6qu_282`,error:`_error_vzs73_392 _empty_1o6qu_282`,status:`_status_vzs73_398 _visuallyHidden_qxi8b_14`,linkForm:`_linkForm_vzs73_403`,linkActions:`_linkActions_vzs73_410`},lp=o(`<div data-member=rich-text-input><div><div><div data-rich-text-input-part=surface role=textbox aria-multiline=true></div></div></div><div role=status aria-live=polite>`),up=o(`<div role=toolbar data-rich-text-input-part=toolbar>`),dp=o(`<div><div>`),fp=o(`<div>`),pp=o(`<form><div>`),mp=o(`<div role=toolbar><div>`),hp=o(`<p>`),gp=o(`<div data-rich-text-input-part=suggestions>`),_p=o(`<ul role=listbox>`),vp=o(`<li role=option><span><span>`),yp=o(`<span aria-hidden=true>`),bp=o(`<span>`),xp=o(`<div aria-hidden=true>`),Sp=o(`<input type=hidden>`);function Cp(o){let p=ee({entities:[],minRows:3,maxRows:12,invalid:!1,disabled:!1,readOnly:!1,autoFocus:!1,pending:!1,toolbarPlacement:`fixed`},x(o,`group`));return s(()=>{let o=i(()=>p.entities),s=m(),v=t(),x=t(),ie=t(),se=t(),S=t(),C=t(),ve=t(),ye=a(()=>p.controlRef),be=e(p.defaultValue??Ae()),xe=e(p.defaultValue??Ae()),w=e(null),we=e({text:``,at:0}),Ee=e({key:``,index:0}),Oe=e(null),ke=e(null),Pe=e(null),Ie=e(!1),Je=e(``),Ye=e(void 0),Ze=e(null),et=e(!1),tt=e(!1),nt=e(!1),rt=e(!1),it=e(!1),D=e(!1),at=e(null),ot=e(!1),O=r(()=>({editor:null,handle:null,lastValue:void 0,saidNow:!1})),k=r(()=>({toolbar:`Formatting`,selectionBar:`Selection`,selectionBarReady:`Controls for the selection are available: Alt+F10`,bold:`Bold`,italic:`Italic`,strike:`Strikethrough`,code:`Code`,link:`Link`,textStyle:`Text style`,paragraph:`Paragraph`,heading:e=>`Heading ${e}`,bulletList:`Bulleted list`,orderedList:`Numbered list`,blockquote:`Quote`,codeBlock:`Code block`,undo:`Undo`,redo:`Redo`,linkForm:`Link`,linkAddress:`Address`,linkApply:`Apply`,linkRemove:`Remove link`,linkInvalid:`Enter a web address, an email address or a phone number.`,formatOn:e=>`${e} on`,formatOff:e=>`${e} off`,linkAdded:`Link added`,linkRemoved:`Link removed`,inserted:e=>`${e} inserted`,undone:`Undone`,redone:`Redone`,count:(e,t)=>`${e} / ${t}`,overLimit:e=>`${e} ${e===1?`character`:`characters`} over the limit`,withinLimit:`Within the limit`,submitEmpty:`There is nothing to submit yet.`,submitOverLimit:e=>`Remove ${e} ${e===1?`character`:`characters`} to submit.`,submitPending:`Still saving.`,suggestions:e=>e===1?`1 suggestion`:`${e} suggestions`,loadingSuggestions:`Loading suggestions…`,noSuggestions:`No results`,...p.messages===void 0?{}:Object.fromEntries(Object.entries(p.messages).filter(([,e])=>e!==void 0))})),st=r(()=>p.value??be.value),ct=r(()=>je(st.value)),lt=r(()=>Ne(st.value)),A=r(()=>p.maxLength===void 0?0:Math.max(0,lt.value-p.maxLength)),j=r(()=>A.value>0),ut=r(()=>Ce(st.value)),dt=r(()=>p.readOnly||p.pending||ut.value),M=r(()=>p.disabled||dt.value),ft=r(()=>!M.value),N=r(()=>Fe.filter(e=>(p.formats??Fe).includes(e))),P=r(()=>e=>N.value.includes(e)),pt=r(()=>o.value.map(e=>({kind:e.kind,trigger:e.trigger}))),mt=r(()=>[[`bold`,`bold`],[`italic`,`italic`],[`strike`,`strikethrough`],[`code`,`code`]].filter(([e])=>P.value(e)).map(([e,t])=>({format:e,icon:t}))),ht=r(()=>[[`bulletList`,`list-bulleted`],[`orderedList`,`list-numbered`],[`blockquote`,`quote`],[`codeBlock`,`code-block`]].filter(([e])=>P.value(e)).map(([e,t])=>({format:e,icon:t}))),gt=r(()=>p.id??`${s}-surface`),_t=r(()=>`${s}-suggestions`),vt=r(()=>`${s}-count`),yt=r(()=>w.value?.active),F=r(()=>w.value?.can),bt=r(()=>({empty:w.value?.collapsed??!0,text:w.value?.selectedText??``,range:w.value?.range??{start:0,end:0}})),xt=r(()=>()=>O.value.editor?.focus()),St=r(()=>e=>{we.value={text:e,at:we.value.at+1},O.value.saidNow=!0,queueMicrotask(()=>{O.value.saidNow=!1})}),Ct=r(()=>e=>e===`heading`?k.value.textStyle:k.value[e]),wt=r(()=>e=>{e.type===`format`?St.value((e.active?k.value.formatOn:k.value.formatOff)(Ct.value(e.format))):e.type===`heading`?St.value(e.level===0?k.value.paragraph:k.value.heading(e.level)):e.type===`link`?St.value(e.active?k.value.linkAdded:k.value.linkRemoved):e.type===`entity`?St.value(k.value.inserted(e.entity.label)):e.type===`undo`?St.value(k.value.undone):St.value(k.value.redone)}),Tt=r(()=>e=>{if(!ut.value){if(p.maxLength!==void 0){let t=Ne(st.value)>p.maxLength,n=Math.max(0,Ne(e)-p.maxLength);!t&&n>0?St.value(k.value.overLimit(n)):t&&n===0&&St.value(k.value.withinLimit)}be.value=e,p.onChange?.(e)}}),Et=r(()=>(e,t)=>{e.setValue(t),Tt.value(e.getValue())}),Dt=r(()=>()=>{let e=O.value.editor;e===null||he(e.getValue())===he(xe.value)||Et.value(e,xe.value)}),Ot=r(()=>()=>{p.value===void 0&&O.value.lastValue!==void 0&&(be.value=O.value.lastValue),O.value.lastValue=p.value}),kt=r(()=>new Intl.Collator(void 0,{usage:`search`,sensitivity:`base`})),At=r(()=>ft.value?w.value?.suggestion??null:null),jt=r(()=>(e=>e===null?void 0:o.value.find(t=>t.kind===e.kind))(At.value)),Mt=r(()=>At.value!==null&&jt.value!==void 0),Nt=r(()=>At.value?.query??``),Pt=r(()=>Nt.value.normalize(`NFC`)),Ft=r(()=>e=>(e=>Pt.value===``||(jt.value?.filter===`startsWith`?kt.value.compare(e.slice(0,Pt.value.length),Pt.value)===0:Array.from({length:Math.max(0,e.length-Pt.value.length+1)},(t,n)=>e.slice(n,n+Pt.value.length)).some(e=>kt.value.compare(e,Pt.value)===0)))(e.normalize(`NFC`))),It=r(()=>Mt.value&&jt.value?.loading===!0),Lt=r(()=>Mt.value&&!It.value&&jt.value?.error!==void 0&&jt.value.error!==``),Rt=r(()=>!Mt.value||Lt.value||jt.value===void 0?[]:jt.value.filter===!1?jt.value.options:jt.value.options.filter(e=>Ft.value(e.label))),zt=r(()=>Mt.value&&At.value!==null?`${At.value.key}:${Nt.value}`:``),Bt=r(()=>Rt.value.length===0?-1:Ee.value.key===zt.value?Math.min(Ee.value.index,Rt.value.length-1):0),Vt=r(()=>Mt.value?It.value?k.value.loadingSuggestions:Lt.value?jt.value?.error??``:Rt.value.length===0?k.value.noSuggestions:k.value.suggestions(Rt.value.length):null),Ht=r(()=>e=>{let t=Rt.value[e],n=O.value.editor,r=jt.value;t===void 0||r===void 0||n===null||(Oe.value=null,n.insertEntity({kind:r.kind,id:t.id,label:t.entityLabel??r.trigger+t.label}))}),Ut=r(()=>e=>Mt.value?e===`ArrowDown`||e===`ArrowUp`?Rt.value.length===0?!1:(Ee.value={key:zt.value,index:e===`ArrowDown`?Math.min(Bt.value+1,Rt.value.length-1):Math.max(Bt.value-1,0)},!0):e===`Enter`?Bt.value===-1?It.value:(Ht.value(Bt.value),!0):e===`Tab`?Bt.value===-1?!1:(Ht.value(Bt.value),!0):(O.value.editor?.dismissSuggestion(),!0):!1),Wt=r(()=>e=>p.annotations===void 0||p.annotations.includes(e)),Gt=r(()=>e=>{w.value=e;let t=e.suggestion,n=t===null?void 0:o.value.find(e=>e.kind===t.kind),r=t===null||n===void 0?null:t.key+`:`+t.query;r!==Oe.value&&(Oe.value=r,t!==null&&r!==null&&n?.onQueryChange?.(t.query));let i=e.collapsed?e.annotations.find(e=>Wt.value(e))??null:null;i!==null&&i!==ke.value&&(Pe.value!==null&&(Pe.value={entered:i}),p.onAnnotationSelect?.(i)),ke.value=i}),I=r(()=>(e=>{let t=O.value.handle;return t!==null&&t.value===e.value&&t.empty===e.empty&&t.length===e.length&&t.overLimit===e.overLimit&&t.disabled===e.disabled&&t.selection.empty===e.selection.empty&&t.selection.text===e.selection.text&&t.selection.range.start===e.selection.range.start&&t.selection.range.end===e.selection.range.end?t:(O.value.handle=e,e)})({focus:()=>O.value.editor?.focus(),clear:()=>O.value.editor?.clear(),insertText:e=>O.value.editor?.insertText(e),insertEntity:e=>O.value.editor?.insertEntity(e),annotate:e=>O.value.editor?.annotate(e)??!1,removeAnnotation:e=>O.value.editor?.removeAnnotation(e)??!1,value:st.value,empty:ct.value,length:lt.value,overLimit:j.value,disabled:M.value,selection:bt.value})),Kt=r(()=>()=>{if(!(p.onSubmit===void 0||p.disabled)){if(p.pending)return St.value(k.value.submitPending);if(ct.value)return St.value(k.value.submitEmpty);if(j.value)return St.value(k.value.submitOverLimit(A.value));p.onSubmit?.(O.value.editor?.getValue()??st.value,I.value)}}),qt=r(()=>e=>{if(e){let e=O.value.editor?.getState().active.link??null;Je.value=e??``,Ye.value=void 0,Ze.value=e}Ie.value=e}),Jt=r(()=>e=>{e.preventDefault(),e.stopPropagation();let t=Je.value.trim(),n=O.value.editor;if(t===``||ge(t,{typed:!0})===null||n===null||!n.setLink(t)){Ye.value=k.value.linkInvalid;return}Ie.value=!1}),Yt=r(()=>()=>{O.value.editor?.setLink(null),Ie.value=!1}),Xt=r(()=>()=>{let e=O.value.editor,t=p.toolbarPlacement===`fixed`||L.value;e===null||!ft.value||!e.getState().can.link||!t||qt.value(!0)}),Zt=r(()=>yt.value===void 0?0:yt.value.codeBlock?-1:yt.value.heading),Qt=r(()=>[0,1,2,3].map(e=>({kind:`checkbox`,label:e===0?k.value.paragraph:k.value.heading(e),checked:Zt.value===e,onCheckedChange:()=>en.value(e)}))),$t=r(()=>e=>{e&&(tt.value=nt.value),et.value=e}),en=r(()=>e=>{O.value.editor?.setHeading(e),et.value=!1}),tn=r(()=>e=>{let t=C.value?.ownerDocument.defaultView;t?.requestAnimationFrame(()=>t.requestAnimationFrame(e))}),nn=r(()=>()=>{let e=se.value?.closest(`[data-member="popover"]`)??null;tn.value(()=>{let t=C.value?.ownerDocument,n=t?.activeElement??null;(n===null||n===t?.body||C.value?.contains(n)===!0||e?.contains(n)===!0)&&O.value.editor?.focus()})}),rn=r(()=>()=>{tt.value&&tn.value(()=>O.value.editor?.focus())}),an=r(()=>p.toolbarPlacement===`selection`&&ft.value&&N.value.length>0),on=r(()=>p.selectionActions!==void 0&&!p.disabled),sn=r(()=>`${bt.value.range.start}:${bt.value.range.end}`),cn=r(()=>an.value&&(Ie.value||et.value)),L=r(()=>(an.value||on.value)&&w.value!==null&&!w.value.collapsed&&(rt.value||it.value||cn.value)&&!D.value&&at.value!==sn.value),ln=r(()=>()=>Mt.value?(O.value.editor?.dismissSuggestion(),!0):L.value?(at.value=sn.value,!0):!1),un=r(()=>e=>{let t=e.ownerDocument.defaultView,n=t=>{t.key!==`Escape`||t.isComposing||t.target!==e||ln.value()&&t.preventDefault()};return t?.addEventListener(`keydown`,n,!0),()=>t?.removeEventListener(`keydown`,n,!0)}),dn=r(()=>(e,t)=>{let n=e.ownerDocument.defaultView;return n===null?()=>{}:pe(n,t)}),fn=r(()=>e=>{let t=e.ownerDocument.defaultView,n=()=>{D.value=!1};return t?.addEventListener(`pointerup`,n,!0),t?.addEventListener(`pointercancel`,n,!0),()=>{t?.removeEventListener(`pointerup`,n,!0),t?.removeEventListener(`pointercancel`,n,!0)}}),pn=r(()=>Mt.value||L.value),mn=r(()=>_e()),hn=r(()=>_e()),gn=r(()=>()=>Te(x.value,O.value.editor?.selectionRect(),ye.value)),_n=r(()=>()=>{Le(x.value,hn.value)&&O.value.editor?.focus()}),vn=r(()=>()=>de(S.value,C.value,O.value.editor?.tokenRect()??At.value?.rect)),yn=r(()=>e=>`${s}-suggestion-${ne(e.id)}`),bn=r(()=>[p[`aria-describedby`],p.maxLength===void 0?void 0:vt.value].filter(e=>e!==void 0).join(` `)||void 0),xn=r(()=>o.value.length>0),Sn=r(()=>({id:gt.value,role:`textbox`,"aria-multiline":`true`,"aria-label":p[`aria-label`],"aria-labelledby":p[`aria-labelledby`],"aria-describedby":bn.value,"aria-required":p[`aria-required`]===!0?`true`:void 0,"aria-invalid":p.invalid||j.value?`true`:void 0,"aria-disabled":p.disabled?`true`:void 0,"aria-readonly":!p.disabled&&dt.value?`true`:void 0,tabindex:p.disabled?void 0:`0`,"aria-autocomplete":xn.value?`list`:void 0,"aria-haspopup":xn.value?`listbox`:void 0,"aria-controls":Mt.value&&Rt.value.length>0?_t.value:void 0,"aria-activedescendant":(e=>Mt.value&&e!==void 0?yn.value(e):void 0)(Bt.value===-1?void 0:Rt.value[Bt.value])})),Cn=r(()=>JSON.stringify([N.value,pt.value,ft.value,!p.disabled&&dt.value,Sn.value,p.placeholder??null,p.annotations??null,p.activeAnnotation??null,p.onSubmit!==void 0,p.onFiles!==void 0])),wn=r(()=>()=>({formats:N.value,entities:pt.value,editable:ft.value,readOnly:!p.disabled&&dt.value,attributes:Sn.value,placeholder:p.placeholder,annotations:p.annotations,activeAnnotation:p.activeAnnotation,onSubmit:p.onSubmit===void 0?void 0:()=>Kt.value(),onFiles:p.onFiles===void 0?void 0:e=>p.onFiles?.(e)})),Tn=r(()=>e=>{let t=cp({element:e,value:st.value,formats:N.value,entities:pt.value,classes:{paragraph:$.paragraph??``,heading:[$.heading1??``,$.heading2??``,$.heading3??``],bulletList:$.list??``,orderedList:$.list??``,listItem:$.item??``,blockquote:$.quote??``,codeBlock:$.codeBlock??``,codeBlockText:``,bold:``,italic:``,strike:``,code:$.code??``,link:$.link??``,entity:$.entity??``,annotation:$.annotation??``,unknown:$.unknown??``},editable:ft.value,readOnly:!p.disabled&&dt.value,attributes:Sn.value,placeholder:p.placeholder,annotations:p.annotations,activeAnnotation:p.activeAnnotation,onChange:e=>Tt.value(e),onState:e=>Gt.value(e),onEvent:e=>wt.value(e),onSubmit:p.onSubmit===void 0?void 0:()=>Kt.value(),onLinkRequest:()=>Xt.value(),onSuggestionKey:e=>Ut.value(e),onFiles:p.onFiles===void 0?void 0:e=>p.onFiles?.(e)});return O.value.editor=t,Gt.value(t.getState()),p.autoFocus&&t.focus(`end`),()=>{t.destroy(),O.value.editor=null}}),En=r(()=>(e,t)=>{let n=O.value.editor;n!==null&&(t(n),e.detail>0&&n.focus())}),Dn=r(()=>e=>{!e.altKey||e.key!==`F10`||(e.preventDefault(),L.value?fe(x.value,hn.value):Pn.value&&fe(ve.value,mn.value))}),On=r(()=>()=>{Pe.value={entered:null},(p.selectionActions!==void 0||an.value)&&(D.value=!0)}),kn=r(()=>e=>{let t=Pe.value;Pe.value=null;let n=(e.target instanceof Element?e.target:null)?.closest(`[data-annotation-id]`)?.getAttribute(`data-annotation-id`);n==null||!Wt.value(n)||O.value.editor?.getState().collapsed===!1||p.disabled||(ke.value=n,t?.entered!==n&&p.onAnnotationSelect?.(n))}),An=r(()=>e=>{let t=e.relatedTarget;t instanceof Node&&x.value?.contains(t)===!0&&(it.value=!0),rt.value=!1}),jn=r(()=>e=>{let t=e.relatedTarget;t instanceof Node&&ye.value?.contains(t)===!0&&(rt.value=!0),(!(t instanceof Node)||!e.currentTarget.contains(t))&&(it.value=!1),t===null&&!L.value&&_n.value()}),Mn=r(()=>e=>Qe(e,{panels:()=>[se.value?.closest(`[data-member="popover"]`)??null],entered:()=>{ot.value=!1,p.onFocus?.()},left:()=>p.onBlur?.()})),Nn=r(()=>p.toolbarPlacement===`fixed`),Pn=r(()=>Nn.value||p.toolbar!==void 0),Fn=r(()=>p.footer===void 0&&p.submitLabel!==void 0&&p.onSubmit!==void 0),In=r(()=>p.footer!==void 0||Fn.value),Ln=Ve(()=>L.value,()=>x.value),R;b(()=>{R?.();let e=C.value?Mn.value(C.value):()=>{};R=()=>{e()}}),y(()=>R?.());let z;b(()=>{z?.();let e=ye.value?Tn.value(ye.value):()=>{};z=()=>{e()}}),y(()=>z?.());let Rn;b(()=>{Rn?.();let e=C.value?$e(C.value,()=>Dt.value()):()=>{};Rn=()=>{e()}}),y(()=>Rn?.());let zn;T(u(()=>p[`aria-labelledby`]),()=>{zn?.();let e=ye.value?Xe(ye.value,()=>O.value.editor?.focus(),()=>!p.disabled):()=>{};zn=()=>{e()}},!0),y(()=>zn?.()),T(u(()=>p.value),()=>{Ot.value()},!0),T(u(()=>Cn.value),()=>{O.value.editor?.update(wn.value())},!1),T(u(()=>[p.value,be.value]),()=>{p.value===void 0||O.value.editor?.setValue(p.value)},!1),T(u(()=>Vt.value),()=>{Vt.value===null||St.value(Vt.value)},!0),T(u(()=>[At.value,Rt.value.length,It.value,Lt.value]),()=>{vn.value()},!0);let Bn;T(u(()=>Mt.value),()=>{Bn?.();let e=Mt.value&&S.value?ae(S.value,vn.value):()=>{};Bn=()=>{e()}},!0),y(()=>Bn?.());let Vn;T(u(()=>pn.value),()=>{Vn?.();let e=pn.value&&ye.value?un.value(ye.value):()=>{};Vn=()=>{e()}},!0),y(()=>Vn?.());let Hn;T(u(()=>D.value),()=>{Hn?.();let e=D.value&&C.value?fn.value(C.value):()=>{};Hn=()=>{e()}},!0),y(()=>Hn?.());let Un;T(u(()=>Pn.value),()=>{Un?.();let e=()=>{ce(ve.value,mn.value)},t=typeof MutationObserver>`u`?void 0:new MutationObserver(e);for(let e of[ve.value])e&&t?.observe(e,{childList:!0,characterData:!0,subtree:!0,attributeFilter:[`disabled`,`aria-disabled`,`hidden`,`inert`]});Un=()=>{t?.disconnect()},e()},!0),y(()=>Un?.());let Wn;T(u(()=>Pn.value),()=>{Wn?.();let e=Pn.value&&ve.value?dn.value(ve.value,()=>ve.value):()=>{};Wn=()=>{e()}},!0),y(()=>Wn?.());let Gn;T(u(()=>Ln()),()=>{Gn?.();let e=()=>{ce(x.value,hn.value)},t=typeof MutationObserver>`u`?void 0:new MutationObserver(e);for(let e of[x.value])e&&t?.observe(e,{childList:!0,characterData:!0,subtree:!0,attributeFilter:[`disabled`,`aria-disabled`,`hidden`,`inert`]});Gn=()=>{t?.disconnect()},e()},!0),y(()=>Gn?.());let B;T(u(()=>Ln()),()=>{B?.();let e=Ln()&&x.value?dn.value(x.value,()=>x.value):()=>{};B=()=>{e()}},!0),y(()=>B?.()),T(u(()=>[L.value,w.value]),()=>{L.value&&gn.value()},!0);let Kn;T(u(()=>L.value),()=>{Kn?.();let e=L.value&&x.value?ae(x.value,gn.value):()=>{};Kn=()=>{e()}},!0),y(()=>Kn?.()),T(u(()=>L.value),()=>{L.value||_n.value()},!1),T(u(()=>L.value),()=>{L.value&&!ot.value&&(ot.value=!0,O.value.saidNow||St.value(k.value.selectionBarReady))},!0),T(u(()=>[sn.value,bt.value.empty]),()=>{at.value!==null&&(bt.value.empty||at.value!==sn.value)&&(at.value=null)},!1),T(u(()=>Ie.value),()=>{Ie.value||nn.value()},!1),T(u(()=>et.value),()=>{et.value||rn.value()},!1);let qn;return b(()=>{qn?.();let e=re({member:`RichTextInput`,element:()=>ye.value,state:()=>({value:Se(st.value),disabled:p.disabled,invalid:p.invalid||j.value,readonly:dt.value,empty:ct.value}),actions:{fill:{argument:`text`,run:e=>(()=>{if(ut.value)throw Error(`The document is of a later format than this field writes.`);if(dt.value)throw Error(`The field is read-only.`);let t=O.value.editor;if(t===null)throw Error(`The field is not ready.`);Et.value(t,De(e))})()},clear:()=>(()=>{if(ut.value)throw Error(`The document is of a later format than this field writes.`);if(dt.value)throw Error(`The field is read-only.`);let e=O.value.editor;if(e===null)throw Error(`The field is not ready.`);e.clear()})(),submit:()=>(()=>{if(p.onSubmit===void 0)throw Error(`The field has no submit.`);if(p.pending)throw Error(`The app is saving; wait for it to finish.`);if(ct.value)throw Error(`The field is empty, and an empty field is not submitted.`);if(j.value)throw Error(`The text is ${A.value} characters over the limit.`);p.onSubmit?.(O.value.editor?.getValue()??st.value,I.value)})()},withholds:()=>[ie.value,v.value,x.value,se.value?.closest(`[data-member="popover"]`)??null]});qn=()=>{e()}}),y(()=>qn?.()),(()=>{var e=lp(),t=e.firstChild,r=t.firstChild,i=r.firstChild,a=t.nextSibling,o=C.attach;typeof o==`function`?h(o,e):C.attach=e,c(t,(()=>{var e=l(()=>!!Pn.value);return()=>e()?(()=>{var e=up(),t=ve.attach;return typeof t==`function`?h(t,e):ve.attach=e,e.$$mousedown=e=>oe(e.currentTarget,e),e.$$focusout=e=>ue(e.currentTarget,e,mn.value),e.$$focusin=e=>le(e.currentTarget,e,mn.value),e.$$keydown=e=>me(e.currentTarget,e,mn.value,xt.value),te(e,ee({get class(){return $.toolbar},get"aria-label"(){return k.value.toolbar},get"aria-controls"(){return gt.value}},{"oncapture:click":e=>nt.value=e.detail>0},{"oncapture:keydown":()=>nt.value=!1}),!1,!0),c(e,(()=>{var e=l(()=>!!Nn.value);return()=>e()?(()=>{var e=dp(),t=e.firstChild,n=ie.attach;return typeof n==`function`?h(n,e):ie.attach=e,c(e,(()=>{var e=l(()=>!!(mt.value.length>0||P.value(`link`)));return()=>e()?(()=>{var e=fp();return c(e,g(Be,{get of(){return mt.value},by:e=>e.format,renew:!0,children:e=>g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,get icon(){return e.icon},get label(){return k.value[e.format]},get pressed(){return yt.value?.[e.format]??!1},get disabled(){return M.value||F.value?.[e.format]===!1},onClick:t=>En.value(t,t=>t.toggle(e.format))})}),null),c(e,(()=>{var e=l(()=>!!P.value(`link`));return()=>e()?g(Ge,{get label(){return k.value.linkForm},get open(){return Ie.value},onOpenChange:e=>qt.value(e),get trigger(){return g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,icon:`link`,get label(){return k.value.link},get pressed(){return(yt.value?.link??null)!==null},get disabled(){return M.value||F.value?.link===!1}})},get children(){var e=pp(),t=e.firstChild,n=se.attach;return typeof n==`function`?h(n,e):se.attach=e,e.addEventListener(`submit`,e=>Jt.value(e)),e.noValidate=!0,c(e,g(Ke,{get label(){return k.value.linkAddress},get error(){return Ye.value},get children(){return g(We,{get value(){return Je.value},autoComplete:`off`,onChange:e=>(Je.value=e,Ye.value=void 0)})}}),t),c(t,(()=>{var e=l(()=>Ze.value!==null);return()=>e()?g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,get label(){return k.value.linkRemove},onClick:()=>Yt.value()}):null})(),null),c(t,g(E,{type:`submit`,variant:`solid`,tone:`accent`,size:`sm`,get label(){return k.value.linkApply}}),null),_(n=>{var r=$.linkForm,i=$.linkActions;return r!==n.e&&f(e,n.e=r),i!==n.t&&f(t,n.t=i),n},{e:void 0,t:void 0}),e}}):null})(),null),_(()=>f(e,$.group)),e})():null})(),t),c(e,(()=>{var e=l(()=>!!P.value(`heading`));return()=>e()?[l(()=>l(()=>!!(mt.value.length>0||P.value(`link`)))()?g(He,{orientation:`vertical`}):null),(()=>{var e=fp();return c(e,g(qe,{get open(){return et.value},get items(){return Qt.value},onOpenChange:e=>$t.value(e),get trigger(){return g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,icon:`heading`,get label(){return k.value.textStyle},get disabled(){return M.value||F.value?.heading===!1}})}})),_(()=>f(e,$.group)),e})()]:null})(),t),c(e,(()=>{var e=l(()=>ht.value.length>0);return()=>e()?[l(()=>l(()=>!!(mt.value.length>0||P.value(`link`)||P.value(`heading`)))()?g(He,{orientation:`vertical`}):null),(()=>{var e=fp();return c(e,g(Be,{get of(){return ht.value},by:e=>e.format,renew:!0,children:e=>g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,get icon(){return e.icon},get label(){return k.value[e.format]},get pressed(){return yt.value?.[e.format]??!1},get disabled(){return M.value||F.value?.[e.format]===!1},onClick:t=>En.value(t,t=>t.toggle(e.format))})})),_(()=>f(e,$.group)),e})()]:null})(),t),c(e,(()=>{var e=l(()=>!!(mt.value.length>0||P.value(`link`)||P.value(`heading`)||ht.value.length>0));return()=>e()?g(He,{orientation:`vertical`}):null})(),t),c(t,g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,icon:`undo`,get label(){return k.value.undo},get disabled(){return M.value||F.value?.undo!==!0},onClick:e=>En.value(e,e=>e.undo())}),null),c(t,g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,icon:`redo`,get label(){return k.value.redo},get disabled(){return M.value||F.value?.redo!==!0},onClick:e=>En.value(e,e=>e.redo())}),null),_(n=>{var r=$.controls,i=$.group;return r!==n.e&&f(e,n.e=r),i!==n.t&&f(t,n.t=i),n},{e:void 0,t:void 0}),e})():null})(),null),c(e,(()=>{var e=l(()=>p.toolbar!==void 0);return()=>e()?(()=>{var e=fp();return c(e,()=>p.toolbar?.({focus:I.value.focus,clear:I.value.clear,insertText:I.value.insertText,insertEntity:I.value.insertEntity,annotate:I.value.annotate,removeAnnotation:I.value.removeAnnotation,value:I.value.value,empty:I.value.empty,length:I.value.length,overLimit:I.value.overLimit,disabled:I.value.disabled,selection:I.value.selection})),_(()=>f(e,$.slot)),e})():null})(),null),e})():null})(),r);var s=ye.attach;return typeof s==`function`?h(s,i):ye.attach=i,i.$$focusout=e=>An.value(e),i.$$focusin=()=>rt.value=!0,i.$$click=e=>kn.value(e),i.$$pointerdown=()=>On.value(),i.$$keydown=e=>Dn.value(e),c(t,(()=>{var e=l(()=>!!Ln());return()=>e()?(()=>{var e=mp(),t=e.firstChild,n=x.attach;return typeof n==`function`?h(n,e):x.attach=e,e.$$mousedown=e=>oe(e.currentTarget,e),e.$$focusout=e=>(ue(e.currentTarget,e,hn.value),jn.value(e)),e.$$focusin=e=>(le(e.currentTarget,e,hn.value),it.value=!0),e.$$keydown=e=>me(e.currentTarget,e,hn.value,xt.value),te(t,ee({get class(){return $.controls}},{"oncapture:click":e=>nt.value=e.detail>0},{"oncapture:keydown":()=>nt.value=!1}),!1,!0),c(t,(()=>{var e=l(()=>!!on.value);return()=>e()?(()=>{var e=fp();return c(e,()=>p.selectionActions?.({focus:I.value.focus,clear:I.value.clear,insertText:I.value.insertText,insertEntity:I.value.insertEntity,annotate:I.value.annotate,removeAnnotation:I.value.removeAnnotation,value:I.value.value,empty:I.value.empty,length:I.value.length,overLimit:I.value.overLimit,disabled:I.value.disabled,selection:I.value.selection})),_(()=>f(e,$.group)),e})():null})(),null),c(t,(()=>{var e=l(()=>!!(an.value&&(mt.value.length>0||P.value(`link`))));return()=>e()?[l(()=>l(()=>!!on.value)()?g(He,{orientation:`vertical`}):null),(()=>{var e=fp();return c(e,g(Be,{get of(){return mt.value},by:e=>e.format,renew:!0,children:e=>g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,get icon(){return e.icon},get label(){return k.value[e.format]},get pressed(){return yt.value?.[e.format]??!1},get disabled(){return M.value||F.value?.[e.format]===!1},onClick:t=>En.value(t,t=>t.toggle(e.format))})}),null),c(e,(()=>{var e=l(()=>!!P.value(`link`));return()=>e()?g(Ge,{get label(){return k.value.linkForm},get open(){return Ie.value},onOpenChange:e=>qt.value(e),get trigger(){return g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,icon:`link`,get label(){return k.value.link},get pressed(){return(yt.value?.link??null)!==null},get disabled(){return M.value||F.value?.link===!1}})},get children(){var e=pp(),t=e.firstChild,n=se.attach;return typeof n==`function`?h(n,e):se.attach=e,e.addEventListener(`submit`,e=>Jt.value(e)),e.noValidate=!0,c(e,g(Ke,{get label(){return k.value.linkAddress},get error(){return Ye.value},get children(){return g(We,{get value(){return Je.value},autoComplete:`off`,onChange:e=>(Je.value=e,Ye.value=void 0)})}}),t),c(t,(()=>{var e=l(()=>Ze.value!==null);return()=>e()?g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,get label(){return k.value.linkRemove},onClick:()=>Yt.value()}):null})(),null),c(t,g(E,{type:`submit`,variant:`solid`,tone:`accent`,size:`sm`,get label(){return k.value.linkApply}}),null),_(n=>{var r=$.linkForm,i=$.linkActions;return r!==n.e&&f(e,n.e=r),i!==n.t&&f(t,n.t=i),n},{e:void 0,t:void 0}),e}}):null})(),null),_(()=>f(e,$.group)),e})()]:null})(),null),c(t,(()=>{var e=l(()=>!!(an.value&&P.value(`heading`)));return()=>e()?[l(()=>l(()=>!!(on.value||an.value&&(mt.value.length>0||P.value(`link`))))()?g(He,{orientation:`vertical`}):null),(()=>{var e=fp();return c(e,g(qe,{get open(){return et.value},get items(){return Qt.value},onOpenChange:e=>$t.value(e),get trigger(){return g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,icon:`heading`,get label(){return k.value.textStyle},get disabled(){return M.value||F.value?.heading===!1}})}})),_(()=>f(e,$.group)),e})()]:null})(),null),c(t,(()=>{var e=l(()=>!!(an.value&&ht.value.length>0));return()=>e()?[l(()=>l(()=>!!(on.value||an.value&&(mt.value.length>0||P.value(`link`))||an.value&&P.value(`heading`)))()?g(He,{orientation:`vertical`}):null),(()=>{var e=fp();return c(e,g(Be,{get of(){return ht.value},by:e=>e.format,renew:!0,children:e=>g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,get icon(){return e.icon},get label(){return k.value[e.format]},get pressed(){return yt.value?.[e.format]??!1},get disabled(){return M.value||F.value?.[e.format]===!1},onClick:t=>En.value(t,t=>t.toggle(e.format))})})),_(()=>f(e,$.group)),e})()]:null})(),null),_(t=>{var n=Me.bar,r=k.value.selectionBar,i=L.value?void 0:`closed`,a=!L.value||void 0;return n!==t.e&&f(e,t.e=n),r!==t.t&&d(e,`aria-label`,t.t=r),i!==t.a&&d(e,`data-state`,t.a=i),a!==t.o&&(e.inert=t.o=a),t},{e:void 0,t:void 0,a:void 0,o:void 0}),e})():null})(),null),c(t,(()=>{var e=l(()=>!!In.value);return()=>e()?(()=>{var e=fp();return c(e,(()=>{var e=l(()=>p.maxLength!==void 0);return()=>e()?(()=>{var e=hp();return c(e,(()=>{var e=l(()=>!!j.value);return()=>e()?k.value.overLimit(A.value):k.value.count(lt.value,p.maxLength)})()),_(t=>{var n=$.count,r=vt.value,i=j.value?`over`:void 0;return n!==t.e&&f(e,t.e=n),r!==t.t&&d(e,`id`,t.t=r),i!==t.a&&d(e,`data-state`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e})():null})(),null),c(e,(()=>{var e=l(()=>p.footer!==void 0);return()=>e()?p.footer?.({focus:I.value.focus,clear:I.value.clear,insertText:I.value.insertText,insertEntity:I.value.insertEntity,annotate:I.value.annotate,removeAnnotation:I.value.removeAnnotation,value:I.value.value,empty:I.value.empty,length:I.value.length,overLimit:I.value.overLimit,disabled:I.value.disabled,selection:I.value.selection}):(()=>{var e=fp(),t=v.attach;return typeof t==`function`?h(t,e):v.attach=e,c(e,(()=>{var e=l(()=>p.cancelLabel!==void 0&&p.onCancel!==void 0);return()=>e()?g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,get label(){return p.cancelLabel},get disabled(){return p.disabled},onClick:()=>p.onCancel?.()}):null})(),null),c(e,g(E,{variant:`solid`,tone:`accent`,size:`sm`,get label(){return p.submitLabel??``},get disabled(){return p.disabled||ct.value||j.value},get loading(){return p.pending},onClick:()=>Kt.value()}),null),_(()=>f(e,$.actions)),e})()})(),null),_(()=>f(e,$.footer)),e})():null})(),null),c(e,(()=>{var e=l(()=>!In.value);return()=>e()&&l(()=>p.maxLength!==void 0)()?(()=>{var e=hp();return c(e,(()=>{var e=l(()=>!!j.value);return()=>e()?k.value.overLimit(A.value):k.value.count(lt.value,p.maxLength)})()),_(t=>{var n=$.count,r=vt.value,i=j.value?`over`:void 0;return n!==t.e&&f(e,t.e=n),r!==t.t&&d(e,`id`,t.t=r),i!==t.a&&d(e,`data-state`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e})():null})(),a),c(e,(()=>{var e=l(()=>!!(Mt.value&&jt.value!==void 0));return()=>e()?(()=>{var e=gp(),t=S.attach;return typeof t==`function`?h(t,e):S.attach=e,e.$$mousedown=e=>e.preventDefault(),c(e,(()=>{var e=l(()=>Rt.value.length>0);return()=>e()?(()=>{var e=_p();return c(e,g(Be,{get of(){return Rt.value},by:e=>e.id,renew:!0,children:(e,t)=>(()=>{var r=vp(),i=r.firstChild,a=i.firstChild;return r.$$click=()=>Ht.value(t()),r.$$pointermove=()=>t()!==Bt.value&&(Ee.value={key:zt.value,index:t()}),c(r,(()=>{var t=l(()=>e.leading!==void 0);return()=>t()?(()=>{var t=yp();return c(t,()=>e.leading),_(()=>f(t,$.leading)),t})():l(()=>e.icon!==void 0)()?(()=>{var t=bp();return c(t,g(n,{get name(){return e.icon},size:`sm`})),_(()=>f(t,$.glyph)),t})():null})(),i),c(a,()=>e.label),c(i,(()=>{var t=l(()=>e.description!==void 0);return()=>t()?(()=>{var t=bp();return c(t,()=>e.description),_(()=>f(t,$.description)),t})():null})(),null),_(n=>{var o=$.option,s=yn.value(ze(e)),c=t()===Bt.value?`true`:`false`,l=t()===Bt.value?``:void 0,u=$.text,p=$.label;return o!==n.e&&f(r,n.e=o),s!==n.t&&d(r,`id`,n.t=s),c!==n.a&&d(r,`aria-selected`,n.a=c),l!==n.o&&d(r,`data-highlighted`,n.o=l),u!==n.i&&f(i,n.i=u),p!==n.n&&f(a,n.n=p),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),r})()})),_(t=>{var n=$.listbox,r=_t.value,i=jt.value?.label;return n!==t.e&&f(e,t.e=n),r!==t.t&&d(e,`id`,t.t=r),i!==t.a&&d(e,`aria-label`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e})():null})(),null),c(e,(()=>{var e=l(()=>!!It.value);return()=>e()?(()=>{var e=xp();return c(e,g(Be,{of:[0,1,2],by:e=>e,children:()=>(()=>{var e=fp();return c(e,g(Ue,{textStep:`sm`})),_(()=>f(e,$.row)),e})()})),_(()=>f(e,$.rows)),e})():null})(),null),c(e,(()=>{var e=l(()=>!!Lt.value);return()=>e()?(()=>{var e=xp();return c(e,()=>jt.value?.error),_(()=>f(e,$.error)),e})():null})(),null),c(e,(()=>{var e=l(()=>!It.value&&!Lt.value&&Rt.value.length===0);return()=>e()?(()=>{var e=xp();return c(e,()=>k.value.noSuggestions),_(()=>f(e,$.empty)),e})():null})(),null),_(()=>f(e,$.suggestions)),e})():null})(),a),c(a,(()=>{var e=l(()=>we.value.text!==``);return()=>e()?g(Re,{get by(){return we.value.at},children:()=>(()=>{var e=bp();return c(e,()=>we.value.text),e})()}):null})()),c(e,(()=>{var e=l(()=>p.name!==void 0);return()=>e()?(()=>{var e=Sp();return _(t=>{var n=p.name,r=p.disabled;return n!==t.e&&d(e,`name`,t.e=n),r!==t.t&&(e.disabled=t.t=r),t},{e:void 0,t:void 0}),_(()=>e.value=he(st.value)),e})():null})(),null),_(n=>{var o=$.root,s=String(p.minRows),c=String(p.maxRows),l=ct.value?``:void 0,u=p.disabled?``:void 0,m=!p.disabled&&dt.value?``:void 0,h=p.invalid||j.value?``:void 0,g=$.frame,_=$.viewport,ee=$.surface,v=gt.value,y=p[`aria-label`],b=p[`aria-labelledby`],x=bn.value,te=p[`aria-required`]===!0?`true`:void 0,ne=p.invalid||j.value?`true`:void 0,re=p.disabled?`true`:void 0,ie=!p.disabled&&dt.value?`true`:void 0,ae=p.disabled?void 0:`0`,oe=xn.value?`list`:void 0,se=xn.value?`listbox`:void 0,S=Sn.value[`aria-controls`],ce=Sn.value[`aria-activedescendant`],le=$.status;return o!==n.e&&f(e,n.e=o),s!==n.t&&d(e,`data-min-rows`,n.t=s),c!==n.a&&d(e,`data-max-rows`,n.a=c),l!==n.o&&d(e,`data-empty`,n.o=l),u!==n.i&&d(e,`data-disabled`,n.i=u),m!==n.n&&d(e,`data-readonly`,n.n=m),h!==n.s&&d(e,`data-invalid`,n.s=h),g!==n.h&&f(t,n.h=g),_!==n.r&&f(r,n.r=_),ee!==n.d&&f(i,n.d=ee),v!==n.l&&d(i,`id`,n.l=v),y!==n.u&&d(i,`aria-label`,n.u=y),b!==n.c&&d(i,`aria-labelledby`,n.c=b),x!==n.w&&d(i,`aria-describedby`,n.w=x),te!==n.m&&d(i,`aria-required`,n.m=te),ne!==n.f&&d(i,`aria-invalid`,n.f=ne),re!==n.y&&d(i,`aria-disabled`,n.y=re),ie!==n.g&&d(i,`aria-readonly`,n.g=ie),ae!==n.p&&d(i,`tabindex`,n.p=ae),oe!==n.b&&d(i,`aria-autocomplete`,n.b=oe),se!==n.T&&d(i,`aria-haspopup`,n.T=se),S!==n.A&&d(i,`aria-controls`,n.A=S),ce!==n.O&&d(i,`aria-activedescendant`,n.O=ce),le!==n.I&&f(a,n.I=le),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0,w:void 0,m:void 0,f:void 0,y:void 0,g:void 0,p:void 0,b:void 0,T:void 0,A:void 0,O:void 0,I:void 0}),e})()})}Cp.controlKind=`group`,p([`keydown`,`pointerdown`,`click`,`focusin`,`focusout`,`mousedown`,`pointermove`]);var wp={tag:`poly-rich-text-input`,member:`RichTextInput`,props:{activeAnnotation:`string`,annotations:`json`,"aria-describedby":`string`,"aria-label":`string`,"aria-labelledby":`string`,"aria-required":`boolean`,autoFocus:`boolean`,cancelLabel:`string`,controlRef:`property`,defaultValue:`json`,disabled:`boolean`,entities:`json`,footer:`property`,formats:`json`,id:`string`,invalid:`boolean`,maxLength:`number`,maxRows:{union:[6,12,`none`,24]},messages:`json`,minRows:`number`,name:`string`,pending:`boolean`,placeholder:`string`,readOnly:`boolean`,selectionActions:`property`,submitLabel:`string`,toolbar:`property`,toolbarPlacement:`string`,value:`json`},events:{onAnnotationSelect:{type:`poly-annotation-select`},onBlur:{type:`poly-blur`},onCancel:{type:`poly-cancel`,listened:!0},onChange:{type:`poly-change`},onFiles:{type:`poly-files`,listened:!0},onFocus:{type:`poly-focus`},onSubmit:{type:`poly-submit`,listened:!0}},slots:[],controlled:{value:`onChange`}},Tp=v(wp,Cp);export{Tp as PolyRichTextInput,wp as definition};
18
+ `:Jf),s=/\S*$/.exec(o),c=s?s[0]:``;if(!c||c.includes(Jf))return null;let l=r.pos-c.length,u=e.schema.marks[Z.link];for(let t of[a,u])if(t&&e.doc.rangeHasMark(l,r.pos,t))return null;for(let{kind:e,trigger:n}of t)if(!(!n||!c.startsWith(n)))return{kind:e,trigger:n,query:c.slice(n.length),from:l,to:r.pos};return null}function Xf(e){return new ri({key:Kf,state:{init:(t,n)=>{let r=Yf(n,e());return{token:r?{...r,key:`1`,dismissed:!1}:null,count:+!!r}},apply:(t,n,r,i)=>{let a=Yf(i,e());if(!a)return n.token?{token:null,count:n.count}:n;let o=n.token,s=o!==null&&t.mapping.map(o.from)===a.from&&o.kind===a.kind,c=t.getMeta(Kf)===qf||s&&o.dismissed;if(s)return{token:{...a,key:o.key,dismissed:c},count:n.count};let l=n.count+1;return{token:{...a,key:String(l),dismissed:c},count:l}}}})}function Zf(){return[Kf,qf]}function Qf(e){return Kf.getState(e)?.token??null}var $f=`polymorphRichTextSilent`,ep=`polymorphRichTextFocus`,tp=`polymorphRichTextApp`;function np(e,t){return t===`start`?V.findFrom(e.resolve(0),1,!0)??V.atStart(e):V.findFrom(e.resolve(e.content.size),-1,!0)??V.atEnd(e)}function rp(e,t){let n=e.resolve(Math.max(0,Math.min(t,e.content.size)));return V.findFrom(n,1,!0)??V.findFrom(n,-1,!0)??V.near(n)}var ip={top:0,bottom:0,left:0,right:0};function ap(e){return new Set(e)}function op(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...n].every(e=>r.has(e))}var sp=e=>e.map(({kind:e,trigger:t})=>JSON.stringify([e,t]));function cp(e){let t=e.element,n=e.headingLevel??2,r=Array.from(t.attributes,e=>[e.name,e.value]),i=[...e.formats],a=[...e.entities],o=e.editable,s=e.readOnly===!0,c=null,l=()=>o&&c===null,u=()=>!l()&&(s||o&&c!==null),d={...e.attributes},f=e.placeholder,p={drawn:e.annotations===void 0?void 0:[...e.annotations],active:e.activeAnnotation,className:e.classes.annotation},m={onChange:e.onChange,onState:e.onState,onEvent:e.onEvent,onSubmit:e.onSubmit,onLinkRequest:e.onLinkRequest,onSuggestionKey:e.onSuggestionKey,onFiles:e.onFiles,onFocus:e.onFocus,onBlur:e.onBlur},h=t.ownerDocument.activeElement===t,g=null,_=null,ee=null,v=!1,y=!1,b,x,te,ne=null,re=null,ie=e=>rt(Ce(e)?ye(e).value:e,i),ae=e=>{if(ne!==null&&ne.doc===e)return ne;let t=Xd(e),n=Se(t,{blockSeparator:``});return ne={doc:e,value:t,text:JSON.stringify(t),length:ke(n),empty:n.trim()===``&&be(t).length===0},ne},oe=e=>{let t=[],n=e.doc.firstChild;f&&n&&e.doc.childCount===1&&n.isTextblock&&n.content.size===0&&t.push(uc.node(0,n.nodeSize,{"data-placeholder":f}));let r=e.selection;return r instanceof U&&r.node.isAtom&&t.push(uc.node(r.from,r.to,{"data-selected":``})),t.length?pc.create(e.doc,t):null},se=new ri({props:{handleDOMEvents:{focus:e=>(v||h||(h=!0,e.dispatch(e.state.tr.setMeta(ep,!0)),m.onFocus?.()),!1),blur:e=>(v||h&&(h=!1,e.dispatch(e.state.tr.setMeta(ep,!1)),m.onBlur?.()),!1),compositionend:()=>(Promise.resolve().then(De),!1),click:(e,t)=>(t.target?.closest?.(`a`)&&t.preventDefault(),!1),auxclick:(e,t)=>(t.target?.closest?.(`a`)&&t.preventDefault(),!1),beforeinput:(e,t)=>{let n=t.inputType??``;return n.startsWith(`format`)?(t.preventDefault(),!0):n===`historyUndo`||n===`historyRedo`?(t.preventDefault(),(n===`historyUndo`?pd:md)(e.state,e.dispatch,e),!0):!1}}}}),S=(e,t)=>u()?(t.preventDefault(),!0):!1,ce=(e,t)=>u()?(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect=`none`),!0):!1,le=new ri({filterTransaction:e=>{if(!u()||!e.docChanged)return!0;let t=e.getMeta(`appendedTransaction`)??e;return t.getMeta(tp)===!0||t.getMeta($f)===!0},props:{handleDOMEvents:{beforeinput:S,paste:S,cut:S,drop:S,dragover:ce,dragenter:ce},handleTextInput:(e,t,n,r)=>{let i=e.state.selection;if(r===``||!(i instanceof U)||i.node.type.name!==X.unknownBlock)return!1;let a=e.state.schema.nodes[X.paragraph];if(a===void 0)return!1;let o=i.to,s=e.state.tr.insert(o,a.create(null,e.state.schema.text(r)));return s.setSelection(H.create(s.doc,o+1+r.length)),e.dispatch(s.scrollIntoView()),!0}}}),ue=()=>[le,..._f(b,i,{suggestionOpen:()=>g?.suggestion!==null&&g?.suggestion!==void 0,onSuggestionKey:()=>m.onSuggestionKey,onSubmit:()=>m.onSubmit,onLinkRequest:()=>m.onLinkRequest,readOnly:u}),Vf(b),Sf(),Ti(),Xf(()=>a),If(b,{onFiles:()=>m.onFiles}),se,Hl(()=>p)],de=t=>{b=bl({formats:i,entities:a,classes:e.classes,headingLevel:n}),x=ap(i),te=Hf(b),c=Ce(t)?t:null;let r=Hd(b,ie(t));return ae(r),ti.create({schema:b,doc:r,selection:np(r,`start`),plugins:ue()})},fe=()=>c??ae(w.state.doc).value,C=e=>{let t=Qf(e);if(!t||t.dismissed||!h||!l())return null;let n=ip;try{let e=w.coordsAtPos(t.from,1);n={top:e.top,bottom:e.bottom,left:e.left,right:e.right}}catch{}return{kind:t.kind,trigger:t.trigger,query:t.query,key:t.key,rect:n}},pe=()=>{let{empty:e,length:t}=ae(w.state.doc);return Wf(w.state,x,te,{empty:e,length:t,focused:h,suggestion:C(w.state)})},me=()=>{if(y)return;let e=pe();Gf(g,e)||(g=e,m.onState?.(e))},he=(e,t,n)=>{let r=m.onEvent;if(!r)return;if(e.type!==`toggle`){r(e);return}let i=Uf(t)[e.format],a=Uf(n)[e.format];i!==a&&r({type:`format`,format:e.format,active:!!a})},ge=e=>{if(y)return;let t=w.state,n=e.getMeta($f)===!0,r=t.apply(e);w.updateState(r);let i=r.doc!==t.doc;if(i&&!n&&c===null){let e=ae(t.doc).text,n=ae(r.doc);n.text!==e&&m.onChange?.(n.value)}me();let a=e.getMeta(Ku);a&&!n&&(i||a.type===`toggle`)&&he(a,t,r),(_||ee)&&!w.composing&&Promise.resolve().then(De)},_e=()=>{let e={};for(let[t,n]of Object.entries(d))n!==void 0&&t!==`contenteditable`&&t!==`class`&&(e[t]=n);return h&&(e[`data-focused`]=``),u()&&(e.inputmode=`none`,e.spellcheck=`false`),e},ve=()=>{for(let[e,n]of Object.entries(d))n===void 0&&t.removeAttribute(e)},xe=de(e.value),w=new Hc({mount:t},{state:xe,editable:()=>o||u(),attributes:_e,decorations:oe,dispatchTransaction:ge});ve(),g=pe();let we=e=>{let t=w.state.doc;if(Yl(t,e)){let t=w.state.tr;if(ql(t,e),t.doc.eq(e)){w.dispatch(t.setMeta(`addToHistory`,!1).setMeta($f,!0));return}}let n=t.content.findDiffStart(e.content);if(n===null)return;let r=t.content.findDiffEnd(e.content),i=r?r.a:t.content.size,a=r?r.b:e.content.size,o=n-Math.min(i,a);o>0&&(i+=o,a+=o);let s=w.state.tr.replace(n,i,e.slice(n,a));s.doc.eq(e)||(s=w.state.tr.replaceWith(0,t.content.size,e.content)),s.setMeta(`addToHistory`,!1).setMeta($f,!0),w.dispatch(s)},Te=e=>{let t=ae(w.state.doc),n=re?.input===e&&re.doc===w.state.doc;if(c===null?e===t.value||n:e===c){re={input:e,doc:w.state.doc};return}let r=c!==null;c=Ce(e)?e:null;let i=Hd(b,ie(e));JSON.stringify(Xd(i))!==t.text&&we(i),re={input:e,doc:w.state.doc},r!==(c!==null)&&(w.setProps({}),me())},Ee=e=>{let t=Qf(w.state),n=t&&!t.dismissed?{from:t.from,to:t.to}:null;je(fd(b,e,n))};function De(){if(!(y||w.composing)){if(_){let e=_;_=null,Te(e)}if(ee){let e=ee;ee=null,Ee(e)}me()}}let Oe=()=>{if(t.ownerDocument.activeElement===t){v=!0;try{t.blur(),t.focus({preventScroll:!0})}finally{v=!1}}},Ae=()=>{let e=fe(),{from:t,to:n}=w.state.selection,r=de(e),i=r;try{let e=n<=r.doc.content.size&&t!==n?H.between(r.doc.resolve(t),r.doc.resolve(n)):rp(r.doc,t);i=r.apply(r.tr.setSelection(e))}catch{i=r}w.updateState(i),me()},je=e=>!y&&c===null&&e(w.state,e=>w.dispatch(e.setMeta(tp,!0)));return{getValue:()=>fe(),setValue(e){if(!y){if(w.composing){_=e;return}Te(e)}},getState:()=>g??pe(),update(e){if(y)return;let{formats:t,entities:n,editable:r}=e;for(let t of Object.keys(e))t.startsWith(`on`)&&(m[t]=e[t]);if(e.attributes!==void 0&&(d={...e.attributes}),`placeholder`in e&&(f=e.placeholder),r!==void 0&&(o=r),`readOnly`in e&&(s=e.readOnly===!0),`annotations`in e||`activeAnnotation`in e){let t=`annotations`in e?e.annotations:p.drawn,n=`activeAnnotation`in e?e.activeAnnotation:p.active;(JSON.stringify(t)!==JSON.stringify(p.drawn)||n!==p.active)&&(p={...p,drawn:t===void 0?void 0:[...t],active:n})}let c=t!==void 0&&!op(t,i)||n!==void 0&&!op(sp(n),sp(a));t!==void 0&&(i=[...t]),n!==void 0&&(a=[...n]),c?Ae():w.setProps({}),ve(),me()},focus(e){y||(e&&w.dispatch(w.state.tr.setSelection(np(w.state.doc,e))),o||u()?w.focus():t.focus({preventScroll:!0}))},toggle(e){return x.has(e)?je(te[e]):!1},setHeading(e){return(e===0?!x.has(`heading`)&&!x.has(`codeBlock`):!x.has(`heading`))?!1:je(od(b,e))},setLink(e){return x.has(`link`)?je(ud(b,e)):!1},undo:()=>je(pd),redo:()=>je(md),insertText(e){je(dd(e))},insertEntity(e){if(!(y||c!==null)){if(w.composing){ee=e,Oe();return}Ee(e)}},annotate:e=>je(Ul(e)),removeAnnotation:e=>je(Wl(e)),selectionRect:()=>y?null:Xl(w),tokenRect:()=>y?null:C(w.state)?.rect??null,dismissSuggestion(){let e=Qf(w.state);if(y||!e||e.dismissed)return;let[t,n]=Zf();w.dispatch(w.state.tr.setMeta(t,n))},clear(){if(y||c!==null||Yd(w.state.doc))return;let e=b.nodes[X.paragraph].create(),t=w.state.tr.replaceWith(0,w.state.doc.content.size,e);t.setSelection(H.create(t.doc,1)),w.dispatch(t.scrollIntoView().setMeta(tp,!0))},destroy(){if(y)return;y=!0,w.destroy();let e=new Map(r);for(let n of Array.from(t.attributes,e=>e.name))e.has(n)||t.removeAttribute(n);for(let[n,r]of e)t.getAttribute(n)!==r&&t.setAttribute(n,r);t.replaceChildren()}}}var $={root:`_root_16vqy_24`,frame:`_frame_16vqy_32 _stateFeedback_lkjqs_17`,toolbar:`_toolbar_16vqy_50`,controls:`_controls_16vqy_59`,group:`_group_16vqy_69`,slot:`_slot_16vqy_75`,viewport:`_viewport_16vqy_87`,surface:`_surface_16vqy_97 _root_1q2y5_16 _root_z92xs_10`,paragraph:`_paragraph_16vqy_177 _text_jx0r4_6`,heading1:`_heading1_16vqy_182 _heading_13374_6`,heading2:`_heading2_16vqy_191 _heading_13374_6`,heading3:`_heading3_16vqy_200 _heading_13374_6`,list:`_list_16vqy_209 _list_1q2y5_20 _list_z92xs_21`,item:`_item_16vqy_213 _item_1q2y5_24 _item_z92xs_31`,quote:`_quote_16vqy_217 _quote_1q2y5_28 _quote_z92xs_44`,codeBlock:`_codeBlock_16vqy_221 _block_1j1lk_6 _focusRing_1hr3n_49`,code:`_code_16vqy_221 _code_hc07h_7`,link:`_link_16vqy_231 _link_1pcjq_13 _focusAround_1hr3n_95`,entity:`_entity_16vqy_237 _entity_1q2y5_53`,unknown:`_unknown_16vqy_242`,annotation:`_annotation_16vqy_257 _annotation_1q2y5_76`,footer:`_footer_16vqy_263`,actions:`_actions_16vqy_271`,count:`_count_16vqy_281`,suggestions:`_suggestions_16vqy_316 _suggestions_1o6qu_156`,listbox:`_listbox_16vqy_348 _listbox_1o6qu_189`,option:`_option_16vqy_352 _option_1o6qu_202 _stateFeedback_lkjqs_17`,glyph:`_glyph_16vqy_356 _glyph_1o6qu_223 _stateFeedback_lkjqs_17`,leading:`_leading_16vqy_361`,text:`_text_16vqy_367 _text_1o6qu_231`,label:`_label_16vqy_371 _label_1o6qu_238`,description:`_description_16vqy_375 _description_1o6qu_245 _stateFeedback_lkjqs_17`,rows:`_rows_16vqy_379 _rows_1o6qu_268`,row:`_row_16vqy_379 _row_1o6qu_268`,empty:`_empty_16vqy_387 _empty_1o6qu_282`,error:`_error_16vqy_392 _empty_1o6qu_282`,status:`_status_16vqy_398 _visuallyHidden_qxi8b_14`,linkForm:`_linkForm_16vqy_403`,linkActions:`_linkActions_16vqy_410`},lp=o(`<div data-member=rich-text-input><div><div><div data-rich-text-input-part=surface role=textbox aria-multiline=true></div></div></div><div role=status aria-live=polite>`),up=o(`<div role=toolbar data-rich-text-input-part=toolbar>`),dp=o(`<div><div>`),fp=o(`<div>`),pp=o(`<form><div>`),mp=o(`<div role=toolbar><div>`),hp=o(`<p>`),gp=o(`<div data-rich-text-input-part=suggestions>`),_p=o(`<ul role=listbox>`),vp=o(`<li role=option><span><span>`),yp=o(`<span aria-hidden=true>`),bp=o(`<span>`),xp=o(`<div aria-hidden=true>`),Sp=o(`<input type=hidden>`);function Cp(o){let p=ee({entities:[],minRows:3,maxRows:12,invalid:!1,disabled:!1,readOnly:!1,autoFocus:!1,pending:!1,toolbarPlacement:`fixed`},x(o,`group`));return s(()=>{let o=i(()=>p.entities),s=m(),v=t(),x=t(),ie=t(),se=t(),S=t(),C=t(),ve=t(),ye=a(()=>p.controlRef),be=e(p.defaultValue??Ae()),xe=e(p.defaultValue??Ae()),w=e(null),we=e({text:``,at:0}),Ee=e({key:``,index:0}),Oe=e(null),ke=e(null),Pe=e(null),Ie=e(!1),Je=e(``),Ye=e(void 0),Ze=e(null),et=e(!1),tt=e(!1),nt=e(!1),rt=e(!1),it=e(!1),D=e(!1),at=e(null),ot=e(!1),O=r(()=>({editor:null,handle:null,lastValue:void 0,saidNow:!1})),k=r(()=>({toolbar:`Formatting`,selectionBar:`Selection`,selectionBarReady:`Controls for the selection are available: Alt+F10`,bold:`Bold`,italic:`Italic`,strike:`Strikethrough`,code:`Code`,link:`Link`,textStyle:`Text style`,paragraph:`Paragraph`,heading:e=>`Heading ${e}`,bulletList:`Bulleted list`,orderedList:`Numbered list`,blockquote:`Quote`,codeBlock:`Code block`,undo:`Undo`,redo:`Redo`,linkForm:`Link`,linkAddress:`Address`,linkApply:`Apply`,linkRemove:`Remove link`,linkInvalid:`Enter a web address, an email address or a phone number.`,formatOn:e=>`${e} on`,formatOff:e=>`${e} off`,linkAdded:`Link added`,linkRemoved:`Link removed`,inserted:e=>`${e} inserted`,undone:`Undone`,redone:`Redone`,count:(e,t)=>`${e} / ${t}`,overLimit:e=>`${e} ${e===1?`character`:`characters`} over the limit`,withinLimit:`Within the limit`,submitEmpty:`There is nothing to submit yet.`,submitOverLimit:e=>`Remove ${e} ${e===1?`character`:`characters`} to submit.`,submitPending:`Still saving.`,suggestions:e=>e===1?`1 suggestion`:`${e} suggestions`,loadingSuggestions:`Loading suggestions…`,noSuggestions:`No results`,...p.messages===void 0?{}:Object.fromEntries(Object.entries(p.messages).filter(([,e])=>e!==void 0))})),st=r(()=>p.value??be.value),ct=r(()=>je(st.value)),lt=r(()=>Ne(st.value)),A=r(()=>p.maxLength===void 0?0:Math.max(0,lt.value-p.maxLength)),j=r(()=>A.value>0),ut=r(()=>Ce(st.value)),dt=r(()=>p.readOnly||p.pending||ut.value),M=r(()=>p.disabled||dt.value),ft=r(()=>!M.value),N=r(()=>Fe.filter(e=>(p.formats??Fe).includes(e))),P=r(()=>e=>N.value.includes(e)),pt=r(()=>o.value.map(e=>({kind:e.kind,trigger:e.trigger}))),mt=r(()=>[[`bold`,`bold`],[`italic`,`italic`],[`strike`,`strikethrough`],[`code`,`code`]].filter(([e])=>P.value(e)).map(([e,t])=>({format:e,icon:t}))),ht=r(()=>[[`bulletList`,`list-bulleted`],[`orderedList`,`list-numbered`],[`blockquote`,`quote`],[`codeBlock`,`code-block`]].filter(([e])=>P.value(e)).map(([e,t])=>({format:e,icon:t}))),gt=r(()=>p.id??`${s}-surface`),_t=r(()=>`${s}-suggestions`),vt=r(()=>`${s}-count`),yt=r(()=>w.value?.active),F=r(()=>w.value?.can),bt=r(()=>({empty:w.value?.collapsed??!0,text:w.value?.selectedText??``,range:w.value?.range??{start:0,end:0}})),xt=r(()=>()=>O.value.editor?.focus()),St=r(()=>e=>{we.value={text:e,at:we.value.at+1},O.value.saidNow=!0,queueMicrotask(()=>{O.value.saidNow=!1})}),Ct=r(()=>e=>e===`heading`?k.value.textStyle:k.value[e]),wt=r(()=>e=>{e.type===`format`?St.value((e.active?k.value.formatOn:k.value.formatOff)(Ct.value(e.format))):e.type===`heading`?St.value(e.level===0?k.value.paragraph:k.value.heading(e.level)):e.type===`link`?St.value(e.active?k.value.linkAdded:k.value.linkRemoved):e.type===`entity`?St.value(k.value.inserted(e.entity.label)):e.type===`undo`?St.value(k.value.undone):St.value(k.value.redone)}),Tt=r(()=>e=>{if(!ut.value){if(p.maxLength!==void 0){let t=Ne(st.value)>p.maxLength,n=Math.max(0,Ne(e)-p.maxLength);!t&&n>0?St.value(k.value.overLimit(n)):t&&n===0&&St.value(k.value.withinLimit)}be.value=e,p.onChange?.(e)}}),Et=r(()=>(e,t)=>{e.setValue(t),Tt.value(e.getValue())}),Dt=r(()=>()=>{let e=O.value.editor;e===null||he(e.getValue())===he(xe.value)||Et.value(e,xe.value)}),Ot=r(()=>()=>{p.value===void 0&&O.value.lastValue!==void 0&&(be.value=O.value.lastValue),O.value.lastValue=p.value}),kt=r(()=>new Intl.Collator(void 0,{usage:`search`,sensitivity:`base`})),At=r(()=>ft.value?w.value?.suggestion??null:null),jt=r(()=>(e=>e===null?void 0:o.value.find(t=>t.kind===e.kind))(At.value)),Mt=r(()=>At.value!==null&&jt.value!==void 0),Nt=r(()=>At.value?.query??``),Pt=r(()=>Nt.value.normalize(`NFC`)),Ft=r(()=>e=>(e=>Pt.value===``||(jt.value?.filter===`startsWith`?kt.value.compare(e.slice(0,Pt.value.length),Pt.value)===0:Array.from({length:Math.max(0,e.length-Pt.value.length+1)},(t,n)=>e.slice(n,n+Pt.value.length)).some(e=>kt.value.compare(e,Pt.value)===0)))(e.normalize(`NFC`))),It=r(()=>Mt.value&&jt.value?.loading===!0),Lt=r(()=>Mt.value&&!It.value&&jt.value?.error!==void 0&&jt.value.error!==``),Rt=r(()=>!Mt.value||Lt.value||jt.value===void 0?[]:jt.value.filter===!1?jt.value.options:jt.value.options.filter(e=>Ft.value(e.label))),zt=r(()=>Mt.value&&At.value!==null?`${At.value.key}:${Nt.value}`:``),Bt=r(()=>Rt.value.length===0?-1:Ee.value.key===zt.value?Math.min(Ee.value.index,Rt.value.length-1):0),Vt=r(()=>Mt.value?It.value?k.value.loadingSuggestions:Lt.value?jt.value?.error??``:Rt.value.length===0?k.value.noSuggestions:k.value.suggestions(Rt.value.length):null),Ht=r(()=>e=>{let t=Rt.value[e],n=O.value.editor,r=jt.value;t===void 0||r===void 0||n===null||(Oe.value=null,n.insertEntity({kind:r.kind,id:t.id,label:t.entityLabel??r.trigger+t.label}))}),Ut=r(()=>e=>Mt.value?e===`ArrowDown`||e===`ArrowUp`?Rt.value.length===0?!1:(Ee.value={key:zt.value,index:e===`ArrowDown`?Math.min(Bt.value+1,Rt.value.length-1):Math.max(Bt.value-1,0)},!0):e===`Enter`?Bt.value===-1?It.value:(Ht.value(Bt.value),!0):e===`Tab`?Bt.value===-1?!1:(Ht.value(Bt.value),!0):(O.value.editor?.dismissSuggestion(),!0):!1),Wt=r(()=>e=>p.annotations===void 0||p.annotations.includes(e)),Gt=r(()=>e=>{w.value=e;let t=e.suggestion,n=t===null?void 0:o.value.find(e=>e.kind===t.kind),r=t===null||n===void 0?null:t.key+`:`+t.query;r!==Oe.value&&(Oe.value=r,t!==null&&r!==null&&n?.onQueryChange?.(t.query));let i=e.collapsed?e.annotations.find(e=>Wt.value(e))??null:null;i!==null&&i!==ke.value&&(Pe.value!==null&&(Pe.value={entered:i}),p.onAnnotationSelect?.(i)),ke.value=i}),I=r(()=>(e=>{let t=O.value.handle;return t!==null&&t.value===e.value&&t.empty===e.empty&&t.length===e.length&&t.overLimit===e.overLimit&&t.disabled===e.disabled&&t.selection.empty===e.selection.empty&&t.selection.text===e.selection.text&&t.selection.range.start===e.selection.range.start&&t.selection.range.end===e.selection.range.end?t:(O.value.handle=e,e)})({focus:()=>O.value.editor?.focus(),clear:()=>O.value.editor?.clear(),insertText:e=>O.value.editor?.insertText(e),insertEntity:e=>O.value.editor?.insertEntity(e),annotate:e=>O.value.editor?.annotate(e)??!1,removeAnnotation:e=>O.value.editor?.removeAnnotation(e)??!1,value:st.value,empty:ct.value,length:lt.value,overLimit:j.value,disabled:M.value,selection:bt.value})),Kt=r(()=>()=>{if(!(p.onSubmit===void 0||p.disabled)){if(p.pending)return St.value(k.value.submitPending);if(ct.value)return St.value(k.value.submitEmpty);if(j.value)return St.value(k.value.submitOverLimit(A.value));p.onSubmit?.(O.value.editor?.getValue()??st.value,I.value)}}),qt=r(()=>e=>{if(e){let e=O.value.editor?.getState().active.link??null;Je.value=e??``,Ye.value=void 0,Ze.value=e}Ie.value=e}),Jt=r(()=>e=>{e.preventDefault(),e.stopPropagation();let t=Je.value.trim(),n=O.value.editor;if(t===``||ge(t,{typed:!0})===null||n===null||!n.setLink(t)){Ye.value=k.value.linkInvalid;return}Ie.value=!1}),Yt=r(()=>()=>{O.value.editor?.setLink(null),Ie.value=!1}),Xt=r(()=>()=>{let e=O.value.editor,t=p.toolbarPlacement===`fixed`||L.value;e===null||!ft.value||!e.getState().can.link||!t||qt.value(!0)}),Zt=r(()=>yt.value===void 0?0:yt.value.codeBlock?-1:yt.value.heading),Qt=r(()=>[0,1,2,3].map(e=>({kind:`checkbox`,label:e===0?k.value.paragraph:k.value.heading(e),checked:Zt.value===e,onCheckedChange:()=>en.value(e)}))),$t=r(()=>e=>{e&&(tt.value=nt.value),et.value=e}),en=r(()=>e=>{O.value.editor?.setHeading(e),et.value=!1}),tn=r(()=>e=>{let t=C.value?.ownerDocument.defaultView;t?.requestAnimationFrame(()=>t.requestAnimationFrame(e))}),nn=r(()=>()=>{let e=se.value?.closest(`[data-member="popover"]`)??null;tn.value(()=>{let t=C.value?.ownerDocument,n=t?.activeElement??null;(n===null||n===t?.body||C.value?.contains(n)===!0||e?.contains(n)===!0)&&O.value.editor?.focus()})}),rn=r(()=>()=>{tt.value&&tn.value(()=>O.value.editor?.focus())}),an=r(()=>p.toolbarPlacement===`selection`&&ft.value&&N.value.length>0),on=r(()=>p.selectionActions!==void 0&&!p.disabled),sn=r(()=>`${bt.value.range.start}:${bt.value.range.end}`),cn=r(()=>an.value&&(Ie.value||et.value)),L=r(()=>(an.value||on.value)&&w.value!==null&&!w.value.collapsed&&(rt.value||it.value||cn.value)&&!D.value&&at.value!==sn.value),ln=r(()=>()=>Mt.value?(O.value.editor?.dismissSuggestion(),!0):L.value?(at.value=sn.value,!0):!1),un=r(()=>e=>{let t=e.ownerDocument.defaultView,n=t=>{t.key!==`Escape`||t.isComposing||t.target!==e||ln.value()&&t.preventDefault()};return t?.addEventListener(`keydown`,n,!0),()=>t?.removeEventListener(`keydown`,n,!0)}),dn=r(()=>(e,t)=>{let n=e.ownerDocument.defaultView;return n===null?()=>{}:pe(n,t)}),fn=r(()=>e=>{let t=e.ownerDocument.defaultView,n=()=>{D.value=!1};return t?.addEventListener(`pointerup`,n,!0),t?.addEventListener(`pointercancel`,n,!0),()=>{t?.removeEventListener(`pointerup`,n,!0),t?.removeEventListener(`pointercancel`,n,!0)}}),pn=r(()=>Mt.value||L.value),mn=r(()=>_e()),hn=r(()=>_e()),gn=r(()=>()=>Te(x.value,O.value.editor?.selectionRect(),ye.value)),_n=r(()=>()=>{Le(x.value,hn.value)&&O.value.editor?.focus()}),vn=r(()=>()=>de(S.value,C.value,O.value.editor?.tokenRect()??At.value?.rect)),yn=r(()=>e=>`${s}-suggestion-${ne(e.id)}`),bn=r(()=>[p[`aria-describedby`],p.maxLength===void 0?void 0:vt.value].filter(e=>e!==void 0).join(` `)||void 0),xn=r(()=>o.value.length>0),Sn=r(()=>({id:gt.value,role:`textbox`,"aria-multiline":`true`,"aria-label":p[`aria-label`],"aria-labelledby":p[`aria-labelledby`],"aria-describedby":bn.value,"aria-required":p[`aria-required`]===!0?`true`:void 0,"aria-invalid":p.invalid||j.value?`true`:void 0,"aria-disabled":p.disabled?`true`:void 0,"aria-readonly":!p.disabled&&dt.value?`true`:void 0,tabindex:p.disabled?void 0:`0`,"aria-autocomplete":xn.value?`list`:void 0,"aria-haspopup":xn.value?`listbox`:void 0,"aria-controls":Mt.value&&Rt.value.length>0?_t.value:void 0,"aria-activedescendant":(e=>Mt.value&&e!==void 0?yn.value(e):void 0)(Bt.value===-1?void 0:Rt.value[Bt.value])})),Cn=r(()=>JSON.stringify([N.value,pt.value,ft.value,!p.disabled&&dt.value,Sn.value,p.placeholder??null,p.annotations??null,p.activeAnnotation??null,p.onSubmit!==void 0,p.onFiles!==void 0])),wn=r(()=>()=>({formats:N.value,entities:pt.value,editable:ft.value,readOnly:!p.disabled&&dt.value,attributes:Sn.value,placeholder:p.placeholder,annotations:p.annotations,activeAnnotation:p.activeAnnotation,onSubmit:p.onSubmit===void 0?void 0:()=>Kt.value(),onFiles:p.onFiles===void 0?void 0:e=>p.onFiles?.(e)})),Tn=r(()=>e=>{let t=cp({element:e,value:st.value,formats:N.value,entities:pt.value,classes:{paragraph:$.paragraph??``,heading:[$.heading1??``,$.heading2??``,$.heading3??``],bulletList:$.list??``,orderedList:$.list??``,listItem:$.item??``,blockquote:$.quote??``,codeBlock:$.codeBlock??``,codeBlockText:``,bold:``,italic:``,strike:``,code:$.code??``,link:$.link??``,entity:$.entity??``,annotation:$.annotation??``,unknown:$.unknown??``},editable:ft.value,readOnly:!p.disabled&&dt.value,attributes:Sn.value,placeholder:p.placeholder,annotations:p.annotations,activeAnnotation:p.activeAnnotation,onChange:e=>Tt.value(e),onState:e=>Gt.value(e),onEvent:e=>wt.value(e),onSubmit:p.onSubmit===void 0?void 0:()=>Kt.value(),onLinkRequest:()=>Xt.value(),onSuggestionKey:e=>Ut.value(e),onFiles:p.onFiles===void 0?void 0:e=>p.onFiles?.(e)});return O.value.editor=t,Gt.value(t.getState()),p.autoFocus&&t.focus(`end`),()=>{t.destroy(),O.value.editor=null}}),En=r(()=>(e,t)=>{let n=O.value.editor;n!==null&&(t(n),e.detail>0&&n.focus())}),Dn=r(()=>e=>{!e.altKey||e.key!==`F10`||(e.preventDefault(),L.value?fe(x.value,hn.value):Pn.value&&fe(ve.value,mn.value))}),On=r(()=>()=>{Pe.value={entered:null},(p.selectionActions!==void 0||an.value)&&(D.value=!0)}),kn=r(()=>e=>{let t=Pe.value;Pe.value=null;let n=(e.target instanceof Element?e.target:null)?.closest(`[data-annotation-id]`)?.getAttribute(`data-annotation-id`);n==null||!Wt.value(n)||O.value.editor?.getState().collapsed===!1||p.disabled||(ke.value=n,t?.entered!==n&&p.onAnnotationSelect?.(n))}),An=r(()=>e=>{let t=e.relatedTarget;t instanceof Node&&x.value?.contains(t)===!0&&(it.value=!0),rt.value=!1}),jn=r(()=>e=>{let t=e.relatedTarget;t instanceof Node&&ye.value?.contains(t)===!0&&(rt.value=!0),(!(t instanceof Node)||!e.currentTarget.contains(t))&&(it.value=!1),t===null&&!L.value&&_n.value()}),Mn=r(()=>e=>Qe(e,{panels:()=>[se.value?.closest(`[data-member="popover"]`)??null],entered:()=>{ot.value=!1,p.onFocus?.()},left:()=>p.onBlur?.()})),Nn=r(()=>p.toolbarPlacement===`fixed`),Pn=r(()=>Nn.value||p.toolbar!==void 0),Fn=r(()=>p.footer===void 0&&p.submitLabel!==void 0&&p.onSubmit!==void 0),In=r(()=>p.footer!==void 0||Fn.value),Ln=Ve(()=>L.value,()=>x.value),R;b(()=>{R?.();let e=C.value?Mn.value(C.value):()=>{};R=()=>{e()}}),y(()=>R?.());let z;b(()=>{z?.();let e=ye.value?Tn.value(ye.value):()=>{};z=()=>{e()}}),y(()=>z?.());let Rn;b(()=>{Rn?.();let e=C.value?$e(C.value,()=>Dt.value()):()=>{};Rn=()=>{e()}}),y(()=>Rn?.());let zn;T(u(()=>p[`aria-labelledby`]),()=>{zn?.();let e=ye.value?Xe(ye.value,()=>O.value.editor?.focus(),()=>!p.disabled):()=>{};zn=()=>{e()}},!0),y(()=>zn?.()),T(u(()=>p.value),()=>{Ot.value()},!0),T(u(()=>Cn.value),()=>{O.value.editor?.update(wn.value())},!1),T(u(()=>[p.value,be.value]),()=>{p.value===void 0||O.value.editor?.setValue(p.value)},!1),T(u(()=>Vt.value),()=>{Vt.value===null||St.value(Vt.value)},!0),T(u(()=>[At.value,Rt.value.length,It.value,Lt.value]),()=>{vn.value()},!0);let Bn;T(u(()=>Mt.value),()=>{Bn?.();let e=Mt.value&&S.value?ae(S.value,vn.value):()=>{};Bn=()=>{e()}},!0),y(()=>Bn?.());let Vn;T(u(()=>pn.value),()=>{Vn?.();let e=pn.value&&ye.value?un.value(ye.value):()=>{};Vn=()=>{e()}},!0),y(()=>Vn?.());let Hn;T(u(()=>D.value),()=>{Hn?.();let e=D.value&&C.value?fn.value(C.value):()=>{};Hn=()=>{e()}},!0),y(()=>Hn?.());let Un;T(u(()=>Pn.value),()=>{Un?.();let e=()=>{ce(ve.value,mn.value)},t=typeof MutationObserver>`u`?void 0:new MutationObserver(e);for(let e of[ve.value])e&&t?.observe(e,{childList:!0,characterData:!0,subtree:!0,attributeFilter:[`disabled`,`aria-disabled`,`hidden`,`inert`]});Un=()=>{t?.disconnect()},e()},!0),y(()=>Un?.());let Wn;T(u(()=>Pn.value),()=>{Wn?.();let e=Pn.value&&ve.value?dn.value(ve.value,()=>ve.value):()=>{};Wn=()=>{e()}},!0),y(()=>Wn?.());let Gn;T(u(()=>Ln()),()=>{Gn?.();let e=()=>{ce(x.value,hn.value)},t=typeof MutationObserver>`u`?void 0:new MutationObserver(e);for(let e of[x.value])e&&t?.observe(e,{childList:!0,characterData:!0,subtree:!0,attributeFilter:[`disabled`,`aria-disabled`,`hidden`,`inert`]});Gn=()=>{t?.disconnect()},e()},!0),y(()=>Gn?.());let B;T(u(()=>Ln()),()=>{B?.();let e=Ln()&&x.value?dn.value(x.value,()=>x.value):()=>{};B=()=>{e()}},!0),y(()=>B?.()),T(u(()=>[L.value,w.value]),()=>{L.value&&gn.value()},!0);let Kn;T(u(()=>L.value),()=>{Kn?.();let e=L.value&&x.value?ae(x.value,gn.value):()=>{};Kn=()=>{e()}},!0),y(()=>Kn?.()),T(u(()=>L.value),()=>{L.value||_n.value()},!1),T(u(()=>L.value),()=>{L.value&&!ot.value&&(ot.value=!0,O.value.saidNow||St.value(k.value.selectionBarReady))},!0),T(u(()=>[sn.value,bt.value.empty]),()=>{at.value!==null&&(bt.value.empty||at.value!==sn.value)&&(at.value=null)},!1),T(u(()=>Ie.value),()=>{Ie.value||nn.value()},!1),T(u(()=>et.value),()=>{et.value||rn.value()},!1);let qn;return b(()=>{qn?.();let e=re({member:`RichTextInput`,element:()=>ye.value,state:()=>({value:Se(st.value),disabled:p.disabled,invalid:p.invalid||j.value,readonly:dt.value,empty:ct.value}),actions:{fill:{argument:`text`,run:e=>(()=>{if(ut.value)throw Error(`The document is of a later format than this field writes.`);if(dt.value)throw Error(`The field is read-only.`);let t=O.value.editor;if(t===null)throw Error(`The field is not ready.`);Et.value(t,De(e))})()},clear:()=>(()=>{if(ut.value)throw Error(`The document is of a later format than this field writes.`);if(dt.value)throw Error(`The field is read-only.`);let e=O.value.editor;if(e===null)throw Error(`The field is not ready.`);e.clear()})(),submit:()=>(()=>{if(p.onSubmit===void 0)throw Error(`The field has no submit.`);if(p.pending)throw Error(`The app is saving; wait for it to finish.`);if(ct.value)throw Error(`The field is empty, and an empty field is not submitted.`);if(j.value)throw Error(`The text is ${A.value} characters over the limit.`);p.onSubmit?.(O.value.editor?.getValue()??st.value,I.value)})()},withholds:()=>[ie.value,v.value,x.value,se.value?.closest(`[data-member="popover"]`)??null]});qn=()=>{e()}}),y(()=>qn?.()),(()=>{var e=lp(),t=e.firstChild,r=t.firstChild,i=r.firstChild,a=t.nextSibling,o=C.attach;typeof o==`function`?h(o,e):C.attach=e,c(t,(()=>{var e=l(()=>!!Pn.value);return()=>e()?(()=>{var e=up(),t=ve.attach;return typeof t==`function`?h(t,e):ve.attach=e,e.$$mousedown=e=>oe(e.currentTarget,e),e.$$focusout=e=>ue(e.currentTarget,e,mn.value),e.$$focusin=e=>le(e.currentTarget,e,mn.value),e.$$keydown=e=>me(e.currentTarget,e,mn.value,xt.value),te(e,ee({get class(){return $.toolbar},get"aria-label"(){return k.value.toolbar},get"aria-controls"(){return gt.value}},{"oncapture:click":e=>nt.value=e.detail>0},{"oncapture:keydown":()=>nt.value=!1}),!1,!0),c(e,(()=>{var e=l(()=>!!Nn.value);return()=>e()?(()=>{var e=dp(),t=e.firstChild,n=ie.attach;return typeof n==`function`?h(n,e):ie.attach=e,c(e,(()=>{var e=l(()=>!!(mt.value.length>0||P.value(`link`)));return()=>e()?(()=>{var e=fp();return c(e,g(Be,{get of(){return mt.value},by:e=>e.format,renew:!0,children:e=>g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,get icon(){return e.icon},get label(){return k.value[e.format]},get pressed(){return yt.value?.[e.format]??!1},get disabled(){return M.value||F.value?.[e.format]===!1},onClick:t=>En.value(t,t=>t.toggle(e.format))})}),null),c(e,(()=>{var e=l(()=>!!P.value(`link`));return()=>e()?g(Ge,{get label(){return k.value.linkForm},get open(){return Ie.value},onOpenChange:e=>qt.value(e),get trigger(){return g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,icon:`link`,get label(){return k.value.link},get pressed(){return(yt.value?.link??null)!==null},get disabled(){return M.value||F.value?.link===!1}})},get children(){var e=pp(),t=e.firstChild,n=se.attach;return typeof n==`function`?h(n,e):se.attach=e,e.addEventListener(`submit`,e=>Jt.value(e)),e.noValidate=!0,c(e,g(Ke,{get label(){return k.value.linkAddress},get error(){return Ye.value},get children(){return g(We,{get value(){return Je.value},autoComplete:`off`,onChange:e=>(Je.value=e,Ye.value=void 0)})}}),t),c(t,(()=>{var e=l(()=>Ze.value!==null);return()=>e()?g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,get label(){return k.value.linkRemove},onClick:()=>Yt.value()}):null})(),null),c(t,g(E,{type:`submit`,variant:`solid`,tone:`accent`,size:`sm`,get label(){return k.value.linkApply}}),null),_(n=>{var r=$.linkForm,i=$.linkActions;return r!==n.e&&f(e,n.e=r),i!==n.t&&f(t,n.t=i),n},{e:void 0,t:void 0}),e}}):null})(),null),_(()=>f(e,$.group)),e})():null})(),t),c(e,(()=>{var e=l(()=>!!P.value(`heading`));return()=>e()?[l(()=>l(()=>!!(mt.value.length>0||P.value(`link`)))()?g(He,{orientation:`vertical`}):null),(()=>{var e=fp();return c(e,g(qe,{get open(){return et.value},get items(){return Qt.value},onOpenChange:e=>$t.value(e),get trigger(){return g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,icon:`heading`,get label(){return k.value.textStyle},get disabled(){return M.value||F.value?.heading===!1}})}})),_(()=>f(e,$.group)),e})()]:null})(),t),c(e,(()=>{var e=l(()=>ht.value.length>0);return()=>e()?[l(()=>l(()=>!!(mt.value.length>0||P.value(`link`)||P.value(`heading`)))()?g(He,{orientation:`vertical`}):null),(()=>{var e=fp();return c(e,g(Be,{get of(){return ht.value},by:e=>e.format,renew:!0,children:e=>g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,get icon(){return e.icon},get label(){return k.value[e.format]},get pressed(){return yt.value?.[e.format]??!1},get disabled(){return M.value||F.value?.[e.format]===!1},onClick:t=>En.value(t,t=>t.toggle(e.format))})})),_(()=>f(e,$.group)),e})()]:null})(),t),c(e,(()=>{var e=l(()=>!!(mt.value.length>0||P.value(`link`)||P.value(`heading`)||ht.value.length>0));return()=>e()?g(He,{orientation:`vertical`}):null})(),t),c(t,g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,icon:`undo`,get label(){return k.value.undo},get disabled(){return M.value||F.value?.undo!==!0},onClick:e=>En.value(e,e=>e.undo())}),null),c(t,g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,icon:`redo`,get label(){return k.value.redo},get disabled(){return M.value||F.value?.redo!==!0},onClick:e=>En.value(e,e=>e.redo())}),null),_(n=>{var r=$.controls,i=$.group;return r!==n.e&&f(e,n.e=r),i!==n.t&&f(t,n.t=i),n},{e:void 0,t:void 0}),e})():null})(),null),c(e,(()=>{var e=l(()=>p.toolbar!==void 0);return()=>e()?(()=>{var e=fp();return c(e,()=>p.toolbar?.({focus:I.value.focus,clear:I.value.clear,insertText:I.value.insertText,insertEntity:I.value.insertEntity,annotate:I.value.annotate,removeAnnotation:I.value.removeAnnotation,value:I.value.value,empty:I.value.empty,length:I.value.length,overLimit:I.value.overLimit,disabled:I.value.disabled,selection:I.value.selection})),_(()=>f(e,$.slot)),e})():null})(),null),e})():null})(),r);var s=ye.attach;return typeof s==`function`?h(s,i):ye.attach=i,i.$$focusout=e=>An.value(e),i.$$focusin=()=>rt.value=!0,i.$$click=e=>kn.value(e),i.$$pointerdown=()=>On.value(),i.$$keydown=e=>Dn.value(e),c(t,(()=>{var e=l(()=>!!Ln());return()=>e()?(()=>{var e=mp(),t=e.firstChild,n=x.attach;return typeof n==`function`?h(n,e):x.attach=e,e.$$mousedown=e=>oe(e.currentTarget,e),e.$$focusout=e=>(ue(e.currentTarget,e,hn.value),jn.value(e)),e.$$focusin=e=>(le(e.currentTarget,e,hn.value),it.value=!0),e.$$keydown=e=>me(e.currentTarget,e,hn.value,xt.value),te(t,ee({get class(){return $.controls}},{"oncapture:click":e=>nt.value=e.detail>0},{"oncapture:keydown":()=>nt.value=!1}),!1,!0),c(t,(()=>{var e=l(()=>!!on.value);return()=>e()?(()=>{var e=fp();return c(e,()=>p.selectionActions?.({focus:I.value.focus,clear:I.value.clear,insertText:I.value.insertText,insertEntity:I.value.insertEntity,annotate:I.value.annotate,removeAnnotation:I.value.removeAnnotation,value:I.value.value,empty:I.value.empty,length:I.value.length,overLimit:I.value.overLimit,disabled:I.value.disabled,selection:I.value.selection})),_(()=>f(e,$.group)),e})():null})(),null),c(t,(()=>{var e=l(()=>!!(an.value&&(mt.value.length>0||P.value(`link`))));return()=>e()?[l(()=>l(()=>!!on.value)()?g(He,{orientation:`vertical`}):null),(()=>{var e=fp();return c(e,g(Be,{get of(){return mt.value},by:e=>e.format,renew:!0,children:e=>g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,get icon(){return e.icon},get label(){return k.value[e.format]},get pressed(){return yt.value?.[e.format]??!1},get disabled(){return M.value||F.value?.[e.format]===!1},onClick:t=>En.value(t,t=>t.toggle(e.format))})}),null),c(e,(()=>{var e=l(()=>!!P.value(`link`));return()=>e()?g(Ge,{get label(){return k.value.linkForm},get open(){return Ie.value},onOpenChange:e=>qt.value(e),get trigger(){return g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,icon:`link`,get label(){return k.value.link},get pressed(){return(yt.value?.link??null)!==null},get disabled(){return M.value||F.value?.link===!1}})},get children(){var e=pp(),t=e.firstChild,n=se.attach;return typeof n==`function`?h(n,e):se.attach=e,e.addEventListener(`submit`,e=>Jt.value(e)),e.noValidate=!0,c(e,g(Ke,{get label(){return k.value.linkAddress},get error(){return Ye.value},get children(){return g(We,{get value(){return Je.value},autoComplete:`off`,onChange:e=>(Je.value=e,Ye.value=void 0)})}}),t),c(t,(()=>{var e=l(()=>Ze.value!==null);return()=>e()?g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,get label(){return k.value.linkRemove},onClick:()=>Yt.value()}):null})(),null),c(t,g(E,{type:`submit`,variant:`solid`,tone:`accent`,size:`sm`,get label(){return k.value.linkApply}}),null),_(n=>{var r=$.linkForm,i=$.linkActions;return r!==n.e&&f(e,n.e=r),i!==n.t&&f(t,n.t=i),n},{e:void 0,t:void 0}),e}}):null})(),null),_(()=>f(e,$.group)),e})()]:null})(),null),c(t,(()=>{var e=l(()=>!!(an.value&&P.value(`heading`)));return()=>e()?[l(()=>l(()=>!!(on.value||an.value&&(mt.value.length>0||P.value(`link`))))()?g(He,{orientation:`vertical`}):null),(()=>{var e=fp();return c(e,g(qe,{get open(){return et.value},get items(){return Qt.value},onOpenChange:e=>$t.value(e),get trigger(){return g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,icon:`heading`,get label(){return k.value.textStyle},get disabled(){return M.value||F.value?.heading===!1}})}})),_(()=>f(e,$.group)),e})()]:null})(),null),c(t,(()=>{var e=l(()=>!!(an.value&&ht.value.length>0));return()=>e()?[l(()=>l(()=>!!(on.value||an.value&&(mt.value.length>0||P.value(`link`))||an.value&&P.value(`heading`)))()?g(He,{orientation:`vertical`}):null),(()=>{var e=fp();return c(e,g(Be,{get of(){return ht.value},by:e=>e.format,renew:!0,children:e=>g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,iconOnly:!0,get icon(){return e.icon},get label(){return k.value[e.format]},get pressed(){return yt.value?.[e.format]??!1},get disabled(){return M.value||F.value?.[e.format]===!1},onClick:t=>En.value(t,t=>t.toggle(e.format))})})),_(()=>f(e,$.group)),e})()]:null})(),null),_(t=>{var n=Me.bar,r=k.value.selectionBar,i=L.value?void 0:`closed`,a=!L.value||void 0;return n!==t.e&&f(e,t.e=n),r!==t.t&&d(e,`aria-label`,t.t=r),i!==t.a&&d(e,`data-state`,t.a=i),a!==t.o&&(e.inert=t.o=a),t},{e:void 0,t:void 0,a:void 0,o:void 0}),e})():null})(),null),c(t,(()=>{var e=l(()=>!!In.value);return()=>e()?(()=>{var e=fp();return c(e,(()=>{var e=l(()=>p.maxLength!==void 0);return()=>e()?(()=>{var e=hp();return c(e,(()=>{var e=l(()=>!!j.value);return()=>e()?k.value.overLimit(A.value):k.value.count(lt.value,p.maxLength)})()),_(t=>{var n=$.count,r=vt.value,i=j.value?`over`:void 0;return n!==t.e&&f(e,t.e=n),r!==t.t&&d(e,`id`,t.t=r),i!==t.a&&d(e,`data-state`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e})():null})(),null),c(e,(()=>{var e=l(()=>p.footer!==void 0);return()=>e()?p.footer?.({focus:I.value.focus,clear:I.value.clear,insertText:I.value.insertText,insertEntity:I.value.insertEntity,annotate:I.value.annotate,removeAnnotation:I.value.removeAnnotation,value:I.value.value,empty:I.value.empty,length:I.value.length,overLimit:I.value.overLimit,disabled:I.value.disabled,selection:I.value.selection}):(()=>{var e=fp(),t=v.attach;return typeof t==`function`?h(t,e):v.attach=e,c(e,(()=>{var e=l(()=>p.cancelLabel!==void 0&&p.onCancel!==void 0);return()=>e()?g(E,{variant:`ghost`,tone:`neutral`,size:`sm`,get label(){return p.cancelLabel},get disabled(){return p.disabled},onClick:()=>p.onCancel?.()}):null})(),null),c(e,g(E,{variant:`solid`,tone:`accent`,size:`sm`,get label(){return p.submitLabel??``},get disabled(){return p.disabled||ct.value||j.value},get loading(){return p.pending},onClick:()=>Kt.value()}),null),_(()=>f(e,$.actions)),e})()})(),null),_(()=>f(e,$.footer)),e})():null})(),null),c(e,(()=>{var e=l(()=>!In.value);return()=>e()&&l(()=>p.maxLength!==void 0)()?(()=>{var e=hp();return c(e,(()=>{var e=l(()=>!!j.value);return()=>e()?k.value.overLimit(A.value):k.value.count(lt.value,p.maxLength)})()),_(t=>{var n=$.count,r=vt.value,i=j.value?`over`:void 0;return n!==t.e&&f(e,t.e=n),r!==t.t&&d(e,`id`,t.t=r),i!==t.a&&d(e,`data-state`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e})():null})(),a),c(e,(()=>{var e=l(()=>!!(Mt.value&&jt.value!==void 0));return()=>e()?(()=>{var e=gp(),t=S.attach;return typeof t==`function`?h(t,e):S.attach=e,e.$$mousedown=e=>e.preventDefault(),c(e,(()=>{var e=l(()=>Rt.value.length>0);return()=>e()?(()=>{var e=_p();return c(e,g(Be,{get of(){return Rt.value},by:e=>e.id,renew:!0,children:(e,t)=>(()=>{var r=vp(),i=r.firstChild,a=i.firstChild;return r.$$click=()=>Ht.value(t()),r.$$pointermove=()=>t()!==Bt.value&&(Ee.value={key:zt.value,index:t()}),c(r,(()=>{var t=l(()=>e.leading!==void 0);return()=>t()?(()=>{var t=yp();return c(t,()=>e.leading),_(()=>f(t,$.leading)),t})():l(()=>e.icon!==void 0)()?(()=>{var t=bp();return c(t,g(n,{get name(){return e.icon},size:`sm`})),_(()=>f(t,$.glyph)),t})():null})(),i),c(a,()=>e.label),c(i,(()=>{var t=l(()=>e.description!==void 0);return()=>t()?(()=>{var t=bp();return c(t,()=>e.description),_(()=>f(t,$.description)),t})():null})(),null),_(n=>{var o=$.option,s=yn.value(ze(e)),c=t()===Bt.value?`true`:`false`,l=t()===Bt.value?``:void 0,u=$.text,p=$.label;return o!==n.e&&f(r,n.e=o),s!==n.t&&d(r,`id`,n.t=s),c!==n.a&&d(r,`aria-selected`,n.a=c),l!==n.o&&d(r,`data-highlighted`,n.o=l),u!==n.i&&f(i,n.i=u),p!==n.n&&f(a,n.n=p),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),r})()})),_(t=>{var n=$.listbox,r=_t.value,i=jt.value?.label;return n!==t.e&&f(e,t.e=n),r!==t.t&&d(e,`id`,t.t=r),i!==t.a&&d(e,`aria-label`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e})():null})(),null),c(e,(()=>{var e=l(()=>!!It.value);return()=>e()?(()=>{var e=xp();return c(e,g(Be,{of:[0,1,2],by:e=>e,children:()=>(()=>{var e=fp();return c(e,g(Ue,{textStep:`sm`})),_(()=>f(e,$.row)),e})()})),_(()=>f(e,$.rows)),e})():null})(),null),c(e,(()=>{var e=l(()=>!!Lt.value);return()=>e()?(()=>{var e=xp();return c(e,()=>jt.value?.error),_(()=>f(e,$.error)),e})():null})(),null),c(e,(()=>{var e=l(()=>!It.value&&!Lt.value&&Rt.value.length===0);return()=>e()?(()=>{var e=xp();return c(e,()=>k.value.noSuggestions),_(()=>f(e,$.empty)),e})():null})(),null),_(()=>f(e,$.suggestions)),e})():null})(),a),c(a,(()=>{var e=l(()=>we.value.text!==``);return()=>e()?g(Re,{get by(){return we.value.at},children:()=>(()=>{var e=bp();return c(e,()=>we.value.text),e})()}):null})()),c(e,(()=>{var e=l(()=>p.name!==void 0);return()=>e()?(()=>{var e=Sp();return _(t=>{var n=p.name,r=p.disabled;return n!==t.e&&d(e,`name`,t.e=n),r!==t.t&&(e.disabled=t.t=r),t},{e:void 0,t:void 0}),_(()=>e.value=he(st.value)),e})():null})(),null),_(n=>{var o=$.root,s=String(p.minRows),c=String(p.maxRows),l=ct.value?``:void 0,u=p.disabled?``:void 0,m=!p.disabled&&dt.value?``:void 0,h=p.invalid||j.value?``:void 0,g=$.frame,_=$.viewport,ee=$.surface,v=gt.value,y=p[`aria-label`],b=p[`aria-labelledby`],x=bn.value,te=p[`aria-required`]===!0?`true`:void 0,ne=p.invalid||j.value?`true`:void 0,re=p.disabled?`true`:void 0,ie=!p.disabled&&dt.value?`true`:void 0,ae=p.disabled?void 0:`0`,oe=xn.value?`list`:void 0,se=xn.value?`listbox`:void 0,S=Sn.value[`aria-controls`],ce=Sn.value[`aria-activedescendant`],le=$.status;return o!==n.e&&f(e,n.e=o),s!==n.t&&d(e,`data-min-rows`,n.t=s),c!==n.a&&d(e,`data-max-rows`,n.a=c),l!==n.o&&d(e,`data-empty`,n.o=l),u!==n.i&&d(e,`data-disabled`,n.i=u),m!==n.n&&d(e,`data-readonly`,n.n=m),h!==n.s&&d(e,`data-invalid`,n.s=h),g!==n.h&&f(t,n.h=g),_!==n.r&&f(r,n.r=_),ee!==n.d&&f(i,n.d=ee),v!==n.l&&d(i,`id`,n.l=v),y!==n.u&&d(i,`aria-label`,n.u=y),b!==n.c&&d(i,`aria-labelledby`,n.c=b),x!==n.w&&d(i,`aria-describedby`,n.w=x),te!==n.m&&d(i,`aria-required`,n.m=te),ne!==n.f&&d(i,`aria-invalid`,n.f=ne),re!==n.y&&d(i,`aria-disabled`,n.y=re),ie!==n.g&&d(i,`aria-readonly`,n.g=ie),ae!==n.p&&d(i,`tabindex`,n.p=ae),oe!==n.b&&d(i,`aria-autocomplete`,n.b=oe),se!==n.T&&d(i,`aria-haspopup`,n.T=se),S!==n.A&&d(i,`aria-controls`,n.A=S),ce!==n.O&&d(i,`aria-activedescendant`,n.O=ce),le!==n.I&&f(a,n.I=le),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0,w:void 0,m:void 0,f:void 0,y:void 0,g:void 0,p:void 0,b:void 0,T:void 0,A:void 0,O:void 0,I:void 0}),e})()})}Cp.controlKind=`group`,p([`keydown`,`pointerdown`,`click`,`focusin`,`focusout`,`mousedown`,`pointermove`]);var wp={tag:`poly-rich-text-input`,member:`RichTextInput`,props:{activeAnnotation:`string`,annotations:`json`,"aria-describedby":`string`,"aria-label":`string`,"aria-labelledby":`string`,"aria-required":`boolean`,autoFocus:`boolean`,cancelLabel:`string`,controlRef:`property`,defaultValue:`json`,disabled:`boolean`,entities:`json`,footer:`property`,formats:`json`,id:`string`,invalid:`boolean`,maxLength:`number`,maxRows:{union:[6,12,`none`,24]},messages:`json`,minRows:`number`,name:`string`,pending:`boolean`,placeholder:`string`,readOnly:`boolean`,selectionActions:`property`,submitLabel:`string`,toolbar:`property`,toolbarPlacement:`string`,value:`json`},events:{onAnnotationSelect:{type:`poly-annotation-select`},onBlur:{type:`poly-blur`},onCancel:{type:`poly-cancel`,listened:!0},onChange:{type:`poly-change`},onFiles:{type:`poly-files`,listened:!0},onFocus:{type:`poly-focus`},onSubmit:{type:`poly-submit`,listened:!0}},slots:[],controlled:{value:`onChange`}},Tp=v(wp,Cp);export{Tp as PolyRichTextInput,wp as definition};