@umbraco-cms/backoffice 16.0.0 → 16.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (568) hide show
  1. package/dist-cms/apps/app/app-auth.controller.js +1 -0
  2. package/dist-cms/apps/backoffice/backoffice.element.d.ts +2 -0
  3. package/dist-cms/apps/backoffice/backoffice.element.js +12 -10
  4. package/dist-cms/assets/lang/da.js +21 -0
  5. package/dist-cms/assets/lang/da.ts +22 -0
  6. package/dist-cms/assets/lang/de.js +24 -0
  7. package/dist-cms/assets/lang/de.ts +26 -0
  8. package/dist-cms/assets/lang/en.js +11 -0
  9. package/dist-cms/assets/lang/en.ts +12 -0
  10. package/dist-cms/assets/lang/pt-br.js +2 -256
  11. package/dist-cms/assets/lang/pt-br.ts +2 -258
  12. package/dist-cms/assets/lang/pt.js +2605 -1
  13. package/dist-cms/assets/lang/pt.ts +2822 -1
  14. package/dist-cms/custom-elements.json +201 -98
  15. package/dist-cms/external/rxjs/index.d.ts +1 -1
  16. package/dist-cms/external/rxjs/index.js +3 -3
  17. package/dist-cms/external/tiptap/extensions/tiptap-html-global-attributes.extension.d.ts +5 -0
  18. package/dist-cms/external/tiptap/extensions/tiptap-span.extension.d.ts +2 -0
  19. package/dist-cms/external/tiptap/index.js +19 -19
  20. package/dist-cms/external/uui/index.js +332 -318
  21. package/dist-cms/libs/extension-api/controller/server-extension-registrator.controller.js +1 -1
  22. package/dist-cms/libs/extension-api/types/manifest-base.interface.d.ts +1 -1
  23. package/dist-cms/packages/block/block/context/block-entry.context.d.ts +3 -0
  24. package/dist-cms/packages/block/block/context/block-entry.context.js +9 -0
  25. package/dist-cms/packages/block/block-grid/components/block-grid-entry/block-grid-entry.element.d.ts +1 -0
  26. package/dist-cms/packages/block/block-grid/components/block-grid-entry/block-grid-entry.element.js +14 -6
  27. package/dist-cms/packages/block/block-list/components/block-list-entry/block-list-entry.element.d.ts +1 -0
  28. package/dist-cms/packages/block/block-list/components/block-list-entry/block-list-entry.element.js +16 -5
  29. package/dist-cms/packages/block/block-rte/components/block-rte-entry/block-rte-entry.element.d.ts +1 -0
  30. package/dist-cms/packages/block/block-rte/components/block-rte-entry/block-rte-entry.element.js +12 -1
  31. package/dist-cms/packages/block/modals/manifest-viewer/manifest-viewer-modal.element.js +6 -0
  32. package/dist-cms/packages/content/content/workspace/views/edit/content-editor.element.js +12 -10
  33. package/dist-cms/packages/content/content-type/modals/composition-picker/composition-picker-modal.element.js +6 -5
  34. package/dist-cms/packages/content/content-type/repository/structure/content-type-structure-server-data-source-base.d.ts +1 -1
  35. package/dist-cms/packages/content/content-type/structure/content-type-structure-manager.class.d.ts +1 -1
  36. package/dist-cms/packages/core/auth/auth-flow.d.ts +2 -2
  37. package/dist-cms/packages/core/auth/auth-flow.js +7 -9
  38. package/dist-cms/packages/core/auth/auth.context.d.ts +9 -7
  39. package/dist-cms/packages/core/auth/auth.context.js +14 -7
  40. package/dist-cms/packages/core/backend-api/sdk.gen.d.ts +406 -406
  41. package/dist-cms/packages/core/backend-api/sdk.gen.js +57 -57
  42. package/dist-cms/packages/core/backend-api/types.gen.d.ts +6 -2
  43. package/dist-cms/packages/core/collection/action/create/collection-create-action.element.d.ts +1 -2
  44. package/dist-cms/packages/core/collection/action/create/collection-create-action.element.js +17 -13
  45. package/dist-cms/packages/core/collection/components/pagination/collection-pagination.element.js +4 -0
  46. package/dist-cms/packages/core/components/dropdown/dropdown.element.d.ts +2 -3
  47. package/dist-cms/packages/core/components/dropdown/dropdown.element.js +30 -18
  48. package/dist-cms/packages/core/components/entity-actions-bundle/entity-actions-bundle.element.d.ts +1 -1
  49. package/dist-cms/packages/core/components/entity-actions-bundle/entity-actions-bundle.element.js +33 -23
  50. package/dist-cms/packages/core/components/input-toggle/input-toggle.element.d.ts +0 -1
  51. package/dist-cms/packages/core/components/input-toggle/input-toggle.element.js +1 -8
  52. package/dist-cms/packages/core/components/table/table.element.js +14 -12
  53. package/dist-cms/packages/core/entity/constants.d.ts +2 -0
  54. package/dist-cms/packages/core/entity/constants.js +2 -0
  55. package/dist-cms/packages/core/entity/entity-type/constants.d.ts +1 -0
  56. package/dist-cms/packages/core/entity/entity-type/constants.js +1 -0
  57. package/dist-cms/packages/core/entity/entity-type/entity-type.condition.d.ts +9 -0
  58. package/dist-cms/packages/core/entity/entity-type/entity-type.condition.js +23 -0
  59. package/dist-cms/packages/core/entity/entity-type/manifests.js +9 -0
  60. package/dist-cms/packages/core/entity/entity-type/types.d.ts +11 -0
  61. package/dist-cms/packages/core/entity/entity-type/types.js +1 -0
  62. package/dist-cms/packages/core/entity/entity-unique/constants.d.ts +1 -0
  63. package/dist-cms/packages/core/entity/entity-unique/constants.js +1 -0
  64. package/dist-cms/packages/core/entity/entity-unique/entity-unique.condition.d.ts +9 -0
  65. package/dist-cms/packages/core/entity/entity-unique/entity-unique.condition.js +23 -0
  66. package/dist-cms/packages/core/entity/entity-unique/manifests.d.ts +1 -0
  67. package/dist-cms/packages/core/entity/entity-unique/manifests.js +9 -0
  68. package/dist-cms/packages/core/entity/entity-unique/types.d.ts +12 -0
  69. package/dist-cms/packages/core/entity/entity-unique/types.js +1 -0
  70. package/dist-cms/packages/core/entity/manifests.d.ts +1 -0
  71. package/dist-cms/packages/core/entity/manifests.js +3 -0
  72. package/dist-cms/packages/core/entity/types.d.ts +3 -1
  73. package/dist-cms/packages/core/entity-action/global-components/entity-actions-dropdown/entity-actions-dropdown.element.d.ts +15 -0
  74. package/dist-cms/packages/core/entity-action/global-components/entity-actions-dropdown/entity-actions-dropdown.element.js +87 -0
  75. package/dist-cms/packages/core/entity-action/global-components/index.d.ts +1 -0
  76. package/dist-cms/packages/core/entity-action/global-components/index.js +1 -0
  77. package/dist-cms/packages/core/entity-item/item-data-api-get-request-controller/item-data-api-get-request.controller.d.ts +1 -1
  78. package/dist-cms/packages/core/event/closed.event.d.ts +4 -0
  79. package/dist-cms/packages/core/event/closed.event.js +7 -0
  80. package/dist-cms/packages/core/event/index.d.ts +2 -0
  81. package/dist-cms/packages/core/event/index.js +2 -0
  82. package/dist-cms/packages/core/event/opened.event.d.ts +4 -0
  83. package/dist-cms/packages/core/event/opened.event.js +7 -0
  84. package/dist-cms/packages/core/extension-registry/components/extension-slot/extension-slot.element.d.ts +3 -3
  85. package/dist-cms/packages/core/extension-registry/components/extension-slot/extension-slot.element.js +9 -9
  86. package/dist-cms/packages/core/http-client/index.d.ts +1 -0
  87. package/dist-cms/packages/core/icon-registry/icon-dictionary.json +1 -2
  88. package/dist-cms/packages/core/icon-registry/icons/icon-next.d.ts +1 -1
  89. package/dist-cms/packages/core/icon-registry/icons/icon-next.js +1 -1
  90. package/dist-cms/packages/core/icon-registry/icons.d.ts +2 -2
  91. package/dist-cms/packages/core/icon-registry/icons.js +3098 -2394
  92. package/dist-cms/packages/core/manifests.js +2 -0
  93. package/dist-cms/packages/core/menu/section-sidebar-menu/section-sidebar-menu.element.js +5 -1
  94. package/dist-cms/packages/core/object-type/object-type.repository.d.ts +1 -1
  95. package/dist-cms/packages/core/openapi-ts.config.js +3 -1
  96. package/dist-cms/packages/core/package.json +2 -2
  97. package/dist-cms/packages/core/property/components/unsupported-property/utils.js +1 -1
  98. package/dist-cms/packages/core/recycle-bin/recycle-bin-repository-base.d.ts +2 -4
  99. package/dist-cms/packages/core/recycle-bin/recycle-bin-repository-base.js +2 -13
  100. package/dist-cms/packages/core/repository/detail/detail-data-source.interface.d.ts +2 -1
  101. package/dist-cms/packages/core/repository/detail/detail-repository-base.d.ts +6 -5
  102. package/dist-cms/packages/core/repository/detail/detail-repository-base.js +2 -2
  103. package/dist-cms/packages/core/repository/detail/read/read-detail-repository.interface.d.ts +1 -1
  104. package/dist-cms/packages/core/repository/item/item-repository-base.d.ts +3 -3
  105. package/dist-cms/packages/core/repository/item/item-repository-base.js +5 -8
  106. package/dist-cms/packages/core/repository/item/item-repository.interface.d.ts +2 -6
  107. package/dist-cms/packages/core/repository/item/item-server-data-source-base.d.ts +1 -1
  108. package/dist-cms/packages/core/repository/repository-items.manager.js +2 -0
  109. package/dist-cms/packages/core/repository/types.d.ts +7 -2
  110. package/dist-cms/packages/core/resources/api-interceptor.controller.d.ts +7 -0
  111. package/dist-cms/packages/core/resources/api-interceptor.controller.js +180 -54
  112. package/dist-cms/packages/core/resources/resource.controller.d.ts +2 -2
  113. package/dist-cms/packages/core/resources/resource.controller.js +11 -6
  114. package/dist-cms/packages/core/resources/try-execute/try-execute.controller.js +27 -13
  115. package/dist-cms/packages/core/resources/types.d.ts +2 -2
  116. package/dist-cms/packages/core/router/route/forbidden/route-forbidden.element.d.ts +17 -0
  117. package/dist-cms/packages/core/router/route/forbidden/route-forbidden.element.js +59 -0
  118. package/dist-cms/packages/core/router/route/index.d.ts +1 -0
  119. package/dist-cms/packages/core/router/route/index.js +1 -0
  120. package/dist-cms/packages/core/section/conditions/constants.d.ts +2 -1
  121. package/dist-cms/packages/core/section/conditions/constants.js +2 -1
  122. package/dist-cms/packages/core/section/conditions/manifests.js +3 -17
  123. package/dist-cms/packages/core/section/conditions/section-alias/constants.d.ts +1 -0
  124. package/dist-cms/packages/core/section/conditions/section-alias/constants.js +1 -0
  125. package/dist-cms/packages/core/section/conditions/section-alias/manifests.d.ts +1 -0
  126. package/dist-cms/packages/core/section/conditions/section-alias/manifests.js +10 -0
  127. package/dist-cms/packages/core/section/conditions/{section-alias.condition.d.ts → section-alias/section-alias.condition.d.ts} +2 -2
  128. package/dist-cms/packages/core/section/conditions/{section-alias.condition.js → section-alias/section-alias.condition.js} +2 -2
  129. package/dist-cms/packages/core/section/conditions/section-alias/types.d.ts +20 -0
  130. package/dist-cms/packages/core/section/conditions/section-alias/types.js +1 -0
  131. package/dist-cms/packages/core/section/conditions/section-user-permission/constants.d.ts +1 -0
  132. package/dist-cms/packages/core/section/conditions/section-user-permission/constants.js +1 -0
  133. package/dist-cms/packages/core/section/conditions/section-user-permission/manifests.d.ts +1 -0
  134. package/dist-cms/packages/core/section/conditions/section-user-permission/manifests.js +10 -0
  135. package/dist-cms/packages/core/section/conditions/{section-user-permission.condition.d.ts → section-user-permission/section-user-permission.condition.d.ts} +1 -1
  136. package/dist-cms/packages/core/section/conditions/section-user-permission/types.d.ts +16 -0
  137. package/dist-cms/packages/core/section/conditions/section-user-permission/types.js +1 -0
  138. package/dist-cms/packages/core/section/conditions/types.d.ts +2 -30
  139. package/dist-cms/packages/core/server-file-system/rename/rename-server-file-repository-base.d.ts +1 -1
  140. package/dist-cms/packages/core/temporary-file/config/config.repository.d.ts +2 -0
  141. package/dist-cms/packages/core/temporary-file/config/config.repository.js +2 -0
  142. package/dist-cms/packages/core/tree/components/index.d.ts +1 -0
  143. package/dist-cms/packages/core/tree/components/index.js +1 -0
  144. package/dist-cms/packages/core/tree/components/tree-load-more-button.element.d.ts +10 -0
  145. package/dist-cms/packages/core/tree/components/tree-load-more-button.element.js +36 -0
  146. package/dist-cms/packages/core/tree/data/tree-repository-base.d.ts +8 -12
  147. package/dist-cms/packages/core/tree/data/tree-repository-base.js +10 -16
  148. package/dist-cms/packages/core/tree/data/tree-repository.interface.d.ts +5 -21
  149. package/dist-cms/packages/core/tree/data/tree-server-data-source-base.d.ts +3 -3
  150. package/dist-cms/packages/core/tree/default/default-tree.element.js +1 -1
  151. package/dist-cms/packages/core/tree/folder/index.d.ts +2 -1
  152. package/dist-cms/packages/core/tree/folder/index.js +2 -1
  153. package/dist-cms/packages/core/tree/folder/workspace/folder-workspace-editor.element.d.ts +10 -0
  154. package/dist-cms/packages/core/tree/folder/workspace/folder-workspace-editor.element.js +31 -0
  155. package/dist-cms/packages/core/tree/folder/workspace/index.d.ts +2 -0
  156. package/dist-cms/packages/core/tree/folder/workspace/index.js +2 -0
  157. package/dist-cms/packages/core/tree/index.d.ts +1 -0
  158. package/dist-cms/packages/core/tree/index.js +1 -0
  159. package/dist-cms/packages/core/tree/tree-item/tree-item-base/tree-item-element-base.d.ts +2 -1
  160. package/dist-cms/packages/core/tree/tree-item/tree-item-base/tree-item-element-base.js +7 -4
  161. package/dist-cms/packages/core/workspace/components/workspace-action/default/workspace-action-default-kind.element.d.ts +1 -0
  162. package/dist-cms/packages/core/workspace/components/workspace-action/default/workspace-action-default-kind.element.js +24 -6
  163. package/dist-cms/packages/core/workspace/components/workspace-action-menu/workspace-action-menu.element.js +6 -1
  164. package/dist-cms/packages/core/workspace/components/workspace-breadcrumb/workspace-menu-breadcrumb/workspace-menu-breadcrumb.element.d.ts +1 -1
  165. package/dist-cms/packages/core/workspace/components/workspace-breadcrumb/workspace-menu-breadcrumb/workspace-menu-breadcrumb.element.js +5 -4
  166. package/dist-cms/packages/core/workspace/components/workspace-breadcrumb/workspace-variant-menu-breadcrumb/workspace-variant-menu-breadcrumb.element.d.ts +1 -1
  167. package/dist-cms/packages/core/workspace/components/workspace-breadcrumb/workspace-variant-menu-breadcrumb/workspace-variant-menu-breadcrumb.element.js +20 -11
  168. package/dist-cms/packages/core/workspace/components/workspace-editor/workspace-editor.element.js +6 -4
  169. package/dist-cms/packages/core/workspace/components/workspace-entity-action-menu/workspace-entity-action-menu.element.d.ts +0 -3
  170. package/dist-cms/packages/core/workspace/components/workspace-entity-action-menu/workspace-entity-action-menu.element.js +14 -48
  171. package/dist-cms/packages/core/workspace/components/workspace-header-name-editable/workspace-header-name-editable.element.d.ts +1 -0
  172. package/dist-cms/packages/core/workspace/components/workspace-header-name-editable/workspace-header-name-editable.element.js +11 -1
  173. package/dist-cms/packages/core/workspace/components/workspace-split-view/workspace-split-view-variant-selector.element.js +4 -0
  174. package/dist-cms/packages/core/workspace/components/workspace-split-view/workspace-split-view.element.js +7 -0
  175. package/dist-cms/packages/core/workspace/controllers/workspace-split-view-manager.controller.d.ts +1 -0
  176. package/dist-cms/packages/core/workspace/controllers/workspace-split-view-manager.controller.js +1 -0
  177. package/dist-cms/packages/core/workspace/entity-detail/entity-detail-workspace-base.d.ts +1 -0
  178. package/dist-cms/packages/core/workspace/entity-detail/entity-detail-workspace-base.js +16 -4
  179. package/dist-cms/packages/core/workspace/entity-detail/entity-named-detail-workspace-base.d.ts +5 -1
  180. package/dist-cms/packages/core/workspace/entity-detail/entity-named-detail-workspace-base.js +5 -2
  181. package/dist-cms/packages/core/workspace/entity-detail/global-components/entity-detail-forbidden.element.d.ts +11 -0
  182. package/dist-cms/packages/core/workspace/entity-detail/global-components/entity-detail-forbidden.element.js +55 -0
  183. package/dist-cms/packages/core/workspace/entity-detail/global-components/entity-detail-workspace-editor.element.d.ts +1 -0
  184. package/dist-cms/packages/core/workspace/entity-detail/global-components/entity-detail-workspace-editor.element.js +20 -3
  185. package/dist-cms/packages/core/workspace/entity-detail/global-components/index.d.ts +1 -2
  186. package/dist-cms/packages/core/workspace/entity-detail/global-components/index.js +1 -2
  187. package/dist-cms/packages/core/workspace/entity-detail/types.d.ts +2 -1
  188. package/dist-cms/packages/core/workspace/namable/index.d.ts +1 -0
  189. package/dist-cms/packages/core/workspace/namable/index.js +1 -0
  190. package/dist-cms/packages/core/workspace/namable/namable-workspace-context.interface.d.ts +2 -0
  191. package/dist-cms/packages/core/workspace/namable/name-write-guard.manager.d.ts +6 -0
  192. package/dist-cms/packages/core/workspace/namable/name-write-guard.manager.js +15 -0
  193. package/dist-cms/packages/data-type/collection/repository/data-type-collection.repository.d.ts +1 -1
  194. package/dist-cms/packages/data-type/collection/repository/data-type-collection.server.data-source.d.ts +1 -1
  195. package/dist-cms/packages/data-type/entity-actions/duplicate/repository/data-type-duplicate.repository.d.ts +1 -1
  196. package/dist-cms/packages/data-type/entity-actions/move-to/repository/data-type-move.repository.d.ts +1 -1
  197. package/dist-cms/packages/data-type/repository/detail/data-type-detail.server.data-source.d.ts +3 -3
  198. package/dist-cms/packages/data-type/repository/item/data-type-item.server.data-source.d.ts +1 -1
  199. package/dist-cms/packages/data-type/search/data-type-search.repository.d.ts +1 -1
  200. package/dist-cms/packages/data-type/search/data-type-search.server.data-source.d.ts +1 -1
  201. package/dist-cms/packages/data-type/search/data-type.search-provider.d.ts +1 -1
  202. package/dist-cms/packages/data-type/tree/folder/repository/data-type-folder.server.data-source.d.ts +3 -3
  203. package/dist-cms/packages/data-type/tree/folder/workspace/data-type-folder-editor.element.d.ts +1 -3
  204. package/dist-cms/packages/data-type/tree/folder/workspace/data-type-folder-editor.element.js +2 -7
  205. package/dist-cms/packages/data-type/tree/tree-item-children/collection/repository/data-type-tree-item-children-collection.repository.d.ts +3 -3
  206. package/dist-cms/packages/dictionary/collection/repository/dictionary-collection.server.data-source.d.ts +1 -1
  207. package/dist-cms/packages/dictionary/dashboard/manifests.js +2 -1
  208. package/dist-cms/packages/dictionary/entity-action/move-to/repository/dictionary-move.repository.d.ts +1 -1
  209. package/dist-cms/packages/dictionary/repository/detail/dictionary-detail.server.data-source.d.ts +3 -3
  210. package/dist-cms/packages/dictionary/repository/import/dictionary-import.repository.d.ts +2 -2
  211. package/dist-cms/packages/dictionary/repository/item/dictionary-item.server.data-source.d.ts +1 -1
  212. package/dist-cms/packages/dictionary/search/dictionary-search.repository.d.ts +1 -1
  213. package/dist-cms/packages/dictionary/search/dictionary-search.server.data-source.d.ts +1 -1
  214. package/dist-cms/packages/dictionary/search/dictionary.search-provider.d.ts +1 -1
  215. package/dist-cms/packages/documents/document-blueprints/entity-actions/move-to/repository/document-blueprint-move.repository.d.ts +1 -1
  216. package/dist-cms/packages/documents/document-blueprints/repository/item/document-blueprint-item.repository.d.ts +1 -1
  217. package/dist-cms/packages/documents/document-blueprints/repository/item/document-blueprint-item.server.data-source.d.ts +2 -2
  218. package/dist-cms/packages/documents/document-blueprints/tree/folder/repository/document-blueprint-folder.server.data-source.d.ts +3 -3
  219. package/dist-cms/packages/documents/document-blueprints/tree/folder/workspace/document-blueprint-folder-editor.element.d.ts +1 -3
  220. package/dist-cms/packages/documents/document-blueprints/tree/folder/workspace/document-blueprint-folder-editor.element.js +2 -7
  221. package/dist-cms/packages/documents/document-blueprints/workspace/document-blueprint-workspace-editor.element.js +27 -13
  222. package/dist-cms/packages/documents/document-redirect-management/dashboard-redirect-management.element.js +7 -1
  223. package/dist-cms/packages/documents/document-redirect-management/manifests.js +2 -1
  224. package/dist-cms/packages/documents/document-types/entity-actions/duplicate/repository/document-type-duplicate.repository.d.ts +1 -1
  225. package/dist-cms/packages/documents/document-types/entity-actions/import/repository/document-type-import.repository.d.ts +1 -1
  226. package/dist-cms/packages/documents/document-types/entity-actions/move-to/repository/document-type-move.repository.d.ts +1 -1
  227. package/dist-cms/packages/documents/document-types/repository/composition/document-type-composition.repository.d.ts +2 -2
  228. package/dist-cms/packages/documents/document-types/repository/composition/document-type-composition.server.data-source.d.ts +2 -2
  229. package/dist-cms/packages/documents/document-types/repository/detail/document-type-detail.server.data-source.d.ts +3 -3
  230. package/dist-cms/packages/documents/document-types/repository/detail/index.d.ts +1 -0
  231. package/dist-cms/packages/documents/document-types/repository/detail/index.js +1 -0
  232. package/dist-cms/packages/documents/document-types/repository/item/document-type-item.server.data-source.d.ts +1 -1
  233. package/dist-cms/packages/documents/document-types/search/document-type-search.repository.d.ts +1 -1
  234. package/dist-cms/packages/documents/document-types/search/document-type-search.server.data-source.d.ts +1 -1
  235. package/dist-cms/packages/documents/document-types/search/document-type.search-provider.d.ts +1 -1
  236. package/dist-cms/packages/documents/document-types/tree/folder/repository/document-type-folder.server.data-source.d.ts +3 -3
  237. package/dist-cms/packages/documents/document-types/tree/folder/workspace/document-type-folder-editor.element.d.ts +1 -3
  238. package/dist-cms/packages/documents/document-types/tree/folder/workspace/document-type-folder-editor.element.js +2 -7
  239. package/dist-cms/packages/documents/document-types/tree/tree-item-children/collection/repository/document-type-tree-item-children-collection.repository.d.ts +3 -3
  240. package/dist-cms/packages/documents/documents/audit-log/info-app/document-history-workspace-info-app.element.js +4 -0
  241. package/dist-cms/packages/documents/documents/audit-log/repository/document-audit-log.repository.d.ts +1 -1
  242. package/dist-cms/packages/documents/documents/audit-log/repository/document-audit-log.server.data-source.d.ts +1 -1
  243. package/dist-cms/packages/documents/documents/collection/repository/document-collection.repository.d.ts +1 -1
  244. package/dist-cms/packages/documents/documents/collection/repository/document-collection.server.data-source.d.ts +1 -1
  245. package/dist-cms/packages/documents/documents/collection/views/table/column-layouts/document-table-column-name.element.js +5 -1
  246. package/dist-cms/packages/documents/documents/entity-actions/create-blueprint/modal/create-blueprint-modal.element.js +13 -12
  247. package/dist-cms/packages/documents/documents/entity-actions/create-blueprint/repository/document-create-blueprint.repository.d.ts +1 -1
  248. package/dist-cms/packages/documents/documents/entity-actions/duplicate/repository/document-duplicate.repository.d.ts +1 -1
  249. package/dist-cms/packages/documents/documents/entity-actions/move-to/repository/document-move.repository.d.ts +1 -1
  250. package/dist-cms/packages/documents/documents/entity-actions/notifications/repository/document-notifications.repository.d.ts +2 -2
  251. package/dist-cms/packages/documents/documents/item/repository/document-item.server.data-source.d.ts +1 -1
  252. package/dist-cms/packages/documents/documents/publishing/repository/document-publishing.repository.d.ts +1 -1
  253. package/dist-cms/packages/documents/documents/publishing/repository/document-publishing.server.data-source.d.ts +1 -1
  254. package/dist-cms/packages/documents/documents/recycle-bin/repository/document-recycle-bin.server.data-source.d.ts +1 -1
  255. package/dist-cms/packages/documents/documents/repository/detail/document-detail.server.data-source.d.ts +7 -17
  256. package/dist-cms/packages/documents/documents/repository/detail/document-detail.server.data-source.js +23 -38
  257. package/dist-cms/packages/documents/documents/search/document-search.server.data-source.d.ts +1 -1
  258. package/dist-cms/packages/documents/documents/tree/tree-item/document-tree-item.element.js +2 -3
  259. package/dist-cms/packages/documents/documents/url/document-urls-data-resolver.js +5 -7
  260. package/dist-cms/packages/documents/documents/url/repository/document-url.server.data-source.d.ts +1 -1
  261. package/dist-cms/packages/documents/documents/workspace/actions/save.action.js +16 -7
  262. package/dist-cms/packages/documents/documents/workspace/document-workspace-editor.element.js +13 -4
  263. package/dist-cms/packages/documents/documents/workspace/document-workspace-split-view.element.d.ts +2 -1
  264. package/dist-cms/packages/documents/documents/workspace/document-workspace-split-view.element.js +14 -6
  265. package/dist-cms/packages/documents/documents/workspace/document-workspace.context.d.ts +2 -1
  266. package/dist-cms/packages/documents/documents/workspace/document-workspace.context.js +28 -35
  267. package/dist-cms/packages/documents/section/manifests.js +2 -2
  268. package/dist-cms/packages/embedded-media/repository/oembed.repository.d.ts +1 -1
  269. package/dist-cms/packages/health-check/manifests.js +2 -1
  270. package/dist-cms/packages/language/app-language-select/manifests.js +2 -1
  271. package/dist-cms/packages/language/collection/repository/language-collection.server.data-source.d.ts +1 -1
  272. package/dist-cms/packages/language/repository/detail/language-detail.server.data-source.d.ts +3 -3
  273. package/dist-cms/packages/language/repository/item/language-item.server.data-source.d.ts +1 -1
  274. package/dist-cms/packages/language/workspace/language/language-workspace-editor.element.d.ts +0 -1
  275. package/dist-cms/packages/language/workspace/language/language-workspace-editor.element.js +1 -3
  276. package/dist-cms/packages/log-viewer/workspace/views/overview/components/log-viewer-message-templates-overview.element.js +4 -0
  277. package/dist-cms/packages/log-viewer/workspace/views/overview/components/log-viewer-saved-searches-overview.element.js +4 -0
  278. package/dist-cms/packages/log-viewer/workspace/views/search/components/log-viewer-messages-list.element.js +7 -1
  279. package/dist-cms/packages/media/imaging/components/imaging-thumbnail.element.js +1 -6
  280. package/dist-cms/packages/media/imaging/imaging.server.data.d.ts +1 -1
  281. package/dist-cms/packages/media/media/audit-log/info-app/media-history-workspace-info-app.element.js +4 -0
  282. package/dist-cms/packages/media/media/audit-log/repository/media-audit-log.repository.d.ts +1 -1
  283. package/dist-cms/packages/media/media/audit-log/repository/media-audit-log.server.data-source.d.ts +1 -1
  284. package/dist-cms/packages/media/media/collection/media-collection.context.d.ts +1 -1
  285. package/dist-cms/packages/media/media/collection/media-collection.context.js +1 -1
  286. package/dist-cms/packages/media/media/collection/repository/media-collection.repository.d.ts +1 -1
  287. package/dist-cms/packages/media/media/collection/repository/media-collection.server.data-source.d.ts +1 -1
  288. package/dist-cms/packages/media/media/components/input-image-cropper/image-cropper-field.element.d.ts +1 -1
  289. package/dist-cms/packages/media/media/components/input-image-cropper/image-cropper-field.element.js +66 -42
  290. package/dist-cms/packages/media/media/components/input-image-cropper/image-cropper-focus-setter.element.js +2 -11
  291. package/dist-cms/packages/media/media/components/input-image-cropper/input-image-cropper.element.js +15 -8
  292. package/dist-cms/packages/media/media/components/input-upload-field/file-upload-preview.element.d.ts +18 -0
  293. package/dist-cms/packages/media/media/components/input-upload-field/file-upload-preview.element.js +123 -0
  294. package/dist-cms/packages/media/media/components/input-upload-field/preview/input-upload-field-audio.element.d.ts +2 -2
  295. package/dist-cms/packages/media/media/components/input-upload-field/preview/input-upload-field-audio.element.js +3 -4
  296. package/dist-cms/packages/media/media/components/input-upload-field/preview/input-upload-field-file.element.d.ts +2 -7
  297. package/dist-cms/packages/media/media/components/input-upload-field/preview/input-upload-field-file.element.js +3 -20
  298. package/dist-cms/packages/media/media/components/input-upload-field/preview/input-upload-field-image.element.d.ts +2 -2
  299. package/dist-cms/packages/media/media/components/input-upload-field/preview/input-upload-field-image.element.js +3 -13
  300. package/dist-cms/packages/media/media/components/input-upload-field/preview/input-upload-field-svg.element.d.ts +2 -2
  301. package/dist-cms/packages/media/media/components/input-upload-field/preview/input-upload-field-svg.element.js +3 -14
  302. package/dist-cms/packages/media/media/components/input-upload-field/preview/input-upload-field-video.element.d.ts +2 -2
  303. package/dist-cms/packages/media/media/components/input-upload-field/preview/input-upload-field-video.element.js +4 -7
  304. package/dist-cms/packages/media/media/components/input-upload-field/preview/manifest.js +2 -2
  305. package/dist-cms/packages/media/media/dashboard/manifests.js +2 -1
  306. package/dist-cms/packages/media/media/dropzone/dropzone-media.element.js +1 -0
  307. package/dist-cms/packages/media/media/entity-actions/move-to/repository/media-move.repository.d.ts +1 -1
  308. package/dist-cms/packages/media/media/index.d.ts +4 -1
  309. package/dist-cms/packages/media/media/index.js +4 -1
  310. package/dist-cms/packages/media/media/modals/image-cropper-editor/components/image-cropper-editor-field.element.d.ts +1 -2
  311. package/dist-cms/packages/media/media/modals/image-cropper-editor/components/image-cropper-editor-field.element.js +21 -79
  312. package/dist-cms/packages/media/media/modals/image-cropper-editor/image-cropper-editor-modal.element.d.ts +3 -2
  313. package/dist-cms/packages/media/media/modals/image-cropper-editor/image-cropper-editor-modal.element.js +89 -37
  314. package/dist-cms/packages/media/media/modals/media-picker/media-picker-modal.element.js +4 -5
  315. package/dist-cms/packages/media/media/property-editors/image-cropper/Umbraco.ImageCropper.js +1 -1
  316. package/dist-cms/packages/media/media/property-editors/image-crops/property-editor-ui-image-crops.element.d.ts +1 -3
  317. package/dist-cms/packages/media/media/property-editors/image-crops/property-editor-ui-image-crops.element.js +102 -93
  318. package/dist-cms/packages/media/media/property-editors/upload-field/property-editor-ui-upload-field.element.js +7 -4
  319. package/dist-cms/packages/media/media/recycle-bin/repository/media-recycle-bin.server.data-source.d.ts +1 -1
  320. package/dist-cms/packages/media/media/repository/detail/media-detail.server.data-source.d.ts +8 -14
  321. package/dist-cms/packages/media/media/repository/detail/media-detail.server.data-source.js +24 -21
  322. package/dist-cms/packages/media/media/repository/item/media-item.repository.d.ts +1 -1
  323. package/dist-cms/packages/media/media/repository/item/media-item.server.data-source.d.ts +2 -2
  324. package/dist-cms/packages/media/media/search/global-search/media-global-search.d.ts +1 -1
  325. package/dist-cms/packages/media/media/search/media-search.repository.d.ts +1 -1
  326. package/dist-cms/packages/media/media/search/media-search.server.data-source.d.ts +1 -1
  327. package/dist-cms/packages/media/media/search/media.search-provider.d.ts +1 -1
  328. package/dist-cms/packages/media/media/tree/tree-item/media-tree-item.element.js +2 -3
  329. package/dist-cms/packages/media/media/url/info-app/media-links-workspace-info-app.element.js +2 -2
  330. package/dist-cms/packages/media/media/url/repository/media-url.server.data-source.d.ts +1 -1
  331. package/dist-cms/packages/media/media/workspace/media-workspace-editor.element.js +24 -12
  332. package/dist-cms/packages/media/media/workspace/media-workspace-split-view.element.d.ts +2 -1
  333. package/dist-cms/packages/media/media/workspace/media-workspace-split-view.element.js +17 -4
  334. package/dist-cms/packages/media/media/workspace/media-workspace.context.d.ts +2 -1
  335. package/dist-cms/packages/media/media/workspace/media-workspace.context.js +4 -4
  336. package/dist-cms/packages/media/media-section/manifests.js +2 -2
  337. package/dist-cms/packages/media/media-types/entity-actions/duplicate/repository/media-type-duplicate.repository.d.ts +1 -1
  338. package/dist-cms/packages/media/media-types/entity-actions/export/repository/media-type-export.repository.d.ts +1 -1
  339. package/dist-cms/packages/media/media-types/entity-actions/import/repository/media-type-import.repository.d.ts +1 -1
  340. package/dist-cms/packages/media/media-types/entity-actions/move-to/repository/media-type-move.repository.d.ts +1 -1
  341. package/dist-cms/packages/media/media-types/repository/composition/media-type-composition.repository.d.ts +2 -2
  342. package/dist-cms/packages/media/media-types/repository/composition/media-type-composition.server.data-source.d.ts +2 -2
  343. package/dist-cms/packages/media/media-types/repository/detail/index.d.ts +1 -0
  344. package/dist-cms/packages/media/media-types/repository/detail/index.js +1 -0
  345. package/dist-cms/packages/media/media-types/repository/detail/media-type-detail.repository.js +2 -2
  346. package/dist-cms/packages/media/media-types/repository/detail/media-type-detail.server.data-source.d.ts +12 -12
  347. package/dist-cms/packages/media/media-types/repository/detail/media-type-detail.server.data-source.js +9 -9
  348. package/dist-cms/packages/media/media-types/repository/item/media-type-item.server.data-source.d.ts +1 -1
  349. package/dist-cms/packages/media/media-types/search/media-type-search.repository.d.ts +1 -1
  350. package/dist-cms/packages/media/media-types/search/media-type-search.server.data-source.d.ts +1 -1
  351. package/dist-cms/packages/media/media-types/search/media-type.search-provider.d.ts +1 -1
  352. package/dist-cms/packages/media/media-types/tree/folder/repository/media-type-folder.server.data-source.d.ts +3 -3
  353. package/dist-cms/packages/media/media-types/tree/folder/workspace/media-type-folder-editor.element.d.ts +1 -3
  354. package/dist-cms/packages/media/media-types/tree/folder/workspace/media-type-folder-editor.element.js +2 -7
  355. package/dist-cms/packages/media/media-types/tree/tree-item-children/collection/repository/media-type-tree-item-children-collection.repository.d.ts +3 -3
  356. package/dist-cms/packages/members/member/collection/repository/member-collection.repository.d.ts +1 -1
  357. package/dist-cms/packages/members/member/collection/repository/member-collection.server.data-source.d.ts +1 -1
  358. package/dist-cms/packages/members/member/item/repository/member-item.server.data-source.d.ts +1 -1
  359. package/dist-cms/packages/members/member/repository/detail/member-detail.server.data-source.d.ts +7 -13
  360. package/dist-cms/packages/members/member/repository/detail/member-detail.server.data-source.js +20 -19
  361. package/dist-cms/packages/members/member/search/member-search.repository.d.ts +1 -1
  362. package/dist-cms/packages/members/member/search/member-search.server.data-source.d.ts +1 -1
  363. package/dist-cms/packages/members/member/search/member.search-provider.d.ts +1 -1
  364. package/dist-cms/packages/members/member/workspace/member/member-workspace-editor.element.d.ts +2 -2
  365. package/dist-cms/packages/members/member/workspace/member/member-workspace-editor.element.js +18 -11
  366. package/dist-cms/packages/members/member/workspace/member/member-workspace-split-view.element.d.ts +2 -1
  367. package/dist-cms/packages/members/member/workspace/member/member-workspace-split-view.element.js +15 -3
  368. package/dist-cms/packages/members/member/workspace/member/member-workspace.context.d.ts +1 -0
  369. package/dist-cms/packages/members/member/workspace/member/member-workspace.context.js +1 -0
  370. package/dist-cms/packages/members/member-group/collection/repository/member-group-collection.server.data-source.d.ts +1 -1
  371. package/dist-cms/packages/members/member-group/repository/detail/member-group-detail.server.data-source.d.ts +3 -3
  372. package/dist-cms/packages/members/member-group/repository/item/member-group-item.server.data-source.d.ts +1 -1
  373. package/dist-cms/packages/members/member-public-access/repository/public-access.repository.d.ts +4 -4
  374. package/dist-cms/packages/members/member-type/constants.d.ts +1 -0
  375. package/dist-cms/packages/members/member-type/constants.js +1 -0
  376. package/dist-cms/packages/members/member-type/entity-actions/duplicate/repository/member-type-duplicate.repository.d.ts +1 -1
  377. package/dist-cms/packages/members/member-type/entity-actions/manifests.js +1 -1
  378. package/dist-cms/packages/members/member-type/entity.d.ts +1 -1
  379. package/dist-cms/packages/members/member-type/entity.js +1 -1
  380. package/dist-cms/packages/members/member-type/index.d.ts +1 -0
  381. package/dist-cms/packages/members/member-type/index.js +1 -0
  382. package/dist-cms/packages/members/member-type/manifests.js +2 -0
  383. package/dist-cms/packages/members/member-type/member-type-root/constants.d.ts +1 -0
  384. package/dist-cms/packages/members/member-type/member-type-root/constants.js +1 -0
  385. package/dist-cms/packages/members/member-type/member-type-root/index.d.ts +1 -0
  386. package/dist-cms/packages/members/member-type/member-type-root/index.js +1 -0
  387. package/dist-cms/packages/members/member-type/member-type-root/manifests.d.ts +1 -0
  388. package/dist-cms/packages/members/member-type/member-type-root/manifests.js +13 -0
  389. package/dist-cms/packages/members/member-type/repository/composition/member-type-composition.repository.d.ts +2 -2
  390. package/dist-cms/packages/members/member-type/repository/composition/member-type-composition.server.data-source.d.ts +2 -2
  391. package/dist-cms/packages/members/member-type/repository/detail/index.d.ts +1 -0
  392. package/dist-cms/packages/members/member-type/repository/detail/index.js +1 -0
  393. package/dist-cms/packages/members/member-type/repository/detail/member-type-detail.repository.js +2 -2
  394. package/dist-cms/packages/members/member-type/repository/detail/member-type-detail.server.data-source.d.ts +18 -19
  395. package/dist-cms/packages/members/member-type/repository/detail/member-type-detail.server.data-source.js +15 -16
  396. package/dist-cms/packages/members/member-type/repository/index.d.ts +1 -1
  397. package/dist-cms/packages/members/member-type/repository/index.js +1 -1
  398. package/dist-cms/packages/members/member-type/repository/item/member-type-item.server.data-source.d.ts +1 -1
  399. package/dist-cms/packages/members/member-type/search/member-type-search.repository.d.ts +1 -1
  400. package/dist-cms/packages/members/member-type/search/member-type-search.server.data-source.d.ts +1 -1
  401. package/dist-cms/packages/members/member-type/search/member-type.search-provider.d.ts +1 -1
  402. package/dist-cms/packages/members/member-type/tree/constants.d.ts +1 -0
  403. package/dist-cms/packages/members/member-type/tree/constants.js +1 -0
  404. package/dist-cms/packages/members/member-type/tree/manifests.js +18 -9
  405. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/action/manifests.d.ts +1 -0
  406. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/action/manifests.js +16 -0
  407. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/constants.d.ts +2 -0
  408. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/constants.js +2 -0
  409. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/index.d.ts +2 -0
  410. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/index.js +2 -0
  411. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/manifests.d.ts +1 -0
  412. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/manifests.js +19 -0
  413. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/repository/constants.d.ts +1 -0
  414. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/repository/constants.js +1 -0
  415. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/repository/index.d.ts +1 -0
  416. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/repository/index.js +1 -0
  417. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/repository/manifests.d.ts +1 -0
  418. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/repository/manifests.js +9 -0
  419. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/repository/member-type-tree-item-children-collection.repository.d.ts +15 -0
  420. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/repository/member-type-tree-item-children-collection.repository.js +26 -0
  421. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/types.d.ts +5 -0
  422. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/types.js +1 -0
  423. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/views/manifests.d.ts +1 -0
  424. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/views/manifests.js +22 -0
  425. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/views/member-type-tree-item-table-collection-view.element.d.ts +16 -0
  426. package/dist-cms/packages/members/member-type/tree/tree-item-children/collection/views/member-type-tree-item-table-collection-view.element.js +112 -0
  427. package/dist-cms/packages/members/member-type/tree/tree-item-children/constants.d.ts +1 -0
  428. package/dist-cms/packages/members/member-type/tree/tree-item-children/constants.js +1 -0
  429. package/dist-cms/packages/members/member-type/tree/tree-item-children/manifests.d.ts +1 -0
  430. package/dist-cms/packages/members/member-type/tree/tree-item-children/manifests.js +3 -0
  431. package/dist-cms/packages/members/member-type/tree/tree-item-children/reload-entity-action/manifests.d.ts +1 -0
  432. package/dist-cms/packages/members/member-type/tree/{reload-tree-item-children → tree-item-children/reload-entity-action}/manifests.js +1 -1
  433. package/dist-cms/packages/members/member-type/workspace/index.d.ts +2 -0
  434. package/dist-cms/packages/members/member-type/workspace/index.js +2 -0
  435. package/dist-cms/packages/members/section/sidebar-app/manifests.js +2 -1
  436. package/dist-cms/packages/models-builder/manifests.js +2 -1
  437. package/dist-cms/packages/packages/package-section/manifests.js +4 -4
  438. package/dist-cms/packages/packages/package-section/views/created/packages-created-overview.element.js +7 -1
  439. package/dist-cms/packages/performance-profiling/manifests.js +2 -1
  440. package/dist-cms/packages/property-editors/label/manifests.js +10 -0
  441. package/dist-cms/packages/property-editors/label/property-editor-ui-label.element.d.ts +3 -4
  442. package/dist-cms/packages/property-editors/label/property-editor-ui-label.element.js +9 -9
  443. package/dist-cms/packages/property-editors/number-range/property-editor-ui-number-range.element.js +2 -3
  444. package/dist-cms/packages/property-editors/overlay-size/property-editor-ui-overlay-size.element.js +7 -1
  445. package/dist-cms/packages/publish-cache/manifests.js +2 -1
  446. package/dist-cms/packages/relations/relation-types/collection/repository/relation-type-collection.server.data-source.d.ts +1 -1
  447. package/dist-cms/packages/relations/relation-types/repository/detail/relation-type-detail.repository.d.ts +1 -1
  448. package/dist-cms/packages/relations/relation-types/repository/detail/relation-type-detail.server.data-source.d.ts +1 -1
  449. package/dist-cms/packages/relations/relation-types/workspace/relation-type/views/relation-type-detail-workspace-view.element.js +4 -0
  450. package/dist-cms/packages/relations/relations/collection/repository/relation-collection.server.data-source.d.ts +1 -1
  451. package/dist-cms/packages/relations/relations/reference/workspace-info-app/entity-references-workspace-view-info.element.js +7 -1
  452. package/dist-cms/packages/search/manifests.js +2 -1
  453. package/dist-cms/packages/segment/collection/repository/segment-collection.server.data-source.d.ts +1 -1
  454. package/dist-cms/packages/settings/advanced/manifests.js +2 -1
  455. package/dist-cms/packages/settings/structure/manifests.js +2 -1
  456. package/dist-cms/packages/settings/welcome/manifests.js +2 -1
  457. package/dist-cms/packages/static-file/repository/item/static-file-item.server.data-source.d.ts +1 -1
  458. package/dist-cms/packages/tags/repository/tag.repository.d.ts +2 -2
  459. package/dist-cms/packages/telemetry/manifests.js +2 -1
  460. package/dist-cms/packages/templating/menu/manifests.js +2 -1
  461. package/dist-cms/packages/templating/partial-views/entity-actions/rename/rename-partial-view.server.data-source.d.ts +1 -1
  462. package/dist-cms/packages/templating/partial-views/repository/item/partial-view-item.server.data-source.d.ts +1 -1
  463. package/dist-cms/packages/templating/partial-views/repository/partial-view-detail.server.data-source.d.ts +3 -3
  464. package/dist-cms/packages/templating/partial-views/tree/folder/repository/partial-view-folder.server.data-source.d.ts +2 -2
  465. package/dist-cms/packages/templating/partial-views/tree/folder/workspace/partial-view-folder-workspace-editor.element.d.ts +1 -5
  466. package/dist-cms/packages/templating/partial-views/tree/folder/workspace/partial-view-folder-workspace-editor.element.js +8 -22
  467. package/dist-cms/packages/templating/scripts/entity-actions/rename/rename-script.server.data-source.d.ts +1 -1
  468. package/dist-cms/packages/templating/scripts/repository/item/script-item.server.data-source.d.ts +1 -1
  469. package/dist-cms/packages/templating/scripts/repository/script-detail.server.data-source.d.ts +3 -3
  470. package/dist-cms/packages/templating/scripts/tree/folder/repository/script-folder.server.data-source.d.ts +2 -2
  471. package/dist-cms/packages/templating/scripts/tree/folder/workspace/script-folder-workspace-editor.element.d.ts +1 -5
  472. package/dist-cms/packages/templating/scripts/tree/folder/workspace/script-folder-workspace-editor.element.js +8 -22
  473. package/dist-cms/packages/templating/stylesheets/entity-actions/rename/rename-stylesheet.server.data-source.d.ts +1 -1
  474. package/dist-cms/packages/templating/stylesheets/repository/item/stylesheet-item.server.data-source.d.ts +1 -1
  475. package/dist-cms/packages/templating/stylesheets/repository/stylesheet-detail.server.data-source.d.ts +3 -3
  476. package/dist-cms/packages/templating/stylesheets/tree/folder/repository/stylesheet-folder.server.data-source.d.ts +2 -2
  477. package/dist-cms/packages/templating/stylesheets/tree/folder/workspace/stylesheet-folder-workspace-editor.element.d.ts +1 -5
  478. package/dist-cms/packages/templating/stylesheets/tree/folder/workspace/stylesheet-folder-workspace-editor.element.js +8 -22
  479. package/dist-cms/packages/templating/templates/repository/detail/template-detail.server.data-source.d.ts +3 -3
  480. package/dist-cms/packages/templating/templates/repository/item/template-item.server.data-source.d.ts +1 -1
  481. package/dist-cms/packages/templating/templates/search/template-search.repository.d.ts +1 -1
  482. package/dist-cms/packages/templating/templates/search/template-search.server.data-source.d.ts +1 -1
  483. package/dist-cms/packages/templating/templates/search/template.search-provider.d.ts +1 -1
  484. package/dist-cms/packages/templating/templates/workspace/template-workspace.context.d.ts +1 -1
  485. package/dist-cms/packages/tiptap/components/cascading-menu-popover/cascading-menu-popover.element.d.ts +1 -0
  486. package/dist-cms/packages/tiptap/components/cascading-menu-popover/cascading-menu-popover.element.js +23 -9
  487. package/dist-cms/packages/tiptap/components/toolbar/style-menu.tiptap-toolbar-api.d.ts +1 -0
  488. package/dist-cms/packages/tiptap/components/toolbar/style-menu.tiptap-toolbar-api.js +29 -11
  489. package/dist-cms/packages/tiptap/components/toolbar/tiptap-toolbar-button.element.js +2 -2
  490. package/dist-cms/packages/tiptap/components/toolbar/tiptap-toolbar-menu.element.js +12 -4
  491. package/dist-cms/packages/tiptap/extensions/manifests.js +9 -9
  492. package/dist-cms/packages/tiptap/extensions/table/components/table-toolbar-menu.element.js +1 -1
  493. package/dist-cms/packages/tiptap/extensions/table/table.tiptap-toolbar-api.d.ts +1 -0
  494. package/dist-cms/packages/tiptap/extensions/table/table.tiptap-toolbar-api.js +5 -0
  495. package/dist-cms/packages/tiptap/extensions/toolbar/clear-formatting.tiptap-toolbar-api.js +1 -1
  496. package/dist-cms/packages/tiptap/extensions/toolbar/font-family.tiptap-toolbar-api.d.ts +1 -0
  497. package/dist-cms/packages/tiptap/extensions/toolbar/font-family.tiptap-toolbar-api.js +5 -1
  498. package/dist-cms/packages/tiptap/extensions/toolbar/font-size.tiptap-toolbar-api.d.ts +1 -0
  499. package/dist-cms/packages/tiptap/extensions/toolbar/font-size.tiptap-toolbar-api.js +5 -1
  500. package/dist-cms/packages/tiptap/extensions/toolbar/text-color-background.tiptap-toolbar-api.js +1 -1
  501. package/dist-cms/packages/tiptap/extensions/toolbar/text-color-foreground.tiptap-toolbar-api.js +1 -1
  502. package/dist-cms/packages/tiptap/extensions/types.d.ts +1 -1
  503. package/dist-cms/packages/tiptap/property-editors/tiptap/components/property-editor-ui-tiptap-statusbar-configuration.element.js +18 -10
  504. package/dist-cms/packages/tiptap/property-editors/tiptap/components/property-editor-ui-tiptap-toolbar-configuration.element.js +21 -12
  505. package/dist-cms/packages/tiptap/property-editors/tiptap/constants.d.ts +1 -0
  506. package/dist-cms/packages/tiptap/property-editors/tiptap/constants.js +1 -0
  507. package/dist-cms/packages/tiptap/property-editors/tiptap/contexts/tiptap-statusbar-configuration.context-token.d.ts +3 -0
  508. package/dist-cms/packages/tiptap/property-editors/tiptap/contexts/tiptap-statusbar-configuration.context-token.js +2 -0
  509. package/dist-cms/packages/tiptap/property-editors/tiptap/contexts/tiptap-statusbar-configuration.context.js +2 -1
  510. package/dist-cms/packages/translation/menu/manifests.js +2 -1
  511. package/dist-cms/packages/ufm/filters/bytes.filter.d.ts +5 -0
  512. package/dist-cms/packages/ufm/filters/bytes.filter.js +10 -0
  513. package/dist-cms/packages/ufm/filters/manifests.js +7 -0
  514. package/dist-cms/packages/umbraco-news/manifests.js +2 -1
  515. package/dist-cms/packages/user/current-user/current-user.context.d.ts +1 -1
  516. package/dist-cms/packages/user/current-user/current-user.context.js +1 -1
  517. package/dist-cms/packages/user/current-user/repository/current-user.repository.d.ts +6 -6
  518. package/dist-cms/packages/user/current-user/repository/current-user.server.data-source.d.ts +4 -4
  519. package/dist-cms/packages/user/section/sidebar-app/manifests.js +2 -1
  520. package/dist-cms/packages/user/user/client-credential/repository/data-source/user-client-credential.server.data-source.d.ts +2 -2
  521. package/dist-cms/packages/user/user/collection/repository/user-collection.repository.d.ts +1 -1
  522. package/dist-cms/packages/user/user/collection/repository/user-collection.server.data-source.d.ts +1 -1
  523. package/dist-cms/packages/user/user/invite/repository/invite-user-server.data-source.d.ts +1 -1
  524. package/dist-cms/packages/user/user/invite/repository/invite-user.repository.d.ts +2 -2
  525. package/dist-cms/packages/user/user/repository/avatar/user-avatar.repository.d.ts +2 -2
  526. package/dist-cms/packages/user/user/repository/change-password/change-user-password.repository.d.ts +1 -1
  527. package/dist-cms/packages/user/user/repository/detail/user-detail.server.data-source.d.ts +4 -4
  528. package/dist-cms/packages/user/user/repository/disable/disable-user.repository.d.ts +1 -1
  529. package/dist-cms/packages/user/user/repository/enable/enable-user.repository.d.ts +1 -1
  530. package/dist-cms/packages/user/user/repository/item/user-item.server.data-source.d.ts +1 -1
  531. package/dist-cms/packages/user/user/repository/unlock/unlock-user.repository.d.ts +1 -1
  532. package/dist-cms/packages/user/user/repository/user.repository.d.ts +3 -3
  533. package/dist-cms/packages/user/user/workspace/user/user-workspace-editor.element.js +7 -12
  534. package/dist-cms/packages/user/user/workspace/user/user-workspace.context.d.ts +3 -3
  535. package/dist-cms/packages/user/user/workspace/user/user-workspace.context.js +5 -0
  536. package/dist-cms/packages/user/user-group/collection/repository/user-group-collection.repository.d.ts +1 -1
  537. package/dist-cms/packages/user/user-group/collection/repository/user-group-collection.server.data-source.d.ts +1 -1
  538. package/dist-cms/packages/user/user-group/repository/detail/user-group-detail.server.data-source.d.ts +3 -3
  539. package/dist-cms/packages/user/user-group/repository/item/user-group-item.server.data-source.d.ts +1 -1
  540. package/dist-cms/packages/webhook/webhook/collection/repository/webhook-collection.server.data-source.d.ts +1 -1
  541. package/dist-cms/packages/webhook/webhook/repository/detail/webhook-detail.server.data-source.d.ts +3 -3
  542. package/dist-cms/packages/webhook/webhook/repository/item/webhook-item.server.data-source.d.ts +1 -1
  543. package/dist-cms/packages/webhook/webhook-delivery/collection/repository/webhook-delivery-collection.server.data-source.d.ts +1 -1
  544. package/dist-cms/packages/webhook/webhook-event/repository/webhook-event.repository.d.ts +1 -1
  545. package/dist-cms/packages/webhook/webhook-event/repository/webhook-event.server.data-source.d.ts +1 -1
  546. package/dist-cms/tsconfig.build.tsbuildinfo +1 -1
  547. package/dist-cms/umbraco-package-schema.json +584 -194
  548. package/dist-cms/umbraco-package.json +1 -1
  549. package/dist-cms/vscode-html-custom-data.json +100 -35
  550. package/examples/collection/README.md +20 -0
  551. package/examples/collection/collection/card-view/collection-view.element.ts +82 -0
  552. package/examples/collection/collection/card-view/manifests.ts +23 -0
  553. package/examples/collection/collection/constants.ts +1 -0
  554. package/examples/collection/collection/manifests.ts +20 -0
  555. package/examples/collection/collection/repository/collection.repository.ts +64 -0
  556. package/examples/collection/collection/repository/constants.ts +1 -0
  557. package/examples/collection/collection/repository/manifests.ts +10 -0
  558. package/examples/collection/collection/repository/types.ts +9 -0
  559. package/examples/collection/collection/table-view/collection-view.element.ts +89 -0
  560. package/examples/collection/collection/table-view/manifests.ts +23 -0
  561. package/examples/collection/dashboard-with-collection/dashboard-with-collection.element.ts +23 -0
  562. package/examples/collection/dashboard-with-collection/manifests.ts +14 -0
  563. package/examples/collection/index.ts +9 -0
  564. package/examples/collection/workspace-view-with-collection/manifests.ts +25 -0
  565. package/examples/validation-context/index.ts +2 -1
  566. package/package.json +4 -4
  567. /package/dist-cms/packages/{members/member-type/tree/reload-tree-item-children → core/entity/entity-type}/manifests.d.ts +0 -0
  568. /package/dist-cms/packages/core/section/conditions/{section-user-permission.condition.js → section-user-permission/section-user-permission.condition.js} +0 -0
@@ -1,18 +1,18 @@
1
- function Z(n){this.content=n}Z.prototype={constructor:Z,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),i=r.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new Z(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Z(t)},addToStart:function(n,e){return new Z([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Z(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),i=r.find(n);return s.splice(i==-1?s.length:i,0,e,t),new Z(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Z.from(n),n.size?new Z(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Z.from(n),n.size?new Z(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Z.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Z.from=function(n){if(n instanceof Z)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Z(e)};function So(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)t++;return t}if(s.content.size||i.content.size){let o=So(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function wo(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,d=Math.min(o.text.length,l.text.length);for(;c<d&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=wo(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class b{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,i){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let i="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new b(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let i=0,o=0;o<t;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),s+=l.nodeSize),o=a}return new b(r,s)}cutByIndex(e,t){return e==t?b.empty:e==0&&t==this.content.length?this:new b(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new b(s,i)}addToStart(e){return new b([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new b(this.content.concat(e),this.size+e.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 new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return So(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return wo(this,e,t,r)}findIndex(e,t=-1){if(e==0)return Vn(0,e);if(e==this.size)return Vn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,s=0;;r++){let i=this.child(r),o=s+i.nodeSize;if(o>=e)return o==e||t>0?Vn(r+1,o):Vn(r,s);s=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return b.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new b(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return b.empty;let t,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new b(t||e,r)}static from(e){if(!e)return b.empty;if(e instanceof b)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new b([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}b.empty=new b([],0);const ys={index:0,offset:0};function Vn(n,e){return ys.index=n,ys.offset=e,ys}function Wn(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Wn(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Wn(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let B=class po{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||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&&Wn(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 new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return po.none;if(e instanceof po)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};B.none=[];class jn extends Error{}class w{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=xo(this.content,e+this.openStart,t);return r&&new w(r,this.openStart,this.openEnd)}removeBetween(e,t){return new w(Co(this.content,e+this.openStart,t+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(e,t){if(!t)return w.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new w(b.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new w(e,r,s)}}w.empty=new w(b.empty,0,0);function Co(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(s==e||i.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(Co(i.content,e-s-1,t-s-1)))}function xo(n,e,t,r){let{index:s,offset:i}=n.findIndex(e),o=n.maybeChild(s);if(i==e||o.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=xo(o.content,e-i-1,t);return l&&n.replaceChild(s,o.copy(l))}function Ud(n,e,t){if(t.openStart>n.depth)throw new jn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new jn("Inconsistent open depths");return Mo(n,e,t,0)}function Mo(n,e,t,r){let s=n.index(r),i=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let o=Mo(n,e,t,r+1);return i.copy(i.content.replaceChild(s,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return ht(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Jd(t,n);return ht(i,Ao(n,o,l,e,r))}else return ht(i,Kn(n,e,r))}function To(n,e){if(!e.type.compatibleContent(n.type))throw new jn("Cannot join "+e.type.name+" onto "+n.type.name)}function bs(n,e,t){let r=n.node(t);return To(r,e.node(t)),r}function ft(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Zt(n,e,t,r){let s=(e||n).node(t),i=0,o=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(ft(n.nodeAfter,r),i++));for(let l=i;l<o;l++)ft(s.child(l),r);e&&e.depth==t&&e.textOffset&&ft(e.nodeBefore,r)}function ht(n,e){return n.type.checkContent(e),n.copy(e)}function Ao(n,e,t,r,s){let i=n.depth>s&&bs(n,e,s+1),o=r.depth>s&&bs(t,r,s+1),l=[];return Zt(null,n,s,l),i&&o&&e.index(s)==t.index(s)?(To(i,o),ft(ht(i,Ao(n,e,t,r,s+1)),l)):(i&&ft(ht(i,Kn(n,e,s+1)),l),Zt(e,t,s,l),o&&ft(ht(o,Kn(t,r,s+1)),l)),Zt(r,null,s,l),new b(l)}function Kn(n,e,t){let r=[];if(Zt(null,n,t,r),n.depth>t){let s=bs(n,e,t+1);ft(ht(s,Kn(n,e,t+1)),r)}return Zt(e,null,t,r),new b(r)}function Jd(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(b.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class Hn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,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 new 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 new 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 r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}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 r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return B.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}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 r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Un(this,e,r);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(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,i=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new Hn(t,r,i)}static resolveCached(e,t){let r=Eo.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==t)return o}else Eo.set(e,r=new qd);let s=r.elts[r.i]=Hn.resolve(e,t);return r.i=(r.i+1)%_d,s}}class qd{constructor(){this.elts=[],this.i=0}}const _d=12,Eo=new WeakMap;class Un{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Gd=Object.create(null);let Te=class mo{constructor(e,t,r,s=B.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||b.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,r,s=0){this.content.nodesBetween(e,t,r,s,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,r,s){return this.content.textBetween(e,t,r,s)}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,r){return this.type==e&&Wn(this.attrs,t||e.defaultAttrs||Gd)&&B.sameSet(this.marks,r||B.none)}copy(e=null){return e==this.content?this:new mo(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new mo(this.type,this.attrs,this.content,e)}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,r=!1){if(e==t)return w.empty;let s=this.resolve(e),i=this.resolve(t),o=r?0:s.sharedDepth(t),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new w(c,s.depth-o,i.depth-o)}replace(e,t,r){return Ud(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return Hn.resolveCached(this,e)}resolveNoCache(e){return Hn.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}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()+")"),Oo(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=b.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,t);return o?o.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),this.type.checkAttrs(this.attrs);let e=B.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!B.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let 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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=b.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,r);return i.type.checkAttrs(i.attrs),i}};Te.prototype.text=void 0;class us extends Te{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Oo(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new us(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new us(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(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 Oo(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Tt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Yd(e,t);if(r.next==null)return Tt.empty;let s=No(r);r.next&&r.err("Unexpected trailing text");let i=ru(nu(s));return su(i,r),i}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,r=e.childCount){let s=this;for(let i=t;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}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 r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function i(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return b.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:d,next:u}=o.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let f=i(u,l.concat(d));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
2
- `)}}Tt.empty=new Tt(!0);class Yd{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 new SyntaxError(e+" (in content expression '"+this.string+"')")}}function No(n){let e=[];do e.push(Xd(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Xd(n){let e=[];do e.push(Qd(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Qd(n){let e=tu(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Zd(n,e);else break;return e}function vo(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Zd(n,e){let t=vo(n),r=t;return n.eat(",")&&(n.next!="}"?r=vo(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function eu(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let i in t){let o=t[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function tu(n){if(n.eat("(")){let e=No(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=eu(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function nu(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let d=t();s(i(o.expr,a),d),a=d}if(o.max==-1)s(i(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let d=t();r(a,d),s(i(o.expr,a),d),a=d}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Ro(n,e){return e-n}function Do(n,e){let t=[];return r(e),t.sort(Ro);function r(s){let i=n[s];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(s);for(let o=0;o<i.length;o++){let{term:l,to:a}=i[o];!l&&t.indexOf(a)==-1&&r(a)}}}function ru(n){let e=Object.create(null);return t(Do(n,0));function t(r){let s=[];r.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);Do(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new Tt(r.indexOf(n.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(Ro);i.next.push({type:s[o][0],next:e[l.join(",")]||t(l)})}return i}}function su(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];o.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Io(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Lo(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let i=n[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function Po(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let i=n[s];i.validate&&i.validate(e[s])}}function Bo(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new ou(n,r,e[r]);return t}let zo=class jd{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Bo(e,r.attrs),this.defaultAttrs=Io(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Tt.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:Lo(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Te(this,this.computeAttrs(e),b.from(t),B.setFrom(r))}createChecked(e=null,t,r){return t=b.from(t),this.checkContent(t),new Te(this,this.computeAttrs(e),t,B.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=b.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let s=this.contentMatch.matchFragment(t),i=s&&s.fillBefore(b.empty,!0);return i?new Te(this,e,t.append(i),B.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Po(this.attrs,e,"node",this.name)}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 r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:B.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,o)=>r[i]=new jd(i,t,o));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function iu(n,e,t){let r=t.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}class ou{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?iu(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class fs{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=Bo(e,s.attrs),this.excluded=null;let i=Io(this.attrs);this.instance=i?new B(this,i):null}create(e=null){return!e&&this.instance?this.instance:new B(this,Lo(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new fs(i,s++,t,o)),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]}checkAttrs(e){Po(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Ho{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=Z.from(e.nodes),t.marks=Z.from(e.marks||{}),this.nodes=zo.compile(this.spec.nodes,this),this.marks=fs.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=Tt.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Fo(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:Fo(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof zo){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,s)}text(e,t){let r=this.nodes.text;return new us(r,r.defaultAttrs,e,B.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Te.fromJSON(this,e)}markFromJSON(e){return B.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Fo(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],i=n.marks[s],o=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function lu(n){return n.tag!=null}function au(n){return n.style!=null}class Ue{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(lu(s))this.tags.push(s);else if(au(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new jo(this,t,!1);return r.addAll(e,B.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new jo(this,t,!0);return r.addAll(e,B.none,t.from,t.to),w.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(uu(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,t,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<i)break}t.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Ko(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Ko(o)),o.node||o.ignore||o.mark||(o.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ue(e,Ue.schemaRules(e)))}}const $o={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},cu={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Vo={ol:!0,ul:!0},en=1,ks=2,Jn=4;function Wo(n,e,t){return e!=null?(e?en:0)|(e==="full"?ks:0):n&&n.whitespace=="pre"?en|ks:t&-5}class qn{constructor(e,t,r,s,i,o){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=B.none,this.match=i||(o&Jn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(b.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&en)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=b.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(b.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&&!$o.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class jo{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,i,o=Wo(null,t.preserveWhitespace,0)|(r?Jn:0);s?i=new qn(s.type,s.attrs,B.none,!0,t.topMatch||s.type.contentMatch,o):r?i=new qn(null,null,B.none,!0,null,o):i=new qn(e.schema.topNodeType,null,B.none,!0,null,o),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 r=e.nodeValue,s=this.top,i=s.options&ks?"full":this.localPreserveWS||(s.options&en)>0;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)i!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
3
- `);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=s.content[s.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Vo.hasOwnProperty(o)&&this.parser.normalizeLists&&du(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:cu.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if($o.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
- `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,s){let i,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r)||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t){let r,s;for(let i=this.open;i>=0;i--){let o=this.nodes[i],l=o.findWrapping(e);if(l&&(!r||r.length>l.length)&&(r=l,s=o,!l.length)||o.solid)break}if(!r)return null;this.sync(s);for(let i=0;i<r.length;i++)t=this.enterInner(r[i],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let r=this.findPlace(e,t);if(r){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=B.none;for(let o of r.concat(e.marks))(s.type?s.type.allowsMarkType(o.type):Uo(o.type,e.type))&&(i=o.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,r,s){let i=this.findPlace(e.create(t),r);return i&&(i=this.enterInner(e,t,r,!0,s)),i}enterInner(e,t,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Wo(e,i,o.options);o.options&Jn&&o.content.length==0&&(l|=Jn);let a=B.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Uo(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new qn(e,t,a,s,null,l)),this.open++,r}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;this.localPreserveWS&&(this.nodes[t].options|=en)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].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,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].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("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function du(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Vo.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function uu(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Ko(n){let e={};for(let t in n)e[t]=n[t];return e}function Uo(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&o(d))return!0}};if(o(s.contentMatch))return!0}}class At{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Ss(t).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],d=this.serializeMark(c,o.isInline,t);d&&(i.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=_n(Ss(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&_n(Ss(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return _n(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new At(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Jo(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Jo(e.marks)}}function Jo(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Ss(n){return n.document||window.document}const qo=new WeakMap;function fu(n){let e=qo.get(n);return e===void 0&&qo.set(n,e=hu(n)),e}function hu(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function _n(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=fu(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(t=s.slice(0,o),s=s.slice(o+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=_n(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const _o=65535,Go=Math.pow(2,16);function pu(n,e){return n+e*Go}function Yo(n){return n&_o}function mu(n){return(n-(n&_o))/Go}const Xo=1,Qo=2,Gn=4,Zo=8;class ws{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Zo)>0}get deletedBefore(){return(this.delInfo&(Xo|Gn))>0}get deletedAfter(){return(this.delInfo&(Qo|Gn))>0}get deletedAcross(){return(this.delInfo&Gn)>0}}class pe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&pe.empty)return pe.empty}recover(e){let t=0,r=Yo(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+mu(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+o],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+s+(f<0?0:d);if(r)return h;let p=e==(t<0?a:u)?null:pu(l/3,e-a),m=e==a?Qo:e==u?Xo:Gn;return(t<0?e!=a:e!=u)&&(m|=Zo),new ws(h,m,p)}s+=d-c}return r?e+s:new ws(e+s,0,null)}touches(e,t){let r=0,s=Yo(t),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+t],d=this.ranges[s+r];e(l,l+c,a,a+d),i+=d-c}}invert(){return new pe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?pe.empty:new pe(e<0?[0,-e,0]:[0,0,e])}}pe.empty=new pe([]);class _t{constructor(e=[],t,r=0,s=e.length){this.maps=e,this.mirror=t,this.from=r,this.to=s}slice(e=0,t=this.maps.length){return new _t(this.maps,this.mirror,e,t)}copy(){return new _t(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,r=this.maps.length;t<e.maps.length;t++){let s=e.getMirror(t);this.appendMap(e.maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this.maps.length+e.maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e.maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new _t;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this.maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this.maps[i],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this.maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new ws(e,s,null)}}const Cs=Object.create(null);class ne{getMap(){return pe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Cs[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Cs)throw new RangeError("Duplicate use of step JSON ID "+e);return Cs[e]=t,t.prototype.jsonID=e,t}}class J{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new J(e,null)}static fail(e){return new J(null,e)}static fromReplace(e,t,r,s){try{return J.ok(e.replace(t,r,s))}catch(i){if(i instanceof jn)return J.fail(i.message);throw i}}}function xs(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(xs(i.content,e,i))),i.isInline&&(i=e(i,t,s)),r.push(i)}return b.fromArray(r)}class ct extends ne{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new w(xs(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),t.openStart,t.openEnd);return J.fromReplace(e,this.from,this.to,i)}invert(){return new Le(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new ct(t.pos,r.pos,this.mark)}merge(e){return e instanceof ct&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ct(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ct(t.from,t.to,e.markFromJSON(t.mark))}}ne.jsonID("addMark",ct);class Le extends ne{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new w(xs(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return J.fromReplace(e,this.from,this.to,r)}invert(){return new ct(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Le(t.pos,r.pos,this.mark)}merge(e){return e instanceof Le&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Le(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Le(t.from,t.to,e.markFromJSON(t.mark))}}ne.jsonID("removeMark",Le);class dt extends ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return J.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return J.fromReplace(e,this.pos,this.pos+1,new w(b.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new dt(this.pos,t.marks[s]);return new dt(this.pos,this.mark)}}return new Gt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new dt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new dt(t.pos,e.markFromJSON(t.mark))}}ne.jsonID("addNodeMark",dt);class Gt extends ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return J.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return J.fromReplace(e,this.pos,this.pos+1,new w(b.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new dt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Gt(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Gt(t.pos,e.markFromJSON(t.mark))}}ne.jsonID("removeNodeMark",Gt);class Q extends ne{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&Ms(e,this.from,this.to)?J.fail("Structure replace would overwrite content"):J.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new pe([this.from,this.to-this.from,this.slice.size])}invert(e){return new Q(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new Q(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof Q)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?w.empty:new w(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Q(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?w.empty:new w(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Q(e.from,this.to,t,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(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Q(t.from,t.to,w.fromJSON(e,t.slice),!!t.structure)}}ne.jsonID("replace",Q);class Y extends ne{constructor(e,t,r,s,i,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Ms(e,this.from,this.gapFrom)||Ms(e,this.gapTo,this.to)))return J.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return J.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?J.fromReplace(e,this.from,this.to,r):J.fail("Content does not fit in gap")}getMap(){return new pe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Y(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||i>r.pos?null:new Y(t.pos,r.pos,s,i,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(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Y(t.from,t.to,t.gapFrom,t.gapTo,w.fromJSON(e,t.slice),t.insert,!!t.structure)}}ne.jsonID("replaceAround",Y);function Ms(n,e,t){let r=n.resolve(e),s=t-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function gu(n,e,t,r){let s=[],i=[],o,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(p)||(o&&o.to==f&&o.mark.eq(u[m])?o.to=h:s.push(o=new Le(f,h,u[m])));l&&l.to==f?l.to=h:i.push(l=new ct(f,h,r))}}),s.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function yu(n,e,t,r){let s=[],i=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;i++;let a=null;if(r instanceof fs){let c=o.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],f;for(let h=0;h<s.length;h++){let p=s[h];p.step==i-1&&u.eq(s[h].style)&&(f=p)}f?(f.to=c,f.step=i):s.push({style:u,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(o=>n.step(new Le(o.from,o.to,o.style)))}function Ts(n,e,t,r=t.contentMatch,s=!0){let i=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Q(l,d,w.empty));else{r=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new Le(l,d,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new w(b.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new Q(l+f.index,l+f.index+f[0].length,p))}}l=d}if(!r.validEnd){let a=r.fillBefore(b.empty,!0);n.replace(l,l,new w(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function bu(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function vt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let s=n.$from.node(r),i=n.$from.index(r),o=n.$to.indexAfter(r);if(r<n.depth&&s.canReplace(i,o,t))return r;if(r==0||s.type.spec.isolating||!bu(s,i,o))break}return null}function ku(n,e,t){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),a=o,c=l,d=b.empty,u=0;for(let p=i,m=!1;p>t;p--)m||r.index(p)>0?(m=!0,d=b.from(r.node(p).copy(d)),u++):a--;let f=b.empty,h=0;for(let p=i,m=!1;p>t;p--)m||s.after(p+1)<s.end(p)?(m=!0,f=b.from(s.node(p).copy(f)),h++):c++;n.step(new Y(a,c,o,l,new w(d.append(f),u,h),d.size-u,!0))}function As(n,e,t=null,r=n){let s=Su(n,e),i=s&&wu(r,e);return i?s.map(el).concat({type:e,attrs:t}).concat(i.map(el)):null}function el(n){return{type:n,attrs:null}}function Su(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return t.canReplaceWith(r,s,o)?i:null}function wu(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function Cu(n,e,t){let r=b.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=b.from(t[o].type.create(t[o].attrs,r))}let s=e.start,i=e.end;n.step(new Y(s,i,s,i,new w(r,0,0),t.length,!0))}function xu(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,a)&&Mu(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&nl(n,o,l,i),Ts(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let d=n.mapping.slice(i),u=d.map(l,1),f=d.map(l+o.nodeSize,1);return n.step(new Y(u,f,u+1,f-1,new w(b.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&tl(n,o,l,i),!1}})}function tl(n,e,t,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let a=n.mapping.slice(r).map(t+1+i+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function nl(n,e,t,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+i);n.replaceWith(o,o+1,e.type.schema.text(`
5
- `))}})}function Mu(n,e,t){let r=n.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,t)}function Tu(n,e,t,r,s){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let o=t.create(r,null,s||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,o);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Y(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new w(b.from(o),0,0),1,!0))}function Pe(n,e,t=1,r){let s=n.resolve(e),i=s.depth-t,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>i;c--,d--){let u=s.node(c),f=s.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!m.type.validContent(h))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function Au(n,e,t=1,r){let s=n.doc.resolve(e),i=b.empty,o=b.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){i=b.from(s.node(l).copy(i));let d=r&&r[c];o=b.from(d?d.type.create(d.attrs,o):s.node(l).copy(o))}n.step(new Q(e,e,new w(i.append(o),t,t),!0))}function Je(n,e){let t=n.resolve(e),r=t.index();return rl(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Eu(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function rl(n,e){return!!(n&&e&&!n.isLeaf&&Eu(n,e))}function Yn(n,e,t=-1){let r=n.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):t>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&rl(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=t<0?r.before(s):r.after(s)}}function Ou(n,e,t){let r=null,{linebreakReplacement:s}=n.doc.type.schema,i=n.doc.resolve(e-t),o=i.node().type;if(s&&o.inlineContent){let d=o.whitespace=="pre",u=!!o.contentMatch.matchType(s);d&&!u?r=!1:!d&&u&&(r=!0)}let l=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);nl(n,d.node(),d.before(),l)}o.inlineContent&&Ts(n,e+t-1,o,i.node().contentMatchAt(i.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new Q(c,a.map(e+t,-1),w.empty,!0)),r===!0){let d=n.doc.resolve(c);tl(n,d.node(),d.before(),n.steps.length)}return n}function Nu(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,t))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,t))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function sl(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let i=0;i<t.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),d=!1;if(i==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Xn(n,e,t=e,r=w.empty){if(e==t&&!r.size)return null;let s=n.resolve(e),i=n.resolve(t);return il(s,i,r)?new Q(e,t,r):new vu(s,i,r).fit()}function il(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class vu{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=b.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=b.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new w(i,o,l);return e>-1?new Y(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Q(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=Es(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(o?c.matchType(o.type)||(u=c.fillBefore(b.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(t==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=Es(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new w(e,t+1,Math.max(r,s.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=Es(e,t);if(s.childCount<=1&&t>0){let i=e.size-t<=t+s.size;this.unplaced=new w(tn(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new w(tn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:s,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[t];if(s){for(let m=0;m<s.childCount;m++)d.push(s.child(m));u=u.matchFragment(s)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(ol(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=nn(this.placed,t,b.from(d)),this.frontier[t].match=u,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?w.empty:new w(tn(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new w(tn(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Os(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:s}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Os(e,t,s,r,i);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Os(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:o,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=nn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,t=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=nn(this.placed,this.depth,b.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(b.empty,!0);t.childCount&&(this.placed=nn(this.placed,this.frontier.length,t))}}function tn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(tn(n.firstChild.content,e-1,t)))}function nn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(nn(n.lastChild.content,e-1,t)))}function Es(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function ol(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,ol(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(b.empty,!0)))),n.copy(r)}function Os(n,e,t,r,s){let i=n.node(e),o=s?n.indexAfter(e):n.index(e);if(o==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!Ru(t,i.content,o)?l:null}function Ru(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Du(n){return n.spec.defining||n.spec.definingForContent}function Iu(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),i=n.doc.resolve(t);if(il(s,i,r))return n.step(new Q(e,t,r));let o=al(s,n.doc.resolve(t));o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:s.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],d=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f],p=Du(h.type);if(p&&!h.sameMarkup(s.node(Math.abs(l)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],y=!0;g<0&&(y=!1,g=-g);let S=s.node(g-1),A=s.index(g-1);if(S.canReplaceWith(A,A,p.type,p.marks))return n.replace(s.before(g),y?i.after(g):t,new w(ll(r.content,0,r.openStart,h),h,r.openEnd))}}let u=n.steps.length;for(let f=o.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>u));f--){let h=o[f];h<0||(e=s.before(h),t=i.after(h))}}function ll(n,e,t,r,s){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(ll(i.content,e+1,t,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(n).append(n);n=o.append(i.matchFragment(o).fillBefore(b.empty,!0))}return n}function Lu(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=Nu(n.doc,e,r.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new w(b.from(r),0,0))}function Pu(n,e,t){let r=n.doc.resolve(e),s=n.doc.resolve(t),i=al(r,s);for(let o=0;o<i.length;o++){let l=i[o],a=o==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return n.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&s.end(o)-t!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function al(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let s=r;s>=0;s--){let i=n.start(s);if(i<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&t.push(s)}return t}class Yt extends ne{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return J.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return J.fromReplace(e,this.pos,this.pos+1,new w(b.from(s),0,t.isLeaf?0:1))}getMap(){return pe.empty}invert(e){return new Yt(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Yt(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Yt(t.pos,t.attr,t.value)}}ne.jsonID("attr",Yt);class Fn extends ne{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return J.ok(r)}getMap(){return pe.empty}invert(e){return new Fn(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Fn(t.attr,t.value)}}ne.jsonID("docAttr",Fn);let Rt=class extends Error{};Rt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},Rt.prototype=Object.create(Error.prototype),Rt.prototype.constructor=Rt,Rt.prototype.name="TransformError";class Ns{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new _t}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Rt(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=w.empty){let s=Xn(this.doc,e,t,r);return s&&this.step(s),this}replaceWith(e,t,r){return this.replace(e,t,new w(b.from(r),0,0))}delete(e,t){return this.replace(e,t,w.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Iu(this,e,t,r),this}replaceRangeWith(e,t,r){return Lu(this,e,t,r),this}deleteRange(e,t){return Pu(this,e,t),this}lift(e,t){return ku(this,e,t),this}join(e,t=1){return Ou(this,e,t),this}wrap(e,t){return Cu(this,e,t),this}setBlockType(e,t=e,r,s=null){return xu(this,e,t,r,s),this}setNodeMarkup(e,t,r=null,s){return Tu(this,e,t,r,s),this}setNodeAttribute(e,t,r){return this.step(new Yt(e,t,r)),this}setDocAttribute(e,t){return this.step(new Fn(e,t)),this}addNodeMark(e,t){return this.step(new dt(e,t)),this}removeNodeMark(e,t){if(!(t instanceof B)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new Gt(e,t)),this}split(e,t=1,r){return Au(this,e,t,r),this}addMark(e,t,r){return gu(this,e,t,r),this}removeMark(e,t,r){return yu(this,e,t,r),this}clearIncompatible(e,t,r){return Ts(this,e,t,r),this}}const vs=Object.create(null);class E{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new cl(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=w.empty){let r=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?w.empty:t),l==0&&fl(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),fl(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let s=e.parent.inlineContent?new T(e):Dt(e.node(0),e.parent,e.pos,e.index(),t,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=t<0?Dt(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):Dt(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new fe(e.node(0))}static atStart(e){return Dt(e,e,0,0,1)||new fe(e)}static atEnd(e){return Dt(e,e,e.content.size,e.childCount,-1)||new fe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=vs[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in vs)throw new RangeError("Duplicate use of selection JSON ID "+e);return vs[e]=t,t.prototype.jsonID=e,t}getBookmark(){return T.between(this.$anchor,this.$head).getBookmark()}}E.prototype.visible=!0;class cl{constructor(e,t){this.$from=e,this.$to=t}}let dl=!1;function ul(n){!dl&&!n.parent.inlineContent&&(dl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class T extends E{constructor(e,t=e){ul(e),ul(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return E.near(r);let s=e.resolve(t.map(this.anchor));return new T(s.parent.inlineContent?s:r,r)}replace(e,t=w.empty){if(super.replace(e,t),t==w.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof T&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new hs(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new T(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let i=E.findFrom(t,r,!0)||E.findFrom(t,-r,!0);if(i)t=i.$head;else return E.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(E.findFrom(e,-r,!0)||E.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new T(e,t)}}E.jsonID("text",T);class hs{constructor(e,t){this.anchor=e,this.head=t}map(e){return new hs(e.map(this.anchor),e.map(this.head))}resolve(e){return T.between(e.resolve(this.anchor),e.resolve(this.head))}}class x extends E{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),i=e.resolve(s);return r?E.near(i):new x(i)}content(){return new w(b.from(this.node),0,0)}eq(e){return e instanceof x&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new go(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new x(e.resolve(t.anchor))}static create(e,t){return new x(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}x.prototype.visible=!1,E.jsonID("node",x);class go{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new hs(r,r):new go(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&x.isSelectable(r)?new x(t):E.near(t)}}class fe extends E{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=w.empty){if(t==w.empty){e.delete(0,e.doc.content.size);let r=E.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new fe(e)}map(e){return new fe(e)}eq(e){return e instanceof fe}getBookmark(){return Bu}}E.jsonID("all",fe);const Bu={map(){return this},resolve(n){return new fe(n)}};function Dt(n,e,t,r,s,i=!1){if(e.inlineContent)return T.create(n,t);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&x.isSelectable(l))return x.create(n,t-(s<0?l.nodeSize:0))}else{let a=Dt(n,l,t+s,s<0?l.childCount:0,s,i);if(a)return a}t+=l.nodeSize*s}return null}function fl(n,e,t){let r=n.steps.length-1;if(r<e)return;let s=n.steps[r];if(!(s instanceof Q||s instanceof Y))return;let i=n.mapping.maps[r],o;i.forEach((l,a,c,d)=>{o==null&&(o=d)}),n.setSelection(E.near(n.doc.resolve(o),t))}const hl=1,pl=2,ml=4;class zu extends Ns{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|hl)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&hl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=pl,this}ensureMarks(e){return B.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&pl)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||B.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(t);i=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,i)),this.selection.empty||this.setSelection(E.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ml,this}get scrolledIntoView(){return(this.updated&ml)>0}}function gl(n,e){return!e||!n?n:n.bind(e)}class rn{constructor(e,t,r){this.name=e,this.init=gl(t.init,r),this.apply=gl(t.apply,r)}}const Hu=[new rn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new rn("selection",{init(n,e){return n.selection||E.atStart(e.doc)},apply(n){return n.selection}}),new rn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new rn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Rs{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Hu.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new rn(r.key,r.spec.state,r))})}}class qt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=s?s[o].n:0,c=s?s[o].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<o?{state:r,n:t.length}:{state:this,n:0})}t.push(d),r=r.applyInner(d),i=!0}s&&(s[o]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new qt(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new zu(this)}static create(e){let t=new Rs(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new qt(t);for(let s=0;s<t.fields.length;s++)r[t.fields[s].name]=t.fields[s].init(e,r);return r}reconfigure(e){let t=new Rs(this.schema,e.plugins),r=t.fields,s=new qt(t);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Rs(e.schema,e.plugins),i=new qt(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Te.fromJSON(e.schema,t.doc);else if(o.name=="selection")i.selection=E.fromJSON(i.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[o.name]=c.fromJSON.call(a,e,t[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function yl(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=yl(s,e,{})),t[r]=s}return t}class H{constructor(e){this.spec=e,this.props={},e.props&&yl(e.props,this,this.props),this.key=e.key?e.key.key:bl("plugin")}getState(e){return e[this.key]}}const Ds=Object.create(null);function bl(n){return n in Ds?n+"$"+ ++Ds[n]:(Ds[n]=0,n+"$")}class q{constructor(e="key"){this.key=bl(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ee=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},sn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Is=null;const Be=function(n,e,t){let r=Is||(Is=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Fu=function(){Is=null},pt=function(n,e,t,r){return t&&(kl(n,e,t,r,-1)||kl(n,e,t,r,1))},$u=/^(img|br|input|textarea|hr)$/i;function kl(n,e,t,r,s){for(;;){if(n==t&&e==r)return!0;if(e==(s<0?0:ge(n))){let i=n.parentNode;if(!i||i.nodeType!=1||on(n)||$u.test(n.nodeName)||n.contentEditable=="false")return!1;e=ee(n)+(s<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.contentEditable=="false")return!1;e=s<0?ge(n):0}else return!1}}function ge(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Vu(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=ge(n)}else if(n.parentNode&&!on(n))e=ee(n),n=n.parentNode;else return null}}function Wu(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!on(n))e=ee(n)+1,n=n.parentNode;else return null}}function ju(n,e,t){for(let r=e==0,s=e==ge(n);r||s;){if(n==t)return!0;let i=ee(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,s=s&&i==ge(n)}}function on(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Qn=function(n){return n.focusNode&&pt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function mt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Ku(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Uu(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(ge(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(ge(r.startContainer),r.startOffset)}}}const Ae=typeof navigator<"u"?navigator:null,Sl=typeof document<"u"?document:null,qe=Ae&&Ae.userAgent||"",Ls=/Edge\/(\d+)/.exec(qe),wl=/MSIE \d/.exec(qe),Ps=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(qe),de=!!(wl||Ps||Ls),_e=wl?document.documentMode:Ps?+Ps[1]:Ls?+Ls[1]:0,we=!de&&/gecko\/(\d+)/i.test(qe);we&&+(/Firefox\/(\d+)/.exec(qe)||[0,0])[1];const Bs=!de&&/Chrome\/(\d+)/.exec(qe),re=!!Bs,Cl=Bs?+Bs[1]:0,oe=!de&&!!Ae&&/Apple Computer/.test(Ae.vendor),It=oe&&(/Mobile\/\w+/.test(qe)||!!Ae&&Ae.maxTouchPoints>2),ye=It||(Ae?/Mac/.test(Ae.platform):!1),Ju=Ae?/Win/.test(Ae.platform):!1,ze=/Android \d/.test(qe),ln=!!Sl&&"webkitFontSmoothing"in Sl.documentElement.style,qu=ln?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function _u(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function He(n,e){return typeof n=="number"?n:n[e]}function Gu(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function xl(n,e,t){let r=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let o=t||n.dom;o;o=sn(o)){if(o.nodeType!=1)continue;let l=o,a=l==i.body,c=a?_u(i):Gu(l),d=0,u=0;if(e.top<c.top+He(r,"top")?u=-(c.top-e.top+He(s,"top")):e.bottom>c.bottom-He(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+He(s,"top")-c.top:e.bottom-c.bottom+He(s,"bottom")),e.left<c.left+He(r,"left")?d=-(c.left-e.left+He(s,"left")):e.right>c.right-He(r,"right")&&(d=e.right-c.right+He(s,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let f=l.scrollLeft,h=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let p=l.scrollLeft-f,m=l.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function Yu(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(i,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:Ml(n.dom)}}function Ml(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=sn(r));return e}function Xu({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Tl(t,r==0?0:r-e)}function Tl(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:s,left:i}=n[t];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let Lt=null;function Qu(n){if(n.setActive)return n.setActive();if(Lt)return n.focus(Lt);let e=Ml(n);n.focus(Lt==null?{get preventScroll(){return Lt={preventScroll:!0},!0}}:void 0),Lt||(Lt=!1,Tl(e,0))}function Al(n,e){let t,r=2e8,s,i=0,o=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=Be(d).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){t=d,r=m,s=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&m&&(i=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!t&&a&&(t=a,s=c,r=0),t&&t.nodeType==3?Zu(t,s):!t||r&&t.nodeType==1?{node:n,offset:i}:Al(t,s)}function Zu(n,e){let t=n.nodeValue.length,r=document.createRange();for(let s=0;s<t;s++){r.setEnd(n,s+1),r.setStart(n,s);let i=Ge(r,1);if(i.top!=i.bottom&&zs(e,i))return{node:n,offset:s+(e.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function zs(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function ef(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function tf(n,e,t){let{node:r,offset:s}=Al(e,t),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,s,i)}function nf(n,e,t,r){let s=-1;for(let i=e,o=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!o&&a.left>r.left||a.top>r.top?s=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function El(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=s;;){let o=n.childNodes[i];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(zs(e,c))return El(o,e,c)}}if((i=(i+1)%r)==s)break}return n}function rf(n,e){let t=n.dom.ownerDocument,r,s=0,i=Uu(t,e.left,e.top);i&&({node:r,offset:s}=i);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=n.dom.getBoundingClientRect();if(!zs(e,c)||(o=El(n.dom,e,c),!o))return null}if(oe)for(let c=o;r&&c;c=sn(c))c.draggable&&(r=void 0);if(o=ef(o,e),r){if(we&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let d=r.childNodes[s],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let c;ln&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==n.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=nf(n,r,s,e))}l==null&&(l=tf(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ol(n){return n.top<n.bottom||n.left<n.right}function Ge(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Ol(r))return r}return Array.prototype.find.call(t,Ol)||n.getBoundingClientRect()}const sf=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Nl(n,e,t){let{node:r,offset:s,atom:i}=n.docView.domFromPos(e,t<0?-1:1),o=ln||we;if(r.nodeType==3)if(o&&(sf.test(r.nodeValue)||(t<0?!s:s==r.nodeValue.length))){let a=Ge(Be(r,s,s),t);if(we&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=Ge(Be(r,s-1,s-1),-1);if(c.top==a.top){let d=Ge(Be(r,s,s+1),-1);if(d.top!=a.top)return an(d,d.left<c.left)}}return a}else{let a=s,c=s,d=t<0?1:-1;return t<0&&!s?(c++,d=-1):t>=0&&s==r.nodeValue.length?(a--,d=1):t<0?a--:c++,an(Ge(Be(r,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(t<0||s==ge(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return Hs(a.getBoundingClientRect(),!1)}if(i==null&&s<ge(r)){let a=r.childNodes[s];if(a.nodeType==1)return Hs(a.getBoundingClientRect(),!0)}return Hs(r.getBoundingClientRect(),t>=0)}if(i==null&&s&&(t<0||s==ge(r))){let a=r.childNodes[s-1],c=a.nodeType==3?Be(a,ge(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return an(Ge(c,1),!1)}if(i==null&&s<ge(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Be(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return an(Ge(c,-1),!0)}return an(Ge(r.nodeType==3?Be(r):r,-t),t>=0)}function an(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Hs(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function vl(n,e,t){let r=n.state,s=n.root.activeElement;r!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),s!=n.dom&&s&&s.focus()}}function of(n,e,t){let r=e.selection,s=t=="up"?r.$from:r.$to;return vl(n,e,()=>{let{node:i}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=Nl(n,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Be(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const lf=/[\u0590-\u08ac]/;function af(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=n.domSelection();return l?!lf.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:o:vl(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let Rl=null,Dl=null,Il=!1;function cf(n,e,t){return Rl==e&&Dl==t?Il:(Rl=e,Dl=t,Il=t=="up"||t=="down"?of(n,e,t):af(n,e,t))}const be=0,Ll=1,gt=2,Ee=3;class cn{constructor(e,t,r,s){this.parent=e,this.children=t,this.dom=r,this.contentDOM=s,this.dirty=be,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let s=this.children[t];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>ee(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!t||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let s=this.children[t],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e||o instanceof zl){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,t);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Pl&&i.side>=0;r--);if(t<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&t&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?ee(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?ee(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(s==-1&&e<=c){let d=o+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=o;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=ee(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=ee(u.dom);break}t+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,s=!1){let i=Math.min(e,t),o=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(i>p&&o<g)return m.setSelection(e-p-m.border,t-p-m.border,r,s);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((we||oe)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==`
6
- `),u&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:ee(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=h.childNodes[p-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(we&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||u&&oe)&&pt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&pt(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let l=r+i.border,a=o-i.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?gt:Ll,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ee:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?gt:Ee}r=o}this.dirty=gt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?gt:Ll;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Pl extends cn{constructor(e,t,r,s){let i,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==be&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class df extends cn{constructor(e,t,r,s){super(e,[],t,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Et extends cn{constructor(e,t,r,s,i){super(e,[],r,s),this.mark=t,this.spec=i}static create(e,t,r,s){let i=s.nodeViews[t.type.name],o=i&&i(t,s,r);return(!o||!o.dom)&&(o=At.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Et(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ee||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ee&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=be){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=be}}slice(e,t,r){let s=Et.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;t<o&&(i=$s(i,t,o,r)),e>0&&(i=$s(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class it extends cn{constructor(e,t,r,s,i,o,l,a,c){super(e,[],i,o),this.node=t,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,t,r,s,i,o){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,s),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=At.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=$l(d,r,t),c?a=new uf(e,t,r,s,d,u||null,f,c,i,o+1):t.isText?new ps(e,t,r,s,d,f,i):new it(e,t,r,s,d,u||null,f,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>b.empty)}return e}matchesNode(e,t,r){return this.dirty==be&&e.eq(this.node)&&Zn(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,s=t,i=e.composing?this.localCompositionInfo(e,t):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new hf(this,o&&o.node,e);gf(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?B.none:this.node.child(d).marks,r,e),a.placeWidget(c,e,s)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==gt)&&(o&&this.protectLocalComposition(e,o),Hl(this.contentDOM,this.children,e),It&&yf(this.dom))}localCompositionInfo(e,t){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof T)||r<t||s>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=bf(this.node.content,o,r-t,s-t);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:s}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new df(this,i,t,s);e.input.compositionNodes.push(o),this.children=$s(this.children,r,r+s.length,e,o)}update(e,t,r,s){return this.dirty==Ee||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,s),!0)}updateInner(e,t,r,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=be}updateOuterDeco(e){if(Zn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Fl(this.dom,this.nodeDOM,Fs(this.outerDeco,this.node,t),Fs(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Bl(n,e,t,r,s){$l(r,e,n);let i=new it(void 0,n,e,t,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class ps extends it{constructor(e,t,r,s,i,o,l){super(e,t,r,s,i,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,s){return this.dirty==Ee||this.dirty!=be&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=be||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=be,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let s=this.node.cut(e,t),i=document.createTextNode(s.text);return new ps(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ee)}get domAtom(){return!1}isText(e){return this.node.text==e}}class zl extends cn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==be&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class uf extends it{constructor(e,t,r,s,i,o,l,a,c,d){super(e,t,r,s,i,o,l,c,d),this.spec=a}update(e,t,r,s){if(this.dirty==Ee)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,r);return i&&this.updateInner(e,t,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,s){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Hl(n,e,t){let r=n.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==n){for(;l!=r;)r=Vl(r),s=!0;r=r.nextSibling}else s=!0,n.insertBefore(l,r);if(o instanceof Et){let a=r?r.previousSibling:n.lastChild;Hl(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Vl(r),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const dn=function(n){n&&(this.nodeName=n)};dn.prototype=Object.create(null);const yt=[new dn];function Fs(n,e,t){if(n.length==0)return yt;let r=t?yt[0]:new dn,s=[r];for(let i=0;i<n.length;i++){let o=n[i].type.attrs;if(o){o.nodeName&&s.push(r=new dn(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&s.length==1&&s.push(r=new dn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function Fl(n,e,t,r){if(t==yt&&r==yt)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=t[i];if(i){let a;l&&l.nodeName==o.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=yt[0]),s=a}ff(s,l||yt[0],o)}return s}function ff(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&n.classList.add(s[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function $l(n,e,t){return Fl(n,n,yt,Fs(e,t,n.nodeType!=1))}function Zn(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Vl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class hf{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=pf(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let s=0,i=this.stack.length>>1,o=Math.min(i,e.length);for(;s<o&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=be,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Et.create(this.top,e[i],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,s,i){let o=this.top.children[s];return o.dirty==Ee&&o.dom==o.contentDOM&&(o.dirty=gt),o.update(e,t,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=t}}updateNextNode(e,t,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof it){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,u,f=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ee&&Zn(t,a.outerDeco));if(!f&&a.update(e,t,r,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,t,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=gt,u.updateChildren(s,o+1),u.dirty=be),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,s,i,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Zn(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=it.create(this.top,t,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,s,i){let o=it.create(this.top,e,t,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new Pl(this.top,e,t,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Et;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ps)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((oe||re)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new zl(this.top,[],r,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function pf(n,e){let t=e,r=t.children.length,s=n.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Et)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function mf(n,e){return n.type.side-e.type.side}function gf(n,e,t,r){let s=e.locals(n),i=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,s,e.forChild(i,d),c),i+=d.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let d,u;for(;o<s.length&&s[o].to==i;){let g=s[o++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(mf);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<n.childCount)h=c,f=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let p=i+f.nodeSize;if(f.isText){let g=p;o<s.length&&s[o].from<g&&(g=s[o].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=f.cut(g-i),f=f.cut(0,g-i),p=g,h=-1)}else for(;o<s.length&&s[o].to<p;)o++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,m,e.forChild(i,f),h),i=p}}function yf(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function bf(n,e,t,r){for(let s=0,i=0;s<n.childCount&&i<=r;){let o=n.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let a=o.text;for(;s<n.childCount;){let c=n.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function $s(n,e,t,r,s){let i=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],c=l,d=l+=a.size;c>=t||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),s&&(i.push(s),s=void 0),d>t&&i.push(a.slice(t-c,a.size,r)))}return i}function Vs(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(Qn(t)){for(a=o;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&x.isSelectable(u)&&s.parent&&!(u.isInline&&ju(t.focusNode,t.focusOffset,s.dom))){let f=s.posBefore;c=new x(o==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=o,f=o;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);u=Math.min(u,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,o]=f==n.state.selection.anchor?[f,u]:[u,f],l=r.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=js(n,d,l,u)}return c}function Wl(n){return n.editable?n.hasFocus():Gl(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Fe(n,e=!1){let t=n.state.selection;if(Jl(n,t),!!Wl(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&re){let r=n.domSelectionRange(),s=n.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&pt(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Sf(n);else{let{anchor:r,head:s}=t,i,o;jl&&!(t instanceof T)&&(t.$from.parent.inlineContent||(i=Kl(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Kl(n,t.to))),n.docView.setSelection(r,s,n,e),jl&&(i&&Ul(i),o&&Ul(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&kf(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const jl=oe||re&&Cl<63;function Kl(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),s=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(oe&&s&&s.contentEditable=="false")return Ws(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Ws(s);if(i)return Ws(i)}}function Ws(n){return n.contentEditable="true",oe&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ul(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function kf(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Wl(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Sf(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,s=r.nodeName=="IMG";s?t.setStart(r.parentNode,ee(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&de&&_e<=11&&(r.disabled=!0,r.disabled=!1)}function Jl(n,e){if(e instanceof x){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ql(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ql(n)}function ql(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function js(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||T.between(e,t,r)}function _l(n){return n.editable&&!n.hasFocus()?!1:Gl(n)}function Gl(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function wf(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return pt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ks(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&&E.findFrom(i,e)}function Ye(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Yl(n,e,t){let r=n.state.selection;if(r instanceof T)if(t.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return Ye(n,new T(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=Ks(n.state,e);return s&&s instanceof x?Ye(n,s):!1}else if(!(ye&&t.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?x.isSelectable(i)?Ye(n,new x(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):ln?Ye(n,new T(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof x&&r.node.isInline)return Ye(n,new T(e>0?r.$to:r.$from));{let s=Ks(n.state,e);return s?Ye(n,s):!1}}}function er(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function un(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Pt(n,e){return e<0?Cf(n):xf(n)}function Cf(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,i,o=!1;for(we&&t.nodeType==1&&r<er(t)&&un(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(un(l,-1))s=t,i=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Xl(t))break;{let l=t.previousSibling;for(;l&&un(l,-1);)s=t.parentNode,i=ee(l),l=l.previousSibling;if(l)t=l,r=er(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Us(n,t,r):s&&Us(n,s,i)}function xf(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=er(t),i,o;for(;;)if(r<s){if(t.nodeType!=1)break;let l=t.childNodes[r];if(un(l,1))i=t,o=++r;else break}else{if(Xl(t))break;{let l=t.nextSibling;for(;l&&un(l,1);)i=l.parentNode,o=ee(l)+1,l=l.nextSibling;if(l)t=l,r=0,s=er(t);else{if(t=t.parentNode,t==n.dom)break;r=s=0}}}i&&Us(n,i,o)}function Xl(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Mf(n,e){for(;n&&e==n.childNodes.length&&!on(n);)e=ee(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Tf(n,e){for(;n&&!e&&!on(n);)e=ee(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Us(n,e,t){if(e.nodeType!=3){let i,o;(o=Mf(e,t))?(e=o,t=0):(i=Tf(e,t))&&(e=i,t=i.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Qn(r)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&Fe(n)},50)}function Ql(n,e){let t=n.state.doc.resolve(e);if(!(re||Ju)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Zl(n,e,t){let r=n.state.selection;if(r instanceof T&&!r.empty||t.indexOf("s")>-1||ye&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Ks(n.state,e);if(o&&o instanceof x)return Ye(n,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof fe?E.near(o,e):E.findFrom(o,e);return l?Ye(n,l):!1}return!1}function ea(n,e){if(!(n.state.selection instanceof T))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let o=n.state.tr;return e<0?o.delete(t.pos-i.nodeSize,t.pos):o.delete(t.pos,t.pos+i.nodeSize),n.dispatch(o),!0}return!1}function ta(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Af(n){if(!oe||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;ta(n,r,"true"),setTimeout(()=>ta(n,r,"false"),20)}return!1}function Ef(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Of(n,e){let t=e.keyCode,r=Ef(e);if(t==8||ye&&t==72&&r=="c")return ea(n,-1)||Pt(n,-1);if(t==46&&!e.shiftKey||ye&&t==68&&r=="c")return ea(n,1)||Pt(n,1);if(t==13||t==27)return!0;if(t==37||ye&&t==66&&r=="c"){let s=t==37?Ql(n,n.state.selection.from)=="ltr"?-1:1:-1;return Yl(n,s,r)||Pt(n,s)}else if(t==39||ye&&t==70&&r=="c"){let s=t==39?Ql(n,n.state.selection.from)=="ltr"?1:-1:1;return Yl(n,s,r)||Pt(n,s)}else{if(t==38||ye&&t==80&&r=="c")return Zl(n,-1,r)||Pt(n,-1);if(t==40||ye&&t==78&&r=="c")return Af(n)||Zl(n,1,r)||Pt(n,1);if(r==(ye?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Js(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||At.fromSchema(n.state.schema),l=ca(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=la[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=l.createElement(d[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
1
+ function Z(n){this.content=n}Z.prototype={constructor:Z,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),i=r.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new Z(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Z(t)},addToStart:function(n,e){return new Z([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Z(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),i=r.find(n);return s.splice(i==-1?s.length:i,0,e,t),new Z(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Z.from(n),n.size?new Z(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Z.from(n),n.size?new Z(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Z.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Z.from=function(n){if(n instanceof Z)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Z(e)};function wo(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)t++;return t}if(s.content.size||i.content.size){let o=wo(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function Co(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,d=Math.min(o.text.length,l.text.length);for(;c<d&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=Co(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class b{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,i){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let i="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new b(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let i=0,o=0;o<t;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),s+=l.nodeSize),o=a}return new b(r,s)}cutByIndex(e,t){return e==t?b.empty:e==0&&t==this.content.length?this:new b(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new b(s,i)}addToStart(e){return new b([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new b(this.content.concat(e),this.size+e.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 new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return wo(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Co(this,e,t,r)}findIndex(e,t=-1){if(e==0)return Vn(0,e);if(e==this.size)return Vn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,s=0;;r++){let i=this.child(r),o=s+i.nodeSize;if(o>=e)return o==e||t>0?Vn(r+1,o):Vn(r,s);s=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return b.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new b(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return b.empty;let t,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new b(t||e,r)}static from(e){if(!e)return b.empty;if(e instanceof b)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new b([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}b.empty=new b([],0);const bs={index:0,offset:0};function Vn(n,e){return bs.index=n,bs.offset=e,bs}function Wn(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Wn(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Wn(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let B=class mo{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||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&&Wn(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 new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return mo.none;if(e instanceof mo)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};B.none=[];class jn extends Error{}class w{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Mo(this.content,e+this.openStart,t);return r&&new w(r,this.openStart,this.openEnd)}removeBetween(e,t){return new w(xo(this.content,e+this.openStart,t+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(e,t){if(!t)return w.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new w(b.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new w(e,r,s)}}w.empty=new w(b.empty,0,0);function xo(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(s==e||i.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(xo(i.content,e-s-1,t-s-1)))}function Mo(n,e,t,r){let{index:s,offset:i}=n.findIndex(e),o=n.maybeChild(s);if(i==e||o.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Mo(o.content,e-i-1,t);return l&&n.replaceChild(s,o.copy(l))}function qd(n,e,t){if(t.openStart>n.depth)throw new jn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new jn("Inconsistent open depths");return To(n,e,t,0)}function To(n,e,t,r){let s=n.index(r),i=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let o=To(n,e,t,r+1);return i.copy(i.content.replaceChild(s,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return ht(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=_d(t,n);return ht(i,Eo(n,o,l,e,r))}else return ht(i,Kn(n,e,r))}function Ao(n,e){if(!e.type.compatibleContent(n.type))throw new jn("Cannot join "+e.type.name+" onto "+n.type.name)}function ks(n,e,t){let r=n.node(t);return Ao(r,e.node(t)),r}function ft(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Zt(n,e,t,r){let s=(e||n).node(t),i=0,o=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(ft(n.nodeAfter,r),i++));for(let l=i;l<o;l++)ft(s.child(l),r);e&&e.depth==t&&e.textOffset&&ft(e.nodeBefore,r)}function ht(n,e){return n.type.checkContent(e),n.copy(e)}function Eo(n,e,t,r,s){let i=n.depth>s&&ks(n,e,s+1),o=r.depth>s&&ks(t,r,s+1),l=[];return Zt(null,n,s,l),i&&o&&e.index(s)==t.index(s)?(Ao(i,o),ft(ht(i,Eo(n,e,t,r,s+1)),l)):(i&&ft(ht(i,Kn(n,e,s+1)),l),Zt(e,t,s,l),o&&ft(ht(o,Kn(t,r,s+1)),l)),Zt(r,null,s,l),new b(l)}function Kn(n,e,t){let r=[];if(Zt(null,n,t,r),n.depth>t){let s=ks(n,e,t+1);ft(ht(s,Kn(n,e,t+1)),r)}return Zt(e,null,t,r),new b(r)}function _d(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(b.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class Hn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,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 new 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 new 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 r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}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 r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return B.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}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 r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Un(this,e,r);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(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,i=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new Hn(t,r,i)}static resolveCached(e,t){let r=Oo.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==t)return o}else Oo.set(e,r=new Gd);let s=r.elts[r.i]=Hn.resolve(e,t);return r.i=(r.i+1)%Yd,s}}class Gd{constructor(){this.elts=[],this.i=0}}const Yd=12,Oo=new WeakMap;class Un{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Xd=Object.create(null);let Te=class go{constructor(e,t,r,s=B.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||b.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,r,s=0){this.content.nodesBetween(e,t,r,s,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,r,s){return this.content.textBetween(e,t,r,s)}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,r){return this.type==e&&Wn(this.attrs,t||e.defaultAttrs||Xd)&&B.sameSet(this.marks,r||B.none)}copy(e=null){return e==this.content?this:new go(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new go(this.type,this.attrs,this.content,e)}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,r=!1){if(e==t)return w.empty;let s=this.resolve(e),i=this.resolve(t),o=r?0:s.sharedDepth(t),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new w(c,s.depth-o,i.depth-o)}replace(e,t,r){return qd(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return Hn.resolveCached(this,e)}resolveNoCache(e){return Hn.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}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()+")"),No(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=b.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,t);return o?o.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),this.type.checkAttrs(this.attrs);let e=B.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!B.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let 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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=b.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,r);return i.type.checkAttrs(i.attrs),i}};Te.prototype.text=void 0;class fs extends Te{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):No(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new fs(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new fs(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(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 No(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Tt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Qd(e,t);if(r.next==null)return Tt.empty;let s=vo(r);r.next&&r.err("Unexpected trailing text");let i=iu(su(s));return ou(i,r),i}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,r=e.childCount){let s=this;for(let i=t;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}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 r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function i(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return b.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:d,next:u}=o.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let f=i(u,l.concat(d));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
2
+ `)}}Tt.empty=new Tt(!0);class Qd{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 new SyntaxError(e+" (in content expression '"+this.string+"')")}}function vo(n){let e=[];do e.push(Zd(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Zd(n){let e=[];do e.push(eu(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function eu(n){let e=ru(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=tu(n,e);else break;return e}function Ro(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function tu(n,e){let t=Ro(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ro(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function nu(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let i in t){let o=t[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function ru(n){if(n.eat("(")){let e=vo(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=nu(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function su(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let d=t();s(i(o.expr,a),d),a=d}if(o.max==-1)s(i(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let d=t();r(a,d),s(i(o.expr,a),d),a=d}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Do(n,e){return e-n}function Io(n,e){let t=[];return r(e),t.sort(Do);function r(s){let i=n[s];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(s);for(let o=0;o<i.length;o++){let{term:l,to:a}=i[o];!l&&t.indexOf(a)==-1&&r(a)}}}function iu(n){let e=Object.create(null);return t(Io(n,0));function t(r){let s=[];r.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);Io(n,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new Tt(r.indexOf(n.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(Do);i.next.push({type:s[o][0],next:e[l.join(",")]||t(l)})}return i}}function ou(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];o.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Lo(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Po(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let i=n[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function Bo(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let i=n[s];i.validate&&i.validate(e[s])}}function zo(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new au(n,r,e[r]);return t}let Ho=class Ud{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=zo(e,r.attrs),this.defaultAttrs=Lo(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Tt.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:Po(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Te(this,this.computeAttrs(e),b.from(t),B.setFrom(r))}createChecked(e=null,t,r){return t=b.from(t),this.checkContent(t),new Te(this,this.computeAttrs(e),t,B.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=b.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let s=this.contentMatch.matchFragment(t),i=s&&s.fillBefore(b.empty,!0);return i?new Te(this,e,t.append(i),B.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Bo(this.attrs,e,"node",this.name)}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 r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:B.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,o)=>r[i]=new Ud(i,t,o));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function lu(n,e,t){let r=t.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}class au{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?lu(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class hs{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=zo(e,s.attrs),this.excluded=null;let i=Lo(this.attrs);this.instance=i?new B(this,i):null}create(e=null){return!e&&this.instance?this.instance:new B(this,Po(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new hs(i,s++,t,o)),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]}checkAttrs(e){Bo(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Fo{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=Z.from(e.nodes),t.marks=Z.from(e.marks||{}),this.nodes=Ho.compile(this.spec.nodes,this),this.marks=hs.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=Tt.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?$o(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:$o(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Ho){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,s)}text(e,t){let r=this.nodes.text;return new fs(r,r.defaultAttrs,e,B.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Te.fromJSON(this,e)}markFromJSON(e){return B.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function $o(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],i=n.marks[s],o=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function cu(n){return n.tag!=null}function du(n){return n.style!=null}class Ue{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(cu(s))this.tags.push(s);else if(du(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new Ko(this,t,!1);return r.addAll(e,B.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Ko(this,t,!0);return r.addAll(e,B.none,t.from,t.to),w.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(hu(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,t,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<i)break}t.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Uo(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Uo(o)),o.node||o.ignore||o.mark||(o.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ue(e,Ue.schemaRules(e)))}}const Vo={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},uu={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Wo={ol:!0,ul:!0},en=1,Ss=2,Jn=4;function jo(n,e,t){return e!=null?(e?en:0)|(e==="full"?Ss:0):n&&n.whitespace=="pre"?en|Ss:t&-5}class qn{constructor(e,t,r,s,i,o){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=B.none,this.match=i||(o&Jn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(b.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&en)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=b.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(b.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&&!Vo.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ko{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,i,o=jo(null,t.preserveWhitespace,0)|(r?Jn:0);s?i=new qn(s.type,s.attrs,B.none,!0,t.topMatch||s.type.contentMatch,o):r?i=new qn(null,null,B.none,!0,null,o):i=new qn(e.schema.topNodeType,null,B.none,!0,null,o),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 r=e.nodeValue,s=this.top,i=s.options&Ss?"full":this.localPreserveWS||(s.options&en)>0;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)i!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
3
+ `);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=s.content[s.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Wo.hasOwnProperty(o)&&this.parser.normalizeLists&&fu(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:uu.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(Vo.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,s){let i,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r)||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t){let r,s;for(let i=this.open;i>=0;i--){let o=this.nodes[i],l=o.findWrapping(e);if(l&&(!r||r.length>l.length)&&(r=l,s=o,!l.length)||o.solid)break}if(!r)return null;this.sync(s);for(let i=0;i<r.length;i++)t=this.enterInner(r[i],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let r=this.findPlace(e,t);if(r){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=B.none;for(let o of r.concat(e.marks))(s.type?s.type.allowsMarkType(o.type):Jo(o.type,e.type))&&(i=o.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,r,s){let i=this.findPlace(e.create(t),r);return i&&(i=this.enterInner(e,t,r,!0,s)),i}enterInner(e,t,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=jo(e,i,o.options);o.options&Jn&&o.content.length==0&&(l|=Jn);let a=B.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Jo(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new qn(e,t,a,s,null,l)),this.open++,r}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;this.localPreserveWS&&(this.nodes[t].options|=en)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].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,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].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("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function fu(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Wo.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function hu(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Uo(n){let e={};for(let t in n)e[t]=n[t];return e}function Jo(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&o(d))return!0}};if(o(s.contentMatch))return!0}}class At{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=ws(t).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],d=this.serializeMark(c,o.isInline,t);d&&(i.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=_n(ws(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&_n(ws(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return _n(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new At(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=qo(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return qo(e.marks)}}function qo(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function ws(n){return n.document||window.document}const _o=new WeakMap;function pu(n){let e=_o.get(n);return e===void 0&&_o.set(n,e=mu(n)),e}function mu(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function _n(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=pu(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(t=s.slice(0,o),s=s.slice(o+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=_n(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Go=65535,Yo=Math.pow(2,16);function gu(n,e){return n+e*Yo}function Xo(n){return n&Go}function yu(n){return(n-(n&Go))/Yo}const Qo=1,Zo=2,Gn=4,el=8;class Cs{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&el)>0}get deletedBefore(){return(this.delInfo&(Qo|Gn))>0}get deletedAfter(){return(this.delInfo&(Zo|Gn))>0}get deletedAcross(){return(this.delInfo&Gn)>0}}class pe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&pe.empty)return pe.empty}recover(e){let t=0,r=Xo(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+yu(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+o],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+s+(f<0?0:d);if(r)return h;let p=e==(t<0?a:u)?null:gu(l/3,e-a),m=e==a?Zo:e==u?Qo:Gn;return(t<0?e!=a:e!=u)&&(m|=el),new Cs(h,m,p)}s+=d-c}return r?e+s:new Cs(e+s,0,null)}touches(e,t){let r=0,s=Xo(t),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+t],d=this.ranges[s+r];e(l,l+c,a,a+d),i+=d-c}}invert(){return new pe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?pe.empty:new pe(e<0?[0,-e,0]:[0,0,e])}}pe.empty=new pe([]);class _t{constructor(e=[],t,r=0,s=e.length){this.maps=e,this.mirror=t,this.from=r,this.to=s}slice(e=0,t=this.maps.length){return new _t(this.maps,this.mirror,e,t)}copy(){return new _t(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,r=this.maps.length;t<e.maps.length;t++){let s=e.getMirror(t);this.appendMap(e.maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this.maps.length+e.maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e.maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new _t;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this.maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this.maps[i],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this.maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Cs(e,s,null)}}const xs=Object.create(null);class ne{getMap(){return pe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=xs[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in xs)throw new RangeError("Duplicate use of step JSON ID "+e);return xs[e]=t,t.prototype.jsonID=e,t}}class J{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new J(e,null)}static fail(e){return new J(null,e)}static fromReplace(e,t,r,s){try{return J.ok(e.replace(t,r,s))}catch(i){if(i instanceof jn)return J.fail(i.message);throw i}}}function Ms(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(Ms(i.content,e,i))),i.isInline&&(i=e(i,t,s)),r.push(i)}return b.fromArray(r)}class ct extends ne{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new w(Ms(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),t.openStart,t.openEnd);return J.fromReplace(e,this.from,this.to,i)}invert(){return new Le(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new ct(t.pos,r.pos,this.mark)}merge(e){return e instanceof ct&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ct(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ct(t.from,t.to,e.markFromJSON(t.mark))}}ne.jsonID("addMark",ct);class Le extends ne{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new w(Ms(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return J.fromReplace(e,this.from,this.to,r)}invert(){return new ct(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Le(t.pos,r.pos,this.mark)}merge(e){return e instanceof Le&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Le(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Le(t.from,t.to,e.markFromJSON(t.mark))}}ne.jsonID("removeMark",Le);class dt extends ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return J.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return J.fromReplace(e,this.pos,this.pos+1,new w(b.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new dt(this.pos,t.marks[s]);return new dt(this.pos,this.mark)}}return new Gt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new dt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new dt(t.pos,e.markFromJSON(t.mark))}}ne.jsonID("addNodeMark",dt);class Gt extends ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return J.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return J.fromReplace(e,this.pos,this.pos+1,new w(b.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new dt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Gt(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Gt(t.pos,e.markFromJSON(t.mark))}}ne.jsonID("removeNodeMark",Gt);class Q extends ne{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&Ts(e,this.from,this.to)?J.fail("Structure replace would overwrite content"):J.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new pe([this.from,this.to-this.from,this.slice.size])}invert(e){return new Q(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new Q(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof Q)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?w.empty:new w(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Q(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?w.empty:new w(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Q(e.from,this.to,t,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(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Q(t.from,t.to,w.fromJSON(e,t.slice),!!t.structure)}}ne.jsonID("replace",Q);class Y extends ne{constructor(e,t,r,s,i,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Ts(e,this.from,this.gapFrom)||Ts(e,this.gapTo,this.to)))return J.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return J.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?J.fromReplace(e,this.from,this.to,r):J.fail("Content does not fit in gap")}getMap(){return new pe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Y(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||i>r.pos?null:new Y(t.pos,r.pos,s,i,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(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Y(t.from,t.to,t.gapFrom,t.gapTo,w.fromJSON(e,t.slice),t.insert,!!t.structure)}}ne.jsonID("replaceAround",Y);function Ts(n,e,t){let r=n.resolve(e),s=t-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function bu(n,e,t,r){let s=[],i=[],o,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(p)||(o&&o.to==f&&o.mark.eq(u[m])?o.to=h:s.push(o=new Le(f,h,u[m])));l&&l.to==f?l.to=h:i.push(l=new ct(f,h,r))}}),s.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function ku(n,e,t,r){let s=[],i=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;i++;let a=null;if(r instanceof hs){let c=o.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],f;for(let h=0;h<s.length;h++){let p=s[h];p.step==i-1&&u.eq(s[h].style)&&(f=p)}f?(f.to=c,f.step=i):s.push({style:u,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(o=>n.step(new Le(o.from,o.to,o.style)))}function As(n,e,t,r=t.contentMatch,s=!0){let i=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Q(l,d,w.empty));else{r=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new Le(l,d,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new w(b.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new Q(l+f.index,l+f.index+f[0].length,p))}}l=d}if(!r.validEnd){let a=r.fillBefore(b.empty,!0);n.replace(l,l,new w(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function Su(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function vt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let s=n.$from.node(r),i=n.$from.index(r),o=n.$to.indexAfter(r);if(r<n.depth&&s.canReplace(i,o,t))return r;if(r==0||s.type.spec.isolating||!Su(s,i,o))break}return null}function wu(n,e,t){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),a=o,c=l,d=b.empty,u=0;for(let p=i,m=!1;p>t;p--)m||r.index(p)>0?(m=!0,d=b.from(r.node(p).copy(d)),u++):a--;let f=b.empty,h=0;for(let p=i,m=!1;p>t;p--)m||s.after(p+1)<s.end(p)?(m=!0,f=b.from(s.node(p).copy(f)),h++):c++;n.step(new Y(a,c,o,l,new w(d.append(f),u,h),d.size-u,!0))}function Es(n,e,t=null,r=n){let s=Cu(n,e),i=s&&xu(r,e);return i?s.map(tl).concat({type:e,attrs:t}).concat(i.map(tl)):null}function tl(n){return{type:n,attrs:null}}function Cu(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return t.canReplaceWith(r,s,o)?i:null}function xu(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function Mu(n,e,t){let r=b.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=b.from(t[o].type.create(t[o].attrs,r))}let s=e.start,i=e.end;n.step(new Y(s,i,s,i,new w(r,0,0),t.length,!0))}function Tu(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,a)&&Au(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&rl(n,o,l,i),As(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let d=n.mapping.slice(i),u=d.map(l,1),f=d.map(l+o.nodeSize,1);return n.step(new Y(u,f,u+1,f-1,new w(b.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&nl(n,o,l,i),!1}})}function nl(n,e,t,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let a=n.mapping.slice(r).map(t+1+i+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function rl(n,e,t,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+i);n.replaceWith(o,o+1,e.type.schema.text(`
5
+ `))}})}function Au(n,e,t){let r=n.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,t)}function Eu(n,e,t,r,s){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let o=t.create(r,null,s||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,o);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Y(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new w(b.from(o),0,0),1,!0))}function Pe(n,e,t=1,r){let s=n.resolve(e),i=s.depth-t,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=t-2;c>i;c--,d--){let u=s.node(c),f=s.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!m.type.validContent(h))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function Ou(n,e,t=1,r){let s=n.doc.resolve(e),i=b.empty,o=b.empty;for(let l=s.depth,a=s.depth-t,c=t-1;l>a;l--,c--){i=b.from(s.node(l).copy(i));let d=r&&r[c];o=b.from(d?d.type.create(d.attrs,o):s.node(l).copy(o))}n.step(new Q(e,e,new w(i.append(o),t,t),!0))}function Je(n,e){let t=n.resolve(e),r=t.index();return sl(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Nu(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function sl(n,e){return!!(n&&e&&!n.isLeaf&&Nu(n,e))}function Yn(n,e,t=-1){let r=n.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):t>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&sl(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=t<0?r.before(s):r.after(s)}}function vu(n,e,t){let r=null,{linebreakReplacement:s}=n.doc.type.schema,i=n.doc.resolve(e-t),o=i.node().type;if(s&&o.inlineContent){let d=o.whitespace=="pre",u=!!o.contentMatch.matchType(s);d&&!u?r=!1:!d&&u&&(r=!0)}let l=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);rl(n,d.node(),d.before(),l)}o.inlineContent&&As(n,e+t-1,o,i.node().contentMatchAt(i.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new Q(c,a.map(e+t,-1),w.empty,!0)),r===!0){let d=n.doc.resolve(c);nl(n,d.node(),d.before(),n.steps.length)}return n}function Ru(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,t))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,t))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function il(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let s=t.content;for(let i=0;i<t.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),d=!1;if(i==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Xn(n,e,t=e,r=w.empty){if(e==t&&!r.size)return null;let s=n.resolve(e),i=n.resolve(t);return ol(s,i,r)?new Q(e,t,r):new Du(s,i,r).fit()}function ol(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Du{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=b.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=b.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new w(i,o,l);return e>-1?new Y(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Q(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=Os(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(o?c.matchType(o.type)||(u=c.fillBefore(b.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(t==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=Os(e,t);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new w(e,t+1,Math.max(r,s.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,s=Os(e,t);if(s.childCount<=1&&t>0){let i=e.size-t<=t+s.size;this.unplaced=new w(tn(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new w(tn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:s,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[t];if(s){for(let m=0;m<s.childCount;m++)d.push(s.child(m));u=u.matchFragment(s)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(ll(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=nn(this.placed,t,b.from(d)),this.frontier[t].match=u,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?w.empty:new w(tn(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new w(tn(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ns(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:s}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Ns(e,t,s,r,i);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Ns(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:o,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=nn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,t=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=nn(this.placed,this.depth,b.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(b.empty,!0);t.childCount&&(this.placed=nn(this.placed,this.frontier.length,t))}}function tn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(tn(n.firstChild.content,e-1,t)))}function nn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(nn(n.lastChild.content,e-1,t)))}function Os(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function ll(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,ll(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(b.empty,!0)))),n.copy(r)}function Ns(n,e,t,r,s){let i=n.node(e),o=s?n.indexAfter(e):n.index(e);if(o==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!Iu(t,i.content,o)?l:null}function Iu(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Lu(n){return n.spec.defining||n.spec.definingForContent}function Pu(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let s=n.doc.resolve(e),i=n.doc.resolve(t);if(ol(s,i,r))return n.step(new Q(e,t,r));let o=cl(s,n.doc.resolve(t));o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:s.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],d=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f],p=Lu(h.type);if(p&&!h.sameMarkup(s.node(Math.abs(l)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],y=!0;g<0&&(y=!1,g=-g);let S=s.node(g-1),A=s.index(g-1);if(S.canReplaceWith(A,A,p.type,p.marks))return n.replace(s.before(g),y?i.after(g):t,new w(al(r.content,0,r.openStart,h),h,r.openEnd))}}let u=n.steps.length;for(let f=o.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>u));f--){let h=o[f];h<0||(e=s.before(h),t=i.after(h))}}function al(n,e,t,r,s){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(al(i.content,e+1,t,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(n).append(n);n=o.append(i.matchFragment(o).fillBefore(b.empty,!0))}return n}function Bu(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let s=Ru(n.doc,e,r.type);s!=null&&(e=t=s)}n.replaceRange(e,t,new w(b.from(r),0,0))}function zu(n,e,t){let r=n.doc.resolve(e),s=n.doc.resolve(t),i=cl(r,s);for(let o=0;o<i.length;o++){let l=i[o],a=o==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return n.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&s.end(o)-t!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function cl(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let s=r;s>=0;s--){let i=n.start(s);if(i<n.pos-(n.depth-s)||e.end(s)>e.pos+(e.depth-s)||n.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==n.depth&&s==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&t.push(s)}return t}class Yt extends ne{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return J.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let s=t.type.create(r,null,t.marks);return J.fromReplace(e,this.pos,this.pos+1,new w(b.from(s),0,t.isLeaf?0:1))}getMap(){return pe.empty}invert(e){return new Yt(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Yt(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Yt(t.pos,t.attr,t.value)}}ne.jsonID("attr",Yt);class Fn extends ne{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let s in e.attrs)t[s]=e.attrs[s];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return J.ok(r)}getMap(){return pe.empty}invert(e){return new Fn(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Fn(t.attr,t.value)}}ne.jsonID("docAttr",Fn);let Rt=class extends Error{};Rt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},Rt.prototype=Object.create(Error.prototype),Rt.prototype.constructor=Rt,Rt.prototype.name="TransformError";class vs{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new _t}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Rt(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=w.empty){let s=Xn(this.doc,e,t,r);return s&&this.step(s),this}replaceWith(e,t,r){return this.replace(e,t,new w(b.from(r),0,0))}delete(e,t){return this.replace(e,t,w.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Pu(this,e,t,r),this}replaceRangeWith(e,t,r){return Bu(this,e,t,r),this}deleteRange(e,t){return zu(this,e,t),this}lift(e,t){return wu(this,e,t),this}join(e,t=1){return vu(this,e,t),this}wrap(e,t){return Mu(this,e,t),this}setBlockType(e,t=e,r,s=null){return Tu(this,e,t,r,s),this}setNodeMarkup(e,t,r=null,s){return Eu(this,e,t,r,s),this}setNodeAttribute(e,t,r){return this.step(new Yt(e,t,r)),this}setDocAttribute(e,t){return this.step(new Fn(e,t)),this}addNodeMark(e,t){return this.step(new dt(e,t)),this}removeNodeMark(e,t){if(!(t instanceof B)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new Gt(e,t)),this}split(e,t=1,r){return Ou(this,e,t,r),this}addMark(e,t,r){return bu(this,e,t,r),this}removeMark(e,t,r){return ku(this,e,t,r),this}clearIncompatible(e,t,r){return As(this,e,t,r),this}}const Rs=Object.create(null);class E{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new dl(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=w.empty){let r=t.content.lastChild,s=null;for(let l=0;l<t.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?w.empty:t),l==0&&hl(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),hl(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let s=e.parent.inlineContent?new T(e):Dt(e.node(0),e.parent,e.pos,e.index(),t,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=t<0?Dt(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):Dt(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new fe(e.node(0))}static atStart(e){return Dt(e,e,0,0,1)||new fe(e)}static atEnd(e){return Dt(e,e,e.content.size,e.childCount,-1)||new fe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Rs[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Rs)throw new RangeError("Duplicate use of selection JSON ID "+e);return Rs[e]=t,t.prototype.jsonID=e,t}getBookmark(){return T.between(this.$anchor,this.$head).getBookmark()}}E.prototype.visible=!0;class dl{constructor(e,t){this.$from=e,this.$to=t}}let ul=!1;function fl(n){!ul&&!n.parent.inlineContent&&(ul=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class T extends E{constructor(e,t=e){fl(e),fl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return E.near(r);let s=e.resolve(t.map(this.anchor));return new T(s.parent.inlineContent?s:r,r)}replace(e,t=w.empty){if(super.replace(e,t),t==w.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof T&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ps(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new T(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let s=e.resolve(t);return new this(s,r==t?s:e.resolve(r))}static between(e,t,r){let s=e.pos-t.pos;if((!r||s)&&(r=s>=0?1:-1),!t.parent.inlineContent){let i=E.findFrom(t,r,!0)||E.findFrom(t,-r,!0);if(i)t=i.$head;else return E.near(t,r)}return e.parent.inlineContent||(s==0?e=t:(e=(E.findFrom(e,-r,!0)||E.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=s<0&&(e=t))),new T(e,t)}}E.jsonID("text",T);class ps{constructor(e,t){this.anchor=e,this.head=t}map(e){return new ps(e.map(this.anchor),e.map(this.head))}resolve(e){return T.between(e.resolve(this.anchor),e.resolve(this.head))}}class x extends E{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:s}=t.mapResult(this.anchor),i=e.resolve(s);return r?E.near(i):new x(i)}content(){return new w(b.from(this.node),0,0)}eq(e){return e instanceof x&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new yo(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new x(e.resolve(t.anchor))}static create(e,t){return new x(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}x.prototype.visible=!1,E.jsonID("node",x);class yo{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new ps(r,r):new yo(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&x.isSelectable(r)?new x(t):E.near(t)}}class fe extends E{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=w.empty){if(t==w.empty){e.delete(0,e.doc.content.size);let r=E.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new fe(e)}map(e){return new fe(e)}eq(e){return e instanceof fe}getBookmark(){return Hu}}E.jsonID("all",fe);const Hu={map(){return this},resolve(n){return new fe(n)}};function Dt(n,e,t,r,s,i=!1){if(e.inlineContent)return T.create(n,t);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&x.isSelectable(l))return x.create(n,t-(s<0?l.nodeSize:0))}else{let a=Dt(n,l,t+s,s<0?l.childCount:0,s,i);if(a)return a}t+=l.nodeSize*s}return null}function hl(n,e,t){let r=n.steps.length-1;if(r<e)return;let s=n.steps[r];if(!(s instanceof Q||s instanceof Y))return;let i=n.mapping.maps[r],o;i.forEach((l,a,c,d)=>{o==null&&(o=d)}),n.setSelection(E.near(n.doc.resolve(o),t))}const pl=1,ml=2,gl=4;class Fu extends vs{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|pl)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&pl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ml,this}ensureMarks(e){return B.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&ml)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||B.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let s=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(t);i=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,s.text(e,i)),this.selection.empty||this.setSelection(E.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=gl,this}get scrolledIntoView(){return(this.updated&gl)>0}}function yl(n,e){return!e||!n?n:n.bind(e)}class rn{constructor(e,t,r){this.name=e,this.init=yl(t.init,r),this.apply=yl(t.apply,r)}}const $u=[new rn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new rn("selection",{init(n,e){return n.selection||E.atStart(e.doc)},apply(n){return n.selection}}),new rn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new rn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Ds{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=$u.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new rn(r.key,r.spec.state,r))})}}class qt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=s?s[o].n:0,c=s?s[o].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<o?{state:r,n:t.length}:{state:this,n:0})}t.push(d),r=r.applyInner(d),i=!0}s&&(s[o]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new qt(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new Fu(this)}static create(e){let t=new Ds(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new qt(t);for(let s=0;s<t.fields.length;s++)r[t.fields[s].name]=t.fields[s].init(e,r);return r}reconfigure(e){let t=new Ds(this.schema,e.plugins),r=t.fields,s=new qt(t);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(s,this[s.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Ds(e.schema,e.plugins),i=new qt(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Te.fromJSON(e.schema,t.doc);else if(o.name=="selection")i.selection=E.fromJSON(i.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[o.name]=c.fromJSON.call(a,e,t[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function bl(n,e,t){for(let r in n){let s=n[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=bl(s,e,{})),t[r]=s}return t}class H{constructor(e){this.spec=e,this.props={},e.props&&bl(e.props,this,this.props),this.key=e.key?e.key.key:kl("plugin")}getState(e){return e[this.key]}}const Is=Object.create(null);function kl(n){return n in Is?n+"$"+ ++Is[n]:(Is[n]=0,n+"$")}class q{constructor(e="key"){this.key=kl(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ee=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},sn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Ls=null;const Be=function(n,e,t){let r=Ls||(Ls=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Vu=function(){Ls=null},pt=function(n,e,t,r){return t&&(Sl(n,e,t,r,-1)||Sl(n,e,t,r,1))},Wu=/^(img|br|input|textarea|hr)$/i;function Sl(n,e,t,r,s){for(;;){if(n==t&&e==r)return!0;if(e==(s<0?0:ge(n))){let i=n.parentNode;if(!i||i.nodeType!=1||on(n)||Wu.test(n.nodeName)||n.contentEditable=="false")return!1;e=ee(n)+(s<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.contentEditable=="false")return!1;e=s<0?ge(n):0}else return!1}}function ge(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ju(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=ge(n)}else if(n.parentNode&&!on(n))e=ee(n),n=n.parentNode;else return null}}function Ku(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!on(n))e=ee(n)+1,n=n.parentNode;else return null}}function Uu(n,e,t){for(let r=e==0,s=e==ge(n);r||s;){if(n==t)return!0;let i=ee(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,s=s&&i==ge(n)}}function on(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Qn=function(n){return n.focusNode&&pt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function mt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Ju(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function qu(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(ge(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(ge(r.startContainer),r.startOffset)}}}const Ae=typeof navigator<"u"?navigator:null,wl=typeof document<"u"?document:null,qe=Ae&&Ae.userAgent||"",Ps=/Edge\/(\d+)/.exec(qe),Cl=/MSIE \d/.exec(qe),Bs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(qe),de=!!(Cl||Bs||Ps),_e=Cl?document.documentMode:Bs?+Bs[1]:Ps?+Ps[1]:0,we=!de&&/gecko\/(\d+)/i.test(qe);we&&+(/Firefox\/(\d+)/.exec(qe)||[0,0])[1];const zs=!de&&/Chrome\/(\d+)/.exec(qe),re=!!zs,xl=zs?+zs[1]:0,oe=!de&&!!Ae&&/Apple Computer/.test(Ae.vendor),It=oe&&(/Mobile\/\w+/.test(qe)||!!Ae&&Ae.maxTouchPoints>2),ye=It||(Ae?/Mac/.test(Ae.platform):!1),_u=Ae?/Win/.test(Ae.platform):!1,ze=/Android \d/.test(qe),ln=!!wl&&"webkitFontSmoothing"in wl.documentElement.style,Gu=ln?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Yu(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function He(n,e){return typeof n=="number"?n:n[e]}function Xu(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Ml(n,e,t){let r=n.someProp("scrollThreshold")||0,s=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let o=t||n.dom;o;o=sn(o)){if(o.nodeType!=1)continue;let l=o,a=l==i.body,c=a?Yu(i):Xu(l),d=0,u=0;if(e.top<c.top+He(r,"top")?u=-(c.top-e.top+He(s,"top")):e.bottom>c.bottom-He(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+He(s,"top")-c.top:e.bottom-c.bottom+He(s,"bottom")),e.left<c.left+He(r,"left")?d=-(c.left-e.left+He(s,"left")):e.right>c.right-He(r,"right")&&(d=e.right-c.right+He(s,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let f=l.scrollLeft,h=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let p=l.scrollLeft-f,m=l.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function Qu(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(i,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:Tl(n.dom)}}function Tl(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=sn(r));return e}function Zu({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Al(t,r==0?0:r-e)}function Al(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:s,left:i}=n[t];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let Lt=null;function ef(n){if(n.setActive)return n.setActive();if(Lt)return n.focus(Lt);let e=Tl(n);n.focus(Lt==null?{get preventScroll(){return Lt={preventScroll:!0},!0}}:void 0),Lt||(Lt=!1,Al(e,0))}function El(n,e){let t,r=2e8,s,i=0,o=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=Be(d).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){t=d,r=m,s=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&m&&(i=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!t&&a&&(t=a,s=c,r=0),t&&t.nodeType==3?tf(t,s):!t||r&&t.nodeType==1?{node:n,offset:i}:El(t,s)}function tf(n,e){let t=n.nodeValue.length,r=document.createRange();for(let s=0;s<t;s++){r.setEnd(n,s+1),r.setStart(n,s);let i=Ge(r,1);if(i.top!=i.bottom&&Hs(e,i))return{node:n,offset:s+(e.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function Hs(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function nf(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function rf(n,e,t){let{node:r,offset:s}=El(e,t),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,s,i)}function sf(n,e,t,r){let s=-1;for(let i=e,o=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!o&&a.left>r.left||a.top>r.top?s=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:n.docView.posFromDOM(e,t,-1)}function Ol(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=s;;){let o=n.childNodes[i];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Hs(e,c))return Ol(o,e,c)}}if((i=(i+1)%r)==s)break}return n}function of(n,e){let t=n.dom.ownerDocument,r,s=0,i=qu(t,e.left,e.top);i&&({node:r,offset:s}=i);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=n.dom.getBoundingClientRect();if(!Hs(e,c)||(o=Ol(n.dom,e,c),!o))return null}if(oe)for(let c=o;r&&c;c=sn(c))c.draggable&&(r=void 0);if(o=nf(o,e),r){if(we&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let d=r.childNodes[s],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let c;ln&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==n.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=sf(n,r,s,e))}l==null&&(l=rf(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Nl(n){return n.top<n.bottom||n.left<n.right}function Ge(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Nl(r))return r}return Array.prototype.find.call(t,Nl)||n.getBoundingClientRect()}const lf=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function vl(n,e,t){let{node:r,offset:s,atom:i}=n.docView.domFromPos(e,t<0?-1:1),o=ln||we;if(r.nodeType==3)if(o&&(lf.test(r.nodeValue)||(t<0?!s:s==r.nodeValue.length))){let a=Ge(Be(r,s,s),t);if(we&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=Ge(Be(r,s-1,s-1),-1);if(c.top==a.top){let d=Ge(Be(r,s,s+1),-1);if(d.top!=a.top)return an(d,d.left<c.left)}}return a}else{let a=s,c=s,d=t<0?1:-1;return t<0&&!s?(c++,d=-1):t>=0&&s==r.nodeValue.length?(a--,d=1):t<0?a--:c++,an(Ge(Be(r,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(t<0||s==ge(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return Fs(a.getBoundingClientRect(),!1)}if(i==null&&s<ge(r)){let a=r.childNodes[s];if(a.nodeType==1)return Fs(a.getBoundingClientRect(),!0)}return Fs(r.getBoundingClientRect(),t>=0)}if(i==null&&s&&(t<0||s==ge(r))){let a=r.childNodes[s-1],c=a.nodeType==3?Be(a,ge(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return an(Ge(c,1),!1)}if(i==null&&s<ge(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Be(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return an(Ge(c,-1),!0)}return an(Ge(r.nodeType==3?Be(r):r,-t),t>=0)}function an(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Fs(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Rl(n,e,t){let r=n.state,s=n.root.activeElement;r!=e&&n.updateState(e),s!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),s!=n.dom&&s&&s.focus()}}function af(n,e,t){let r=e.selection,s=t=="up"?r.$from:r.$to;return Rl(n,e,()=>{let{node:i}=n.docView.domFromPos(s.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=vl(n,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Be(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const cf=/[\u0590-\u08ac]/;function df(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=n.domSelection();return l?!cf.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:o:Rl(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let Dl=null,Il=null,Ll=!1;function uf(n,e,t){return Dl==e&&Il==t?Ll:(Dl=e,Il=t,Ll=t=="up"||t=="down"?af(n,e,t):df(n,e,t))}const be=0,Pl=1,gt=2,Ee=3;class cn{constructor(e,t,r,s){this.parent=e,this.children=t,this.dom=r,this.contentDOM=s,this.dirty=be,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let s=this.children[t];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=t>ee(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!t||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let s=this.children[t],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e||o instanceof Hl){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,t);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Bl&&i.side>=0;r--);if(t<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&t&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?ee(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?ee(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(s==-1&&e<=c){let d=o+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=o;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=ee(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=ee(u.dom);break}t+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,s=!1){let i=Math.min(e,t),o=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(i>p&&o<g)return m.setSelection(e-p-m.border,t-p-m.border,r,s);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((we||oe)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==`
6
+ `),u&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:ee(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=h.childNodes[p-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(we&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||u&&oe)&&pt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&pt(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let l=r+i.border,a=o-i.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?gt:Pl,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ee:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?gt:Ee}r=o}this.dirty=gt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?gt:Pl;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Bl extends cn{constructor(e,t,r,s){let i,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==be&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class ff extends cn{constructor(e,t,r,s){super(e,[],t,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Et extends cn{constructor(e,t,r,s,i){super(e,[],r,s),this.mark=t,this.spec=i}static create(e,t,r,s){let i=s.nodeViews[t.type.name],o=i&&i(t,s,r);return(!o||!o.dom)&&(o=At.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Et(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ee||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ee&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=be){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=be}}slice(e,t,r){let s=Et.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;t<o&&(i=Vs(i,t,o,r)),e>0&&(i=Vs(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class it extends cn{constructor(e,t,r,s,i,o,l,a,c){super(e,[],i,o),this.node=t,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,t,r,s,i,o){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,s),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=At.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=Vl(d,r,t),c?a=new hf(e,t,r,s,d,u||null,f,c,i,o+1):t.isText?new ms(e,t,r,s,d,f,i):new it(e,t,r,s,d,u||null,f,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>b.empty)}return e}matchesNode(e,t,r){return this.dirty==be&&e.eq(this.node)&&Zn(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,s=t,i=e.composing?this.localCompositionInfo(e,t):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new mf(this,o&&o.node,e);bf(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?B.none:this.node.child(d).marks,r,e),a.placeWidget(c,e,s)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==gt)&&(o&&this.protectLocalComposition(e,o),Fl(this.contentDOM,this.children,e),It&&kf(this.dom))}localCompositionInfo(e,t){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof T)||r<t||s>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=Sf(this.node.content,o,r-t,s-t);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:s}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new ff(this,i,t,s);e.input.compositionNodes.push(o),this.children=Vs(this.children,r,r+s.length,e,o)}update(e,t,r,s){return this.dirty==Ee||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,s),!0)}updateInner(e,t,r,s){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=be}updateOuterDeco(e){if(Zn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=$l(this.dom,this.nodeDOM,$s(this.outerDeco,this.node,t),$s(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function zl(n,e,t,r,s){Vl(r,e,n);let i=new it(void 0,n,e,t,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class ms extends it{constructor(e,t,r,s,i,o,l){super(e,t,r,s,i,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,s){return this.dirty==Ee||this.dirty!=be&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=be||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=be,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let s=this.node.cut(e,t),i=document.createTextNode(s.text);return new ms(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ee)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Hl extends cn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==be&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class hf extends it{constructor(e,t,r,s,i,o,l,a,c,d){super(e,t,r,s,i,o,l,c,d),this.spec=a}update(e,t,r,s){if(this.dirty==Ee)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,r);return i&&this.updateInner(e,t,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,s){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Fl(n,e,t){let r=n.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==n){for(;l!=r;)r=Wl(r),s=!0;r=r.nextSibling}else s=!0,n.insertBefore(l,r);if(o instanceof Et){let a=r?r.previousSibling:n.lastChild;Fl(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Wl(r),s=!0;s&&t.trackWrites==n&&(t.trackWrites=null)}const dn=function(n){n&&(this.nodeName=n)};dn.prototype=Object.create(null);const yt=[new dn];function $s(n,e,t){if(n.length==0)return yt;let r=t?yt[0]:new dn,s=[r];for(let i=0;i<n.length;i++){let o=n[i].type.attrs;if(o){o.nodeName&&s.push(r=new dn(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&s.length==1&&s.push(r=new dn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function $l(n,e,t,r){if(t==yt&&r==yt)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=t[i];if(i){let a;l&&l.nodeName==o.nodeName&&s!=n&&(a=s.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=yt[0]),s=a}pf(s,l||yt[0],o)}return s}function pf(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&n.classList.add(s[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)n.style.removeProperty(s[1])}t.style&&(n.style.cssText+=t.style)}}function Vl(n,e,t){return $l(n,n,yt,$s(e,t,n.nodeType!=1))}function Zn(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Wl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class mf{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=gf(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let s=0,i=this.stack.length>>1,o=Math.min(i,e.length);for(;s<o&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=be,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Et.create(this.top,e[i],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,s,i){let o=this.top.children[s];return o.dirty==Ee&&o.dom==o.contentDOM&&(o.dirty=gt),o.update(e,t,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=t}}updateNextNode(e,t,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof it){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,u,f=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ee&&Zn(t,a.outerDeco));if(!f&&a.update(e,t,r,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,t,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=gt,u.updateChildren(s,o+1),u.dirty=be),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,s,i,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Zn(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=it.create(this.top,t,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,s,i){let o=it.create(this.top,e,t,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new Bl(this.top,e,t,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Et;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ms)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((oe||re)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new Hl(this.top,[],r,null);t!=this.top?t.children.push(s):t.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function gf(n,e){let t=e,r=t.children.length,s=n.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Et)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function yf(n,e){return n.type.side-e.type.side}function bf(n,e,t,r){let s=e.locals(n),i=0;if(s.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,s,e.forChild(i,d),c),i+=d.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let d,u;for(;o<s.length&&s[o].to==i;){let g=s[o++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(yf);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<n.childCount)h=c,f=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let p=i+f.nodeSize;if(f.isText){let g=p;o<s.length&&s[o].from<g&&(g=s[o].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=f.cut(g-i),f=f.cut(0,g-i),p=g,h=-1)}else for(;o<s.length&&s[o].to<p;)o++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,m,e.forChild(i,f),h),i=p}}function kf(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Sf(n,e,t,r){for(let s=0,i=0;s<n.childCount&&i<=r;){let o=n.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let a=o.text;for(;s<n.childCount;){let c=n.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Vs(n,e,t,r,s){let i=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],c=l,d=l+=a.size;c>=t||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),s&&(i.push(s),s=void 0),d>t&&i.push(a.slice(t-c,a.size,r)))}return i}function Ws(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let s=n.docView.nearestDesc(t.focusNode),i=s&&s.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(Qn(t)){for(a=o;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&x.isSelectable(u)&&s.parent&&!(u.isInline&&Uu(t.focusNode,t.focusOffset,s.dom))){let f=s.posBefore;c=new x(o==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=o,f=o;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);u=Math.min(u,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,o]=f==n.state.selection.anchor?[f,u]:[u,f],l=r.resolve(o)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=Ks(n,d,l,u)}return c}function jl(n){return n.editable?n.hasFocus():Yl(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Fe(n,e=!1){let t=n.state.selection;if(ql(n,t),!!jl(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&re){let r=n.domSelectionRange(),s=n.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&pt(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Cf(n);else{let{anchor:r,head:s}=t,i,o;Kl&&!(t instanceof T)&&(t.$from.parent.inlineContent||(i=Ul(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Ul(n,t.to))),n.docView.setSelection(r,s,n,e),Kl&&(i&&Jl(i),o&&Jl(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&wf(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Kl=oe||re&&xl<63;function Ul(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),s=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(oe&&s&&s.contentEditable=="false")return js(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return js(s);if(i)return js(i)}}function js(n){return n.contentEditable="true",oe&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Jl(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function wf(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,s=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=s)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!jl(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Cf(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,s=r.nodeName=="IMG";s?t.setStart(r.parentNode,ee(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!s&&!n.state.selection.visible&&de&&_e<=11&&(r.disabled=!0,r.disabled=!1)}function ql(n,e){if(e instanceof x){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(_l(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else _l(n)}function _l(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Ks(n,e,t,r){return n.someProp("createSelectionBetween",s=>s(n,e,t))||T.between(e,t,r)}function Gl(n){return n.editable&&!n.hasFocus()?!1:Yl(n)}function Yl(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function xf(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return pt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Us(n,e){let{$anchor:t,$head:r}=n.selection,s=e>0?t.max(r):t.min(r),i=s.parent.inlineContent?s.depth?n.doc.resolve(e>0?s.after():s.before()):null:s;return i&&E.findFrom(i,e)}function Ye(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Xl(n,e,t){let r=n.state.selection;if(r instanceof T)if(t.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=n.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return Ye(n,new T(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let s=Us(n.state,e);return s&&s instanceof x?Ye(n,s):!1}else if(!(ye&&t.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=n.docView.descAt(l))&&!o.contentDOM?x.isSelectable(i)?Ye(n,new x(e<0?n.state.doc.resolve(s.pos-i.nodeSize):s)):ln?Ye(n,new T(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof x&&r.node.isInline)return Ye(n,new T(e>0?r.$to:r.$from));{let s=Us(n.state,e);return s?Ye(n,s):!1}}}function er(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function un(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Pt(n,e){return e<0?Mf(n):Tf(n)}function Mf(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s,i,o=!1;for(we&&t.nodeType==1&&r<er(t)&&un(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(un(l,-1))s=t,i=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Ql(t))break;{let l=t.previousSibling;for(;l&&un(l,-1);)s=t.parentNode,i=ee(l),l=l.previousSibling;if(l)t=l,r=er(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?Js(n,t,r):s&&Js(n,s,i)}function Tf(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let s=er(t),i,o;for(;;)if(r<s){if(t.nodeType!=1)break;let l=t.childNodes[r];if(un(l,1))i=t,o=++r;else break}else{if(Ql(t))break;{let l=t.nextSibling;for(;l&&un(l,1);)i=l.parentNode,o=ee(l)+1,l=l.nextSibling;if(l)t=l,r=0,s=er(t);else{if(t=t.parentNode,t==n.dom)break;r=s=0}}}i&&Js(n,i,o)}function Ql(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Af(n,e){for(;n&&e==n.childNodes.length&&!on(n);)e=ee(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Ef(n,e){for(;n&&!e&&!on(n);)e=ee(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Js(n,e,t){if(e.nodeType!=3){let i,o;(o=Af(e,t))?(e=o,t=0):(i=Ef(e,t))&&(e=i,t=i.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Qn(r)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:s}=n;setTimeout(()=>{n.state==s&&Fe(n)},50)}function Zl(n,e){let t=n.state.doc.resolve(e);if(!(re||_u)&&t.parent.inlineContent){let s=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function ea(n,e,t){let r=n.state.selection;if(r instanceof T&&!r.empty||t.indexOf("s")>-1||ye&&t.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=Us(n.state,e);if(o&&o instanceof x)return Ye(n,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof fe?E.near(o,e):E.findFrom(o,e);return l?Ye(n,l):!1}return!1}function ta(n,e){if(!(n.state.selection instanceof T))return!0;let{$head:t,$anchor:r,empty:s}=n.state.selection;if(!t.sameParent(r))return!0;if(!s)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let o=n.state.tr;return e<0?o.delete(t.pos-i.nodeSize,t.pos):o.delete(t.pos,t.pos+i.nodeSize),n.dispatch(o),!0}return!1}function na(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Of(n){if(!oe||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;na(n,r,"true"),setTimeout(()=>na(n,r,"false"),20)}return!1}function Nf(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function vf(n,e){let t=e.keyCode,r=Nf(e);if(t==8||ye&&t==72&&r=="c")return ta(n,-1)||Pt(n,-1);if(t==46&&!e.shiftKey||ye&&t==68&&r=="c")return ta(n,1)||Pt(n,1);if(t==13||t==27)return!0;if(t==37||ye&&t==66&&r=="c"){let s=t==37?Zl(n,n.state.selection.from)=="ltr"?-1:1:-1;return Xl(n,s,r)||Pt(n,s)}else if(t==39||ye&&t==70&&r=="c"){let s=t==39?Zl(n,n.state.selection.from)=="ltr"?1:-1:1;return Xl(n,s,r)||Pt(n,s)}else{if(t==38||ye&&t==80&&r=="c")return ea(n,-1,r)||Pt(n,-1);if(t==40||ye&&t==78&&r=="c")return Of(n)||ea(n,1,r)||Pt(n,1);if(r==(ye?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function qs(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||At.fromSchema(n.state.schema),l=da(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=aa[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=l.createElement(d[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
7
7
 
8
- `);return{dom:a,text:f,slice:e}}function na(n,e,t,r,s){let i=s.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,i||r,n)}),i)return e?new w(b.from(n.state.schema.text(e.replace(/\r\n?/g,`
9
- `))),0,0):w.empty;let u=n.someProp("clipboardTextParser",f=>f(e,s,r,n));if(u)l=u;else{let f=s.marks(),{schema:h}=n.state,p=At.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),o=Df(t),ln&&If(o);let c=o&&o.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ue.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Nf.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Lf(oa(l,+d[1],+d[2]),d[4]);else if(l=w.maxOpen(vf(l.content,s),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=oa(l,u,f)}return n.someProp("transformPasted",u=>{l=u(l,n)}),l}const Nf=/^(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 vf(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,o=[];if(n.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&sa(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=ia(o[o.length-1],i.length));let d=ra(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return b.from(o)}return n}function ra(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,b.from(n));return n}function sa(n,e,t,r,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=sa(n,e,t,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==n.length-1?t.type:n[s+1]))return r.copy(r.content.append(b.from(ra(t,n,s+1))))}}function ia(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,ia(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(b.empty,!0);return n.copy(t.append(r))}function qs(n,e,t,r,s,i){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(i=0),s<r-1&&(l=qs(l,e,t,r,s+1,i)),s>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(b.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function oa(n,e,t){return e<n.openStart&&(n=new w(qs(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new w(qs(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const la={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let aa=null;function ca(){return aa||(aa=document.implementation.createHTMLDocument("title"))}let _s=null;function Rf(n){let e=window.trustedTypes;return e?(_s||(_s=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),_s.createHTML(n)):n}function Df(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ca().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&la[r[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Rf(n),s)for(let i=0;i<s.length;i++)t=t.querySelector(s[i])||t;return t}function If(n){let e=n.querySelectorAll(re?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Lf(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:s,openStart:i,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=b.from(a.create(r[l+1],s)),i++,o++}return new w(s,i,o)}const le={},ae={},Pf={touchstart:!0,touchmove:!0};class Bf{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function zf(n){for(let e in le){let t=le[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Ff(n,r)&&!Ys(n,r)&&(n.editable||!(r.type in ae))&&t(n,r)},Pf[e]?{passive:!0}:void 0)}oe&&n.dom.addEventListener("input",()=>null),Gs(n)}function Xe(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Hf(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Gs(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Ys(n,r))})}function Ys(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Ff(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function $f(n,e){!Ys(n,e)&&le[e.type]&&(n.editable||!(e.type in ae))&&le[e.type](n,e)}ae.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!ua(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ze&&re&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),It&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",s=>s(n,mt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Of(n,t)?t.preventDefault():Xe(n,"key")},ae.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},ae.keypress=(n,e)=>{let t=e;if(ua(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ye&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof T)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function tr(n){return{left:n.clientX,top:n.clientY}}function Vf(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Xs(n,e,t,r,s){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(n.someProp(e,l=>o>i.depth?l(n,t,i.nodeAfter,i.before(o),s,!0):l(n,t,i.node(o),i.before(o),s,!1)))return!0;return!1}function Bt(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Wf(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&x.isSelectable(r)?(Bt(n,new x(t)),!0):!1}function jf(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof x&&(r=t.node);let i=n.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(x.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(o);break}}return s!=null?(Bt(n,x.create(n.state.doc,s)),!0):!1}function Kf(n,e,t,r,s){return Xs(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(s?jf(n,t):Wf(n,t))}function Uf(n,e,t,r){return Xs(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",s=>s(n,e,r))}function Jf(n,e,t,r){return Xs(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||qf(n,t,r)}function qf(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Bt(n,T.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)Bt(n,T.create(r,l+1,l+1+o.content.size));else if(x.isSelectable(o))Bt(n,x.create(r,l));else continue;return!0}}function Qs(n){return nr(n)}const da=ye?"metaKey":"ctrlKey";le.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Qs(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&Vf(t,n.input.lastClick)&&!t[da]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i};let o=n.posAtCoords(tr(t));o&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new _f(n,o,t,!!r)):(i=="doubleClick"?Uf:Jf)(n,o.pos,o.inside,t)?t.preventDefault():Xe(n,"pointer"))};class _f{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[da],this.allowDefault=r.shiftKey;let i,o;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,o=d.depth?d.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof x&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&we&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Xe(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Fe(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(tr(e))),this.updateAllowDefault(e),this.allowDefault||!t?Xe(this.view,"pointer"):Kf(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||oe&&this.mightDrag&&!this.mightDrag.node.isAtom||re&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Bt(this.view,E.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Xe(this.view,"pointer")}move(e){this.updateAllowDefault(e),Xe(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}le.touchstart=n=>{n.input.lastTouch=Date.now(),Qs(n),Xe(n,"pointer")},le.touchmove=n=>{n.input.lastTouch=Date.now(),Xe(n,"pointer")},le.contextmenu=n=>Qs(n);function ua(n,e){return n.composing?!0:oe&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Gf=ze?5e3:-1;ae.compositionstart=ae.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof T&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),nr(n,!0),n.markCursor=null;else if(nr(n,!e.selection.empty),we&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}n.input.composing=!0}fa(n,Gf)},ae.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,fa(n,20))};function fa(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>nr(n),e))}function ha(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Xf());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Yf(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Vu(e.focusNode,e.focusOffset),r=Wu(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let s=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function Xf(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function nr(n,e=!1){if(!(ze&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),ha(n),e||n.docView&&n.docView.dirty){let t=Vs(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Qf(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const fn=de&&_e<15||It&&qu<604;le.copy=ae.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let i=fn?null:t.clipboardData,o=r.content(),{dom:l,text:a}=Js(n,o);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):Qf(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Zf(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function eh(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?hn(n,r.value,null,s,e):hn(n,r.textContent,r.innerHTML,s,e)},50)}function hn(n,e,t,r,s){let i=na(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,i||w.empty)))return!0;if(!i)return!1;let o=Zf(i),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function pa(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ae.paste=(n,e)=>{let t=e;if(n.composing&&!ze)return;let r=fn?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&hn(n,pa(r),r.getData("text/html"),s,t)?t.preventDefault():eh(n,t)};class ma{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const ga=ye?"altKey":"ctrlKey";le.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(tr(t)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof x?s.to-1:s.to))){if(r&&r.mightDrag)o=x.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(o=x.create(n.state.doc,u.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:d}=Js(n,l);(!t.dataTransfer.files.length||!re||Cl>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(fn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",fn||t.dataTransfer.setData("text/plain",c),n.dragging=new ma(d,!t[ga],o)},le.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},ae.dragover=ae.dragenter=(n,e)=>e.preventDefault(),ae.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(tr(t));if(!s)return;let i=n.state.doc.resolve(s.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n)}):o=na(n,pa(t.dataTransfer),fn?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&!t[ga]);if(n.someProp("handleDrop",p=>p(n,t,o||w.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?sl(n.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,o.content.firstChild):c.replaceRange(d,d,o),c.doc.eq(f))return;let h=c.doc.resolve(d);if(u&&x.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new x(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,S)=>p=S),c.setSelection(js(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},le.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Fe(n)},20))},le.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},le.beforeinput=(n,e)=>{if(re&&ze&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,mt(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in ae)le[n]=ae[n];function pn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class ms{constructor(e,t){this.toDOM=e,this.spec=t||bt,this.side=this.spec.side||0}map(e,t,r,s){let{pos:i,deleted:o}=e.mapResult(t.from+s,this.side<0?-1:1);return o?null:new X(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ms&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&pn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ot{constructor(e,t){this.attrs=e,this.spec=t||bt}map(e,t,r,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new X(i,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof ot&&pn(this.attrs,e.attrs)&&pn(this.spec,e.spec)}static is(e){return e.type instanceof ot}destroy(){}}class yo{constructor(e,t){this.attrs=e,this.spec=t||bt}map(e,t,r,s){let i=e.mapResult(t.from+s,1);if(i.deleted)return null;let o=e.mapResult(t.to+s,-1);return o.deleted||o.pos<=i.pos?null:new X(i.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:s}=e.content.findIndex(t.from),i;return s==t.from&&!(i=e.child(r)).isText&&s+i.nodeSize==t.to}eq(e){return this==e||e instanceof yo&&pn(this.attrs,e.attrs)&&pn(this.spec,e.spec)}destroy(){}}class X{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new X(e,t,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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new X(e,e,new ms(t,r))}static inline(e,t,r,s){return new X(e,t,new ot(r,s))}static node(e,t,r,s){return new X(e,t,new yo(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof ot}get widget(){return this.type instanceof ms}}const zt=[],bt={};class z{constructor(e,t){this.local=e.length?e:zt,this.children=t.length?t:zt}static create(e,t){return t.length?rr(t,e,0,bt):se}find(e,t,r){let s=[];return this.findInner(e??0,t??1e9,s,0,r),s}findInner(e,t,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,s+l,i)}}map(e,t,r){return this==se||e.maps.length==0?this:this.mapInner(e,t,0,0,r||bt)}mapInner(e,t,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(t,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?th(this.children,o||[],e,t,r,s,i):o?new z(o.sort(kt),zt):se}add(e,t){return t.length?this==se?z.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,d;if(d=ba(t,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,d,c+1):s.splice(i,0,a,a+l.nodeSize,rr(d,l,c+1,bt)),i+=3}});let o=ya(i?ka(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new z(o.length?this.local.concat(o).sort(kt):this.local,s||this.children)}remove(e){return e.length==0||this==se?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+t,a=r[i+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(o||(o=[])).push(u));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=se?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new z(s,r):se}forChild(e,t){if(this==se)return this;if(t.isLeaf)return z.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof ot){let c=Math.max(i,a.from)-i,d=Math.min(o,a.to)-i;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new z(s.sort(kt),zt);return r?new lt([l,r]):l}return r||se}eq(e){if(this==e)return!0;if(!(e instanceof z)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Zs(this.localsInner(e))}localsInner(e){if(this==se)return zt;if(e.inlineContent||!this.local.some(ot.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ot||t.push(this.local[r]);return t}forEachSet(e){e(this)}}z.empty=new z([],[]),z.removeOverlap=Zs;const se=z.empty;class lt{constructor(e){this.members=e}map(e,t){const r=this.members.map(s=>s.map(e,t,bt));return lt.from(r)}forChild(e,t){if(t.isLeaf)return z.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=se&&(i instanceof lt?r=r.concat(i.members):r.push(i))}return lt.from(r)}eq(e){if(!(e instanceof lt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let o=0;o<i.length;o++)t.push(i[o])}}return t?Zs(r?t:t.sort(kt)):zt}static from(e){switch(e.length){case 0:return se;case 1:return e[0];default:return new lt(e.every(t=>t instanceof z)?e:e.reduce((t,r)=>t.concat(r instanceof z?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function th(n,e,t,r,s,i,o){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let y=0;y<l.length;y+=3){let S=l[y+1];if(S<0||f>S+d-u)continue;let A=l[y]+d-u;h>=A?l[y+1]=f<=A?-2:-1:f>=d&&g&&(l[y]+=g,l[y+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+i),u=d-s;if(u<0||u>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+i,-1),h=f-s,{index:p,offset:m}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&m==u&&m+g.nodeSize==h){let y=l[c+2].mapInner(t,g,d+1,n[c]+i+1,o);y!=se?(l[c]=u,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=nh(l,n,e,t,s,i,o),d=rr(c,r,0,o);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new z(e.sort(kt),l)}function ya(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let s=n[r];t.push(new X(s.from+e,s.to+e,s.type))}return t}function nh(n,e,t,r,s,i,o){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,s,c);u?t.push(u):o.onRemove&&o.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function ba(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,s=null;for(let i=0,o;i<n.length;i++)(o=n[i])&&o.from>t&&o.to<r&&((s||(s=[])).push(o),n[i]=null);return s}function ka(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function rr(n,e,t,r){let s=[],i=!1;e.forEach((l,a)=>{let c=ba(n,l,a+t);if(c){i=!0;let d=rr(c,l,t+a+1,r);d!=se&&s.push(a,a+l.nodeSize,d)}});let o=ya(i?ka(n):n,-t).sort(kt);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new z(o,s):se}function kt(n,e){return n.from-e.from||n.to-e.to}function Zs(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let s=t+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[s]=i.copy(i.from,r.to),Sa(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),Sa(e,s,r.copy(i.from,r.to)));break}}}return e}function Sa(n,e,t){for(;e<n.length&&kt(t,n[e])>0;)e++;n.splice(e,0,t)}function ei(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=se&&e.push(r)}),n.cursorWrapper&&e.push(z.create(n.state.doc,[n.cursorWrapper.deco])),lt.from(e)}const rh={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},sh=de&&_e<=11;class ih{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class oh{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ih,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);de&&_e<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),sh&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,rh)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(_l(this.view)){if(this.suppressingSelectionUpdates)return Fe(this.view);if(de&&_e<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&pt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=sn(i))t.add(i);for(let i=e.anchorNode;i;i=sn(i))if(t.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&_l(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(i=i<0?u.from:Math.min(u.from,i),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(l=!0))}if(we&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||ch(e,u)!=h)&&f.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Qn(r)&&(c=Vs(e))&&c.eq(E.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Fe(e),this.currentSelection.set(r)):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),lh(e)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Fe(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(de&&_e<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let o=s&&s.parentNode==e.target?ee(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?ee(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let wa=new WeakMap,Ca=!1;function lh(n){if(!wa.has(n)&&(wa.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=we,Ca)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."),Ca=!0}}function xa(n,e){let t=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return pt(o.node,o.offset,s,i)&&([t,r,s,i]=[s,i,t,r]),{anchorNode:t,anchorOffset:r,focusNode:s,focusOffset:i}}function ah(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return xa(n,s)}let t;function r(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?xa(n,t):null}function ch(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function dh(n,e,t){let{node:r,fromOffset:s,toOffset:i,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],Qn(a)||c.push({node:a.focusNode,offset:a.focusOffset})),re&&n.input.lastKeyCode===8)for(let g=i;g>s;g--){let y=r.childNodes[g-1],S=y.pmViewDesc;if(y.nodeName=="BR"&&!S){i=g;break}if(!S||S.size)break}let u=n.state.doc,f=n.someProp("domParser")||Ue.fromSchema(n.state.schema),h=u.resolve(o),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:uh,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+o,head:y+o}}return{doc:m,sel:p,from:o,to:l}}function uh(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(oe&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||oe&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const fh=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function hh(n,e,t,r,s){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let D=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,me=Vs(n,D);if(me&&!n.state.selection.eq(me)){if(re&&ze&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Xt=>Xt(n,mt(13,"Enter"))))return;let ut=n.state.tr.setSelection(me);D=="pointer"?ut.setMeta("pointer",!0):D=="key"&&ut.scrollIntoView(),i&&ut.setMeta("composition",i),n.dispatch(ut)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=dh(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=gh(u.content,c.doc.content,c.from,f,h);if(p&&n.input.domChangeCount++,(It&&n.input.lastIOSEnter>Date.now()-225||ze)&&s.some(D=>D.nodeType==1&&!fh.test(D.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",D=>D(n,mt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof T&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let D=Ma(n,n.state.doc,c.sel);if(D&&!D.eq(n.state.selection)){let me=n.state.tr.setSelection(D);i&&me.setMeta("composition",i),n.dispatch(me)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof T&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),de&&_e<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=d.resolve(p.start),S=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA,A;if((It&&n.input.lastIOSEnter>Date.now()-225&&(!S||s.some(D=>D.nodeName=="DIV"||D.nodeName=="P"))||!S&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(A=E.findFrom(c.doc.resolve(m.pos+1),1,!0))&&A.head==g.pos)&&n.someProp("handleKeyDown",D=>D(n,mt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&mh(d,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",D=>D(n,mt(8,"Backspace")))){ze&&re&&n.domObserver.suppressSelectionUpdates();return}re&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),ze&&!S&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(D){return D(n,mt(13,"Enter"))})},20));let R=p.start,M=p.endA,v,V,U;if(S){if(m.pos==g.pos)de&&_e<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Fe(n),20)),v=n.state.tr.delete(R,M),V=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(U=ph(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))v=n.state.tr,U.type=="add"?v.addMark(R,M,U.mark):v.removeMark(R,M,U.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let D=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",me=>me(n,R,M,D)))return;v=n.state.tr.insertText(D,R,M)}}if(v||(v=n.state.tr.replace(R,M,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let D=Ma(n,v.doc,c.sel);D&&!(re&&n.composing&&D.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(D.head==R||D.head==v.mapping.map(M)-1)||de&&D.empty&&D.head==R)&&v.setSelection(D)}V&&v.ensureMarks(V),i&&v.setMeta("composition",i),n.dispatch(v.scrollIntoView())}function Ma(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:js(n,e.resolve(t.anchor),e.resolve(t.head))}function ph(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,s=t,i=r,o,l,a;for(let d=0;d<r.length;d++)s=r[d].removeFromSet(s);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(b.from(c).eq(n))return{mark:l,type:o}}function mh(n,e,t,r,s){if(t-e<=s.pos-r.pos||ti(r,!0,!1)<s.pos)return!1;let i=n.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=n.resolve(ti(i,!0,!0));return!o.parent.isTextblock||o.pos>t||ti(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function ti(n,e,t){let r=n.depth,s=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,s++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function gh(n,e,t,r,s){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(o,l));r-=o+a-i}if(o<i&&n.size<e.size){let a=r<=i&&r>=o?i-r:0;i-=a,i&&i<e.size&&Ta(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-o),o=i}else if(l<i){let a=r<=i&&r>=l?i-r:0;i-=a,i&&i<n.size&&Ta(n.textBetween(i-1,i+1))&&(i+=a?1:-1),o=i+(o-l),l=i}return{start:i,endA:o,endB:l}}function Ta(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class yh{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 Bf,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(va),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Oa(this),Ea(this),this.nodeViews=Na(this),this.docView=Bl(this.state.doc,Aa(this),ei(this),this.dom,this),this.domObserver=new oh(this,(r,s,i,o)=>hh(this,r,s,i,o)),this.domObserver.start(),zf(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&&Gs(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(va),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(ha(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Na(this);kh(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Gs(this),this.editable=Oa(this),Ea(this);let a=ei(this),c=Aa(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(o=!0);let f=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Yu(this);if(o){this.domObserver.stop();let h=u&&(de||re)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&bh(s.selection,e.selection);if(u){let p=re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Yf(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Bl(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&wf(this))?Fe(this,h):(Jl(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&Xu(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof x){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&xl(this,t.getBoundingClientRect(),e)}else xl(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 t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new ma(e.slice,e.move,s<0?void 0:x.create(this.state.doc,s))}someProp(e,t){let r=this._props&&this._props[e],s;if(r!=null&&(s=t?t(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=t?t(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(de){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Qu(this.dom),Fe(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return rf(this,e)}coordsAtPos(e,t=1){return Nl(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,r=-1){let s=this.docView.posFromDOM(e,t,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return cf(this,t||this.state,e)}pasteHTML(e,t){return hn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return hn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Js(this,e)}destroy(){this.docView&&(Hf(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ei(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Fu())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return $f(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?oe&&this.root.nodeType===11&&Ku(this.dom.ownerDocument)==this.dom&&ah(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Aa(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[X.node(0,n.state.doc.content.size,e)]}function Ea(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:X.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Oa(n){return!n.someProp("editable",e=>e(n.state)===!1)}function bh(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Na(n){let e=Object.create(null);function t(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function kh(n,e){let t=0,r=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)r++;return t!=r}function va(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var Qe={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:"'"},sr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Sh=typeof navigator<"u"&&/Mac/.test(navigator.platform),wh=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),te=0;te<10;te++)Qe[48+te]=Qe[96+te]=String(te);for(var te=1;te<=24;te++)Qe[te+111]="F"+te;for(var te=65;te<=90;te++)Qe[te]=String.fromCharCode(te+32),sr[te]=String.fromCharCode(te);for(var ni in Qe)sr.hasOwnProperty(ni)||(sr[ni]=Qe[ni]);function Ch(n){var e=Sh&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||wh&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?sr:Qe)[n.keyCode]||n.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}const xh=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Mh(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))xh?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),s&&(t="Ctrl-"+t),o&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function Th(n){let e=Object.create(null);for(let t in n)e[Mh(t)]=n[t];return e}function ri(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Ah(n){return new H({props:{handleKeyDown:si(n)}})}function si(n){let e=Th(n);return function(t,r){let s=Ch(r),i,o=e[ri(s,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[ri(s,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||s.charCodeAt(0)>127)&&(i=Qe[r.keyCode])&&i!=s){let l=e[ri(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const ii=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Ra(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Da=(n,e,t)=>{let r=Ra(n,t);if(!r)return!1;let s=oi(r);if(!s){let o=r.blockRange(),l=o&&vt(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(Va(n,s,e,-1))return!0;if(r.parent.content.size==0&&(Ht(i,"end")||x.isSelectable(i)))for(let o=r.depth;;o--){let l=Xn(n.doc,r.before(o),r.after(o),w.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Ht(i,"end")?E.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):x.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},Eh=(n,e,t)=>{let r=Ra(n,t);if(!r)return!1;let s=oi(r);return s?Ia(n,s,e):!1},Oh=(n,e,t)=>{let r=Pa(n,t);if(!r)return!1;let s=li(r);return s?Ia(n,s,e):!1};function Ia(n,e,t){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=d}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=Xn(n.doc,i,a,w.empty);if(!c||c.from!=i||c instanceof Q&&c.slice.size>=a-i)return!1;if(t){let d=n.tr.step(c);d.setSelection(T.create(d.doc,i)),t(d.scrollIntoView())}return!0}function Ht(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const La=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=oi(r)}let o=i&&i.nodeBefore;return!o||!x.isSelectable(o)?!1:(e&&e(n.tr.setSelection(x.create(n.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function oi(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Pa(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Ba=(n,e,t)=>{let r=Pa(n,t);if(!r)return!1;let s=li(r);if(!s)return!1;let i=s.nodeAfter;if(Va(n,s,e,1))return!0;if(r.parent.content.size==0&&(Ht(i,"start")||x.isSelectable(i))){let o=Xn(n.doc,r.before(),r.after(),w.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(Ht(i,"start")?E.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):x.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},za=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=li(r)}let o=i&&i.nodeAfter;return!o||!x.isSelectable(o)?!1:(e&&e(n.tr.setSelection(x.create(n.doc,i.pos)).scrollIntoView()),!0)};function li(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Nh=(n,e)=>{let t=n.selection,r=t instanceof x,s;if(r){if(t.node.isTextblock||!Je(n.doc,t.from))return!1;s=t.from}else if(s=Yn(n.doc,t.from,-1),s==null)return!1;if(e){let i=n.tr.join(s);r&&i.setSelection(x.create(i.doc,s-n.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},vh=(n,e)=>{let t=n.selection,r;if(t instanceof x){if(t.node.isTextblock||!Je(n.doc,t.to))return!1;r=t.to}else if(r=Yn(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Rh=(n,e)=>{let{$from:t,$to:r}=n.selection,s=t.blockRange(r),i=s&&vt(s);return i==null?!1:(e&&e(n.tr.lift(s,i).scrollIntoView()),!0)},Ha=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
10
- `).scrollIntoView()),!0)};function ai(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Dh=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let s=t.node(-1),i=t.indexAfter(-1),o=ai(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(E.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Fa=(n,e)=>{let t=n.selection,{$from:r,$to:s}=t;if(t instanceof fe||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=ai(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=n.tr.insert(o,i.createAndFill());l.setSelection(T.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},$a=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(Pe(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),s=r&&vt(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)};function Ih(n){return(e,t)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof x&&e.selection.node.isBlock)return!r.parentOffset||!Pe(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=ai(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),i.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof T||e.selection instanceof fe)&&d.deleteSelection();let u=d.mapping.map(r.pos),f=Pe(d.doc,u,i.length,i);if(f||(i[0]=l?{type:l}:null,f=Pe(d.doc,u,i.length,i)),d.split(u,i.length,i),!a&&c&&r.node(o).type!=l){let h=d.mapping.map(r.before(o)),p=d.doc.resolve(h);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return t&&t(d.scrollIntoView()),!0}}const Lh=Ih(),Ph=(n,e)=>{let{$from:t,to:r}=n.selection,s,i=t.sharedDepth(r);return i==0?!1:(s=t.before(i),e&&e(n.tr.setSelection(x.create(n.doc,s))),!0)};function Bh(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||Je(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Va(n,e,t,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&Bh(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(t){let h=e.pos+i.nodeSize,p=b.empty;for(let y=o.length-1;y>=0;y--)p=b.from(o[y].create(null,p));p=b.from(s.copy(p));let m=n.tr.step(new Y(e.pos-1,h,e.pos,h,new w(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==s.type&&Je(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&a?null:E.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&vt(u);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(u,f).scrollIntoView()),!0;if(c&&Ht(i,"start",!0)&&Ht(s,"end")){let h=s,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let y=b.empty;for(let A=p.length-1;A>=0;A--)y=b.from(p[A].copy(y));let S=n.tr.step(new Y(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new w(y,p.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function Wa(n){return function(e,t){let r=e.selection,s=n<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(t&&t(e.tr.setSelection(T.create(e.doc,n<0?s.start(i):s.end(i)))),!0):!1}}const zh=Wa(-1),Hh=Wa(1);function Fh(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i),l=o&&As(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function ja(n,e=null){return function(t,r){let s=!1;for(let i=0;i<t.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(o,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let d=t.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,n)}})}if(!s)return!1;if(r){let i=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];i.setBlockType(l,a,n,e)}r(i.scrollIntoView())}return!0}}function ci(...n){return function(e,t,r){for(let s=0;s<n.length;s++)if(n[s](e,t,r))return!0;return!1}}ci(ii,Da,La),ci(ii,Ba,za),ci(Ha,Fa,$a,Lh),typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function $h(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i),l=!1,a=o;if(!o)return!1;if(o.depth>=2&&s.node(o.depth-1).type.compatibleContent(n)&&o.startIndex==0){if(s.index(o.depth-1)==0)return!1;let d=t.doc.resolve(o.start-2);a=new Un(d,d,o.depth),o.endIndex<o.parent.childCount&&(o=new Un(s,t.doc.resolve(i.end(o.depth)),o.depth)),l=!0}let c=As(a,n,e,o);return c?(r&&r(Vh(t.tr,o,c,l,n).scrollIntoView()),!0):!1}}function Vh(n,e,t,r,s){let i=b.empty;for(let d=t.length-1;d>=0;d--)i=b.from(t[d].type.create(t[d].attrs,i));n.step(new Y(e.start-(r?2:0),e.end,e.start,e.end,new w(i,0,0),t.length,!0));let o=0;for(let d=0;d<t.length;d++)t[d].type==s&&(o=d+1);let l=t.length-o,a=e.start+t.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,f=!0;d<u;d++,f=!1)!f&&Pe(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function Wh(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==n);return i?t?r.node(i.depth-1).type==n?jh(e,t,n,i):Kh(e,t,i):!0:!1}}function jh(n,e,t,r){let s=n.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new Y(i-1,o,i,o,new w(b.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Un(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const l=vt(r);if(l==null)return!1;s.lift(r,l);let a=s.mapping.map(i,-1)-1;return Je(s.doc,a)&&s.join(a),e(s.scrollIntoView()),!0}function Kh(n,e,t){let r=n.tr,s=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=s.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(t.start),o=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,o.content.append(a?b.empty:b.from(s))))return!1;let u=i.pos,f=u+o.nodeSize;return r.step(new Y(u-(l?1:0),f+(a?1:0),u+1,f-1,new w((l?b.empty:b.from(s.copy(b.empty))).append(a?b.empty:b.from(s.copy(b.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Uh(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=b.from(c?n.create():null),u=new w(b.from(n.create(null,b.from(l.type.create(null,d)))),c?3:1,0),f=i.start,h=i.end;t(e.tr.step(new Y(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}function mn(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:s}=t,{storedMarks:i}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=t.selection,s=t.doc,i=t.storedMarks,t}}}class gn{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:s}=t,{tr:i}=r,o=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...d)=>{const u=a(...d)(o);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l=[],a=!!e,c=e||i.tr,d=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{const g=this.buildProps(c,t),y=h(...m)(g);return l.push(y),u}])),run:d};return u}createCan(e){const{rawCommands:t,state:r}=this,s=!1,i=e||r.tr,o=this.buildProps(i,s);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...d)=>c(...d)({...o,dispatch:void 0})])),chain:()=>this.createChain(i,s)}}buildProps(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l={tr:e,editor:s,view:o,state:mn({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...d)=>c(...d)(l)]))}};return l}}class Jh{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(s=>s.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(s=>s!==t):delete this.callbacks[e]),this}once(e,t){const r=(...s)=>{this.off(e,r),t.apply(this,s)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function C(n,e,t){return n.config[e]===void 0&&n.parent?C(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?C(n.parent,e,t):null}):n.config[e]}function yn(n){const e=n.filter(s=>s.type==="extension"),t=n.filter(s=>s.type==="node"),r=n.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function di(n){const e=[],{nodeExtensions:t,markExtensions:r}=yn(n),s=[...t,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:s},a=C(o,"addGlobalAttributes",l);if(!a)return;a().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([f,h])=>{e.push({type:u,name:f,attribute:{...i,...h}})})})})}),s.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=C(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([d,u])=>{const f={...i,...u};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:o.name,name:d,attribute:f})})}),e}function _(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function I(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?String(i).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(d=>!a.includes(d));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=i?i.split(";").map(d=>d.trim()).filter(Boolean):[],a=r[s]?r[s].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;a.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),l.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),r[s]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[s]=i}),r},{})}function ir(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>I(t,r),{})}function ui(n){return typeof n=="function"}function O(n,e=void 0,...t){return ui(n)?e?n.bind(e)(...t):n(...t):n}function Ka(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Ua(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function fi(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):Ua(t.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function Ja(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Ka(t)?!1:t!=null))}function hi(n,e){var t;const r=di(n),{nodeExtensions:s,markExtensions:i}=yn(n),o=(t=s.find(c=>C(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(s.map(c=>{const d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((y,S)=>{const A=C(S,"extendNodeSchema",u);return{...y,...A?A(c):{}}},{}),h=Ja({...f,content:O(C(c,"content",u)),marks:O(C(c,"marks",u)),group:O(C(c,"group",u)),inline:O(C(c,"inline",u)),atom:O(C(c,"atom",u)),selectable:O(C(c,"selectable",u)),draggable:O(C(c,"draggable",u)),code:O(C(c,"code",u)),whitespace:O(C(c,"whitespace",u)),linebreakReplacement:O(C(c,"linebreakReplacement",u)),defining:O(C(c,"defining",u)),isolating:O(C(c,"isolating",u)),attrs:Object.fromEntries(d.map(y=>{var S;return[y.name,{default:(S=y?.attribute)===null||S===void 0?void 0:S.default}]}))}),p=O(C(c,"parseHTML",u));p&&(h.parseDOM=p.map(y=>fi(y,d)));const m=C(c,"renderHTML",u);m&&(h.toDOM=y=>m({node:y,HTMLAttributes:ir(y,d)}));const g=C(c,"renderText",u);return g&&(h.toText=g),[c.name,h]})),a=Object.fromEntries(i.map(c=>{const d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((g,y)=>{const S=C(y,"extendMarkSchema",u);return{...g,...S?S(c):{}}},{}),h=Ja({...f,inclusive:O(C(c,"inclusive",u)),excludes:O(C(c,"excludes",u)),group:O(C(c,"group",u)),spanning:O(C(c,"spanning",u)),code:O(C(c,"code",u)),attrs:Object.fromEntries(d.map(g=>{var y;return[g.name,{default:(y=g?.attribute)===null||y===void 0?void 0:y.default}]}))}),p=O(C(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>fi(g,d)));const m=C(c,"renderHTML",u);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:ir(g,d)})),[c.name,h]}));return new Ho({topNode:o,nodes:l,marks:a})}function or(n,e){return e.nodes[n]||e.marks[n]||null}function pi(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function bn(n,e){const t=At.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}const qa=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;const d=((c=(a=s.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";t+=s.isAtom&&!s.isText?d:d.slice(0,Math.max(0,r-i))}),t};function lr(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class Ft{constructor(e){this.find=e.find,this.handler=e.handler}}const qh=(n,e)=>{if(lr(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function ar(n){var e;const{editor:t,from:r,to:s,text:i,rules:o,plugin:l}=n,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1;const u=qa(c)+i;return o.forEach(f=>{if(d)return;const h=qh(u,f.find);if(!h)return;const p=a.state.tr,m=mn({state:a.state,transaction:p}),g={from:r-(h[0].length-i.length),to:s},{commands:y,chain:S,can:A}=new gn({editor:t,state:m});f.handler({state:m,range:g,match:h,commands:y,chain:S,can:A})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:r,to:s,text:i}),a.dispatch(p),d=!0)}),d}function _a(n){const{editor:e,rules:t}=n,r=new H({state:{init(){return null},apply(s,i,o){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=bn(b.from(d),o.schema);const{from:u}=a,f=u+d.length;ar({editor:e,from:u,to:f,text:d,rules:t,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return ar({editor:e,from:i,to:o,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&ar({editor:e,from:i.pos,to:i.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?ar({editor:e,from:o.pos,to:o.pos,text:`
11
- `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function _h(n){return Object.prototype.toString.call(n).slice(8,-1)}function kn(n){return _h(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Sn(n,e){const t={...n};return kn(n)&&kn(e)&&Object.keys(e).forEach(r=>{kn(e[r])&&kn(n[r])?t[r]=Sn(n[r],e[r]):t[r]=e[r]}),t}class ce{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=O(C(this,"addOptions",{name:this.name}))),this.storage=O(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new ce(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Sn(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new ce(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=O(C(t,"addOptions",{name:t.name})),t.storage=O(C(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>c?.type.name===t.name))return!1;const a=o.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}}function Ga(n){return typeof n=="number"}class cr{constructor(e){this.find=e.find,this.handler=e.handler}}const Gh=(n,e,t)=>{if(lr(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=n,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function Yh(n){const{editor:e,state:t,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=n,{commands:a,chain:c,can:d}=new gn({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,s,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;const m=Math.max(r,p),g=Math.min(s,p+h.content.size),y=h.textBetween(m-p,g-p,void 0,"\uFFFC");Gh(y,i.find,o).forEach(A=>{if(A.index===void 0)return;const R=m+A.index+1,M=R+A[0].length,v={from:t.tr.mapping.map(R),to:t.tr.mapping.map(M)},V=i.handler({state:t,range:v,match:A,commands:a,chain:c,can:d,pasteEvent:o,dropEvent:l});u.push(V)})}),u.every(h=>h!==null)}let dr=null;const Xh=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function Ya(n){const{editor:e,rules:t}=n;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:d,from:u,to:f,rule:h,pasteEvt:p})=>{const m=d.tr,g=mn({state:d,transaction:m});if(!(!Yh({editor:e,state:g,from:Math.max(u-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return t.map(d=>new H({view(u){const f=p=>{var m;r=!((m=u.dom.parentElement)===null||m===void 0)&&m.contains(p.target)?u.dom.parentElement:null,r&&(dr=e)},h=()=>{dr&&(dr=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(i=r===u.dom.parentElement,l=f,!i){const h=dr;h&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,f)=>{var h;const p=(h=f.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return o=f,s=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(u,f,h)=>{const p=u[0],m=p.getMeta("uiEvent")==="paste"&&!s,g=p.getMeta("uiEvent")==="drop"&&!i,y=p.getMeta("applyPasteRules"),S=!!y;if(!m&&!g&&!S)return;if(S){let{text:M}=y;typeof M=="string"?M=M:M=bn(b.from(M),h.schema);const{from:v}=y,V=v+M.length,U=Xh(M);return a({rule:d,state:h,from:v,to:{b:V},pasteEvt:U})}const A=f.doc.content.findDiffStart(h.doc.content),R=f.doc.content.findDiffEnd(h.doc.content);if(!(!Ga(A)||!R||A===R.b))return a({rule:d,state:h,from:A,to:R,pasteEvt:o})}}))}function Xa(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}class Ot{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=Ot.resolve(e),this.schema=hi(this.extensions,t),this.setupExtensions()}static resolve(e){const t=Ot.sort(Ot.flatten(e)),r=Xa(t.map(s=>s.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},s=C(t,"addExtensions",r);return s?[t,...this.flatten(s())]:t}).flat(10)}static sort(e){return e.sort((r,s)=>{const i=C(r,"priority")||100,o=C(s,"priority")||100;return i>o?-1:i<o?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:or(t.name,this.schema)},s=C(t,"addCommands",r);return s?{...e,...s()}:e},{})}get plugins(){const{editor:e}=this,t=Ot.sort([...this.extensions].reverse()),r=[],s=[],i=t.map(o=>{const l={name:o.name,options:o.options,storage:o.storage,editor:e,type:or(o.name,this.schema)},a=[],c=C(o,"addKeyboardShortcuts",l);let d={};if(o.type==="mark"&&C(o,"exitable",l)&&(d.ArrowRight=()=>ce.handleExit({editor:e,mark:o})),c){const m=Object.fromEntries(Object.entries(c()).map(([g,y])=>[g,()=>y({editor:e})]));d={...d,...m}}const u=Ah(d);a.push(u);const f=C(o,"addInputRules",l);pi(o,e.options.enableInputRules)&&f&&r.push(...f());const h=C(o,"addPasteRules",l);pi(o,e.options.enablePasteRules)&&h&&s.push(...h());const p=C(o,"addProseMirrorPlugins",l);if(p){const m=p();a.push(...m)}return a}).flat();return[_a({editor:e,rules:r}),...Ya({editor:e,rules:s}),...i]}get attributes(){return di(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=yn(this.extensions);return Object.fromEntries(t.filter(r=>!!C(r,"addNodeView")).map(r=>{const s=this.attributes.filter(a=>a.type===r.name),i={name:r.name,options:r.options,storage:r.storage,editor:e,type:_(r.name,this.schema)},o=C(r,"addNodeView",i);if(!o)return[];const l=(a,c,d,u,f)=>{const h=ir(a,s);return o()({node:a,view:c,getPos:d,decorations:u,innerDecorations:f,editor:e,extension:r,HTMLAttributes:h})};return[r.name,l]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:or(e.name,this.schema)};e.type==="mark"&&(!((t=O(C(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const s=C(e,"onBeforeCreate",r),i=C(e,"onCreate",r),o=C(e,"onUpdate",r),l=C(e,"onSelectionUpdate",r),a=C(e,"onTransaction",r),c=C(e,"onFocus",r),d=C(e,"onBlur",r),u=C(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}}class W{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=O(C(this,"addOptions",{name:this.name}))),this.storage=O(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new W(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Sn(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new W({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=O(C(t,"addOptions",{name:t.name})),t.storage=O(C(t,"addStorage",{name:t.name,options:t.options})),t}}function mi(n,e,t){const{from:r,to:s}=e,{blockSeparator:i=`
8
+ `);return{dom:a,text:f,slice:e}}function ra(n,e,t,r,s){let i=s.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,i||r,n)}),i)return e?new w(b.from(n.state.schema.text(e.replace(/\r\n?/g,`
9
+ `))),0,0):w.empty;let u=n.someProp("clipboardTextParser",f=>f(e,s,r,n));if(u)l=u;else{let f=s.marks(),{schema:h}=n.state,p=At.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),o=Lf(t),ln&&Pf(o);let c=o&&o.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ue.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Rf.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Bf(la(l,+d[1],+d[2]),d[4]);else if(l=w.maxOpen(Df(l.content,s),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=la(l,u,f)}return n.someProp("transformPasted",u=>{l=u(l,n)}),l}const Rf=/^(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 Df(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.index(t)),i,o=[];if(n.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&ia(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=oa(o[o.length-1],i.length));let d=sa(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return b.from(o)}return n}function sa(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,b.from(n));return n}function ia(n,e,t,r,s){if(s<n.length&&s<e.length&&n[s]==e[s]){let i=ia(n,e,t,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==n.length-1?t.type:n[s+1]))return r.copy(r.content.append(b.from(sa(t,n,s+1))))}}function oa(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,oa(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(b.empty,!0);return n.copy(t.append(r))}function _s(n,e,t,r,s,i){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(i=0),s<r-1&&(l=_s(l,e,t,r,s+1,i)),s>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(b.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function la(n,e,t){return e<n.openStart&&(n=new w(_s(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new w(_s(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const aa={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ca=null;function da(){return ca||(ca=document.implementation.createHTMLDocument("title"))}let Gs=null;function If(n){let e=window.trustedTypes;return e?(Gs||(Gs=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Gs.createHTML(n)):n}function Lf(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=da().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),s;if((s=r&&aa[r[1].toLowerCase()])&&(n=s.map(i=>"<"+i+">").join("")+n+s.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=If(n),s)for(let i=0;i<s.length;i++)t=t.querySelector(s[i])||t;return t}function Pf(n){let e=n.querySelectorAll(re?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Bf(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:s,openStart:i,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=b.from(a.create(r[l+1],s)),i++,o++}return new w(s,i,o)}const le={},ae={},zf={touchstart:!0,touchmove:!0};class Hf{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Ff(n){for(let e in le){let t=le[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Vf(n,r)&&!Xs(n,r)&&(n.editable||!(r.type in ae))&&t(n,r)},zf[e]?{passive:!0}:void 0)}oe&&n.dom.addEventListener("input",()=>null),Ys(n)}function Xe(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function $f(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Ys(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Xs(n,r))})}function Xs(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Vf(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Wf(n,e){!Xs(n,e)&&le[e.type]&&(n.editable||!(e.type in ae))&&le[e.type](n,e)}ae.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!fa(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ze&&re&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),It&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",s=>s(n,mt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||vf(n,t)?t.preventDefault():Xe(n,"key")},ae.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},ae.keypress=(n,e)=>{let t=e;if(fa(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||ye&&t.metaKey)return;if(n.someProp("handleKeyPress",s=>s(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof T)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(t.charCode);!/[\r\n]/.test(s)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,s))&&n.dispatch(n.state.tr.insertText(s).scrollIntoView()),t.preventDefault()}};function tr(n){return{left:n.clientX,top:n.clientY}}function jf(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Qs(n,e,t,r,s){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(n.someProp(e,l=>o>i.depth?l(n,t,i.nodeAfter,i.before(o),s,!0):l(n,t,i.node(o),i.before(o),s,!1)))return!0;return!1}function Bt(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Kf(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&x.isSelectable(r)?(Bt(n,new x(t)),!0):!1}function Uf(n,e){if(e==-1)return!1;let t=n.state.selection,r,s;t instanceof x&&(r=t.node);let i=n.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(x.isSelectable(l)){r&&t.$from.depth>0&&o>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?s=i.before(t.$from.depth):s=i.before(o);break}}return s!=null?(Bt(n,x.create(n.state.doc,s)),!0):!1}function Jf(n,e,t,r,s){return Qs(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(s?Uf(n,t):Kf(n,t))}function qf(n,e,t,r){return Qs(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",s=>s(n,e,r))}function _f(n,e,t,r){return Qs(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",s=>s(n,e,r))||Gf(n,t,r)}function Gf(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Bt(n,T.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)Bt(n,T.create(r,l+1,l+1+o.content.size));else if(x.isSelectable(o))Bt(n,x.create(r,l));else continue;return!0}}function Zs(n){return nr(n)}const ua=ye?"metaKey":"ctrlKey";le.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Zs(n),s=Date.now(),i="singleClick";s-n.input.lastClick.time<500&&jf(t,n.input.lastClick)&&!t[ua]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:s,x:t.clientX,y:t.clientY,type:i};let o=n.posAtCoords(tr(t));o&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Yf(n,o,t,!!r)):(i=="doubleClick"?qf:_f)(n,o.pos,o.inside,t)?t.preventDefault():Xe(n,"pointer"))};class Yf{constructor(e,t,r,s){this.view=e,this.pos=t,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[ua],this.allowDefault=r.shiftKey;let i,o;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),o=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,o=d.depth?d.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof x&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&we&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Xe(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Fe(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(tr(e))),this.updateAllowDefault(e),this.allowDefault||!t?Xe(this.view,"pointer"):Jf(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||oe&&this.mightDrag&&!this.mightDrag.node.isAtom||re&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Bt(this.view,E.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Xe(this.view,"pointer")}move(e){this.updateAllowDefault(e),Xe(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}le.touchstart=n=>{n.input.lastTouch=Date.now(),Zs(n),Xe(n,"pointer")},le.touchmove=n=>{n.input.lastTouch=Date.now(),Xe(n,"pointer")},le.contextmenu=n=>Zs(n);function fa(n,e){return n.composing?!0:oe&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Xf=ze?5e3:-1;ae.compositionstart=ae.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof T&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),nr(n,!0),n.markCursor=null;else if(nr(n,!e.selection.empty),we&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=n.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}n.input.composing=!0}ha(n,Xf)},ae.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,ha(n,20))};function ha(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>nr(n),e))}function pa(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Zf());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Qf(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=ju(e.focusNode,e.focusOffset),r=Ku(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let s=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function Zf(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function nr(n,e=!1){if(!(ze&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),pa(n),e||n.docView&&n.docView.dirty){let t=Ws(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function eh(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const fn=de&&_e<15||It&&Gu<604;le.copy=ae.cut=(n,e)=>{let t=e,r=n.state.selection,s=t.type=="cut";if(r.empty)return;let i=fn?null:t.clipboardData,o=r.content(),{dom:l,text:a}=qs(n,o);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):eh(n,l),s&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function th(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function nh(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?hn(n,r.value,null,s,e):hn(n,r.textContent,r.innerHTML,s,e)},50)}function hn(n,e,t,r,s){let i=ra(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,s,i||w.empty)))return!0;if(!i)return!1;let o=th(i),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ma(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ae.paste=(n,e)=>{let t=e;if(n.composing&&!ze)return;let r=fn?null:t.clipboardData,s=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&hn(n,ma(r),r.getData("text/html"),s,t)?t.preventDefault():nh(n,t)};class ga{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const ya=ye?"altKey":"ctrlKey";le.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let s=n.state.selection,i=s.empty?null:n.posAtCoords(tr(t)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof x?s.to-1:s.to))){if(r&&r.mightDrag)o=x.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(o=x.create(n.state.doc,u.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:d}=qs(n,l);(!t.dataTransfer.files.length||!re||xl>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(fn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",fn||t.dataTransfer.setData("text/plain",c),n.dragging=new ga(d,!t[ya],o)},le.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},ae.dragover=ae.dragenter=(n,e)=>e.preventDefault(),ae.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let s=n.posAtCoords(tr(t));if(!s)return;let i=n.state.doc.resolve(s.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n)}):o=ra(n,ma(t.dataTransfer),fn?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&!t[ya]);if(n.someProp("handleDrop",p=>p(n,t,o||w.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?il(n.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,o.content.firstChild):c.replaceRange(d,d,o),c.doc.eq(f))return;let h=c.doc.resolve(d);if(u&&x.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new x(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,S)=>p=S),c.setSelection(Ks(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},le.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Fe(n)},20))},le.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},le.beforeinput=(n,e)=>{if(re&&ze&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,mt(8,"Backspace")))))return;let{$cursor:s}=n.state.selection;s&&s.pos>0&&n.dispatch(n.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let n in ae)le[n]=ae[n];function pn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class gs{constructor(e,t){this.toDOM=e,this.spec=t||bt,this.side=this.spec.side||0}map(e,t,r,s){let{pos:i,deleted:o}=e.mapResult(t.from+s,this.side<0?-1:1);return o?null:new X(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof gs&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&pn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ot{constructor(e,t){this.attrs=e,this.spec=t||bt}map(e,t,r,s){let i=e.map(t.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new X(i,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof ot&&pn(this.attrs,e.attrs)&&pn(this.spec,e.spec)}static is(e){return e.type instanceof ot}destroy(){}}class bo{constructor(e,t){this.attrs=e,this.spec=t||bt}map(e,t,r,s){let i=e.mapResult(t.from+s,1);if(i.deleted)return null;let o=e.mapResult(t.to+s,-1);return o.deleted||o.pos<=i.pos?null:new X(i.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:s}=e.content.findIndex(t.from),i;return s==t.from&&!(i=e.child(r)).isText&&s+i.nodeSize==t.to}eq(e){return this==e||e instanceof bo&&pn(this.attrs,e.attrs)&&pn(this.spec,e.spec)}destroy(){}}class X{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new X(e,t,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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new X(e,e,new gs(t,r))}static inline(e,t,r,s){return new X(e,t,new ot(r,s))}static node(e,t,r,s){return new X(e,t,new bo(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof ot}get widget(){return this.type instanceof gs}}const zt=[],bt={};class z{constructor(e,t){this.local=e.length?e:zt,this.children=t.length?t:zt}static create(e,t){return t.length?rr(t,e,0,bt):se}find(e,t,r){let s=[];return this.findInner(e??0,t??1e9,s,0,r),s}findInner(e,t,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,s+l,i)}}map(e,t,r){return this==se||e.maps.length==0?this:this.mapInner(e,t,0,0,r||bt)}mapInner(e,t,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(t,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?rh(this.children,o||[],e,t,r,s,i):o?new z(o.sort(kt),zt):se}add(e,t){return t.length?this==se?z.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,d;if(d=ka(t,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,d,c+1):s.splice(i,0,a,a+l.nodeSize,rr(d,l,c+1,bt)),i+=3}});let o=ba(i?Sa(t):t,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new z(o.length?this.local.concat(o).sort(kt):this.local,s||this.children)}remove(e){return e.length==0||this==se?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+t,a=r[i+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(o||(o=[])).push(u));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=se?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,t)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new z(s,r):se}forChild(e,t){if(this==se)return this;if(t.isLeaf)return z.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof ot){let c=Math.max(i,a.from)-i,d=Math.min(o,a.to)-i;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new z(s.sort(kt),zt);return r?new lt([l,r]):l}return r||se}eq(e){if(this==e)return!0;if(!(e instanceof z)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return ei(this.localsInner(e))}localsInner(e){if(this==se)return zt;if(e.inlineContent||!this.local.some(ot.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ot||t.push(this.local[r]);return t}forEachSet(e){e(this)}}z.empty=new z([],[]),z.removeOverlap=ei;const se=z.empty;class lt{constructor(e){this.members=e}map(e,t){const r=this.members.map(s=>s.map(e,t,bt));return lt.from(r)}forChild(e,t){if(t.isLeaf)return z.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,t);i!=se&&(i instanceof lt?r=r.concat(i.members):r.push(i))}return lt.from(r)}eq(e){if(!(e instanceof lt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let o=0;o<i.length;o++)t.push(i[o])}}return t?ei(r?t:t.sort(kt)):zt}static from(e){switch(e.length){case 0:return se;case 1:return e[0];default:return new lt(e.every(t=>t instanceof z)?e:e.reduce((t,r)=>t.concat(r instanceof z?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function rh(n,e,t,r,s,i,o){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let y=0;y<l.length;y+=3){let S=l[y+1];if(S<0||f>S+d-u)continue;let A=l[y]+d-u;h>=A?l[y+1]=f<=A?-2:-1:f>=d&&g&&(l[y]+=g,l[y+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+i),u=d-s;if(u<0||u>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+i,-1),h=f-s,{index:p,offset:m}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&m==u&&m+g.nodeSize==h){let y=l[c+2].mapInner(t,g,d+1,n[c]+i+1,o);y!=se?(l[c]=u,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=sh(l,n,e,t,s,i,o),d=rr(c,r,0,o);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new z(e.sort(kt),l)}function ba(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let s=n[r];t.push(new X(s.from+e,s.to+e,s.type))}return t}function sh(n,e,t,r,s,i,o){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,s,c);u?t.push(u):o.onRemove&&o.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function ka(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,s=null;for(let i=0,o;i<n.length;i++)(o=n[i])&&o.from>t&&o.to<r&&((s||(s=[])).push(o),n[i]=null);return s}function Sa(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function rr(n,e,t,r){let s=[],i=!1;e.forEach((l,a)=>{let c=ka(n,l,a+t);if(c){i=!0;let d=rr(c,l,t+a+1,r);d!=se&&s.push(a,a+l.nodeSize,d)}});let o=ba(i?Sa(n):n,-t).sort(kt);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new z(o,s):se}function kt(n,e){return n.from-e.from||n.to-e.to}function ei(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let s=t+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[s]=i.copy(i.from,r.to),wa(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),wa(e,s,r.copy(i.from,r.to)));break}}}return e}function wa(n,e,t){for(;e<n.length&&kt(t,n[e])>0;)e++;n.splice(e,0,t)}function ti(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=se&&e.push(r)}),n.cursorWrapper&&e.push(z.create(n.state.doc,[n.cursorWrapper.deco])),lt.from(e)}const ih={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},oh=de&&_e<=11;class lh{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class ah{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new lh,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);de&&_e<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),oh&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,ih)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Gl(this.view)){if(this.suppressingSelectionUpdates)return Fe(this.view);if(de&&_e<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&pt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=sn(i))t.add(i);for(let i=e.anchorNode;i;i=sn(i))if(t.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Gl(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(i=i<0?u.from:Math.min(u.from,i),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(l=!0))}if(we&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||uh(e,u)!=h)&&f.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Qn(r)&&(c=Ws(e))&&c.eq(E.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Fe(e),this.currentSelection.set(r)):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),ch(e)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Fe(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(de&&_e<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let o=s&&s.parentNode==e.target?ee(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?ee(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Ca=new WeakMap,xa=!1;function ch(n){if(!Ca.has(n)&&(Ca.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=we,xa)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."),xa=!0}}function Ma(n,e){let t=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return pt(o.node,o.offset,s,i)&&([t,r,s,i]=[s,i,t,r]),{anchorNode:t,anchorOffset:r,focusNode:s,focusOffset:i}}function dh(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return Ma(n,s)}let t;function r(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Ma(n,t):null}function uh(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function fh(n,e,t){let{node:r,fromOffset:s,toOffset:i,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],Qn(a)||c.push({node:a.focusNode,offset:a.focusOffset})),re&&n.input.lastKeyCode===8)for(let g=i;g>s;g--){let y=r.childNodes[g-1],S=y.pmViewDesc;if(y.nodeName=="BR"&&!S){i=g;break}if(!S||S.size)break}let u=n.state.doc,f=n.someProp("domParser")||Ue.fromSchema(n.state.schema),h=u.resolve(o),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:s,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:hh,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+o,head:y+o}}return{doc:m,sel:p,from:o,to:l}}function hh(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(oe&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||oe&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const ph=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function mh(n,e,t,r,s){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let D=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,me=Ws(n,D);if(me&&!n.state.selection.eq(me)){if(re&&ze&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Xt=>Xt(n,mt(13,"Enter"))))return;let ut=n.state.tr.setSelection(me);D=="pointer"?ut.setMeta("pointer",!0):D=="key"&&ut.scrollIntoView(),i&&ut.setMeta("composition",i),n.dispatch(ut)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=fh(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=bh(u.content,c.doc.content,c.from,f,h);if(p&&n.input.domChangeCount++,(It&&n.input.lastIOSEnter>Date.now()-225||ze)&&s.some(D=>D.nodeType==1&&!ph.test(D.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",D=>D(n,mt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof T&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let D=Ta(n,n.state.doc,c.sel);if(D&&!D.eq(n.state.selection)){let me=n.state.tr.setSelection(D);i&&me.setMeta("composition",i),n.dispatch(me)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof T&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),de&&_e<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=d.resolve(p.start),S=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA,A;if((It&&n.input.lastIOSEnter>Date.now()-225&&(!S||s.some(D=>D.nodeName=="DIV"||D.nodeName=="P"))||!S&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(A=E.findFrom(c.doc.resolve(m.pos+1),1,!0))&&A.head==g.pos)&&n.someProp("handleKeyDown",D=>D(n,mt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&yh(d,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",D=>D(n,mt(8,"Backspace")))){ze&&re&&n.domObserver.suppressSelectionUpdates();return}re&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),ze&&!S&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(D){return D(n,mt(13,"Enter"))})},20));let R=p.start,M=p.endA,v,V,U;if(S){if(m.pos==g.pos)de&&_e<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Fe(n),20)),v=n.state.tr.delete(R,M),V=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(U=gh(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))v=n.state.tr,U.type=="add"?v.addMark(R,M,U.mark):v.removeMark(R,M,U.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let D=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",me=>me(n,R,M,D)))return;v=n.state.tr.insertText(D,R,M)}}if(v||(v=n.state.tr.replace(R,M,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let D=Ta(n,v.doc,c.sel);D&&!(re&&n.composing&&D.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(D.head==R||D.head==v.mapping.map(M)-1)||de&&D.empty&&D.head==R)&&v.setSelection(D)}V&&v.ensureMarks(V),i&&v.setMeta("composition",i),n.dispatch(v.scrollIntoView())}function Ta(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Ks(n,e.resolve(t.anchor),e.resolve(t.head))}function gh(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,s=t,i=r,o,l,a;for(let d=0;d<r.length;d++)s=r[d].removeFromSet(s);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(b.from(c).eq(n))return{mark:l,type:o}}function yh(n,e,t,r,s){if(t-e<=s.pos-r.pos||ni(r,!0,!1)<s.pos)return!1;let i=n.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=n.resolve(ni(i,!0,!0));return!o.parent.isTextblock||o.pos>t||ni(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function ni(n,e,t){let r=n.depth,s=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,s++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function bh(n,e,t,r,s){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(o,l));r-=o+a-i}if(o<i&&n.size<e.size){let a=r<=i&&r>=o?i-r:0;i-=a,i&&i<e.size&&Aa(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-o),o=i}else if(l<i){let a=r<=i&&r>=l?i-r:0;i-=a,i&&i<n.size&&Aa(n.textBetween(i-1,i+1))&&(i+=a?1:-1),o=i+(o-l),l=i}return{start:i,endA:o,endB:l}}function Aa(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class kh{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 Hf,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ra),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Na(this),Oa(this),this.nodeViews=va(this),this.docView=zl(this.state.doc,Ea(this),ti(this),this.dom,this),this.domObserver=new ah(this,(r,s,i,o)=>mh(this,r,s,i,o)),this.domObserver.start(),Ff(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(Ra),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(pa(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=va(this);wh(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ys(this),this.editable=Na(this),Oa(this);let a=ti(this),c=Ea(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(o=!0);let f=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Qu(this);if(o){this.domObserver.stop();let h=u&&(de||re)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Sh(s.selection,e.selection);if(u){let p=re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Qf(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=zl(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&xf(this))?Fe(this,h):(ql(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&Zu(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof x){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Ml(this,t.getBoundingClientRect(),e)}else Ml(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 t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new ga(e.slice,e.move,s<0?void 0:x.create(this.state.doc,s))}someProp(e,t){let r=this._props&&this._props[e],s;if(r!=null&&(s=t?t(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=t?t(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=t?t(l):l))return s}}hasFocus(){if(de){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&ef(this.dom),Fe(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return of(this,e)}coordsAtPos(e,t=1){return vl(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,r=-1){let s=this.docView.posFromDOM(e,t,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,t){return uf(this,t||this.state,e)}pasteHTML(e,t){return hn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return hn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return qs(this,e)}destroy(){this.docView&&($f(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ti(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Vu())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Wf(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?oe&&this.root.nodeType===11&&Ju(this.dom.ownerDocument)==this.dom&&dh(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ea(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[X.node(0,n.state.doc.content.size,e)]}function Oa(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:X.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Na(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Sh(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function va(n){let e=Object.create(null);function t(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function wh(n,e){let t=0,r=0;for(let s in n){if(n[s]!=e[s])return!0;t++}for(let s in e)r++;return t!=r}function Ra(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var Qe={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:"'"},sr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ch=typeof navigator<"u"&&/Mac/.test(navigator.platform),xh=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),te=0;te<10;te++)Qe[48+te]=Qe[96+te]=String(te);for(var te=1;te<=24;te++)Qe[te+111]="F"+te;for(var te=65;te<=90;te++)Qe[te]=String.fromCharCode(te+32),sr[te]=String.fromCharCode(te);for(var ri in Qe)sr.hasOwnProperty(ri)||(sr[ri]=Qe[ri]);function Mh(n){var e=Ch&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||xh&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?sr:Qe)[n.keyCode]||n.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}const Th=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Ah(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Th?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),s&&(t="Ctrl-"+t),o&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function Eh(n){let e=Object.create(null);for(let t in n)e[Ah(t)]=n[t];return e}function si(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Oh(n){return new H({props:{handleKeyDown:ii(n)}})}function ii(n){let e=Eh(n);return function(t,r){let s=Mh(r),i,o=e[si(s,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[si(s,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||s.charCodeAt(0)>127)&&(i=Qe[r.keyCode])&&i!=s){let l=e[si(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const oi=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Da(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Ia=(n,e,t)=>{let r=Da(n,t);if(!r)return!1;let s=li(r);if(!s){let o=r.blockRange(),l=o&&vt(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(Wa(n,s,e,-1))return!0;if(r.parent.content.size==0&&(Ht(i,"end")||x.isSelectable(i)))for(let o=r.depth;;o--){let l=Xn(n.doc,r.before(o),r.after(o),w.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Ht(i,"end")?E.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):x.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},Nh=(n,e,t)=>{let r=Da(n,t);if(!r)return!1;let s=li(r);return s?La(n,s,e):!1},vh=(n,e,t)=>{let r=Ba(n,t);if(!r)return!1;let s=ai(r);return s?La(n,s,e):!1};function La(n,e,t){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=d}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=Xn(n.doc,i,a,w.empty);if(!c||c.from!=i||c instanceof Q&&c.slice.size>=a-i)return!1;if(t){let d=n.tr.step(c);d.setSelection(T.create(d.doc,i)),t(d.scrollIntoView())}return!0}function Ht(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Pa=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=li(r)}let o=i&&i.nodeBefore;return!o||!x.isSelectable(o)?!1:(e&&e(n.tr.setSelection(x.create(n.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function li(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Ba(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const za=(n,e,t)=>{let r=Ba(n,t);if(!r)return!1;let s=ai(r);if(!s)return!1;let i=s.nodeAfter;if(Wa(n,s,e,1))return!0;if(r.parent.content.size==0&&(Ht(i,"start")||x.isSelectable(i))){let o=Xn(n.doc,r.before(),r.after(),w.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(Ht(i,"start")?E.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):x.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(n.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},Ha=(n,e,t)=>{let{$head:r,empty:s}=n.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=ai(r)}let o=i&&i.nodeAfter;return!o||!x.isSelectable(o)?!1:(e&&e(n.tr.setSelection(x.create(n.doc,i.pos)).scrollIntoView()),!0)};function ai(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Rh=(n,e)=>{let t=n.selection,r=t instanceof x,s;if(r){if(t.node.isTextblock||!Je(n.doc,t.from))return!1;s=t.from}else if(s=Yn(n.doc,t.from,-1),s==null)return!1;if(e){let i=n.tr.join(s);r&&i.setSelection(x.create(i.doc,s-n.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},Dh=(n,e)=>{let t=n.selection,r;if(t instanceof x){if(t.node.isTextblock||!Je(n.doc,t.to))return!1;r=t.to}else if(r=Yn(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Ih=(n,e)=>{let{$from:t,$to:r}=n.selection,s=t.blockRange(r),i=s&&vt(s);return i==null?!1:(e&&e(n.tr.lift(s,i).scrollIntoView()),!0)},Fa=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
10
+ `).scrollIntoView()),!0)};function ci(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Lh=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let s=t.node(-1),i=t.indexAfter(-1),o=ci(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(E.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},$a=(n,e)=>{let t=n.selection,{$from:r,$to:s}=t;if(t instanceof fe||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=ci(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=n.tr.insert(o,i.createAndFill());l.setSelection(T.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Va=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(Pe(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),s=r&&vt(r);return s==null?!1:(e&&e(n.tr.lift(r,s).scrollIntoView()),!0)};function Ph(n){return(e,t)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof x&&e.selection.node.isBlock)return!r.parentOffset||!Pe(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=ci(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),i.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof T||e.selection instanceof fe)&&d.deleteSelection();let u=d.mapping.map(r.pos),f=Pe(d.doc,u,i.length,i);if(f||(i[0]=l?{type:l}:null,f=Pe(d.doc,u,i.length,i)),d.split(u,i.length,i),!a&&c&&r.node(o).type!=l){let h=d.mapping.map(r.before(o)),p=d.doc.resolve(h);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return t&&t(d.scrollIntoView()),!0}}const Bh=Ph(),zh=(n,e)=>{let{$from:t,to:r}=n.selection,s,i=t.sharedDepth(r);return i==0?!1:(s=t.before(i),e&&e(n.tr.setSelection(x.create(n.doc,s))),!0)};function Hh(n,e,t){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||Je(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Wa(n,e,t,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&Hh(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(t){let h=e.pos+i.nodeSize,p=b.empty;for(let y=o.length-1;y>=0;y--)p=b.from(o[y].create(null,p));p=b.from(s.copy(p));let m=n.tr.step(new Y(e.pos-1,h,e.pos,h,new w(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==s.type&&Je(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&a?null:E.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&vt(u);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(u,f).scrollIntoView()),!0;if(c&&Ht(i,"start",!0)&&Ht(s,"end")){let h=s,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let y=b.empty;for(let A=p.length-1;A>=0;A--)y=b.from(p[A].copy(y));let S=n.tr.step(new Y(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new w(y,p.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function ja(n){return function(e,t){let r=e.selection,s=n<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(t&&t(e.tr.setSelection(T.create(e.doc,n<0?s.start(i):s.end(i)))),!0):!1}}const Fh=ja(-1),$h=ja(1);function Vh(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i),l=o&&Es(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Ka(n,e=null){return function(t,r){let s=!1;for(let i=0;i<t.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(o,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)s=!0;else{let d=t.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,n)}})}if(!s)return!1;if(r){let i=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];i.setBlockType(l,a,n,e)}r(i.scrollIntoView())}return!0}}function di(...n){return function(e,t,r){for(let s=0;s<n.length;s++)if(n[s](e,t,r))return!0;return!1}}di(oi,Ia,Pa),di(oi,za,Ha),di(Fa,$a,Va,Bh),typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Wh(n,e=null){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i),l=!1,a=o;if(!o)return!1;if(o.depth>=2&&s.node(o.depth-1).type.compatibleContent(n)&&o.startIndex==0){if(s.index(o.depth-1)==0)return!1;let d=t.doc.resolve(o.start-2);a=new Un(d,d,o.depth),o.endIndex<o.parent.childCount&&(o=new Un(s,t.doc.resolve(i.end(o.depth)),o.depth)),l=!0}let c=Es(a,n,e,o);return c?(r&&r(jh(t.tr,o,c,l,n).scrollIntoView()),!0):!1}}function jh(n,e,t,r,s){let i=b.empty;for(let d=t.length-1;d>=0;d--)i=b.from(t[d].type.create(t[d].attrs,i));n.step(new Y(e.start-(r?2:0),e.end,e.start,e.end,new w(i,0,0),t.length,!0));let o=0;for(let d=0;d<t.length;d++)t[d].type==s&&(o=d+1);let l=t.length-o,a=e.start+t.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,f=!0;d<u;d++,f=!1)!f&&Pe(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function Kh(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==n);return i?t?r.node(i.depth-1).type==n?Uh(e,t,n,i):Jh(e,t,i):!0:!1}}function Uh(n,e,t,r){let s=n.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new Y(i-1,o,i,o,new w(b.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Un(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const l=vt(r);if(l==null)return!1;s.lift(r,l);let a=s.mapping.map(i,-1)-1;return Je(s.doc,a)&&s.join(a),e(s.scrollIntoView()),!0}function Jh(n,e,t){let r=n.tr,s=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=s.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(t.start),o=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==s.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,o.content.append(a?b.empty:b.from(s))))return!1;let u=i.pos,f=u+o.nodeSize;return r.step(new Y(u-(l?1:0),f+(a?1:0),u+1,f-1,new w((l?b.empty:b.from(s.copy(b.empty))).append(a?b.empty:b.from(s.copy(b.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function qh(n){return function(e,t){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=b.from(c?n.create():null),u=new w(b.from(n.create(null,b.from(l.type.create(null,d)))),c?3:1,0),f=i.start,h=i.end;t(e.tr.step(new Y(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}function mn(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:s}=t,{storedMarks:i}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=t.selection,s=t.doc,i=t.storedMarks,t}}}class gn{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:s}=t,{tr:i}=r,o=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...d)=>{const u=a(...d)(o);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l=[],a=!!e,c=e||i.tr,d=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{const g=this.buildProps(c,t),y=h(...m)(g);return l.push(y),u}])),run:d};return u}createCan(e){const{rawCommands:t,state:r}=this,s=!1,i=e||r.tr,o=this.buildProps(i,s);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...d)=>c(...d)({...o,dispatch:void 0})])),chain:()=>this.createChain(i,s)}}buildProps(e,t=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,l={tr:e,editor:s,view:o,state:mn({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...d)=>c(...d)(l)]))}};return l}}class _h{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(s=>s.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(s=>s!==t):delete this.callbacks[e]),this}once(e,t){const r=(...s)=>{this.off(e,r),t.apply(this,s)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function C(n,e,t){return n.config[e]===void 0&&n.parent?C(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?C(n.parent,e,t):null}):n.config[e]}function yn(n){const e=n.filter(s=>s.type==="extension"),t=n.filter(s=>s.type==="node"),r=n.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function ui(n){const e=[],{nodeExtensions:t,markExtensions:r}=yn(n),s=[...t,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:s},a=C(o,"addGlobalAttributes",l);if(!a)return;a().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([f,h])=>{e.push({type:u,name:f,attribute:{...i,...h}})})})})}),s.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=C(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([d,u])=>{const f={...i,...u};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:o.name,name:d,attribute:f})})}),e}function _(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function I(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?String(i).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(d=>!a.includes(d));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=i?i.split(";").map(d=>d.trim()).filter(Boolean):[],a=r[s]?r[s].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;a.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),l.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),r[s]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[s]=i}),r},{})}function ir(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>I(t,r),{})}function fi(n){return typeof n=="function"}function O(n,e=void 0,...t){return fi(n)?e?n.bind(e)(...t):n(...t):n}function Ua(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Ja(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function hi(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):Ja(t.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function qa(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Ua(t)?!1:t!=null))}function pi(n,e){var t;const r=ui(n),{nodeExtensions:s,markExtensions:i}=yn(n),o=(t=s.find(c=>C(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(s.map(c=>{const d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((y,S)=>{const A=C(S,"extendNodeSchema",u);return{...y,...A?A(c):{}}},{}),h=qa({...f,content:O(C(c,"content",u)),marks:O(C(c,"marks",u)),group:O(C(c,"group",u)),inline:O(C(c,"inline",u)),atom:O(C(c,"atom",u)),selectable:O(C(c,"selectable",u)),draggable:O(C(c,"draggable",u)),code:O(C(c,"code",u)),whitespace:O(C(c,"whitespace",u)),linebreakReplacement:O(C(c,"linebreakReplacement",u)),defining:O(C(c,"defining",u)),isolating:O(C(c,"isolating",u)),attrs:Object.fromEntries(d.map(y=>{var S;return[y.name,{default:(S=y?.attribute)===null||S===void 0?void 0:S.default}]}))}),p=O(C(c,"parseHTML",u));p&&(h.parseDOM=p.map(y=>hi(y,d)));const m=C(c,"renderHTML",u);m&&(h.toDOM=y=>m({node:y,HTMLAttributes:ir(y,d)}));const g=C(c,"renderText",u);return g&&(h.toText=g),[c.name,h]})),a=Object.fromEntries(i.map(c=>{const d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((g,y)=>{const S=C(y,"extendMarkSchema",u);return{...g,...S?S(c):{}}},{}),h=qa({...f,inclusive:O(C(c,"inclusive",u)),excludes:O(C(c,"excludes",u)),group:O(C(c,"group",u)),spanning:O(C(c,"spanning",u)),code:O(C(c,"code",u)),attrs:Object.fromEntries(d.map(g=>{var y;return[g.name,{default:(y=g?.attribute)===null||y===void 0?void 0:y.default}]}))}),p=O(C(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>hi(g,d)));const m=C(c,"renderHTML",u);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:ir(g,d)})),[c.name,h]}));return new Fo({topNode:o,nodes:l,marks:a})}function or(n,e){return e.nodes[n]||e.marks[n]||null}function mi(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function bn(n,e){const t=At.fromSchema(e).serializeFragment(n),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(t),s.innerHTML}const _a=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;const d=((c=(a=s.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";t+=s.isAtom&&!s.isText?d:d.slice(0,Math.max(0,r-i))}),t};function lr(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class Ft{constructor(e){this.find=e.find,this.handler=e.handler}}const Gh=(n,e)=>{if(lr(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function ar(n){var e;const{editor:t,from:r,to:s,text:i,rules:o,plugin:l}=n,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1;const u=_a(c)+i;return o.forEach(f=>{if(d)return;const h=Gh(u,f.find);if(!h)return;const p=a.state.tr,m=mn({state:a.state,transaction:p}),g={from:r-(h[0].length-i.length),to:s},{commands:y,chain:S,can:A}=new gn({editor:t,state:m});f.handler({state:m,range:g,match:h,commands:y,chain:S,can:A})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:r,to:s,text:i}),a.dispatch(p),d=!0)}),d}function Ga(n){const{editor:e,rules:t}=n,r=new H({state:{init(){return null},apply(s,i,o){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=bn(b.from(d),o.schema);const{from:u}=a,f=u+d.length;ar({editor:e,from:u,to:f,text:d,rules:t,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return ar({editor:e,from:i,to:o,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&ar({editor:e,from:i.pos,to:i.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?ar({editor:e,from:o.pos,to:o.pos,text:`
11
+ `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function Yh(n){return Object.prototype.toString.call(n).slice(8,-1)}function kn(n){return Yh(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Sn(n,e){const t={...n};return kn(n)&&kn(e)&&Object.keys(e).forEach(r=>{kn(e[r])&&kn(n[r])?t[r]=Sn(n[r],e[r]):t[r]=e[r]}),t}class ce{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=O(C(this,"addOptions",{name:this.name}))),this.storage=O(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new ce(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Sn(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new ce(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=O(C(t,"addOptions",{name:t.name})),t.storage=O(C(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>c?.type.name===t.name))return!1;const a=o.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}}function Ya(n){return typeof n=="number"}class cr{constructor(e){this.find=e.find,this.handler=e.handler}}const Xh=(n,e,t)=>{if(lr(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=n,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function Qh(n){const{editor:e,state:t,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=n,{commands:a,chain:c,can:d}=new gn({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,s,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;const m=Math.max(r,p),g=Math.min(s,p+h.content.size),y=h.textBetween(m-p,g-p,void 0,"\uFFFC");Xh(y,i.find,o).forEach(A=>{if(A.index===void 0)return;const R=m+A.index+1,M=R+A[0].length,v={from:t.tr.mapping.map(R),to:t.tr.mapping.map(M)},V=i.handler({state:t,range:v,match:A,commands:a,chain:c,can:d,pasteEvent:o,dropEvent:l});u.push(V)})}),u.every(h=>h!==null)}let dr=null;const Zh=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function Xa(n){const{editor:e,rules:t}=n;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:d,from:u,to:f,rule:h,pasteEvt:p})=>{const m=d.tr,g=mn({state:d,transaction:m});if(!(!Qh({editor:e,state:g,from:Math.max(u-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return t.map(d=>new H({view(u){const f=p=>{var m;r=!((m=u.dom.parentElement)===null||m===void 0)&&m.contains(p.target)?u.dom.parentElement:null,r&&(dr=e)},h=()=>{dr&&(dr=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(i=r===u.dom.parentElement,l=f,!i){const h=dr;h&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,f)=>{var h;const p=(h=f.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return o=f,s=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(u,f,h)=>{const p=u[0],m=p.getMeta("uiEvent")==="paste"&&!s,g=p.getMeta("uiEvent")==="drop"&&!i,y=p.getMeta("applyPasteRules"),S=!!y;if(!m&&!g&&!S)return;if(S){let{text:M}=y;typeof M=="string"?M=M:M=bn(b.from(M),h.schema);const{from:v}=y,V=v+M.length,U=Zh(M);return a({rule:d,state:h,from:v,to:{b:V},pasteEvt:U})}const A=f.doc.content.findDiffStart(h.doc.content),R=f.doc.content.findDiffEnd(h.doc.content);if(!(!Ya(A)||!R||A===R.b))return a({rule:d,state:h,from:A,to:R,pasteEvt:o})}}))}function Qa(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}class Ot{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=Ot.resolve(e),this.schema=pi(this.extensions,t),this.setupExtensions()}static resolve(e){const t=Ot.sort(Ot.flatten(e)),r=Qa(t.map(s=>s.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},s=C(t,"addExtensions",r);return s?[t,...this.flatten(s())]:t}).flat(10)}static sort(e){return e.sort((r,s)=>{const i=C(r,"priority")||100,o=C(s,"priority")||100;return i>o?-1:i<o?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:or(t.name,this.schema)},s=C(t,"addCommands",r);return s?{...e,...s()}:e},{})}get plugins(){const{editor:e}=this,t=Ot.sort([...this.extensions].reverse()),r=[],s=[],i=t.map(o=>{const l={name:o.name,options:o.options,storage:o.storage,editor:e,type:or(o.name,this.schema)},a=[],c=C(o,"addKeyboardShortcuts",l);let d={};if(o.type==="mark"&&C(o,"exitable",l)&&(d.ArrowRight=()=>ce.handleExit({editor:e,mark:o})),c){const m=Object.fromEntries(Object.entries(c()).map(([g,y])=>[g,()=>y({editor:e})]));d={...d,...m}}const u=Oh(d);a.push(u);const f=C(o,"addInputRules",l);mi(o,e.options.enableInputRules)&&f&&r.push(...f());const h=C(o,"addPasteRules",l);mi(o,e.options.enablePasteRules)&&h&&s.push(...h());const p=C(o,"addProseMirrorPlugins",l);if(p){const m=p();a.push(...m)}return a}).flat();return[Ga({editor:e,rules:r}),...Xa({editor:e,rules:s}),...i]}get attributes(){return ui(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=yn(this.extensions);return Object.fromEntries(t.filter(r=>!!C(r,"addNodeView")).map(r=>{const s=this.attributes.filter(a=>a.type===r.name),i={name:r.name,options:r.options,storage:r.storage,editor:e,type:_(r.name,this.schema)},o=C(r,"addNodeView",i);if(!o)return[];const l=(a,c,d,u,f)=>{const h=ir(a,s);return o()({node:a,view:c,getPos:d,decorations:u,innerDecorations:f,editor:e,extension:r,HTMLAttributes:h})};return[r.name,l]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:or(e.name,this.schema)};e.type==="mark"&&(!((t=O(C(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const s=C(e,"onBeforeCreate",r),i=C(e,"onCreate",r),o=C(e,"onUpdate",r),l=C(e,"onSelectionUpdate",r),a=C(e,"onTransaction",r),c=C(e,"onFocus",r),d=C(e,"onBlur",r),u=C(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}}class W{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=O(C(this,"addOptions",{name:this.name}))),this.storage=O(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new W(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Sn(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new W({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=O(C(t,"addOptions",{name:t.name})),t.storage=O(C(t,"addStorage",{name:t.name,options:t.options})),t}}function gi(n,e,t){const{from:r,to:s}=e,{blockSeparator:i=`
12
12
 
13
- `,textSerializers:o={}}=t||{};let l="";return n.nodesBetween(r,s,(a,c,d,u)=>{var f;a.isBlock&&c>r&&(l+=i);const h=o?.[a.type.name];if(h)return d&&(l+=h({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(f=a?.text)===null||f===void 0?void 0:f.slice(Math.max(r,c)-c,s-c))}),l}function ur(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Qa=W.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new H({key:new q("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos)),a=ur(t);return mi(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Qh=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Zh=(n=!1)=>({commands:e})=>e.setContent("",n),ep=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:s}=r;return t&&s.forEach(({$from:i,$to:o})=>{n.doc.nodesBetween(i.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),h=u.blockRange(f);if(!h)return;const p=vt(h);if(l.type.isTextblock){const{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},tp=n=>e=>n(e),np=()=>({state:n,dispatch:e})=>Fa(n,e),rp=(n,e)=>({editor:t,tr:r})=>{const{state:s}=t,i=s.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new T(r.doc.resolve(o-1))),!0},sp=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const s=n.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),a=s.after(i);n.delete(l,a).scrollIntoView()}return!0}return!1},ip=n=>({tr:e,state:t,dispatch:r})=>{const s=_(n,t.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const a=i.before(o),c=i.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},op=n=>({tr:e,dispatch:t})=>{const{from:r,to:s}=n;return t&&e.delete(r,s),!0},lp=()=>({state:n,dispatch:e})=>ii(n,e),ap=()=>({commands:n})=>n.keyboardShortcut("Enter"),cp=()=>({state:n,dispatch:e})=>Dh(n,e);function wn(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>t.strict?e[s]===n[s]:lr(e[s])?e[s].test(n[s]):e[s]===n[s]):!0}function Za(n,e,t={}){return n.find(r=>r.type===e&&wn(Object.fromEntries(Object.keys(t).map(s=>[s,r.attrs[s]])),t))}function ec(n,e,t={}){return!!Za(n,e,t)}function fr(n,e,t){var r;if(!n||!e)return;let s=n.parent.childAfter(n.parentOffset);if((!s.node||!s.node.marks.some(d=>d.type===e))&&(s=n.parent.childBefore(n.parentOffset)),!s.node||!s.node.marks.some(d=>d.type===e)||(t=t||((r=s.node.marks[0])===null||r===void 0?void 0:r.attrs),!Za([...s.node.marks],e,t)))return;let o=s.index,l=n.start()+s.offset,a=o+1,c=l+s.node.nodeSize;for(;o>0&&ec([...n.parent.child(o-1).marks],e,t);)o-=1,l-=n.parent.child(o).nodeSize;for(;a<n.parent.childCount&&ec([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function $e(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const dp=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const i=$e(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:d}=l;if(s){const u=fr(a,i,e);if(u&&u.from<=c&&u.to>=d){const f=T.create(o,u.from,u.to);t.setSelection(f)}}return!0},up=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function gi(n){return n instanceof T}function Oe(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function yi(n,e=null){if(!e)return null;const t=E.atStart(n),r=E.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const s=t.from,i=r.to;return e==="all"?T.create(n,Oe(0,s,i),Oe(n.content.size,s,i)):T.create(n,Oe(e,s,i),Oe(e,s,i))}function tc(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Cn(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const fp=(n=null,e={})=>({editor:t,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(Cn()||tc())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(i&&n===null&&!gi(t.state.selection))return o(),!0;const l=yi(s.doc,n)||t.state.selection,a=t.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},hp=(n,e)=>t=>n.every((r,s)=>e(r,{...t,index:s})),pp=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),nc=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&nc(r)}return n};function $t(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return nc(t)}function xn(n,e,t){if(n instanceof Te||n instanceof b)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,s=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return b.fromArray(n.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(i){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",i),xn("",e,t)}if(s){if(t.errorOnInvalidContent){let o=!1,l="";const a=new Ho({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Ue.fromSchema(a).parseSlice($t(n),t.parseOptions):Ue.fromSchema(a).parse($t(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=Ue.fromSchema(e);return t.slice?i.parseSlice($t(n),t.parseOptions).content:i.parse($t(n),t.parseOptions)}return xn("",e,t)}function rc(n,e,t){const r=n.steps.length-1;if(r<e)return;const s=n.steps[r];if(!(s instanceof Q||s instanceof Y))return;const i=n.mapping.maps[r];let o=0;i.forEach((l,a,c,d)=>{o===0&&(o=d)}),n.setSelection(E.near(n.doc.resolve(o),t))}const mp=n=>!("type"in n),gp=(n,e,t)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){t={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;try{l=xn(e,i.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions},errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:i.options.enableContentCheck})}catch(p){return i.emit("contentError",{editor:i,error:p,disableCollaboration:()=>{i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}}),!1}let{from:a,to:c}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},d=!0,u=!0;if((mp(l)?l:[l]).forEach(p=>{p.check(),d=d?p.isText&&p.marks.length===0:!1,u=u?p.isBlock:!1}),a===c&&u){const{parent:p}=r.doc.resolve(a);p.isTextblock&&!p.type.spec.code&&!p.childCount&&(a-=1,c+=1)}let h;if(d){if(Array.isArray(e))h=e.map(p=>p.text||"").join("");else if(e instanceof b){let p="";e.forEach(m=>{m.text&&(p+=m.text)}),h=p}else typeof e=="object"&&e&&e.text?h=e.text:h=e;r.insertText(h,a,c)}else h=l,r.replaceWith(a,c,h);t.updateSelection&&rc(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:a,text:h}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:a,text:h})}return!0},yp=()=>({state:n,dispatch:e})=>Nh(n,e),bp=()=>({state:n,dispatch:e})=>vh(n,e),kp=()=>({state:n,dispatch:e})=>Da(n,e),Sp=()=>({state:n,dispatch:e})=>Ba(n,e),wp=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Yn(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Cp=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Yn(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},xp=()=>({state:n,dispatch:e})=>Eh(n,e),Mp=()=>({state:n,dispatch:e})=>Oh(n,e);function bi(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Tp(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Cn()||bi()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),s&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),i&&(t=`Shift-${t}`),t}const Ap=n=>({editor:e,view:t,tr:r,dispatch:s})=>{const i=Tp(n).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{const d=c.map(r.mapping);d&&s&&r.maybeStep(d)}),!0};function Vt(n,e,t={}){const{from:r,to:s,empty:i}=n.selection,o=e?_(e,n.schema):null,l=[];n.doc.nodesBetween(r,s,(u,f)=>{if(u.isText)return;const h=Math.max(r,f),p=Math.min(s,f+u.nodeSize);l.push({node:u,from:h,to:p})});const a=s-r,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>wn(u.node.attrs,t,{strict:!1}));return i?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}const Ep=(n,e={})=>({state:t,dispatch:r})=>{const s=_(n,t.schema);return Vt(t,s,e)?Rh(t,r):!1},Op=()=>({state:n,dispatch:e})=>$a(n,e),Np=n=>({state:e,dispatch:t})=>{const r=_(n,e.schema);return Wh(r)(e,t)},vp=()=>({state:n,dispatch:e})=>Ha(n,e);function Mn(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function ki(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,s)=>(t.includes(s)||(r[s]=n[s]),r),{})}const Rp=(n,e)=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const l=Mn(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=_(n,r.schema)),l==="mark"&&(o=$e(n,r.schema)),s&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,d)=>{i&&i===c.type&&t.setNodeMarkup(d,void 0,ki(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&t.addMark(d,d+c.nodeSize,o.create(ki(u.attrs,e)))})})}),!0):!1},Dp=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Ip=()=>({tr:n,dispatch:e})=>{if(e){const t=new fe(n.doc);n.setSelection(t)}return!0},Lp=()=>({state:n,dispatch:e})=>La(n,e),Pp=()=>({state:n,dispatch:e})=>za(n,e),Bp=()=>({state:n,dispatch:e})=>Ph(n,e),zp=()=>({state:n,dispatch:e})=>Hh(n,e),Hp=()=>({state:n,dispatch:e})=>zh(n,e);function hr(n,e,t={},r={}){return xn(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const Fp=(n,e=!1,t={},r={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{var a,c;const{doc:d}=i;if(t.preserveWhitespace!=="full"){const u=hr(n,s.schema,t,{errorOnInvalidContent:(a=r.errorOnInvalidContent)!==null&&a!==void 0?a:s.options.enableContentCheck});return o&&i.replaceWith(0,d.content.size,u).setMeta("preventUpdate",!e),!0}return o&&i.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:d.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:s.options.enableContentCheck})};function Si(n,e){const t=$e(e,n.schema),{from:r,to:s,empty:i}=n.selection,o=[];i?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function sc(n,e){const t=new Ns(n);return e.forEach(r=>{r.steps.forEach(s=>{t.step(s)})}),t}function ic(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function $p(n,e){const t=[];return n.descendants((r,s)=>{e(r)&&t.push({node:r,pos:s})}),t}function oc(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(s,i)=>{t(s)&&r.push({node:s,pos:i})}),r}function wi(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Wt(n){return e=>wi(e.$from,n)}function pr(n,e){const t=Ot.resolve(n);return hi(t,e)}function Vp(n,e){const t=pr(e),r=Te.fromJSON(t,n);return bn(r.content,t)}function Wp(n,e){const t=pr(e),r=$t(n);return Ue.fromSchema(t).parse(r).toJSON()}function Ci(n,e){const t={from:0,to:n.content.size};return mi(n,t,e)}function jp(n,e,t){const{blockSeparator:r=`
13
+ `,textSerializers:o={}}=t||{};let l="";return n.nodesBetween(r,s,(a,c,d,u)=>{var f;a.isBlock&&c>r&&(l+=i);const h=o?.[a.type.name];if(h)return d&&(l+=h({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(f=a?.text)===null||f===void 0?void 0:f.slice(Math.max(r,c)-c,s-c))}),l}function ur(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Za=W.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new H({key:new q("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos)),a=ur(t);return gi(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),ep=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),tp=(n=!1)=>({commands:e})=>e.setContent("",n),np=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:s}=r;return t&&s.forEach(({$from:i,$to:o})=>{n.doc.nodesBetween(i.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),h=u.blockRange(f);if(!h)return;const p=vt(h);if(l.type.isTextblock){const{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},rp=n=>e=>n(e),sp=()=>({state:n,dispatch:e})=>$a(n,e),ip=(n,e)=>({editor:t,tr:r})=>{const{state:s}=t,i=s.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new T(r.doc.resolve(o-1))),!0},op=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const s=n.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),a=s.after(i);n.delete(l,a).scrollIntoView()}return!0}return!1},lp=n=>({tr:e,state:t,dispatch:r})=>{const s=_(n,t.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const a=i.before(o),c=i.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},ap=n=>({tr:e,dispatch:t})=>{const{from:r,to:s}=n;return t&&e.delete(r,s),!0},cp=()=>({state:n,dispatch:e})=>oi(n,e),dp=()=>({commands:n})=>n.keyboardShortcut("Enter"),up=()=>({state:n,dispatch:e})=>Lh(n,e);function wn(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>t.strict?e[s]===n[s]:lr(e[s])?e[s].test(n[s]):e[s]===n[s]):!0}function ec(n,e,t={}){return n.find(r=>r.type===e&&wn(Object.fromEntries(Object.keys(t).map(s=>[s,r.attrs[s]])),t))}function tc(n,e,t={}){return!!ec(n,e,t)}function fr(n,e,t){var r;if(!n||!e)return;let s=n.parent.childAfter(n.parentOffset);if((!s.node||!s.node.marks.some(d=>d.type===e))&&(s=n.parent.childBefore(n.parentOffset)),!s.node||!s.node.marks.some(d=>d.type===e)||(t=t||((r=s.node.marks[0])===null||r===void 0?void 0:r.attrs),!ec([...s.node.marks],e,t)))return;let o=s.index,l=n.start()+s.offset,a=o+1,c=l+s.node.nodeSize;for(;o>0&&tc([...n.parent.child(o-1).marks],e,t);)o-=1,l-=n.parent.child(o).nodeSize;for(;a<n.parent.childCount&&tc([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function $e(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const fp=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const i=$e(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:d}=l;if(s){const u=fr(a,i,e);if(u&&u.from<=c&&u.to>=d){const f=T.create(o,u.from,u.to);t.setSelection(f)}}return!0},hp=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function yi(n){return n instanceof T}function Oe(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function bi(n,e=null){if(!e)return null;const t=E.atStart(n),r=E.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const s=t.from,i=r.to;return e==="all"?T.create(n,Oe(0,s,i),Oe(n.content.size,s,i)):T.create(n,Oe(e,s,i),Oe(e,s,i))}function nc(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Cn(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const pp=(n=null,e={})=>({editor:t,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(Cn()||nc())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(i&&n===null&&!yi(t.state.selection))return o(),!0;const l=bi(s.doc,n)||t.state.selection,a=t.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},mp=(n,e)=>t=>n.every((r,s)=>e(r,{...t,index:s})),gp=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),rc=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&rc(r)}return n};function $t(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return rc(t)}function xn(n,e,t){if(n instanceof Te||n instanceof b)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,s=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return b.fromArray(n.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(i){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",i),xn("",e,t)}if(s){if(t.errorOnInvalidContent){let o=!1,l="";const a=new Fo({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Ue.fromSchema(a).parseSlice($t(n),t.parseOptions):Ue.fromSchema(a).parse($t(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=Ue.fromSchema(e);return t.slice?i.parseSlice($t(n),t.parseOptions).content:i.parse($t(n),t.parseOptions)}return xn("",e,t)}function sc(n,e,t){const r=n.steps.length-1;if(r<e)return;const s=n.steps[r];if(!(s instanceof Q||s instanceof Y))return;const i=n.mapping.maps[r];let o=0;i.forEach((l,a,c,d)=>{o===0&&(o=d)}),n.setSelection(E.near(n.doc.resolve(o),t))}const yp=n=>!("type"in n),bp=(n,e,t)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){t={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;try{l=xn(e,i.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions},errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:i.options.enableContentCheck})}catch(p){return i.emit("contentError",{editor:i,error:p,disableCollaboration:()=>{i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}}),!1}let{from:a,to:c}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},d=!0,u=!0;if((yp(l)?l:[l]).forEach(p=>{p.check(),d=d?p.isText&&p.marks.length===0:!1,u=u?p.isBlock:!1}),a===c&&u){const{parent:p}=r.doc.resolve(a);p.isTextblock&&!p.type.spec.code&&!p.childCount&&(a-=1,c+=1)}let h;if(d){if(Array.isArray(e))h=e.map(p=>p.text||"").join("");else if(e instanceof b){let p="";e.forEach(m=>{m.text&&(p+=m.text)}),h=p}else typeof e=="object"&&e&&e.text?h=e.text:h=e;r.insertText(h,a,c)}else h=l,r.replaceWith(a,c,h);t.updateSelection&&sc(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:a,text:h}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:a,text:h})}return!0},kp=()=>({state:n,dispatch:e})=>Rh(n,e),Sp=()=>({state:n,dispatch:e})=>Dh(n,e),wp=()=>({state:n,dispatch:e})=>Ia(n,e),Cp=()=>({state:n,dispatch:e})=>za(n,e),xp=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Yn(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Mp=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Yn(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Tp=()=>({state:n,dispatch:e})=>Nh(n,e),Ap=()=>({state:n,dispatch:e})=>vh(n,e);function ki(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Ep(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Cn()||ki()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),s&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),i&&(t=`Shift-${t}`),t}const Op=n=>({editor:e,view:t,tr:r,dispatch:s})=>{const i=Ep(n).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{const d=c.map(r.mapping);d&&s&&r.maybeStep(d)}),!0};function Vt(n,e,t={}){const{from:r,to:s,empty:i}=n.selection,o=e?_(e,n.schema):null,l=[];n.doc.nodesBetween(r,s,(u,f)=>{if(u.isText)return;const h=Math.max(r,f),p=Math.min(s,f+u.nodeSize);l.push({node:u,from:h,to:p})});const a=s-r,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>wn(u.node.attrs,t,{strict:!1}));return i?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}const Np=(n,e={})=>({state:t,dispatch:r})=>{const s=_(n,t.schema);return Vt(t,s,e)?Ih(t,r):!1},vp=()=>({state:n,dispatch:e})=>Va(n,e),Rp=n=>({state:e,dispatch:t})=>{const r=_(n,e.schema);return Kh(r)(e,t)},Dp=()=>({state:n,dispatch:e})=>Fa(n,e);function Mn(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Si(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,s)=>(t.includes(s)||(r[s]=n[s]),r),{})}const Ip=(n,e)=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const l=Mn(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=_(n,r.schema)),l==="mark"&&(o=$e(n,r.schema)),s&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,d)=>{i&&i===c.type&&t.setNodeMarkup(d,void 0,Si(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&t.addMark(d,d+c.nodeSize,o.create(Si(u.attrs,e)))})})}),!0):!1},Lp=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Pp=()=>({tr:n,dispatch:e})=>{if(e){const t=new fe(n.doc);n.setSelection(t)}return!0},Bp=()=>({state:n,dispatch:e})=>Pa(n,e),zp=()=>({state:n,dispatch:e})=>Ha(n,e),Hp=()=>({state:n,dispatch:e})=>zh(n,e),Fp=()=>({state:n,dispatch:e})=>$h(n,e),$p=()=>({state:n,dispatch:e})=>Fh(n,e);function hr(n,e,t={},r={}){return xn(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const Vp=(n,e=!1,t={},r={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{var a,c;const{doc:d}=i;if(t.preserveWhitespace!=="full"){const u=hr(n,s.schema,t,{errorOnInvalidContent:(a=r.errorOnInvalidContent)!==null&&a!==void 0?a:s.options.enableContentCheck});return o&&i.replaceWith(0,d.content.size,u).setMeta("preventUpdate",!e),!0}return o&&i.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:d.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:s.options.enableContentCheck})};function wi(n,e){const t=$e(e,n.schema),{from:r,to:s,empty:i}=n.selection,o=[];i?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function ic(n,e){const t=new vs(n);return e.forEach(r=>{r.steps.forEach(s=>{t.step(s)})}),t}function oc(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Wp(n,e){const t=[];return n.descendants((r,s)=>{e(r)&&t.push({node:r,pos:s})}),t}function lc(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(s,i)=>{t(s)&&r.push({node:s,pos:i})}),r}function Ci(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Wt(n){return e=>Ci(e.$from,n)}function pr(n,e){const t=Ot.resolve(n);return pi(t,e)}function jp(n,e){const t=pr(e),r=Te.fromJSON(t,n);return bn(r.content,t)}function Kp(n,e){const t=pr(e),r=$t(n);return Ue.fromSchema(t).parse(r).toJSON()}function xi(n,e){const t={from:0,to:n.content.size};return gi(n,t,e)}function Up(n,e,t){const{blockSeparator:r=`
14
14
 
15
- `,textSerializers:s={}}=t||{},i=pr(e),o=Te.fromJSON(i,n);return Ci(o,{blockSeparator:r,textSerializers:{...ur(i),...s}})}function lc(n,e){const t=_(e,n.schema),{from:r,to:s}=n.selection,i=[];n.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function xi(n,e){const t=Mn(typeof e=="string"?e:e.name,n.schema);return t==="node"?lc(n,e):t==="mark"?Si(n,e):{}}function ac(n,e=JSON.stringify){const t={};return n.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(t,s)?!1:t[s]=!0})}function Kp(n){const e=ac(n);return e.length===1?e:e.filter((t,r)=>!e.filter((i,o)=>o!==r).some(i=>t.oldRange.from>=i.oldRange.from&&t.oldRange.to<=i.oldRange.to&&t.newRange.from>=i.newRange.from&&t.newRange.to<=i.newRange.to))}function cc(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=t[i];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(i).map(l,-1),d=e.slice(i).map(a),u=e.invert().map(c,-1),f=e.invert().map(d);r.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),Kp(r)}function dc(n,e=0){const r=n.type===n.type.schema.topNodeType?0:1,s=e,i=s+n.nodeSize,o=n.marks.map(c=>{const d={type:c.type.name};return Object.keys(c.attrs).length&&(d.attrs={...c.attrs}),d}),l={...n.attrs},a={type:n.type.name,from:s,to:i};return Object.keys(l).length&&(a.attrs=l),o.length&&(a.marks=o),n.content.childCount&&(a.content=[],n.forEach((c,d)=>{var u;(u=a.content)===null||u===void 0||u.push(dc(c,e+d+r))})),n.text&&(a.text=n.text),a}function mr(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(s=>{const i=t.resolve(n),o=fr(i,s.type);o&&r.push({mark:s,...o})}):t.nodesBetween(n,e,(s,i)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}const Up=(n,e,t,r=20)=>{const s=n.doc.resolve(t);let i=r,o=null;for(;i>0&&o===null;){const l=s.node(i);l?.type.name===e?o=l:i-=1}return[o,i]};function Tn(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const s=n.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}function gr(n,e,t={}){const{empty:r,ranges:s}=n.selection,i=e?$e(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>wn(u.attrs,t,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:u,$to:f})=>{const h=u.pos,p=f.pos;n.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const y=Math.max(h,g),S=Math.min(p,g+m.nodeSize),A=S-y;o+=A,l.push(...m.marks.map(R=>({mark:R,from:y,to:S})))})}),o===0)return!1;const a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>wn(u.mark.attrs,t,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=o}function uc(n,e,t={}){if(!e)return Vt(n,null,t)||gr(n,null,t);const r=Mn(e,n.schema);return r==="node"?Vt(n,e,t):r==="mark"?gr(n,e,t):!1}const Jp=(n,e)=>{const{$from:t,$to:r,$anchor:s}=n.selection;if(e){const i=Wt(l=>l.type.name===e)(n.selection);if(!i)return!1;const o=n.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},qp=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Mi(n,e){const{nodeExtensions:t}=yn(e),r=t.find(o=>o.name===n);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=O(C(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function An(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let s=!0;return n.content.forEach(i=>{s!==!1&&(An(i,{ignoreWhitespace:t,checkChildren:e})||(s=!1))}),s}return!1}function fc(n){return n instanceof x}function _p(n,e,t){const s=n.state.doc.content.size,i=Oe(e,0,s),o=Oe(t,0,s),l=n.coordsAtPos(i),a=n.coordsAtPos(o,-1),c=Math.min(l.top,a.top),d=Math.max(l.bottom,a.bottom),u=Math.min(l.left,a.left),f=Math.max(l.right,a.right),h=f-u,p=d-c,y={top:c,bottom:d,left:u,right:f,width:h,height:p,x:u,y:c};return{...y,toJSON:()=>y}}function hc({json:n,validMarks:e,validNodes:t,options:r,rewrittenContent:s=[]}){return n.marks&&Array.isArray(n.marks)&&(n.marks=n.marks.filter(i=>{const o=typeof i=="string"?i:i.type;return e.has(o)?!0:(s.push({original:JSON.parse(JSON.stringify(i)),unsupported:o}),!1)})),n.content&&Array.isArray(n.content)&&(n.content=n.content.map(i=>hc({json:i,validMarks:e,validNodes:t,options:r,rewrittenContent:s}).json).filter(i=>i!=null)),n.type&&!t.has(n.type)?(s.push({original:JSON.parse(JSON.stringify(n)),unsupported:n.type}),n.content&&Array.isArray(n.content)&&r?.fallbackToParagraph!==!1?(n.type="paragraph",{json:n,rewrittenContent:s}):{json:null,rewrittenContent:s}):{json:n,rewrittenContent:s}}function Gp(n,e,t){return hc({json:n,validNodes:new Set(Object.keys(e.nodes)),validMarks:new Set(Object.keys(e.marks)),options:t})}function Yp(n,e,t){var r;const{selection:s}=e;let i=null;if(gi(s)&&(i=s.$cursor),i){const l=(r=n.storedMarks)!==null&&r!==void 0?r:i.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:o}=s;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}const Xp=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const{selection:i}=t,{empty:o,ranges:l}=i,a=$e(n,r.schema);if(s)if(o){const c=Si(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{const p=Math.max(h,d),m=Math.min(h+f.nodeSize,u);f.marks.find(y=>y.type===a)?f.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create({...y.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return Yp(r,t,a)},Qp=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Zp=(n,e={})=>({state:t,dispatch:r,chain:s})=>{const i=_(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>ja(i,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>ja(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},em=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,s=Oe(n,0,r.content.size),i=x.create(r,s);e.setSelection(i)}return!0},tm=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:s,to:i}=typeof n=="number"?{from:n,to:n}:n,o=T.atStart(r).from,l=T.atEnd(r).to,a=Oe(s,o,l),c=Oe(i,o,l),d=T.create(r,a,c);e.setSelection(d)}return!0},nm=n=>({state:e,dispatch:t})=>{const r=_(n,e.schema);return Uh(r)(e,t)};function pc(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(s=>e?.includes(s.type.name));n.tr.ensureMarks(r)}}const rm=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,d=Tn(c,l.node().type.name,l.node().attrs);if(i instanceof x&&i.node.isBlock)return!l.parentOffset||!Pe(o,l.pos)?!1:(r&&(n&&pc(t,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:ic(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,p=Pe(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Pe(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),r){if(p&&(i instanceof T&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){const m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&pc(t,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},sm=(n,e={})=>({tr:t,state:r,dispatch:s,editor:i})=>{var o;const l=_(n,r.schema),{$from:a,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;const u=a.node(-1);if(u.type!==l)return!1;const f=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let y=b.empty;const S=a.index(-1)?1:a.index(-2)?2:3;for(let U=a.depth-S;U>=a.depth-3;U-=1)y=b.from(a.node(U).copy(y));const A=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,R={...Tn(f,a.node().type.name,a.node().attrs),...e},M=((o=l.contentMatch.defaultType)===null||o===void 0?void 0:o.createAndFill(R))||void 0;y=y.append(b.from(l.createAndFill(null,M)||void 0));const v=a.before(a.depth-(S-1));t.replace(v,a.after(-A),new w(y,4-S,0));let V=-1;t.doc.nodesBetween(v,t.doc.content.size,(U,D)=>{if(V>-1)return!1;U.isTextblock&&U.content.size===0&&(V=D+1)}),V>-1&&t.setSelection(T.near(t.doc.resolve(V))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...Tn(f,u.type.name,u.attrs),...e},m={...Tn(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const g=h?[{type:l,attrs:p},{type:h,attrs:m}]:[{type:l,attrs:p}];if(!Pe(t.doc,a.pos,2))return!1;if(s){const{selection:y,storedMarks:S}=r,{splittableMarks:A}=i.extensionManager,R=S||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!R||!s)return!0;const M=R.filter(v=>A.includes(v.type.name));t.ensureMarks(M)}return!0},Ti=(n,e)=>{const t=Wt(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Je(n.doc,t.pos)&&n.join(t.pos),!0},Ai=(n,e)=>{const t=Wt(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Je(n.doc,r)&&n.join(r),!0},im=(n,e,t,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:u,splittableMarks:f}=s.extensionManager,h=_(n,o.schema),p=_(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:S}=m,A=y.blockRange(S),R=g||m.$to.parentOffset&&m.$from.marks();if(!A)return!1;const M=Wt(v=>Mi(v.type.name,u))(m);if(A.depth>=1&&M&&A.depth-M.depth<=1){if(M.node.type===h)return c.liftListItem(p);if(Mi(M.node.type.name,u)&&h.validContent(M.node.content)&&l)return a().command(()=>(i.setNodeMarkup(M.pos,h),!0)).command(()=>Ti(i,h)).command(()=>Ai(i,h)).run()}return!t||!R||!l?a().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Ti(i,h)).command(()=>Ai(i,h)).run():a().command(()=>{const v=d().wrapInList(h,r),V=R.filter(U=>f.includes(U.type.name));return i.ensureMarks(V),v?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Ti(i,h)).command(()=>Ai(i,h)).run()},om=(n,e={},t={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=t,o=$e(n,r.schema);return gr(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},lm=(n,e,t={})=>({state:r,commands:s})=>{const i=_(n,r.schema),o=_(e,r.schema),l=Vt(r,i,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(o,a):s.setNode(i,{...a,...t})},am=(n,e={})=>({state:t,commands:r})=>{const s=_(n,t.schema);return Vt(t,s,e)?r.lift(s):r.wrapIn(s,e)},cm=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const s=t[r];let i;if(s.spec.isInputRules&&(i=s.getState(n))){if(e){const o=n.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},dm=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:s}=t;return r||e&&s.forEach(i=>{n.removeMark(i.$from.pos,i.$to.pos)}),!0},um=(n,e={})=>({tr:t,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=$e(n,r.schema),{$from:c,empty:d,ranges:u}=l;if(!s)return!0;if(d&&o){let{from:f,to:h}=l;const p=(i=c.marks().find(g=>g.type===a))===null||i===void 0?void 0:i.attrs,m=fr(c,a,p);m&&(f=m.from,h=m.to),t.removeMark(f,h,a)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},fm=(n,e={})=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const l=Mn(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=_(n,r.schema)),l==="mark"&&(o=$e(n,r.schema)),s&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,d=a.$to.pos;let u,f,h,p;t.selection.empty?r.doc.nodesBetween(c,d,(m,g)=>{i&&i===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,d),u=g,f=m)}):r.doc.nodesBetween(c,d,(m,g)=>{g<c&&i&&i===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,d),u=g,f=m),g>=c&&g<=d&&(i&&i===m.type&&t.setNodeMarkup(g,void 0,{...m.attrs,...e}),o&&m.marks.length&&m.marks.forEach(y=>{if(o===y.type){const S=Math.max(g,c),A=Math.min(g+m.nodeSize,d);t.addMark(S,A,o.create({...y.attrs,...e}))}}))}),f&&(u!==void 0&&t.setNodeMarkup(u,void 0,{...f.attrs,...e}),o&&f.marks.length&&f.marks.forEach(m=>{o===m.type&&t.addMark(h,p,o.create({...m.attrs,...e}))}))}),!0):!1},hm=(n,e={})=>({state:t,dispatch:r})=>{const s=_(n,t.schema);return Fh(s,e)(t,r)},pm=(n,e={})=>({state:t,dispatch:r})=>{const s=_(n,t.schema);return $h(s,e)(t,r)};var mm=Object.freeze({__proto__:null,blur:Qh,clearContent:Zh,clearNodes:ep,command:tp,createParagraphNear:np,cut:rp,deleteCurrentNode:sp,deleteNode:ip,deleteRange:op,deleteSelection:lp,enter:ap,exitCode:cp,extendMarkRange:dp,first:up,focus:fp,forEach:hp,insertContent:pp,insertContentAt:gp,joinBackward:kp,joinDown:bp,joinForward:Sp,joinItemBackward:wp,joinItemForward:Cp,joinTextblockBackward:xp,joinTextblockForward:Mp,joinUp:yp,keyboardShortcut:Ap,lift:Ep,liftEmptyBlock:Op,liftListItem:Np,newlineInCode:vp,resetAttributes:Rp,scrollIntoView:Dp,selectAll:Ip,selectNodeBackward:Lp,selectNodeForward:Pp,selectParentNode:Bp,selectTextblockEnd:zp,selectTextblockStart:Hp,setContent:Fp,setMark:Xp,setMeta:Qp,setNode:Zp,setNodeSelection:em,setTextSelection:tm,sinkListItem:nm,splitBlock:rm,splitListItem:sm,toggleList:im,toggleMark:om,toggleNode:lm,toggleWrap:am,undoInputRule:cm,unsetAllMarks:dm,unsetMark:um,updateAttributes:fm,wrapIn:hm,wrapInList:pm});const mc=W.create({name:"commands",addCommands(){return{...mm}}}),gc=W.create({name:"drop",addProseMirrorPlugins(){return[new H({key:new q("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),yc=W.create({name:"editable",addProseMirrorPlugins(){return[new H({key:new q("editable"),props:{editable:()=>this.editor.options.editable}})]}}),bc=new q("focusEvents"),kc=W.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new H({key:bc,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Sc=W.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,m=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,y=m&&p.parent.childCount===1?g===u.pos:E.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Cn()||bi()?i:s},addProseMirrorPlugins(){return[new H({key:new q("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(m=>m.getMeta("composition")))return;const r=n.some(m=>m.docChanged)&&!e.doc.eq(t.doc),s=n.some(m=>m.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:l}=e.selection,a=E.atStart(e.doc).from,c=E.atEnd(e.doc).to;if(i||!(o===a&&l===c)||!An(t.doc))return;const f=t.tr,h=mn({state:t,transaction:f}),{commands:p}=new gn({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),wc=W.create({name:"paste",addProseMirrorPlugins(){return[new H({key:new q("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Cc=W.create({name:"tabindex",addProseMirrorPlugins(){return[new H({key:new q("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});var gm=Object.freeze({__proto__:null,ClipboardTextSerializer:Qa,Commands:mc,Drop:gc,Editable:yc,FocusEvents:kc,Keymap:Sc,Paste:wc,Tabindex:Cc,focusEventsPluginKey:bc});class at{get name(){return this.node.type.name}constructor(e,t,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=s}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new at(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new at(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new at(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const s=t.isBlock&&!t.isTextblock,i=t.isAtom&&!t.isText,o=this.pos+r+(i?0:1),l=this.resolvedPos.doc.resolve(o);if(!s&&l.depth<=this.depth)return;const a=new at(l,this.editor,s,s?t:null);s&&(a.actualDepth=this.depth+1),e.push(new at(l,this.editor,s,s?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(t).length>0){const i=s.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){const a=o[l];if(i[a]!==t[a])break}}else r=s;s=s.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(t);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(a=>t[a]===o.node.attrs[a])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,t,r))))}),s}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const ym=`.ProseMirror {
15
+ `,textSerializers:s={}}=t||{},i=pr(e),o=Te.fromJSON(i,n);return xi(o,{blockSeparator:r,textSerializers:{...ur(i),...s}})}function ac(n,e){const t=_(e,n.schema),{from:r,to:s}=n.selection,i=[];n.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function Mi(n,e){const t=Mn(typeof e=="string"?e:e.name,n.schema);return t==="node"?ac(n,e):t==="mark"?wi(n,e):{}}function cc(n,e=JSON.stringify){const t={};return n.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(t,s)?!1:t[s]=!0})}function Jp(n){const e=cc(n);return e.length===1?e:e.filter((t,r)=>!e.filter((i,o)=>o!==r).some(i=>t.oldRange.from>=i.oldRange.from&&t.oldRange.to<=i.oldRange.to&&t.newRange.from>=i.newRange.from&&t.newRange.to<=i.newRange.to))}function dc(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=t[i];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(i).map(l,-1),d=e.slice(i).map(a),u=e.invert().map(c,-1),f=e.invert().map(d);r.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),Jp(r)}function uc(n,e=0){const r=n.type===n.type.schema.topNodeType?0:1,s=e,i=s+n.nodeSize,o=n.marks.map(c=>{const d={type:c.type.name};return Object.keys(c.attrs).length&&(d.attrs={...c.attrs}),d}),l={...n.attrs},a={type:n.type.name,from:s,to:i};return Object.keys(l).length&&(a.attrs=l),o.length&&(a.marks=o),n.content.childCount&&(a.content=[],n.forEach((c,d)=>{var u;(u=a.content)===null||u===void 0||u.push(uc(c,e+d+r))})),n.text&&(a.text=n.text),a}function mr(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(s=>{const i=t.resolve(n),o=fr(i,s.type);o&&r.push({mark:s,...o})}):t.nodesBetween(n,e,(s,i)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}const qp=(n,e,t,r=20)=>{const s=n.doc.resolve(t);let i=r,o=null;for(;i>0&&o===null;){const l=s.node(i);l?.type.name===e?o=l:i-=1}return[o,i]};function Tn(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const s=n.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}function gr(n,e,t={}){const{empty:r,ranges:s}=n.selection,i=e?$e(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>wn(u.attrs,t,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:u,$to:f})=>{const h=u.pos,p=f.pos;n.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const y=Math.max(h,g),S=Math.min(p,g+m.nodeSize),A=S-y;o+=A,l.push(...m.marks.map(R=>({mark:R,from:y,to:S})))})}),o===0)return!1;const a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>wn(u.mark.attrs,t,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=o}function fc(n,e,t={}){if(!e)return Vt(n,null,t)||gr(n,null,t);const r=Mn(e,n.schema);return r==="node"?Vt(n,e,t):r==="mark"?gr(n,e,t):!1}const _p=(n,e)=>{const{$from:t,$to:r,$anchor:s}=n.selection;if(e){const i=Wt(l=>l.type.name===e)(n.selection);if(!i)return!1;const o=n.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},Gp=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Ti(n,e){const{nodeExtensions:t}=yn(e),r=t.find(o=>o.name===n);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=O(C(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function An(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let s=!0;return n.content.forEach(i=>{s!==!1&&(An(i,{ignoreWhitespace:t,checkChildren:e})||(s=!1))}),s}return!1}function hc(n){return n instanceof x}function Yp(n,e,t){const s=n.state.doc.content.size,i=Oe(e,0,s),o=Oe(t,0,s),l=n.coordsAtPos(i),a=n.coordsAtPos(o,-1),c=Math.min(l.top,a.top),d=Math.max(l.bottom,a.bottom),u=Math.min(l.left,a.left),f=Math.max(l.right,a.right),h=f-u,p=d-c,y={top:c,bottom:d,left:u,right:f,width:h,height:p,x:u,y:c};return{...y,toJSON:()=>y}}function pc({json:n,validMarks:e,validNodes:t,options:r,rewrittenContent:s=[]}){return n.marks&&Array.isArray(n.marks)&&(n.marks=n.marks.filter(i=>{const o=typeof i=="string"?i:i.type;return e.has(o)?!0:(s.push({original:JSON.parse(JSON.stringify(i)),unsupported:o}),!1)})),n.content&&Array.isArray(n.content)&&(n.content=n.content.map(i=>pc({json:i,validMarks:e,validNodes:t,options:r,rewrittenContent:s}).json).filter(i=>i!=null)),n.type&&!t.has(n.type)?(s.push({original:JSON.parse(JSON.stringify(n)),unsupported:n.type}),n.content&&Array.isArray(n.content)&&r?.fallbackToParagraph!==!1?(n.type="paragraph",{json:n,rewrittenContent:s}):{json:null,rewrittenContent:s}):{json:n,rewrittenContent:s}}function Xp(n,e,t){return pc({json:n,validNodes:new Set(Object.keys(e.nodes)),validMarks:new Set(Object.keys(e.marks)),options:t})}function Qp(n,e,t){var r;const{selection:s}=e;let i=null;if(yi(s)&&(i=s.$cursor),i){const l=(r=n.storedMarks)!==null&&r!==void 0?r:i.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:o}=s;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}const Zp=(n,e={})=>({tr:t,state:r,dispatch:s})=>{const{selection:i}=t,{empty:o,ranges:l}=i,a=$e(n,r.schema);if(s)if(o){const c=wi(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{const p=Math.max(h,d),m=Math.min(h+f.nodeSize,u);f.marks.find(y=>y.type===a)?f.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create({...y.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return Qp(r,t,a)},em=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),tm=(n,e={})=>({state:t,dispatch:r,chain:s})=>{const i=_(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>Ka(i,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Ka(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},nm=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,s=Oe(n,0,r.content.size),i=x.create(r,s);e.setSelection(i)}return!0},rm=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:s,to:i}=typeof n=="number"?{from:n,to:n}:n,o=T.atStart(r).from,l=T.atEnd(r).to,a=Oe(s,o,l),c=Oe(i,o,l),d=T.create(r,a,c);e.setSelection(d)}return!0},sm=n=>({state:e,dispatch:t})=>{const r=_(n,e.schema);return qh(r)(e,t)};function mc(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(s=>e?.includes(s.type.name));n.tr.ensureMarks(r)}}const im=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,d=Tn(c,l.node().type.name,l.node().attrs);if(i instanceof x&&i.node.isBlock)return!l.parentOffset||!Pe(o,l.pos)?!1:(r&&(n&&mc(t,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:oc(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,p=Pe(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Pe(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),r){if(p&&(i instanceof T&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){const m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&mc(t,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},om=(n,e={})=>({tr:t,state:r,dispatch:s,editor:i})=>{var o;const l=_(n,r.schema),{$from:a,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;const u=a.node(-1);if(u.type!==l)return!1;const f=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let y=b.empty;const S=a.index(-1)?1:a.index(-2)?2:3;for(let U=a.depth-S;U>=a.depth-3;U-=1)y=b.from(a.node(U).copy(y));const A=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,R={...Tn(f,a.node().type.name,a.node().attrs),...e},M=((o=l.contentMatch.defaultType)===null||o===void 0?void 0:o.createAndFill(R))||void 0;y=y.append(b.from(l.createAndFill(null,M)||void 0));const v=a.before(a.depth-(S-1));t.replace(v,a.after(-A),new w(y,4-S,0));let V=-1;t.doc.nodesBetween(v,t.doc.content.size,(U,D)=>{if(V>-1)return!1;U.isTextblock&&U.content.size===0&&(V=D+1)}),V>-1&&t.setSelection(T.near(t.doc.resolve(V))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...Tn(f,u.type.name,u.attrs),...e},m={...Tn(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const g=h?[{type:l,attrs:p},{type:h,attrs:m}]:[{type:l,attrs:p}];if(!Pe(t.doc,a.pos,2))return!1;if(s){const{selection:y,storedMarks:S}=r,{splittableMarks:A}=i.extensionManager,R=S||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!R||!s)return!0;const M=R.filter(v=>A.includes(v.type.name));t.ensureMarks(M)}return!0},Ai=(n,e)=>{const t=Wt(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Je(n.doc,t.pos)&&n.join(t.pos),!0},Ei=(n,e)=>{const t=Wt(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const s=n.doc.nodeAt(r);return t.node.type===s?.type&&Je(n.doc,r)&&n.join(r),!0},lm=(n,e,t,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:u,splittableMarks:f}=s.extensionManager,h=_(n,o.schema),p=_(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:S}=m,A=y.blockRange(S),R=g||m.$to.parentOffset&&m.$from.marks();if(!A)return!1;const M=Wt(v=>Ti(v.type.name,u))(m);if(A.depth>=1&&M&&A.depth-M.depth<=1){if(M.node.type===h)return c.liftListItem(p);if(Ti(M.node.type.name,u)&&h.validContent(M.node.content)&&l)return a().command(()=>(i.setNodeMarkup(M.pos,h),!0)).command(()=>Ai(i,h)).command(()=>Ei(i,h)).run()}return!t||!R||!l?a().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Ai(i,h)).command(()=>Ei(i,h)).run():a().command(()=>{const v=d().wrapInList(h,r),V=R.filter(U=>f.includes(U.type.name));return i.ensureMarks(V),v?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Ai(i,h)).command(()=>Ei(i,h)).run()},am=(n,e={},t={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=t,o=$e(n,r.schema);return gr(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},cm=(n,e,t={})=>({state:r,commands:s})=>{const i=_(n,r.schema),o=_(e,r.schema),l=Vt(r,i,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(o,a):s.setNode(i,{...a,...t})},dm=(n,e={})=>({state:t,commands:r})=>{const s=_(n,t.schema);return Vt(t,s,e)?r.lift(s):r.wrapIn(s,e)},um=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const s=t[r];let i;if(s.spec.isInputRules&&(i=s.getState(n))){if(e){const o=n.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},fm=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:s}=t;return r||e&&s.forEach(i=>{n.removeMark(i.$from.pos,i.$to.pos)}),!0},hm=(n,e={})=>({tr:t,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=$e(n,r.schema),{$from:c,empty:d,ranges:u}=l;if(!s)return!0;if(d&&o){let{from:f,to:h}=l;const p=(i=c.marks().find(g=>g.type===a))===null||i===void 0?void 0:i.attrs,m=fr(c,a,p);m&&(f=m.from,h=m.to),t.removeMark(f,h,a)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},pm=(n,e={})=>({tr:t,state:r,dispatch:s})=>{let i=null,o=null;const l=Mn(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=_(n,r.schema)),l==="mark"&&(o=$e(n,r.schema)),s&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,d=a.$to.pos;let u,f,h,p;t.selection.empty?r.doc.nodesBetween(c,d,(m,g)=>{i&&i===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,d),u=g,f=m)}):r.doc.nodesBetween(c,d,(m,g)=>{g<c&&i&&i===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,d),u=g,f=m),g>=c&&g<=d&&(i&&i===m.type&&t.setNodeMarkup(g,void 0,{...m.attrs,...e}),o&&m.marks.length&&m.marks.forEach(y=>{if(o===y.type){const S=Math.max(g,c),A=Math.min(g+m.nodeSize,d);t.addMark(S,A,o.create({...y.attrs,...e}))}}))}),f&&(u!==void 0&&t.setNodeMarkup(u,void 0,{...f.attrs,...e}),o&&f.marks.length&&f.marks.forEach(m=>{o===m.type&&t.addMark(h,p,o.create({...m.attrs,...e}))}))}),!0):!1},mm=(n,e={})=>({state:t,dispatch:r})=>{const s=_(n,t.schema);return Vh(s,e)(t,r)},gm=(n,e={})=>({state:t,dispatch:r})=>{const s=_(n,t.schema);return Wh(s,e)(t,r)};var ym=Object.freeze({__proto__:null,blur:ep,clearContent:tp,clearNodes:np,command:rp,createParagraphNear:sp,cut:ip,deleteCurrentNode:op,deleteNode:lp,deleteRange:ap,deleteSelection:cp,enter:dp,exitCode:up,extendMarkRange:fp,first:hp,focus:pp,forEach:mp,insertContent:gp,insertContentAt:bp,joinBackward:wp,joinDown:Sp,joinForward:Cp,joinItemBackward:xp,joinItemForward:Mp,joinTextblockBackward:Tp,joinTextblockForward:Ap,joinUp:kp,keyboardShortcut:Op,lift:Np,liftEmptyBlock:vp,liftListItem:Rp,newlineInCode:Dp,resetAttributes:Ip,scrollIntoView:Lp,selectAll:Pp,selectNodeBackward:Bp,selectNodeForward:zp,selectParentNode:Hp,selectTextblockEnd:Fp,selectTextblockStart:$p,setContent:Vp,setMark:Zp,setMeta:em,setNode:tm,setNodeSelection:nm,setTextSelection:rm,sinkListItem:sm,splitBlock:im,splitListItem:om,toggleList:lm,toggleMark:am,toggleNode:cm,toggleWrap:dm,undoInputRule:um,unsetAllMarks:fm,unsetMark:hm,updateAttributes:pm,wrapIn:mm,wrapInList:gm});const gc=W.create({name:"commands",addCommands(){return{...ym}}}),yc=W.create({name:"drop",addProseMirrorPlugins(){return[new H({key:new q("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),bc=W.create({name:"editable",addProseMirrorPlugins(){return[new H({key:new q("editable"),props:{editable:()=>this.editor.options.editable}})]}}),kc=new q("focusEvents"),Sc=W.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new H({key:kc,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),wc=W.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,m=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,y=m&&p.parent.childCount===1?g===u.pos:E.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Cn()||ki()?i:s},addProseMirrorPlugins(){return[new H({key:new q("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(m=>m.getMeta("composition")))return;const r=n.some(m=>m.docChanged)&&!e.doc.eq(t.doc),s=n.some(m=>m.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:l}=e.selection,a=E.atStart(e.doc).from,c=E.atEnd(e.doc).to;if(i||!(o===a&&l===c)||!An(t.doc))return;const f=t.tr,h=mn({state:t,transaction:f}),{commands:p}=new gn({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),Cc=W.create({name:"paste",addProseMirrorPlugins(){return[new H({key:new q("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),xc=W.create({name:"tabindex",addProseMirrorPlugins(){return[new H({key:new q("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});var bm=Object.freeze({__proto__:null,ClipboardTextSerializer:Za,Commands:gc,Drop:yc,Editable:bc,FocusEvents:Sc,Keymap:wc,Paste:Cc,Tabindex:xc,focusEventsPluginKey:kc});class at{get name(){return this.node.type.name}constructor(e,t,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=s}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new at(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new at(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new at(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const s=t.isBlock&&!t.isTextblock,i=t.isAtom&&!t.isText,o=this.pos+r+(i?0:1),l=this.resolvedPos.doc.resolve(o);if(!s&&l.depth<=this.depth)return;const a=new at(l,this.editor,s,s?t:null);s&&(a.actualDepth=this.depth+1),e.push(new at(l,this.editor,s,s?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(t).length>0){const i=s.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){const a=o[l];if(i[a]!==t[a])break}}else r=s;s=s.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(t);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(a=>t[a]===o.node.attrs[a])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,t,r))))}),s}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const km=`.ProseMirror {
16
16
  position: relative;
17
17
  }
18
18
 
@@ -86,14 +86,14 @@ img.ProseMirror-separator {
86
86
 
87
87
  .tippy-box[data-animation=fade][data-state=hidden] {
88
88
  opacity: 0
89
- }`;function xc(n,e,t){const r=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),s.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(s),s}class bm extends Jh{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:s})=>this.options.onDrop(t,r,s)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=xc(ym,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const r=ui(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let r=t;if([].concat(e).forEach(i=>{const o=typeof i=="string"?`${i}$`:i.key;r=t.filter(l=>!l.key.startsWith(o))}),t.length===r.length)return;const s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}createExtensionManager(){var e,t;const s=[...this.options.enableCoreExtensions?[yc,Qa.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),mc,kc,Sc,Cc,gc,wc].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i?.type));this.extensionManager=new Ot(s,this)}createCommandManager(){this.commandManager=new gn({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=hr(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(o){if(!(o instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(o.message))throw o;this.emit("contentError",{editor:this,error:o,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(l=>l.name!=="collaboration"),this.createExtensionManager()}}),t=hr(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=yi(t,this.options.autofocus);this.view=new yh(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:qt.create({doc:t,selection:r||void 0})});const s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.createNodeViews(),this.prependClass();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(o=>{var l;return(l=this.capturedTransaction)===null||l===void 0?void 0:l.step(o)});return}const t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const s=e.getMeta("focus"),i=e.getMeta("blur");s&&this.emit("focus",{editor:this,event:s.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return xi(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,s=typeof e=="string"?t:e;return uc(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return bn(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
89
+ }`;function Mc(n,e,t){const r=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),s.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(s),s}class Sm extends _h{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:s})=>this.options.onDrop(t,r,s)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=Mc(km,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const r=fi(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let r=t;if([].concat(e).forEach(i=>{const o=typeof i=="string"?`${i}$`:i.key;r=t.filter(l=>!l.key.startsWith(o))}),t.length===r.length)return;const s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}createExtensionManager(){var e,t;const s=[...this.options.enableCoreExtensions?[bc,Za.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),gc,Sc,wc,xc,yc,Cc].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i?.type));this.extensionManager=new Ot(s,this)}createCommandManager(){this.commandManager=new gn({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=hr(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(o){if(!(o instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(o.message))throw o;this.emit("contentError",{editor:this,error:o,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(l=>l.name!=="collaboration"),this.createExtensionManager()}}),t=hr(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=bi(t,this.options.autofocus);this.view=new kh(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:qt.create({doc:t,selection:r||void 0})});const s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.createNodeViews(),this.prependClass();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(o=>{var l;return(l=this.capturedTransaction)===null||l===void 0?void 0:l.step(o)});return}const t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const s=e.getMeta("focus"),i=e.getMeta("blur");s&&this.emit("focus",{editor:this,event:s.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return Mi(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,s=typeof e=="string"?t:e;return fc(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return bn(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
90
90
 
91
- `,textSerializers:r={}}=e||{};return Ci(this.state.doc,{blockSeparator:t,textSerializers:{...ur(this.schema),...r}})}get isEmpty(){return An(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new at(t,this)}get $doc(){return this.$pos(0)}}function St(n){return new Ft({find:n.find,handler:({state:e,range:t,match:r})=>{const s=O(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),d=c+o.length;if(mr(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===n.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;d<t.to&&i.delete(d,t.to),c>t.from&&i.delete(t.from+a,c);const f=t.from+a+o.length;i.addMark(t.from+a,f,n.type.create(s||{})),i.removeStoredMark(n.type)}}})}function Ei(n){return new Ft({find:n.find,handler:({state:e,range:t,match:r})=>{const s=O(n.getAttributes,void 0,r)||{},{tr:i}=e,o=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=o+c;d>l?d=l:l=d+r[1].length;const u=r[0][r[0].length-1];i.insertText(u,o+r[0].length-1),i.replaceWith(d,l,a)}else if(r[0]){const c=n.type.isInline?o:o-1;i.insert(c,n.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l))}i.scrollIntoView()}})}function yr(n){return new Ft({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),i=O(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,i)}})}function km(n){return new Ft({find:n.find,handler:({state:e,range:t,match:r})=>{let s=n.replace,i=t.from;const o=t.to;if(r[1]){const l=r[0].lastIndexOf(r[1]);s+=r[0].slice(l+r[1].length),i+=l;const a=i-o;a>0&&(s=r[0].slice(l-a,l)+s,i=o)}e.tr.insertText(s,i,o)}})}function jt(n){return new Ft({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const i=O(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&As(a,n.type,i);if(!c)return null;if(o.wrap(a,c),n.keepMarks&&n.editor){const{selection:u,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||u.$to.parentOffset&&u.$from.marks();if(p){const m=p.filter(g=>h.includes(g.type.name));o.ensureMarks(m)}}if(n.keepAttributes){const u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(u,i).run()}const d=o.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&Je(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&o.join(t.from-1)}})}class ${constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=O(C(this,"addOptions",{name:this.name}))),this.storage=O(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new $(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Sn(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new $(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=O(C(t,"addOptions",{name:t.name})),t.storage=O(C(t,"addStorage",{name:t.name,options:t.options})),t}}class Sm{constructor(e,t,r){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...r},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,r,s,i,o,l,a;const{view:c}=this.editor,d=e.target,u=d.nodeType===3?(t=d.parentElement)===null||t===void 0?void 0:t.closest("[data-drag-handle]"):d.closest("[data-drag-handle]");if(!this.dom||!((r=this.contentDOM)===null||r===void 0)&&r.contains(d)||!u)return;let f=0,h=0;if(this.dom!==u){const S=this.dom.getBoundingClientRect(),A=u.getBoundingClientRect(),R=(s=e.offsetX)!==null&&s!==void 0?s:(i=e.nativeEvent)===null||i===void 0?void 0:i.offsetX,M=(o=e.offsetY)!==null&&o!==void 0?o:(l=e.nativeEvent)===null||l===void 0?void 0:l.offsetY;f=A.x-S.x+R,h=A.y-S.y+M}const p=this.dom.cloneNode(!0);(a=e.dataTransfer)===null||a===void 0||a.setDragImage(p,f,h);const m=this.getPos();if(typeof m!="number")return;const g=x.create(c.state.doc,m),y=c.state.tr.setSelection(g);c.dispatch(y)}stopEvent(e){var t;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:e});const r=e.target;if(!(this.dom.contains(r)&&!(!((t=this.contentDOM)===null||t===void 0)&&t.contains(r))))return!1;const i=e.type.startsWith("drag"),o=e.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(r.tagName)||r.isContentEditable)&&!o&&!i)return!0;const{isEditable:a}=this.editor,{isDragging:c}=this,d=!!this.node.type.spec.draggable,u=x.isSelectable(this.node),f=e.type==="copy",h=e.type==="paste",p=e.type==="cut",m=e.type==="mousedown";if(!d&&u&&i&&e.target===this.dom&&e.preventDefault(),d&&i&&!c&&e.target===this.dom)return e.preventDefault(),!1;if(d&&a&&!c&&m){const g=r.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||o||f||h||p||m&&u)}ignoreMutation(e){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type==="selection"||this.dom.contains(e.target)&&e.type==="childList"&&(Cn()||tc())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(r=>r.isContentEditable)?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command(({tr:t})=>{const r=this.getPos();return typeof r!="number"?!1:(t.setNodeMarkup(r,void 0,{...this.node.attrs,...e}),!0)})}deleteNode(){const e=this.getPos();if(typeof e!="number")return;const t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}}function Ze(n){return new cr({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const i=O(n.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const d=a.search(/\S/),u=t.from+a.indexOf(l),f=u+l.length;if(mr(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===n.type&&g!==p.mark.type)).filter(p=>p.to>u).length)return null;f<t.to&&o.delete(f,t.to),u>t.from&&o.delete(t.from+d,u),c=t.from+d+l.length,o.addMark(t.from+d,c,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}function wm(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function Cm(n){return typeof n=="string"}function xm(n){return new cr({find:n.find,handler({match:e,chain:t,range:r,pasteEvent:s}){const i=O(n.getAttributes,void 0,e,s),o=O(n.getContent,void 0,i);if(i===!1||i===null)return null;const l={type:n.type.name,attrs:i};o&&(l.content=o),e.input&&t().deleteRange(r).insertContentAt(r.from,l)}})}function Mm(n){return new cr({find:n.find,handler:({state:e,range:t,match:r})=>{let s=n.replace,i=t.from;const o=t.to;if(r[1]){const l=r[0].lastIndexOf(r[1]);s+=r[0].slice(l+r[1].length),i+=l;const a=i-o;a>0&&(s=r[0].slice(l-a,l)+s,i=o)}e.tr.insertText(s,i,o)}})}class Tm{constructor(e){this.transaction=e,this.currentStep=this.transaction.steps.length}map(e){let t=!1;return{position:this.transaction.steps.slice(this.currentStep).reduce((s,i)=>{const o=i.getMap().mapResult(s);return o.deleted&&(t=!0),o.pos},e),deleted:t}}}const Am=/^\s*>\s$/,Mc=$.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[jt({find:Am,type:this.type})]}}),Em=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Om=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Nm=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,vm=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Tc=ce.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[St({find:Em,type:this.type}),St({find:Nm,type:this.type})]},addPasteRules(){return[Ze({find:Om,type:this.type}),Ze({find:vm,type:this.type})]}}),Rm="listItem",Ac="textStyle",Ec=/^\s*([-+*])\s$/,Oc=$.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",I(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Rm,this.editor.getAttributes(Ac)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=jt({find:Ec,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=jt({find:Ec,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ac),editor:this.editor})),[n]}}),Dm=/(^|[^`])`([^`]+)`(?!`)/,Im=/(^|[^`])`([^`]+)`(?!`)/g,Nc=ce.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[St({find:Dm,type:this.type})]},addPasteRules(){return[Ze({find:Im,type:this.type})]}}),Lm=/^```([a-z]+)?[\s\n]$/,Pm=/^~~~([a-z]+)?[\s\n]$/,vc=$.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,i=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",I(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
91
+ `,textSerializers:r={}}=e||{};return xi(this.state.doc,{blockSeparator:t,textSerializers:{...ur(this.schema),...r}})}get isEmpty(){return An(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new at(t,this)}get $doc(){return this.$pos(0)}}function St(n){return new Ft({find:n.find,handler:({state:e,range:t,match:r})=>{const s=O(n.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),d=c+o.length;if(mr(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===n.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;d<t.to&&i.delete(d,t.to),c>t.from&&i.delete(t.from+a,c);const f=t.from+a+o.length;i.addMark(t.from+a,f,n.type.create(s||{})),i.removeStoredMark(n.type)}}})}function Oi(n){return new Ft({find:n.find,handler:({state:e,range:t,match:r})=>{const s=O(n.getAttributes,void 0,r)||{},{tr:i}=e,o=t.from;let l=t.to;const a=n.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=o+c;d>l?d=l:l=d+r[1].length;const u=r[0][r[0].length-1];i.insertText(u,o+r[0].length-1),i.replaceWith(d,l,a)}else if(r[0]){const c=n.type.isInline?o:o-1;i.insert(c,n.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l))}i.scrollIntoView()}})}function yr(n){return new Ft({find:n.find,handler:({state:e,range:t,match:r})=>{const s=e.doc.resolve(t.from),i=O(n.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,i)}})}function wm(n){return new Ft({find:n.find,handler:({state:e,range:t,match:r})=>{let s=n.replace,i=t.from;const o=t.to;if(r[1]){const l=r[0].lastIndexOf(r[1]);s+=r[0].slice(l+r[1].length),i+=l;const a=i-o;a>0&&(s=r[0].slice(l-a,l)+s,i=o)}e.tr.insertText(s,i,o)}})}function jt(n){return new Ft({find:n.find,handler:({state:e,range:t,match:r,chain:s})=>{const i=O(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&Es(a,n.type,i);if(!c)return null;if(o.wrap(a,c),n.keepMarks&&n.editor){const{selection:u,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||u.$to.parentOffset&&u.$from.marks();if(p){const m=p.filter(g=>h.includes(g.type.name));o.ensureMarks(m)}}if(n.keepAttributes){const u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(u,i).run()}const d=o.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&Je(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&o.join(t.from-1)}})}class ${constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=O(C(this,"addOptions",{name:this.name}))),this.storage=O(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new $(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Sn(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new $(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=O(C(t,"addOptions",{name:t.name})),t.storage=O(C(t,"addStorage",{name:t.name,options:t.options})),t}}class Cm{constructor(e,t,r){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...r},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,r,s,i,o,l,a;const{view:c}=this.editor,d=e.target,u=d.nodeType===3?(t=d.parentElement)===null||t===void 0?void 0:t.closest("[data-drag-handle]"):d.closest("[data-drag-handle]");if(!this.dom||!((r=this.contentDOM)===null||r===void 0)&&r.contains(d)||!u)return;let f=0,h=0;if(this.dom!==u){const S=this.dom.getBoundingClientRect(),A=u.getBoundingClientRect(),R=(s=e.offsetX)!==null&&s!==void 0?s:(i=e.nativeEvent)===null||i===void 0?void 0:i.offsetX,M=(o=e.offsetY)!==null&&o!==void 0?o:(l=e.nativeEvent)===null||l===void 0?void 0:l.offsetY;f=A.x-S.x+R,h=A.y-S.y+M}const p=this.dom.cloneNode(!0);(a=e.dataTransfer)===null||a===void 0||a.setDragImage(p,f,h);const m=this.getPos();if(typeof m!="number")return;const g=x.create(c.state.doc,m),y=c.state.tr.setSelection(g);c.dispatch(y)}stopEvent(e){var t;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:e});const r=e.target;if(!(this.dom.contains(r)&&!(!((t=this.contentDOM)===null||t===void 0)&&t.contains(r))))return!1;const i=e.type.startsWith("drag"),o=e.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(r.tagName)||r.isContentEditable)&&!o&&!i)return!0;const{isEditable:a}=this.editor,{isDragging:c}=this,d=!!this.node.type.spec.draggable,u=x.isSelectable(this.node),f=e.type==="copy",h=e.type==="paste",p=e.type==="cut",m=e.type==="mousedown";if(!d&&u&&i&&e.target===this.dom&&e.preventDefault(),d&&i&&!c&&e.target===this.dom)return e.preventDefault(),!1;if(d&&a&&!c&&m){const g=r.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||o||f||h||p||m&&u)}ignoreMutation(e){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type==="selection"||this.dom.contains(e.target)&&e.type==="childList"&&(Cn()||nc())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(r=>r.isContentEditable)?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command(({tr:t})=>{const r=this.getPos();return typeof r!="number"?!1:(t.setNodeMarkup(r,void 0,{...this.node.attrs,...e}),!0)})}deleteNode(){const e=this.getPos();if(typeof e!="number")return;const t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}}function Ze(n){return new cr({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:s})=>{const i=O(n.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const d=a.search(/\S/),u=t.from+a.indexOf(l),f=u+l.length;if(mr(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===n.type&&g!==p.mark.type)).filter(p=>p.to>u).length)return null;f<t.to&&o.delete(f,t.to),u>t.from&&o.delete(t.from+d,u),c=t.from+d+l.length,o.addMark(t.from+d,c,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}function xm(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function Mm(n){return typeof n=="string"}function Tm(n){return new cr({find:n.find,handler({match:e,chain:t,range:r,pasteEvent:s}){const i=O(n.getAttributes,void 0,e,s),o=O(n.getContent,void 0,i);if(i===!1||i===null)return null;const l={type:n.type.name,attrs:i};o&&(l.content=o),e.input&&t().deleteRange(r).insertContentAt(r.from,l)}})}function Am(n){return new cr({find:n.find,handler:({state:e,range:t,match:r})=>{let s=n.replace,i=t.from;const o=t.to;if(r[1]){const l=r[0].lastIndexOf(r[1]);s+=r[0].slice(l+r[1].length),i+=l;const a=i-o;a>0&&(s=r[0].slice(l-a,l)+s,i=o)}e.tr.insertText(s,i,o)}})}class Em{constructor(e){this.transaction=e,this.currentStep=this.transaction.steps.length}map(e){let t=!1;return{position:this.transaction.steps.slice(this.currentStep).reduce((s,i)=>{const o=i.getMap().mapResult(s);return o.deleted&&(t=!0),o.pos},e),deleted:t}}}const Om=/^\s*>\s$/,Tc=$.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[jt({find:Om,type:this.type})]}}),Nm=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,vm=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Rm=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Dm=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Ac=ce.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[St({find:Nm,type:this.type}),St({find:Rm,type:this.type})]},addPasteRules(){return[Ze({find:vm,type:this.type}),Ze({find:Dm,type:this.type})]}}),Im="listItem",Ec="textStyle",Oc=/^\s*([-+*])\s$/,Nc=$.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",I(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Im,this.editor.getAttributes(Ec)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=jt({find:Oc,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=jt({find:Oc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ec),editor:this.editor})),[n]}}),Lm=/(^|[^`])`([^`]+)`(?!`)/,Pm=/(^|[^`])`([^`]+)`(?!`)/g,vc=ce.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[St({find:Lm,type:this.type})]},addPasteRules(){return[Ze({find:Pm,type:this.type})]}}),Bm=/^```([a-z]+)?[\s\n]$/,zm=/^~~~([a-z]+)?[\s\n]$/,Rc=$.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,i=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",I(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
92
92
 
93
- `);return!i||!o?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:i}=t;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(E.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[yr({find:Lm,type:this.type,getAttributes:n=>({language:n[1]})}),yr({find:Pm,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new H({key:new q("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!t||!i)return!1;const{tr:o,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,`
94
- `));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(T.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),Bm=$.create({name:"doc",topNode:!0,content:"block+"});function zm(n={}){return new H({view(e){return new Hm(e,n)}})}class Hm{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r;if(t){let l=e.nodeBefore,a=e.nodeAfter;if(l||a){let c=this.editorView.nodeDOM(this.cursorPos-(l?l.nodeSize:0));if(c){let d=c.getBoundingClientRect(),u=l?d.bottom:d.top;l&&a&&(u=(u+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:d.left,right:d.right,top:u-this.width/2,bottom:u+this.width/2}}}}if(!r){let l=this.editorView.coordsAtPos(this.cursorPos);r={left:l.left-this.width/2,right:l.left+this.width/2,top:l.top,bottom:l.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let i,o;if(!s||s==document.body&&getComputedStyle(s).position=="static")i=-pageXOffset,o=-pageYOffset;else{let l=s.getBoundingClientRect();i=l.left-s.scrollLeft,o=l.top-s.scrollTop}this.element.style.left=r.left-i+"px",this.element.style.top=r.top-o+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!i){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=sl(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}}const Fm=W.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[zm(this.options)]}});class K extends E{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return K.valid(r)?new K(r):E.near(r)}content(){return w.empty}eq(e){return e instanceof K&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new K(e.resolve(t.pos))}getBookmark(){return new bo(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!$m(e)||!Vm(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&K.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=t;let a=e.doc.resolve(s);if(K.valid(a))return a}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!x.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*t),r=!1;continue e}break}i=o,s+=t;let l=e.doc.resolve(s);if(K.valid(l))return l}return null}}}K.prototype.visible=!1,K.findFrom=K.findGapCursorFrom,E.jsonID("gapcursor",K);class bo{constructor(e){this.pos=e}map(e){return new bo(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return K.valid(t)?new K(t):E.near(t)}}function $m(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function Vm(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function Wm(){return new H({props:{decorations:Jm,createSelectionBetween(n,e,t){return e.pos==t.pos&&K.valid(t)?new K(t):null},handleClick:Km,handleKeyDown:jm,handleDOMEvents:{beforeinput:Um}}})}const jm=si({ArrowLeft:br("horiz",-1),ArrowRight:br("horiz",1),ArrowUp:br("vert",-1),ArrowDown:br("vert",1)});function br(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof T){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=K.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new K(c))),!0):!1}}function Km(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!K.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&x.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new K(r))),!0)}function Um(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof K))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=b.empty;for(let o=r.length-1;o>=0;o--)s=b.from(r[o].createAndFill(null,s));let i=n.state.tr.replace(t.pos,t.pos,new w(s,0,0));return i.setSelection(T.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function Jm(n){if(!(n.selection instanceof K))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",z.create(n.doc,[X.widget(n.selection.head,e,{key:"gapcursor"})])}const qm=W.create({name:"gapCursor",addProseMirrorPlugins(){return[Wm()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=O(C(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),_m=$.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",I(this.options.HTMLAttributes,n)]},renderText(){return`
95
- `},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:i}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&o){const u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Rc=$.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,I(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>yr({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var kr=200,G=function(){};G.prototype.append=function(e){return e.length?(e=G.from(e),!this.length&&e||e.length<kr&&this.leafAppend(e)||this.length<kr&&e.leafPrepend(this)||this.appendInner(e)):this},G.prototype.prepend=function(e){return e.length?G.from(e).append(this):this},G.prototype.appendInner=function(e){return new Gm(this,e)},G.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?G.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},G.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},G.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},G.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},t,r),s},G.from=function(e){return e instanceof G?e:e&&e.length?new Dc(e):G.empty};var Dc=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=kr)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=kr)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(G);G.empty=new Dc([]);var Gm=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(G);const Ym=500;class Me{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;t&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){s||(s=this.remapping(r,f+1),i=s.maps.length),i--,d.push(u);return}if(s){d.push(new Ie(u.map));let h=u.step.map(s.slice(i)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Ie(p,void 0,void 0,c.length+d.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(i)):u.selection,a=new Me(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new Ie(e.mapping.maps[d],u,t),h;(h=a&&a.merge(f))&&(f=h,d?i.pop():l=l.slice(0,l.length-1)),i.push(f),t&&(o++,t=void 0),s||(a=f)}let c=o-r.depth;return c>Qm&&(l=Xm(l,c),o-=c),new Me(l.append(i),o)}remapping(e,t){let r=new _t;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new Me(this.items.append(e.map(t=>new Ie(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=i.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(i.slice(a+1,h));g&&l++,r.push(new Ie(p,m,g))}else r.push(new Ie(p))},s);let c=[];for(let f=t;f<o;f++)c.push(new Ie(i.maps[f]));let d=this.items.slice(0,s).append(c).append(r),u=new Me(d,l);return u.emptyItemCount()>Ym&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let d=o.selection&&o.selection.map(t.slice(r));d&&i++;let u=new Ie(c.invert(),a,d),f,h=s.length-1;(f=s.length&&s[h].merge(u))?s[h]=f:s.push(u)}}else o.map&&r--},this.items.length,0),new Me(G.from(s.reverse()),i)}}Me.empty=new Me(G.empty,0);function Xm(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class Ie{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Ie(t.getMap().invert(),t,this.selection)}}}class et{constructor(e,t,r,s,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const Qm=20;function Zm(n,e,t,r){let s=t.getMeta(wt),i;if(s)return s.historyState;t.getMeta(ng)&&(n=new et(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(wt))return o.getMeta(wt).redo?new et(n.done.addTransform(t,void 0,r,Sr(e)),n.undone,Ic(t.mapping.maps),n.prevTime,n.prevComposition):new et(n.done,n.undone.addTransform(t,void 0,r,Sr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!eg(t,n.prevRanges)),c=o?Oi(n.prevRanges,t.mapping):Ic(t.mapping.maps);return new et(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Sr(e)),Me.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new et(n.done.rebased(t,i),n.undone.rebased(t,i),Oi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new et(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Oi(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function eg(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(t=!0)}),t}function Ic(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,i,o)=>e.push(i,o));return e}function Oi(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),i=e.map(n[r+1],-1);s<=i&&t.push(s,i)}return t}function tg(n,e,t){let r=Sr(e),s=wt.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new et(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(wt,{redo:t,historyState:a})}let Ni=!1,Lc=null;function Sr(n){let e=n.plugins;if(Lc!=e){Ni=!1,Lc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ni=!0;break}}return Ni}const wt=new q("history"),ng=new q("closeHistory");function rg(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new H({key:wt,state:{init(){return new et(Me.empty,Me.empty,null,0,-1)},apply(e,t,r){return Zm(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?Bc:r=="historyRedo"?zc:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function Pc(n,e){return(t,r)=>{let s=wt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let i=tg(s,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}const Bc=Pc(!1,!0),zc=Pc(!0,!0),sg=W.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Bc(n,e),redo:()=>({state:n,dispatch:e})=>zc(n,e)}},addProseMirrorPlugins(){return[rg(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}}),Hc=$.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",I(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{selection:t}=e,{$from:r,$to:s}=t,i=n();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):fc(t)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:o,dispatch:l})=>{var a;if(l){const{$to:c}=o.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(T.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(x.create(o.doc,c.pos)):o.setSelection(T.create(o.doc,c.pos));else{const u=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();u&&(o.insert(d,u),o.setSelection(T.create(o.doc,d+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Ei({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ig=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,og=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,lg=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,ag=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Fc=ce.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[St({find:ig,type:this.type}),St({find:lg,type:this.type})]},addPasteRules(){return[Ze({find:og,type:this.type}),Ze({find:ag,type:this.type})]}}),$c=$.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",I(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),cg="listItem",Vc="textStyle",Wc=/^(\d+)\.\s$/,jc=$.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",I(this.options.HTMLAttributes,t),0]:["ol",I(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(cg,this.editor.getAttributes(Vc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=jt({find:Wc,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=jt({find:Wc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Vc)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),dg=$.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ug=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,fg=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Kc=ce.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[St({find:ug,type:this.type})]},addPasteRules(){return[Ze({find:fg,type:this.type})]}}),hg=$.create({name:"text",group:"inline"}),pg=W.create({name:"starterKit",addExtensions(){const n=[];return this.options.bold!==!1&&n.push(Tc.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(Mc.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(Oc.configure(this.options.bulletList)),this.options.code!==!1&&n.push(Nc.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(vc.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(Bm.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(Fm.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(qm.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(_m.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(Rc.configure(this.options.heading)),this.options.history!==!1&&n.push(sg.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(Hc.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(Fc.configure(this.options.italic)),this.options.listItem!==!1&&n.push($c.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(jc.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(dg.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(Kc.configure(this.options.strike)),this.options.text!==!1&&n.push(hg.configure(this.options.text)),n}}),mg=W.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new H({key:new q("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!t)return null;const i=this.editor.isEmpty;return n.descendants((o,l)=>{const a=r>=l&&r<=l+o.nodeSize,c=!o.isLeaf&&An(o);if((a||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];i&&d.push(this.options.emptyEditorClass);const u=X.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:a}):this.options.placeholder});s.push(u)}return this.options.includeChildren}),z.create(n,s)}}})]}}),gg=n=>{if(!n.children.length)return;const e=n.querySelectorAll("span");e&&e.forEach(t=>{var r,s;const i=t.getAttribute("style"),o=(s=(r=t.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||s===void 0?void 0:s.getAttribute("style");t.setAttribute("style",`${o};${i}`)})},yg=ce.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&gg(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",I(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,r)=>{if(t.isTextblock)return!0;t.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||n.removeMark(r,r+t.nodeSize,this.type)}),!0}}}}),bg=W.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new H({key:new q("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const o=i-s,l=0,a=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=i-r,c=l-a,d=l;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}}),kg=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Uc=$.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",I(this.options.HTMLAttributes,n)]},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[Ei({find:kg,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}}),Sg="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",wg="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",Kt=(n,e)=>{for(const t in e)n[t]=e[t];return n},vi="numeric",Ri="ascii",Di="alpha",En="asciinumeric",On="alphanumeric",Ii="domain",Jc="emoji",Cg="scheme",xg="slashscheme",Li="whitespace";function Mg(n,e){return n in e||(e[n]=[]),e[n]}function Ct(n,e,t){e[vi]&&(e[En]=!0,e[On]=!0),e[Ri]&&(e[En]=!0,e[Di]=!0),e[En]&&(e[On]=!0),e[Di]&&(e[On]=!0),e[On]&&(e[Ii]=!0),e[Jc]&&(e[Ii]=!0);for(const r in e){const s=Mg(r,t);s.indexOf(n)<0&&s.push(n)}}function Tg(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function ue(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}ue.groups={},ue.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(n))return i}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let s=0;s<n.length;s++)this.tt(n[s],e,t,r)},tr(n,e,t,r){r=r||ue.groups;let s;return e&&e.j?s=e:(s=new ue(e),t&&r&&Ct(e,t,r)),this.jr.push([n,s]),s},ts(n,e,t,r){let s=this;const i=n.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(n[o]);return s.tt(n[i-1],e,t,r)},tt(n,e,t,r){r=r||ue.groups;const s=this;if(e&&e.j)return s.j[n]=e,e;const i=e;let o,l=s.go(n);if(l?(o=new ue,Kt(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new ue,i){if(r)if(o.t&&typeof o.t=="string"){const a=Kt(Tg(o.t,r),t);Ct(i,a,r)}else t&&Ct(i,t,r);o.t=i}return s.j[n]=o,o}};const N=(n,e,t,r,s)=>n.ta(e,t,r,s),j=(n,e,t,r,s)=>n.tr(e,t,r,s),qc=(n,e,t,r,s)=>n.ts(e,t,r,s),k=(n,e,t,r,s)=>n.tt(e,t,r,s),Ve="WORD",Pi="UWORD",_c="ASCIINUMERICAL",Gc="ALPHANUMERICAL",Nn="LOCALHOST",Bi="TLD",zi="UTLD",wr="SCHEME",Ut="SLASH_SCHEME",Hi="NUM",Fi="WS",$i="NL",vn="OPENBRACE",Rn="CLOSEBRACE",Cr="OPENBRACKET",xr="CLOSEBRACKET",Mr="OPENPAREN",Tr="CLOSEPAREN",Ar="OPENANGLEBRACKET",Er="CLOSEANGLEBRACKET",Or="FULLWIDTHLEFTPAREN",Nr="FULLWIDTHRIGHTPAREN",vr="LEFTCORNERBRACKET",Rr="RIGHTCORNERBRACKET",Dr="LEFTWHITECORNERBRACKET",Ir="RIGHTWHITECORNERBRACKET",Lr="FULLWIDTHLESSTHAN",Pr="FULLWIDTHGREATERTHAN",Br="AMPERSAND",Vi="APOSTROPHE",zr="ASTERISK",tt="AT",Hr="BACKSLASH",Fr="BACKTICK",$r="CARET",nt="COLON",Wi="COMMA",Vr="DOLLAR",Ne="DOT",Wr="EQUALS",ji="EXCLAMATION",ke="HYPHEN",Dn="PERCENT",jr="PIPE",Kr="PLUS",Ur="POUND",In="QUERY",Ki="QUOTE",Yc="FULLWIDTHMIDDLEDOT",Ui="SEMI",ve="SLASH",Ln="TILDE",Jr="UNDERSCORE",Xc="EMOJI",qr="SYM";var Qc=Object.freeze({__proto__:null,WORD:Ve,UWORD:Pi,ASCIINUMERICAL:_c,ALPHANUMERICAL:Gc,LOCALHOST:Nn,TLD:Bi,UTLD:zi,SCHEME:wr,SLASH_SCHEME:Ut,NUM:Hi,WS:Fi,NL:$i,OPENBRACE:vn,CLOSEBRACE:Rn,OPENBRACKET:Cr,CLOSEBRACKET:xr,OPENPAREN:Mr,CLOSEPAREN:Tr,OPENANGLEBRACKET:Ar,CLOSEANGLEBRACKET:Er,FULLWIDTHLEFTPAREN:Or,FULLWIDTHRIGHTPAREN:Nr,LEFTCORNERBRACKET:vr,RIGHTCORNERBRACKET:Rr,LEFTWHITECORNERBRACKET:Dr,RIGHTWHITECORNERBRACKET:Ir,FULLWIDTHLESSTHAN:Lr,FULLWIDTHGREATERTHAN:Pr,AMPERSAND:Br,APOSTROPHE:Vi,ASTERISK:zr,AT:tt,BACKSLASH:Hr,BACKTICK:Fr,CARET:$r,COLON:nt,COMMA:Wi,DOLLAR:Vr,DOT:Ne,EQUALS:Wr,EXCLAMATION:ji,HYPHEN:ke,PERCENT:Dn,PIPE:jr,PLUS:Kr,POUND:Ur,QUERY:In,QUOTE:Ki,FULLWIDTHMIDDLEDOT:Yc,SEMI:Ui,SLASH:ve,TILDE:Ln,UNDERSCORE:Jr,EMOJI:Xc,SYM:qr});const We=/[a-z]/,Pn=/\p{L}/u,Ji=/\p{Emoji}/u,je=/\d/,qi=/\s/,Zc="\r",_i=`
96
- `,Ag="\uFE0F",Eg="\u200D",Gi="\uFFFC";let _r=null,Gr=null;function Og(n=[]){const e={};ue.groups=e;const t=new ue;_r==null&&(_r=td(Sg)),Gr==null&&(Gr=td(wg)),k(t,"'",Vi),k(t,"{",vn),k(t,"}",Rn),k(t,"[",Cr),k(t,"]",xr),k(t,"(",Mr),k(t,")",Tr),k(t,"<",Ar),k(t,">",Er),k(t,"\uFF08",Or),k(t,"\uFF09",Nr),k(t,"\u300C",vr),k(t,"\u300D",Rr),k(t,"\u300E",Dr),k(t,"\u300F",Ir),k(t,"\uFF1C",Lr),k(t,"\uFF1E",Pr),k(t,"&",Br),k(t,"*",zr),k(t,"@",tt),k(t,"`",Fr),k(t,"^",$r),k(t,":",nt),k(t,",",Wi),k(t,"$",Vr),k(t,".",Ne),k(t,"=",Wr),k(t,"!",ji),k(t,"-",ke),k(t,"%",Dn),k(t,"|",jr),k(t,"+",Kr),k(t,"#",Ur),k(t,"?",In),k(t,'"',Ki),k(t,"/",ve),k(t,";",Ui),k(t,"~",Ln),k(t,"_",Jr),k(t,"\\",Hr),k(t,"\u30FB",Yc);const r=j(t,je,Hi,{[vi]:!0});j(r,je,r);const s=j(r,We,_c,{[En]:!0}),i=j(r,Pn,Gc,{[On]:!0}),o=j(t,We,Ve,{[Ri]:!0});j(o,je,s),j(o,We,o),j(s,je,s),j(s,We,s);const l=j(t,Pn,Pi,{[Di]:!0});j(l,We),j(l,je,i),j(l,Pn,l),j(i,je,i),j(i,We),j(i,Pn,i);const a=k(t,_i,$i,{[Li]:!0}),c=k(t,Zc,Fi,{[Li]:!0}),d=j(t,qi,Fi,{[Li]:!0});k(t,Gi,d),k(c,_i,a),k(c,Gi,d),j(c,qi,d),k(d,Zc),k(d,_i),j(d,qi,d),k(d,Gi,d);const u=j(t,Ji,Xc,{[Jc]:!0});k(u,"#"),j(u,Ji,u),k(u,Ag,u);const f=k(u,Eg);k(f,"#"),j(f,Ji,u);const h=[[We,o],[je,s]],p=[[We,null],[Pn,l],[je,i]];for(let m=0;m<_r.length;m++)rt(t,_r[m],Bi,Ve,h);for(let m=0;m<Gr.length;m++)rt(t,Gr[m],zi,Pi,p);Ct(Bi,{tld:!0,ascii:!0},e),Ct(zi,{utld:!0,alpha:!0},e),rt(t,"file",wr,Ve,h),rt(t,"mailto",wr,Ve,h),rt(t,"http",Ut,Ve,h),rt(t,"https",Ut,Ve,h),rt(t,"ftp",Ut,Ve,h),rt(t,"ftps",Ut,Ve,h),Ct(wr,{scheme:!0,ascii:!0},e),Ct(Ut,{slashscheme:!0,ascii:!0},e),n=n.sort((m,g)=>m[0]>g[0]?1:-1);for(let m=0;m<n.length;m++){const g=n[m][0],S=n[m][1]?{[Cg]:!0}:{[xg]:!0};g.indexOf("-")>=0?S[Ii]=!0:We.test(g)?je.test(g)?S[En]=!0:S[Ri]=!0:S[vi]=!0,qc(t,g,g,S)}return qc(t,"localhost",Nn,{ascii:!0}),t.jd=new ue(qr),{start:t,tokens:Kt({groups:e},Qc)}}function ed(n,e){const t=Ng(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,s=[];let i=0,o=0;for(;o<r;){let l=n,a=null,c=0,d=null,u=-1,f=-1;for(;o<r&&(a=l.go(t[o]));)l=a,l.accepts()?(u=0,f=0,d=l):u>=0&&(u+=t[o].length,f++),c+=t[o].length,i+=t[o].length,o++;i-=u,o-=f,c-=u,s.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return s}function Ng(n){const e=[],t=n.length;let r=0;for(;r<t;){let s=n.charCodeAt(r),i,o=s<55296||s>56319||r+1===t||(i=n.charCodeAt(r+1))<56320||i>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function rt(n,e,t,r,s){let i;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];n.j[a]?i=n.j[a]:(i=new ue(r),i.jr=s.slice(),n.j[a]=i),n=i}return i=new ue(t),i.jr=s.slice(),n.j[e[o-1]]=i,i}function td(n){const e=[],t=[];let r=0,s="0123456789";for(;r<n.length;){let i=0;for(;s.indexOf(n[r+i])>=0;)i++;if(i>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+i),10);o>0;o--)t.pop();r+=i}else t.push(n[r]),r++}return e}const Bn={defaultProtocol:"http",events:null,format:nd,formatHref:nd,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Yi(n,e=null){let t=Kt({},Bn);n&&(t=Kt(t,n instanceof Yi?n.o:n));const r=t.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=s}Yi.prototype={o:Bn,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let s=this.o[n];return s&&(typeof s=="object"?(s=t.t in s?s[t.t]:Bn[n],typeof s=="function"&&r&&(s=s(e,t))):typeof s=="function"&&r&&(s=s(e,t.t,t)),s)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function nd(n){return n}function rd(n,e){this.t="token",this.v=n,this.tk=e}rd.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"\u2026":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=Bn.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),s=n.get("tagName",t,e),i=this.toFormattedString(n),o={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),d&&Kt(o,d),{tagName:s,attributes:o,content:i,eventListeners:u}}};function Yr(n,e){class t extends rd{constructor(s,i){super(s,i),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const sd=Yr("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),id=Yr("text"),vg=Yr("nl"),Xr=Yr("url",{isLink:!0,toHref(n=Bn.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==Nn&&n[1].t===nt}}),Se=n=>new ue(n);function Rg({groups:n}){const e=n.domain.concat([Br,zr,tt,Hr,Fr,$r,Vr,Wr,ke,Hi,Dn,jr,Kr,Ur,ve,qr,Ln,Jr]),t=[nt,Wi,Ne,ji,Dn,In,Ki,Ui,Ar,Er,vn,Rn,xr,Cr,Mr,Tr,Or,Nr,vr,Rr,Dr,Ir,Lr,Pr],r=[Br,Vi,zr,Hr,Fr,$r,Vr,Wr,ke,vn,Rn,Dn,jr,Kr,Ur,In,ve,qr,Ln,Jr],s=Se(),i=k(s,Ln);N(i,r,i),N(i,n.domain,i);const o=Se(),l=Se(),a=Se();N(s,n.domain,o),N(s,n.scheme,l),N(s,n.slashscheme,a),N(o,r,i),N(o,n.domain,o);const c=k(o,tt);k(i,tt,c),k(l,tt,c),k(a,tt,c);const d=k(i,Ne);N(d,r,i),N(d,n.domain,i);const u=Se();N(c,n.domain,u),N(u,n.domain,u);const f=k(u,Ne);N(f,n.domain,u);const h=Se(sd);N(f,n.tld,h),N(f,n.utld,h),k(c,Nn,h);const p=k(u,ke);k(p,ke,p),N(p,n.domain,u),N(h,n.domain,u),k(h,Ne,f),k(h,ke,p);const m=k(h,nt);N(m,n.numeric,sd);const g=k(o,ke),y=k(o,Ne);k(g,ke,g),N(g,n.domain,o),N(y,r,i),N(y,n.domain,o);const S=Se(Xr);N(y,n.tld,S),N(y,n.utld,S),N(S,n.domain,o),N(S,r,i),k(S,Ne,y),k(S,ke,g),k(S,tt,c);const A=k(S,nt),R=Se(Xr);N(A,n.numeric,R);const M=Se(Xr),v=Se();N(M,e,M),N(M,t,v),N(v,e,M),N(v,t,v),k(S,ve,M),k(R,ve,M);const V=k(l,nt),U=k(a,nt),D=k(U,ve),me=k(D,ve);N(l,n.domain,o),k(l,Ne,y),k(l,ke,g),N(a,n.domain,o),k(a,Ne,y),k(a,ke,g),N(V,n.domain,M),k(V,ve,M),k(V,In,M),N(me,n.domain,M),N(me,e,M),k(me,ve,M);const ut=[[vn,Rn],[Cr,xr],[Mr,Tr],[Ar,Er],[Or,Nr],[vr,Rr],[Dr,Ir],[Lr,Pr]];for(let Xt=0;Xt<ut.length;Xt++){const[ko,gs]=ut[Xt],$n=k(M,ko);k(v,ko,$n),k($n,gs,M);const Nt=Se(Xr);N($n,e,Nt);const Qt=Se();N($n,t),N(Nt,e,Nt),N(Nt,t,Qt),N(Qt,e,Nt),N(Qt,t,Qt),k(Nt,gs,M),k(Qt,gs,M)}return k(s,Nn,S),k(s,$i,vg),{start:s,tokens:Qc}}function Dg(n,e,t){let r=t.length,s=0,i=[],o=[];for(;s<r;){let l=n,a=null,c=null,d=0,u=null,f=-1;for(;s<r&&!(a=l.go(t[s].t));)o.push(t[s++]);for(;s<r&&(c=a||l.go(t[s].t));)a=null,l=c,l.accepts()?(f=0,u=l):f>=0&&f++,s++,d++;if(f<0)s-=d,s<r&&(o.push(t[s]),s++);else{o.length>0&&(i.push(Xi(id,e,o)),o=[]),s-=f,d-=f;const h=u.t,p=t.slice(s-d,s);i.push(Xi(h,e,p))}}return o.length>0&&i.push(Xi(id,e,o)),i}function Xi(n,e,t){const r=t[0].s,s=t[t.length-1].e,i=e.slice(r,s);return new n(i,t)}const Ig=typeof console<"u"&&console&&console.warn||(()=>{}),Lg="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",F={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Pg(){return ue.groups={},F.scanner=null,F.parser=null,F.tokenQueue=[],F.pluginQueue=[],F.customSchemes=[],F.initialized=!1,F}function od(n,e=!1){if(F.initialized&&Ig(`linkifyjs: already initialized - will not register custom scheme "${n}" ${Lg}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
93
+ `);return!i||!o?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:s,empty:i}=t;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(E.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[yr({find:Bm,type:this.type,getAttributes:n=>({language:n[1]})}),yr({find:zm,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new H({key:new q("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!t||!i)return!1;const{tr:o,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,`
94
+ `));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(T.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),Hm=$.create({name:"doc",topNode:!0,content:"block+"});function Fm(n={}){return new H({view(e){return new $m(e,n)}})}class $m{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r;if(t){let l=e.nodeBefore,a=e.nodeAfter;if(l||a){let c=this.editorView.nodeDOM(this.cursorPos-(l?l.nodeSize:0));if(c){let d=c.getBoundingClientRect(),u=l?d.bottom:d.top;l&&a&&(u=(u+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:d.left,right:d.right,top:u-this.width/2,bottom:u+this.width/2}}}}if(!r){let l=this.editorView.coordsAtPos(this.cursorPos);r={left:l.left-this.width/2,right:l.left+this.width/2,top:l.top,bottom:l.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let i,o;if(!s||s==document.body&&getComputedStyle(s).position=="static")i=-pageXOffset,o=-pageYOffset;else{let l=s.getBoundingClientRect();i=l.left-s.scrollLeft,o=l.top-s.scrollTop}this.element.style.left=r.left-i+"px",this.element.style.top=r.top-o+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,t,e):s;if(t&&!i){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=il(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}}const Vm=W.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Fm(this.options)]}});class K extends E{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return K.valid(r)?new K(r):E.near(r)}content(){return w.empty}eq(e){return e instanceof K&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new K(e.resolve(t.pos))}getBookmark(){return new ko(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Wm(e)||!jm(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let s=t.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&K.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=t;let a=e.doc.resolve(s);if(K.valid(a))return a}for(;;){let o=t>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!x.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*t),r=!1;continue e}break}i=o,s+=t;let l=e.doc.resolve(s);if(K.valid(l))return l}return null}}}K.prototype.visible=!1,K.findFrom=K.findGapCursorFrom,E.jsonID("gapcursor",K);class ko{constructor(e){this.pos=e}map(e){return new ko(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return K.valid(t)?new K(t):E.near(t)}}function Wm(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function jm(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(t);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function Km(){return new H({props:{decorations:_m,createSelectionBetween(n,e,t){return e.pos==t.pos&&K.valid(t)?new K(t):null},handleClick:Jm,handleKeyDown:Um,handleDOMEvents:{beforeinput:qm}}})}const Um=ii({ArrowLeft:br("horiz",-1),ArrowRight:br("horiz",1),ArrowUp:br("vert",-1),ArrowDown:br("vert",1)});function br(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof T){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=K.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new K(c))),!0):!1}}function Jm(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!K.valid(r))return!1;let s=n.posAtCoords({left:t.clientX,top:t.clientY});return s&&s.inside>-1&&x.isSelectable(n.state.doc.nodeAt(s.inside))?!1:(n.dispatch(n.state.tr.setSelection(new K(r))),!0)}function qm(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof K))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let s=b.empty;for(let o=r.length-1;o>=0;o--)s=b.from(r[o].createAndFill(null,s));let i=n.state.tr.replace(t.pos,t.pos,new w(s,0,0));return i.setSelection(T.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function _m(n){if(!(n.selection instanceof K))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",z.create(n.doc,[X.widget(n.selection.head,e,{key:"gapcursor"})])}const Gm=W.create({name:"gapCursor",addProseMirrorPlugins(){return[Km()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=O(C(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),Ym=$.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",I(this.options.HTMLAttributes,n)]},renderText(){return`
95
+ `},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:s,storedMarks:i}=t;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&o){const u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Dc=$.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,I(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>yr({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var kr=200,G=function(){};G.prototype.append=function(e){return e.length?(e=G.from(e),!this.length&&e||e.length<kr&&this.leafAppend(e)||this.length<kr&&e.leafPrepend(this)||this.appendInner(e)):this},G.prototype.prepend=function(e){return e.length?G.from(e).append(this):this},G.prototype.appendInner=function(e){return new Xm(this,e)},G.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?G.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},G.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},G.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},G.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},t,r),s},G.from=function(e){return e instanceof G?e:e&&e.length?new Ic(e):G.empty};var Ic=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=kr)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=kr)return new e(s.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(G);G.empty=new Ic([]);var Xm=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(G);const Qm=500;class Me{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;t&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){s||(s=this.remapping(r,f+1),i=s.maps.length),i--,d.push(u);return}if(s){d.push(new Ie(u.map));let h=u.step.map(s.slice(i)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Ie(p,void 0,void 0,c.length+d.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(i)):u.selection,a=new Me(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new Ie(e.mapping.maps[d],u,t),h;(h=a&&a.merge(f))&&(f=h,d?i.pop():l=l.slice(0,l.length-1)),i.push(f),t&&(o++,t=void 0),s||(a=f)}let c=o-r.depth;return c>eg&&(l=Zm(l,c),o-=c),new Me(l.append(i),o)}remapping(e,t){let r=new _t;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new Me(this.items.append(e.map(t=>new Ie(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-t),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=t;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=i.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(i.slice(a+1,h));g&&l++,r.push(new Ie(p,m,g))}else r.push(new Ie(p))},s);let c=[];for(let f=t;f<o;f++)c.push(new Ie(i.maps[f]));let d=this.items.slice(0,s).append(c).append(r),u=new Me(d,l);return u.emptyItemCount()>Qm&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let d=o.selection&&o.selection.map(t.slice(r));d&&i++;let u=new Ie(c.invert(),a,d),f,h=s.length-1;(f=s.length&&s[h].merge(u))?s[h]=f:s.push(u)}}else o.map&&r--},this.items.length,0),new Me(G.from(s.reverse()),i)}}Me.empty=new Me(G.empty,0);function Zm(n,e){let t;return n.forEach((r,s)=>{if(r.selection&&e--==0)return t=s,!1}),n.slice(t)}class Ie{constructor(e,t,r,s){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Ie(t.getMap().invert(),t,this.selection)}}}class et{constructor(e,t,r,s,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const eg=20;function tg(n,e,t,r){let s=t.getMeta(wt),i;if(s)return s.historyState;t.getMeta(sg)&&(n=new et(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(wt))return o.getMeta(wt).redo?new et(n.done.addTransform(t,void 0,r,Sr(e)),n.undone,Lc(t.mapping.maps),n.prevTime,n.prevComposition):new et(n.done,n.undone.addTransform(t,void 0,r,Sr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!ng(t,n.prevRanges)),c=o?Ni(n.prevRanges,t.mapping):Lc(t.mapping.maps);return new et(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Sr(e)),Me.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new et(n.done.rebased(t,i),n.undone.rebased(t,i),Ni(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new et(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Ni(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function ng(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(t=!0)}),t}function Lc(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,s,i,o)=>e.push(i,o));return e}function Ni(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let s=e.map(n[r],1),i=e.map(n[r+1],-1);s<=i&&t.push(s,i)}return t}function rg(n,e,t){let r=Sr(e),s=wt.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new et(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(wt,{redo:t,historyState:a})}let vi=!1,Pc=null;function Sr(n){let e=n.plugins;if(Pc!=e){vi=!1,Pc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){vi=!0;break}}return vi}const wt=new q("history"),sg=new q("closeHistory");function ig(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new H({key:wt,state:{init(){return new et(Me.empty,Me.empty,null,0,-1)},apply(e,t,r){return tg(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,s=r=="historyUndo"?zc:r=="historyRedo"?Hc:null;return s?(t.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function Bc(n,e){return(t,r)=>{let s=wt.getState(t);if(!s||(n?s.undone:s.done).eventCount==0)return!1;if(r){let i=rg(s,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}const zc=Bc(!1,!0),Hc=Bc(!0,!0),og=W.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>zc(n,e),redo:()=>({state:n,dispatch:e})=>Hc(n,e)}},addProseMirrorPlugins(){return[ig(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}}),Fc=$.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",I(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{selection:t}=e,{$from:r,$to:s}=t,i=n();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):hc(t)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:o,dispatch:l})=>{var a;if(l){const{$to:c}=o.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(T.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(x.create(o.doc,c.pos)):o.setSelection(T.create(o.doc,c.pos));else{const u=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();u&&(o.insert(d,u),o.setSelection(T.create(o.doc,d+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Oi({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),lg=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,ag=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,cg=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,dg=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,$c=ce.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[St({find:lg,type:this.type}),St({find:cg,type:this.type})]},addPasteRules(){return[Ze({find:ag,type:this.type}),Ze({find:dg,type:this.type})]}}),Vc=$.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",I(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ug="listItem",Wc="textStyle",jc=/^(\d+)\.\s$/,Kc=$.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",I(this.options.HTMLAttributes,t),0]:["ol",I(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ug,this.editor.getAttributes(Wc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=jt({find:jc,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=jt({find:jc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Wc)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),fg=$.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),hg=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,pg=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Uc=ce.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[St({find:hg,type:this.type})]},addPasteRules(){return[Ze({find:pg,type:this.type})]}}),mg=$.create({name:"text",group:"inline"}),gg=W.create({name:"starterKit",addExtensions(){const n=[];return this.options.bold!==!1&&n.push(Ac.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(Tc.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(Nc.configure(this.options.bulletList)),this.options.code!==!1&&n.push(vc.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(Rc.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(Hm.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(Vm.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(Gm.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(Ym.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(Dc.configure(this.options.heading)),this.options.history!==!1&&n.push(og.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(Fc.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push($c.configure(this.options.italic)),this.options.listItem!==!1&&n.push(Vc.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(Kc.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(fg.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(Uc.configure(this.options.strike)),this.options.text!==!1&&n.push(mg.configure(this.options.text)),n}}),yg=W.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new H({key:new q("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!t)return null;const i=this.editor.isEmpty;return n.descendants((o,l)=>{const a=r>=l&&r<=l+o.nodeSize,c=!o.isLeaf&&An(o);if((a||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];i&&d.push(this.options.emptyEditorClass);const u=X.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:a}):this.options.placeholder});s.push(u)}return this.options.includeChildren}),z.create(n,s)}}})]}}),bg=n=>{if(!n.children.length)return;const e=n.querySelectorAll("span");e&&e.forEach(t=>{var r,s;const i=t.getAttribute("style"),o=(s=(r=t.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||s===void 0?void 0:s.getAttribute("style");t.setAttribute("style",`${o};${i}`)})},kg=ce.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&bg(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",I(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,r)=>{if(t.isTextblock)return!0;t.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||n.removeMark(r,r+t.nodeSize,this.type)}),!0}}}}),Sg=W.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new H({key:new q("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const s=this.options.limit;if(s==null||s===0){n=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const o=i-s,l=0,a=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=i-r,c=l-a,d=l;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}}),wg=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Jc=$.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",I(this.options.HTMLAttributes,n)]},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[Oi({find:wg,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}}),Cg="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",xg="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",Kt=(n,e)=>{for(const t in e)n[t]=e[t];return n},Ri="numeric",Di="ascii",Ii="alpha",En="asciinumeric",On="alphanumeric",Li="domain",qc="emoji",Mg="scheme",Tg="slashscheme",Pi="whitespace";function Ag(n,e){return n in e||(e[n]=[]),e[n]}function Ct(n,e,t){e[Ri]&&(e[En]=!0,e[On]=!0),e[Di]&&(e[En]=!0,e[Ii]=!0),e[En]&&(e[On]=!0),e[Ii]&&(e[On]=!0),e[On]&&(e[Li]=!0),e[qc]&&(e[Li]=!0);for(const r in e){const s=Ag(r,t);s.indexOf(n)<0&&s.push(n)}}function Eg(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function ue(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}ue.groups={},ue.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(n))return i}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let s=0;s<n.length;s++)this.tt(n[s],e,t,r)},tr(n,e,t,r){r=r||ue.groups;let s;return e&&e.j?s=e:(s=new ue(e),t&&r&&Ct(e,t,r)),this.jr.push([n,s]),s},ts(n,e,t,r){let s=this;const i=n.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(n[o]);return s.tt(n[i-1],e,t,r)},tt(n,e,t,r){r=r||ue.groups;const s=this;if(e&&e.j)return s.j[n]=e,e;const i=e;let o,l=s.go(n);if(l?(o=new ue,Kt(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new ue,i){if(r)if(o.t&&typeof o.t=="string"){const a=Kt(Eg(o.t,r),t);Ct(i,a,r)}else t&&Ct(i,t,r);o.t=i}return s.j[n]=o,o}};const N=(n,e,t,r,s)=>n.ta(e,t,r,s),j=(n,e,t,r,s)=>n.tr(e,t,r,s),_c=(n,e,t,r,s)=>n.ts(e,t,r,s),k=(n,e,t,r,s)=>n.tt(e,t,r,s),Ve="WORD",Bi="UWORD",Gc="ASCIINUMERICAL",Yc="ALPHANUMERICAL",Nn="LOCALHOST",zi="TLD",Hi="UTLD",wr="SCHEME",Ut="SLASH_SCHEME",Fi="NUM",$i="WS",Vi="NL",vn="OPENBRACE",Rn="CLOSEBRACE",Cr="OPENBRACKET",xr="CLOSEBRACKET",Mr="OPENPAREN",Tr="CLOSEPAREN",Ar="OPENANGLEBRACKET",Er="CLOSEANGLEBRACKET",Or="FULLWIDTHLEFTPAREN",Nr="FULLWIDTHRIGHTPAREN",vr="LEFTCORNERBRACKET",Rr="RIGHTCORNERBRACKET",Dr="LEFTWHITECORNERBRACKET",Ir="RIGHTWHITECORNERBRACKET",Lr="FULLWIDTHLESSTHAN",Pr="FULLWIDTHGREATERTHAN",Br="AMPERSAND",Wi="APOSTROPHE",zr="ASTERISK",tt="AT",Hr="BACKSLASH",Fr="BACKTICK",$r="CARET",nt="COLON",ji="COMMA",Vr="DOLLAR",Ne="DOT",Wr="EQUALS",Ki="EXCLAMATION",ke="HYPHEN",Dn="PERCENT",jr="PIPE",Kr="PLUS",Ur="POUND",In="QUERY",Ui="QUOTE",Xc="FULLWIDTHMIDDLEDOT",Ji="SEMI",ve="SLASH",Ln="TILDE",Jr="UNDERSCORE",Qc="EMOJI",qr="SYM";var Zc=Object.freeze({__proto__:null,WORD:Ve,UWORD:Bi,ASCIINUMERICAL:Gc,ALPHANUMERICAL:Yc,LOCALHOST:Nn,TLD:zi,UTLD:Hi,SCHEME:wr,SLASH_SCHEME:Ut,NUM:Fi,WS:$i,NL:Vi,OPENBRACE:vn,CLOSEBRACE:Rn,OPENBRACKET:Cr,CLOSEBRACKET:xr,OPENPAREN:Mr,CLOSEPAREN:Tr,OPENANGLEBRACKET:Ar,CLOSEANGLEBRACKET:Er,FULLWIDTHLEFTPAREN:Or,FULLWIDTHRIGHTPAREN:Nr,LEFTCORNERBRACKET:vr,RIGHTCORNERBRACKET:Rr,LEFTWHITECORNERBRACKET:Dr,RIGHTWHITECORNERBRACKET:Ir,FULLWIDTHLESSTHAN:Lr,FULLWIDTHGREATERTHAN:Pr,AMPERSAND:Br,APOSTROPHE:Wi,ASTERISK:zr,AT:tt,BACKSLASH:Hr,BACKTICK:Fr,CARET:$r,COLON:nt,COMMA:ji,DOLLAR:Vr,DOT:Ne,EQUALS:Wr,EXCLAMATION:Ki,HYPHEN:ke,PERCENT:Dn,PIPE:jr,PLUS:Kr,POUND:Ur,QUERY:In,QUOTE:Ui,FULLWIDTHMIDDLEDOT:Xc,SEMI:Ji,SLASH:ve,TILDE:Ln,UNDERSCORE:Jr,EMOJI:Qc,SYM:qr});const We=/[a-z]/,Pn=/\p{L}/u,qi=/\p{Emoji}/u,je=/\d/,_i=/\s/,ed="\r",Gi=`
96
+ `,Og="\uFE0F",Ng="\u200D",Yi="\uFFFC";let _r=null,Gr=null;function vg(n=[]){const e={};ue.groups=e;const t=new ue;_r==null&&(_r=nd(Cg)),Gr==null&&(Gr=nd(xg)),k(t,"'",Wi),k(t,"{",vn),k(t,"}",Rn),k(t,"[",Cr),k(t,"]",xr),k(t,"(",Mr),k(t,")",Tr),k(t,"<",Ar),k(t,">",Er),k(t,"\uFF08",Or),k(t,"\uFF09",Nr),k(t,"\u300C",vr),k(t,"\u300D",Rr),k(t,"\u300E",Dr),k(t,"\u300F",Ir),k(t,"\uFF1C",Lr),k(t,"\uFF1E",Pr),k(t,"&",Br),k(t,"*",zr),k(t,"@",tt),k(t,"`",Fr),k(t,"^",$r),k(t,":",nt),k(t,",",ji),k(t,"$",Vr),k(t,".",Ne),k(t,"=",Wr),k(t,"!",Ki),k(t,"-",ke),k(t,"%",Dn),k(t,"|",jr),k(t,"+",Kr),k(t,"#",Ur),k(t,"?",In),k(t,'"',Ui),k(t,"/",ve),k(t,";",Ji),k(t,"~",Ln),k(t,"_",Jr),k(t,"\\",Hr),k(t,"\u30FB",Xc);const r=j(t,je,Fi,{[Ri]:!0});j(r,je,r);const s=j(r,We,Gc,{[En]:!0}),i=j(r,Pn,Yc,{[On]:!0}),o=j(t,We,Ve,{[Di]:!0});j(o,je,s),j(o,We,o),j(s,je,s),j(s,We,s);const l=j(t,Pn,Bi,{[Ii]:!0});j(l,We),j(l,je,i),j(l,Pn,l),j(i,je,i),j(i,We),j(i,Pn,i);const a=k(t,Gi,Vi,{[Pi]:!0}),c=k(t,ed,$i,{[Pi]:!0}),d=j(t,_i,$i,{[Pi]:!0});k(t,Yi,d),k(c,Gi,a),k(c,Yi,d),j(c,_i,d),k(d,ed),k(d,Gi),j(d,_i,d),k(d,Yi,d);const u=j(t,qi,Qc,{[qc]:!0});k(u,"#"),j(u,qi,u),k(u,Og,u);const f=k(u,Ng);k(f,"#"),j(f,qi,u);const h=[[We,o],[je,s]],p=[[We,null],[Pn,l],[je,i]];for(let m=0;m<_r.length;m++)rt(t,_r[m],zi,Ve,h);for(let m=0;m<Gr.length;m++)rt(t,Gr[m],Hi,Bi,p);Ct(zi,{tld:!0,ascii:!0},e),Ct(Hi,{utld:!0,alpha:!0},e),rt(t,"file",wr,Ve,h),rt(t,"mailto",wr,Ve,h),rt(t,"http",Ut,Ve,h),rt(t,"https",Ut,Ve,h),rt(t,"ftp",Ut,Ve,h),rt(t,"ftps",Ut,Ve,h),Ct(wr,{scheme:!0,ascii:!0},e),Ct(Ut,{slashscheme:!0,ascii:!0},e),n=n.sort((m,g)=>m[0]>g[0]?1:-1);for(let m=0;m<n.length;m++){const g=n[m][0],S=n[m][1]?{[Mg]:!0}:{[Tg]:!0};g.indexOf("-")>=0?S[Li]=!0:We.test(g)?je.test(g)?S[En]=!0:S[Di]=!0:S[Ri]=!0,_c(t,g,g,S)}return _c(t,"localhost",Nn,{ascii:!0}),t.jd=new ue(qr),{start:t,tokens:Kt({groups:e},Zc)}}function td(n,e){const t=Rg(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,s=[];let i=0,o=0;for(;o<r;){let l=n,a=null,c=0,d=null,u=-1,f=-1;for(;o<r&&(a=l.go(t[o]));)l=a,l.accepts()?(u=0,f=0,d=l):u>=0&&(u+=t[o].length,f++),c+=t[o].length,i+=t[o].length,o++;i-=u,o-=f,c-=u,s.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return s}function Rg(n){const e=[],t=n.length;let r=0;for(;r<t;){let s=n.charCodeAt(r),i,o=s<55296||s>56319||r+1===t||(i=n.charCodeAt(r+1))<56320||i>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function rt(n,e,t,r,s){let i;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];n.j[a]?i=n.j[a]:(i=new ue(r),i.jr=s.slice(),n.j[a]=i),n=i}return i=new ue(t),i.jr=s.slice(),n.j[e[o-1]]=i,i}function nd(n){const e=[],t=[];let r=0,s="0123456789";for(;r<n.length;){let i=0;for(;s.indexOf(n[r+i])>=0;)i++;if(i>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+i),10);o>0;o--)t.pop();r+=i}else t.push(n[r]),r++}return e}const Bn={defaultProtocol:"http",events:null,format:rd,formatHref:rd,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Xi(n,e=null){let t=Kt({},Bn);n&&(t=Kt(t,n instanceof Xi?n.o:n));const r=t.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=s}Xi.prototype={o:Bn,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let s=this.o[n];return s&&(typeof s=="object"?(s=t.t in s?s[t.t]:Bn[n],typeof s=="function"&&r&&(s=s(e,t))):typeof s=="function"&&r&&(s=s(e,t.t,t)),s)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function rd(n){return n}function sd(n,e){this.t="token",this.v=n,this.tk=e}sd.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"\u2026":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=Bn.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),s=n.get("tagName",t,e),i=this.toFormattedString(n),o={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),d&&Kt(o,d),{tagName:s,attributes:o,content:i,eventListeners:u}}};function Yr(n,e){class t extends sd{constructor(s,i){super(s,i),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const id=Yr("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),od=Yr("text"),Dg=Yr("nl"),Xr=Yr("url",{isLink:!0,toHref(n=Bn.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==Nn&&n[1].t===nt}}),Se=n=>new ue(n);function Ig({groups:n}){const e=n.domain.concat([Br,zr,tt,Hr,Fr,$r,Vr,Wr,ke,Fi,Dn,jr,Kr,Ur,ve,qr,Ln,Jr]),t=[nt,ji,Ne,Ki,Dn,In,Ui,Ji,Ar,Er,vn,Rn,xr,Cr,Mr,Tr,Or,Nr,vr,Rr,Dr,Ir,Lr,Pr],r=[Br,Wi,zr,Hr,Fr,$r,Vr,Wr,ke,vn,Rn,Dn,jr,Kr,Ur,In,ve,qr,Ln,Jr],s=Se(),i=k(s,Ln);N(i,r,i),N(i,n.domain,i);const o=Se(),l=Se(),a=Se();N(s,n.domain,o),N(s,n.scheme,l),N(s,n.slashscheme,a),N(o,r,i),N(o,n.domain,o);const c=k(o,tt);k(i,tt,c),k(l,tt,c),k(a,tt,c);const d=k(i,Ne);N(d,r,i),N(d,n.domain,i);const u=Se();N(c,n.domain,u),N(u,n.domain,u);const f=k(u,Ne);N(f,n.domain,u);const h=Se(id);N(f,n.tld,h),N(f,n.utld,h),k(c,Nn,h);const p=k(u,ke);k(p,ke,p),N(p,n.domain,u),N(h,n.domain,u),k(h,Ne,f),k(h,ke,p);const m=k(h,nt);N(m,n.numeric,id);const g=k(o,ke),y=k(o,Ne);k(g,ke,g),N(g,n.domain,o),N(y,r,i),N(y,n.domain,o);const S=Se(Xr);N(y,n.tld,S),N(y,n.utld,S),N(S,n.domain,o),N(S,r,i),k(S,Ne,y),k(S,ke,g),k(S,tt,c);const A=k(S,nt),R=Se(Xr);N(A,n.numeric,R);const M=Se(Xr),v=Se();N(M,e,M),N(M,t,v),N(v,e,M),N(v,t,v),k(S,ve,M),k(R,ve,M);const V=k(l,nt),U=k(a,nt),D=k(U,ve),me=k(D,ve);N(l,n.domain,o),k(l,Ne,y),k(l,ke,g),N(a,n.domain,o),k(a,Ne,y),k(a,ke,g),N(V,n.domain,M),k(V,ve,M),k(V,In,M),N(me,n.domain,M),N(me,e,M),k(me,ve,M);const ut=[[vn,Rn],[Cr,xr],[Mr,Tr],[Ar,Er],[Or,Nr],[vr,Rr],[Dr,Ir],[Lr,Pr]];for(let Xt=0;Xt<ut.length;Xt++){const[So,ys]=ut[Xt],$n=k(M,So);k(v,So,$n),k($n,ys,M);const Nt=Se(Xr);N($n,e,Nt);const Qt=Se();N($n,t),N(Nt,e,Nt),N(Nt,t,Qt),N(Qt,e,Nt),N(Qt,t,Qt),k(Nt,ys,M),k(Qt,ys,M)}return k(s,Nn,S),k(s,Vi,Dg),{start:s,tokens:Zc}}function Lg(n,e,t){let r=t.length,s=0,i=[],o=[];for(;s<r;){let l=n,a=null,c=null,d=0,u=null,f=-1;for(;s<r&&!(a=l.go(t[s].t));)o.push(t[s++]);for(;s<r&&(c=a||l.go(t[s].t));)a=null,l=c,l.accepts()?(f=0,u=l):f>=0&&f++,s++,d++;if(f<0)s-=d,s<r&&(o.push(t[s]),s++);else{o.length>0&&(i.push(Qi(od,e,o)),o=[]),s-=f,d-=f;const h=u.t,p=t.slice(s-d,s);i.push(Qi(h,e,p))}}return o.length>0&&i.push(Qi(od,e,o)),i}function Qi(n,e,t){const r=t[0].s,s=t[t.length-1].e,i=e.slice(r,s);return new n(i,t)}const Pg=typeof console<"u"&&console&&console.warn||(()=>{}),Bg="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",F={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function zg(){return ue.groups={},F.scanner=null,F.parser=null,F.tokenQueue=[],F.pluginQueue=[],F.customSchemes=[],F.initialized=!1,F}function ld(n,e=!1){if(F.initialized&&Pg(`linkifyjs: already initialized - will not register custom scheme "${n}" ${Bg}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
97
97
  1. Must only contain digits, lowercase ASCII letters or "-"
98
98
  2. Cannot start or end with "-"
99
- 3. "-" cannot repeat`);F.customSchemes.push([n,e])}function Bg(){F.scanner=Og(F.customSchemes);for(let n=0;n<F.tokenQueue.length;n++)F.tokenQueue[n][1]({scanner:F.scanner});F.parser=Rg(F.scanner.tokens);for(let n=0;n<F.pluginQueue.length;n++)F.pluginQueue[n][1]({scanner:F.scanner,parser:F.parser});return F.initialized=!0,F}function Qi(n){return F.initialized||Bg(),Dg(F.parser.start,n,ed(F.scanner.start,n))}Qi.scan=ed;function ld(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Yi(t),s=Qi(n),i=[];for(let o=0;o<s.length;o++){const l=s[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}function zg(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function Hg(n){return new H({key:new q("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,l=sc(t.doc,[...e]);if(cc(l).forEach(({newRange:c})=>{const d=oc(r.doc,c,h=>h.isTextblock);let u,f;if(d.length>1?(u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ")):d.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")),u&&f){const h=f.split(" ").filter(y=>y!=="");if(h.length<=0)return!1;const p=h[h.length-1],m=u.pos+f.lastIndexOf(p);if(!p)return!1;const g=Qi(p).map(y=>y.toObject(n.defaultProtocol));if(!zg(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>n.validate(y.value)).filter(y=>n.shouldAutoLink(y.value)).forEach(y=>{mr(y.from,y.to,r.doc).some(S=>S.mark.type===n.type)||o.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function Fg(n){return new H({key:new q("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=r.target;const l=[];for(;o.nodeName!=="DIV";)l.push(o),o=o.parentNode;if(!l.find(f=>f.nodeName==="A"))return!1;const a=xi(e.state,n.type.name),c=r.target,d=(s=c?.href)!==null&&s!==void 0?s:a.href,u=(i=c?.target)!==null&&i!==void 0?i:a.target;return c&&d?(window.open(d,u),!0):!1}}})}function $g(n){return new H({key:new q("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:s}=e,{selection:i}=s,{empty:o}=i;if(o)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});const a=ld(l,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:n.editor.commands.setMark(n.type,{href:a.href})}}})}const Vg=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function xt(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&t.push(s)}),!n||n.replace(Vg,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const ad=ce.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){od(n);return}od(n.scheme,n.optionalSlashes)})},onDestroy(){Pg()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!xt(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!xt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!xt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",I(this.options.HTMLAttributes,n),0]:["a",I(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!xt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!xt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ze({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,s=ld(n).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!xt(o,t),protocols:t,defaultProtocol:r}));s.length&&s.forEach(i=>e.push({text:i.value,data:{href:i.href},index:i.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(Hg({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!xt(s,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(Fg({type:this.type})),this.options.linkOnPaste&&n.push($g({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),Wg=ce.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(n){return n!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sub",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setSubscript:()=>({commands:n})=>n.setMark(this.name),toggleSubscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSubscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),jg=ce.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(n){return n!=="super"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sup",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setSuperscript:()=>({commands:n})=>n.setMark(this.name),toggleSuperscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSuperscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});var Zi,eo;if(typeof WeakMap<"u"){let n=new WeakMap;Zi=e=>n.get(e),eo=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Zi=r=>{for(let s=0;s<n.length;s+=2)if(n[s]==r)return n[s+1]},eo=(r,s)=>(t==10&&(t=0),n[t++]=r,n[t++]=s)}var L=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==t;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:s,top:i,bottom:o}=this.findCell(n);return e=="horiz"?(t<0?r==0:s==this.width)?null:this.map[i*this.width+(t<0?r-1:s)]:(t<0?i==0:o==this.height)?null:this.map[r+this.width*(t<0?i-1:o)]}rectBetween(n,e){const{left:t,right:r,top:s,bottom:i}=this.findCell(n),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,o),top:Math.min(s,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let s=n.left;s<n.right;s++){const i=r*this.width+s,o=this.map[i];t[o]||(t[o]=!0,!(s==n.left&&s&&this.map[i-1]==o||r==n.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(n,e,t){for(let r=0,s=0;;r++){const i=s+t.child(r).nodeSize;if(r==n){let o=e+n*this.width;const l=(n+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(n){return Zi(n)||eo(n,Kg(n))}};function Kg(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=Ug(n),t=n.childCount,r=[];let s=0,i=null;const o=[];for(let c=0,d=e*t;c<d;c++)r[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==u.childCount)break;const m=u.child(p),{colspan:g,rowspan:y,colwidth:S}=m.attrs;for(let A=0;A<y;A++){if(A+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:y-A});break}const R=s+A*e;for(let M=0;M<g;M++){r[R+M]==0?r[R+M]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:g-M});const v=S&&S[M];if(v){const V=(R+M)%e*2,U=o[V];U==null||U!=v&&o[V+1]==1?(o[V]=v,o[V+1]=1):U==v&&o[V+1]++}}}s+=g,d+=m.nodeSize}const f=(c+1)*e;let h=0;for(;s<f;)r[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),d++}(e===0||t===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new L(e,t,r,i);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&Jg(l,o,n),l}function Ug(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const s=n.child(r);let i=0;if(t)for(let o=0;o<r;o++){const l=n.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function Jg(n,e,t){n.problems||(n.problems=[]);const r={};for(let s=0;s<n.map.length;s++){const i=n.map[s];if(r[i])continue;r[i]=!0;const o=t.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const d=(s+c)%n.width,u=e[d*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=qg(a)))[c]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function qg(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function ie(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],s=r.spec.tableRole;s&&(e[s]=r)}}return e}var st=new q("selectingCells");function Jt(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function _g(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Ce(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Qr(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Jt(e.$head)||Gg(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Gg(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function to(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Yg(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function no(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function cd(n,e,t){const r=n.node(-1),s=L.get(r),i=n.start(-1),o=s.nextCell(n.pos-i,e,t);return o==null?null:n.node(0).resolve(i+o)}function Mt(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function dd(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<t;s++)r.colwidth.splice(e,0,0)}return r}function Xg(n,e,t){const r=ie(e.type.schema).header_cell;for(let s=0;s<n.height;s++)if(e.nodeAt(n.map[t+s*n.width]).type!=r)return!1;return!0}var P=class Ke extends E{constructor(e,t=e){const r=e.node(-1),s=L.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=s.cellsInRect(o).filter(d=>d!=t.pos-i);a.unshift(t.pos-i);const c=a.map(d=>{const u=r.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const f=i+d+1;return new cl(l.resolve(f),l.resolve(f+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(to(r)&&to(s)&&no(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Ke.rowSelection(r,s):i&&this.isColSelection()?Ke.colSelection(r,s):new Ke(r,s)}return T.between(r,s)}content(){const e=this.$anchorCell.node(-1),t=L.get(e),r=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let d=a*t.width+s.left,u=s.left;u<s.right;u++,d++){const f=t.map[d];if(i[f])continue;i[f]=!0;const h=t.findCell(f);let p=e.nodeAt(f);if(!p)throw RangeError(`No cell with offset ${f} found`);const m=s.left-h.left,g=h.right-s.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=Mt(y,0,m)),g>0&&(y=Mt(y,y.colspan-g,g)),h.left<s.left){if(p=p.type.createAndFill(y),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(h.top<s.top||h.bottom>s.bottom){const y={...p.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}o.push(e.child(a).copy(b.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new w(b.from(l),1,1)}replace(e,t=w.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:a}=s[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?w.empty:t)}const i=E.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new w(b.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=L.get(t),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(t.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),s=L.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(i+s.map[o.left])),l.bottom<s.height&&(t=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new Ke(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=L.get(e),r=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-r),i=t.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==t.width}eq(e){return e instanceof Ke&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),s=L.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(t=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=a.resolve(i+s.map[s.width*(o.top+1)-1]))),new Ke(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Ke(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Ke(e.resolve(t),e.resolve(r))}getBookmark(){return new Qg(this.$anchorCell.pos,this.$headCell.pos)}};P.prototype.visible=!1,E.jsonID("cell",P);var Qg=class Kd{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Kd(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&no(t,r)?new P(t,r):E.near(r,1)}};function Zg(n){if(!(n.selection instanceof P))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(X.node(r,r+t.nodeSize,{class:"selectedCell"}))}),z.create(n.doc,e)}function ey({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(s).type.spec.tableRole)}function ty({$from:n,$to:e}){let t,r;for(let s=n.depth;s>0;s--){const i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function ny(n,e,t){const r=(e||n).selection,s=(e||n).doc;let i,o;if(r instanceof x&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=P.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=P.rowSelection(l,l)}else if(!t){const l=L.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=P.create(s,a+1,c)}}else r instanceof T&&ey(r)?i=T.create(s,r.from):r instanceof T&&ty(r)&&(i=T.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var ry=new q("fix-tables");function ud(n,e,t,r){const s=n.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){const a=e.child(o);for(let c=l,d=Math.min(s,o+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<s&&n.child(l).sameMarkup(a)?ud(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function fd(n,e){let t;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(t=sy(n,s,i,t))};return e?e.doc!=n.doc&&ud(e.doc,n.doc,0,r):n.doc.descendants(r),t}function sy(n,e,t,r){const s=L.get(e);if(!s.problems)return r;r||(r=n.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let f=0;f<u.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Mt(u,u.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(t);r.delete(d,d+e.nodeSize)}}let o,l;for(let a=0;a<i.length;a++)i[a]&&(o==null&&(o=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const d=e.child(a),u=c+d.nodeSize,f=i[a];if(f>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<f;g++){const y=ie(n.schema)[h].createAndFill();y&&p.push(y)}const m=(a==0||o==a-1)&&l==a?c+1:u-1;r.insert(r.mapping.map(m),p)}c=u}return r.setMeta(ry,{fixTables:!0})}function Re(n){const e=n.selection,t=Qr(n),r=t.node(-1),s=t.start(-1),i=L.get(r);return{...e instanceof P?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(t.pos-s),tableStart:s,map:i,table:r}}function hd(n,{map:e,tableStart:t,table:r},s){let i=s>0?-1:0;Xg(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,dd(c.attrs,s-e.colCount(a))),o+=c.attrs.rowspan-1}else{const a=i==null?ie(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(o,s,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function iy(n,e){if(!Ce(n))return!1;if(e){const t=Re(n);e(hd(n.tr,t,t.left))}return!0}function oy(n,e){if(!Ce(n))return!1;if(e){const t=Re(n);e(hd(n.tr,t,t.right))}return!0}function ly(n,{map:e,table:t,tableStart:r},s){const i=n.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+s,a=e.map[l],c=t.nodeAt(a),d=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(i).map(r+a),null,Mt(d,s-e.colCount(a)));else{const u=n.mapping.slice(i).map(r+a);n.delete(u,u+c.nodeSize)}o+=d.rowspan}}function ay(n,e){if(!Ce(n))return!1;if(e){const t=Re(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let s=t.right-1;ly(r,t,s),s!=t.left;s--){const i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw RangeError("No table found");t.table=i,t.map=L.get(i)}e(r)}return!0}function cy(n,e,t){var r;const s=ie(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(((r=e.nodeAt(n.map[i+t*n.width]))==null?void 0:r.type)!=s)return!1;return!0}function pd(n,{map:e,tableStart:t,table:r},s){var i;let o=t;for(let c=0;c<s;c++)o+=r.child(c).nodeSize;const l=[];let a=s>0?-1:0;cy(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let c=0,d=e.width*s;c<e.width;c++,d++)if(s>0&&s<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],f=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{const u=a==null?ie(r.type.schema).cell:(i=r.nodeAt(e.map[d+a*e.width]))==null?void 0:i.type,f=u?.createAndFill();f&&l.push(f)}return n.insert(o,ie(r.type.schema).row.create(null,l)),n}function dy(n,e){if(!Ce(n))return!1;if(e){const t=Re(n);e(pd(n.tr,t,t.top))}return!0}function uy(n,e){if(!Ce(n))return!1;if(e){const t=Re(n);e(pd(n.tr,t,t.bottom))}return!0}function fy(n,{map:e,table:t,tableStart:r},s){let i=0;for(let c=0;c<s;c++)i+=t.child(c).nodeSize;const o=i+t.child(s).nodeSize,l=n.mapping.maps.length;n.delete(i+r,o+r);const a=new Set;for(let c=0,d=s*e.width;c<e.width;c++,d++){const u=e.map[d];if(!a.has(u)){if(a.add(u),s>0&&u==e.map[d-e.width]){const f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(s<e.height&&u==e.map[d+e.width]){const f=t.nodeAt(u),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(s+1,c,t);n.insert(n.mapping.slice(l).map(r+m),p),c+=h.colspan-1}}}}function hy(n,e){if(!Ce(n))return!1;if(e){const t=Re(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let s=t.bottom-1;fy(r,t,s),s!=t.top;s--){const i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw RangeError("No table found");t.table=i,t.map=L.get(t.table)}e(r)}return!0}function md(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function py({width:n,height:e,map:t},r){let s=r.top*n+r.left,i=s,o=(r.bottom-1)*n+r.left,l=s+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[l]==t[l+1])return!0;i+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[s]==t[s-n]||r.bottom<e&&t[o]==t[o+n])return!0;s++,o++}return!1}function gd(n,e){const t=n.selection;if(!(t instanceof P)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=Re(n),{map:s}=r;if(py(s,r))return!1;if(e){const i=n.tr,o={};let l=b.empty,a,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const f=s.map[d*s.width+u],h=r.table.nodeAt(f);if(!(o[f]||!h))if(o[f]=!0,a==null)a=f,c=h;else{md(h)||(l=l.append(h.content));const p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...dd(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const d=a+1+c.content.size,u=md(c)?a+1:d;i.replaceWith(u+r.tableStart,d+r.tableStart,l)}i.setSelection(new P(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function yd(n,e){const t=ie(n.schema);return my(({node:r})=>t[r.type.spec.tableRole])(n,e)}function my(n){return(e,t)=>{var r;const s=e.selection;let i,o;if(s instanceof P){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;i=s.$anchorCell.nodeAfter,o=s.$anchorCell.pos}else{if(i=_g(s.$from),!i)return!1;o=(r=Jt(s.$from))==null?void 0:r.pos}if(i==null||o==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let l=i.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const d=Re(e),u=e.tr;for(let h=0;h<d.right-d.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=d.top;h<d.bottom;h++){let p=d.map.positionAt(h,d.left,d.table);h==d.top&&(p+=i.nodeSize);for(let m=d.left,g=0;m<d.right;m++,g++)m==d.left&&h==d.top||u.insert(f=u.mapping.map(p+d.tableStart,1),n({node:i,row:h,col:m}).createAndFill(a[g]))}u.setNodeMarkup(o,n({node:i,row:d.top,col:d.left}),a[0]),s instanceof P&&u.setSelection(new P(u.doc.resolve(s.$anchorCell.pos),f?u.doc.resolve(f):void 0)),t(u)}return!0}}function gy(n,e){return function(t,r){if(!Ce(t))return!1;const s=Qr(t);if(s.nodeAfter.attrs[n]===e)return!1;if(r){const i=t.tr;t.selection instanceof P?t.selection.forEachCell((o,l)=>{o.attrs[n]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[n]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[n]:e}),r(i)}return!0}}function yy(n){return function(e,t){if(!Ce(e))return!1;if(t){const r=ie(e.schema),s=Re(e),i=e.tr,o=s.map.cellsInRect(n=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:n=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(a=>s.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[a],r.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<o.length;a++)i.setNodeMarkup(s.tableStart+o[a],r.header_cell,l[a].attrs);t(i)}return!0}}function bd(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function zn(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?yy(n):function(t,r){if(!Ce(t))return!1;if(r){const s=ie(t.schema),i=Re(t),o=t.tr,l=bd("row",i,s),a=bd("column",i,s),d=(n==="column"?l:n==="row"?a:!1)?1:0,u=n=="column"?{left:0,top:d,right:1,bottom:i.map.height}:n=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,f=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(h=>{const p=h+i.tableStart,m=o.doc.nodeAt(p);m&&o.setNodeMarkup(p,f,m.attrs)}),r(o)}return!0}}zn("row",{useDeprecatedLogic:!0}),zn("column",{useDeprecatedLogic:!0});var by=zn("cell",{useDeprecatedLogic:!0});function ky(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,s=n.before();r>=0;r--){const i=n.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),s=n.after();r<t.childCount;r++){const i=t.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function kd(n){return function(e,t){if(!Ce(e))return!1;const r=ky(Qr(e),n);if(r==null)return!1;if(t){const s=e.doc.resolve(r);t(e.tr.setSelection(T.between(s,Yg(s))).scrollIntoView())}return!0}}function Sy(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Zr(n,e){const t=n.selection;if(!(t instanceof P))return!1;if(e){const r=n.tr,s=ie(n.schema).cell.createAndFill().content;t.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new w(s,0,0))}),r.docChanged&&e(r)}return!0}function wy(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),u=a<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=ro(ie(o).row,new w(c,d,u)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||r?ro(ie(o).row,new w(e,t,r)).content:e);else return null;return Cy(o,l)}function Cy(n,e){const t=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=i.child(o).attrs;for(let c=s;c<s+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let s=0;s<t.length;s++)r=Math.max(r,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(b.empty),t[s]<r){const i=ie(n).cell.createAndFill(),o=[];for(let l=t[s];l<r;l++)o.push(i);e[s]=e[s].append(b.from(o))}return{height:e.length,width:r,rows:e}}function ro(n,e){const t=n.createAndFill();return new Ns(t).replace(0,t.content.size,e).doc}function xy({width:n,height:e,rows:t},r,s){if(n!=r){const i=[],o=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=i[l]||0,u=0;d<r;u++){let f=a.child(u%a.childCount);d+f.attrs.colspan>r&&(f=f.type.createChecked(Mt(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),c.push(f),d+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}o.push(b.from(c))}t=o,n=r}if(e!=s){const i=[];for(let o=0,l=0;o<s;o++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);o+u.attrs.rowspan>s&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,s-u.attrs.rowspan)},u.content)),a.push(u)}i.push(b.from(a))}t=i,e=s}return{width:n,height:e,rows:t}}function My(n,e,t,r,s,i,o){const l=n.doc.type.schema,a=ie(l);let c,d;if(s>e.width)for(let u=0,f=0;u<e.height;u++){const h=t.child(u);f+=h.nodeSize;const p=[];let m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<s;g++)p.push(m);n.insert(n.mapping.slice(o).map(f-1+r),p)}if(i>e.height){const u=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,b.from(u)),h=[];for(let p=e.height;p<i;p++)h.push(f);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||d)}function Sd(n,e,t,r,s,i,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const d=o*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const f=t.nodeAt(u),{top:h,left:p}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,{...f.attrs,rowspan:o-h}),n.insert(n.mapping.slice(l).map(e.positionAt(o,p,t)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-o})),c+=f.attrs.colspan-1}}return a}function wd(n,e,t,r,s,i,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const d=c*e.width+o,u=e.map[d];if(e.map[d-1]==u){a=!0;const f=t.nodeAt(u),h=e.colCount(u),p=n.mapping.slice(l).map(u+r);n.setNodeMarkup(p,null,Mt(f.attrs,o-h,f.attrs.colspan-(o-h))),n.insert(p+f.nodeSize,f.type.createAndFill(Mt(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function Cd(n,e,t,r,s){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let o=L.get(i);const{top:l,left:a}=r,c=a+s.width,d=l+s.height,u=n.tr;let f=0;function h(){if(i=t?u.doc.nodeAt(t-1):u.doc,!i)throw new Error("No table found");o=L.get(i),f=u.mapping.maps.length}My(u,o,i,t,c,d,f)&&h(),Sd(u,o,i,t,a,c,l,f)&&h(),Sd(u,o,i,t,a,c,d,f)&&h(),wd(u,o,i,t,l,d,a,f)&&h(),wd(u,o,i,t,l,d,c,f)&&h();for(let p=l;p<d;p++){const m=o.positionAt(p,a,i),g=o.positionAt(p,c,i);u.replace(u.mapping.slice(f).map(m+t),u.mapping.slice(f).map(g+t),new w(s.rows[p-l],0,0))}h(),u.setSelection(new P(u.doc.resolve(t+o.positionAt(l,a,i)),u.doc.resolve(t+o.positionAt(d-1,c-1,i)))),e(u)}var Ty=si({ArrowLeft:ts("horiz",-1),ArrowRight:ts("horiz",1),ArrowUp:ts("vert",-1),ArrowDown:ts("vert",1),"Shift-ArrowLeft":ns("horiz",-1),"Shift-ArrowRight":ns("horiz",1),"Shift-ArrowUp":ns("vert",-1),"Shift-ArrowDown":ns("vert",1),Backspace:Zr,"Mod-Backspace":Zr,Delete:Zr,"Mod-Delete":Zr});function es(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function ts(n,e){return(t,r,s)=>{if(!s)return!1;const i=t.selection;if(i instanceof P)return es(t,r,E.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const o=xd(s,n,e);if(o==null)return!1;if(n=="horiz")return es(t,r,E.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(o),a=cd(l,n,e);let c;return a?c=E.near(a,1):e<0?c=E.near(t.doc.resolve(l.before(-1)),-1):c=E.near(t.doc.resolve(l.after(-1)),1),es(t,r,c)}}}function ns(n,e){return(t,r,s)=>{if(!s)return!1;const i=t.selection;let o;if(i instanceof P)o=i;else{const a=xd(s,n,e);if(a==null)return!1;o=new P(t.doc.resolve(a))}const l=cd(o.$headCell,n,e);return l?es(t,r,new P(o.$anchorCell,l)):!1}}function Ay(n,e){const t=n.state.doc,r=Jt(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new P(r))),!0):!1}function Ey(n,e,t){if(!Ce(n.state))return!1;let r=wy(t);const s=n.state.selection;if(s instanceof P){r||(r={width:1,height:1,rows:[b.from(ro(ie(n.state.schema).cell,t))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=L.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=xy(r,l.right-l.left,l.bottom-l.top),Cd(n.state,n.dispatch,o,l,r),!0}else if(r){const i=Qr(n.state),o=i.start(-1);return Cd(n.state,n.dispatch,o,L.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function Oy(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Md(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof P)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=Jt(n.state.selection.$anchor))!=null&&((t=so(n,e))==null?void 0:t.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(a,c){let d=so(n,c);const u=st.getState(n.state)==null;if(!d||!no(a,d))if(u)d=a;else return;const f=new P(a,d);if(u||!n.state.selection.eq(f)){const h=n.state.tr.setSelection(f);u&&h.setMeta(st,a.pos),n.dispatch(h)}}function o(){n.root.removeEventListener("mouseup",o),n.root.removeEventListener("dragstart",o),n.root.removeEventListener("mousemove",l),st.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(st,-1))}function l(a){const c=a,d=st.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(Md(n,c.target)!=r&&(u=so(n,e),!u))return o();u&&i(u,c)}n.root.addEventListener("mouseup",o),n.root.addEventListener("dragstart",o),n.root.addEventListener("mousemove",l)}function xd(n,e,t){if(!(n.state.selection instanceof T))return null;const{$head:r}=n.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((t<0?r.index(s):r.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=r.before(s),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Md(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function so(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Jt(n.state.doc.resolve(t.pos)):null}var Td=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),io(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,io(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function io(n,e,t,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let u=0,f=0;u<d.childCount;u++){const{colspan:h,colwidth:p}=d.child(u).attrs;for(let m=0;m<h;m++,f++){const g=s==f?i:p&&p[m],y=g?g+"px":"";if(l+=g||r,g||(a=!1),c)c.style.width!=y&&(c.style.width=y),c=c.nextSibling;else{const S=document.createElement("col");S.style.width=y,e.appendChild(S)}}}for(;c;){const u=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=u}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var he=new q("tableColumnResizing");function Ny({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=Td,lastColumnResizable:s=!0}={}){const i=new H({key:he,state:{init(o,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,u=ie(l.schema).table.name;return r&&d&&(d[u]=(f,h)=>new r(f,t,h)),new vy(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=he.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{Ry(o,l,n,s)},mouseleave:o=>{Dy(o)},mousedown:(o,l)=>{Iy(o,l,e,t)}},decorations:o=>{const l=he.getState(o);if(l&&l.activeHandle>-1)return Hy(o,l.activeHandle)},nodeViews:{}}});return i}var vy=class ds{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(he);if(r&&r.setHandle!=null)return new ds(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new ds(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return to(e.doc.resolve(s))||(s=-1),new ds(s,t.dragging)}return t}};function Ry(n,e,t,r){if(!n.editable)return;const s=he.getState(n.state);if(s&&!s.dragging){const i=Py(e.target);let o=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?o=Ad(n,e,"left",t):a-e.clientX<=t&&(o=Ad(n,e,"right",t))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=n.state.doc.resolve(o),a=l.node(-1),c=L.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Od(n,o)}}}function Dy(n){if(!n.editable)return;const e=he.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Od(n,-1)}function Iy(n,e,t,r){var s;if(!n.editable)return!1;const i=(s=n.dom.ownerDocument.defaultView)!=null?s:window,o=he.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=n.state.doc.nodeAt(o.activeHandle),a=Ly(n,o.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(he,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const f=he.getState(n.state);f?.dragging&&(By(n,f.activeHandle,Ed(f.dragging,u,t)),n.dispatch(n.state.tr.setMeta(he,{setDragging:null})))}function d(u){if(!u.which)return c(u);const f=he.getState(n.state);if(f&&f.dragging){const h=Ed(f.dragging,u,t);Nd(n,f.activeHandle,h,r)}}return Nd(n,o.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function Ly(n,e,{colspan:t,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=n.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function Py(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Ad(n,e,t,r){const s=t=="right"?-r:r,i=n.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,l=Jt(n.state.doc.resolve(o));if(!l)return-1;if(t=="right")return l.pos;const a=L.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Ed(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Od(n,e){n.dispatch(n.state.tr.setMeta(he,{setHandle:e}))}function By(n,e,t){const r=n.state.doc.resolve(e),s=r.node(-1),i=L.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const u=i.map[d],f=s.nodeAt(u).attrs,h=f.colspan==1?0:l-i.colCount(u);if(f.colwidth&&f.colwidth[h]==t)continue;const p=f.colwidth?f.colwidth.slice():zy(f.colspan);p[h]=t,a.setNodeMarkup(o+u,null,{...f,colwidth:p})}a.docChanged&&n.dispatch(a)}function Nd(n,e,t,r){const s=n.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=L.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let a=n.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&io(i,a.firstChild,a,r,l,t)}function zy(n){return Array(n).fill(0)}function Hy(n,e){var t;const r=[],s=n.doc.resolve(e),i=s.node(-1);if(!i)return z.empty;const o=L.get(i),l=s.start(-1),a=o.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const d=a+c*o.width;if((a==o.width-1||o.map[d]!=o.map[d+1])&&(c==0||o.map[d]!=o.map[d-o.width])){const u=o.map[d],f=l+u+i.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(t=he.getState(n))!=null&&t.dragging&&r.push(X.node(l+u,l+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),r.push(X.widget(f,h))}}return z.create(n.doc,r)}function Fy({allowTableNodeSelection:n=!1}={}){return new H({key:st,state:{init(){return null},apply(e,t){const r=e.getMeta(st);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:Zg,handleDOMEvents:{mousedown:Oy},createSelectionBetween(e){return st.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Ay,handleKeyDown:Ty,handlePaste:Ey},appendTransaction(e,t,r){return ny(r,fd(r,t),n)}})}function oo(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function vd(n,e,t,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d!==null)for(let u=0,f=0;u<d.childCount;u+=1){const{colspan:h,colwidth:p}=d.child(u).attrs;for(let m=0;m<h;m+=1,f+=1){const g=s===f?i:p&&p[m],y=g?`${g}px`:"";if(l+=g||r,g||(a=!1),c){if(c.style.width!==y){const[S,A]=oo(r,g);c.style.setProperty(S,A)}c=c.nextSibling}else{const S=document.createElement("col"),[A,R]=oo(r,g);S.style.setProperty(A,R),e.appendChild(S)}}}for(;c;){const u=c.nextSibling;(o=c.parentNode)===null||o===void 0||o.removeChild(c),c=u}a?(t.style.width=`${l}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${l}px`)}class $y{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),vd(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,vd(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function Vy(n,e,t,r){let s=0,i=!0;const o=[],l=n.firstChild;if(!l)return{};for(let u=0,f=0;u<l.childCount;u+=1){const{colspan:h,colwidth:p}=l.child(u).attrs;for(let m=0;m<h;m+=1,f+=1){const g=t===f?r:p&&p[m];s+=g||e,g||(i=!1);const[y,S]=oo(e,g);o.push(["col",{style:`${y}: ${S}`}])}}const a=i?`${s}px`:"",c=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function Rd(n,e){return n.createAndFill()}function Wy(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function jy(n,e,t,r,s){const i=Wy(n),o=[],l=[];for(let c=0;c<t;c+=1){const d=Rd(i.cell);if(d&&l.push(d),r){const u=Rd(i.header_cell);u&&o.push(u)}}const a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?o:l));return i.table.createChecked(null,a)}function Ky(n){return n instanceof P}const rs=({editor:n})=>{const{selection:e}=n.state;if(!Ky(e))return!1;let t=0;const r=wi(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},ss=$.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:$y,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){const{colgroup:t,tableWidth:r,tableMinWidth:s}=Vy(n,this.options.cellMinWidth);return["table",I(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${s}`}),t,["tbody",0]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=jy(i.schema,n,e,t);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(T.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>iy(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>oy(n,e),deleteColumn:()=>({state:n,dispatch:e})=>ay(n,e),addRowBefore:()=>({state:n,dispatch:e})=>dy(n,e),addRowAfter:()=>({state:n,dispatch:e})=>uy(n,e),deleteRow:()=>({state:n,dispatch:e})=>hy(n,e),deleteTable:()=>({state:n,dispatch:e})=>Sy(n,e),mergeCells:()=>({state:n,dispatch:e})=>gd(n,e),splitCell:()=>({state:n,dispatch:e})=>yd(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>zn("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>zn("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>by(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>gd(n,e)?!0:yd(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>gy(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>kd(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>kd(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&fd(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=P.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:rs,"Mod-Backspace":rs,Delete:rs,"Mod-Delete":rs}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Ny({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Fy({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:O(C(n,"tableRole",e))}}}),Dd=$.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",I(this.options.HTMLAttributes,n),0]}}),Id=$.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",I(this.options.HTMLAttributes,n),0]}}),Ld=$.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",I(this.options.HTMLAttributes,n),0]}}),Uy=W.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).every(e=>e)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Jy=ce.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),qy=$.create({name:"anchor",atom:!0,draggable:!0,inline:!0,group:"inline",marks:"",selectable:!0,addAttributes(){return{id:{}}},addNodeView(){return({HTMLAttributes:n})=>{const e=document.createElement("span");e.setAttribute("data-umb-anchor",""),e.setAttribute("title",n.id);const t=document.createElement("uui-icon");return t.setAttribute("name","icon-anchor"),e.appendChild(t),{dom:e}}},addOptions(){return{HTMLAttributes:{id:"id"}}},parseHTML(){return[{tag:"a[id]",getAttrs:n=>n.innerHTML===""?{}:!1}]},renderHTML({HTMLAttributes:n}){return["a",I(this.options.HTMLAttributes,n)]}}),_y=$.create({name:"div",priority:50,group:"block",content:"inline*",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:this.name}]},renderHTML({HTMLAttributes:n}){return[this.name,I(this.options.HTMLAttributes,n),0]}}),Gy=$.create({name:"figcaption",addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",selectable:!1,draggable:!1,parseHTML(){return[{tag:"figcaption"}]},renderHTML({HTMLAttributes:n}){return[this.name,n,0]}}),Yy=$.create({name:"figure",group:"block",content:"block+",draggable:!0,selectable:!0,isolating:!0,atom:!0,addAttributes(){return{figcaption:{default:""}}},addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"figure",getAttrs:n=>({figcaption:n.querySelector("figcaption")?.textContent||""})}]},renderHTML({HTMLAttributes:n}){return[this.name,I(this.options.HTMLAttributes,n),0]}}),Xy=ce.create({name:"span",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:this.name}]},renderHTML({HTMLAttributes:n}){return[this.name,I(this.options.HTMLAttributes,n),0]},addCommands(){return{setSpanStyle:n=>({commands:e,editor:t})=>{if(!n)return!1;const r=t.getAttributes(this.name)?.style;if(!r&&!t.isActive(this.name))return e.setMark(this.name,{style:n});const s=((r??"")+";"+n).split(";"),i={};s.filter(l=>l).forEach(l=>{if(l.trim()!==""){const[a,c]=l.split(":");i[a.trim()]=c.trim()}});const o=Object.entries(i).map(([l,a])=>`${l}: ${a}`).join(";");return e.updateAttributes(this.name,{style:o})}}}});function Qy(n){return n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase())}const Zy=W.create({name:"htmlGlobalAttributes",addOptions(){return{types:[]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{class:{},dataset:{parseHTML:n=>n.dataset,renderHTML:n=>{const e=n.dataset?Object.keys(n.dataset):[];if(!e.length)return{};const t={};return e.forEach(r=>{t["data-"+Qy(r)]=n.dataset[r]}),t}},id:{},style:{parseHTML:n=>n.style.length?n.style.cssText:null}}}]},addCommands(){return{setClassName:(n,e)=>({commands:t})=>n?(e?[e]:this.options.types).map(r=>t.updateAttributes(r,{class:n})).every(r=>r):!1,unsetClassName:n=>({commands:e})=>(n?[n]:this.options.types).map(t=>e.resetAttributes(t,"class")).every(t=>t),setId:(n,e)=>({commands:t})=>n?(e?[e]:this.options.types).map(r=>t.updateAttributes(r,{id:n})).every(r=>r):!1,unsetId:n=>({commands:e})=>(n?[n]:this.options.types).map(t=>e.resetAttributes(t,"id")).every(t=>t)}}}),e0=W.create({name:"textDirection",addOptions(){return{directions:["ltr","rtl","auto"],types:["heading","paragraph"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textDirection:{parseHTML:n=>n.dir,renderHTML:n=>this.options.directions.includes(n.textDirection)?{dir:n.textDirection}:null}}}]},addCommands(){return{setTextDirection:n=>({commands:e})=>this.options.directions.includes(n)?this.options.types.every(t=>e.updateAttributes(t,{textDirection:n})):!1,unsetTextDirection:()=>({commands:n})=>this.options.types.every(e=>n.resetAttributes(e,"textDirection"))}}}),t0=W.create({name:"textIndent",addOptions(){return{minLevel:0,maxLevel:5,types:["heading","paragraph","listItem","taskItem"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:null,parseHTML:n=>{const e=this.options.minLevel,t=this.options.maxLevel,r=n.style.textIndent;return r?Math.max(e,Math.min(t,parseInt(r,10))):null},renderHTML:n=>n.indent?{style:`text-indent: ${n.indent}rem;`}:{}}}}]},addCommands(){const n=(r,s,i)=>{const o=r.doc.nodeAt(s);if(!o)return r;const l=this.options.minLevel,a=this.options.maxLevel;let c=(o.attrs.indent||0)+i;return c=Math.max(l,Math.min(a,parseInt(c,10))),c===o.attrs.indent?r:r.setNodeMarkup(s,o.type,{...o.attrs,indent:c},o.marks)},e=(r,s)=>{if(r.selection instanceof T||r.selection instanceof fe){const{from:i,to:o}=r.selection;r.doc.nodesBetween(i,o,(l,a)=>this.options.types.includes(l.type.name)?(r=n(r,a,s),!1):!0)}return r},t=r=>()=>function({tr:s,state:i,dispatch:o}){const{selection:l}=i;return s.setSelection(l),s=e(s,r),s.docChanged?(o instanceof Function&&o(s),!0):!1};return{textIndent:t(1),textOutdent:t(-1)}}});function Pd({types:n,node:e}){return Array.isArray(n)&&n.includes(e.type)||e.type===n}const n0=W.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new q(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new H({key:n,appendTransaction:(t,r,s)=>{const{doc:i,tr:o,schema:l}=s,a=n.getState(s),c=i.content.size,d=l.nodes[this.options.node];if(a)return o.insert(c,d.create())},state:{init:(t,r)=>{const s=r.tr.doc.lastChild;return!Pd({node:s,types:e})},apply:(t,r)=>{if(!t.docChanged)return r;const s=t.doc.lastChild;return!Pd({node:s,types:e})}}})]}});var Bd=n=>{throw TypeError(n)},zd=(n,e,t)=>e.has(n)||Bd("Cannot "+t),De=(n,e,t)=>(zd(n,e,"read from private field"),t?t.call(n):e.get(n)),lo=(n,e,t)=>e.has(n)?Bd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),ao=(n,e,t,r)=>(zd(n,e,"write to private field"),e.set(n,t),t),is,xe,ls;const r0=W.create({name:"umbBubbleMenu",addOptions(){return{unique:"umb-tiptap-menu",placement:"top",elementName:null,shouldShow:null}},addProseMirrorPlugins(){return!this.options.unique||!this.options.elementName?[]:[as(this.editor,{unique:this.options.unique,placement:this.options.placement,elementName:this.options.elementName,shouldShow:this.options.shouldShow})]}});class s0{constructor(e,t,r){if(lo(this,is),lo(this,xe),lo(this,ls),ao(this,is,e),ao(this,ls,r.shouldShow??null),ao(this,xe,document.createElement("uui-popover-container")),De(this,xe).id=r.unique,De(this,xe).setAttribute("placement",r.placement??"top"),De(this,xe).setAttribute("popover","manual"),r.elementName){const s=document.createElement(r.elementName);s.editor=e,De(this,xe).appendChild(s)}t.dom.parentNode?.appendChild(De(this,xe)),this.update(t,null)}update(e,t){var r;const s=De(this,is),{state:i}=e,{selection:o}=i,{ranges:l}=o,a=Math.min(...l.map(d=>d.$from.pos)),c=Math.max(...l.map(d=>d.$to.pos));(r=De(this,ls))!=null&&r.call(this,{editor:s,view:e,state:i,from:a,to:c})?De(this,xe).showPopover():De(this,xe).hidePopover()}destroy(){De(this,xe).remove()}}is=new WeakMap,xe=new WeakMap,ls=new WeakMap;const as=(n,e)=>new H({view(t){return new s0(n,t,e)}}),i0=$.create({name:"umbEmbeddedMedia",group(){return this.options.inline?"inline":"block"},inline(){return this.options.inline},atom:!0,marks:"",draggable:!0,selectable:!0,addAttributes(){return{"data-embed-constrain":{default:!1},"data-embed-height":{default:240},"data-embed-url":{default:null},"data-embed-width":{default:360},markup:{default:null,parseHTML:n=>n.innerHTML}}},parseHTML(){return[{tag:"div",priority:100,getAttrs:n=>n.classList.contains("umb-embed-holder")&&null}]},renderHTML({HTMLAttributes:n}){const{markup:e,...t}=n,r=document.createRange().createContextualFragment(e);return["div",I({class:"umb-embed-holder"},t),r]},addCommands(){return{setEmbeddedMedia:n=>({commands:e})=>{const t={markup:n.markup,"data-embed-url":n.url,"data-embed-width":n.width,"data-embed-height":n.height,"data-embed-constrain":n.constrain};return e.insertContent({type:this.name,attrs:t})}}}}),o0=Uc.extend({addAttributes(){return{...this.parent?.(),width:{default:null},height:{default:null},loading:{default:null},srcset:{default:null},sizes:{default:null},"data-tmpimg":{default:null},"data-udi":{default:null}}}}),l0=ad.extend({name:"umbLink",addAttributes(){return{...this.parent?.(),"data-anchor":{default:null},title:{default:null},type:{default:"external"}}},addOptions(){return{...this.parent?.(),HTMLAttributes:{target:"","data-router-slot":"disabled"}}},addCommands(){return{setUmbLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),unsetUmbLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}}});var Hd=n=>{throw TypeError(n)},a0=(n,e,t)=>e.has(n)||Hd("Cannot "+t),c0=(n,e,t)=>e.has(n)?Hd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),Fd=(n,e,t)=>(a0(n,e,"access private method"),t),cs,co;class $d extends Td{constructor(e,t){super(e,t),c0(this,cs),Fd(this,cs,co).call(this,e)}update(e){return super.update(e)?(Fd(this,cs,co).call(this,e),!0):!1}}cs=new WeakSet,co=function(n){if(n.attrs.style){const e=this.table.style.minWidth,t=n.attrs.style;this.table.style.cssText=`${t}; min-width: ${e};`}};const d0=ss.configure({resizable:!0,View:$d}),u0=Ld.extend({allowGapCursor:!1}),f0=Id.extend({addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(t=>parseInt(t,10)):null}},style:{default:null}}},addProseMirrorPlugins(){const{editor:n}=this;return[as(this.editor,{unique:"table-column-menu",placement:"top",elementName:"umb-tiptap-table-column-menu",shouldShow(e){return S0(e)}}),new H({props:{decorations:e=>{const{isEditable:t}=this.editor;if(!t)return z.empty;const{doc:r,selection:s}=e,i=[],o=y0(0)(s);return o&&o.forEach(({pos:l},a)=>{i.push(X.widget(l+1,()=>{const c=p0(a)(s),d=document.createElement("a");return d.appendChild(document.createElement("uui-symbol-more")),d.className=c?"grip-column selected":"grip-column",d.setAttribute("popovertarget",c?"table-column-menu":""),d.addEventListener("mousedown",u=>{u.preventDefault(),u.stopImmediatePropagation(),this.editor.view.dispatch(b0(a)(this.editor.state.tr))}),d}))}),z.create(r,i)}}})]}}),h0=Dd.extend({addAttributes(){return{colspan:{default:1,parseHTML:n=>{const e=n.getAttribute("colspan");return e?parseInt(e,10):1}},rowspan:{default:1,parseHTML:n=>{const e=n.getAttribute("rowspan");return e?parseInt(e,10):1}},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}},style:{default:null}}},addProseMirrorPlugins(){const{editor:n}=this;return[as(this.editor,{unique:"table-row-menu",placement:"left",elementName:"umb-tiptap-table-row-menu",shouldShow(e){return w0(e)}}),new H({props:{decorations:e=>{const{isEditable:t}=this.editor;if(!t)return z.empty;const{doc:r,selection:s}=e,i=[],o=g0(0)(s);return o&&o.forEach(({pos:l},a)=>{i.push(X.widget(l+1,()=>{const c=m0(a)(s),d=document.createElement("a");return d.appendChild(document.createElement("uui-symbol-more")),d.className=c?"grip-row selected":"grip-row",d.setAttribute("popovertarget",c?"table-row-menu":""),d.addEventListener("mousedown",u=>{u.preventDefault(),u.stopImmediatePropagation(),this.editor.view.dispatch(k0(a)(this.editor.state.tr))}),d}))}),z.create(r,i)}}})]}}),uo=n=>e=>{const t=L.get(e.$anchorCell.node(-1)),r=e.$anchorCell.start(-1),s=t.cellsInRect(n),i=t.cellsInRect(t.rectBetween(e.$anchorCell.pos-r,e.$headCell.pos-r));for(let o=0,l=s.length;o<l;o+=1)if(i.indexOf(s[o])===-1)return!1;return!0},fo=n=>Wt(e=>e.type.spec.tableRole&&e.type.spec.tableRole==="table")(n),ho=n=>n instanceof P,p0=n=>e=>{if(ho(e)){const t=L.get(e.$anchorCell.node(-1));return uo({left:n,right:n+1,top:0,bottom:t.height})(e)}return!1},m0=n=>e=>{if(ho(e)){const t=L.get(e.$anchorCell.node(-1));return uo({left:0,right:t.width,top:n,bottom:n+1})(e)}return!1},Vd=n=>{if(ho(n)){const e=L.get(n.$anchorCell.node(-1));return uo({left:0,right:e.width,top:0,bottom:e.height})(n)}return!1},g0=n=>e=>{const t=fo(e);if(t){const r=L.get(t.node);return(Array.isArray(n)?n:Array.from([n])).reduce((s,i)=>{if(i>=0&&i<=r.width-1){const o=r.cellsInRect({left:i,right:i+1,top:0,bottom:r.height});return s.concat(o.map(l=>{const a=t.node.nodeAt(l),c=l+t.start;return{pos:c,start:c+1,node:a}}))}return s},[])}return null},y0=n=>e=>{const t=fo(e);if(t){const r=L.get(t.node);return(Array.isArray(n)?n:Array.from([n])).reduce((s,i)=>{if(i>=0&&i<=r.height-1){const o=r.cellsInRect({left:0,right:r.width,top:i,bottom:i+1});return s.concat(o.map(l=>{const a=t.node.nodeAt(l),c=l+t.start;return{pos:c,start:c+1,node:a}}))}return s},[])}return null},Wd=n=>e=>t=>{const r=fo(t.selection),s=n==="row";if(r){const i=L.get(r.node);if(e>=0&&e<(s?i.height:i.width)){const o=s?0:e,l=s?e:0,a=s?i.width:e+1,c=s?e+1:i.height,d=i.cellsInRect({left:o,top:l,right:s?a:o+1,bottom:s?l+1:c}),u=c-l===1?d:i.cellsInRect({left:s?o:a-1,top:s?c-1:l,right:a,bottom:c}),f=r.start+d[0],h=r.start+u[u.length-1],p=t.doc.resolve(f),m=t.doc.resolve(h);return t.setSelection(new P(m,p))}}return t},b0=Wd("column"),k0=Wd("row"),S0=({editor:n,view:e,state:t,from:r})=>{const s=e.domAtPos(r).node,i=e.nodeDOM(r)||s;if(!n.isActive(ss.name)||!i||Vd(t.selection))return!1;let o=i;for(;o&&!["TD","TH"].includes(o.tagName);)o=o.parentElement;return!!(o&&o.querySelector&&o.querySelector("a.grip-column.selected"))},w0=({editor:n,view:e,state:t,from:r})=>{const s=e.domAtPos(r).node,i=e.nodeDOM(r)||s;if(!n.isActive(ss.name)||!i||Vd(t.selection))return!1;let o=i;for(;o&&!["TD","TH"].includes(o.tagName);)o=o.parentElement;return!!(o&&o.querySelector&&o.querySelector("a.grip-row.selected"))};export{qy as Anchor,Mc as Blockquote,Tc as Bold,Oc as BulletList,bg as CharacterCount,Nc as Code,vc as CodeBlock,gn as CommandManager,_y as Div,bm as Editor,W as Extension,Gy as Figcaption,Yy as Figure,Rc as Heading,Hc as HorizontalRule,Zy as HtmlGlobalAttributes,Uc as Image,Ft as InputRule,Fc as Italic,ad as Link,$c as ListItem,ce as Mark,$ as Node,at as NodePos,Sm as NodeView,jc as OrderedList,cr as PasteRule,mg as Placeholder,Xy as Span,pg as StarterKit,Kc as Strike,Wg as Subscript,jg as Superscript,ss as Table,Dd as TableCell,Id as TableHeader,Ld as TableRow,Uy as TextAlign,e0 as TextDirection,t0 as TextIndent,yg as TextStyle,Tm as Tracker,n0 as TrailingNode,r0 as UmbBubbleMenu,as as UmbBubbleMenuPlugin,o0 as UmbImage,l0 as UmbLink,d0 as UmbTable,h0 as UmbTableCell,f0 as UmbTableHeader,u0 as UmbTableRow,$d as UmbTableView,Jy as Underline,O as callOrReturn,sc as combineTransactionSteps,mn as createChainableState,hr as createDocument,xn as createNodeFromContent,xc as createStyleTag,ic as defaultBlockAt,ki as deleteProps,$t as elementFromString,wm as escapeForRegEx,gm as extensions,$p as findChildren,oc as findChildrenInRange,Xa as findDuplicates,Wt as findParentNode,wi as findParentNodeClosestToPos,Ua as fromString,Vp as generateHTML,Wp as generateJSON,jp as generateText,xi as getAttributes,di as getAttributesFromExtensions,cc as getChangedRanges,dc as getDebugJSON,C as getExtensionField,bn as getHTMLFromFragment,Si as getMarkAttributes,fr as getMarkRange,$e as getMarkType,mr as getMarksBetween,Up as getNodeAtPosition,lc as getNodeAttributes,_ as getNodeType,ir as getRenderedAttributes,pr as getSchema,hi as getSchemaByResolvedExtensions,or as getSchemaTypeByName,Mn as getSchemaTypeNameByName,Tn as getSplittedAttributes,Ci as getText,mi as getTextBetween,qa as getTextContentFromNodes,ur as getTextSerializersFromSchema,fi as injectExtensionAttributesToParseRule,_a as inputRulesPlugin,uc as isActive,Jp as isAtEndOfNode,qp as isAtStartOfNode,Ka as isEmptyObject,pi as isExtensionRulesEnabled,ui as isFunction,Mi as isList,bi as isMacOS,gr as isMarkActive,Vt as isNodeActive,An as isNodeEmpty,fc as isNodeSelection,Ga as isNumber,kn as isPlainObject,lr as isRegExp,Cm as isString,gi as isTextSelection,Cn as isiOS,St as markInputRule,Ze as markPasteRule,I as mergeAttributes,Sn as mergeDeep,Oe as minMax,Ei as nodeInputRule,xm as nodePasteRule,wn as objectIncludes,Ya as pasteRulesPlugin,_p as posToDOMRect,ac as removeDuplicates,yi as resolveFocusPosition,Gp as rewriteUnknownContent,rc as selectionToInsertionEnd,yn as splitExtensions,km as textInputRule,Mm as textPasteRule,yr as textblockTypeInputRule,i0 as umbEmbeddedMedia,jt as wrappingInputRule};
99
+ 3. "-" cannot repeat`);F.customSchemes.push([n,e])}function Hg(){F.scanner=vg(F.customSchemes);for(let n=0;n<F.tokenQueue.length;n++)F.tokenQueue[n][1]({scanner:F.scanner});F.parser=Ig(F.scanner.tokens);for(let n=0;n<F.pluginQueue.length;n++)F.pluginQueue[n][1]({scanner:F.scanner,parser:F.parser});return F.initialized=!0,F}function Zi(n){return F.initialized||Hg(),Lg(F.parser.start,n,td(F.scanner.start,n))}Zi.scan=td;function ad(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Xi(t),s=Zi(n),i=[];for(let o=0;o<s.length;o++){const l=s[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}function Fg(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function $g(n){return new H({key:new q("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,l=ic(t.doc,[...e]);if(dc(l).forEach(({newRange:c})=>{const d=lc(r.doc,c,h=>h.isTextblock);let u,f;if(d.length>1?(u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ")):d.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")),u&&f){const h=f.split(" ").filter(y=>y!=="");if(h.length<=0)return!1;const p=h[h.length-1],m=u.pos+f.lastIndexOf(p);if(!p)return!1;const g=Zi(p).map(y=>y.toObject(n.defaultProtocol));if(!Fg(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>n.validate(y.value)).filter(y=>n.shouldAutoLink(y.value)).forEach(y=>{mr(y.from,y.to,r.doc).some(S=>S.mark.type===n.type)||o.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function Vg(n){return new H({key:new q("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=r.target;const l=[];for(;o.nodeName!=="DIV";)l.push(o),o=o.parentNode;if(!l.find(f=>f.nodeName==="A"))return!1;const a=Mi(e.state,n.type.name),c=r.target,d=(s=c?.href)!==null&&s!==void 0?s:a.href,u=(i=c?.target)!==null&&i!==void 0?i:a.target;return c&&d?(window.open(d,u),!0):!1}}})}function Wg(n){return new H({key:new q("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:s}=e,{selection:i}=s,{empty:o}=i;if(o)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});const a=ad(l,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:n.editor.commands.setMark(n.type,{href:a.href})}}})}const jg=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function xt(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&t.push(s)}),!n||n.replace(jg,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const cd=ce.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){ld(n);return}ld(n.scheme,n.optionalSlashes)})},onDestroy(){zg()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!xt(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!xt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!xt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",I(this.options.HTMLAttributes,n),0]:["a",I(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!xt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!xt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ze({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,s=ad(n).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!xt(o,t),protocols:t,defaultProtocol:r}));s.length&&s.forEach(i=>e.push({text:i.value,data:{href:i.href},index:i.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push($g({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!xt(s,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(Vg({type:this.type})),this.options.linkOnPaste&&n.push(Wg({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),Kg=ce.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(n){return n!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sub",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setSubscript:()=>({commands:n})=>n.setMark(this.name),toggleSubscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSubscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),Ug=ce.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(n){return n!=="super"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sup",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setSuperscript:()=>({commands:n})=>n.setMark(this.name),toggleSuperscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSuperscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});var eo,to;if(typeof WeakMap<"u"){let n=new WeakMap;eo=e=>n.get(e),to=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;eo=r=>{for(let s=0;s<n.length;s+=2)if(n[s]==r)return n[s+1]},to=(r,s)=>(t==10&&(t=0),n[t++]=r,n[t++]=s)}var L=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==t;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:s,top:i,bottom:o}=this.findCell(n);return e=="horiz"?(t<0?r==0:s==this.width)?null:this.map[i*this.width+(t<0?r-1:s)]:(t<0?i==0:o==this.height)?null:this.map[r+this.width*(t<0?i-1:o)]}rectBetween(n,e){const{left:t,right:r,top:s,bottom:i}=this.findCell(n),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,o),top:Math.min(s,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let s=n.left;s<n.right;s++){const i=r*this.width+s,o=this.map[i];t[o]||(t[o]=!0,!(s==n.left&&s&&this.map[i-1]==o||r==n.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(n,e,t){for(let r=0,s=0;;r++){const i=s+t.child(r).nodeSize;if(r==n){let o=e+n*this.width;const l=(n+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(n){return eo(n)||to(n,Jg(n))}};function Jg(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=qg(n),t=n.childCount,r=[];let s=0,i=null;const o=[];for(let c=0,d=e*t;c<d;c++)r[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==u.childCount)break;const m=u.child(p),{colspan:g,rowspan:y,colwidth:S}=m.attrs;for(let A=0;A<y;A++){if(A+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:y-A});break}const R=s+A*e;for(let M=0;M<g;M++){r[R+M]==0?r[R+M]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:g-M});const v=S&&S[M];if(v){const V=(R+M)%e*2,U=o[V];U==null||U!=v&&o[V+1]==1?(o[V]=v,o[V+1]=1):U==v&&o[V+1]++}}}s+=g,d+=m.nodeSize}const f=(c+1)*e;let h=0;for(;s<f;)r[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),d++}(e===0||t===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new L(e,t,r,i);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&_g(l,o,n),l}function qg(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const s=n.child(r);let i=0;if(t)for(let o=0;o<r;o++){const l=n.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function _g(n,e,t){n.problems||(n.problems=[]);const r={};for(let s=0;s<n.map.length;s++){const i=n.map[s];if(r[i])continue;r[i]=!0;const o=t.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const d=(s+c)%n.width,u=e[d*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=Gg(a)))[c]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function Gg(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function ie(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],s=r.spec.tableRole;s&&(e[s]=r)}}return e}var st=new q("selectingCells");function Jt(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function Yg(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Ce(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Qr(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Jt(e.$head)||Xg(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Xg(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function no(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Qg(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function ro(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function dd(n,e,t){const r=n.node(-1),s=L.get(r),i=n.start(-1),o=s.nextCell(n.pos-i,e,t);return o==null?null:n.node(0).resolve(i+o)}function Mt(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function ud(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<t;s++)r.colwidth.splice(e,0,0)}return r}function Zg(n,e,t){const r=ie(e.type.schema).header_cell;for(let s=0;s<n.height;s++)if(e.nodeAt(n.map[t+s*n.width]).type!=r)return!1;return!0}var P=class Ke extends E{constructor(e,t=e){const r=e.node(-1),s=L.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=s.cellsInRect(o).filter(d=>d!=t.pos-i);a.unshift(t.pos-i);const c=a.map(d=>{const u=r.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const f=i+d+1;return new dl(l.resolve(f),l.resolve(f+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(no(r)&&no(s)&&ro(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Ke.rowSelection(r,s):i&&this.isColSelection()?Ke.colSelection(r,s):new Ke(r,s)}return T.between(r,s)}content(){const e=this.$anchorCell.node(-1),t=L.get(e),r=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let d=a*t.width+s.left,u=s.left;u<s.right;u++,d++){const f=t.map[d];if(i[f])continue;i[f]=!0;const h=t.findCell(f);let p=e.nodeAt(f);if(!p)throw RangeError(`No cell with offset ${f} found`);const m=s.left-h.left,g=h.right-s.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=Mt(y,0,m)),g>0&&(y=Mt(y,y.colspan-g,g)),h.left<s.left){if(p=p.type.createAndFill(y),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(h.top<s.top||h.bottom>s.bottom){const y={...p.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}o.push(e.child(a).copy(b.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new w(b.from(l),1,1)}replace(e,t=w.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:a}=s[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?w.empty:t)}const i=E.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new w(b.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=L.get(t),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(t.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),s=L.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(i+s.map[o.left])),l.bottom<s.height&&(t=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new Ke(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=L.get(e),r=this.$anchorCell.start(-1),s=t.colCount(this.$anchorCell.pos-r),i=t.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==t.width}eq(e){return e instanceof Ke&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),s=L.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(t.pos-i),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(t=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=a.resolve(i+s.map[s.width*(o.top+1)-1]))),new Ke(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Ke(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Ke(e.resolve(t),e.resolve(r))}getBookmark(){return new ey(this.$anchorCell.pos,this.$headCell.pos)}};P.prototype.visible=!1,E.jsonID("cell",P);var ey=class Jd{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Jd(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&ro(t,r)?new P(t,r):E.near(r,1)}};function ty(n){if(!(n.selection instanceof P))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(X.node(r,r+t.nodeSize,{class:"selectedCell"}))}),z.create(n.doc,e)}function ny({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(s).type.spec.tableRole)}function ry({$from:n,$to:e}){let t,r;for(let s=n.depth;s>0;s--){const i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function sy(n,e,t){const r=(e||n).selection,s=(e||n).doc;let i,o;if(r instanceof x&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=P.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=P.rowSelection(l,l)}else if(!t){const l=L.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=P.create(s,a+1,c)}}else r instanceof T&&ny(r)?i=T.create(s,r.from):r instanceof T&&ry(r)&&(i=T.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var iy=new q("fix-tables");function fd(n,e,t,r){const s=n.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){const a=e.child(o);for(let c=l,d=Math.min(s,o+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<s&&n.child(l).sameMarkup(a)?fd(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function hd(n,e){let t;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(t=oy(n,s,i,t))};return e?e.doc!=n.doc&&fd(e.doc,n.doc,0,r):n.doc.descendants(r),t}function oy(n,e,t,r){const s=L.get(e);if(!s.problems)return r;r||(r=n.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let f=0;f<u.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Mt(u,u.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(t);r.delete(d,d+e.nodeSize)}}let o,l;for(let a=0;a<i.length;a++)i[a]&&(o==null&&(o=a),l=a);for(let a=0,c=t+1;a<s.height;a++){const d=e.child(a),u=c+d.nodeSize,f=i[a];if(f>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<f;g++){const y=ie(n.schema)[h].createAndFill();y&&p.push(y)}const m=(a==0||o==a-1)&&l==a?c+1:u-1;r.insert(r.mapping.map(m),p)}c=u}return r.setMeta(iy,{fixTables:!0})}function Re(n){const e=n.selection,t=Qr(n),r=t.node(-1),s=t.start(-1),i=L.get(r);return{...e instanceof P?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(t.pos-s),tableStart:s,map:i,table:r}}function pd(n,{map:e,tableStart:t,table:r},s){let i=s>0?-1:0;Zg(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,ud(c.attrs,s-e.colCount(a))),o+=c.attrs.rowspan-1}else{const a=i==null?ie(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(o,s,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function ly(n,e){if(!Ce(n))return!1;if(e){const t=Re(n);e(pd(n.tr,t,t.left))}return!0}function ay(n,e){if(!Ce(n))return!1;if(e){const t=Re(n);e(pd(n.tr,t,t.right))}return!0}function cy(n,{map:e,table:t,tableStart:r},s){const i=n.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+s,a=e.map[l],c=t.nodeAt(a),d=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(i).map(r+a),null,Mt(d,s-e.colCount(a)));else{const u=n.mapping.slice(i).map(r+a);n.delete(u,u+c.nodeSize)}o+=d.rowspan}}function dy(n,e){if(!Ce(n))return!1;if(e){const t=Re(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let s=t.right-1;cy(r,t,s),s!=t.left;s--){const i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw RangeError("No table found");t.table=i,t.map=L.get(i)}e(r)}return!0}function uy(n,e,t){var r;const s=ie(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(((r=e.nodeAt(n.map[i+t*n.width]))==null?void 0:r.type)!=s)return!1;return!0}function md(n,{map:e,tableStart:t,table:r},s){var i;let o=t;for(let c=0;c<s;c++)o+=r.child(c).nodeSize;const l=[];let a=s>0?-1:0;uy(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let c=0,d=e.width*s;c<e.width;c++,d++)if(s>0&&s<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],f=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{const u=a==null?ie(r.type.schema).cell:(i=r.nodeAt(e.map[d+a*e.width]))==null?void 0:i.type,f=u?.createAndFill();f&&l.push(f)}return n.insert(o,ie(r.type.schema).row.create(null,l)),n}function fy(n,e){if(!Ce(n))return!1;if(e){const t=Re(n);e(md(n.tr,t,t.top))}return!0}function hy(n,e){if(!Ce(n))return!1;if(e){const t=Re(n);e(md(n.tr,t,t.bottom))}return!0}function py(n,{map:e,table:t,tableStart:r},s){let i=0;for(let c=0;c<s;c++)i+=t.child(c).nodeSize;const o=i+t.child(s).nodeSize,l=n.mapping.maps.length;n.delete(i+r,o+r);const a=new Set;for(let c=0,d=s*e.width;c<e.width;c++,d++){const u=e.map[d];if(!a.has(u)){if(a.add(u),s>0&&u==e.map[d-e.width]){const f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(s<e.height&&u==e.map[d+e.width]){const f=t.nodeAt(u),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(s+1,c,t);n.insert(n.mapping.slice(l).map(r+m),p),c+=h.colspan-1}}}}function my(n,e){if(!Ce(n))return!1;if(e){const t=Re(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let s=t.bottom-1;py(r,t,s),s!=t.top;s--){const i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw RangeError("No table found");t.table=i,t.map=L.get(t.table)}e(r)}return!0}function gd(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function gy({width:n,height:e,map:t},r){let s=r.top*n+r.left,i=s,o=(r.bottom-1)*n+r.left,l=s+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[l]==t[l+1])return!0;i+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[s]==t[s-n]||r.bottom<e&&t[o]==t[o+n])return!0;s++,o++}return!1}function yd(n,e){const t=n.selection;if(!(t instanceof P)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=Re(n),{map:s}=r;if(gy(s,r))return!1;if(e){const i=n.tr,o={};let l=b.empty,a,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const f=s.map[d*s.width+u],h=r.table.nodeAt(f);if(!(o[f]||!h))if(o[f]=!0,a==null)a=f,c=h;else{gd(h)||(l=l.append(h.content));const p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...ud(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const d=a+1+c.content.size,u=gd(c)?a+1:d;i.replaceWith(u+r.tableStart,d+r.tableStart,l)}i.setSelection(new P(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function bd(n,e){const t=ie(n.schema);return yy(({node:r})=>t[r.type.spec.tableRole])(n,e)}function yy(n){return(e,t)=>{var r;const s=e.selection;let i,o;if(s instanceof P){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;i=s.$anchorCell.nodeAfter,o=s.$anchorCell.pos}else{if(i=Yg(s.$from),!i)return!1;o=(r=Jt(s.$from))==null?void 0:r.pos}if(i==null||o==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let l=i.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const d=Re(e),u=e.tr;for(let h=0;h<d.right-d.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=d.top;h<d.bottom;h++){let p=d.map.positionAt(h,d.left,d.table);h==d.top&&(p+=i.nodeSize);for(let m=d.left,g=0;m<d.right;m++,g++)m==d.left&&h==d.top||u.insert(f=u.mapping.map(p+d.tableStart,1),n({node:i,row:h,col:m}).createAndFill(a[g]))}u.setNodeMarkup(o,n({node:i,row:d.top,col:d.left}),a[0]),s instanceof P&&u.setSelection(new P(u.doc.resolve(s.$anchorCell.pos),f?u.doc.resolve(f):void 0)),t(u)}return!0}}function by(n,e){return function(t,r){if(!Ce(t))return!1;const s=Qr(t);if(s.nodeAfter.attrs[n]===e)return!1;if(r){const i=t.tr;t.selection instanceof P?t.selection.forEachCell((o,l)=>{o.attrs[n]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[n]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[n]:e}),r(i)}return!0}}function ky(n){return function(e,t){if(!Ce(e))return!1;if(t){const r=ie(e.schema),s=Re(e),i=e.tr,o=s.map.cellsInRect(n=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:n=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(a=>s.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[a],r.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<o.length;a++)i.setNodeMarkup(s.tableStart+o[a],r.header_cell,l[a].attrs);t(i)}return!0}}function kd(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function zn(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?ky(n):function(t,r){if(!Ce(t))return!1;if(r){const s=ie(t.schema),i=Re(t),o=t.tr,l=kd("row",i,s),a=kd("column",i,s),d=(n==="column"?l:n==="row"?a:!1)?1:0,u=n=="column"?{left:0,top:d,right:1,bottom:i.map.height}:n=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,f=n=="column"?a?s.cell:s.header_cell:n=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(h=>{const p=h+i.tableStart,m=o.doc.nodeAt(p);m&&o.setNodeMarkup(p,f,m.attrs)}),r(o)}return!0}}zn("row",{useDeprecatedLogic:!0}),zn("column",{useDeprecatedLogic:!0});var Sy=zn("cell",{useDeprecatedLogic:!0});function wy(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,s=n.before();r>=0;r--){const i=n.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),s=n.after();r<t.childCount;r++){const i=t.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Sd(n){return function(e,t){if(!Ce(e))return!1;const r=wy(Qr(e),n);if(r==null)return!1;if(t){const s=e.doc.resolve(r);t(e.tr.setSelection(T.between(s,Qg(s))).scrollIntoView())}return!0}}function Cy(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Zr(n,e){const t=n.selection;if(!(t instanceof P))return!1;if(e){const r=n.tr,s=ie(n.schema).cell.createAndFill().content;t.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new w(s,0,0))}),r.docChanged&&e(r)}return!0}function xy(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),u=a<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=so(ie(o).row,new w(c,d,u)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||r?so(ie(o).row,new w(e,t,r)).content:e);else return null;return My(o,l)}function My(n,e){const t=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=i.child(o).attrs;for(let c=s;c<s+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let s=0;s<t.length;s++)r=Math.max(r,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(b.empty),t[s]<r){const i=ie(n).cell.createAndFill(),o=[];for(let l=t[s];l<r;l++)o.push(i);e[s]=e[s].append(b.from(o))}return{height:e.length,width:r,rows:e}}function so(n,e){const t=n.createAndFill();return new vs(t).replace(0,t.content.size,e).doc}function Ty({width:n,height:e,rows:t},r,s){if(n!=r){const i=[],o=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=i[l]||0,u=0;d<r;u++){let f=a.child(u%a.childCount);d+f.attrs.colspan>r&&(f=f.type.createChecked(Mt(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),c.push(f),d+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}o.push(b.from(c))}t=o,n=r}if(e!=s){const i=[];for(let o=0,l=0;o<s;o++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);o+u.attrs.rowspan>s&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,s-u.attrs.rowspan)},u.content)),a.push(u)}i.push(b.from(a))}t=i,e=s}return{width:n,height:e,rows:t}}function Ay(n,e,t,r,s,i,o){const l=n.doc.type.schema,a=ie(l);let c,d;if(s>e.width)for(let u=0,f=0;u<e.height;u++){const h=t.child(u);f+=h.nodeSize;const p=[];let m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<s;g++)p.push(m);n.insert(n.mapping.slice(o).map(f-1+r),p)}if(i>e.height){const u=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,b.from(u)),h=[];for(let p=e.height;p<i;p++)h.push(f);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||d)}function wd(n,e,t,r,s,i,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const d=o*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const f=t.nodeAt(u),{top:h,left:p}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,{...f.attrs,rowspan:o-h}),n.insert(n.mapping.slice(l).map(e.positionAt(o,p,t)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-o})),c+=f.attrs.colspan-1}}return a}function Cd(n,e,t,r,s,i,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const d=c*e.width+o,u=e.map[d];if(e.map[d-1]==u){a=!0;const f=t.nodeAt(u),h=e.colCount(u),p=n.mapping.slice(l).map(u+r);n.setNodeMarkup(p,null,Mt(f.attrs,o-h,f.attrs.colspan-(o-h))),n.insert(p+f.nodeSize,f.type.createAndFill(Mt(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function xd(n,e,t,r,s){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let o=L.get(i);const{top:l,left:a}=r,c=a+s.width,d=l+s.height,u=n.tr;let f=0;function h(){if(i=t?u.doc.nodeAt(t-1):u.doc,!i)throw new Error("No table found");o=L.get(i),f=u.mapping.maps.length}Ay(u,o,i,t,c,d,f)&&h(),wd(u,o,i,t,a,c,l,f)&&h(),wd(u,o,i,t,a,c,d,f)&&h(),Cd(u,o,i,t,l,d,a,f)&&h(),Cd(u,o,i,t,l,d,c,f)&&h();for(let p=l;p<d;p++){const m=o.positionAt(p,a,i),g=o.positionAt(p,c,i);u.replace(u.mapping.slice(f).map(m+t),u.mapping.slice(f).map(g+t),new w(s.rows[p-l],0,0))}h(),u.setSelection(new P(u.doc.resolve(t+o.positionAt(l,a,i)),u.doc.resolve(t+o.positionAt(d-1,c-1,i)))),e(u)}var Ey=ii({ArrowLeft:ts("horiz",-1),ArrowRight:ts("horiz",1),ArrowUp:ts("vert",-1),ArrowDown:ts("vert",1),"Shift-ArrowLeft":ns("horiz",-1),"Shift-ArrowRight":ns("horiz",1),"Shift-ArrowUp":ns("vert",-1),"Shift-ArrowDown":ns("vert",1),Backspace:Zr,"Mod-Backspace":Zr,Delete:Zr,"Mod-Delete":Zr});function es(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function ts(n,e){return(t,r,s)=>{if(!s)return!1;const i=t.selection;if(i instanceof P)return es(t,r,E.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const o=Md(s,n,e);if(o==null)return!1;if(n=="horiz")return es(t,r,E.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(o),a=dd(l,n,e);let c;return a?c=E.near(a,1):e<0?c=E.near(t.doc.resolve(l.before(-1)),-1):c=E.near(t.doc.resolve(l.after(-1)),1),es(t,r,c)}}}function ns(n,e){return(t,r,s)=>{if(!s)return!1;const i=t.selection;let o;if(i instanceof P)o=i;else{const a=Md(s,n,e);if(a==null)return!1;o=new P(t.doc.resolve(a))}const l=dd(o.$headCell,n,e);return l?es(t,r,new P(o.$anchorCell,l)):!1}}function Oy(n,e){const t=n.state.doc,r=Jt(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new P(r))),!0):!1}function Ny(n,e,t){if(!Ce(n.state))return!1;let r=xy(t);const s=n.state.selection;if(s instanceof P){r||(r={width:1,height:1,rows:[b.from(so(ie(n.state.schema).cell,t))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=L.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=Ty(r,l.right-l.left,l.bottom-l.top),xd(n.state,n.dispatch,o,l,r),!0}else if(r){const i=Qr(n.state),o=i.start(-1);return xd(n.state,n.dispatch,o,L.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function vy(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Td(n,e.target);let s;if(e.shiftKey&&n.state.selection instanceof P)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=Jt(n.state.selection.$anchor))!=null&&((t=io(n,e))==null?void 0:t.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(a,c){let d=io(n,c);const u=st.getState(n.state)==null;if(!d||!ro(a,d))if(u)d=a;else return;const f=new P(a,d);if(u||!n.state.selection.eq(f)){const h=n.state.tr.setSelection(f);u&&h.setMeta(st,a.pos),n.dispatch(h)}}function o(){n.root.removeEventListener("mouseup",o),n.root.removeEventListener("dragstart",o),n.root.removeEventListener("mousemove",l),st.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(st,-1))}function l(a){const c=a,d=st.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(Td(n,c.target)!=r&&(u=io(n,e),!u))return o();u&&i(u,c)}n.root.addEventListener("mouseup",o),n.root.addEventListener("dragstart",o),n.root.addEventListener("mousemove",l)}function Md(n,e,t){if(!(n.state.selection instanceof T))return null;const{$head:r}=n.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((t<0?r.index(s):r.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=r.before(s),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Td(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function io(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Jt(n.state.doc.resolve(t.pos)):null}var Ad=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),oo(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,oo(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function oo(n,e,t,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let u=0,f=0;u<d.childCount;u++){const{colspan:h,colwidth:p}=d.child(u).attrs;for(let m=0;m<h;m++,f++){const g=s==f?i:p&&p[m],y=g?g+"px":"";if(l+=g||r,g||(a=!1),c)c.style.width!=y&&(c.style.width=y),c=c.nextSibling;else{const S=document.createElement("col");S.style.width=y,e.appendChild(S)}}}for(;c;){const u=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=u}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var he=new q("tableColumnResizing");function Ry({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=Ad,lastColumnResizable:s=!0}={}){const i=new H({key:he,state:{init(o,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,u=ie(l.schema).table.name;return r&&d&&(d[u]=(f,h)=>new r(f,t,h)),new Dy(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=he.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{Iy(o,l,n,s)},mouseleave:o=>{Ly(o)},mousedown:(o,l)=>{Py(o,l,e,t)}},decorations:o=>{const l=he.getState(o);if(l&&l.activeHandle>-1)return $y(o,l.activeHandle)},nodeViews:{}}});return i}var Dy=class us{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(he);if(r&&r.setHandle!=null)return new us(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new us(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);return no(e.doc.resolve(s))||(s=-1),new us(s,t.dragging)}return t}};function Iy(n,e,t,r){if(!n.editable)return;const s=he.getState(n.state);if(s&&!s.dragging){const i=zy(e.target);let o=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?o=Ed(n,e,"left",t):a-e.clientX<=t&&(o=Ed(n,e,"right",t))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=n.state.doc.resolve(o),a=l.node(-1),c=L.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Nd(n,o)}}}function Ly(n){if(!n.editable)return;const e=he.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Nd(n,-1)}function Py(n,e,t,r){var s;if(!n.editable)return!1;const i=(s=n.dom.ownerDocument.defaultView)!=null?s:window,o=he.getState(n.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=n.state.doc.nodeAt(o.activeHandle),a=By(n,o.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(he,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const f=he.getState(n.state);f?.dragging&&(Hy(n,f.activeHandle,Od(f.dragging,u,t)),n.dispatch(n.state.tr.setMeta(he,{setDragging:null})))}function d(u){if(!u.which)return c(u);const f=he.getState(n.state);if(f&&f.dragging){const h=Od(f.dragging,u,t);vd(n,f.activeHandle,h,r)}}return vd(n,o.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function By(n,e,{colspan:t,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=n.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function zy(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Ed(n,e,t,r){const s=t=="right"?-r:r,i=n.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,l=Jt(n.state.doc.resolve(o));if(!l)return-1;if(t=="right")return l.pos;const a=L.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Od(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Nd(n,e){n.dispatch(n.state.tr.setMeta(he,{setHandle:e}))}function Hy(n,e,t){const r=n.state.doc.resolve(e),s=r.node(-1),i=L.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const u=i.map[d],f=s.nodeAt(u).attrs,h=f.colspan==1?0:l-i.colCount(u);if(f.colwidth&&f.colwidth[h]==t)continue;const p=f.colwidth?f.colwidth.slice():Fy(f.colspan);p[h]=t,a.setNodeMarkup(o+u,null,{...f,colwidth:p})}a.docChanged&&n.dispatch(a)}function vd(n,e,t,r){const s=n.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=L.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let a=n.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&oo(i,a.firstChild,a,r,l,t)}function Fy(n){return Array(n).fill(0)}function $y(n,e){var t;const r=[],s=n.doc.resolve(e),i=s.node(-1);if(!i)return z.empty;const o=L.get(i),l=s.start(-1),a=o.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const d=a+c*o.width;if((a==o.width-1||o.map[d]!=o.map[d+1])&&(c==0||o.map[d]!=o.map[d-o.width])){const u=o.map[d],f=l+u+i.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(t=he.getState(n))!=null&&t.dragging&&r.push(X.node(l+u,l+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),r.push(X.widget(f,h))}}return z.create(n.doc,r)}function Vy({allowTableNodeSelection:n=!1}={}){return new H({key:st,state:{init(){return null},apply(e,t){const r=e.getMeta(st);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:ty,handleDOMEvents:{mousedown:vy},createSelectionBetween(e){return st.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Oy,handleKeyDown:Ey,handlePaste:Ny},appendTransaction(e,t,r){return sy(r,hd(r,t),n)}})}function lo(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function Rd(n,e,t,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d!==null)for(let u=0,f=0;u<d.childCount;u+=1){const{colspan:h,colwidth:p}=d.child(u).attrs;for(let m=0;m<h;m+=1,f+=1){const g=s===f?i:p&&p[m],y=g?`${g}px`:"";if(l+=g||r,g||(a=!1),c){if(c.style.width!==y){const[S,A]=lo(r,g);c.style.setProperty(S,A)}c=c.nextSibling}else{const S=document.createElement("col"),[A,R]=lo(r,g);S.style.setProperty(A,R),e.appendChild(S)}}}for(;c;){const u=c.nextSibling;(o=c.parentNode)===null||o===void 0||o.removeChild(c),c=u}a?(t.style.width=`${l}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${l}px`)}class Wy{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Rd(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Rd(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function jy(n,e,t,r){let s=0,i=!0;const o=[],l=n.firstChild;if(!l)return{};for(let u=0,f=0;u<l.childCount;u+=1){const{colspan:h,colwidth:p}=l.child(u).attrs;for(let m=0;m<h;m+=1,f+=1){const g=t===f?r:p&&p[m];s+=g||e,g||(i=!1);const[y,S]=lo(e,g);o.push(["col",{style:`${y}: ${S}`}])}}const a=i?`${s}px`:"",c=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function Dd(n,e){return n.createAndFill()}function Ky(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function Uy(n,e,t,r,s){const i=Ky(n),o=[],l=[];for(let c=0;c<t;c+=1){const d=Dd(i.cell);if(d&&l.push(d),r){const u=Dd(i.header_cell);u&&o.push(u)}}const a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?o:l));return i.table.createChecked(null,a)}function Jy(n){return n instanceof P}const rs=({editor:n})=>{const{selection:e}=n.state;if(!Jy(e))return!1;let t=0;const r=Ci(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},ss=$.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Wy,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){const{colgroup:t,tableWidth:r,tableMinWidth:s}=jy(n,this.options.cellMinWidth);return["table",I(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${s}`}),t,["tbody",0]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=Uy(i.schema,n,e,t);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(T.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>ly(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>ay(n,e),deleteColumn:()=>({state:n,dispatch:e})=>dy(n,e),addRowBefore:()=>({state:n,dispatch:e})=>fy(n,e),addRowAfter:()=>({state:n,dispatch:e})=>hy(n,e),deleteRow:()=>({state:n,dispatch:e})=>my(n,e),deleteTable:()=>({state:n,dispatch:e})=>Cy(n,e),mergeCells:()=>({state:n,dispatch:e})=>yd(n,e),splitCell:()=>({state:n,dispatch:e})=>bd(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>zn("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>zn("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>Sy(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>yd(n,e)?!0:bd(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>by(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Sd(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Sd(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&hd(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=P.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:rs,"Mod-Backspace":rs,Delete:rs,"Mod-Delete":rs}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Ry({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Vy({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:O(C(n,"tableRole",e))}}}),Id=$.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",I(this.options.HTMLAttributes,n),0]}}),Ld=$.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",I(this.options.HTMLAttributes,n),0]}}),Pd=$.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",I(this.options.HTMLAttributes,n),0]}}),qy=W.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).every(e=>e)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),_y=ce.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",I(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Gy=$.create({name:"anchor",atom:!0,draggable:!0,inline:!0,group:"inline",marks:"",selectable:!0,addAttributes(){return{id:{}}},addNodeView(){return({HTMLAttributes:n})=>{const e=document.createElement("span");e.setAttribute("data-umb-anchor",""),e.setAttribute("title",n.id);const t=document.createElement("uui-icon");return t.setAttribute("name","icon-anchor"),e.appendChild(t),{dom:e}}},addOptions(){return{HTMLAttributes:{id:"id"}}},parseHTML(){return[{tag:"a[id]",getAttrs:n=>n.innerHTML===""?{}:!1}]},renderHTML({HTMLAttributes:n}){return["a",I(this.options.HTMLAttributes,n)]}}),Yy=$.create({name:"div",priority:50,group:"block",content:"inline*",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:this.name}]},renderHTML({HTMLAttributes:n}){return[this.name,I(this.options.HTMLAttributes,n),0]}}),Xy=$.create({name:"figcaption",addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",selectable:!1,draggable:!1,parseHTML(){return[{tag:"figcaption"}]},renderHTML({HTMLAttributes:n}){return[this.name,n,0]}}),Qy=$.create({name:"figure",group:"block",content:"block+",draggable:!0,selectable:!0,isolating:!0,atom:!0,addAttributes(){return{figcaption:{default:""}}},addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"figure",getAttrs:n=>({figcaption:n.querySelector("figcaption")?.textContent||""})}]},renderHTML({HTMLAttributes:n}){return[this.name,I(this.options.HTMLAttributes,n),0]}});function is(n){const e={};return(n??"").split(";").map(t=>t.trim()).filter(t=>t).forEach(t=>{const[r,s]=t.split(":");r&&s&&(e[r.trim()]=s.trim())}),e}function Bd(n){return Object.entries(n).map(([e,t])=>`${e}: ${t}`).join(";")+";"}const Zy=ce.create({name:"span",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:this.name}]},renderHTML({HTMLAttributes:n}){return[this.name,I(this.options.HTMLAttributes,n),0]},addCommands(){return{setSpanStyle:n=>({commands:e,editor:t})=>{if(!n)return!1;const r=t.getAttributes(this.name)?.style;if(!r&&!t.isActive(this.name))return e.setMark(this.name,{style:n});const s={...is(r),...is(n)},i=Bd(s);return i===";"?!1:e.updateAttributes(this.name,{style:i})},toggleSpanStyle:n=>({commands:e,editor:t})=>n?t.getAttributes(this.name)?.style?.includes(n)===!0?e.unsetSpanStyle(n):e.setSpanStyle(n):!1,unsetSpanStyle:n=>({commands:e,editor:t})=>{if(!n)return!1;is(n);const r=new Set;if(n.split(";").map(l=>l.trim()).filter(l=>l).forEach(l=>{const[a]=l.split(":");a&&r.add(a.trim())}),r.size===0)return!1;const s=t.getAttributes(this.name)?.style,i=is(s);for(const l of r)delete i[l];const o=Bd(i);return o===";"?e.resetAttributes(this.name,"style"):e.updateAttributes(this.name,{style:o})}}}});function e0(n){return n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase())}const t0=W.create({name:"htmlGlobalAttributes",addOptions(){return{types:[]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{class:{},dataset:{parseHTML:n=>n.dataset,renderHTML:n=>{const e=n.dataset?Object.keys(n.dataset):[];if(!e.length)return{};const t={};return e.forEach(r=>{t["data-"+e0(r)]=n.dataset[r]}),t}},id:{},style:{parseHTML:n=>n.style.length?n.style.cssText:null}}}]},addCommands(){return{setClassName:(n,e)=>({commands:t})=>n?(e?[e]:this.options.types).map(r=>t.updateAttributes(r,{class:n})).every(r=>r):!1,toggleClassName:(n,e)=>({commands:t,editor:r})=>n?(e?[e]:this.options.types).map(s=>r.getAttributes(s)?.class).filter(s=>s).length?t.unsetClassName(e):t.setClassName(n,e):!1,unsetClassName:n=>({commands:e})=>(n?[n]:this.options.types).map(t=>e.resetAttributes(t,"class")).every(t=>t),setId:(n,e)=>({commands:t})=>n?(e?[e]:this.options.types).map(r=>t.updateAttributes(r,{id:n})).every(r=>r):!1,toggleId:(n,e)=>({commands:t,editor:r})=>n?(e?[e]:this.options.types).map(s=>r.getAttributes(s)?.id).filter(s=>s).length?t.unsetId(e):t.setId(n,e):!1,unsetId:n=>({commands:e})=>(n?[n]:this.options.types).map(t=>e.resetAttributes(t,"id")).every(t=>t),setStyles:(n,e)=>({commands:t})=>n?(e?[e]:this.options.types).map(r=>t.updateAttributes(r,{style:n})).every(r=>r):!1,toggleStyles:(n,e)=>({commands:t,editor:r})=>n?(e?[e]:this.options.types).map(s=>r.getAttributes(s)?.style).filter(s=>s).length?t.unsetStyles(e):t.setStyles(n,e):!1,unsetStyles:n=>({commands:e})=>(n?[n]:this.options.types).map(t=>e.resetAttributes(t,"style")).every(t=>t)}}}),n0=W.create({name:"textDirection",addOptions(){return{directions:["ltr","rtl","auto"],types:["heading","paragraph"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textDirection:{parseHTML:n=>n.dir,renderHTML:n=>this.options.directions.includes(n.textDirection)?{dir:n.textDirection}:null}}}]},addCommands(){return{setTextDirection:n=>({commands:e})=>this.options.directions.includes(n)?this.options.types.every(t=>e.updateAttributes(t,{textDirection:n})):!1,unsetTextDirection:()=>({commands:n})=>this.options.types.every(e=>n.resetAttributes(e,"textDirection"))}}}),r0=W.create({name:"textIndent",addOptions(){return{minLevel:0,maxLevel:5,types:["heading","paragraph","listItem","taskItem"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{indent:{default:null,parseHTML:n=>{const e=this.options.minLevel,t=this.options.maxLevel,r=n.style.textIndent;return r?Math.max(e,Math.min(t,parseInt(r,10))):null},renderHTML:n=>n.indent?{style:`text-indent: ${n.indent}rem;`}:{}}}}]},addCommands(){const n=(r,s,i)=>{const o=r.doc.nodeAt(s);if(!o)return r;const l=this.options.minLevel,a=this.options.maxLevel;let c=(o.attrs.indent||0)+i;return c=Math.max(l,Math.min(a,parseInt(c,10))),c===o.attrs.indent?r:r.setNodeMarkup(s,o.type,{...o.attrs,indent:c},o.marks)},e=(r,s)=>{if(r.selection instanceof T||r.selection instanceof fe){const{from:i,to:o}=r.selection;r.doc.nodesBetween(i,o,(l,a)=>this.options.types.includes(l.type.name)?(r=n(r,a,s),!1):!0)}return r},t=r=>()=>function({tr:s,state:i,dispatch:o}){const{selection:l}=i;return s.setSelection(l),s=e(s,r),s.docChanged?(o instanceof Function&&o(s),!0):!1};return{textIndent:t(1),textOutdent:t(-1)}}});function zd({types:n,node:e}){return Array.isArray(n)&&n.includes(e.type)||e.type===n}const s0=W.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new q(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new H({key:n,appendTransaction:(t,r,s)=>{const{doc:i,tr:o,schema:l}=s,a=n.getState(s),c=i.content.size,d=l.nodes[this.options.node];if(a)return o.insert(c,d.create())},state:{init:(t,r)=>{const s=r.tr.doc.lastChild;return!zd({node:s,types:e})},apply:(t,r)=>{if(!t.docChanged)return r;const s=t.doc.lastChild;return!zd({node:s,types:e})}}})]}});var Hd=n=>{throw TypeError(n)},Fd=(n,e,t)=>e.has(n)||Hd("Cannot "+t),De=(n,e,t)=>(Fd(n,e,"read from private field"),t?t.call(n):e.get(n)),ao=(n,e,t)=>e.has(n)?Hd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),co=(n,e,t,r)=>(Fd(n,e,"write to private field"),e.set(n,t),t),ls,xe,as;const i0=W.create({name:"umbBubbleMenu",addOptions(){return{unique:"umb-tiptap-menu",placement:"top",elementName:null,shouldShow:null}},addProseMirrorPlugins(){return!this.options.unique||!this.options.elementName?[]:[cs(this.editor,{unique:this.options.unique,placement:this.options.placement,elementName:this.options.elementName,shouldShow:this.options.shouldShow})]}});class o0{constructor(e,t,r){if(ao(this,ls),ao(this,xe),ao(this,as),co(this,ls,e),co(this,as,r.shouldShow??null),co(this,xe,document.createElement("uui-popover-container")),De(this,xe).id=r.unique,De(this,xe).setAttribute("placement",r.placement??"top"),De(this,xe).setAttribute("popover","manual"),r.elementName){const s=document.createElement(r.elementName);s.editor=e,De(this,xe).appendChild(s)}t.dom.parentNode?.appendChild(De(this,xe)),this.update(t,null)}update(e,t){var r;const s=De(this,ls),{state:i}=e,{selection:o}=i,{ranges:l}=o,a=Math.min(...l.map(d=>d.$from.pos)),c=Math.max(...l.map(d=>d.$to.pos));(r=De(this,as))!=null&&r.call(this,{editor:s,view:e,state:i,from:a,to:c})?De(this,xe).showPopover():De(this,xe).hidePopover()}destroy(){De(this,xe).remove()}}ls=new WeakMap,xe=new WeakMap,as=new WeakMap;const cs=(n,e)=>new H({view(t){return new o0(n,t,e)}}),l0=$.create({name:"umbEmbeddedMedia",group(){return this.options.inline?"inline":"block"},inline(){return this.options.inline},atom:!0,marks:"",draggable:!0,selectable:!0,addAttributes(){return{"data-embed-constrain":{default:!1},"data-embed-height":{default:240},"data-embed-url":{default:null},"data-embed-width":{default:360},markup:{default:null,parseHTML:n=>n.innerHTML}}},parseHTML(){return[{tag:"div",priority:100,getAttrs:n=>n.classList.contains("umb-embed-holder")&&null}]},renderHTML({HTMLAttributes:n}){const{markup:e,...t}=n,r=document.createRange().createContextualFragment(e);return["div",I({class:"umb-embed-holder"},t),r]},addCommands(){return{setEmbeddedMedia:n=>({commands:e})=>{const t={markup:n.markup,"data-embed-url":n.url,"data-embed-width":n.width,"data-embed-height":n.height,"data-embed-constrain":n.constrain};return e.insertContent({type:this.name,attrs:t})}}}}),a0=Jc.extend({addAttributes(){return{...this.parent?.(),width:{default:null},height:{default:null},loading:{default:null},srcset:{default:null},sizes:{default:null},"data-tmpimg":{default:null},"data-udi":{default:null}}}}),c0=cd.extend({name:"umbLink",addAttributes(){return{...this.parent?.(),"data-anchor":{default:null},title:{default:null},type:{default:"external"}}},addOptions(){return{...this.parent?.(),HTMLAttributes:{target:"","data-router-slot":"disabled"}}},addCommands(){return{setUmbLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),unsetUmbLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}}});var $d=n=>{throw TypeError(n)},d0=(n,e,t)=>e.has(n)||$d("Cannot "+t),u0=(n,e,t)=>e.has(n)?$d("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),Vd=(n,e,t)=>(d0(n,e,"access private method"),t),ds,uo;class Wd extends Ad{constructor(e,t){super(e,t),u0(this,ds),Vd(this,ds,uo).call(this,e)}update(e){return super.update(e)?(Vd(this,ds,uo).call(this,e),!0):!1}}ds=new WeakSet,uo=function(n){if(n.attrs.style){const e=this.table.style.minWidth,t=n.attrs.style;this.table.style.cssText=`${t}; min-width: ${e};`}};const f0=ss.configure({resizable:!0,View:Wd}),h0=Pd.extend({allowGapCursor:!1}),p0=Ld.extend({addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(t=>parseInt(t,10)):null}},style:{default:null}}},addProseMirrorPlugins(){const{editor:n}=this;return[cs(this.editor,{unique:"table-column-menu",placement:"top",elementName:"umb-tiptap-table-column-menu",shouldShow(e){return C0(e)}}),new H({props:{decorations:e=>{const{isEditable:t}=this.editor;if(!t)return z.empty;const{doc:r,selection:s}=e,i=[],o=k0(0)(s);return o&&o.forEach(({pos:l},a)=>{i.push(X.widget(l+1,()=>{const c=g0(a)(s),d=document.createElement("a");return d.appendChild(document.createElement("uui-symbol-more")),d.className=c?"grip-column selected":"grip-column",d.setAttribute("popovertarget",c?"table-column-menu":""),d.addEventListener("mousedown",u=>{u.preventDefault(),u.stopImmediatePropagation(),this.editor.view.dispatch(S0(a)(this.editor.state.tr))}),d}))}),z.create(r,i)}}})]}}),m0=Id.extend({addAttributes(){return{colspan:{default:1,parseHTML:n=>{const e=n.getAttribute("colspan");return e?parseInt(e,10):1}},rowspan:{default:1,parseHTML:n=>{const e=n.getAttribute("rowspan");return e?parseInt(e,10):1}},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}},style:{default:null}}},addProseMirrorPlugins(){const{editor:n}=this;return[cs(this.editor,{unique:"table-row-menu",placement:"left",elementName:"umb-tiptap-table-row-menu",shouldShow(e){return x0(e)}}),new H({props:{decorations:e=>{const{isEditable:t}=this.editor;if(!t)return z.empty;const{doc:r,selection:s}=e,i=[],o=b0(0)(s);return o&&o.forEach(({pos:l},a)=>{i.push(X.widget(l+1,()=>{const c=y0(a)(s),d=document.createElement("a");return d.appendChild(document.createElement("uui-symbol-more")),d.className=c?"grip-row selected":"grip-row",d.setAttribute("popovertarget",c?"table-row-menu":""),d.addEventListener("mousedown",u=>{u.preventDefault(),u.stopImmediatePropagation(),this.editor.view.dispatch(w0(a)(this.editor.state.tr))}),d}))}),z.create(r,i)}}})]}}),fo=n=>e=>{const t=L.get(e.$anchorCell.node(-1)),r=e.$anchorCell.start(-1),s=t.cellsInRect(n),i=t.cellsInRect(t.rectBetween(e.$anchorCell.pos-r,e.$headCell.pos-r));for(let o=0,l=s.length;o<l;o+=1)if(i.indexOf(s[o])===-1)return!1;return!0},ho=n=>Wt(e=>e.type.spec.tableRole&&e.type.spec.tableRole==="table")(n),po=n=>n instanceof P,g0=n=>e=>{if(po(e)){const t=L.get(e.$anchorCell.node(-1));return fo({left:n,right:n+1,top:0,bottom:t.height})(e)}return!1},y0=n=>e=>{if(po(e)){const t=L.get(e.$anchorCell.node(-1));return fo({left:0,right:t.width,top:n,bottom:n+1})(e)}return!1},jd=n=>{if(po(n)){const e=L.get(n.$anchorCell.node(-1));return fo({left:0,right:e.width,top:0,bottom:e.height})(n)}return!1},b0=n=>e=>{const t=ho(e);if(t){const r=L.get(t.node);return(Array.isArray(n)?n:Array.from([n])).reduce((s,i)=>{if(i>=0&&i<=r.width-1){const o=r.cellsInRect({left:i,right:i+1,top:0,bottom:r.height});return s.concat(o.map(l=>{const a=t.node.nodeAt(l),c=l+t.start;return{pos:c,start:c+1,node:a}}))}return s},[])}return null},k0=n=>e=>{const t=ho(e);if(t){const r=L.get(t.node);return(Array.isArray(n)?n:Array.from([n])).reduce((s,i)=>{if(i>=0&&i<=r.height-1){const o=r.cellsInRect({left:0,right:r.width,top:i,bottom:i+1});return s.concat(o.map(l=>{const a=t.node.nodeAt(l),c=l+t.start;return{pos:c,start:c+1,node:a}}))}return s},[])}return null},Kd=n=>e=>t=>{const r=ho(t.selection),s=n==="row";if(r){const i=L.get(r.node);if(e>=0&&e<(s?i.height:i.width)){const o=s?0:e,l=s?e:0,a=s?i.width:e+1,c=s?e+1:i.height,d=i.cellsInRect({left:o,top:l,right:s?a:o+1,bottom:s?l+1:c}),u=c-l===1?d:i.cellsInRect({left:s?o:a-1,top:s?c-1:l,right:a,bottom:c}),f=r.start+d[0],h=r.start+u[u.length-1],p=t.doc.resolve(f),m=t.doc.resolve(h);return t.setSelection(new P(m,p))}}return t},S0=Kd("column"),w0=Kd("row"),C0=({editor:n,view:e,state:t,from:r})=>{const s=e.domAtPos(r).node,i=e.nodeDOM(r)||s;if(!n.isActive(ss.name)||!i||jd(t.selection))return!1;let o=i;for(;o&&!["TD","TH"].includes(o.tagName);)o=o.parentElement;return!!(o&&o.querySelector&&o.querySelector("a.grip-column.selected"))},x0=({editor:n,view:e,state:t,from:r})=>{const s=e.domAtPos(r).node,i=e.nodeDOM(r)||s;if(!n.isActive(ss.name)||!i||jd(t.selection))return!1;let o=i;for(;o&&!["TD","TH"].includes(o.tagName);)o=o.parentElement;return!!(o&&o.querySelector&&o.querySelector("a.grip-row.selected"))};export{Gy as Anchor,Tc as Blockquote,Ac as Bold,Nc as BulletList,Sg as CharacterCount,vc as Code,Rc as CodeBlock,gn as CommandManager,Yy as Div,Sm as Editor,W as Extension,Xy as Figcaption,Qy as Figure,Dc as Heading,Fc as HorizontalRule,t0 as HtmlGlobalAttributes,Jc as Image,Ft as InputRule,$c as Italic,cd as Link,Vc as ListItem,ce as Mark,$ as Node,at as NodePos,Cm as NodeView,Kc as OrderedList,cr as PasteRule,yg as Placeholder,Zy as Span,gg as StarterKit,Uc as Strike,Kg as Subscript,Ug as Superscript,ss as Table,Id as TableCell,Ld as TableHeader,Pd as TableRow,qy as TextAlign,n0 as TextDirection,r0 as TextIndent,kg as TextStyle,Em as Tracker,s0 as TrailingNode,i0 as UmbBubbleMenu,cs as UmbBubbleMenuPlugin,a0 as UmbImage,c0 as UmbLink,f0 as UmbTable,m0 as UmbTableCell,p0 as UmbTableHeader,h0 as UmbTableRow,Wd as UmbTableView,_y as Underline,O as callOrReturn,ic as combineTransactionSteps,mn as createChainableState,hr as createDocument,xn as createNodeFromContent,Mc as createStyleTag,oc as defaultBlockAt,Si as deleteProps,$t as elementFromString,xm as escapeForRegEx,bm as extensions,Wp as findChildren,lc as findChildrenInRange,Qa as findDuplicates,Wt as findParentNode,Ci as findParentNodeClosestToPos,Ja as fromString,jp as generateHTML,Kp as generateJSON,Up as generateText,Mi as getAttributes,ui as getAttributesFromExtensions,dc as getChangedRanges,uc as getDebugJSON,C as getExtensionField,bn as getHTMLFromFragment,wi as getMarkAttributes,fr as getMarkRange,$e as getMarkType,mr as getMarksBetween,qp as getNodeAtPosition,ac as getNodeAttributes,_ as getNodeType,ir as getRenderedAttributes,pr as getSchema,pi as getSchemaByResolvedExtensions,or as getSchemaTypeByName,Mn as getSchemaTypeNameByName,Tn as getSplittedAttributes,xi as getText,gi as getTextBetween,_a as getTextContentFromNodes,ur as getTextSerializersFromSchema,hi as injectExtensionAttributesToParseRule,Ga as inputRulesPlugin,fc as isActive,_p as isAtEndOfNode,Gp as isAtStartOfNode,Ua as isEmptyObject,mi as isExtensionRulesEnabled,fi as isFunction,Ti as isList,ki as isMacOS,gr as isMarkActive,Vt as isNodeActive,An as isNodeEmpty,hc as isNodeSelection,Ya as isNumber,kn as isPlainObject,lr as isRegExp,Mm as isString,yi as isTextSelection,Cn as isiOS,St as markInputRule,Ze as markPasteRule,I as mergeAttributes,Sn as mergeDeep,Oe as minMax,Oi as nodeInputRule,Tm as nodePasteRule,wn as objectIncludes,Xa as pasteRulesPlugin,Yp as posToDOMRect,cc as removeDuplicates,bi as resolveFocusPosition,Xp as rewriteUnknownContent,sc as selectionToInsertionEnd,yn as splitExtensions,wm as textInputRule,Am as textPasteRule,yr as textblockTypeInputRule,l0 as umbEmbeddedMedia,jt as wrappingInputRule};