kritzel-stencil 0.0.171 → 0.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.
- package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -3
- package/dist/cjs/{default-line-tool.config-JuTDR6PF.js → default-line-tool.config-7eJND6Jb.js} +1516 -206
- package/dist/cjs/index-BeKMS-Zt.js +3280 -0
- package/dist/cjs/index.cjs.js +10 -7
- package/dist/cjs/kritzel-brush-style.cjs.entry.js +4 -5
- package/dist/cjs/kritzel-color_22.cjs.entry.js +291 -106
- package/dist/cjs/loader.cjs.js +2 -3
- package/dist/cjs/stencil.cjs.js +3 -4
- package/dist/collection/classes/core/core.class.js +0 -1
- package/dist/collection/classes/core/reviver.class.js +0 -1
- package/dist/collection/classes/core/store.class.js +0 -1
- package/dist/collection/classes/core/viewport.class.js +0 -1
- package/dist/collection/classes/core/workspace.class.js +0 -1
- package/dist/collection/classes/handlers/base.handler.js +0 -1
- package/dist/collection/classes/handlers/context-menu.handler.js +0 -1
- package/dist/collection/classes/handlers/hover.handler.js +0 -1
- package/dist/collection/classes/handlers/key.handler.js +0 -1
- package/dist/collection/classes/handlers/line-handle.handler.js +0 -1
- package/dist/collection/classes/handlers/move.handler.js +0 -1
- package/dist/collection/classes/handlers/resize.handler.js +0 -1
- package/dist/collection/classes/handlers/rotation.handler.js +0 -1
- package/dist/collection/classes/handlers/selection.handler.js +0 -1
- package/dist/collection/classes/managers/anchor.manager.js +0 -1
- package/dist/collection/classes/managers/cursor.manager.js +0 -1
- package/dist/collection/classes/objects/base-object.class.js +0 -1
- package/dist/collection/classes/objects/custom-element.class.js +0 -1
- package/dist/collection/classes/objects/group.class.js +0 -1
- package/dist/collection/classes/objects/image.class.js +0 -1
- package/dist/collection/classes/objects/line.class.js +0 -1
- package/dist/collection/classes/objects/path.class.js +0 -1
- package/dist/collection/classes/objects/selection-box.class.js +0 -1
- package/dist/collection/classes/objects/selection-group.class.js +0 -1
- package/dist/collection/classes/objects/shape.class.js +0 -1
- package/dist/collection/classes/objects/text.class.js +0 -1
- package/dist/collection/classes/providers/broadcast-sync-provider.class.js +0 -1
- package/dist/collection/classes/providers/hocuspocus-sync-provider.class.js +0 -1
- package/dist/collection/classes/providers/indexeddb-sync-provider.class.js +0 -1
- package/dist/collection/classes/providers/websocket-sync-provider.class.js +0 -1
- package/dist/collection/classes/registries/icon-registry.class.js +0 -1
- package/dist/collection/classes/registries/tool.registry.js +0 -1
- package/dist/collection/classes/structures/app-state-map.structure.js +0 -1
- package/dist/collection/classes/structures/object-map.structure.js +0 -1
- package/dist/collection/classes/structures/quadtree.structure.js +0 -1
- package/dist/collection/classes/tools/base-tool.class.js +0 -1
- package/dist/collection/classes/tools/brush-tool.class.js +0 -1
- package/dist/collection/classes/tools/eraser-tool.class.js +0 -1
- package/dist/collection/classes/tools/image-tool.class.js +0 -1
- package/dist/collection/classes/tools/line-tool.class.js +0 -1
- package/dist/collection/classes/tools/selection-tool.class.js +0 -1
- package/dist/collection/classes/tools/shape-tool.class.js +0 -1
- package/dist/collection/classes/tools/text-tool.class.js +0 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +1 -2
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +2 -3
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +6 -7
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js +1 -2
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js +2 -3
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +8 -3
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.css +151 -21
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js +192 -23
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js +1 -2
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +1 -2
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +8 -3
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js +0 -1
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +1 -2
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +2 -3
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +1 -2
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +1 -2
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +1 -2
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +2 -3
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -2
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +2 -3
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +2 -3
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +1 -2
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +3 -4
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -2
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js +0 -1
- package/dist/collection/configs/default-brush-tool.config.js +0 -1
- package/dist/collection/configs/default-engine-config.js +0 -1
- package/dist/collection/configs/default-line-tool.config.js +0 -1
- package/dist/collection/configs/default-shape-tool.config.js +0 -1
- package/dist/collection/configs/default-sync.config.js +0 -1
- package/dist/collection/configs/default-text-tool.config.js +0 -1
- package/dist/collection/constants/core.constants.js +0 -1
- package/dist/collection/constants/engine.constants.js +0 -1
- package/dist/collection/enums/event-button.enum.js +0 -1
- package/dist/collection/enums/handle-type.enum.js +0 -1
- package/dist/collection/enums/shape-type.enum.js +0 -1
- package/dist/collection/helpers/class.helper.js +0 -1
- package/dist/collection/helpers/cursor.helper.js +0 -1
- package/dist/collection/helpers/devices.helper.js +0 -1
- package/dist/collection/helpers/event.helper.js +0 -1
- package/dist/collection/helpers/geometry.helper.js +0 -1
- package/dist/collection/helpers/html.helper.js +0 -1
- package/dist/collection/helpers/keyboard.helper.js +0 -1
- package/dist/collection/helpers/math.helper.js +0 -1
- package/dist/collection/helpers/object.helper.js +0 -1
- package/dist/collection/index.js +0 -1
- package/dist/collection/interfaces/anchor.interface.js +0 -1
- package/dist/collection/interfaces/arrow-head.interface.js +0 -1
- package/dist/collection/interfaces/bounding-box.interface.js +0 -1
- package/dist/collection/interfaces/clonable.interface.js +0 -1
- package/dist/collection/interfaces/context-menu-item.interface.js +0 -1
- package/dist/collection/interfaces/debug-info.interface.js +0 -1
- package/dist/collection/interfaces/engine-state.interface.js +0 -1
- package/dist/collection/interfaces/line-options.interface.js +0 -1
- package/dist/collection/interfaces/menu-item.interface.js +0 -1
- package/dist/collection/interfaces/object.interface.js +0 -1
- package/dist/collection/interfaces/path-options.interface.js +0 -1
- package/dist/collection/interfaces/point.interface.js +0 -1
- package/dist/collection/interfaces/polygon.interface.js +0 -1
- package/dist/collection/interfaces/selection-state.interface.js +0 -1
- package/dist/collection/interfaces/serializable.interface.js +0 -1
- package/dist/collection/interfaces/shortcut.interface.js +0 -1
- package/dist/collection/interfaces/sync-config.interface.js +0 -1
- package/dist/collection/interfaces/sync-provider.interface.js +0 -1
- package/dist/collection/interfaces/tool.interface.js +0 -1
- package/dist/collection/interfaces/toolbar-control.interface.js +0 -1
- package/dist/collection/interfaces/undo-state.interface.js +0 -1
- package/dist/collection/types/deep-readonly.type.js +0 -1
- package/dist/collection/types/state.types.js +0 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -1477
- package/dist/components/kritzel-brush-style.js +1 -67
- package/dist/components/kritzel-color-palette.js +1 -9
- package/dist/components/kritzel-color.js +1 -9
- package/dist/components/kritzel-context-menu.js +1 -9
- package/dist/components/kritzel-control-brush-config.js +1 -9
- package/dist/components/kritzel-control-text-config.js +1 -9
- package/dist/components/kritzel-controls.js +1 -9
- package/dist/components/kritzel-cursor-trail.js +1 -9
- package/dist/components/kritzel-dropdown.js +1 -9
- package/dist/components/kritzel-editor.js +1 -605
- package/dist/components/kritzel-engine.js +1 -9
- package/dist/components/kritzel-font-family.js +1 -9
- package/dist/components/kritzel-font-size.js +1 -9
- package/dist/components/kritzel-font.js +1 -9
- package/dist/components/kritzel-icon.js +1 -9
- package/dist/components/kritzel-menu-item.js +1 -9
- package/dist/components/kritzel-menu.js +1 -9
- package/dist/components/kritzel-portal.js +1 -9
- package/dist/components/kritzel-split-button.js +1 -9
- package/dist/components/kritzel-stroke-size.js +1 -9
- package/dist/components/kritzel-tooltip.js +1 -9
- package/dist/components/kritzel-utility-panel.js +1 -9
- package/dist/components/kritzel-workspace-manager.js +1 -9
- package/dist/components/p-1z-ds26_.js +1 -0
- package/dist/components/p-4FEa4ADy.js +1 -0
- package/dist/components/p-B0kd2rUI.js +1 -16
- package/dist/components/p-B7Fdo5QJ.js +1 -0
- package/dist/components/p-BXaWhpO2.js +1 -0
- package/dist/components/p-Bj_Og27M.js +1 -0
- package/dist/components/p-BtuXeItZ.js +1 -0
- package/dist/components/p-C-d2IH4v.js +1 -0
- package/dist/components/p-C3UriJh7.js +1 -0
- package/dist/components/p-C4krHoUl.js +1 -0
- package/dist/components/p-C6qB08BS.js +1 -68
- package/dist/components/p-CF5L2Gdl.js +1 -0
- package/dist/components/p-CXzfYQ_u.js +1 -0
- package/dist/components/p-CeKT_dTd.js +1 -0
- package/dist/components/p-Cp15toXH.js +1 -0
- package/dist/components/p-Cy77SpWt.js +1 -0
- package/dist/components/p-D1tfzpy8.js +1 -0
- package/dist/components/p-D3LRBk2t.js +9 -0
- package/dist/components/p-D5ZsALCP.js +1 -0
- package/dist/components/p-D8W6LE-c.js +1 -11
- package/dist/components/p-DB5s1NY4.js +1 -0
- package/dist/components/p-DTezr6w9.js +1 -0
- package/dist/components/p-Du1vxHy8.js +1 -0
- package/dist/components/p-IAqZFssU.js +1 -0
- package/dist/components/p-g0N9j_uT.js +1 -0
- package/dist/components/p-l10It7Nm.js +1 -30
- package/dist/components/p-n789Y3S-.js +1 -45
- package/dist/esm/app-globals-DQuL1Twl.js +0 -3
- package/dist/esm/{default-line-tool.config-CuBm2vpW.js → default-line-tool.config-CD5sTKH-.js} +1515 -205
- package/dist/esm/index-BqhmuUH2.js +3253 -0
- package/dist/esm/index.js +11 -8
- package/dist/esm/kritzel-brush-style.entry.js +4 -5
- package/dist/esm/kritzel-color_22.entry.js +291 -106
- package/dist/esm/loader.js +3 -4
- package/dist/esm/stencil.js +4 -5
- package/dist/stencil/index.esm.js +1 -2
- package/dist/stencil/p-09295079.entry.js +1 -0
- package/dist/stencil/p-381c0e9c.entry.js +9 -0
- package/dist/stencil/p-BqhmuUH2.js +2 -0
- package/dist/stencil/p-CD5sTKH-.js +1 -0
- package/dist/stencil/p-DQuL1Twl.js +1 -2
- package/dist/stencil/stencil.esm.js +1 -2
- package/dist/types/components/shared/kritzel-color-palette/kritzel-color-palette.d.ts +1 -0
- package/dist/types/components/shared/kritzel-dropdown/kritzel-dropdown.d.ts +22 -3
- package/dist/types/components/shared/kritzel-font-size/kritzel-font-size.d.ts +1 -0
- package/dist/types/components.d.ts +2 -2
- package/dist/types/stencil-public-runtime.d.ts +57 -3
- package/package.json +6 -1
- package/dist/cjs/app-globals-V2Kpy_OQ.js.map +0 -1
- package/dist/cjs/default-line-tool.config-JuTDR6PF.js.map +0 -1
- package/dist/cjs/index-Cj__YTlG.js +0 -1650
- package/dist/cjs/index-Cj__YTlG.js.map +0 -1
- package/dist/cjs/index.cjs.js.map +0 -1
- package/dist/cjs/kritzel-brush-style.entry.cjs.js.map +0 -1
- package/dist/cjs/loader.cjs.js.map +0 -1
- package/dist/cjs/stencil.cjs.js.map +0 -1
- package/dist/collection/classes/core/core.class.js.map +0 -1
- package/dist/collection/classes/core/reviver.class.js.map +0 -1
- package/dist/collection/classes/core/store.class.js.map +0 -1
- package/dist/collection/classes/core/viewport.class.js.map +0 -1
- package/dist/collection/classes/core/workspace.class.js.map +0 -1
- package/dist/collection/classes/handlers/base.handler.js.map +0 -1
- package/dist/collection/classes/handlers/context-menu.handler.js.map +0 -1
- package/dist/collection/classes/handlers/hover.handler.js.map +0 -1
- package/dist/collection/classes/handlers/key.handler.js.map +0 -1
- package/dist/collection/classes/handlers/line-handle.handler.js.map +0 -1
- package/dist/collection/classes/handlers/move.handler.js.map +0 -1
- package/dist/collection/classes/handlers/resize.handler.js.map +0 -1
- package/dist/collection/classes/handlers/rotation.handler.js.map +0 -1
- package/dist/collection/classes/handlers/selection.handler.js.map +0 -1
- package/dist/collection/classes/managers/anchor.manager.js.map +0 -1
- package/dist/collection/classes/managers/cursor.manager.js.map +0 -1
- package/dist/collection/classes/objects/base-object.class.js.map +0 -1
- package/dist/collection/classes/objects/custom-element.class.js.map +0 -1
- package/dist/collection/classes/objects/group.class.js.map +0 -1
- package/dist/collection/classes/objects/image.class.js.map +0 -1
- package/dist/collection/classes/objects/line.class.js.map +0 -1
- package/dist/collection/classes/objects/path.class.js.map +0 -1
- package/dist/collection/classes/objects/selection-box.class.js.map +0 -1
- package/dist/collection/classes/objects/selection-group.class.js.map +0 -1
- package/dist/collection/classes/objects/shape.class.js.map +0 -1
- package/dist/collection/classes/objects/text.class.js.map +0 -1
- package/dist/collection/classes/providers/broadcast-sync-provider.class.js.map +0 -1
- package/dist/collection/classes/providers/hocuspocus-sync-provider.class.js.map +0 -1
- package/dist/collection/classes/providers/indexeddb-sync-provider.class.js.map +0 -1
- package/dist/collection/classes/providers/websocket-sync-provider.class.js.map +0 -1
- package/dist/collection/classes/registries/icon-registry.class.js.map +0 -1
- package/dist/collection/classes/registries/tool.registry.js.map +0 -1
- package/dist/collection/classes/structures/app-state-map.structure.js.map +0 -1
- package/dist/collection/classes/structures/object-map.structure.js.map +0 -1
- package/dist/collection/classes/structures/quadtree.structure.js.map +0 -1
- package/dist/collection/classes/tools/base-tool.class.js.map +0 -1
- package/dist/collection/classes/tools/brush-tool.class.js.map +0 -1
- package/dist/collection/classes/tools/eraser-tool.class.js.map +0 -1
- package/dist/collection/classes/tools/image-tool.class.js.map +0 -1
- package/dist/collection/classes/tools/line-tool.class.js.map +0 -1
- package/dist/collection/classes/tools/selection-tool.class.js.map +0 -1
- package/dist/collection/classes/tools/shape-tool.class.js.map +0 -1
- package/dist/collection/classes/tools/text-tool.class.js.map +0 -1
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js.map +0 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +0 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +0 -1
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js.map +0 -1
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js.map +0 -1
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js.map +0 -1
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js.map +0 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js.map +0 -1
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js.map +0 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js.map +0 -1
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js.map +0 -1
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js.map +0 -1
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js.map +0 -1
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js.map +0 -1
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js.map +0 -1
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js.map +0 -1
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js.map +0 -1
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +0 -1
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js.map +0 -1
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js.map +0 -1
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +0 -1
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js.map +0 -1
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js.map +0 -1
- package/dist/collection/configs/default-brush-tool.config.js.map +0 -1
- package/dist/collection/configs/default-engine-config.js.map +0 -1
- package/dist/collection/configs/default-line-tool.config.js.map +0 -1
- package/dist/collection/configs/default-shape-tool.config.js.map +0 -1
- package/dist/collection/configs/default-sync.config.js.map +0 -1
- package/dist/collection/configs/default-text-tool.config.js.map +0 -1
- package/dist/collection/constants/core.constants.js.map +0 -1
- package/dist/collection/constants/engine.constants.js.map +0 -1
- package/dist/collection/enums/event-button.enum.js.map +0 -1
- package/dist/collection/enums/handle-type.enum.js.map +0 -1
- package/dist/collection/enums/shape-type.enum.js.map +0 -1
- package/dist/collection/helpers/class.helper.js.map +0 -1
- package/dist/collection/helpers/cursor.helper.js.map +0 -1
- package/dist/collection/helpers/devices.helper.js.map +0 -1
- package/dist/collection/helpers/event.helper.js.map +0 -1
- package/dist/collection/helpers/geometry.helper.js.map +0 -1
- package/dist/collection/helpers/html.helper.js.map +0 -1
- package/dist/collection/helpers/keyboard.helper.js.map +0 -1
- package/dist/collection/helpers/math.helper.js.map +0 -1
- package/dist/collection/helpers/object.helper.js.map +0 -1
- package/dist/collection/index.js.map +0 -1
- package/dist/collection/interfaces/anchor.interface.js.map +0 -1
- package/dist/collection/interfaces/arrow-head.interface.js.map +0 -1
- package/dist/collection/interfaces/bounding-box.interface.js.map +0 -1
- package/dist/collection/interfaces/clonable.interface.js.map +0 -1
- package/dist/collection/interfaces/context-menu-item.interface.js.map +0 -1
- package/dist/collection/interfaces/debug-info.interface.js.map +0 -1
- package/dist/collection/interfaces/engine-state.interface.js.map +0 -1
- package/dist/collection/interfaces/line-options.interface.js.map +0 -1
- package/dist/collection/interfaces/menu-item.interface.js.map +0 -1
- package/dist/collection/interfaces/object.interface.js.map +0 -1
- package/dist/collection/interfaces/path-options.interface.js.map +0 -1
- package/dist/collection/interfaces/point.interface.js.map +0 -1
- package/dist/collection/interfaces/polygon.interface.js.map +0 -1
- package/dist/collection/interfaces/selection-state.interface.js.map +0 -1
- package/dist/collection/interfaces/serializable.interface.js.map +0 -1
- package/dist/collection/interfaces/shortcut.interface.js.map +0 -1
- package/dist/collection/interfaces/sync-config.interface.js.map +0 -1
- package/dist/collection/interfaces/sync-provider.interface.js.map +0 -1
- package/dist/collection/interfaces/tool.interface.js.map +0 -1
- package/dist/collection/interfaces/toolbar-control.interface.js.map +0 -1
- package/dist/collection/interfaces/undo-state.interface.js.map +0 -1
- package/dist/collection/types/deep-readonly.type.js.map +0 -1
- package/dist/collection/types/state.types.js.map +0 -1
- package/dist/components/index.js.map +0 -1
- package/dist/components/kritzel-brush-style.js.map +0 -1
- package/dist/components/kritzel-color-palette.js.map +0 -1
- package/dist/components/kritzel-color.js.map +0 -1
- package/dist/components/kritzel-context-menu.js.map +0 -1
- package/dist/components/kritzel-control-brush-config.js.map +0 -1
- package/dist/components/kritzel-control-text-config.js.map +0 -1
- package/dist/components/kritzel-controls.js.map +0 -1
- package/dist/components/kritzel-cursor-trail.js.map +0 -1
- package/dist/components/kritzel-dropdown.js.map +0 -1
- package/dist/components/kritzel-editor.js.map +0 -1
- package/dist/components/kritzel-engine.js.map +0 -1
- package/dist/components/kritzel-font-family.js.map +0 -1
- package/dist/components/kritzel-font-size.js.map +0 -1
- package/dist/components/kritzel-font.js.map +0 -1
- package/dist/components/kritzel-icon.js.map +0 -1
- package/dist/components/kritzel-menu-item.js.map +0 -1
- package/dist/components/kritzel-menu.js.map +0 -1
- package/dist/components/kritzel-portal.js.map +0 -1
- package/dist/components/kritzel-split-button.js.map +0 -1
- package/dist/components/kritzel-stroke-size.js.map +0 -1
- package/dist/components/kritzel-tooltip.js.map +0 -1
- package/dist/components/kritzel-utility-panel.js.map +0 -1
- package/dist/components/kritzel-workspace-manager.js.map +0 -1
- package/dist/components/p-B0kd2rUI.js.map +0 -1
- package/dist/components/p-B6r22FSC.js +0 -57
- package/dist/components/p-B6r22FSC.js.map +0 -1
- package/dist/components/p-BUsg2vtg.js +0 -14897
- package/dist/components/p-BUsg2vtg.js.map +0 -1
- package/dist/components/p-B_3OZeom.js +0 -119
- package/dist/components/p-B_3OZeom.js.map +0 -1
- package/dist/components/p-BdwB-S9G.js +0 -130
- package/dist/components/p-BdwB-S9G.js.map +0 -1
- package/dist/components/p-BhLtP5Cg.js +0 -308
- package/dist/components/p-BhLtP5Cg.js.map +0 -1
- package/dist/components/p-Brd9SxWS.js +0 -73
- package/dist/components/p-Brd9SxWS.js.map +0 -1
- package/dist/components/p-C29Efgmc.js +0 -106
- package/dist/components/p-C29Efgmc.js.map +0 -1
- package/dist/components/p-C6-tSCMR.js +0 -272
- package/dist/components/p-C6-tSCMR.js.map +0 -1
- package/dist/components/p-C6qB08BS.js.map +0 -1
- package/dist/components/p-CFH6XRL5.js +0 -75
- package/dist/components/p-CFH6XRL5.js.map +0 -1
- package/dist/components/p-CIts5Uma.js +0 -110
- package/dist/components/p-CIts5Uma.js.map +0 -1
- package/dist/components/p-CO8bwl_3.js +0 -103
- package/dist/components/p-CO8bwl_3.js.map +0 -1
- package/dist/components/p-CRGwaUcp.js +0 -55
- package/dist/components/p-CRGwaUcp.js.map +0 -1
- package/dist/components/p-Ck4lGnmt.js +0 -46
- package/dist/components/p-Ck4lGnmt.js.map +0 -1
- package/dist/components/p-CwkUrTy1.js +0 -1367
- package/dist/components/p-CwkUrTy1.js.map +0 -1
- package/dist/components/p-D0UgEnEL.js +0 -39586
- package/dist/components/p-D0UgEnEL.js.map +0 -1
- package/dist/components/p-D8W6LE-c.js.map +0 -1
- package/dist/components/p-DGnDUmrk.js +0 -62
- package/dist/components/p-DGnDUmrk.js.map +0 -1
- package/dist/components/p-DO4auCYf.js +0 -111
- package/dist/components/p-DO4auCYf.js.map +0 -1
- package/dist/components/p-LAsVgL2e.js +0 -83
- package/dist/components/p-LAsVgL2e.js.map +0 -1
- package/dist/components/p-aeYt0bPO.js +0 -231
- package/dist/components/p-aeYt0bPO.js.map +0 -1
- package/dist/components/p-l10It7Nm.js.map +0 -1
- package/dist/components/p-n789Y3S-.js.map +0 -1
- package/dist/components/p-nIBAWFcK.js +0 -132
- package/dist/components/p-nIBAWFcK.js.map +0 -1
- package/dist/components/p-nZdy-Ii5.js +0 -157
- package/dist/components/p-nZdy-Ii5.js.map +0 -1
- package/dist/components/p-y25EBKEA.js +0 -201
- package/dist/components/p-y25EBKEA.js.map +0 -1
- package/dist/esm/app-globals-DQuL1Twl.js.map +0 -1
- package/dist/esm/default-line-tool.config-CuBm2vpW.js.map +0 -1
- package/dist/esm/index-SGde3HXB.js +0 -1623
- package/dist/esm/index-SGde3HXB.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/kritzel-brush-style.entry.js.map +0 -1
- package/dist/esm/loader.js.map +0 -1
- package/dist/esm/stencil.js.map +0 -1
- package/dist/stencil/index.esm.js.map +0 -1
- package/dist/stencil/kritzel-brush-style.entry.esm.js.map +0 -1
- package/dist/stencil/loader.esm.js.map +0 -1
- package/dist/stencil/p-385bab97.entry.js +0 -2
- package/dist/stencil/p-385bab97.entry.js.map +0 -1
- package/dist/stencil/p-CuBm2vpW.js +0 -2
- package/dist/stencil/p-CuBm2vpW.js.map +0 -1
- package/dist/stencil/p-DQuL1Twl.js.map +0 -1
- package/dist/stencil/p-SGde3HXB.js +0 -3
- package/dist/stencil/p-SGde3HXB.js.map +0 -1
- package/dist/stencil/p-d3f7214e.entry.js +0 -10
- package/dist/stencil/p-d3f7214e.entry.js.map +0 -1
- package/dist/stencil/stencil.esm.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{O as t}from"./p-B0kd2rUI.js";import{K as e}from"./p-l10It7Nm.js";import{K as i}from"./p-D8W6LE-c.js";class r{static registry={};static registerTool(t,e,i){const r=new e(i);return r.name=t,this.registry[t]=r,r}static getTool(t){return this.registry[t]||(console.warn(`Unknown tool: ${t}`),null)}}class n{static doPolygonsIntersect(t,e){const i=[t.bottomLeft,t.bottomRight,t.topRight,t.topLeft],r=[e.bottomLeft,e.bottomRight,e.topRight,e.topLeft];for(const t of i)if(this.isPointInPolygon(t,r))return!0;for(const t of r)if(this.isPointInPolygon(t,i))return!0;for(let t=0;t<i.length;t++){const e=i[t],n=i[(t+1)%i.length];for(let t=0;t<r.length;t++)if(this.intersectLines(e,n,r[t],r[(t+1)%r.length]))return!0}return!1}static isPointInPolygon(t,e){let i=!1;for(let r=0,n=e.length-1;r<e.length;n=r++){const s=e[r].x,h=e[r].y,l=e[n].y;h>t.y!=l>t.y&&t.x<(e[n].x-s)*(t.y-h)/(l-h)+s&&(i=!i)}return i}static intersectLines(t,e,i,r){const n=(e.x-t.x)*(r.y-i.y)-(e.y-t.y)*(r.x-i.x);if(0===n)return!1;const s=((i.x-t.x)*(r.y-i.y)-(i.y-t.y)*(r.x-i.x))/n,h=-((t.x-i.x)*(e.y-t.y)-(t.y-i.y)*(e.x-t.x))/n;return s>=0&&s<=1&&h>=0&&h<=1}static getLineIntersectionPoint(t,e,i,r){const n=(e.x-t.x)*(r.y-i.y)-(e.y-t.y)*(r.x-i.x);if(0===n)return null;const s=((i.x-t.x)*(r.y-i.y)-(i.y-t.y)*(r.x-i.x))/n,h=-((t.x-i.x)*(e.y-t.y)-(t.y-i.y)*(e.x-t.x))/n;return s>=0&&s<=1&&h>=0&&h<=1?{x:t.x+s*(e.x-t.x),y:t.y+s*(e.y-t.y)}:null}static getLinePolygonIntersection(t,e,i){const r=[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft];let n=null,s=1/0;for(let i=0;i<r.length;i++){const h=this.getLineIntersectionPoint(t,e,r[i],r[(i+1)%r.length]);if(h){const e=Math.sqrt(Math.pow(h.x-t.x,2)+Math.pow(h.y-t.y,2));e<s&&(s=e,n=h)}}return n}static getEllipsePolygonApproximation(t,e,i,r,n=32,s=0){const h=[],l=Math.cos(s),o=Math.sin(s);for(let s=0;s<n;s++){const u=2*Math.PI*s/n,f=i*Math.cos(u),a=r*Math.sin(u);h.push({x:t+f*l-a*o,y:e+f*o+a*l})}return h}static getLinePointsArrayIntersection(t,e,i){let r=null,n=1/0;for(let s=0;s<i.length;s++){const h=this.getLineIntersectionPoint(t,e,i[s],i[(s+1)%i.length]);if(h){const e=Math.sqrt(Math.pow(h.x-t.x,2)+Math.pow(h.y-t.y,2));e<n&&(n=e,r=h)}}return r}static isPointInPolygonPoints(t,e){return this.isPointInPolygon(t,e)}}class s{__class__="KritzelBaseObject";_core;_elementRef;id;workspaceId;x;y;translateX;translateY;height;width;backgroundColor;borderColor;borderWidth=0;opacity=1;padding=0;scale;resizing=!1;rotation=0;markedForRemoval=!1;zIndex=0;isVisible=!0;isSelected=!1;isHovered=!1;isMounted=!1;isEditable=!1;isInteractive=!1;isDebugInfoVisible=!1;get totalWidth(){return this.width+2*this.padding}get totalHeight(){return this.height+2*this.padding}set elementRef(t){this._elementRef=t}get elementRef(){return this._elementRef}get boundingBox(){return{x:this.translateX,y:this.translateY,z:this.scale,width:this.totalWidth/this.scale,height:this.totalHeight/this.scale}}get rotatedBoundingBox(){return{x:this.minXRotated,y:this.minYRotated,z:this.scale,width:this.maxXRotated-this.minXRotated,height:this.maxYRotated-this.minYRotated}}get rotatedPolygon(){const t=this.translateX+this.totalWidth/2/this.scale,e=this.translateY+this.totalHeight/2/this.scale,i=this.rotation,r=this.totalWidth/this.scale,n=this.totalHeight/this.scale,s={topLeft:{x:this.translateX,y:this.translateY},topRight:{x:this.translateX+r,y:this.translateY},bottomRight:{x:this.translateX+r,y:this.translateY+n},bottomLeft:{x:this.translateX,y:this.translateY+n}};return Object.keys(s).reduce(((r,n)=>{const h=s[n],l=Math.cos(i)*(h.x-t)-Math.sin(i)*(h.y-e)+t,o=Math.sin(i)*(h.x-t)+Math.cos(i)*(h.y-e)+e;return r[n]={x:l,y:o},r}),{})}get minXRotated(){return Math.min(this.rotatedPolygon.topLeft.x,this.rotatedPolygon.topRight.x,this.rotatedPolygon.bottomRight.x,this.rotatedPolygon.bottomLeft.x)}get minYRotated(){return Math.min(this.rotatedPolygon.topLeft.y,this.rotatedPolygon.topRight.y,this.rotatedPolygon.bottomRight.y,this.rotatedPolygon.bottomLeft.y)}get maxXRotated(){return Math.max(this.rotatedPolygon.topLeft.x,this.rotatedPolygon.topRight.x,this.rotatedPolygon.bottomRight.x,this.rotatedPolygon.bottomLeft.x)}get maxYRotated(){return Math.max(this.rotatedPolygon.topLeft.y,this.rotatedPolygon.topRight.y,this.rotatedPolygon.bottomRight.y,this.rotatedPolygon.bottomLeft.y)}get transformationMatrix(){const t=1/this.scale;return`matrix(${t}, 0, 0, ${t}, ${this.translateX}, ${this.translateY})`}get rotationDegrees(){return this.rotation*(180/Math.PI)}get centerX(){return this.translateX+this.totalWidth/2/this.scale}get centerY(){return this.translateY+this.totalHeight/2/this.scale}constructor(){this.id=this.generateId()}static create(t){const e=new s;return e._core=t,e.zIndex=t.store.currentZIndex,e.workspaceId=t.store.state.activeWorkspace.id,e}mount(t){this.isMounted||(this.elementRef=t,this.isMounted=!0)}generateId(){return t.generateUUID()}isInViewport(){const t=this._core.store.state.scale;if(this.boundingBox.width*t*(this.boundingBox.height*t)<.5)return!1;const e=-this._core.store.state.translateX/this._core.store.state.scale,i=-this._core.store.state.translateY/this._core.store.state.scale;return this.rotatedBoundingBox.x<e+this._core.store.state.viewportWidth/this._core.store.state.scale&&this.rotatedBoundingBox.x+this.rotatedBoundingBox.width>e&&this.rotatedBoundingBox.y<i+this._core.store.state.viewportHeight/this._core.store.state.scale&&this.rotatedBoundingBox.y+this.rotatedBoundingBox.height>i}centerInViewport(){const{viewportWidth:t,viewportHeight:e,translateX:i,translateY:r,scale:n}=this._core.store.state,{x:s,y:h,width:l,height:o}=this.rotatedBoundingBox;this.updatePosition(this.translateX+((t/2-i)/n-(s+l/2)),this.translateY+((e/2-r)/n-(h+o/2)))}update(){this._core.store.state.objects.update(this)}move(t,e,i,r){const n=(e-r)/this._core.store.state.scale;this.translateX+=(t-i)/this._core.store.state.scale,this.translateY+=n,this._core.store.state.objects.update(this)}resize(t,e,i,r){i<=1||r<=1||(this.width=i,this.height=r,this.translateX=t,this.translateY=e,this._core.store.state.objects.update(this),this._core.anchorManager.updateAnchorsForObject(this.id))}rotate(t){this.rotation=t,this._core.store.state.objects.update(this)}clone(){const t=Object.create(Object.getPrototypeOf(this));return Object.assign(t,this),t.id=this.id,t}copy(){const t=Object.create(Object.getPrototypeOf(this));return Object.assign(t,this),t.id=this.generateId(),t.isMounted=!1,t}serialize(){const{_core:t,_elementRef:e,element:i,totalWidth:r,totalHeight:n,...s}=this,h=structuredClone(s);return i&&"object"==typeof i&&"nodeType"in i&&1===i.nodeType&&(h.element=i.cloneNode(!0)),h}deserialize(t){return Object.assign(this,t),this}isClass(t){return this.__class__===t}edit(t){}hitTest(t,e){return!0}hitTestPolygon(t){return n.doPolygonsIntersect(this.rotatedPolygon,t)}updatePosition(t,e){this.translateX=t,this.translateY=e,this._core.store.state.objects.update(this)}}class h{static forceHideKeyboard(){document.activeElement instanceof HTMLElement&&document.activeElement.blur()}static enableInteractiveWidget(){const t=document.querySelector('meta[name="viewport"][content*="interactive-widget=resizes-content"]');if(t){let e=t.getAttribute("content");e.includes("interactive-widget=resizes-content")||(e+=", interactive-widget=resizes-content"),t.setAttribute("content",e)}}static disableInteractiveWidget(){const t=document.querySelector('meta[name="viewport"][content*="interactive-widget=resizes-content"]');if(t){let e=t.getAttribute("content").replace(/\s*interactive-widget=resizes-content\s*[,;]?/g,"");e=e.replace(/,(\s*,)+/g,",").replace(/^,/,"").replace(/,$/,"").trim(),t.setAttribute("content",e)}}static onKeyboardVisibleChanged(t){if("visualViewport"in window){const e=.75,i=i=>{const r=i.target,n=r.height*r.scale/window.screen.height<e;t(n)};return window.visualViewport.addEventListener("resize",i),()=>window.visualViewport.removeEventListener("resize",i)}return console.warn("Listening for keyboard visibility changes is not reliably supported in this browser."),()=>{}}}function l(t){this.content=t}function o(t,e,i){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:i;let n=t.child(r),s=e.child(r);if(n!=s){if(!n.sameMarkup(s))return i;if(n.isText&&n.text!=s.text){for(let t=0;n.text[t]==s.text[t];t++)i++;return i}if(n.content.size||s.content.size){let t=o(n.content,s.content,i+1);if(null!=t)return t}i+=n.nodeSize}else i+=n.nodeSize}}function u(t,e,i,r){for(let n=t.childCount,s=e.childCount;;){if(0==n||0==s)return n==s?null:{a:i,b:r};let h=t.child(--n),l=e.child(--s),o=h.nodeSize;if(h!=l){if(!h.sameMarkup(l))return{a:i,b:r};if(h.isText&&h.text!=l.text){let t=0,e=Math.min(h.text.length,l.text.length);for(;t<e&&h.text[h.text.length-t-1]==l.text[l.text.length-t-1];)t++,i--,r--;return{a:i,b:r}}if(h.content.size||l.content.size){let t=u(h.content,l.content,i-1,r-1);if(t)return t}i-=o,r-=o}else i-=o,r-=o}}l.prototype={constructor:l,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,i){var r=i&&i!=t?this.remove(i):this,n=r.find(t),s=r.content.slice();return-1==n?s.push(i||t,e):(s[n+1]=e,i&&(s[n]=i)),new l(s)},remove:function(t){var e=this.find(t);if(-1==e)return this;var i=this.content.slice();return i.splice(e,2),new l(i)},addToStart:function(t,e){return new l([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var i=this.remove(t).content.slice();return i.push(t,e),new l(i)},addBefore:function(t,e,i){var r=this.remove(e),n=r.content.slice(),s=r.find(t);return n.splice(-1==s?n.length:s,0,e,i),new l(n)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=l.from(t)).size?new l(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=l.from(t)).size?new l(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=l.from(t);for(var i=0;i<t.content.length;i+=2)e=e.remove(t.content[i]);return e},toObject:function(){var t={};return this.forEach((function(e,i){t[e]=i})),t},get size(){return this.content.length>>1}},l.from=function(t){if(t instanceof l)return t;var e=[];if(t)for(var i in t)e.push(i,t[i]);return new l(e)};class f{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,i,r=0,n){for(let s=0,h=0;h<e;s++){let l=this.content[s],o=h+l.nodeSize;if(o>t&&!1!==i(l,r+h,n||null,s)&&l.content.size){let n=h+1;l.nodesBetween(Math.max(0,t-n),Math.min(l.content.size,e-n),i,r+n)}h=o}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,i,r){let n="",s=!0;return this.nodesBetween(t,e,((h,l)=>{let o=h.isText?h.text.slice(Math.max(t,l)-l,e-l):h.isLeaf?r?"function"==typeof r?r(h):r:h.type.spec.leafText?h.type.spec.leafText(h):"":"";h.isBlock&&(h.isLeaf&&o||h.isTextblock)&&i&&(s?s=!1:n+=i),n+=o}),0),n}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,i=t.firstChild,r=this.content.slice(),n=0;for(e.isText&&e.sameMarkup(i)&&(r[r.length-1]=e.withText(e.text+i.text),n=1);n<t.content.length;n++)r.push(t.content[n]);return new f(r,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let i=[],r=0;if(e>t)for(let n=0,s=0;s<e;n++){let h=this.content[n],l=s+h.nodeSize;l>t&&((s<t||l>e)&&(h=h.isText?h.cut(Math.max(0,t-s),Math.min(h.text.length,e-s)):h.cut(Math.max(0,t-s-1),Math.min(h.content.size,e-s-1))),i.push(h),r+=h.nodeSize),s=l}return new f(i,r)}cutByIndex(t,e){return t==e?f.empty:0==t&&e==this.content.length?this:new f(this.content.slice(t,e))}replaceChild(t,e){let i=this.content[t];if(i==e)return this;let r=this.content.slice(),n=this.size+e.nodeSize-i.nodeSize;return r[t]=e,new f(r,n)}addToStart(t){return new f([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new f(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,i=0;e<this.content.length;e++){let r=this.content[e];t(r,i,e),i+=r.nodeSize}}findDiffStart(t,e=0){return o(this,t,e)}findDiffEnd(t,e=this.size,i=t.size){return u(this,t,e,i)}findIndex(t){if(0==t)return c(0,t);if(t==this.size)return c(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let e=0,i=0;;e++){let r=i+this.child(e).nodeSize;if(r>=t)return r==t?c(e+1,r):c(e,i);i=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return f.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new f(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return f.empty;let e,i=0;for(let r=0;r<t.length;r++){let n=t[r];i+=n.nodeSize,r&&n.isText&&t[r-1].sameMarkup(n)?(e||(e=t.slice(0,r)),e[e.length-1]=n.withText(e[e.length-1].text+n.text)):e&&e.push(n)}return new f(e||t,i)}static from(t){if(!t)return f.empty;if(t instanceof f)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new f([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}f.empty=new f([],0);const a={index:0,offset:0};function c(t,e){return a.index=t,a.offset=e,a}function d(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let i=Array.isArray(t);if(Array.isArray(e)!=i)return!1;if(i){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!d(t[i],e[i]))return!1}else{for(let i in t)if(!(i in e)||!d(t[i],e[i]))return!1;for(let i in e)if(!(i in t))return!1}return!0}class p{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,i=!1;for(let r=0;r<t.length;r++){let n=t[r];if(this.eq(n))return t;if(this.type.excludes(n.type))e||(e=t.slice(0,r));else{if(n.type.excludes(this.type))return t;!i&&n.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),i=!0),e&&e.push(n)}}return e||(e=t.slice()),i||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&d(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let i=t.marks[e.type];if(!i)throw new RangeError(`There is no mark type ${e.type} in this schema`);let r=i.create(e.attrs);return i.checkAttrs(r.attrs),r}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].eq(e[i]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return p.none;if(t instanceof p)return[t];let e=t.slice();return e.sort(((t,e)=>t.type.rank-e.type.rank)),e}}p.none=[];class m extends Error{}class w{constructor(t,e,i){this.content=t,this.openStart=e,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let i=b(this.content,t+this.openStart,e);return i&&new w(i,this.openStart,this.openEnd)}removeBetween(t,e){return new w(g(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return w.empty;let i=e.openStart||0,r=e.openEnd||0;if("number"!=typeof i||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new w(f.fromJSON(t,e.content),i,r)}static maxOpen(t,e=!0){let i=0,r=0;for(let r=t.firstChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.firstChild)i++;for(let i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)r++;return new w(t,i,r)}}function g(t,e,i){let{index:r,offset:n}=t.findIndex(e),s=t.maybeChild(r),{index:h,offset:l}=t.findIndex(i);if(n==e||s.isText){if(l!=i&&!t.child(h).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(i))}if(r!=h)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(g(s.content,e-n-1,i-n-1)))}function b(t,e,i,r){let{index:n,offset:s}=t.findIndex(e),h=t.maybeChild(n);if(s==e||h.isText)return r&&!r.canReplace(n,n,i)?null:t.cut(0,e).append(i).append(t.cut(e));let l=b(h.content,e-s-1,i,h);return l&&t.replaceChild(n,h.copy(l))}function y(t,e,i){if(i.openStart>t.depth)throw new m("Inserted content deeper than insertion position");if(t.depth-i.openStart!=e.depth-i.openEnd)throw new m("Inconsistent open depths");return M(t,e,i,0)}function M(t,e,i,r){let n=t.index(r),s=t.node(r);if(n==e.index(r)&&r<t.depth-i.openStart){let h=M(t,e,i,r+1);return s.copy(s.content.replaceChild(n,h))}if(i.content.size){if(i.openStart||i.openEnd||t.depth!=r||e.depth!=r){let{start:n,end:h}=function(t,e){let i=e.depth-t.openStart,r=e.node(i).copy(t.content);for(let t=i-1;t>=0;t--)r=e.node(t).copy(f.from(r));return{start:r.resolveNoCache(t.openStart+i),end:r.resolveNoCache(r.content.size-t.openEnd-i)}}(i,t);return O(s,E(t,n,h,e,r))}{let r=t.parent,n=r.content;return O(r,n.cut(0,t.parentOffset).append(i.content).append(n.cut(e.parentOffset)))}}return O(s,D(t,e,r))}function v(t,e){if(!e.type.compatibleContent(t.type))throw new m("Cannot join "+e.type.name+" onto "+t.type.name)}function k(t,e,i){let r=t.node(i);return v(r,e.node(i)),r}function S(t,e){let i=e.length-1;i>=0&&t.isText&&t.sameMarkup(e[i])?e[i]=t.withText(e[i].text+t.text):e.push(t)}function x(t,e,i,r){let n=(e||t).node(i),s=0,h=e?e.index(i):n.childCount;t&&(s=t.index(i),t.depth>i?s++:t.textOffset&&(S(t.nodeAfter,r),s++));for(let t=s;t<h;t++)S(n.child(t),r);e&&e.depth==i&&e.textOffset&&S(e.nodeBefore,r)}function O(t,e){return t.type.checkContent(e),t.copy(e)}function E(t,e,i,r,n){let s=t.depth>n&&k(t,e,n+1),h=r.depth>n&&k(i,r,n+1),l=[];return x(null,t,n,l),s&&h&&e.index(n)==i.index(n)?(v(s,h),S(O(s,E(t,e,i,r,n+1)),l)):(s&&S(O(s,D(t,e,n+1)),l),x(e,i,n,l),h&&S(O(h,D(i,r,n+1)),l)),x(r,null,n,l),new f(l)}function D(t,e,i){let r=[];return x(null,t,i,r),t.depth>i&&S(O(k(t,e,i+1),D(t,e,i+1)),r),x(e,null,i,r),new f(r)}w.empty=new w(f.empty,0,0);class R{constructor(t,e,i){this.pos=t,this.path=e,this.parentOffset=i,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let i=this.pos-this.path[this.path.length-1],r=t.child(e);return i?t.child(e).cut(i):r}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let i=this.path[3*e],r=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)r+=i.child(e).nodeSize;return r}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return p.none;if(this.textOffset)return t.child(e).marks;let i=t.maybeChild(e-1),r=t.maybeChild(e);if(!i){let t=i;i=r,r=t}let n=i.marks;for(var s=0;s<n.length;s++)!1!==n[s].type.spec.inclusive||r&&n[s].isInSet(r.marks)||(n=n[s--].removeFromSet(n));return n}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let i=e.marks,r=t.parent.maybeChild(t.index());for(var n=0;n<i.length;n++)!1!==i[n].type.spec.inclusive||r&&i[n].isInSet(r.marks)||(i=i[n--].removeFromSet(i));return i}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let i=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);i>=0;i--)if(t.pos<=this.end(i)&&(!e||e(this.node(i))))return new C(this,t,i);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let i=[],r=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n),h=n-s;if(i.push(e,t,r+s),!h)break;if(e=e.child(t),e.isText)break;n=h-1,r+=s+1}return new R(e,i,n)}static resolveCached(t,e){let i=A.get(t);if(i)for(let t=0;t<i.elts.length;t++){let r=i.elts[t];if(r.pos==e)return r}else A.set(t,i=new N);let r=i.elts[i.i]=R.resolve(t,e);return i.i=(i.i+1)%T,r}}class N{constructor(){this.elts=[],this.i=0}}const T=12,A=new WeakMap;class C{constructor(t,e,i){this.$from=t,this.$to=e,this.depth=i}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 I=Object.create(null);class P{constructor(t,e,i,r=p.none){this.type=t,this.attrs=e,this.marks=r,this.content=i||f.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,i,r=0){this.content.nodesBetween(t,e,i,r,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,i,r){return this.content.textBetween(t,e,i,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,i){return this.type==t&&d(this.attrs,e||t.defaultAttrs||I)&&p.sameSet(this.marks,i||p.none)}copy(t=null){return t==this.content?this:new P(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new P(this.type,this.attrs,this.content,t)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,i=!1){if(t==e)return w.empty;let r=this.resolve(t),n=this.resolve(e),s=i?0:r.sharedDepth(e),h=r.start(s),l=r.node(s).content.cut(r.pos-h,n.pos-h);return new w(l,r.depth-s,n.depth-s)}replace(t,e,i){return y(this.resolve(t),this.resolve(e),i)}nodeAt(t){for(let e=this;;){let{index:i,offset:r}=e.content.findIndex(t);if(e=e.maybeChild(i),!e)return null;if(r==t||e.isText)return e;t-=r+1}}childAfter(t){let{index:e,offset:i}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:i}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:i}=this.content.findIndex(t);if(i<t)return{node:this.content.child(e),index:e,offset:i};let r=this.content.child(e-1);return{node:r,index:e-1,offset:i-r.nodeSize}}resolve(t){return R.resolveCached(this,t)}resolveNoCache(t){return R.resolve(this,t)}rangeHasMark(t,e,i){let r=!1;return e>t&&this.nodesBetween(t,e,(t=>(i.isInSet(t.marks)&&(r=!0),!r))),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),$(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,i=f.empty,r=0,n=i.childCount){let s=this.contentMatchAt(t).matchFragment(i,r,n),h=s&&s.matchFragment(this.content,e);if(!h||!h.validEnd)return!1;for(let t=r;t<n;t++)if(!this.type.allowsMarks(i.child(t).marks))return!1;return!0}canReplaceWith(t,e,i,r){if(r&&!this.type.allowsMarks(r))return!1;let n=this.contentMatchAt(t).matchType(i),s=n&&n.matchFragment(this.content,e);return!!s&&s.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=p.none;for(let e=0;e<this.marks.length;e++){let i=this.marks[e];i.type.checkAttrs(i.attrs),t=i.addToSet(t)}if(!p.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t=>t.type.name))}`);this.content.forEach((t=>t.check()))}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let i;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,i)}let r=f.fromJSON(t,e.content),n=t.nodeType(e.type).create(e.attrs,r,i);return n.type.checkAttrs(n.attrs),n}}P.prototype.text=void 0;class F extends P{constructor(t,e,i,r){if(super(t,e,null,r),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):$(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new F(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new F(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function $(t,e){for(let i=t.length-1;i>=0;i--)e=t[i].type.name+"("+e+")";return e}class j{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let i=new B(t,e);if(null==i.next)return j.empty;let r=J(i);i.next&&i.err("Unexpected trailing text");let n=function(t){let e=Object.create(null);return function i(r){let n=[];r.forEach((e=>{t[e].forEach((({term:e,to:i})=>{if(!e)return;let r;for(let t=0;t<n.length;t++)n[t][0]==e&&(r=n[t][1]);U(t,i).forEach((t=>{r||n.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)}))}))}));let s=e[r.join(",")]=new j(r.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let r=n[t][1].sort(q);s.next.push({type:n[t][0],next:e[r.join(",")]||i(r)})}return s}(U(t,0))}(function(t){let e=[[]];return n(function t(e,s){if("choice"==e.type)return e.exprs.reduce(((e,i)=>e.concat(t(i,s))),[]);if("seq"!=e.type){if("star"==e.type){let h=i();return r(s,h),n(t(e.expr,h),h),[r(h)]}if("plus"==e.type){let h=i();return n(t(e.expr,s),h),n(t(e.expr,h),h),[r(h)]}if("opt"==e.type)return[r(s)].concat(t(e.expr,s));if("range"==e.type){let h=s;for(let r=0;r<e.min;r++){let r=i();n(t(e.expr,h),r),h=r}if(-1==e.max)n(t(e.expr,h),h);else for(let s=e.min;s<e.max;s++){let s=i();r(h,s),n(t(e.expr,h),s),h=s}return[r(h)]}if("name"==e.type)return[r(s,void 0,e.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let h=t(e.exprs[r],s);if(r==e.exprs.length-1)return h;n(h,s=i())}}(t,0),i()),e;function i(){return e.push([])-1}function r(t,i,r){let n={term:r,to:i};return e[t].push(n),n}function n(t,e){t.forEach((t=>t.to=e))}}(r));return function(t,e){for(let i=0,r=[t];i<r.length;i++){let t=r[i],n=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:i,next:h}=t.next[e];s.push(i.name),!n||i.isText||i.hasRequiredAttrs()||(n=!1),-1==r.indexOf(h)&&r.push(h)}n&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(n,i),n}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,i=t.childCount){let r=this;for(let n=e;r&&n<i;n++)r=r.matchType(t.child(n).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let i=0;i<t.next.length;i++)if(this.next[e].type==t.next[i].type)return!0;return!1}fillBefore(t,e=!1,i=0){let r=[this];return function n(s,h){let l=s.matchFragment(t,i);if(l&&(!e||l.validEnd))return f.from(h.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:i}=s.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==r.indexOf(i)){r.push(i);let t=n(i,h.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let r=i.shift(),n=r.match;if(n.matchType(t)){let t=[];for(let e=r;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<n.next.length;t++){let{type:s,next:h}=n.next[t];s.isLeaf||s.hasRequiredAttrs()||s.name in e||r.type&&!h.validEnd||(i.push({match:s.contentMatch,type:s,via:r}),e[s.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(i){t.push(i);for(let r=0;r<i.next.length;r++)-1==t.indexOf(i.next[r].next)&&e(i.next[r].next)}(this),t.map(((e,i)=>{let r=i+(e.validEnd?"*":" ")+" ";for(let i=0;i<e.next.length;i++)r+=(i?", ":"")+e.next[i].type.name+"->"+t.indexOf(e.next[i].next);return r})).join("\n")}}j.empty=new j(!0);class B{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function J(t){let e=[];do{e.push(_(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function _(t){let e=[];do{e.push(z(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function z(t){let e=function(t){if(t.eat("(")){let e=J(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let i=t.nodeTypes,r=i[e];if(r)return[r];let n=[];for(let t in i){let r=i[t];r.isInGroup(e)&&n.push(r)}return 0==n.length&&t.err("No node type or group '"+e+"' found"),n}(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=L(t,e)}return e}function W(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function L(t,e){let i=W(t),r=i;return t.eat(",")&&(r="}"!=t.next?W(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:i,max:r,expr:e}}function q(t,e){return e-t}function U(t,e){let i=[];return function e(r){let n=t[r];if(1==n.length&&!n[0].term)return e(n[0].to);i.push(r);for(let t=0;t<n.length;t++){let{term:r,to:s}=n[t];r||-1!=i.indexOf(s)||e(s)}}(e),i.sort(q)}function K(t){let e=Object.create(null);for(let i in t){let r=t[i];if(!r.hasDefault)return null;e[i]=r.default}return e}function V(t,e){let i=Object.create(null);for(let r in t){let n=e&&e[r];if(void 0===n){let e=t[r];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+r);n=e.default}i[r]=n}return i}function H(t,e,i){for(let r in e)if(!(r in t))throw new RangeError(`Unsupported attribute ${r} for ${i} of type ${r}`);for(let i in t){let r=t[i];r.validate&&r.validate(e[i])}}function Y(t,e){let i=Object.create(null);if(e)for(let r in e)i[r]=new X(t,r,e[r]);return i}let G=class t{constructor(t,e,i){this.name=t,this.schema=e,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=Y(t,i.attrs),this.defaultAttrs=K(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==j.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:V(this.attrs,t)}create(t=null,e,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new P(this,this.computeAttrs(t),f.from(e),p.setFrom(i))}createChecked(t=null,e,i){return e=f.from(e),this.checkContent(e),new P(this,this.computeAttrs(t),e,p.setFrom(i))}createAndFill(t=null,e,i){if(t=this.computeAttrs(t),(e=f.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let r=this.contentMatch.matchFragment(e),n=r&&r.fillBefore(f.empty,!0);return n?new P(this,t,e.append(n),p.setFrom(i)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){H(this.attrs,t,"node")}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let i=0;i<t.length;i++)this.allowsMarkType(t[i].type)?e&&e.push(t[i]):e||(e=t.slice(0,i));return e?e.length?e:p.none:t}static compile(e,i){let r=Object.create(null);e.forEach(((e,n)=>r[e]=new t(e,i,n)));let n=i.spec.topNode||"doc";if(!r[n])throw new RangeError("Schema is missing its top node type ('"+n+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let t in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class X{constructor(t,e,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate="string"==typeof i.validate?function(t,e,i){let r=i.split("|");return i=>{let n=null===i?"null":typeof i;if(r.indexOf(n)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${n}`)}}(t,e,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class Q{constructor(t,e,i,r){this.name=t,this.rank=e,this.schema=i,this.spec=r,this.attrs=Y(t,r.attrs),this.excluded=null;let n=K(this.attrs);this.instance=n?new p(this,n):null}create(t=null){return!t&&this.instance?this.instance:new p(this,V(this.attrs,t))}static compile(t,e){let i=Object.create(null),r=0;return t.forEach(((t,n)=>i[t]=new Q(t,r++,e,n))),i}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){H(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class Z{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let i in t)e[i]=t[i];e.nodes=l.from(t.nodes),e.marks=l.from(t.marks||{}),this.nodes=G.compile(this.spec.nodes,this),this.marks=Q.compile(this.spec.marks,this);let i=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],r=e.spec.content||"",n=e.spec.marks;if(e.contentMatch=i[r]||(i[r]=j.parse(r,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==n?null:n?tt(this,n.split(" ")):""!=n&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],i=e.spec.excludes;e.excluded=null==i?[e]:""==i?[]:tt(this,i.split(" "))}this.nodeFromJSON=t=>P.fromJSON(this,t),this.markFromJSON=t=>p.fromJSON(this,t),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,i,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof G))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,i,r)}text(t,e){let i=this.nodes.text;return new F(i,i.defaultAttrs,t,p.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function tt(t,e){let i=[];for(let r=0;r<e.length;r++){let n=e[r],s=t.marks[n],h=s;if(s)i.push(s);else for(let e in t.marks){let r=t.marks[e];("_"==n||r.spec.group&&r.spec.group.split(" ").indexOf(n)>-1)&&i.push(h=r)}if(!h)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return i}class et{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let i=this.matchedStyles=[];e.forEach((t=>{if(function(t){return null!=t.tag}(t))this.tags.push(t);else if(function(t){return null!=t.style}(t)){let e=/[^=]*/.exec(t.style)[0];i.indexOf(e)<0&&i.push(e),this.styles.push(t)}})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let i=t.nodes[e.node];return i.contentMatch.matchType(i)}))}parse(t,e={}){let i=new lt(this,e,!1);return i.addAll(t,p.none,e.from,e.to),i.finish()}parseSlice(t,e={}){let i=new lt(this,e,!0);return i.addAll(t,p.none,e.from,e.to),w.maxOpen(i.finish())}matchTag(t,e,i){for(let r=i?this.tags.indexOf(i)+1:0;r<this.tags.length;r++){let i=this.tags[r];if(ot(t,i.tag)&&(void 0===i.namespace||t.namespaceURI==i.namespace)&&(!i.context||e.matchesContext(i.context))){if(i.getAttrs){let e=i.getAttrs(t);if(!1===e)continue;i.attrs=e||void 0}return i}}}matchStyle(t,e,i,r){for(let n=r?this.styles.indexOf(r)+1:0;n<this.styles.length;n++){let r=this.styles[n],s=r.style;if(!(0!=s.indexOf(t)||r.context&&!i.matchesContext(r.context)||s.length>t.length&&(61!=s.charCodeAt(t.length)||s.slice(t.length+1)!=e))){if(r.getAttrs){let t=r.getAttrs(e);if(!1===t)continue;r.attrs=t||void 0}return r}}}static schemaRules(t){let e=[];function i(t){let i=null==t.priority?50:t.priority,r=0;for(;r<e.length;r++){let t=e[r];if((null==t.priority?50:t.priority)<i)break}e.splice(r,0,t)}for(let e in t.marks){let r=t.marks[e].spec.parseDOM;r&&r.forEach((t=>{i(t=ut(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)}))}for(let e in t.nodes){let r=t.nodes[e].spec.parseDOM;r&&r.forEach((t=>{i(t=ut(t)),t.node||t.ignore||t.mark||(t.node=e)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new et(t,et.schemaRules(t)))}}const it={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},rt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},nt={ol:!0,ul:!0};function st(t,e,i){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&i}class ht{constructor(t,e,i,r,n,s){this.type=t,this.attrs=e,this.marks=i,this.solid=r,this.options=s,this.content=[],this.activeMarks=p.none,this.match=n||(4&s?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(f.from(t));if(!e){let e,i=this.type.contentMatch;return(e=i.findWrapping(t.type))?(this.match=i,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let i=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-t[0].length))}}let e=f.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(f.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!it.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class lt{constructor(t,e,i){this.parser=t,this.options=e,this.isOpen=i,this.open=0,this.localPreserveWS=!1;let r,n=e.topNode,s=st(null,e.preserveWhitespace,0)|(i?4:0);r=n?new ht(n.type,n.attrs,p.none,!0,e.topMatch||n.type.contentMatch,s):new ht(i?null:t.schema.topNodeType,null,p.none,!0,null,s),this.nodes=[r],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){3==t.nodeType?this.addTextNode(t,e):1==t.nodeType&&this.addElement(t,e)}addTextNode(t,e){let i=t.nodeValue,r=this.top,n=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:s}=this.parser;if("full"===n||r.inlineContext(t)||/[^ \t\r\n\u000c]/.test(i)){if(n)if("full"===n)i=i.replace(/\r\n?/g,"\n");else if(s.linebreakReplacement&&/[\r\n]/.test(i)&&this.top.findWrapping(s.linebreakReplacement.create())){let t=i.split(/\r?\n|\r/);for(let i=0;i<t.length;i++)i&&this.insertNode(s.linebreakReplacement.create(),e,!0),t[i]&&this.insertNode(s.text(t[i]),e,!/\S/.test(t[i]));i=""}else i=i.replace(/\r?\n|\r/g," ");else if(i=i.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let e=r.content[r.content.length-1],n=t.previousSibling;(!e||n&&"BR"==n.nodeName||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))&&(i=i.slice(1))}i&&this.insertNode(s.text(i),e,!/\S/.test(i)),this.findInText(t)}else this.findInside(t)}addElement(t,e,i){let r=this.localPreserveWS,n=this.top;("PRE"==t.tagName||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let s,h=t.nodeName.toLowerCase();nt.hasOwnProperty(h)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,i=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&nt.hasOwnProperty(t)&&i?(i.appendChild(e),e=i):"li"==t?i=e:t&&(i=null)}}(t);let l=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(s=this.parser.matchTag(t,this,i));t:if(l?l.ignore:rt.hasOwnProperty(h))this.findInside(t),this.ignoreFallback(t,e);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(t=l.skip);let i,r=this.needsBlock;if(it.hasOwnProperty(h))n.content.length&&n.content[0].isInline&&this.open&&(this.open--,n=this.top),i=!0,n.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,e);break t}let s=l&&l.skip?e:this.readStyles(t,e);s&&this.addAll(t,s),i&&this.sync(n),this.needsBlock=r}else{let i=this.readStyles(t,e);i&&this.addElementByRule(t,l,i,!1===l.consuming?s:void 0)}this.localPreserveWS=r}leafFallback(t,e){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),e,!0)}readStyles(t,e){let i=t.style;if(i&&i.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let r=this.parser.matchedStyles[t],n=i.getPropertyValue(r);if(n)for(let t;;){let i=this.parser.matchStyle(r,n,this,t);if(!i)break;if(i.ignore)return null;if(e=i.clearMark?e.filter((t=>!i.clearMark(t))):e.concat(this.parser.schema.marks[i.mark].create(i.attrs)),!1!==i.consuming)break;t=i}}return e}addElementByRule(t,e,i,r){let n,s;if(e.node)if(s=this.parser.schema.nodes[e.node],s.isLeaf)this.insertNode(s.create(e.attrs),i,"BR"==t.nodeName)||this.leafFallback(t,i);else{let t=this.enter(s,e.attrs||null,i,e.preserveWhitespace);t&&(n=!0,i=t)}else i=i.concat(this.parser.schema.marks[e.mark].create(e.attrs));let h=this.top;if(s&&s.isLeaf)this.findInside(t);else if(r)this.addElement(t,i,r);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,i,!1)));else{let r=t;"string"==typeof e.contentElement?r=t.querySelector(e.contentElement):"function"==typeof e.contentElement?r=e.contentElement(t):e.contentElement&&(r=e.contentElement),this.findAround(t,r,!0),this.addAll(r,i),this.findAround(t,r,!1)}n&&this.sync(h)&&this.open--}addAll(t,e,i,r){let n=i||0;for(let s=i?t.childNodes[i]:t.firstChild,h=null==r?null:t.childNodes[r];s!=h;s=s.nextSibling,++n)this.findAtPoint(t,n),this.addDOM(s,e);this.findAtPoint(t,n)}findPlace(t,e,i){let r,n;for(let e=this.open,s=0;e>=0;e--){let h=this.nodes[e],l=h.findWrapping(t);if(l&&(!r||r.length>l.length+s)&&(r=l,n=h,!l.length))break;if(h.solid){if(i)break;s+=2}}if(!r)return null;this.sync(n);for(let t=0;t<r.length;t++)e=this.enterInner(r[t],null,e,!1);return e}insertNode(t,e,i){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&(e=this.enterInner(t,null,e))}let r=this.findPlace(t,e,i);if(r){this.closeExtra();let e=this.top;e.match&&(e.match=e.match.matchType(t.type));let i=p.none;for(let n of r.concat(t.marks))(e.type?e.type.allowsMarkType(n.type):ft(n.type,t.type))&&(i=n.addToSet(i));return e.content.push(t.mark(i)),!0}return!1}enter(t,e,i,r){let n=this.findPlace(t.create(e),i,!1);return n&&(n=this.enterInner(t,e,i,!0,r)),n}enterInner(t,e,i,r=!1,n){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let h=st(t,n,s.options);4&s.options&&0==s.content.length&&(h|=4);let l=p.none;return i=i.filter((e=>!(s.type?s.type.allowsMarkType(e.type):ft(e.type,t))||(l=e.addToSet(l),!1))),this.nodes.push(new ht(t,e,l,r,null,h)),this.open++,i}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(t){for(let e=this.open;e>=0;e--){if(this.nodes[e]==t)return this.open=e,!0;this.localPreserveWS&&(this.nodes[e].options|=1)}return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let i=this.nodes[e].content;for(let e=i.length-1;e>=0;e--)t+=i[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==t&&this.find[i].offset==e&&(this.find[i].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,i){if(t!=e&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==t.nodeType&&t.contains(this.find[r].node)&&e.compareDocumentPosition(this.find[r].node)&(i?2:4)&&(this.find[r].pos=this.currentPos)}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),i=this.options.context,r=!(this.isOpen||i&&i.parent.type!=this.nodes[0].type),n=(r?0:1)-(i?i.depth+1:0),s=(t,h)=>{for(;t>=0;t--){let l=e[t];if(""==l){if(t==e.length-1||0==t)continue;for(;h>=n;h--)if(s(t-1,h))return!0;return!1}{let t=h>0||0==h&&r?this.nodes[h].type:i&&h>=n?i.node(h-n).type:null;if(!t||t.name!=l&&!t.isInGroup(l))return!1;h--}}return!0};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let i=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function ot(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ut(t){let e={};for(let i in t)e[i]=t[i];return e}function ft(t,e){let i=e.schema.nodes;for(let r in i){let n=i[r];if(!n.allowsMarkType(t))continue;let s=[],h=t=>{s.push(t);for(let i=0;i<t.edgeCount;i++){let{type:r,next:n}=t.edge(i);if(r==e)return!0;if(s.indexOf(n)<0&&h(n))return!0}};if(h(n.contentMatch))return!0}}class at{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},i){i||(i=dt(e).createDocumentFragment());let r=i,n=[];return t.forEach((t=>{if(n.length||t.marks.length){let i=0,s=0;for(;i<n.length&&s<t.marks.length;){let e=t.marks[s];if(this.marks[e.type.name]){if(!e.eq(n[i][0])||!1===e.type.spec.spanning)break;i++,s++}else s++}for(;i<n.length;)r=n.pop()[1];for(;s<t.marks.length;){let i=t.marks[s++],h=this.serializeMark(i,t.isInline,e);h&&(n.push([i,r]),r.appendChild(h.dom),r=h.contentDOM||h.dom)}}r.appendChild(this.serializeNodeInner(t,e))})),i}serializeNodeInner(t,e){let{dom:i,contentDOM:r}=mt(dt(e),this.nodes[t.type.name](t),null,t.attrs);if(r){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,r)}return i}serializeNode(t,e={}){let i=this.serializeNodeInner(t,e);for(let r=t.marks.length-1;r>=0;r--){let n=this.serializeMark(t.marks[r],t.isInline,e);n&&((n.contentDOM||n.dom).appendChild(i),i=n.dom)}return i}serializeMark(t,e,i={}){let r=this.marks[t.type.name];return r&&mt(dt(i),r(t,e),null,t.attrs)}static renderSpec(t,e,i=null,r){return mt(t,e,i,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new at(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=ct(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return ct(t.marks)}}function ct(t){let e={};for(let i in t){let r=t[i].spec.toDOM;r&&(e[i]=r)}return e}function dt(t){return t.document||window.document}const pt=new WeakMap;function mt(t,e,i,r){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let n,s=e[0];if("string"!=typeof s)throw new RangeError("Invalid array passed to renderSpec");if(r&&(n=function(t){let e=pt.get(t);return void 0===e&&pt.set(t,e=function(t){let e=null;return function t(i){if(i&&"object"==typeof i)if(Array.isArray(i))if("string"==typeof i[0])e||(e=[]),e.push(i);else for(let e=0;e<i.length;e++)t(i[e]);else for(let e in i)t(i[e])}(t),e}(t)),e}(r))&&n.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 h,l=s.indexOf(" ");l>0&&(i=s.slice(0,l),s=s.slice(l+1));let o=i?t.createElementNS(i,s):t.createElement(s),u=e[1],f=1;if(u&&"object"==typeof u&&null==u.nodeType&&!Array.isArray(u)){f=2;for(let t in u)if(null!=u[t]){let e=t.indexOf(" ");e>0?o.setAttributeNS(t.slice(0,e),t.slice(e+1),u[t]):"style"==t&&o.style?o.style.cssText=u[t]:o.setAttribute(t,u[t])}}for(let n=f;n<e.length;n++){let s=e[n];if(0===s){if(n<e.length-1||n>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:o,contentDOM:o}}{let{dom:e,contentDOM:n}=mt(t,s,i,r);if(o.appendChild(e),n){if(h)throw new RangeError("Multiple content holes");h=n}}}return{dom:o,contentDOM:h}}const wt=Math.pow(2,16);function gt(t){return 65535&t}class bt{constructor(t,e,i){this.pos=t,this.delInfo=e,this.recover=i}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class yt{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&yt.empty)return yt.empty}recover(t){let e=0,i=gt(t);if(!this.inverted)for(let t=0;t<i;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*i]+e+function(t){return(t-(65535&t))/wt}(t)}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,i){let r=0,n=this.inverted?2:1,s=this.inverted?1:2;for(let h=0;h<this.ranges.length;h+=3){let l=this.ranges[h]-(this.inverted?r:0);if(l>t)break;let o=this.ranges[h+n],u=this.ranges[h+s],f=l+o;if(t<=f){let n=l+r+((o?t==l?-1:t==f?1:e:e)<0?0:u);if(i)return n;let s=t==l?2:t==f?1:4;return(e<0?t!=l:t!=f)&&(s|=8),new bt(n,s,t==(e<0?l:f)?null:h/3+(t-l)*wt)}r+=u-o}return i?t+r:new bt(t+r,0,null)}touches(t,e){let i=0,r=gt(e),n=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let h=this.ranges[e]-(this.inverted?i:0);if(h>t)break;let l=this.ranges[e+n];if(t<=h+l&&e==3*r)return!0;i+=this.ranges[e+s]-l}return!1}forEach(t){let e=this.inverted?2:1,i=this.inverted?1:2;for(let r=0,n=0;r<this.ranges.length;r+=3){let s=this.ranges[r],h=s-(this.inverted?n:0),l=s+(this.inverted?0:n),o=this.ranges[r+e],u=this.ranges[r+i];t(h,h+o,l,l+u),n+=u-o}}invert(){return new yt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?yt.empty:new yt(t<0?[0,-t,0]:[0,0,t])}}yt.empty=new yt([]);class Mt{constructor(t,e,i=0,r=(t?t.length:0)){this.mirror=e,this.from=i,this.to=r,this._maps=t||[],this.ownData=!(t||e)}get maps(){return this._maps}slice(t=0,e=this.maps.length){return new Mt(this._maps,this.mirror,t,e)}appendMap(t,e){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),null!=e&&this.setMirror(this._maps.length-1,e)}appendMapping(t){for(let e=0,i=this._maps.length;e<t._maps.length;e++){let r=t.getMirror(e);this.appendMap(t._maps[e],null!=r&&r<e?i+r:void 0)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,i=this._maps.length+t._maps.length;e>=0;e--){let r=t.getMirror(e);this.appendMap(t._maps[e].invert(),null!=r&&r>e?i-r-1:void 0)}}invert(){let t=new Mt;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let i=this.from;i<this.to;i++)t=this._maps[i].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,!1)}_map(t,e,i){let r=0;for(let i=this.from;i<this.to;i++){let n=this._maps[i].mapResult(t,e);if(null!=n.recover){let e=this.getMirror(i);if(null!=e&&e>i&&e<this.to){i=e,t=this._maps[e].recover(n.recover);continue}}r|=n.delInfo,t=n.pos}return i?t:new bt(t,r,null)}}const vt=Object.create(null);class kt{getMap(){return yt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=vt[e.stepType];if(!i)throw new RangeError(`No step type ${e.stepType} defined`);return i.fromJSON(t,e)}static jsonID(t,e){if(t in vt)throw new RangeError("Duplicate use of step JSON ID "+t);return vt[t]=e,e.prototype.jsonID=t,e}}class St{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new St(t,null)}static fail(t){return new St(null,t)}static fromReplace(t,e,i,r){try{return St.ok(t.replace(e,i,r))}catch(t){if(t instanceof m)return St.fail(t.message);throw t}}}function xt(t,e,i){let r=[];for(let n=0;n<t.childCount;n++){let s=t.child(n);s.content.size&&(s=s.copy(xt(s.content,e,s))),s.isInline&&(s=e(s,i,n)),r.push(s)}return f.fromArray(r)}class Ot extends kt{constructor(t,e,i){super(),this.from=t,this.to=e,this.mark=i}apply(t){let e=t.slice(this.from,this.to),i=t.resolve(this.from),r=i.node(i.sharedDepth(this.to)),n=new w(xt(e.content,((t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t),r),e.openStart,e.openEnd);return St.fromReplace(t,this.from,this.to,n)}invert(){return new Et(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);return e.deleted&&i.deleted||e.pos>=i.pos?null:new Ot(e.pos,i.pos,this.mark)}merge(t){return t instanceof Ot&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Ot(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ot(e.from,e.to,t.markFromJSON(e.mark))}}kt.jsonID("addMark",Ot);class Et extends kt{constructor(t,e,i){super(),this.from=t,this.to=e,this.mark=i}apply(t){let e=t.slice(this.from,this.to),i=new w(xt(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return St.fromReplace(t,this.from,this.to,i)}invert(){return new Ot(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);return e.deleted&&i.deleted||e.pos>=i.pos?null:new Et(e.pos,i.pos,this.mark)}merge(t){return t instanceof Et&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Et(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Et(e.from,e.to,t.markFromJSON(e.mark))}}kt.jsonID("removeMark",Et);class Dt extends kt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return St.fail("No node at mark step's position");let i=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return St.fromReplace(t,this.pos,this.pos+1,new w(f.from(i),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let i=0;i<e.marks.length;i++)if(!e.marks[i].isInSet(t))return new Dt(this.pos,e.marks[i]);return new Dt(this.pos,this.mark)}}return new Rt(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Dt(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Dt(e.pos,t.markFromJSON(e.mark))}}kt.jsonID("addNodeMark",Dt);class Rt extends kt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return St.fail("No node at mark step's position");let i=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return St.fromReplace(t,this.pos,this.pos+1,new w(f.from(i),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new Dt(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Rt(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Rt(e.pos,t.markFromJSON(e.mark))}}kt.jsonID("removeNodeMark",Rt);class Nt extends kt{constructor(t,e,i,r=!1){super(),this.from=t,this.to=e,this.slice=i,this.structure=r}apply(t){return this.structure&&At(t,this.from,this.to)?St.fail("Structure replace would overwrite content"):St.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new yt([this.from,this.to-this.from,this.slice.size])}invert(t){return new Nt(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);return e.deletedAcross&&i.deletedAcross?null:new Nt(e.pos,Math.max(e.pos,i.pos),this.slice,this.structure)}merge(t){if(!(t instanceof Nt)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let e=this.slice.size+t.slice.size==0?w.empty:new w(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Nt(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?w.empty:new w(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Nt(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Nt(e.from,e.to,w.fromJSON(t,e.slice),!!e.structure)}}kt.jsonID("replace",Nt);class Tt extends kt{constructor(t,e,i,r,n,s,h=!1){super(),this.from=t,this.to=e,this.gapFrom=i,this.gapTo=r,this.slice=n,this.insert=s,this.structure=h}apply(t){if(this.structure&&(At(t,this.from,this.gapFrom)||At(t,this.gapTo,this.to)))return St.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return St.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,e.content);return i?St.fromReplace(t,this.from,this.to,i):St.fail("Content does not fit in gap")}getMap(){return new yt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new Tt(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1),r=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1),n=this.to==this.gapTo?i.pos:t.map(this.gapTo,1);return e.deletedAcross&&i.deletedAcross||r<e.pos||n>i.pos?null:new Tt(e.pos,i.pos,r,n,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Tt(e.from,e.to,e.gapFrom,e.gapTo,w.fromJSON(t,e.slice),e.insert,!!e.structure)}}function At(t,e,i){let r=t.resolve(e),n=i-e,s=r.depth;for(;n>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,n--;if(n>0){let t=r.node(s).maybeChild(r.indexAfter(s));for(;n>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,n--}}return!1}function Ct(t,e,i,r=i.contentMatch,n=!0){let s=t.doc.nodeAt(e),h=[],l=e+1;for(let e=0;e<s.childCount;e++){let o=s.child(e),u=l+o.nodeSize,a=r.matchType(o.type);if(a){r=a;for(let e=0;e<o.marks.length;e++)i.allowsMarkType(o.marks[e].type)||t.step(new Et(l,u,o.marks[e]));if(n&&o.isText&&"pre"!=i.whitespace){let t,e,r=/\r?\n|\r/g;for(;t=r.exec(o.text);)e||(e=new w(f.from(i.schema.text(" ",i.allowedMarks(o.marks))),0,0)),h.push(new Nt(l+t.index,l+t.index+t[0].length,e))}}else h.push(new Nt(l,u,w.empty));l=u}if(!r.validEnd){let e=r.fillBefore(f.empty,!0);t.replace(l,l,new w(e,0,0))}for(let e=h.length-1;e>=0;e--)t.step(h[e])}function It(t,e,i){return(0==e||t.canReplace(e,t.childCount))&&(i==t.childCount||t.canReplace(0,i))}function Pt(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let i=t.depth,r=0,n=0;;--i){let s=t.$from.node(i),h=t.$from.index(i)+r,l=t.$to.indexAfter(i)-n;if(i<t.depth&&s.canReplace(h,l,e))return i;if(0==i||s.type.spec.isolating||!It(s,h,l))break;h&&(r=1),l<s.childCount&&(n=1)}return null}function Ft(t,e,i,r){e.forEach(((n,s)=>{if(n.isText){let h,l=/\r?\n|\r/g;for(;h=l.exec(n.text);){let n=t.mapping.slice(r).map(i+1+s+h.index);t.replaceWith(n,n+1,e.type.schema.linebreakReplacement.create())}}}))}function $t(t,e,i,r){e.forEach(((n,s)=>{if(n.type==n.type.schema.linebreakReplacement){let n=t.mapping.slice(r).map(i+1+s);t.replaceWith(n,n+1,e.type.schema.text("\n"))}}))}function jt(t,e,i=1,r){let n=t.resolve(e),s=n.depth-i,h=r&&r[r.length-1]||n.parent;if(s<0||n.parent.type.spec.isolating||!n.parent.canReplace(n.index(),n.parent.childCount)||!h.type.validContent(n.parent.content.cutByIndex(n.index(),n.parent.childCount)))return!1;for(let t=n.depth-1,e=i-2;t>s;t--,e--){let i=n.node(t),s=n.index(t);if(i.type.spec.isolating)return!1;let h=i.content.cutByIndex(s,i.childCount),l=r&&r[e+1];l&&(h=h.replaceChild(0,l.type.create(l.attrs)));let o=r&&r[e]||i;if(!i.canReplace(s+1,i.childCount)||!o.type.validContent(h))return!1}let l=n.indexAfter(s),o=r&&r[0];return n.node(s).canReplaceWith(l,l,o?o.type:n.node(s+1).type)}function Bt(t,e){let i=t.resolve(e),r=i.index();return s=i.nodeAfter,!(!(n=i.nodeBefore)||!s||n.isLeaf||!function(t,e){e.content.size||t.type.compatibleContent(e.type);let i=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let n=0;n<e.childCount;n++){let s=e.child(n);if(i=i.matchType(s.type==r?t.type.schema.nodes.text:s.type),!i)return!1;if(!t.type.allowsMarks(s.marks))return!1}return i.validEnd}(n,s))&&i.parent.canReplace(r,r+1);var n,s}function Jt(t,e,i=e,r=w.empty){if(e==i&&!r.size)return null;let n=t.resolve(e),s=t.resolve(i);return _t(n,s,r)?new Nt(e,i,r):new zt(n,s,r).fit()}function _t(t,e,i){return!i.openStart&&!i.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),i.content)}kt.jsonID("replaceAround",Tt);class zt{constructor(t,e,i){this.$from=t,this.$to=e,this.unplaced=i,this.frontier=[],this.placed=f.empty;for(let e=0;e<=t.depth;e++){let i=t.node(e);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=f.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,i=this.$from,r=this.close(t<0?this.$to:i.doc.resolve(t));if(!r)return null;let n=this.placed,s=i.depth,h=r.depth;for(;s&&h&&1==n.childCount;)n=n.firstChild.content,s--,h--;let l=new w(n,s,h);return t>-1?new Tt(i.pos,t,this.$to.pos,this.$to.end(),l,e):l.size||i.pos!=this.$to.pos?new Nt(i.pos,r.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,i=0,r=this.unplaced.openEnd;i<t;i++){let n=e.firstChild;if(e.childCount>1&&(r=0),n.type.spec.isolating&&r<=i){t=i;break}e=n.content}for(let e=1;e<=2;e++)for(let i=1==e?t:this.unplaced.openStart;i>=0;i--){let t,r=null;i?(r=qt(this.unplaced.content,i-1).firstChild,t=r.content):t=this.unplaced.content;let n=t.firstChild;for(let t=this.depth;t>=0;t--){let s,{type:h,match:l}=this.frontier[t],o=null;if(1==e&&(n?l.matchType(n.type)||(o=l.fillBefore(f.from(n),!1)):r&&h.compatibleContent(r.type)))return{sliceDepth:i,frontierDepth:t,parent:r,inject:o};if(2==e&&n&&(s=l.findWrapping(n.type)))return{sliceDepth:i,frontierDepth:t,parent:r,wrap:s};if(r&&l.matchType(r.type))break}}}openMore(){let{content:t,openStart:e,openEnd:i}=this.unplaced,r=qt(t,e);return!(!r.childCount||r.firstChild.isLeaf||(this.unplaced=new w(t,e+1,Math.max(i,r.size+e>=t.size-i?e+1:0)),0))}dropNode(){let{content:t,openStart:e,openEnd:i}=this.unplaced,r=qt(t,e);if(r.childCount<=1&&e>0){let n=t.size-e<=e+r.size;this.unplaced=new w(Wt(t,e-1,1),e-1,n?e-1:i)}else this.unplaced=new w(Wt(t,e,1),e,i)}placeNodes({sliceDepth:t,frontierDepth:e,parent:i,inject:r,wrap:n}){for(;this.depth>e;)this.closeFrontierNode();if(n)for(let t=0;t<n.length;t++)this.openFrontierNode(n[t]);let s=this.unplaced,h=i?i.content:s.content,l=s.openStart-t,o=0,u=[],{match:a,type:c}=this.frontier[e];if(r){for(let t=0;t<r.childCount;t++)u.push(r.child(t));a=a.matchFragment(r)}let d=h.size+t-(s.content.size-s.openEnd);for(;o<h.childCount;){let t=h.child(o),e=a.matchType(t.type);if(!e)break;o++,(o>1||0==l||t.content.size)&&(a=e,u.push(Ut(t.mark(c.allowedMarks(t.marks)),1==o?l:0,o==h.childCount?d:-1)))}let p=o==h.childCount;p||(d=-1),this.placed=Lt(this.placed,e,f.from(u)),this.frontier[e].match=a,p&&d<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=h;t<d;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=p?0==t?w.empty:new w(Wt(s.content,t-1,1),t-1,d<0?s.openEnd:t-1):new w(Wt(s.content,t,o),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!Kt(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:i}=this.$to,r=this.$to.after(i);for(;i>1&&r==this.$to.end(--i);)++r;return r}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:i,type:r}=this.frontier[e],n=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=Kt(t,e,r,i,n);if(s){for(let i=e-1;i>=0;i--){let{match:e,type:r}=this.frontier[i],n=Kt(t,i,r,e,!0);if(!n||n.childCount)continue t}return{depth:e,fit:s,move:n?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=Lt(this.placed,e.depth,e.fit)),t=e.move;for(let i=e.depth+1;i<=t.depth;i++){let e=t.node(i),r=e.type.contentMatch.fillBefore(e.content,!0,t.index(i));this.openFrontierNode(e.type,e.attrs,r)}return t}openFrontierNode(t,e=null,i){let r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=Lt(this.placed,this.depth,f.from(t.create(e,i))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(f.empty,!0);t.childCount&&(this.placed=Lt(this.placed,this.frontier.length,t))}}function Wt(t,e,i){return 0==e?t.cutByIndex(i,t.childCount):t.replaceChild(0,t.firstChild.copy(Wt(t.firstChild.content,e-1,i)))}function Lt(t,e,i){return 0==e?t.append(i):t.replaceChild(t.childCount-1,t.lastChild.copy(Lt(t.lastChild.content,e-1,i)))}function qt(t,e){for(let i=0;i<e;i++)t=t.firstChild.content;return t}function Ut(t,e,i){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Ut(r.firstChild,e-1,1==r.childCount?i-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),i<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(f.empty,!0)))),t.copy(r)}function Kt(t,e,i,r,n){let s=t.node(e),h=n?t.indexAfter(e):t.index(e);if(h==s.childCount&&!i.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,h);return l&&!function(t,e,i){for(let r=i;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}(i,s.content,h)?l:null}function Vt(t,e,i,r,n){if(e<i){let n=t.firstChild;t=t.replaceChild(0,n.copy(Vt(n.content,e+1,i,r,n)))}if(e>r){let e=n.contentMatchAt(0),i=e.fillBefore(t).append(t);t=i.append(e.matchFragment(i).fillBefore(f.empty,!0))}return t}function Ht(t,e){let i=[];for(let r=Math.min(t.depth,e.depth);r>=0;r--){let n=t.start(r);if(n<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(n==e.start(r)||r==t.depth&&r==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==n-1)&&i.push(r)}return i}class Yt extends kt{constructor(t,e,i){super(),this.pos=t,this.attr=e,this.value=i}apply(t){let e=t.nodeAt(this.pos);if(!e)return St.fail("No node at attribute step's position");let i=Object.create(null);for(let t in e.attrs)i[t]=e.attrs[t];i[this.attr]=this.value;let r=e.type.create(i,null,e.marks);return St.fromReplace(t,this.pos,this.pos+1,new w(f.from(r),0,e.isLeaf?0:1))}getMap(){return yt.empty}invert(t){return new Yt(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Yt(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Yt(e.pos,e.attr,e.value)}}kt.jsonID("attr",Yt);class Gt extends kt{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let i in t.attrs)e[i]=t.attrs[i];e[this.attr]=this.value;let i=t.type.create(e,t.content,t.marks);return St.ok(i)}getMap(){return yt.empty}invert(t){return new Gt(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if("string"!=typeof e.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Gt(e.attr,e.value)}}kt.jsonID("docAttr",Gt);let Xt=class extends Error{};Xt=function t(e){let i=Error.call(this,e);return i.__proto__=t.prototype,i},(Xt.prototype=Object.create(Error.prototype)).constructor=Xt,Xt.prototype.name="TransformError";class Qt{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Mt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Xt(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,i=w.empty){let r=Jt(this.doc,t,e,i);return r&&this.step(r),this}replaceWith(t,e,i){return this.replace(t,e,new w(f.from(i),0,0))}delete(t,e){return this.replace(t,e,w.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,i){return function(t,e,i,r){if(!r.size)return t.deleteRange(e,i);let n=t.doc.resolve(e),s=t.doc.resolve(i);if(_t(n,s,r))return t.step(new Nt(e,i,r));let h=Ht(n,s);0==h[h.length-1]&&h.pop();let l=-(n.depth+1);h.unshift(l);for(let t=n.depth,e=n.pos-1;t>0;t--,e--){let i=n.node(t).type.spec;if(i.defining||i.definingAsContext||i.isolating)break;h.indexOf(t)>-1?l=t:n.before(t)==e&&h.splice(1,0,-t)}let o=h.indexOf(l),u=[],f=r.openStart;for(let t=r.content,e=0;;e++){let i=t.firstChild;if(u.push(i),e==r.openStart)break;t=i.content}for(let t=f-1;t>=0;t--){let e=u[t],i=(a=e.type).spec.defining||a.spec.definingForContent;if(i&&!e.sameMarkup(n.node(Math.abs(l)-1)))f=t;else if(i||!e.type.isTextblock)break}var a;for(let e=r.openStart;e>=0;e--){let l=(e+f+1)%(r.openStart+1),a=u[l];if(a)for(let e=0;e<h.length;e++){let u=h[(e+o)%h.length],f=!0;u<0&&(f=!1,u=-u);let c=n.node(u-1),d=n.index(u-1);if(c.canReplaceWith(d,d,a.type,a.marks))return t.replace(n.before(u),f?s.after(u):i,new w(Vt(r.content,0,r.openStart,l),l,r.openEnd))}}let c=t.steps.length;for(let l=h.length-1;l>=0&&(t.replace(e,i,r),!(t.steps.length>c));l--){let t=h[l];t<0||(e=n.before(t),i=s.after(t))}}(this,t,e,i),this}replaceRangeWith(t,e,i){return function(t,e,i,r){if(!r.isInline&&e==i&&t.doc.resolve(e).parent.content.size){let n=function(t,e,i){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),i))return e;if(0==r.parentOffset)for(let t=r.depth-1;t>=0;t--){let e=r.index(t);if(r.node(t).canReplaceWith(e,e,i))return r.before(t+1);if(e>0)return null}if(r.parentOffset==r.parent.content.size)for(let t=r.depth-1;t>=0;t--){let e=r.indexAfter(t);if(r.node(t).canReplaceWith(e,e,i))return r.after(t+1);if(e<r.node(t).childCount)return null}return null}(t.doc,e,r.type);null!=n&&(e=i=n)}t.replaceRange(e,i,new w(f.from(r),0,0))}(this,t,e,i),this}deleteRange(t,e){return function(t,e,i){let r=t.doc.resolve(e),n=t.doc.resolve(i),s=Ht(r,n);for(let e=0;e<s.length;e++){let i=s[e],h=e==s.length-1;if(h&&0==i||r.node(i).type.contentMatch.validEnd)return t.delete(r.start(i),n.end(i));if(i>0&&(h||r.node(i-1).canReplace(r.index(i-1),n.indexAfter(i-1))))return t.delete(r.before(i),n.after(i))}for(let s=1;s<=r.depth&&s<=n.depth;s++)if(e-r.start(s)==r.depth-s&&i>r.end(s)&&n.end(s)-i!=n.depth-s&&r.start(s-1)==n.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),n.index(s-1)))return t.delete(r.before(s),i);t.delete(e,i)}(this,t,e),this}lift(t,e){return function(t,e,i){let{$from:r,$to:n,depth:s}=e,h=r.before(s+1),l=n.after(s+1),o=h,u=l,a=f.empty,c=0;for(let t=s,e=!1;t>i;t--)e||r.index(t)>0?(e=!0,a=f.from(r.node(t).copy(a)),c++):o--;let d=f.empty,p=0;for(let t=s,e=!1;t>i;t--)e||n.after(t+1)<n.end(t)?(e=!0,d=f.from(n.node(t).copy(d)),p++):u++;t.step(new Tt(o,u,h,l,new w(a.append(d),c,p),a.size-c,!0))}(this,t,e),this}join(t,e=1){return function(t,e,i){let r=null,{linebreakReplacement:n}=t.doc.type.schema,s=t.doc.resolve(e-i),h=s.node().type;if(n&&h.inlineContent){let t="pre"==h.whitespace,e=!!h.contentMatch.matchType(n);t&&!e?r=!1:!t&&e&&(r=!0)}let l=t.steps.length;if(!1===r){let r=t.doc.resolve(e+i);$t(t,r.node(),r.before(),l)}h.inlineContent&&Ct(t,e+i-1,h,s.node().contentMatchAt(s.index()),null==r);let o=t.mapping.slice(l),u=o.map(e-i);if(t.step(new Nt(u,o.map(e+i,-1),w.empty,!0)),!0===r){let e=t.doc.resolve(u);Ft(t,e.node(),e.before(),t.steps.length)}}(this,t,e),this}wrap(t,e){return function(t,e,i){let r=f.empty;for(let t=i.length-1;t>=0;t--){if(r.size){let e=i[t].type.contentMatch.matchFragment(r);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=f.from(i[t].type.create(i[t].attrs,r))}let n=e.start,s=e.end;t.step(new Tt(n,s,n,s,new w(r,0,0),i.length,!0))}(this,t,e),this}setBlockType(t,e=t,i,r=null){return function(t,e,i,r,n){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,i,((e,i)=>{let h="function"==typeof n?n(e):n;if(e.isTextblock&&!e.hasMarkup(r,h)&&function(t,e,i){let r=t.resolve(e),n=r.index();return r.parent.canReplaceWith(n,n+1,i)}(t.doc,t.mapping.slice(s).map(i),r)){let n=null;if(r.schema.linebreakReplacement){let t="pre"==r.whitespace,e=!!r.contentMatch.matchType(r.schema.linebreakReplacement);t&&!e?n=!1:!t&&e&&(n=!0)}!1===n&&$t(t,e,i,s),Ct(t,t.mapping.slice(s).map(i,1),r,void 0,null===n);let l=t.mapping.slice(s),o=l.map(i,1),u=l.map(i+e.nodeSize,1);return t.step(new Tt(o,u,o+1,u-1,new w(f.from(r.create(h,null,e.marks)),0,0),1,!0)),!0===n&&Ft(t,e,i,s),!1}}))}(this,t,e,i,r),this}setNodeMarkup(t,e,i=null,r){return function(t,e,i,r,n){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");i||(i=s.type);let h=i.create(r,null,n||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,h);if(!i.validContent(s.content))throw new RangeError("Invalid content for node type "+i.name);t.step(new Tt(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new w(f.from(h),0,0),1,!0))}(this,t,e,i,r),this}setNodeAttribute(t,e,i){return this.step(new Yt(t,e,i)),this}setDocAttribute(t,e){return this.step(new Gt(t,e)),this}addNodeMark(t,e){return this.step(new Dt(t,e)),this}removeNodeMark(t,e){let i=this.doc.nodeAt(t);if(!i)throw new RangeError("No node at position "+t);if(e instanceof p)e.isInSet(i.marks)&&this.step(new Rt(t,e));else{let r,n=i.marks,s=[];for(;r=e.isInSet(n);)s.push(new Rt(t,r)),n=r.removeFromSet(n);for(let t=s.length-1;t>=0;t--)this.step(s[t])}return this}split(t,e=1,i){return function(t,e,i=1,r){let n=t.doc.resolve(e),s=f.empty,h=f.empty;for(let t=n.depth,e=n.depth-i,l=i-1;t>e;t--,l--){s=f.from(n.node(t).copy(s));let e=r&&r[l];h=f.from(e?e.type.create(e.attrs,h):n.node(t).copy(h))}t.step(new Nt(e,e,new w(s.append(h),i,i),!0))}(this,t,e,i),this}addMark(t,e,i){return function(t,e,i,r){let n,s,h=[],l=[];t.doc.nodesBetween(e,i,((t,o,u)=>{if(!t.isInline)return;let f=t.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let u=Math.max(o,e),a=Math.min(o+t.nodeSize,i),c=r.addToSet(f);for(let t=0;t<f.length;t++)f[t].isInSet(c)||(n&&n.to==u&&n.mark.eq(f[t])?n.to=a:h.push(n=new Et(u,a,f[t])));s&&s.to==u?s.to=a:l.push(s=new Ot(u,a,r))}})),h.forEach((e=>t.step(e))),l.forEach((e=>t.step(e)))}(this,t,e,i),this}removeMark(t,e,i){return function(t,e,i,r){let n=[],s=0;t.doc.nodesBetween(e,i,((t,h)=>{if(!t.isInline)return;s++;let l=null;if(r instanceof Q){let e,i=t.marks;for(;e=r.isInSet(i);)(l||(l=[])).push(e),i=e.removeFromSet(i)}else r?r.isInSet(t.marks)&&(l=[r]):l=t.marks;if(l&&l.length){let r=Math.min(h+t.nodeSize,i);for(let t=0;t<l.length;t++){let i,o=l[t];for(let t=0;t<n.length;t++){let e=n[t];e.step==s-1&&o.eq(n[t].style)&&(i=e)}i?(i.to=r,i.step=s):n.push({style:o,from:Math.max(h,e),to:r,step:s})}}})),n.forEach((e=>t.step(new Et(e.from,e.to,e.style))))}(this,t,e,i),this}clearIncompatible(t,e,i){return Ct(this,t,e,i),this}}const Zt=Object.create(null);class te{constructor(t,e,i){this.$anchor=t,this.$head=e,this.ranges=i||[new ee(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=w.empty){let i=e.content.lastChild,r=null;for(let t=0;t<e.openEnd;t++)r=i,i=i.lastChild;let n=t.steps.length,s=this.ranges;for(let h=0;h<s.length;h++){let{$from:l,$to:o}=s[h],u=t.mapping.slice(n);t.replaceRange(u.map(l.pos),u.map(o.pos),h?w.empty:e),0==h&&ae(t,n,(i?i.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let i=t.steps.length,r=this.ranges;for(let n=0;n<r.length;n++){let{$from:s,$to:h}=r[n],l=t.mapping.slice(i),o=l.map(s.pos),u=l.map(h.pos);n?t.deleteRange(o,u):(t.replaceRangeWith(o,u,e),ae(t,i,e.isInline?-1:1))}}static findFrom(t,e,i=!1){let r=t.parent.inlineContent?new ne(t):fe(t.node(0),t.parent,t.pos,t.index(),e,i);if(r)return r;for(let r=t.depth-1;r>=0;r--){let n=e<0?fe(t.node(0),t.node(r),t.before(r+1),t.index(r),e,i):fe(t.node(0),t.node(r),t.after(r+1),t.index(r)+1,e,i);if(n)return n}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new oe(t.node(0))}static atStart(t){return fe(t,t,0,0,1)||new oe(t)}static atEnd(t){return fe(t,t,t.content.size,t.childCount,-1)||new oe(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=Zt[e.type];if(!i)throw new RangeError(`No selection type ${e.type} defined`);return i.fromJSON(t,e)}static jsonID(t,e){if(t in Zt)throw new RangeError("Duplicate use of selection JSON ID "+t);return Zt[t]=e,e.prototype.jsonID=t,e}getBookmark(){return ne.between(this.$anchor,this.$head).getBookmark()}}te.prototype.visible=!0;class ee{constructor(t,e){this.$from=t,this.$to=e}}let ie=!1;function re(t){ie||t.parent.inlineContent||(ie=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ne extends te{constructor(t,e=t){re(t),re(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let i=t.resolve(e.map(this.head));if(!i.parent.inlineContent)return te.near(i);let r=t.resolve(e.map(this.anchor));return new ne(r.parent.inlineContent?r:i,i)}replace(t,e=w.empty){if(super.replace(t,e),e==w.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof ne&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new se(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new ne(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,i=e){let r=t.resolve(e);return new this(r,i==e?r:t.resolve(i))}static between(t,e,i){let r=t.pos-e.pos;if(i&&!r||(i=r>=0?1:-1),!e.parent.inlineContent){let t=te.findFrom(e,i,!0)||te.findFrom(e,-i,!0);if(!t)return te.near(e,i);e=t.$head}return t.parent.inlineContent||(0==r||(t=(te.findFrom(t,-i,!0)||te.findFrom(t,i,!0)).$anchor).pos<e.pos!=r<0)&&(t=e),new ne(t,e)}}te.jsonID("text",ne);class se{constructor(t,e){this.anchor=t,this.head=e}map(t){return new se(t.map(this.anchor),t.map(this.head))}resolve(t){return ne.between(t.resolve(this.anchor),t.resolve(this.head))}}class he extends te{constructor(t){let e=t.nodeAfter,i=t.node(0).resolve(t.pos+e.nodeSize);super(t,i),this.node=e}map(t,e){let{deleted:i,pos:r}=e.mapResult(this.anchor),n=t.resolve(r);return i?te.near(n):new he(n)}content(){return new w(f.from(this.node),0,0)}eq(t){return t instanceof he&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new le(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new he(t.resolve(e.anchor))}static create(t,e){return new he(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}he.prototype.visible=!1,te.jsonID("node",he);class le{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:i}=t.mapResult(this.anchor);return e?new se(i,i):new le(i)}resolve(t){let e=t.resolve(this.anchor),i=e.nodeAfter;return i&&he.isSelectable(i)?new he(e):te.near(e)}}class oe extends te{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=w.empty){if(e==w.empty){t.delete(0,t.doc.content.size);let e=te.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new oe(t)}map(t){return new oe(t)}eq(t){return t instanceof oe}getBookmark(){return ue}}te.jsonID("all",oe);const ue={map(){return this},resolve:t=>new oe(t)};function fe(t,e,i,r,n,s=!1){if(e.inlineContent)return ne.create(t,i);for(let h=r-(n>0?0:1);n>0?h<e.childCount:h>=0;h+=n){let r=e.child(h);if(r.isAtom){if(!s&&he.isSelectable(r))return he.create(t,i-(n<0?r.nodeSize:0))}else{let e=fe(t,r,i+n,n<0?r.childCount:0,n,s);if(e)return e}i+=r.nodeSize*n}return null}function ae(t,e,i){let r=t.steps.length-1;if(r<e)return;let n,s=t.steps[r];(s instanceof Nt||s instanceof Tt)&&(t.mapping.maps[r].forEach(((t,e,i,r)=>{null==n&&(n=r)})),t.setSelection(te.near(t.doc.resolve(n),i)))}class ce extends Qt{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return p.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let i=this.selection;return e&&(t=t.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||p.none))),i.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,i){let r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();{if(null==i&&(i=e),!t)return this.deleteRange(e,i);let n=this.storedMarks;if(!n){let t=this.doc.resolve(e);n=i==e?t.marks():t.marksAcross(this.doc.resolve(i))}return this.replaceRangeWith(e,i,r.text(t,n)),this.selection.empty||this.selection.to!=e+t.length||this.setSelection(te.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function de(t,e){return e&&t?t.bind(e):t}class pe{constructor(t,e,i){this.name=t,this.init=de(e.init,i),this.apply=de(e.apply,i)}}const me=[new pe("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new pe("selection",{init:(t,e)=>t.selection||te.atStart(e.doc),apply:t=>t.selection}),new pe("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,i,r)=>r.selection.$cursor?t.storedMarks:null}),new pe("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class we{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=me.slice(),e&&e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t),this.pluginsByKey[t.key]=t,t.spec.state&&this.fields.push(new pe(t.key,t.spec.state,t))}))}}class ge{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let i=0;i<this.config.plugins.length;i++)if(i!=e){let e=this.config.plugins[i];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],i=this.applyInner(t),r=null;for(;;){let n=!1;for(let s=0;s<this.config.plugins.length;s++){let h=this.config.plugins[s];if(h.spec.appendTransaction){let l=r?r[s].n:0,o=r?r[s].state:this,u=l<e.length&&h.spec.appendTransaction.call(h,l?e.slice(l):e,o,i);if(u&&i.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",t),!r){r=[];for(let t=0;t<this.config.plugins.length;t++)r.push(t<s?{state:i,n:e.length}:{state:this,n:0})}e.push(u),i=i.applyInner(u),n=!0}r&&(r[s]={state:i,n:e.length})}}if(!n)return{state:i,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new ge(this.config),i=this.config.fields;for(let r=0;r<i.length;r++){let n=i[r];e[n.name]=n.apply(t,this[n.name],this,e)}return e}get tr(){return new ce(this)}static create(t){let e=new we(t.doc?t.doc.type.schema:t.schema,t.plugins),i=new ge(e);for(let r=0;r<e.fields.length;r++)i[e.fields[r].name]=e.fields[r].init(t,i);return i}reconfigure(t){let e=new we(this.schema,t.plugins),i=e.fields,r=new ge(e);for(let e=0;e<i.length;e++){let n=i[e].name;r[n]=this.hasOwnProperty(n)?this[n]:i[e].init(t,r)}return r}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((t=>t.toJSON()))),t&&"object"==typeof t)for(let i in t){if("doc"==i||"selection"==i)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=t[i],n=r.spec.state;n&&n.toJSON&&(e[i]=n.toJSON.call(r,this[r.key]))}return e}static fromJSON(t,e,i){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let r=new we(t.schema,t.plugins),n=new ge(r);return r.fields.forEach((r=>{if("doc"==r.name)n.doc=P.fromJSON(t.schema,e.doc);else if("selection"==r.name)n.selection=te.fromJSON(n.doc,e.selection);else if("storedMarks"==r.name)e.storedMarks&&(n.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(i)for(let s in i){let h=i[s],l=h.spec.state;if(h.key==r.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(e,s))return void(n[r.name]=l.fromJSON.call(h,t,e[s],n))}n[r.name]=r.init(t,n)}})),n}}function be(t,e,i){for(let r in t){let n=t[r];n instanceof Function?n=n.bind(e):"handleDOMEvents"==r&&(n=be(n,e,{})),i[r]=n}return i}class ye{constructor(t){var e;this.spec=t,this.props={},t.props&&be(t.props,this,this.props),this.key=t.key?t.key.key:(e="plugin")in Me?e+"$"+ ++Me[e]:(Me[e]=0,e+"$")}getState(t){return t[this.key]}}const Me=Object.create(null),ve=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},ke=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let Se=null;const xe=function(t,e,i){let r=Se||(Se=document.createRange());return r.setEnd(t,null==i?t.nodeValue.length:i),r.setStart(t,e||0),r},Oe=function(t,e,i,r){return i&&(De(t,e,i,r,-1)||De(t,e,i,r,1))},Ee=/^(img|br|input|textarea|hr)$/i;function De(t,e,i,r,n){for(var s;;){if(t==i&&e==r)return!0;if(e==(n<0?0:Re(t))){let i=t.parentNode;if(!i||1!=i.nodeType||Ne(t)||Ee.test(t.nodeName)||"false"==t.contentEditable)return!1;e=ve(t)+(n<0?0:1),t=i}else{if(1!=t.nodeType)return!1;{let i=t.childNodes[e+(n<0?-1:0)];if(1==i.nodeType&&"false"==i.contentEditable){if(!(null===(s=i.pmViewDesc)||void 0===s?void 0:s.ignoreForSelection))return!1;e+=n}else t=i,e=n<0?Re(t):0}}}}function Re(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Ne(t){let e;for(let i=t;i&&!(e=i.pmViewDesc);i=i.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Te=function(t){return t.focusNode&&Oe(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ae(t,e){let i=document.createEvent("Event");return i.initEvent("keydown",!0,!0),i.keyCode=t,i.key=i.code=e,i}const Ce="undefined"!=typeof navigator?navigator:null,Ie="undefined"!=typeof document?document:null,Pe=Ce&&Ce.userAgent||"",Fe=/Edge\/(\d+)/.exec(Pe),$e=/MSIE \d/.exec(Pe),je=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Pe),Be=!!($e||je||Fe),Je=$e?document.documentMode:je?+je[1]:Fe?+Fe[1]:0,_e=!Be&&/gecko\/(\d+)/i.test(Pe),ze=!Be&&/Chrome\/(\d+)/.exec(Pe),We=!!ze,Le=ze?+ze[1]:0,qe=!Be&&!!Ce&&/Apple Computer/.test(Ce.vendor),Ue=qe&&(/Mobile\/\w+/.test(Pe)||!!Ce&&Ce.maxTouchPoints>2),Ke=Ue||!!Ce&&/Mac/.test(Ce.platform),Ve=!!Ce&&/Win/.test(Ce.platform),He=/Android \d/.test(Pe),Ye=!!Ie&&"webkitFontSmoothing"in Ie.documentElement.style,Ge=Ye?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Xe(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Qe(t,e){return"number"==typeof t?t:t[e]}function Ze(t){let e=t.getBoundingClientRect();return{left:e.left,right:e.left+t.clientWidth*(e.width/t.offsetWidth||1),top:e.top,bottom:e.top+t.clientHeight*(e.height/t.offsetHeight||1)}}function ti(t,e,i){let r=t.someProp("scrollThreshold")||0,n=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let h=i||t.dom;h;){if(1!=h.nodeType){h=ke(h);continue}let t=h,i=t==s.body,l=i?Xe(s):Ze(t),o=0,u=0;if(e.top<l.top+Qe(r,"top")?u=-(l.top-e.top+Qe(n,"top")):e.bottom>l.bottom-Qe(r,"bottom")&&(u=e.bottom-e.top>l.bottom-l.top?e.top+Qe(n,"top")-l.top:e.bottom-l.bottom+Qe(n,"bottom")),e.left<l.left+Qe(r,"left")?o=-(l.left-e.left+Qe(n,"left")):e.right>l.right-Qe(r,"right")&&(o=e.right-l.right+Qe(n,"right")),o||u)if(i)s.defaultView.scrollBy(o,u);else{let i=t.scrollLeft,r=t.scrollTop;u&&(t.scrollTop+=u),o&&(t.scrollLeft+=o);let n=t.scrollLeft-i,s=t.scrollTop-r;e={left:e.left-n,top:e.top-s,right:e.right-n,bottom:e.bottom-s}}let f=i?"fixed":getComputedStyle(h).position;if(/^(fixed|sticky)$/.test(f))break;h="absolute"==f?h.offsetParent:ke(h)}}function ei(t){let e=[],i=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=i);r=ke(r));return e}function ii(t,e){for(let i=0;i<t.length;i++){let{dom:r,top:n,left:s}=t[i];r.scrollTop!=n+e&&(r.scrollTop=n+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let ri=null;function ni(t,e){let i,r,n,s,h=2e8,l=0,o=e.top,u=e.top;for(let f=t.firstChild,a=0;f;f=f.nextSibling,a++){let t;if(1==f.nodeType)t=f.getClientRects();else{if(3!=f.nodeType)continue;t=xe(f).getClientRects()}for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=o&&d.bottom>=u){o=Math.max(d.bottom,o),u=Math.min(d.top,u);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<h){i=f,h=t,r=t&&3==i.nodeType?{left:d.right<e.left?d.right:d.left,top:e.top}:e,1==f.nodeType&&t&&(l=a+(e.left>=(d.left+d.right)/2?1:0));continue}}else d.top>e.top&&!n&&d.left<=e.left&&d.right>=e.left&&(n=f,s={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top});!i&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(l=a+1)}}return!i&&n&&(i=n,r=s,h=0),i&&3==i.nodeType?function(t,e){let i,r=t.nodeValue.length,n=document.createRange();for(let s=0;s<r;s++){n.setEnd(t,s+1),n.setStart(t,s);let r=ui(n,1);if(r.top!=r.bottom&&si(e,r)){i={node:t,offset:s+(e.left>=(r.left+r.right)/2?1:0)};break}}return n.detach(),i||{node:t,offset:0}}(i,r):!i||h&&1==i.nodeType?{node:t,offset:l}:ni(i,r)}function si(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function hi(t,e,i){let r=t.childNodes.length;if(r&&i.top<i.bottom)for(let n=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-i.top)/(i.bottom-i.top))-2)),s=n;;){let i=t.childNodes[s];if(1==i.nodeType){let t=i.getClientRects();for(let r=0;r<t.length;r++){let n=t[r];if(si(e,n))return hi(i,e,n)}}if((s=(s+1)%r)==n)break}return t}function li(t,e){let i,r=t.dom.ownerDocument,n=0,s=function(t,e,i){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,i);if(r)return{node:r.offsetNode,offset:Math.min(Re(r.offsetNode),r.offset)}}catch(t){}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,i);if(r)return{node:r.startContainer,offset:Math.min(Re(r.startContainer),r.startOffset)}}}(r,e.left,e.top);s&&({node:i,offset:n}=s);let h,l=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top);if(!l||!t.dom.contains(1!=l.nodeType?l.parentNode:l)){let i=t.dom.getBoundingClientRect();if(!si(e,i))return null;if(l=hi(t.dom,e,i),!l)return null}if(qe)for(let t=l;i&&t;t=ke(t))t.draggable&&(i=void 0);if(l=function(t,e){let i=t.parentNode;return i&&/^li$/i.test(i.nodeName)&&e.left<t.getBoundingClientRect().left?i:t}(l,e),i){if(_e&&1==i.nodeType&&(n=Math.min(n,i.childNodes.length),n<i.childNodes.length)){let t,r=i.childNodes[n];"IMG"==r.nodeName&&(t=r.getBoundingClientRect()).right<=e.left&&t.bottom>e.top&&n++}let r;Ye&&n&&1==i.nodeType&&1==(r=i.childNodes[n-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=e.top&&n--,i==t.dom&&n==i.childNodes.length-1&&1==i.lastChild.nodeType&&e.top>i.lastChild.getBoundingClientRect().bottom?h=t.state.doc.content.size:0!=n&&1==i.nodeType&&"BR"==i.childNodes[n-1].nodeName||(h=function(t,e,i,r){let n=-1;for(let i=e,s=!1;i!=t.dom;){let e,h=t.docView.nearestDesc(i,!0);if(!h)return null;if(1==h.dom.nodeType&&(h.node.isBlock&&h.parent||!h.contentDOM)&&((e=h.dom.getBoundingClientRect()).width||e.height)&&(h.node.isBlock&&h.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(h.dom.nodeName)&&(!s&&e.left>r.left||e.top>r.top?n=h.posBefore:(!s&&e.right<r.left||e.bottom<r.top)&&(n=h.posAfter),s=!0),!h.contentDOM&&n<0&&!h.node.isText))return(h.node.isBlock?r.top<(e.top+e.bottom)/2:r.left<(e.left+e.right)/2)?h.posBefore:h.posAfter;i=h.dom.parentNode}return n>-1?n:t.docView.posFromDOM(e,i,-1)}(t,i,n,e))}null==h&&(h=function(t,e,i){let{node:r,offset:n}=ni(e,i),s=-1;if(1==r.nodeType&&!r.firstChild){let t=r.getBoundingClientRect();s=t.left!=t.right&&i.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(r,n,s)}(t,l,e));let o=t.docView.nearestDesc(l,!0);return{pos:h,inside:o?o.posAtStart-o.border:-1}}function oi(t){return t.top<t.bottom||t.left<t.right}function ui(t,e){let i=t.getClientRects();if(i.length){let t=i[e<0?0:i.length-1];if(oi(t))return t}return Array.prototype.find.call(i,oi)||t.getBoundingClientRect()}const fi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ai(t,e,i){let{node:r,offset:n,atom:s}=t.docView.domFromPos(e,i<0?-1:1),h=Ye||_e;if(3==r.nodeType){if(!h||!fi.test(r.nodeValue)&&(i<0?n:n!=r.nodeValue.length)){let t=n,e=n,s=i<0?1:-1;return i<0&&!n?(e++,s=-1):i>=0&&n==r.nodeValue.length?(t--,s=1):i<0?t--:e++,ci(ui(xe(r,t,e),s),s<0)}{let t=ui(xe(r,n,n),i);if(_e&&n&&/\s/.test(r.nodeValue[n-1])&&n<r.nodeValue.length){let e=ui(xe(r,n-1,n-1),-1);if(e.top==t.top){let i=ui(xe(r,n,n+1),-1);if(i.top!=t.top)return ci(i,i.left<e.left)}}return t}}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(null==s&&n&&(i<0||n==Re(r))){let t=r.childNodes[n-1];if(1==t.nodeType)return di(t.getBoundingClientRect(),!1)}if(null==s&&n<Re(r)){let t=r.childNodes[n];if(1==t.nodeType)return di(t.getBoundingClientRect(),!0)}return di(r.getBoundingClientRect(),i>=0)}if(null==s&&n&&(i<0||n==Re(r))){let t=r.childNodes[n-1],e=3==t.nodeType?xe(t,Re(t)-(h?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return ci(ui(e,1),!1)}if(null==s&&n<Re(r)){let t=r.childNodes[n];for(;t.pmViewDesc&&t.pmViewDesc.ignoreForCoords;)t=t.nextSibling;let e=t?3==t.nodeType?xe(t,0,h?0:1):1==t.nodeType?t:null:null;if(e)return ci(ui(e,-1),!0)}return ci(ui(3==r.nodeType?xe(r):r,-i),i>=0)}function ci(t,e){if(0==t.width)return t;let i=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:i,right:i}}function di(t,e){if(0==t.height)return t;let i=e?t.top:t.bottom;return{top:i,bottom:i,left:t.left,right:t.right}}function pi(t,e,i){let r=t.state,n=t.root.activeElement;r!=e&&t.updateState(e),n!=t.dom&&t.focus();try{return i()}finally{r!=e&&t.updateState(r),n!=t.dom&&n&&n.focus()}}const mi=/[\u0590-\u08ac]/;let wi=null,gi=null,bi=!1;class yi{constructor(t,e,i,r){this.parent=t,this.children=e,this.dom=i,this.contentDOM=r,this.dirty=0,i.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,i){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,i=this.posAtStart;;e++){let r=this.children[e];if(r==t)return i;i+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,i){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(i<0){let i,r;if(t==this.contentDOM)i=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.previousSibling}for(;i&&(!(r=i.pmViewDesc)||r.parent!=this);)i=i.previousSibling;return i?this.posBeforeChild(r)+r.size:this.posAtStart}{let i,r;if(t==this.contentDOM)i=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.nextSibling}for(;i&&(!(r=i.pmViewDesc)||r.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(r):this.posAtEnd}}let r;if(t==this.dom&&this.contentDOM)r=e>ve(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!1;break}if(e.previousSibling)break}if(null==r&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!0;break}if(e.nextSibling)break}}return(null==r?i>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let i=!0,r=t;r;r=r.parentNode){let n,s=this.getDesc(r);if(s&&(!e||s.node)){if(!i||!(n=s.nodeDOM)||(1==n.nodeType?n.contains(1==t.nodeType?t:t.parentNode):n==t))return s;i=!1}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,i){for(let r=t;r;r=r.parentNode){let n=this.getDesc(r);if(n)return n.localPosFromDOM(t,e,i)}return-1}descAt(t){for(let e=0,i=0;e<this.children.length;e++){let r=this.children[e],n=i+r.size;if(i==t&&n!=i){for(;!r.border&&r.children.length;)for(let t=0;t<r.children.length;t++){let e=r.children[t];if(e.size){r=e;break}}return r}if(t<n)return r.descAt(t-i-r.border);i=n}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let i=0,r=0;for(let e=0;i<this.children.length;i++){let n=this.children[i],s=e+n.size;if(s>t||n instanceof Ei){r=t-e;break}e=s}if(r)return this.children[i].domFromPos(r-this.children[i].border,e);for(let t;i&&!(t=this.children[i-1]).size&&t instanceof Mi&&t.side>=0;i--);if(e<=0){let t,r=!0;for(;t=i?this.children[i-1]:null,t&&t.dom.parentNode!=this.contentDOM;i--,r=!1);return t&&e&&r&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?ve(t.dom)+1:0}}{let t,r=!0;for(;t=i<this.children.length?this.children[i]:null,t&&t.dom.parentNode!=this.contentDOM;i++,r=!1);return t&&r&&!t.border&&!t.domAtom?t.domFromPos(0,e):{node:this.contentDOM,offset:t?ve(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,i=0){if(0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,n=-1;for(let s=i,h=0;;h++){let i=this.children[h],l=s+i.size;if(-1==r&&t<=l){let n=s+i.border;if(t>=n&&e<=l-i.border&&i.node&&i.contentDOM&&this.contentDOM.contains(i.contentDOM))return i.parseRange(t,e,n);t=s;for(let e=h;e>0;e--){let i=this.children[e-1];if(i.size&&i.dom.parentNode==this.contentDOM&&!i.emptyChildAt(1)){r=ve(i.dom)+1;break}t-=i.size}-1==r&&(r=0)}if(r>-1&&(l>e||h==this.children.length-1)){e=l;for(let t=h+1;t<this.children.length;t++){let i=this.children[t];if(i.size&&i.dom.parentNode==this.contentDOM&&!i.emptyChildAt(-1)){n=ve(i.dom);break}e+=i.size}-1==n&&(n=this.contentDOM.childNodes.length);break}s=l}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:n}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:i}=this.domFromPos(t,0);if(1!=e.nodeType||i==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[i]}setSelection(t,e,i,r=!1){let n=Math.min(t,e),s=Math.max(t,e);for(let h=0,l=0;h<this.children.length;h++){let o=this.children[h],u=l+o.size;if(n>l&&s<u)return o.setSelection(t-l-o.border,e-l-o.border,i,r);l=u}let h=this.domFromPos(t,t?-1:1),l=e==t?h:this.domFromPos(e,e?-1:1),o=i.root.getSelection(),u=i.domSelectionRange(),f=!1;if((_e||qe)&&t==e){let{node:t,offset:e}=h;if(3==t.nodeType){if(f=!(!e||"\n"!=t.nodeValue[e-1]),f&&e==t.nodeValue.length)for(let e,i=t;i;i=i.parentNode){if(e=i.nextSibling){"BR"==e.nodeName&&(h=l={node:e.parentNode,offset:ve(e)+1});break}let t=i.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}else{let i=t.childNodes[e-1];f=i&&("BR"==i.nodeName||"false"==i.contentEditable)}}if(_e&&u.focusNode&&u.focusNode!=l.node&&1==u.focusNode.nodeType){let t=u.focusNode.childNodes[u.focusOffset];t&&"false"==t.contentEditable&&(r=!0)}if(!(r||f&&qe)&&Oe(h.node,h.offset,u.anchorNode,u.anchorOffset)&&Oe(l.node,l.offset,u.focusNode,u.focusOffset))return;let a=!1;if((o.extend||t==e)&&(!f||!_e)){o.collapse(h.node,h.offset);try{t!=e&&o.extend(l.node,l.offset),a=!0}catch(t){}}if(!a){if(t>e){let t=h;h=l,l=t}let i=document.createRange();i.setEnd(l.node,l.offset),i.setStart(h.node,h.offset),o.removeAllRanges(),o.addRange(i)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let i=0,r=0;r<this.children.length;r++){let n=this.children[r],s=i+n.size;if(i==s?t<=s&&e>=i:t<s&&e>i){let r=i+n.border,h=s-n.border;if(t>=r&&e<=h)return this.dirty=t==i||e==s?2:1,void(t!=r||e!=h||!n.contentLost&&n.dom.parentNode==this.contentDOM?n.markDirty(t-r,e-r):n.dirty=3);n.dirty=n.dom!=n.contentDOM||n.dom.parentNode!=this.contentDOM||n.children.length?3:2}i=s}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let i=1==t?2:1;e.dirty<i&&(e.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}}class Mi extends yi{constructor(t,e,i,r){let n,s=e.type.toDOM;if("function"==typeof s&&(s=s(i,(()=>n?n.parent?n.parent.posBeforeChild(n):void 0:r))),!e.type.spec.raw){if(1!=s.nodeType){let t=document.createElement("span");t.appendChild(s),s=t}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(t,[],s,null),this.widget=e,this.widget=e,n=this}matchesWidget(t){return 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class vi extends yi{constructor(t,e,i,r){super(t,[],e,null),this.textDOM=i,this.text=r}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class ki extends yi{constructor(t,e,i,r,n){super(t,[],i,r),this.mark=e,this.spec=n}static create(t,e,i,r){let n=r.nodeViews[e.type.name],s=n&&n(e,r,i);return s&&s.dom||(s=at.renderSpec(document,e.type.spec.toDOM(e,i),null,e.attrs)),new ki(t,e,s.dom,s.contentDOM||s.dom,s)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let t=this.parent;for(;!t.node;)t=t.parent;t.dirty<this.dirty&&(t.dirty=this.dirty),this.dirty=0}}slice(t,e,i){let r=ki.create(this.parent,this.mark,!0,i),n=this.children,s=this.size;e<s&&(n=Ji(n,e,s,i)),t>0&&(n=Ji(n,0,t,i));for(let t=0;t<n.length;t++)n[t].parent=r;return r.children=n,r}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Si extends yi{constructor(t,e,i,r,n,s,h,l,o){super(t,[],n,s),this.node=e,this.outerDeco=i,this.innerDeco=r,this.nodeDOM=h}static create(t,e,i,r,n,s){let h,l=n.nodeViews[e.type.name],o=l&&l(e,n,(()=>h?h.parent?h.parent.posBeforeChild(h):void 0:s),i,r),u=o&&o.dom,f=o&&o.contentDOM;if(e.isText)if(u){if(3!=u.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else u=document.createTextNode(e.text);else if(!u){let t=at.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:u,contentDOM:f}=t)}f||e.isText||"BR"==u.nodeName||(u.hasAttribute("contenteditable")||(u.contentEditable="false"),e.type.spec.draggable&&(u.draggable=!0));let a=u;return u=Pi(u,i,e),o?h=new Di(t,e,i,r,u,f||null,a,o,n,s+1):e.isText?new Oi(t,e,i,r,u,a,n):new Si(t,e,i,r,u,f||null,a,n,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let i=this.children[e];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}t.contentElement||(t.getContent=()=>f.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,i){return 0==this.dirty&&t.eq(this.node)&&Fi(e,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let i=this.node.inlineContent,r=e,n=t.composing?this.localCompositionInfo(t,e):null,s=n&&n.pos>-1?n:null,h=n&&n.pos<0,l=new ji(this,s&&s.node,t);!function(t,e,i,r){let n=e.locals(t),s=0;if(0==n.length){for(let i=0;i<t.childCount;i++){let h=t.child(i);r(h,n,e.forChild(s,h),i),s+=h.nodeSize}return}let h=0,l=[],o=null;for(let u=0;;){let f,a,c,d;for(;h<n.length&&n[h].to==s;){let t=n[h++];t.widget&&(f?(a||(a=[f])).push(t):f=t)}if(f)if(a){a.sort(Bi);for(let t=0;t<a.length;t++)i(a[t],u,!!o)}else i(f,u,!!o);if(o)d=-1,c=o,o=null;else{if(!(u<t.childCount))break;d=u,c=t.child(u++)}for(let t=0;t<l.length;t++)l[t].to<=s&&l.splice(t--,1);for(;h<n.length&&n[h].from<=s&&n[h].to>s;)l.push(n[h++]);let p=s+c.nodeSize;if(c.isText){let t=p;h<n.length&&n[h].from<t&&(t=n[h].from);for(let e=0;e<l.length;e++)l[e].to<t&&(t=l[e].to);t<p&&(o=c.cut(t-s),c=c.cut(0,t-s),p=t,d=-1)}else for(;h<n.length&&n[h].to<p;)h++;r(c,c.isInline&&!c.isLeaf?l.filter((t=>!t.inline)):l.slice(),e.forChild(s,c),d),s=p}}(this.node,this.innerDeco,((e,n,s)=>{e.spec.marks?l.syncToMarks(e.spec.marks,i,t):e.type.side>=0&&!s&&l.syncToMarks(n==this.node.childCount?p.none:this.node.child(n).marks,i,t),l.placeWidget(e,t,r)}),((e,s,o,u)=>{let f;l.syncToMarks(e.marks,i,t),l.findNodeMatch(e,s,o,u)||h&&t.state.selection.from>r&&t.state.selection.to<r+e.nodeSize&&(f=l.findIndexWithChild(n.node))>-1&&l.updateNodeAt(e,s,o,f,t)||l.updateNextNode(e,s,o,t,u,r)||l.addNode(e,s,o,t,r),r+=e.nodeSize})),l.syncToMarks([],i,t),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(s&&this.protectLocalComposition(t,s),Ri(this.contentDOM,this.children,t),Ue&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t),t.style.cssText=e}}(this.dom))}localCompositionInfo(t,e){let{from:i,to:r}=t.state.selection;if(!(t.state.selection instanceof ne)||i<e||r>e+this.node.content.size)return null;let n=t.input.compositionNode;if(!n||!this.dom.contains(n.parentNode))return null;if(this.node.inlineContent){let t=n.nodeValue,s=function(t,e,i,r){for(let n=0,s=0;n<t.childCount&&s<=r;){let h=t.child(n++),l=s;if(s+=h.nodeSize,!h.isText)continue;let o=h.text;for(;n<t.childCount;){let e=t.child(n++);if(s+=e.nodeSize,!e.isText)break;o+=e.text}if(s>=i){if(s>=r&&o.slice(r-e.length-l,r-l)==e)return r-e.length;let t=l<r?o.lastIndexOf(e,r-l-1):-1;if(t>=0&&t+e.length+l>=i)return l+t;if(i==r&&o.length>=r+e.length-l&&o.slice(r-l,r-l+e.length)==e)return r}}return-1}(this.node.content,t,i-e,r-e);return s<0?null:{node:n,pos:s,text:t}}return{node:n,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:i,text:r}){if(this.getDesc(e))return;let n=e;for(;n.parentNode!=this.contentDOM;n=n.parentNode){for(;n.previousSibling;)n.parentNode.removeChild(n.previousSibling);for(;n.nextSibling;)n.parentNode.removeChild(n.nextSibling);n.pmViewDesc&&(n.pmViewDesc=void 0)}let s=new vi(this,n,e,r);t.input.compositionNodes.push(s),this.children=Ji(this.children,i,i+r.length,t,s)}update(t,e,i,r){return!(3==this.dirty||!t.sameMarkup(this.node)||(this.updateInner(t,e,i,r),0))}updateInner(t,e,i,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=i,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(t){if(Fi(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,i=this.dom;this.dom=Ci(this.dom,this.nodeDOM,Ai(this.outerDeco,this.node,e),Ai(t,this.node,e)),this.dom!=i&&(i.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function xi(t,e,i,r,n){Pi(r,e,t);let s=new Si(void 0,t,e,i,r,r,r,n,0);return s.contentDOM&&s.updateChildren(n,0),s}class Oi extends Si{constructor(t,e,i,r,n,s,h){super(t,e,i,r,n,null,s,h,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,i,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node)||(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,0))}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,i){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,i)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,i){let r=this.node.cut(t,e),n=document.createTextNode(r.text);return new Oi(this.parent,r,this.outerDeco,this.innerDeco,n,n,i)}markDirty(t,e){super.markDirty(t,e),this.dom==this.nodeDOM||0!=t&&e!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(t){return this.node.text==t}}class Ei extends yi{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Di extends Si{constructor(t,e,i,r,n,s,h,l,o,u){super(t,e,i,r,n,s,h,o,u),this.spec=l}update(t,e,i,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let n=this.spec.update(t,e,i);return n&&this.updateInner(t,e,i,r),n}return!(!this.contentDOM&&!t.isLeaf)&&super.update(t,e,i,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,i,r){this.spec.setSelection?this.spec.setSelection(t,e,i.root):super.setSelection(t,e,i,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function Ri(t,e,i){let r=t.firstChild,n=!1;for(let s=0;s<e.length;s++){let h=e[s],l=h.dom;if(l.parentNode==t){for(;l!=r;)r=$i(r),n=!0;r=r.nextSibling}else n=!0,t.insertBefore(l,r);if(h instanceof ki){let e=r?r.previousSibling:t.lastChild;Ri(h.contentDOM,h.children,i),r=e?e.nextSibling:t.firstChild}}for(;r;)r=$i(r),n=!0;n&&i.trackWrites==t&&(i.trackWrites=null)}const Ni=function(t){t&&(this.nodeName=t)};Ni.prototype=Object.create(null);const Ti=[new Ni];function Ai(t,e,i){if(0==t.length)return Ti;let r=i?Ti[0]:new Ni,n=[r];for(let s=0;s<t.length;s++){let h=t[s].type.attrs;if(h){h.nodeName&&n.push(r=new Ni(h.nodeName));for(let t in h){let s=h[t];null!=s&&(i&&1==n.length&&n.push(r=new Ni(e.isInline?"span":"div")),"class"==t?r.class=(r.class?r.class+" ":"")+s:"style"==t?r.style=(r.style?r.style+";":"")+s:"nodeName"!=t&&(r[t]=s))}}}return n}function Ci(t,e,i,r){if(i==Ti&&r==Ti)return e;let n=e;for(let e=0;e<r.length;e++){let s=r[e],h=i[e];if(e){let e;h&&h.nodeName==s.nodeName&&n!=t&&(e=n.parentNode)&&e.nodeName.toLowerCase()==s.nodeName||(e=document.createElement(s.nodeName),e.pmIsDeco=!0,e.appendChild(n),h=Ti[0]),n=e}Ii(n,h||Ti[0],s)}return n}function Ii(t,e,i){for(let r in e)"class"==r||"style"==r||"nodeName"==r||r in i||t.removeAttribute(r);for(let r in i)"class"!=r&&"style"!=r&&"nodeName"!=r&&i[r]!=e[r]&&t.setAttribute(r,i[r]);if(e.class!=i.class){let r=e.class?e.class.split(" ").filter(Boolean):[],n=i.class?i.class.split(" ").filter(Boolean):[];for(let e=0;e<r.length;e++)-1==n.indexOf(r[e])&&t.classList.remove(r[e]);for(let e=0;e<n.length;e++)-1==r.indexOf(n[e])&&t.classList.add(n[e]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=i.style){if(e.style){let i,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}i.style&&(t.style.cssText+=i.style)}}function Pi(t,e,i){return Ci(t,t,Ti,Ai(e,i,1!=t.nodeType))}function Fi(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].type.eq(e[i].type))return!1;return!0}function $i(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class ji{constructor(t,e,i){this.lock=e,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(t,e){let i=e,r=i.children.length,n=t.childCount,s=new Map,h=[];t:for(;n>0;){let l;for(;;)if(r){let t=i.children[r-1];if(!(t instanceof ki)){l=t,r--;break}i=t,r=t.children.length}else{if(i==e)break t;r=i.parent.children.indexOf(i),i=i.parent}let o=l.node;if(o){if(o!=t.child(n-1))break;--n,s.set(l,n),h.push(l)}}return{index:n,matched:s,matches:h.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let i=t;i<e;i++)this.top.children[i].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,i){let r=0,n=this.stack.length>>1,s=Math.min(n,t.length);for(;r<s&&(r==n-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&!1!==t[r].type.spec.spanning;)r++;for(;r<n;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),n--;for(;n<t.length;){this.stack.push(this.top,this.index+1);let r=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let i=this.top.children[e];if(i.matchesMark(t[n])&&!this.isLocked(i.dom)){r=e;break}}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=ki.create(this.top,t[n],e,i);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,n++}}findNodeMatch(t,e,i,r){let n,s=-1;if(r>=this.preMatch.index&&(n=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&n.matchesNode(t,e,i))s=this.top.children.indexOf(n,this.index);else for(let r=this.index,n=Math.min(this.top.children.length,r+5);r<n;r++){let n=this.top.children[r];if(n.matchesNode(t,e,i)&&!this.preMatch.matched.has(n)){s=r;break}}return!(s<0||(this.destroyBetween(this.index,s),this.index++,0))}updateNodeAt(t,e,i,r,n){let s=this.top.children[r];return 3==s.dirty&&s.dom==s.contentDOM&&(s.dirty=2),!!s.update(t,e,i,n)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++)if(this.top.children[t]==e)return t;return-1}t=e}}updateNextNode(t,e,i,r,n,s){for(let h=this.index;h<this.top.children.length;h++){let l=this.top.children[h];if(l instanceof Si){let o=this.preMatch.matched.get(l);if(null!=o&&o!=n)return!1;let u,f=l.dom,a=this.isLocked(f)&&!(t.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==t.text&&3!=l.dirty&&Fi(e,l.outerDeco));if(!a&&l.update(t,e,i,r))return this.destroyBetween(this.index,h),l.dom!=f&&(this.changed=!0),this.index++,!0;if(!a&&(u=this.recreateWrapper(l,t,e,i,r,s)))return this.destroyBetween(this.index,h),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=2,u.updateChildren(r,s+1),u.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,e,i,r,n,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!Fi(i,t.outerDeco)||!r.eq(t.innerDeco))return null;let h=Si.create(this.top,e,i,r,n,s);if(h.contentDOM){h.children=t.children,t.children=[];for(let t of h.children)t.parent=h}return t.destroy(),h}addNode(t,e,i,r,n){let s=Si.create(this.top,t,e,i,r,n);s.contentDOM&&s.updateChildren(r,n+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(t,e,i){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(t)||t!=r.widget&&r.widget.type.toDOM.parentNode){let r=new Mi(this.top,t,e,i);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof ki;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof Oi)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((qe||We)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let i=document.createElement(t);"IMG"==t&&(i.className="ProseMirror-separator",i.alt=""),"BR"==t&&(i.className="ProseMirror-trailingBreak");let r=new Ei(this.top,[],i,null);e!=this.top?e.children.push(r):e.children.splice(this.index++,0,r),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||1==t.nodeType&&t.contains(this.lock.parentNode))}}function Bi(t,e){return t.type.side-e.type.side}function Ji(t,e,i,r,n){let s=[];for(let h=0,l=0;h<t.length;h++){let o=t[h],u=l,f=l+=o.size;u>=i||f<=e?s.push(o):(u<e&&s.push(o.slice(0,e-u,r)),n&&(s.push(n),n=void 0),f>i&&s.push(o.slice(i-u,o.size,r)))}return s}function _i(t,e=null){let i=t.domSelectionRange(),r=t.state.doc;if(!i.focusNode)return null;let n=t.docView.nearestDesc(i.focusNode),s=n&&0==n.size,h=t.docView.posFromDOM(i.focusNode,i.focusOffset,1);if(h<0)return null;let l,o,u=r.resolve(h);if(Te(i)){for(l=h;n&&!n.node;)n=n.parent;let t=n.node;if(n&&t.isAtom&&he.isSelectable(t)&&n.parent&&(!t.isInline||!function(t,e,i){for(let r=0==e,n=e==Re(t);r||n;){if(t==i)return!0;let e=ve(t);if(!(t=t.parentNode))return!1;r=r&&0==e,n=n&&e==Re(t)}}(i.focusNode,i.focusOffset,n.dom))){let t=n.posBefore;o=new he(h==t?u:r.resolve(t))}}else{if(i instanceof t.dom.ownerDocument.defaultView.Selection&&i.rangeCount>1){let e=h,n=h;for(let r=0;r<i.rangeCount;r++){let s=i.getRangeAt(r);e=Math.min(e,t.docView.posFromDOM(s.startContainer,s.startOffset,1)),n=Math.max(n,t.docView.posFromDOM(s.endContainer,s.endOffset,-1))}if(e<0)return null;[l,h]=n==t.state.selection.anchor?[n,e]:[e,n],u=r.resolve(h)}else l=t.docView.posFromDOM(i.anchorNode,i.anchorOffset,1);if(l<0)return null}let f=r.resolve(l);return o||(o=Yi(t,f,u,"pointer"==e||t.state.selection.head<u.pos&&!s?1:-1)),o}function zi(t){return t.editable?t.hasFocus():Xi(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Wi(t,e=!1){let i=t.state.selection;if(Vi(t,i),zi(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&We){let e=t.domSelectionRange(),i=t.domObserver.currentSelection;if(e.anchorNode&&i.anchorNode&&Oe(e.anchorNode,e.anchorOffset,i.anchorNode,i.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){let e=t.domSelection();if(!e)return;let i=t.cursorWrapper.dom,r="IMG"==i.nodeName;r?e.collapse(i.parentNode,ve(i)+1):e.collapse(i,0),!r&&!t.state.selection.visible&&Be&&Je<=11&&(i.disabled=!0,i.disabled=!1)}(t);else{let r,n,{anchor:s,head:h}=i;!Li||i instanceof ne||(i.$from.parent.inlineContent||(r=qi(t,i.from)),i.empty||i.$from.parent.inlineContent||(n=qi(t,i.to))),t.docView.setSelection(s,h,t,e),Li&&(r&&Ki(r),n&&Ki(n)),i.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let i=t.domSelectionRange(),r=i.anchorNode,n=i.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{i.anchorNode==r&&i.anchorOffset==n||(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout((()=>{zi(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Li=qe||We&&Le<63;function qi(t,e){let{node:i,offset:r}=t.docView.domFromPos(e,0),n=r<i.childNodes.length?i.childNodes[r]:null,s=r?i.childNodes[r-1]:null;if(qe&&n&&"false"==n.contentEditable)return Ui(n);if(!(n&&"false"!=n.contentEditable||s&&"false"!=s.contentEditable)){if(n)return Ui(n);if(s)return Ui(s)}}function Ui(t){return t.contentEditable="true",qe&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Ki(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Vi(t,e){if(e instanceof he){let i=t.docView.descAt(e.from);i!=t.lastSelectedViewDesc&&(Hi(t),i&&i.selectNode(),t.lastSelectedViewDesc=i)}else Hi(t)}function Hi(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Yi(t,e,i,r){return t.someProp("createSelectionBetween",(r=>r(t,e,i)))||ne.between(e,i,r)}function Gi(t){return!(t.editable&&!t.hasFocus())&&Xi(t)}function Xi(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function Qi(t,e){let{$anchor:i,$head:r}=t.selection,n=e>0?i.max(r):i.min(r),s=n.parent.inlineContent?n.depth?t.doc.resolve(e>0?n.after():n.before()):null:n;return s&&te.findFrom(s,e)}function Zi(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function tr(t,e,i){let r=t.state.selection;if(!(r instanceof ne)){if(r instanceof he&&r.node.isInline)return Zi(t,new ne(e>0?r.$to:r.$from));{let i=Qi(t.state,e);return!!i&&Zi(t,i)}}if(i.indexOf("s")>-1){let{$head:i}=r,n=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!n||n.isText||!n.isLeaf)return!1;let s=t.state.doc.resolve(i.pos+n.nodeSize*(e<0?-1:1));return Zi(t,new ne(r.$anchor,s))}if(!r.empty)return!1;if(t.endOfTextblock(e>0?"forward":"backward")){let i=Qi(t.state,e);return!!(i&&i instanceof he)&&Zi(t,i)}if(!(Ke&&i.indexOf("m")>-1)){let i,n=r.$head,s=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter;if(!s||s.isText)return!1;let h=e<0?n.pos-s.nodeSize:n.pos;return!!(s.isAtom||(i=t.docView.descAt(h))&&!i.contentDOM)&&(he.isSelectable(s)?Zi(t,new he(e<0?t.state.doc.resolve(n.pos-s.nodeSize):n)):!!Ye&&Zi(t,new ne(t.state.doc.resolve(e<0?h:h+s.nodeSize))))}}function er(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function ir(t,e){let i=t.pmViewDesc;return i&&0==i.size&&(e<0||t.nextSibling||"BR"!=t.nodeName)}function rr(t,e){return e<0?function(t){let e=t.domSelectionRange(),i=e.focusNode,r=e.focusOffset;if(!i)return;let n,s,h=!1;for(_e&&1==i.nodeType&&r<er(i)&&ir(i.childNodes[r],-1)&&(h=!0);;)if(r>0){if(1!=i.nodeType)break;{let t=i.childNodes[r-1];if(ir(t,-1))n=i,s=--r;else{if(3!=t.nodeType)break;i=t,r=i.nodeValue.length}}}else{if(nr(i))break;{let e=i.previousSibling;for(;e&&ir(e,-1);)n=i.parentNode,s=ve(e),e=e.previousSibling;if(e)i=e,r=er(i);else{if(i=i.parentNode,i==t.dom)break;r=0}}}h?sr(t,i,r):n&&sr(t,n,s)}(t):function(t){let e=t.domSelectionRange(),i=e.focusNode,r=e.focusOffset;if(!i)return;let n,s,h=er(i);for(;;)if(r<h){if(1!=i.nodeType)break;if(!ir(i.childNodes[r],1))break;n=i,s=++r}else{if(nr(i))break;{let e=i.nextSibling;for(;e&&ir(e,1);)n=e.parentNode,s=ve(e)+1,e=e.nextSibling;if(e)i=e,r=0,h=er(i);else{if(i=i.parentNode,i==t.dom)break;r=h=0}}}n&&sr(t,n,s)}(t)}function nr(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function sr(t,e,i){if(3!=e.nodeType){let t,r;(r=function(t,e){for(;t&&e==t.childNodes.length&&!Ne(t);)e=ve(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let i=t.childNodes[e];if(3==i.nodeType)return i;if(1==i.nodeType&&"false"==i.contentEditable)break;t=i,e=0}}(e,i))?(e=r,i=0):(t=function(t,e){for(;t&&!e&&!Ne(t);)e=ve(t),t=t.parentNode;for(;t&&e;){let i=t.childNodes[e-1];if(3==i.nodeType)return i;if(1==i.nodeType&&"false"==i.contentEditable)break;e=(t=i).childNodes.length}}(e,i))&&(e=t,i=t.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Te(r)){let t=document.createRange();t.setEnd(e,i),t.setStart(e,i),r.removeAllRanges(),r.addRange(t)}else r.extend&&r.extend(e,i);t.domObserver.setCurSelection();let{state:n}=t;setTimeout((()=>{t.state==n&&Wi(t)}),50)}function hr(t,e){let i=t.state.doc.resolve(e);if(!We&&!Ve&&i.parent.inlineContent){let r=t.coordsAtPos(e);if(e>i.start()){let i=t.coordsAtPos(e-1),n=(i.top+i.bottom)/2;if(n>r.top&&n<r.bottom&&Math.abs(i.left-r.left)>1)return i.left<r.left?"ltr":"rtl"}if(e<i.end()){let i=t.coordsAtPos(e+1),n=(i.top+i.bottom)/2;if(n>r.top&&n<r.bottom&&Math.abs(i.left-r.left)>1)return i.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(t.dom).direction?"rtl":"ltr"}function lr(t,e,i){let r=t.state.selection;if(r instanceof ne&&!r.empty||i.indexOf("s")>-1)return!1;if(Ke&&i.indexOf("m")>-1)return!1;let{$from:n,$to:s}=r;if(!n.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=Qi(t.state,e);if(i&&i instanceof he)return Zi(t,i)}if(!n.parent.inlineContent){let i=e<0?n:s,h=r instanceof oe?te.near(i,e):te.findFrom(i,e);return!!h&&Zi(t,h)}return!1}function or(t,e){if(!(t.state.selection instanceof ne))return!0;let{$head:i,$anchor:r,empty:n}=t.state.selection;if(!i.sameParent(r))return!0;if(!n)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!i.textOffset&&(e<0?i.nodeBefore:i.nodeAfter);if(s&&!s.isText){let r=t.state.tr;return e<0?r.delete(i.pos-s.nodeSize,i.pos):r.delete(i.pos,i.pos+s.nodeSize),t.dispatch(r),!0}return!1}function ur(t,e,i){t.domObserver.stop(),e.contentEditable=i,t.domObserver.start()}function fr(t,e){t.someProp("transformCopied",(i=>{e=i(e,t)}));let i=[],{content:r,openStart:n,openEnd:s}=e;for(;n>1&&s>1&&1==r.childCount&&1==r.firstChild.childCount;){n--,s--;let t=r.firstChild;i.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),r=t.content}let h=t.someProp("clipboardSerializer")||at.fromSchema(t.state.schema),l=Mr(),o=l.createElement("div");o.appendChild(h.serializeFragment(r,{document:l}));let u,f=o.firstChild,a=0;for(;f&&1==f.nodeType&&(u=br[f.nodeName.toLowerCase()]);){for(let t=u.length-1;t>=0;t--){let e=l.createElement(u[t]);for(;o.firstChild;)e.appendChild(o.firstChild);o.appendChild(e),a++}f=o.firstChild}return f&&1==f.nodeType&&f.setAttribute("data-pm-slice",`${n} ${s}${a?` -${a}`:""} ${JSON.stringify(i)}`),{dom:o,text:t.someProp("clipboardTextSerializer",(i=>i(e,t)))||e.content.textBetween(0,e.content.size,"\n\n"),slice:e}}function ar(t,e,i,r,n){let s,h,l=n.parent.type.spec.code;if(!i&&!e)return null;let o=!!e&&(r||l||!i);if(o){if(t.someProp("transformPastedText",(i=>{e=i(e,l||r,t)})),l)return h=new w(f.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0),t.someProp("transformPasted",(e=>{h=e(h,t,!0)})),h;let i=t.someProp("clipboardTextParser",(i=>i(e,n,r,t)));if(i)h=i;else{let i=n.marks(),{schema:r}=t.state,h=at.fromSchema(r);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=s.appendChild(document.createElement("p"));t&&e.appendChild(h.serializeNode(r.text(t,i)))}))}}else t.someProp("transformPastedHTML",(e=>{i=e(i,t)})),s=function(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let i,r=Mr().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t);if((i=n&&br[n[1].toLowerCase()])&&(t=i.map((t=>"<"+t+">")).join("")+t+i.map((t=>"</"+t+">")).reverse().join("")),r.innerHTML=function(t){let e=window.trustedTypes;return e?(vr||(vr=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),vr.createHTML(t)):t}(t),i)for(let t=0;t<i.length;t++)r=r.querySelector(i[t])||r;return r}(i),Ye&&function(t){let e=t.querySelectorAll(We?"span:not([class]):not([style])":"span.Apple-converted-space");for(let i=0;i<e.length;i++){let r=e[i];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}(s);let u=s&&s.querySelector("[data-pm-slice]"),a=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(a&&a[3])for(let t=+a[3];t>0;t--){let t=s.firstChild;for(;t&&1!=t.nodeType;)t=t.nextSibling;if(!t)break;s=t}if(!h){let e=t.someProp("clipboardParser")||t.someProp("domParser")||et.fromSchema(t.state.schema);h=e.parseSlice(s,{preserveWhitespace:!(!o&&!a),context:n,ruleFromNode:t=>"BR"!=t.nodeName||t.nextSibling||!t.parentNode||cr.test(t.parentNode.nodeName)?null:{ignore:!0}})}if(a)h=function(t,e){if(!t.size)return t;let i,r=t.content.firstChild.type.schema;try{i=JSON.parse(e)}catch(e){return t}let{content:n,openStart:s,openEnd:h}=t;for(let t=i.length-2;t>=0;t-=2){let e=r.nodes[i[t]];if(!e||e.hasRequiredAttrs())break;n=f.from(e.create(i[t+1],n)),s++,h++}return new w(n,s,h)}(gr(h,+a[1],+a[2]),a[4]);else if(h=w.maxOpen(function(t,e){if(t.childCount<2)return t;for(let i=e.depth;i>=0;i--){let r,n=e.node(i).contentMatchAt(e.index(i)),s=[];if(t.forEach((t=>{if(!s)return;let e,i=n.findWrapping(t.type);if(!i)return s=null;if(e=s.length&&r.length&&pr(i,r,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=mr(s[s.length-1],r.length));let e=dr(t,i);s.push(e),n=n.matchType(e.type),r=i}})),s)return f.from(s)}return t}(h.content,n),!0),h.openStart||h.openEnd){let t=0,e=0;for(let e=h.content.firstChild;t<h.openStart&&!e.type.spec.isolating;t++,e=e.firstChild);for(let t=h.content.lastChild;e<h.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild);h=gr(h,t,e)}return t.someProp("transformPasted",(e=>{h=e(h,t,o)})),h}const cr=/^(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 dr(t,e,i=0){for(let r=e.length-1;r>=i;r--)t=e[r].create(null,f.from(t));return t}function pr(t,e,i,r,n){if(n<t.length&&n<e.length&&t[n]==e[n]){let s=pr(t,e,i,r.lastChild,n+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(n==t.length-1?i.type:t[n+1]))return r.copy(r.content.append(f.from(dr(i,t,n+1))))}}function mr(t,e){if(0==e)return t;let i=t.content.replaceChild(t.childCount-1,mr(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(f.empty,!0);return t.copy(i.append(r))}function wr(t,e,i,r,n,s){let h=e<0?t.firstChild:t.lastChild,l=h.content;return t.childCount>1&&(s=0),n<r-1&&(l=wr(l,e,i,r,n+1,s)),n>=i&&(l=e<0?h.contentMatchAt(0).fillBefore(l,s<=n).append(l):l.append(h.contentMatchAt(h.childCount).fillBefore(f.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,h.copy(l))}function gr(t,e,i){return e<t.openStart&&(t=new w(wr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),i<t.openEnd&&(t=new w(wr(t.content,1,i,t.openEnd,0,0),t.openStart,i)),t}const br={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 yr=null;function Mr(){return yr||(yr=document.implementation.createHTMLDocument("title"))}let vr=null;const kr={},Sr={},xr={touchstart:!0,touchmove:!0};class Or{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Er(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Dr(t){t.someProp("handleDOMEvents",(e=>{for(let i in e)t.input.eventHandlers[i]||t.dom.addEventListener(i,t.input.eventHandlers[i]=e=>Rr(t,e))}))}function Rr(t,e){return t.someProp("handleDOMEvents",(i=>{let r=i[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function Nr(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i=e.target;i!=t.dom;i=i.parentNode)if(!i||11==i.nodeType||i.pmViewDesc&&i.pmViewDesc.stopEvent(e))return!1;return!0}function Tr(t){return{left:t.clientX,top:t.clientY}}function Ar(t,e,i,r,n){if(-1==r)return!1;let s=t.state.doc.resolve(r);for(let r=s.depth+1;r>0;r--)if(t.someProp(e,(e=>r>s.depth?e(t,i,s.nodeAfter,s.before(r),n,!0):e(t,i,s.node(r),s.before(r),n,!1))))return!0;return!1}function Cr(t,e){if(t.focused||t.focus(),t.state.selection.eq(e))return;let i=t.state.tr.setSelection(e);i.setMeta("pointer",!0),t.dispatch(i)}function Ir(t,e,i,r){return Ar(t,"handleDoubleClickOn",e,i,r)||t.someProp("handleDoubleClick",(i=>i(t,e,r)))}function Pr(t,e,i,r){return Ar(t,"handleTripleClickOn",e,i,r)||t.someProp("handleTripleClick",(i=>i(t,e,r)))||function(t,e,i){if(0!=i.button)return!1;let r=t.state.doc;if(-1==e)return!!r.inlineContent&&(Cr(t,ne.create(r,0,r.content.size)),!0);let n=r.resolve(e);for(let e=n.depth+1;e>0;e--){let i=e>n.depth?n.nodeAfter:n.node(e),s=n.before(e);if(i.inlineContent)Cr(t,ne.create(r,s+1,s+1+i.content.size));else{if(!he.isSelectable(i))continue;Cr(t,he.create(r,s))}return!0}}(t,i,r)}function Fr(t){return Wr(t)}Sr.keydown=(t,e)=>{let i=e;if(t.input.shiftKey=16==i.keyCode||i.shiftKey,!Br(t,i)&&(t.input.lastKeyCode=i.keyCode,t.input.lastKeyCodeTime=Date.now(),!He||!We||13!=i.keyCode))if(229!=i.keyCode&&t.domObserver.forceFlush(),!Ue||13!=i.keyCode||i.ctrlKey||i.altKey||i.metaKey)t.someProp("handleKeyDown",(e=>e(t,i)))||function(t,e){let i=e.keyCode,r=function(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);if(8==i||Ke&&72==i&&"c"==r)return or(t,-1)||rr(t,-1);if(46==i&&!e.shiftKey||Ke&&68==i&&"c"==r)return or(t,1)||rr(t,1);if(13==i||27==i)return!0;if(37==i||Ke&&66==i&&"c"==r){let e=37==i?"ltr"==hr(t,t.state.selection.from)?-1:1:-1;return tr(t,e,r)||rr(t,e)}if(39==i||Ke&&70==i&&"c"==r){let e=39==i?"ltr"==hr(t,t.state.selection.from)?1:-1:1;return tr(t,e,r)||rr(t,e)}return 38==i||Ke&&80==i&&"c"==r?lr(t,-1,r)||rr(t,-1):40==i||Ke&&78==i&&"c"==r?function(t){if(!qe||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:i}=t.domSelectionRange();if(e&&1==e.nodeType&&0==i&&e.firstChild&&"false"==e.firstChild.contentEditable){let i=e.firstChild;ur(t,i,"true"),setTimeout((()=>ur(t,i,"false")),20)}return!1}(t)||lr(t,1,r)||rr(t,1):r==(Ke?"m":"c")&&(66==i||73==i||89==i||90==i)}(t,i)?i.preventDefault():Er(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",(e=>e(t,Ae(13,"Enter")))),t.input.lastIOSEnter=0)}),200)}},Sr.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},Sr.keypress=(t,e)=>{let i=e;if(Br(t,i)||!i.charCode||i.ctrlKey&&!i.altKey||Ke&&i.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,i))))return void i.preventDefault();let r=t.state.selection;if(!(r instanceof ne&&r.$from.sameParent(r.$to))){let e=String.fromCharCode(i.charCode),n=()=>t.state.tr.insertText(e).scrollIntoView();/[\r\n]/.test(e)||t.someProp("handleTextInput",(i=>i(t,r.$from.pos,r.$to.pos,e,n)))||t.dispatch(n()),i.preventDefault()}};const $r=Ke?"metaKey":"ctrlKey";kr.mousedown=(t,e)=>{let i=e;t.input.shiftKey=i.shiftKey;let r=Fr(t),n=Date.now(),s="singleClick";n-t.input.lastClick.time<500&&function(t,e){let i=e.x-t.clientX,r=e.y-t.clientY;return i*i+r*r<100}(i,t.input.lastClick)&&!i[$r]&&t.input.lastClick.button==i.button&&("singleClick"==t.input.lastClick.type?s="doubleClick":"doubleClick"==t.input.lastClick.type&&(s="tripleClick")),t.input.lastClick={time:n,x:i.clientX,y:i.clientY,type:s,button:i.button};let h=t.posAtCoords(Tr(i));h&&("singleClick"==s?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new jr(t,h,i,!!r)):("doubleClick"==s?Ir:Pr)(t,h.pos,h.inside,i)?i.preventDefault():Er(t,"pointer"))};class jr{constructor(t,e,i,r){let n,s;if(this.view=t,this.pos=e,this.event=i,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!i[$r],this.allowDefault=i.shiftKey,e.inside>-1)n=t.state.doc.nodeAt(e.inside),s=e.inside;else{let i=t.state.doc.resolve(e.pos);n=i.parent,s=i.depth?i.before():0}const h=r?null:i.target,l=h?t.docView.nearestDesc(h,!0):null;this.target=l&&1==l.nodeDOM.nodeType?l.nodeDOM:null;let{selection:o}=t.state;(0==i.button&&n.type.spec.draggable&&!1!==n.type.spec.selectable||o instanceof he&&o.from<=s&&o.to>s)&&(this.mightDrag={node:n,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!_e||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),Er(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>Wi(this.view))),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(Tr(t))),this.updateAllowDefault(t),this.allowDefault||!e?Er(this.view,"pointer"):function(t,e,i,r,n){return Ar(t,"handleClickOn",e,i,r)||t.someProp("handleClick",(i=>i(t,e,r)))||(n?function(t,e){if(-1==e)return!1;let i,r,n=t.state.selection;n instanceof he&&(i=n.node);let s=t.state.doc.resolve(e);for(let t=s.depth+1;t>0;t--){let e=t>s.depth?s.nodeAfter:s.node(t);if(he.isSelectable(e)){r=i&&n.$from.depth>0&&t>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?s.before(n.$from.depth):s.before(t);break}}return null!=r&&(Cr(t,he.create(t.state.doc,r)),!0)}(t,i):function(t,e){if(-1==e)return!1;let i=t.state.doc.resolve(e),r=i.nodeAfter;return!!(r&&r.isAtom&&he.isSelectable(r))&&(Cr(t,new he(i)),!0)}(t,i))}(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||qe&&this.mightDrag&&!this.mightDrag.node.isAtom||We&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(Cr(this.view,te.near(this.view.state.doc.resolve(e.pos))),t.preventDefault()):Er(this.view,"pointer")}move(t){this.updateAllowDefault(t),Er(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function Br(t,e){return!!t.composing||!!(qe&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}kr.touchstart=t=>{t.input.lastTouch=Date.now(),Fr(t),Er(t,"pointer")},kr.touchmove=t=>{t.input.lastTouch=Date.now(),Er(t,"pointer")},kr.contextmenu=t=>Fr(t);const Jr=He?5e3:-1;function _r(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout((()=>Wr(t)),e))}function zr(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=function(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Wr(t,e=!1){if(!(He&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),zr(t),e||t.docView&&t.docView.dirty){let i=_i(t),r=t.state.selection;return i&&!i.eq(r)?t.dispatch(t.state.tr.setSelection(i)):!t.markCursor&&!e||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.updateState(t.state):t.dispatch(t.state.tr.deleteSelection()),!0}return!1}}Sr.compositionstart=Sr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,i=e.selection.$to;if(e.selection instanceof ne&&(e.storedMarks||!i.textOffset&&i.parentOffset&&i.nodeBefore.marks.some((t=>!1===t.type.spec.inclusive))||We&&Ve&&function(t){let{focusNode:e,focusOffset:i}=t.domSelectionRange();if(!e||1!=e.nodeType||i>=e.childNodes.length)return!1;let r=e.childNodes[i];return 1==r.nodeType&&"false"==r.contentEditable}(t)))t.markCursor=t.state.storedMarks||i.marks(),Wr(t,!0),t.markCursor=null;else if(Wr(t,!e.selection.empty),_e&&e.selection.empty&&i.parentOffset&&!i.textOffset&&i.nodeBefore.marks.length){let e=t.domSelectionRange();for(let i=e.focusNode,r=e.focusOffset;i&&1==i.nodeType&&0!=r;){let e=r<0?i.lastChild:i.childNodes[r-1];if(!e)break;if(3==e.nodeType){let i=t.domSelection();i&&i.collapse(e,e.nodeValue.length);break}i=e,r=-1}}t.input.composing=!0}_r(t,Jr)},Sr.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then((()=>t.domObserver.flush())),t.input.compositionID++,_r(t,20))};const Lr=Be&&Je<15||Ue&&Ge<604;function qr(t,e,i,r,n){let s=ar(t,e,i,r,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,n,s||w.empty))))return!0;if(!s)return!1;let h=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(s),l=h?t.state.tr.replaceSelectionWith(h,r):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ur(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let i=t.getData("text/uri-list");return i?i.replace(/\r?\n/g," "):""}kr.copy=Sr.cut=(t,e)=>{let i=e,r=t.state.selection,n="cut"==i.type;if(r.empty)return;let s=Lr?null:i.clipboardData,h=r.content(),{dom:l,text:o}=fr(t,h);s?(i.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",o)):function(t,e){if(!t.dom.parentNode)return;let i=t.dom.parentNode.appendChild(document.createElement("div"));i.appendChild(e),i.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),n=document.createRange();n.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(n),setTimeout((()=>{i.parentNode&&i.parentNode.removeChild(i),t.focus()}),50)}(t,l),n&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Sr.paste=(t,e)=>{let i=e;if(t.composing&&!He)return;let r=Lr?null:i.clipboardData,n=t.input.shiftKey&&45!=t.input.lastKeyCode;r&&qr(t,Ur(r),r.getData("text/html"),n,i)?i.preventDefault():function(t,e){if(!t.dom.parentNode)return;let i=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(i?"textarea":"div"));i||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let n=t.input.shiftKey&&45!=t.input.lastKeyCode;setTimeout((()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),i?qr(t,r.value,null,n,e):qr(t,r.textContent,r.innerHTML,n,e)}),50)}(t,i)};class Kr{constructor(t,e,i){this.slice=t,this.move=e,this.node=i}}const Vr=Ke?"altKey":"ctrlKey";function Hr(t,e){let i=t.someProp("dragCopies",(t=>!t(e)));return null!=i?i:!e[Vr]}kr.dragstart=(t,e)=>{let i=e,r=t.input.mouseDown;if(r&&r.done(),!i.dataTransfer)return;let n,s=t.state.selection,h=s.empty?null:t.posAtCoords(Tr(i));if(h&&h.pos>=s.from&&h.pos<=(s instanceof he?s.to-1:s.to));else if(r&&r.mightDrag)n=he.create(t.state.doc,r.mightDrag.pos);else if(i.target&&1==i.target.nodeType){let e=t.docView.nearestDesc(i.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&(n=he.create(t.state.doc,e.posBefore))}let l=(n||t.state.selection).content(),{dom:o,text:u,slice:f}=fr(t,l);(!i.dataTransfer.files.length||!We||Le>120)&&i.dataTransfer.clearData(),i.dataTransfer.setData(Lr?"Text":"text/html",o.innerHTML),i.dataTransfer.effectAllowed="copyMove",Lr||i.dataTransfer.setData("text/plain",u),t.dragging=new Kr(f,Hr(t,i),n)},kr.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{t.dragging==e&&(t.dragging=null)}),50)},Sr.dragover=Sr.dragenter=(t,e)=>e.preventDefault(),Sr.drop=(t,e)=>{try{!function(t,e,i){if(!e.dataTransfer)return;let r=t.posAtCoords(Tr(e));if(!r)return;let n=t.state.doc.resolve(r.pos),s=i&&i.slice;s?t.someProp("transformPasted",(e=>{s=e(s,t,!1)})):s=ar(t,Ur(e.dataTransfer),Lr?null:e.dataTransfer.getData("text/html"),!1,n);let h=!(!i||!Hr(t,e));if(t.someProp("handleDrop",(i=>i(t,e,s||w.empty,h))))return void e.preventDefault();if(!s)return;e.preventDefault();let l=s?function(t,e,i){let r=t.resolve(e);if(!i.content.size)return e;let n=i.content;for(let t=0;t<i.openStart;t++)n=n.firstChild.content;for(let t=1;t<=(0==i.openStart&&i.size?2:1);t++)for(let e=r.depth;e>=0;e--){let i=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1,s=r.index(e)+(i>0?1:0),h=r.node(e),l=!1;if(1==t)l=h.canReplace(s,s,n);else{let t=h.contentMatchAt(s).findWrapping(n.firstChild.type);l=t&&h.canReplaceWith(s,s,t[0])}if(l)return 0==i?r.pos:i<0?r.before(e+1):r.after(e+1)}return null}(t.state.doc,n.pos,s):n.pos;null==l&&(l=n.pos);let o=t.state.tr;if(h){let{node:t}=i;t?t.replace(o):o.deleteSelection()}let u=o.mapping.map(l),f=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,a=o.doc;if(f?o.replaceRangeWith(u,u,s.content.firstChild):o.replaceRange(u,u,s),o.doc.eq(a))return;let c=o.doc.resolve(u);if(f&&he.isSelectable(s.content.firstChild)&&c.nodeAfter&&c.nodeAfter.sameMarkup(s.content.firstChild))o.setSelection(new he(c));else{let e=o.mapping.map(l);o.mapping.maps[o.mapping.maps.length-1].forEach(((t,i,r,n)=>e=n)),o.setSelection(Yi(t,c,o.doc.resolve(e)))}t.focus(),t.dispatch(o.setMeta("uiEvent","drop"))}(t,e,t.dragging)}finally{t.dragging=null}},kr.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Wi(t)}),20))},kr.blur=(t,e)=>{let i=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),i.relatedTarget&&t.dom.contains(i.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)},kr.beforeinput=(t,e)=>{if(We&&He&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e)return;if(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",(e=>e(t,Ae(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())}),50)}};for(let t in Sr)kr[t]=Sr[t];function Yr(t,e){if(t==e)return!0;for(let i in t)if(t[i]!==e[i])return!1;for(let i in e)if(!(i in t))return!1;return!0}class Gr{constructor(t,e){this.toDOM=t,this.spec=e||en,this.side=this.spec.side||0}map(t,e,i,r){let{pos:n,deleted:s}=t.mapResult(e.from+r,this.side<0?-1:1);return s?null:new Zr(n-i,n-i,this)}valid(){return!0}eq(t){return this==t||t instanceof Gr&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Yr(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class Xr{constructor(t,e){this.attrs=t,this.spec=e||en}map(t,e,i,r){let n=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-i,s=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-i;return n>=s?null:new Zr(n,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof Xr&&Yr(this.attrs,t.attrs)&&Yr(this.spec,t.spec)}static is(t){return t.type instanceof Xr}destroy(){}}class Qr{constructor(t,e){this.attrs=t,this.spec=e||en}map(t,e,i,r){let n=t.mapResult(e.from+r,1);if(n.deleted)return null;let s=t.mapResult(e.to+r,-1);return s.deleted||s.pos<=n.pos?null:new Zr(n.pos-i,s.pos-i,this)}valid(t,e){let i,{index:r,offset:n}=t.content.findIndex(e.from);return n==e.from&&!(i=t.child(r)).isText&&n+i.nodeSize==e.to}eq(t){return this==t||t instanceof Qr&&Yr(this.attrs,t.attrs)&&Yr(this.spec,t.spec)}destroy(){}}class Zr{constructor(t,e,i){this.from=t,this.to=e,this.type=i}copy(t,e){return new Zr(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,i){return this.type.map(t,this,e,i)}static widget(t,e,i){return new Zr(t,t,new Gr(e,i))}static inline(t,e,i,r){return new Zr(t,e,new Xr(i,r))}static node(t,e,i,r){return new Zr(t,e,new Qr(i,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Xr}get widget(){return this.type instanceof Gr}}const tn=[],en={};class rn{constructor(t,e){this.local=t.length?t:tn,this.children=e.length?e:tn}static create(t,e){return e.length?un(e,t,0,en):nn}find(t,e,i){let r=[];return this.findInner(null==t?0:t,null==e?1e9:e,r,0,i),r}findInner(t,e,i,r,n){for(let s=0;s<this.local.length;s++){let h=this.local[s];h.from<=e&&h.to>=t&&(!n||n(h.spec))&&i.push(h.copy(h.from+r,h.to+r))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<e&&this.children[s+1]>t){let h=this.children[s]+1;this.children[s+2].findInner(t-h,e-h,i,r+h,n)}}map(t,e,i){return this==nn||0==t.maps.length?this:this.mapInner(t,e,0,0,i||en)}mapInner(t,e,i,r,n){let s;for(let h=0;h<this.local.length;h++){let l=this.local[h].map(t,i,r);l&&l.type.valid(e,l)?(s||(s=[])).push(l):n.onRemove&&n.onRemove(this.local[h].spec)}return this.children.length?function(t,e,i,r,n,s,h){let l=t.slice();for(let t=0,e=s;t<i.maps.length;t++){let r=0;i.maps[t].forEach(((t,i,n,s)=>{let h=s-n-(i-t);for(let n=0;n<l.length;n+=3){let s=l[n+1];if(s<0||t>s+e-r)continue;let o=l[n]+e-r;i>=o?l[n+1]=t<=o?-2:-1:t>=e&&h&&(l[n]+=h,l[n+1]+=h)}r+=h})),e=i.maps[t].map(e,-1)}let o=!1;for(let e=0;e<l.length;e+=3)if(l[e+1]<0){if(-2==l[e+1]){o=!0,l[e+1]=-1;continue}let u=i.map(t[e]+s),f=u-n;if(f<0||f>=r.content.size){o=!0;continue}let a=i.map(t[e+1]+s,-1)-n,{index:c,offset:d}=r.content.findIndex(f),p=r.maybeChild(c);if(p&&d==f&&d+p.nodeSize==a){let r=l[e+2].mapInner(i,p,u+1,t[e]+s+1,h);r!=nn?(l[e]=f,l[e+1]=a,l[e+2]=r):(l[e+1]=-2,o=!0)}else o=!0}if(o){let o=function(t,e,i,r,n,s,h){function l(t,e){for(let s=0;s<t.local.length;s++){let l=t.local[s].map(r,n,e);l?i.push(l):h.onRemove&&h.onRemove(t.local[s].spec)}for(let i=0;i<t.children.length;i+=3)l(t.children[i+2],t.children[i]+e+1)}for(let i=0;i<t.length;i+=3)-1==t[i+1]&&l(t[i+2],e[i]+s+1);return i}(l,t,e,i,n,s,h),u=un(o,r,0,h);e=u.local;for(let t=0;t<l.length;t+=3)l[t+1]<0&&(l.splice(t,3),t-=3);for(let t=0,e=0;t<u.children.length;t+=3){let i=u.children[t];for(;e<l.length&&l[e]<i;)e+=3;l.splice(e,0,u.children[t],u.children[t+1],u.children[t+2])}}return new rn(e.sort(fn),l)}(this.children,s||[],t,e,i,r,n):s?new rn(s.sort(fn),tn):nn}add(t,e){return e.length?this==nn?rn.create(t,e):this.addInner(t,e,0):this}addInner(t,e,i){let r,n=0;t.forEach(((t,s)=>{let h,l=s+i;if(h=ln(e,t,l)){for(r||(r=this.children.slice());n<r.length&&r[n]<s;)n+=3;r[n]==s?r[n+2]=r[n+2].addInner(t,h,l+1):r.splice(n,0,s,s+t.nodeSize,un(h,t,l+1,en)),n+=3}}));let s=hn(n?on(e):e,-i);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||s.splice(e--,1);return new rn(s.length?this.local.concat(s).sort(fn):this.local,r||this.children)}remove(t){return 0==t.length||this==nn?this:this.removeInner(t,0)}removeInner(t,e){let i=this.children,r=this.local;for(let r=0;r<i.length;r+=3){let n,s=i[r]+e,h=i[r+1]+e;for(let e,i=0;i<t.length;i++)(e=t[i])&&e.from>s&&e.to<h&&(t[i]=null,(n||(n=[])).push(e));if(!n)continue;i==this.children&&(i=this.children.slice());let l=i[r+2].removeInner(n,s+1);l!=nn?i[r+2]=l:(i.splice(r,3),r-=3)}if(r.length)for(let i,n=0;n<t.length;n++)if(i=t[n])for(let t=0;t<r.length;t++)r[t].eq(i,e)&&(r==this.local&&(r=this.local.slice()),r.splice(t--,1));return i==this.children&&r==this.local?this:r.length||i.length?new rn(r,i):nn}forChild(t,e){if(this==nn)return this;if(e.isLeaf)return rn.empty;let i,r;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(i=this.children[e+2]);break}let n=t+1,s=n+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>n&&e.type instanceof Xr){let t=Math.max(n,e.from)-n,i=Math.min(s,e.to)-n;t<i&&(r||(r=[])).push(e.copy(t,i))}}if(r){let t=new rn(r.sort(fn),tn);return i?new sn([t,i]):t}return i||nn}eq(t){if(this==t)return!0;if(!(t instanceof rn)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(t){return an(this.localsInner(t))}localsInner(t){if(this==nn)return tn;if(t.inlineContent||!this.local.some(Xr.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++)this.local[t].type instanceof Xr||e.push(this.local[t]);return e}forEachSet(t){t(this)}}rn.empty=new rn([],[]),rn.removeOverlap=an;const nn=rn.empty;class sn{constructor(t){this.members=t}map(t,e){const i=this.members.map((i=>i.map(t,e,en)));return sn.from(i)}forChild(t,e){if(e.isLeaf)return rn.empty;let i=[];for(let r=0;r<this.members.length;r++){let n=this.members[r].forChild(t,e);n!=nn&&(n instanceof sn?i=i.concat(n.members):i.push(n))}return sn.from(i)}eq(t){if(!(t instanceof sn)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,i=!0;for(let r=0;r<this.members.length;r++){let n=this.members[r].localsInner(t);if(n.length)if(e){i&&(e=e.slice(),i=!1);for(let t=0;t<n.length;t++)e.push(n[t])}else e=n}return e?an(i?e:e.sort(fn)):tn}static from(t){switch(t.length){case 0:return nn;case 1:return t[0];default:return new sn(t.every((t=>t instanceof rn))?t:t.reduce(((t,e)=>t.concat(e instanceof rn?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function hn(t,e){if(!e||!t.length)return t;let i=[];for(let r=0;r<t.length;r++){let n=t[r];i.push(new Zr(n.from+e,n.to+e,n.type))}return i}function ln(t,e,i){if(e.isLeaf)return null;let r=i+e.nodeSize,n=null;for(let e,s=0;s<t.length;s++)(e=t[s])&&e.from>i&&e.to<r&&((n||(n=[])).push(e),t[s]=null);return n}function on(t){let e=[];for(let i=0;i<t.length;i++)null!=t[i]&&e.push(t[i]);return e}function un(t,e,i,r){let n=[],s=!1;e.forEach(((e,h)=>{let l=ln(t,e,h+i);if(l){s=!0;let t=un(l,e,i+h+1,r);t!=nn&&n.push(h,h+e.nodeSize,t)}}));let h=hn(s?on(t):t,-i).sort(fn);for(let t=0;t<h.length;t++)h[t].type.valid(e,h[t])||(r.onRemove&&r.onRemove(h[t].spec),h.splice(t--,1));return h.length||n.length?new rn(h,n):nn}function fn(t,e){return t.from-e.from||t.to-e.to}function an(t){let e=t;for(let i=0;i<e.length-1;i++){let r=e[i];if(r.from!=r.to)for(let n=i+1;n<e.length;n++){let s=e[n];if(s.from!=r.from){s.from<r.to&&(e==t&&(e=t.slice()),e[i]=r.copy(r.from,s.from),cn(e,n,r.copy(s.from,r.to)));break}s.to!=r.to&&(e==t&&(e=t.slice()),e[n]=s.copy(s.from,r.to),cn(e,n+1,s.copy(r.to,s.to)))}}return e}function cn(t,e,i){for(;e<t.length&&fn(i,t[e])>0;)e++;t.splice(e,0,i)}function dn(t){let e=[];return t.someProp("decorations",(i=>{let r=i(t.state);r&&r!=nn&&e.push(r)})),t.cursorWrapper&&e.push(rn.create(t.state.doc,[t.cursorWrapper.deco])),sn.from(e)}const pn={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},mn=Be&&Je<=11;class wn{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class gn{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new wn,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);Be&&Je<=11&&t.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),mn&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,pn)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(Gi(this.view)){if(this.suppressingSelectionUpdates)return Wi(this.view);if(Be&&Je<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Oe(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e,i=new Set;for(let e=t.focusNode;e;e=ke(e))i.add(e);for(let r=t.anchorNode;r;r=ke(r))if(i.has(r)){e=r;break}let r=e&&this.view.docView.nearestDesc(e);return r&&r.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();e.length&&(this.queue=[]);let i=t.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&Gi(t)&&!this.ignoreSelectionChange(i),n=-1,s=-1,h=!1,l=[];if(t.editable)for(let t=0;t<e.length;t++){let i=this.registerMutation(e[t],l);i&&(n=n<0?i.from:Math.min(i.from,n),s=s<0?i.to:Math.max(i.to,s),i.typeOver&&(h=!0))}if(_e&&l.length){let e=l.filter((t=>"BR"==t.nodeName));if(2==e.length){let[t,i]=e;t.parentNode&&t.parentNode.parentNode==i.parentNode?i.remove():t.remove()}else{let{focusNode:i}=this.currentSelection;for(let r of e){let e=r.parentNode;!e||"LI"!=e.nodeName||i&&vn(t,i)==e||r.remove()}}}else if((We||qe)&&l.some((t=>"BR"==t.nodeName))&&(8==t.input.lastKeyCode||46==t.input.lastKeyCode))for(let t of l)if("BR"==t.nodeName&&t.parentNode){let e=t.nextSibling;e&&1==e.nodeType&&"false"==e.contentEditable&&t.parentNode.removeChild(t)}let o=null;n<0&&r&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Te(i)&&(o=_i(t))&&o.eq(te.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,Wi(t),this.currentSelection.set(i),t.scrollToSelection()):(n>-1||r)&&(n>-1&&(t.docView.markDirty(n,s),function(t){if(!bn.has(t)&&(bn.set(t,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace))){if(t.requiresGeckoHackNode=_e,yn)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."),yn=!0}}(t)),this.handleDOMChange(n,s,h,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(i)||Wi(t),this.currentSelection.set(i))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let i=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(i==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!i||i.ignoreMutation(t))return null;if("childList"==t.type){for(let i=0;i<t.addedNodes.length;i++){let r=t.addedNodes[i];e.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(t.target))return{from:i.posBefore,to:i.posAfter};let r=t.previousSibling,n=t.nextSibling;if(Be&&Je<=11&&t.addedNodes.length)for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:i,nextSibling:s}=t.addedNodes[e];(!i||Array.prototype.indexOf.call(t.addedNodes,i)<0)&&(r=i),(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)&&(n=s)}let s=r&&r.parentNode==t.target?ve(r)+1:0,h=i.localPosFromDOM(t.target,s,-1),l=n&&n.parentNode==t.target?ve(n):t.target.childNodes.length;return{from:h,to:i.localPosFromDOM(t.target,l,1)}}return"attributes"==t.type?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=t.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let bn=new WeakMap,yn=!1;function Mn(t,e){let i=e.startContainer,r=e.startOffset,n=e.endContainer,s=e.endOffset,h=t.domAtPos(t.state.selection.anchor);return Oe(h.node,h.offset,n,s)&&([i,r,n,s]=[n,s,i,r]),{anchorNode:i,anchorOffset:r,focusNode:n,focusOffset:s}}function vn(t,e){for(let i=e.parentNode;i&&i!=t.dom;i=i.parentNode){let e=t.docView.nearestDesc(i,!0);if(e&&e.node.isBlock)return i}return null}function kn(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(qe&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||qe&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Sn=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function xn(t,e,i){return Math.max(i.anchor,i.head)>e.content.size?null:Yi(t,e.resolve(i.anchor),e.resolve(i.head))}function On(t,e,i){let r=t.depth,n=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,n++,e=!1;if(i){let e=t.node(r).maybeChild(t.indexAfter(r));for(;e&&!e.isLeaf;)e=e.firstChild,n++}return n}function En(t){if(2!=t.length)return!1;let e=t.charCodeAt(0),i=t.charCodeAt(1);return e>=56320&&e<=57343&&i>=55296&&i<=56319}class Dn{constructor(t,e){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Or,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(Cn),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=Tn(this),Nn(this),this.nodeViews=An(this),this.docView=xi(this.state.doc,Rn(this),dn(this),this.dom,this),this.domObserver=new gn(this,((t,e,i,r)=>function(t,e,i,r,n){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,i=_i(t,e);if(i&&!t.state.selection.eq(i)){if(We&&He&&13===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,Ae(13,"Enter")))))return;let r=t.state.tr.setSelection(i);"pointer"==e?r.setMeta("pointer",!0):"key"==e&&r.scrollIntoView(),s&&r.setMeta("composition",s),t.dispatch(r)}return}let h=t.state.doc.resolve(e),l=h.sharedDepth(i);e=h.before(l+1),i=t.state.doc.resolve(i).after(l+1);let o,u,a=t.state.selection,c=function(t,e,i){let r,{node:n,fromOffset:s,toOffset:h,from:l,to:o}=t.docView.parseRange(e,i),u=t.domSelectionRange(),f=u.anchorNode;if(f&&t.dom.contains(1==f.nodeType?f:f.parentNode)&&(r=[{node:f,offset:u.anchorOffset}],Te(u)||r.push({node:u.focusNode,offset:u.focusOffset})),We&&8===t.input.lastKeyCode)for(let t=h;t>s;t--){let e=n.childNodes[t-1],i=e.pmViewDesc;if("BR"==e.nodeName&&!i){h=t;break}if(!i||i.size)break}let a=t.state.doc,c=t.someProp("domParser")||et.fromSchema(t.state.schema),d=a.resolve(l),p=null,m=c.parse(n,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:!0,from:s,to:h,preserveWhitespace:"pre"!=d.parent.type.whitespace||"full",findPositions:r,ruleFromNode:kn,context:d});if(r&&null!=r[0].pos){let t=r[0].pos,e=r[1]&&r[1].pos;null==e&&(e=t),p={anchor:t+l,head:e+l}}return{doc:m,sel:p,from:l,to:o}}(t,e,i),d=t.state.doc,p=d.slice(c.from,c.to);8===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime?(o=t.state.selection.to,u="end"):(o=t.state.selection.from,u="start"),t.input.lastKeyCode=null;let m=function(t,e,i,r,n){let s=t.findDiffStart(e,i);if(null==s)return null;let{a:h,b:l}=t.findDiffEnd(e,i+t.size,i+e.size);if("end"==n&&(r-=h+Math.max(0,s-Math.min(h,l))-s),h<s&&t.size<e.size){let t=r<=s&&r>=h?s-r:0;s-=t,s&&s<e.size&&En(e.textBetween(s-1,s+1))&&(s+=t?1:-1),l=s+(l-h),h=s}else if(l<s){let e=r<=s&&r>=l?s-r:0;s-=e,s&&s<t.size&&En(t.textBetween(s-1,s+1))&&(s+=e?1:-1),h=s+(h-l),l=s}return{start:s,endA:h,endB:l}}(p.content,c.doc.content,c.from,o,u);if(m&&t.input.domChangeCount++,(Ue&&t.input.lastIOSEnter>Date.now()-225||He)&&n.some((t=>1==t.nodeType&&!Sn.test(t.nodeName)))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",(e=>e(t,Ae(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(!m){if(!(r&&a instanceof ne&&!a.empty&&a.$head.sameParent(a.$anchor))||t.composing||c.sel&&c.sel.anchor!=c.sel.head){if(c.sel){let e=xn(t,t.state.doc,c.sel);if(e&&!e.eq(t.state.selection)){let i=t.state.tr.setSelection(e);s&&i.setMeta("composition",s),t.dispatch(i)}}return}m={start:a.from,endA:a.to,endB:a.to}}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof ne&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to)),Be&&Je<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>c.from&&" "==c.doc.textBetween(m.start-c.from-1,m.start-c.from+1)&&(m.start--,m.endA--,m.endB--);let w=c.doc.resolveNoCache(m.start-c.from),g=c.doc.resolveNoCache(m.endB-c.from),b=d.resolve(m.start),y=w.sameParent(g)&&w.parent.inlineContent&&b.end()>=m.endA;if((Ue&&t.input.lastIOSEnter>Date.now()-225&&(!y||n.some((t=>"DIV"==t.nodeName||"P"==t.nodeName)))||!y&&w.pos<c.doc.content.size&&(!w.sameParent(g)||!w.parent.inlineContent)&&w.pos<g.pos&&!/\S/.test(c.doc.textBetween(w.pos,g.pos,"","")))&&t.someProp("handleKeyDown",(e=>e(t,Ae(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>m.start&&function(t,e,i,r,n){if(i-e<=n.pos-r.pos||On(r,!0,!1)<n.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let t=s.nodeAfter;return null!=t&&i==e+t.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let h=t.resolve(On(s,!0,!0));return!(!h.parent.isTextblock||h.pos>i||On(h,!0,!1)<i)&&r.parent.content.cut(r.parentOffset).eq(h.parent.content)}(d,m.start,m.endA,w,g)&&t.someProp("handleKeyDown",(e=>e(t,Ae(8,"Backspace")))))return void(He&&We&&t.domObserver.suppressSelectionUpdates());We&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),He&&!y&&w.start()!=g.start()&&0==g.parentOffset&&w.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,g=c.doc.resolveNoCache(m.endB-c.from),setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,Ae(13,"Enter"))}))}),20));let M,v=m.start,k=m.endA,S=e=>{let i=e||t.state.tr.replace(v,k,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let e=xn(t,i.doc,c.sel);e&&!(We&&t.composing&&e.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==v||e.head==i.mapping.map(k)-1)||Be&&e.empty&&e.head==v)&&i.setSelection(e)}return s&&i.setMeta("composition",s),i.scrollIntoView()};if(y)if(w.pos==g.pos){Be&&Je<=11&&0==w.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((()=>Wi(t)),20));let e=S(t.state.tr.delete(v,k)),i=d.resolve(m.start).marksAcross(d.resolve(m.endA));i&&e.ensureMarks(i),t.dispatch(e)}else if(m.endA==m.endB&&(M=function(t,e){let i,r,n,s=t.firstChild.marks,h=e.firstChild.marks,l=s,o=h;for(let t=0;t<h.length;t++)l=h[t].removeFromSet(l);for(let t=0;t<s.length;t++)o=s[t].removeFromSet(o);if(1==l.length&&0==o.length)r=l[0],i="add",n=t=>t.mark(r.addToSet(t.marks));else{if(0!=l.length||1!=o.length)return null;r=o[0],i="remove",n=t=>t.mark(r.removeFromSet(t.marks))}let u=[];for(let t=0;t<e.childCount;t++)u.push(n(e.child(t)));if(f.from(u).eq(t))return{mark:r,type:i}}(w.parent.content.cut(w.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,m.endA-b.start())))){let e=S(t.state.tr);"add"==M.type?e.addMark(v,k,M.mark):e.removeMark(v,k,M.mark),t.dispatch(e)}else if(w.parent.child(w.index()).isText&&w.index()==g.index()-(g.textOffset?0:1)){let e=w.parent.textBetween(w.parentOffset,g.parentOffset),i=()=>S(t.state.tr.insertText(e,v,k));t.someProp("handleTextInput",(r=>r(t,v,k,e,i)))||t.dispatch(i())}else t.dispatch(S());else t.dispatch(S())}(this,t,e,i,r))),this.domObserver.start(),function(t){for(let e in kr){let i=kr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{!Nr(t,e)||Rr(t,e)||!t.editable&&e.type in Sr||i(t,e)},xr[e]?{passive:!0}:void 0)}qe&&t.dom.addEventListener("input",(()=>null)),Dr(t)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Dr(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(Cn),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let i in t)e[i]=t[i];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var i;let r=this.state,n=!1,s=!1;t.storedMarks&&this.composing&&(zr(this),s=!0),this.state=t;let h=r.plugins!=t.plugins||this._props.plugins!=e.plugins;if(h||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=An(this);(function(t,e){let i=0,r=0;for(let r in t){if(t[r]!=e[r])return!0;i++}for(let t in e)r++;return i!=r})(t,this.nodeViews)&&(this.nodeViews=t,n=!0)}(h||e.handleDOMEvents!=this._props.handleDOMEvents)&&Dr(this),this.editable=Tn(this),Nn(this);let l=dn(this),o=Rn(this),u=r.plugins==t.plugins||r.doc.eq(t.doc)?t.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",f=n||!this.docView.matchesNode(t.doc,o,l);!f&&t.selection.eq(r.selection)||(s=!0);let a="preserve"==u&&s&&null==this.dom.style.overflowAnchor&&function(t){let e,i,r=t.dom.getBoundingClientRect(),n=Math.max(0,r.top);for(let s=(r.left+r.right)/2,h=n+1;h<Math.min(innerHeight,r.bottom);h+=5){let r=t.root.elementFromPoint(s,h);if(!r||r==t.dom||!t.dom.contains(r))continue;let l=r.getBoundingClientRect();if(l.top>=n-20){e=r,i=l.top;break}}return{refDOM:e,refTop:i,stack:ei(t.dom)}}(this);if(s){this.domObserver.stop();let e=f&&(Be||We)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&function(t,e){let i=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(i)!=e.$anchor.start(i)}(r.selection,t.selection);if(f){let i=We?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let i=function(t,e){for(;;){if(3==t.nodeType&&e)return t;if(1==t.nodeType&&e>0){if("false"==t.contentEditable)return null;e=Re(t=t.childNodes[e-1])}else{if(!t.parentNode||Ne(t))return null;e=ve(t),t=t.parentNode}}}(e.focusNode,e.focusOffset),r=function(t,e){for(;;){if(3==t.nodeType&&e<t.nodeValue.length)return t;if(1==t.nodeType&&e<t.childNodes.length){if("false"==t.contentEditable)return null;t=t.childNodes[e],e=0}else{if(!t.parentNode||Ne(t))return null;e=ve(t)+1,t=t.parentNode}}}(e.focusNode,e.focusOffset);if(i&&r&&i!=r){let e=r.pmViewDesc,n=t.domObserver.lastChangedTextNode;if(i==n||r==n)return n;if(!e||!e.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let t=i.pmViewDesc;if(t&&t.isText(i.nodeValue))return r}}return i||r}(this)),!n&&this.docView.update(t.doc,o,l,this)||(this.docView.updateOuterDeco(o),this.docView.destroy(),this.docView=xi(t.doc,o,l,this.dom,this)),i&&!this.trackWrites&&(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),i=t.domSelectionRange();return Oe(e.node,e.offset,i.anchorNode,i.anchorOffset)}(this))?Wi(this,e):(Vi(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(i=this.dragging)||void 0===i?void 0:i.node)&&!r.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==u?this.dom.scrollTop=0:"to selection"==u?this.scrollToSelection():a&&function({refDOM:t,refTop:e,stack:i}){let r=t?t.getBoundingClientRect().top:0;ii(i,0==r?0:r-e)}(a)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(t&&this.dom.contains(1==t.nodeType?t:t.parentNode))if(this.someProp("handleScrollToSelection",(t=>t(this))));else if(this.state.selection instanceof he){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&ti(this,e.getBoundingClientRect(),t)}else ti(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;e<this.pluginViews.length;e++){let i=this.pluginViews[e];i.update&&i.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}}}updateDraggedNode(t,e){let i=t.node,r=-1;if(this.state.doc.nodeAt(i.from)==i.node)r=i.from;else{let t=i.from+(this.state.doc.content.size-e.doc.content.size);(t>0&&this.state.doc.nodeAt(t))==i.node&&(r=t)}this.dragging=new Kr(t.slice,t.move,r<0?void 0:he.create(this.state.doc,r))}someProp(t,e){let i,r=this._props&&this._props[t];if(null!=r&&(i=e?e(r):r))return i;for(let r=0;r<this.directPlugins.length;r++){let n=this.directPlugins[r].props[t];if(null!=n&&(i=e?e(n):n))return i}let n=this.state.plugins;if(n)for(let r=0;r<n.length;r++){let s=n[r].props[t];if(null!=s&&(i=e?e(s):s))return i}}hasFocus(){if(Be){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if("false"==t.contentEditable)return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(ri)return t.focus(ri);let e=ei(t);t.focus(null==ri?{get preventScroll(){return ri={preventScroll:!0},!0}}:void 0),ri||(ri=!1,ii(e,0))}(this.dom),Wi(this),this.domObserver.start()}get root(){let t=this._root;if(null==t)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return t||document}updateRoot(){this._root=null}posAtCoords(t){return li(this,t)}coordsAtPos(t,e=1){return ai(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,i=-1){let r=this.docView.posFromDOM(t,e,i);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(t,e){return function(t,e,i){return wi==e&&gi==i?bi:(wi=e,gi=i,bi="up"==i||"down"==i?function(t,e,i){let r=e.selection,n="up"==i?r.$from:r.$to;return pi(t,e,(()=>{let{node:e}=t.docView.domFromPos(n.pos,"up"==i?-1:1);for(;;){let i=t.docView.nearestDesc(e,!0);if(!i)break;if(i.node.isBlock){e=i.contentDOM||i.dom;break}e=i.dom.parentNode}let r=ai(t,n.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=xe(t,0,t.nodeValue.length).getClientRects()}for(let t=0;t<e.length;t++){let n=e[t];if(n.bottom>n.top+1&&("up"==i?r.top-n.top>2*(n.bottom-r.top):n.bottom-r.bottom>2*(r.bottom-n.top)))return!1}}return!0}))}(t,e,i):function(t,e,i){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let n=r.parentOffset,s=!n,h=n==r.parent.content.size,l=t.domSelection();return l?mi.test(r.parent.textContent)&&l.modify?pi(t,e,(()=>{let{focusNode:e,focusOffset:n,anchorNode:s,anchorOffset:h}=t.domSelectionRange(),o=l.caretBidiLevel;l.modify("move",i,"character");let u=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:f,focusOffset:a}=t.domSelectionRange(),c=f&&!u.contains(1==f.nodeType?f:f.parentNode)||e==f&&n==a;try{l.collapse(s,h),e&&(e!=s||n!=h)&&l.extend&&l.extend(e,n)}catch(t){}return null!=o&&(l.caretBidiLevel=o),c})):"left"==i||"backward"==i?s:h:r.pos==r.start()||r.pos==r.end()}(t,e,i))}(this,e||this.state,t)}pasteHTML(t,e){return qr(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return qr(this,t,null,!0,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return fr(this,t)}destroy(){this.docView&&(function(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],dn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Se=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function(t,e){Rr(t,e)||!kr[e.type]||!t.editable&&e.type in Sr||kr[e.type](t,e)}(this,t)}domSelectionRange(){let t=this.domSelection();return t?qe&&11===this.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Mn(t,i)}let i;function r(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),i?Mn(t,i):null}(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Rn(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",(i=>{if("function"==typeof i&&(i=i(t.state)),i)for(let t in i)"class"==t?e.class+=" "+i[t]:"style"==t?e.style=(e.style?e.style+";":"")+i[t]:e[t]||"contenteditable"==t||"nodeName"==t||(e[t]=String(i[t]))})),e.translate||(e.translate="no"),[Zr.node(0,t.state.doc.content.size,e)]}function Nn(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Zr.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Tn(t){return!t.someProp("editable",(e=>!1===e(t.state)))}function An(t){let e=Object.create(null);function i(t){for(let i in t)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=t[i])}return t.someProp("nodeViews",i),t.someProp("markViews",i),e}function Cn(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}Dn.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};const In=["p",0],Pn=["blockquote",0],Fn=["hr"],$n=["pre",["code",0]],jn=["br"],Bn=["em",0],Jn=["strong",0],_n=["code",0],zn=new Z({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:()=>In},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:()=>Pn},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>Fn},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM:t=>["h"+t.attrs.level,0]},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:()=>$n},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:t=>({src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")})}],toDOM(t){let{src:e,alt:i,title:r}=t.attrs;return["img",{src:e,alt:i,title:r}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>jn}},marks:{link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:t=>({href:t.getAttribute("href"),title:t.getAttribute("title")})}],toDOM(t){let{href:e,title:i}=t.attrs;return["a",{href:e,title:i},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>"em"==t.type.name}],toDOM:()=>Bn},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!=t.style.fontWeight&&null},{style:"font-weight=400",clearMark:t=>"strong"==t.type.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM:()=>Jn},code:{code:!0,parseDOM:[{tag:"code"}],toDOM:()=>_n}}}),Wn=["ol",0],Ln=["ul",0],qn=["li",0],Un={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs:t=>({order:t.hasAttribute("start")?+t.getAttribute("start"):1})}],toDOM:t=>1==t.attrs.order?Wn:["ol",{start:t.attrs.order},0]},Kn={parseDOM:[{tag:"ul"}],toDOM:()=>Ln},Vn={parseDOM:[{tag:"li"}],toDOM:()=>qn,defining:!0};function Hn(t,e){let i={};for(let e in t)i[e]=t[e];for(let t in e)i[t]=e[t];return i}function Yn(t,e,i){return t.append({ordered_list:Hn(Un,{content:"list_item+",group:i}),bullet_list:Hn(Kn,{content:"list_item+",group:i}),list_item:Hn(Vn,{content:e})})}for(var Gn={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:"'"},Xn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Qn="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Zn="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ts=0;ts<10;ts++)Gn[48+ts]=Gn[96+ts]=String(ts);for(ts=1;ts<=24;ts++)Gn[ts+111]="F"+ts;for(ts=65;ts<=90;ts++)Gn[ts]=String.fromCharCode(ts+32),Xn[ts]=String.fromCharCode(ts);for(var es in Gn)Xn.hasOwnProperty(es)||(Xn[es]=Gn[es]);const is="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),rs="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function ns(t){let e,i,r,n,s=t.split(/-(?!$)/),h=s[s.length-1];"Space"==h&&(h=" ");for(let t=0;t<s.length-1;t++){let h=s[t];if(/^(cmd|meta|m)$/i.test(h))n=!0;else if(/^a(lt)?$/i.test(h))e=!0;else if(/^(c|ctrl|control)$/i.test(h))i=!0;else if(/^s(hift)?$/i.test(h))r=!0;else{if(!/^mod$/i.test(h))throw new Error("Unrecognized modifier name: "+h);is?n=!0:i=!0}}return e&&(h="Alt-"+h),i&&(h="Ctrl-"+h),n&&(h="Meta-"+h),r&&(h="Shift-"+h),h}function ss(t,e,i=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),i&&e.shiftKey&&(t="Shift-"+t),t}function hs(t){return new ye({props:{handleKeyDown:ls(t)}})}function ls(t){let e=function(t){let e=Object.create(null);for(let i in t)e[ns(i)]=t[i];return e}(t);return function(t,i){let r,n=function(t){var e=!(Qn&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Zn&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?Xn:Gn)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(i),s=e[ss(n,i)];if(s&&s(t.state,t.dispatch,t))return!0;if(1==n.length&&" "!=n){if(i.shiftKey){let r=e[ss(n,i,!1)];if(r&&r(t.state,t.dispatch,t))return!0}if((i.altKey||i.metaKey||i.ctrlKey)&&!(rs&&i.ctrlKey&&i.altKey)&&(r=Gn[i.keyCode])&&r!=n){let n=e[ss(r,i)];if(n&&n(t.state,t.dispatch,t))return!0}}return!1}}const us=(t,e)=>!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function fs(t,e,i=!1){for(let r=t;r;r="start"==e?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(i&&1!=r.childCount)return!1}return!1}function as(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function cs(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let i=t.node(e);if(t.index(e)+1<i.childCount)return t.doc.resolve(t.after(e+1));if(i.type.spec.isolating)break}return null}function ds(t){for(let e=0;e<t.edgeCount;e++){let{type:i}=t.edge(e);if(i.isTextblock&&!i.hasRequiredAttrs())return i}return null}function ps(t,e,i,r){let n,s,h=e.nodeBefore,l=e.nodeAfter,o=h.type.spec.isolating||l.type.spec.isolating;if(!o&&function(t,e,i){let r=e.nodeBefore,n=e.nodeAfter,s=e.index();return!(!(r&&n&&r.type.compatibleContent(n.type))||(!r.content.size&&e.parent.canReplace(s-1,s)?(i&&i(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(s,s+1)||!n.isTextblock&&!Bt(t.doc,e.pos)||(i&&i(t.tr.join(e.pos).scrollIntoView()),0)))}(t,e,i))return!0;let u=!o&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(n=(s=h.contentMatchAt(h.childCount)).findWrapping(l.type))&&s.matchType(n[0]||l.type).validEnd){if(i){let r=e.pos+l.nodeSize,s=f.empty;for(let t=n.length-1;t>=0;t--)s=f.from(n[t].create(null,s));s=f.from(h.copy(s));let o=t.tr.step(new Tt(e.pos-1,r,e.pos,r,new w(s,1,0),n.length,!0)),u=o.doc.resolve(r+2*n.length);u.nodeAfter&&u.nodeAfter.type==h.type&&Bt(o.doc,u.pos)&&o.join(u.pos),i(o.scrollIntoView())}return!0}let a=l.type.spec.isolating||r>0&&o?null:te.findFrom(e,1),c=a&&a.$from.blockRange(a.$to),d=c&&Pt(c);if(null!=d&&d>=e.depth)return i&&i(t.tr.lift(c,d).scrollIntoView()),!0;if(u&&fs(l,"start",!0)&&fs(h,"end")){let r=h,n=[];for(;n.push(r),!r.isTextblock;)r=r.lastChild;let s=l,o=1;for(;!s.isTextblock;s=s.firstChild)o++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(i){let r=f.empty;for(let t=n.length-1;t>=0;t--)r=f.from(n[t].copy(r));i(t.tr.step(new Tt(e.pos-n.length,e.pos+l.nodeSize,e.pos+o,e.pos+l.nodeSize-o,new w(r,n.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function ms(t){return function(e,i){let r=e.selection,n=t<0?r.$from:r.$to,s=n.depth;for(;n.node(s).isInline;){if(!s)return!1;s--}return!!n.node(s).isTextblock&&(i&&i(e.tr.setSelection(ne.create(e.doc,t<0?n.start(s):n.end(s)))),!0)}}const ws=ms(-1),gs=ms(1);function bs(...t){return function(e,i,r){for(let n=0;n<t.length;n++)if(t[n](e,i,r))return!0;return!1}}let ys=bs(us,((t,e,i)=>{let r=function(t,e){let{$cursor:i}=t.selection;return!i||(e?!e.endOfTextblock("backward",t):i.parentOffset>0)?null:i}(t,i);if(!r)return!1;let n=as(r);if(!n){let i=r.blockRange(),n=i&&Pt(i);return null!=n&&(e&&e(t.tr.lift(i,n).scrollIntoView()),!0)}let s=n.nodeBefore;if(ps(t,n,e,-1))return!0;if(0==r.parent.content.size&&(fs(s,"end")||he.isSelectable(s)))for(let i=r.depth;;i--){let h=Jt(t.doc,r.before(i),r.after(i),w.empty);if(h&&h.slice.size<h.to-h.from){if(e){let i=t.tr.step(h);i.setSelection(fs(s,"end")?te.findFrom(i.doc.resolve(i.mapping.map(n.pos,-1)),-1):he.create(i.doc,n.pos-s.nodeSize)),e(i.scrollIntoView())}return!0}if(1==i||r.node(i-1).childCount>1)break}return!(!s.isAtom||n.depth!=r.depth-1||(e&&e(t.tr.delete(n.pos-s.nodeSize,n.pos).scrollIntoView()),0))}),((t,e,i)=>{let{$head:r,empty:n}=t.selection,s=r;if(!n)return!1;if(r.parent.isTextblock){if(i?!i.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=as(r)}let h=s&&s.nodeBefore;return!(!h||!he.isSelectable(h)||(e&&e(t.tr.setSelection(he.create(t.doc,s.pos-h.nodeSize)).scrollIntoView()),0))})),Ms=bs(us,((t,e,i)=>{let r=function(t,e){let{$cursor:i}=t.selection;return!i||(e?!e.endOfTextblock("forward",t):i.parentOffset<i.parent.content.size)?null:i}(t,i);if(!r)return!1;let n=cs(r);if(!n)return!1;let s=n.nodeAfter;if(ps(t,n,e,1))return!0;if(0==r.parent.content.size&&(fs(s,"start")||he.isSelectable(s))){let i=Jt(t.doc,r.before(),r.after(),w.empty);if(i&&i.slice.size<i.to-i.from){if(e){let r=t.tr.step(i);r.setSelection(fs(s,"start")?te.findFrom(r.doc.resolve(r.mapping.map(n.pos)),1):he.create(r.doc,r.mapping.map(n.pos))),e(r.scrollIntoView())}return!0}}return!(!s.isAtom||n.depth!=r.depth-1||(e&&e(t.tr.delete(n.pos,n.pos+s.nodeSize).scrollIntoView()),0))}),((t,e,i)=>{let{$head:r,empty:n}=t.selection,s=r;if(!n)return!1;if(r.parent.isTextblock){if(i?!i.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=cs(r)}let h=s&&s.nodeAfter;return!(!h||!he.isSelectable(h)||(e&&e(t.tr.setSelection(he.create(t.doc,s.pos)).scrollIntoView()),0))}));const vs={Enter:bs(((t,e)=>{let{$head:i,$anchor:r}=t.selection;return!(!i.parent.type.spec.code||!i.sameParent(r)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))}),((t,e)=>{let i=t.selection,{$from:r,$to:n}=i;if(i instanceof oe||r.parent.inlineContent||n.parent.inlineContent)return!1;let s=ds(n.parent.contentMatchAt(n.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let i=(!r.parentOffset&&n.index()<n.parent.childCount?r:n).pos,h=t.tr.insert(i,s.createAndFill());h.setSelection(ne.create(h.doc,i+1)),e(h.scrollIntoView())}return!0}),((t,e)=>{let{$cursor:i}=t.selection;if(!i||i.parent.content.size)return!1;if(i.depth>1&&i.after()!=i.end(-1)){let r=i.before();if(jt(t.doc,r))return e&&e(t.tr.split(r).scrollIntoView()),!0}let r=i.blockRange(),n=r&&Pt(r);return null!=n&&(e&&e(t.tr.lift(r,n).scrollIntoView()),!0)}),((t,e)=>{let{$from:i}=t.selection;if(t.selection instanceof he&&t.selection.node.isBlock)return!(!i.parentOffset||!jt(t.doc,i.pos)||(e&&e(t.tr.split(i.pos).scrollIntoView()),0));if(!i.depth)return!1;let r,n,s=[],h=!1,l=!1;for(let t=i.depth;;t--){if(i.node(t).isBlock){h=i.end(t)==i.pos+(i.depth-t),l=i.start(t)==i.pos-(i.depth-t),n=ds(i.node(t-1).contentMatchAt(i.indexAfter(t-1))),s.unshift(h&&n?{type:n}:null),r=t;break}if(1==t)return!1;s.unshift(null)}let o=t.tr;(t.selection instanceof ne||t.selection instanceof oe)&&o.deleteSelection();let u=o.mapping.map(i.pos),f=jt(o.doc,u,s.length,s);if(f||(s[0]=n?{type:n}:null,f=jt(o.doc,u,s.length,s)),!f)return!1;if(o.split(u,s.length,s),!h&&l&&i.node(r).type!=n){let t=o.mapping.map(i.before(r)),e=o.doc.resolve(t);n&&i.node(r-1).canReplaceWith(e.index(),e.index()+1,n)&&o.setNodeMarkup(o.mapping.map(i.before(r)),n)}return e&&e(o.scrollIntoView()),!0})),"Mod-Enter":(t,e)=>{let{$head:i,$anchor:r}=t.selection;if(!i.parent.type.spec.code||!i.sameParent(r))return!1;let n=i.node(-1),s=i.indexAfter(-1),h=ds(n.contentMatchAt(s));if(!h||!n.canReplaceWith(s,s,h))return!1;if(e){let r=i.after(),n=t.tr.replaceWith(r,r,h.createAndFill());n.setSelection(te.near(n.doc.resolve(r),1)),e(n.scrollIntoView())}return!0},Backspace:ys,"Mod-Backspace":ys,"Shift-Backspace":ys,Delete:Ms,"Mod-Delete":Ms,"Mod-a":(t,e)=>(e&&e(t.tr.setSelection(new oe(t.doc))),!0)},ks={"Ctrl-h":vs.Backspace,"Alt-Backspace":vs["Mod-Backspace"],"Ctrl-d":vs.Delete,"Ctrl-Alt-Backspace":vs["Mod-Delete"],"Alt-Delete":vs["Mod-Delete"],"Alt-d":vs["Mod-Delete"],"Ctrl-a":ws,"Ctrl-e":gs};for(let t in vs)ks[t]=vs[t];const Ss=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&"darwin"==os.platform())?ks:vs;class xs extends s{__class__="KritzelText";fontFamily="Arial";fontSize=8;fontColor="#000000";initialWidth=1;initialHeight=1;scale=1;scaleFactor=1;isDebugInfoVisible=!0;isEditable=!0;isEditing=!1;editor=null;content=null;_schema=new Z({nodes:Yn(zn.spec.nodes,"paragraph block*","block"),marks:zn.spec.marks});uneditedObject=null;rows=1;get isEmpty(){if(!this.editor)return!0;const t=this.editor.state.doc;return 0===t.content.size||0===t.textContent.trim().length}constructor(t){super(),t&&(this.translateX=t.translateX||0,this.translateY=t.translateY||0,this.fontSize=t.fontSize||8,this.fontFamily=t.fontFamily||"Arial",this.fontColor=t.fontColor||"#000000",this.width=this.initialWidth/(this._core.store.state.scale<0?this._core.store.state.scale:1),this.height=1.2*this.fontSize/(this._core.store.state.scale<0?this._core.store.state.scale:1),this.scale=t.scale||1,this.scaleFactor=t.scaleX??1)}static create(t,e,i){const r=new xs;return r._core=t,r.id=r.generateId(),r.workspaceId=t.store.state.activeWorkspace.id,r.fontSize=e,r.fontFamily=i,r.translateX=0,r.translateY=0,r.width=r.initialWidth/(r._core.store.state.scale<0?r._core.store.state.scale:1),r.height=1.2*r.fontSize/(r._core.store.state.scale<0?r._core.store.state.scale:1),r.backgroundColor="transparent",r.initialWidth=r.width,r.initialHeight=r.height,r.scaleFactor=1,r.scale=r._core.store.state.scale,r.zIndex=t.store.currentZIndex,r.editor=r.createEditor(),r}mount(t){null!==t&&!1!==this.isInViewport()&&(this.isMounted&&this.elementRef===t&&this.editor.dom.parentElement===t||(this.elementRef=t,this.elementRef.style.fontFamily=this.fontFamily,this.elementRef.style.fontSize=`${this.fontSize}pt`,this.elementRef.style.color=this.fontColor,this.elementRef.style.whiteSpace="pre-wrap",this.elementRef.style.wordWrap="break-word",this.elementRef.innerHTML="",this.elementRef.appendChild(this.editor.dom),this.isMounted=!0,requestAnimationFrame((()=>this.adjustSizeOnInput()))))}createEditor(){const t=this._schema.node("doc",null,[this._schema.node("paragraph")]);return new Dn(null,{state:ge.create({doc:t,plugins:[hs(Ss)]}),editable:()=>!1,dispatchTransaction:t=>{const e=this.editor.state.apply(t);this.editor.updateState(e),t.docChanged&&(this.content=e.doc.toJSON(),this.adjustSizeOnInput(),t.getMeta("fromRemote")||this._core.store.state.objects.update(this,{temporary:!0}))}})}setContent(t){if(this.content=t,this.editor&&t){const e=this.editor.state.schema.nodeFromJSON(t),i=this.editor.state.tr.replaceWith(0,this.editor.state.doc.content.size,e.content);i.setMeta("fromRemote",!0),this.editor.dispatch(i)}}adjustSizeOnInput(){const t=this.elementRef;if(t&&this.isMounted&&t.scrollWidth>0){const e=this.totalWidth,i=this.totalHeight,r=t.scrollHeight;if(this.width=t.scrollWidth*this.scaleFactor,this.height=r*this.scaleFactor,0!==this.rotation){const t=(this.totalWidth-e)/2/this.scale,r=(this.totalHeight-i)/2/this.scale;if(0!==t||0!==r){const e=Math.cos(this.rotation),i=Math.sin(this.rotation),n=i*t+e*r;this.translateX+=e*t-i*r-t,this.translateY+=n-r}}}}resize(t,e,i,r){if(i<=1||r<=1)return;const n=this.width/this.scaleFactor,s=this.height/this.scaleFactor;this.scaleFactor=Math.min(i/n,r/s),this.width=n*this.scaleFactor,this.height=s*this.scaleFactor,this.translateX=t,this.translateY=e,this._core.store.state.objects.update(this)}focus(t){if(this.editor){const i=this.editor.state.doc;if(t.x&&t.y){const r=this.editor.posAtCoords({left:t.x,top:t.y});if(r)return this.editor.dispatch(this.editor.state.tr.setSelection(ne.create(i,r.pos))),this.editor.focus(),void(e.isIOS()&&this.scrollIntoViewOnIOS())}const r=Math.max(1,i.content.size-1);this.editor.dispatch(this.editor.state.tr.setSelection(ne.create(i,r))),this.editor.focus(),e.isIOS()&&this.scrollIntoViewOnIOS()}}scrollIntoViewOnIOS(){setTimeout((()=>{this.editor&&this.editor.dom&&this.editor.dom.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}),300)}edit(t){h.disableInteractiveWidget(),this.uneditedObject=this.clone(),this._core.store.setState("activeTool",r.getTool("text")),this.editor.setProps({editable:()=>!0}),this.isEditing=!0,this._core.rerender(),this.adjustSizeOnInput(),this.focus({x:t?.clientX,y:t?.clientY}),h.enableInteractiveWidget()}save(){requestAnimationFrame((()=>this.adjustSizeOnInput())),this.content=this.editor.state.doc.toJSON(),this.editor.setProps({editable:()=>!1}),this.editor.dom.blur(),this.isEditing=!1,this._core.store.state.objects.consolidateTemporaryItems(),this._core.store.state.objects.update(this),this._core.engine.emitObjectsChange()}handlePointerDown(t){this.isEditing&&t.stopPropagation()}handlePointerMove(t){this.isEditing&&t.stopPropagation()}handlePointerUp(t){this.isEditing&&t.stopPropagation()}copy(){const t=super.copy();return t.editor=t.createEditor(),this.content&&t.setContent(this.content),t}serialize(){const{_core:t,_elementRef:e,_schema:i,element:r,totalWidth:n,totalHeight:s,editor:h,uneditedObject:l,...o}=this,u=structuredClone(o);return r&&"object"==typeof r&&"nodeType"in r&&1===r.nodeType&&(u.element=r.cloneNode(!0)),u}deserialize(t){return super.deserialize(t),t.content&&this.setContent(t.content),this}}var Os,Es={},Ds=(Os||(Os=1,function(){var t=Object.defineProperty;function e(t,e,i,r=t=>t){return t*r(.5-e*(.5-i))}function i(t,e){return[t[0]+e[0],t[1]+e[1]]}function r(t,e){return[t[0]-e[0],t[1]-e[1]]}function n(t,e){return[t[0]*e,t[1]*e]}function s(t){return[t[1],-t[0]]}function h(t,e){return t[0]*e[0]+t[1]*e[1]}function l(t,e){return t[0]===e[0]&&t[1]===e[1]}function o(t,e){return function(t){return t[0]*t[0]+t[1]*t[1]}(r(t,e))}function u(t){return function(t,e){return[t[0]/e,t[1]/e]}(t,function(t){return Math.hypot(t[0],t[1])}(t))}function f(t,e){return Math.hypot(t[1]-e[1],t[0]-e[0])}function a(t,e,i){let r=Math.sin(i),n=Math.cos(i),s=t[0]-e[0],h=t[1]-e[1];return[s*n-h*r+e[0],s*r+h*n+e[1]]}function c(t,e,s){return i(t,n(r(e,t),s))}function d(t,e,r){return i(t,n(e,r))}((e,i)=>{for(var r in(e=>{t(e,"__esModule",{value:!0})})(e),i)t(e,r,{get:i[r],enumerable:!0})})(Es,{default:()=>v,getStroke:()=>M,getStrokeOutlinePoints:()=>b,getStrokePoints:()=>y});var{min:p,PI:m}=Math,w=.275,g=m+1e-4;function b(t,l={}){let{size:f=16,smoothing:m=.5,thinning:b=.5,simulatePressure:y=!0,easing:M=t=>t,start:v={},end:k={},last:S=!1}=l,{cap:x=!0,easing:O=t=>t*(2-t)}=v,{cap:E=!0,easing:D=t=>--t*t*t+1}=k;if(0===t.length||f<=0)return[];let R,N=t[t.length-1].runningLength,T=!1===v.taper?0:!0===v.taper?Math.max(f,N):v.taper,A=!1===k.taper?0:!0===k.taper?Math.max(f,N):k.taper,C=Math.pow(f*m,2),I=[],P=[],F=t.slice(0,10).reduce(((t,e)=>{let i=e.pressure;if(y){let r=p(1,e.distance/f),n=p(1,1-r);i=p(1,t+r*w*(n-t))}return(t+i)/2}),t[0].pressure),$=e(f,b,t[t.length-1].pressure,M),j=t[0].vector,B=t[0].point,J=B,_=B,z=J,W=!1;for(let l=0;l<t.length;l++){let{pressure:u}=t[l],{point:d,vector:m,distance:v,runningLength:k}=t[l];if(l<t.length-1&&N-k<3)continue;if(b){if(y){let t=p(1,v/f),e=p(1,1-t);u=p(1,F+t*w*(e-F))}$=e(f,b,u,M)}else $=f/2;void 0===R&&(R=$);let S=k<T?O(k/T):1,x=N-k<A?D((N-k)/A):1;$=Math.max(.01,$*Math.min(S,x));let E=(l<t.length-1?t[l+1]:t[l]).vector,L=l<t.length-1?h(m,E):1,q=null!==L&&L<0;if(h(m,j)<0&&!W||q){let t=n(s(j),$);for(let e=1/13,n=0;n<=1;n+=e)_=a(r(d,t),d,g*n),I.push(_),z=a(i(d,t),d,g*-n),P.push(z);B=_,J=z,q&&(W=!0);continue}if(W=!1,l===t.length-1){let t=n(s(m),$);I.push(r(d,t)),P.push(i(d,t));continue}let U=n(s(c(E,m,L)),$);_=r(d,U),(l<=1||o(B,_)>C)&&(I.push(_),B=_),z=i(d,U),(l<=1||o(J,z)>C)&&(P.push(z),J=z),F=u,j=m}let L=t[0].point.slice(0,2),q=t.length>1?t[t.length-1].point.slice(0,2):i(t[0].point,[1,1]),U=[],K=[];if(1===t.length){if(!T&&!A||S){let t=d(L,u(s(r(L,q))),-(R||$)),e=[];for(let i=1/13,r=i;r<=1;r+=i)e.push(a(t,L,2*g*r));return e}}else{if(!(T||A&&1===t.length))if(x)for(let t=1/13,e=t;e<=1;e+=t){let t=a(P[0],L,g*e);U.push(t)}else{let t=r(I[0],P[0]),e=n(t,.5),s=n(t,.51);U.push(r(L,e),r(L,s),i(L,s),i(L,e))}let e=s(function(t){return[-t[0],-t[1]]}(t[t.length-1].vector));if(A||T&&1===t.length)K.push(q);else if(E){let t=d(q,e,$);for(let e=1/29,i=e;i<1;i+=e)K.push(a(t,q,3*g*i))}else K.push(i(q,n(e,$)),i(q,n(e,.99*$)),r(q,n(e,.99*$)),r(q,n(e,$)))}return I.concat(K,P.reverse(),U)}function y(t,e={}){var n;let{streamline:s=.5,size:h=16,last:o=!1}=e;if(0===t.length)return[];let a=.15+.85*(1-s),d=Array.isArray(t[0])?t:t.map((({x:t,y:e,pressure:i=.5})=>[t,e,i]));if(2===d.length){let t=d[1];d=d.slice(0,-1);for(let e=1;e<5;e++)d.push(c(d[0],t,e/4))}1===d.length&&(d=[...d,[...i(d[0],[1,1]),...d[0].slice(2)]]);let p=[{point:[d[0][0],d[0][1]],pressure:d[0][2]>=0?d[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],m=!1,w=0,g=p[0],b=d.length-1;for(let t=1;t<d.length;t++){let e=o&&t===b?d[t].slice(0,2):c(g.point,d[t],a);if(l(g.point,e))continue;let i=f(e,g.point);if(w+=i,t<b&&!m){if(w<h)continue;m=!0}g={point:e,pressure:d[t][2]>=0?d[t][2]:.5,vector:u(r(g.point,e)),distance:i,runningLength:w},p.push(g)}return p[0].vector=(null==(n=p[1])?void 0:n.vector)||[0,0],p}function M(t,e={}){return b(y(t,e),e)}var v=M}()),Es);class Rs{static average(t,e){return(t+e)/2}}class Ns extends s{__class__="KritzelPath";points;d;stroke="none";strokeWidth;lineSlack=.5;fill;x=0;y=0;height=0;width=0;scale=1;options;isVisible=!0;isDebugInfoVisible=!0;isCompleted=!1;_adjustedPoints=null;get viewBox(){return`${this.x} ${this.y} ${this.width} ${this.height}`}constructor(t){super(),this.options=t,this.points=t?.points??[],this.translateX=t?.translateX??0,this.translateY=t?.translateY??0,this.scale=t?.scale??1,this.strokeWidth=t?.strokeWidth??8,this.fill=t?.fill??"#000000",this.d=this.generateSvgPath(),this.updateDimensions()}static create(t,e){const i=new Ns;return i._core=t,i.id=i.generateId(),i.workspaceId=t.store.state.activeWorkspace.id,i.options=e,i.points=e?.points??[],i.translateX=e?.translateX??0,i.translateY=e?.translateY??0,i.scale=e?.scale??1,i.strokeWidth=e?.strokeWidth??8,i.fill=e?.fill??"#000000",i.zIndex=t.store.currentZIndex,i.d=i.generateSvgPath(),i.updateDimensions(),i}resize(t,e,i,r){if(i<=1||r<=1)return;const n=i/this.width,s=r/this.height;this.width=i,this.height=r,this.points=this.points.map((([t,e])=>[t*n,e*s])),this.d=this.generateSvgPath(),this.width=Math.max(...this.points.map((t=>t[0])))-Math.min(...this.points.map((t=>t[0])))+this.strokeWidth,this.height=Math.max(...this.points.map((t=>t[1])))-Math.min(...this.points.map((t=>t[1])))+this.strokeWidth,this.x=Math.min(...this.points.map((t=>t[0])))-this.strokeWidth/2,this.y=Math.min(...this.points.map((t=>t[1])))-this.strokeWidth/2,this.translateX=t,this.translateY=e,this._adjustedPoints=null,this._core.store.state.objects.update(this)}rotate(t){this.rotation=t,this._adjustedPoints=null,this._core.store.state.objects.update(this)}move(t,e,i,r){const n=(e-r)/this._core.store.state.scale;this.translateX+=(t-i)/this._core.store.state.scale,this.translateY+=n,this._adjustedPoints=null,this._core.store.state.objects.update(this)}hitTest(t,e){const i=this.strokeWidth/this.scale/2;if(null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints()),1===this._adjustedPoints.length){const r=this._adjustedPoints[0];return this.pointToLineSegmentDistance(t,e,r[0],r[1],r[0],r[1])<=i}for(let r=0;r<this._adjustedPoints.length-1;r++){const n=this._adjustedPoints[r],s=this._adjustedPoints[r+1];if(this.pointToLineSegmentDistance(t,e,n[0],n[1],s[0],s[1])<=i)return!0}return!1}hitTestPolygon(t){const e=this.strokeWidth/this.scale/2;null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints());const i=[{x:t.bottomLeft.x,y:t.bottomLeft.y},{x:t.bottomRight.x,y:t.bottomRight.y},{x:t.topRight.x,y:t.topRight.y},{x:t.topLeft.x,y:t.topLeft.y}];for(const[t,e]of this._adjustedPoints)if(n.isPointInPolygon({x:t,y:e},i))return!0;for(const t of i)if(this.hitTest(t.x,t.y))return!0;for(let t=0;t<this._adjustedPoints.length-1;t++){const e={x:this._adjustedPoints[t][0],y:this._adjustedPoints[t][1]},r={x:this._adjustedPoints[t+1][0],y:this._adjustedPoints[t+1][1]};for(let t=0;t<i.length;t++)if(n.intersectLines(e,r,i[t],i[(t+1)%i.length]))return!0}for(let t=0;t<this._adjustedPoints.length-1;t++){const r=this._adjustedPoints[t],n=this._adjustedPoints[t+1];for(let t=0;t<i.length;t++){const s=i[t],h=i[(t+1)%i.length],l=this.pointToLineSegmentDistance(s.x,s.y,r[0],r[1],n[0],n[1]),o=this.pointToLineSegmentDistance(h.x,h.y,r[0],r[1],n[0],n[1]),u=this.pointToLineSegmentDistance(r[0],r[1],s.x,s.y,h.x,h.y),f=this.pointToLineSegmentDistance(n[0],n[1],s.x,s.y,h.x,h.y);if(Math.min(l,o,u,f)<=e)return!0}}return!1}updatePosition(t,e){this.translateX=t,this.translateY=e,this._adjustedPoints=null,this._core.store.state.objects.update(this)}computeAdjustedPoints(){if(!this.points?.length)return[];const t=this.rotation,e=Math.cos(t),i=Math.sin(t),r=this.points.map((t=>t[0])),n=this.points.map((t=>t[1])),s={x:(Math.min(...r)+Math.max(...r))/2,y:(Math.min(...n)+Math.max(...n))/2},{x:h,y:l}=s;return this.points.map((([t,r])=>{const n=t-h,s=r-l;return[h+n*e-s*i,l+n*i+s*e]})).map((([t,e])=>[Math.abs(t-this.x)/this.scale+this.translateX,Math.abs(e-this.y)/this.scale+this.translateY]))}pointToLineSegmentDistance(t,e,i,r,n,s){const h=n-i,l=s-r,o=h*h+l*l;let u,f,a=-1;0!==o&&(a=((t-i)*h+(e-r)*l)/o),a<0?(u=i,f=r):a>1?(u=n,f=s):(u=i+a*h,f=r+a*l);const c=t-u,d=e-f;return Math.sqrt(c*c+d*d)}updateDimensions(){const t=this.points.map((([t,e])=>[t*Math.cos(this.rotation)-e*Math.sin(this.rotation),t*Math.sin(this.rotation)+e*Math.cos(this.rotation)])),e=Math.min(...t.map((t=>t[0]-this.strokeWidth/2))),i=Math.min(...t.map((t=>t[1]-this.strokeWidth/2))),r=Math.max(...t.map((t=>t[0]+this.strokeWidth/2))),n=Math.max(...t.map((t=>t[1]+this.strokeWidth/2)));this.width=r-e+this.lineSlack,this.height=n-i+this.lineSlack,this.x=e,this.y=i,this.translateX=(this.x+this.translateX)/this.scale,this.translateY=(this.y+this.translateY)/this.scale}generateSvgPath(){const t=this.getStrokeFromPoints(this.points,this.strokeWidth);return this.getSvgPathFromStroke(t)}getStrokeFromPoints(t,e){return Ds.getStroke(t,{size:e,thinning:.5,smoothing:.5,streamline:.5,easing:t=>t,simulatePressure:!0,last:!0,start:{cap:!0,taper:0,easing:t=>t},end:{cap:!0,taper:0,easing:t=>t}})}getSvgPathFromStroke(t,e=!0){const i=t.length;if(i<4)return"";let r=t[0],n=t[1];const s=t[2];let h=`M${r[0].toFixed(2)},${r[1].toFixed(2)} Q${n[0].toFixed(2)},${n[1].toFixed(2)} ${Rs.average(n[0],s[0]).toFixed(2)},${Rs.average(n[1],s[1]).toFixed(2)} T`;for(let e=2,s=i-1;e<s;e++)r=t[e],n=t[e+1],h+=`${Rs.average(r[0],n[0]).toFixed(2)},${Rs.average(r[1],n[1]).toFixed(2)} `;return e&&(h+="Z"),h}isLowRes(){if(!this._core)return!1;const t=this._core.store.state.scale;return this.boundingBox.width*t*(this.boundingBox.height*t)<500}getClipPoint(t){const e=this.centerX,i=this.centerY,r=this.strokeWidth/this.scale/2;if(null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints()),this._adjustedPoints.length<1)return null;let n=!0;for(let s=1;s<=32;s++){const h=s/32,l=t.x+(e-t.x)*h,o=t.y+(i-t.y)*h;let u=1/0;if(1===this._adjustedPoints.length){const t=this._adjustedPoints[0],e=l-t[0],i=o-t[1];u=Math.sqrt(e*e+i*i)}else for(let t=0;t<this._adjustedPoints.length-1;t++){const e=this._adjustedPoints[t],i=this._adjustedPoints[t+1],r=this.pointToLineSegmentDistance(l,o,e[0],e[1],i[0],i[1]);r<u&&(u=r)}const f=u<=r;if(n&&f){let n=(s-1)/32,l=h;for(let s=0;s<8;s++){const s=(n+l)/2,h=t.x+(e-t.x)*s,o=t.y+(i-t.y)*s;let u=1/0;if(1===this._adjustedPoints.length){const t=this._adjustedPoints[0],e=h-t[0],i=o-t[1];u=Math.sqrt(e*e+i*i)}else for(let t=0;t<this._adjustedPoints.length-1;t++){const e=this._adjustedPoints[t],i=this._adjustedPoints[t+1],r=this.pointToLineSegmentDistance(h,o,e[0],e[1],i[0],i[1]);r<u&&(u=r)}u<=r?l=s:n=s}const o=(n+l)/2;return{x:t.x+(e-t.x)*o,y:t.y+(i-t.y)*o}}n=!f}return null}}class Ts{static isRightClick(t){return t.button===i.Right}static isLeftClick(t){return t.button===i.Left}static isPointerEventOnContextMenu(t){return!!t.composedPath().find((t=>t.classList&&t.classList.contains("context-menu")))}static onLongPress(t,e,i){if("touch"!==t.pointerType)return i?.(),()=>{};const r=t.clientX,n=t.clientY,s=t.target;if(!s)return i?.(),()=>{};const h=setTimeout((()=>{a(),e(t)}),400),l=()=>{clearTimeout(h),a(),i?.()},o=t=>{(Math.abs(t.clientX-r)>10||Math.abs(t.clientY-n)>10)&&l()},u=()=>{l()},f=()=>{l()},a=()=>{s.removeEventListener("pointermove",o),s.removeEventListener("pointerup",u),s.removeEventListener("pointercancel",f)};return s.addEventListener("pointermove",o,{passive:!0}),s.addEventListener("pointerup",u,{once:!0}),s.addEventListener("pointercancel",f,{once:!0}),l}}class As{__class__=this.constructor.name;name="base-tool";_core;constructor(t){this._core=t}onActivate(){}onDeactivate(){}handlePointerDown(t){}handlePointerMove(t){}handlePointerUp(t){}handleWheel(t){}serialize(){return{__class__:this.__class__,name:this.name}}deserialize(t){return Object.assign(this,t),this}}class Cs extends As{type="pen";color="#000000";size=6;palettes={pen:["#000000","#FFFFFF","#FF0000","#00FF00","#0000FF","#FFFF00","#FF00FF","#00FFFF","#808080","#C0C0C0","#800000","#008000","#000080","#800080"],highlighter:["#ffff00","#ffb347","#b4ffb4"]};_currentPathId=null;constructor(t){super(t)}handlePointerDown(t){if(t.cancelable&&t.preventDefault(),"mouse"===t.pointerType&&Ts.isLeftClick(t)){this._core.store.state.isDrawing=!0;const e=Ns.create(this._core,{points:[[t.clientX-this._core.store.offsetX,t.clientY-this._core.store.offsetY]],translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,fill:this.color,strokeWidth:this.size});e.isCompleted=!1,this._currentPathId=e.id,this._core.store.state.objects.insert(e)}if("touch"===t.pointerType){const t=Array.from(this._core.store.state.pointers.values());if(1===t.length){const e=Math.round(t[0].clientX-this._core.store.offsetX),i=Math.round(t[0].clientY-this._core.store.offsetY);this._core.store.state.isDrawing=!0;const r=Ns.create(this._core,{points:[[e,i]],translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,fill:this.color,strokeWidth:this.size});r.isCompleted=!1,this._currentPathId=r.id,this._core.store.state.objects.insert(r)}}}handlePointerMove(t){if(t.cancelable&&t.preventDefault(),"mouse"===t.pointerType&&this._core.store.state.isDrawing&&this._currentPathId){const e=this._core.store.state.objects.filter((t=>t.id===this._currentPathId)),i=e.length>0?e[0]:null;if(i){const e=Ns.create(this._core,{points:[...i.points,[t.clientX-this._core.store.offsetX,t.clientY-this._core.store.offsetY]],translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,fill:this.color,strokeWidth:this.size});e.id=i.id,e.workspaceId=i.workspaceId,e.zIndex=i.zIndex,e.isCompleted=!1,this._core.store.state.objects.update(e)}}if("touch"===t.pointerType){const t=Array.from(this._core.store.state.pointers.values());if(1===t.length&&this._currentPathId){const e=this._core.store.state.objects.filter((t=>t.id===this._currentPathId)),i=e.length>0?e[0]:null;if(i){const e=Math.round(t[0].clientX-this._core.store.offsetX),r=Math.round(t[0].clientY-this._core.store.offsetY),n=Ns.create(this._core,{points:[...i.points,[e,r]],translateX:-this._core.store.state.translateX,translateY:-this._core.store.state.translateY,scale:this._core.store.state.scale,fill:this.color,strokeWidth:this.size});n.id=i.id,n.workspaceId=i.workspaceId,n.zIndex=i.zIndex,n.isCompleted=!1,this._core.store.state.objects.update(n)}}}}handlePointerUp(t){if(t.cancelable&&t.preventDefault(),"mouse"===t.pointerType&&this._core.store.state.isDrawing&&(this._core.store.state.isDrawing=!1,this._currentPathId)){const t=this._core.store.state.objects.filter((t=>t.id===this._currentPathId)),e=t.length>0?t[0]:null;e&&(e.isCompleted=!0,this._core.store.state.objects.update(e),this._core.engine.emitObjectsChange()),this._currentPathId=null}if("touch"===t.pointerType&&this._core.store.state.isDrawing&&(this._core.store.state.isDrawing=!1,this._currentPathId)){const t=this._core.store.state.objects.filter((t=>t.id===this._currentPathId)),e=t.length>0?t[0]:null;e&&(e.isCompleted=!0,this._core.store.state.objects.update(e),this._core.engine.emitObjectsChange()),this._currentPathId=null}}}class Is extends As{fontFamily="Arial";fontSize=16;fontColor="#000000";palette=["#000000","#FFFFFF","#FF0000","#00FF00","#0000FF","#FFFF00","#FF00FF","#00FFFF","#808080","#C0C0C0","#800000","#008000","#000080","#808000","#800080"];constructor(t){super(t)}handlePointerDown(t){if(t.cancelable&&t.preventDefault(),"mouse"===t.pointerType){const e=t.composedPath().slice(1).find((t=>t.classList&&t.classList.contains("object"))),i=this._core.findObjectById(e?.id),n=this._core.store.activeText;if(null===n&&i instanceof xs)return void i.edit(t);if(null!==n&&i instanceof xs)return n.save(),void i.edit(t);if(null!==n&&i instanceof xs==0)return this._core.resetActiveText(),void this._core.store.setState("activeTool",r.getTool("selection"));if(!1===Ts.isLeftClick(t))return;const s=t.clientX-this._core.store.offsetX,h=t.clientY-this._core.store.offsetY,l=xs.create(this._core,this.fontSize,this.fontFamily);l.fontColor=this.fontColor,l.translateX=(s-this._core.store.state.translateX)/this._core.store.state.scale,l.translateY=(h-this._core.store.state.translateY)/this._core.store.state.scale,l.zIndex=this._core.store.currentZIndex,this._core.store.state.objects.insert(l),this._core.rerender(),l.edit(t)}if("touch"===t.pointerType){const e=Array.from(this._core.store.state.pointers.values()),i=t.composedPath().slice(1).find((t=>t.classList&&t.classList.contains("object"))),n=this._core.findObjectById(i?.id),s=this._core.store.activeText;if(null===s&&n instanceof xs)return void n.edit(t);if(null!==s&&n instanceof xs)return s.save(),void n.edit(t);if(null!==s&&n instanceof xs==0)return this._core.resetActiveText(),void this._core.store.setState("activeTool",r.getTool("selection"));if(e.length>1)return;const h=Math.round(e[0].clientX-this._core.store.offsetX),l=Math.round(e[0].clientY-this._core.store.offsetY),o=xs.create(this._core,this.fontSize,this.fontFamily);o.fontColor=this.fontColor,o.translateX=(h-this._core.store.state.translateX)/this._core.store.state.scale,o.translateY=(l-this._core.store.state.translateY)/this._core.store.state.scale,o.zIndex=this._core.store.currentZIndex,this._core.store.state.objects.insert(o),this._core.rerender(),o.edit(t)}}handlePointerUp(t){t.cancelable&&t.preventDefault(),this._core.store.activeText?.edit(t)}}export{Dn as E,xs as K,Z as S,ne as T,Ns as a,Cs as b,Is as c,h as d,s as e,n as f,As as g,Ts as h,r as i,Yn as j,ge as k,hs as l,Ss as m,zn as s}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as t,H as s,c as e,h as i,d as h,t as o}from"./p-Bj_Og27M.js";import{O as n}from"./p-B0kd2rUI.js";import{K as r}from"./p-C6qB08BS.js";const a=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.close=e(this,"close")}get host(){return this}anchor;anchorChanged(t){t?(this.openPortal(),this.calculatePosition(),this.autoFocus&&this.focusFirstElement()):this.closePortal()}offsetX;offsetY;autoFocus=!0;close;handleOutsideClick(t){t.stopPropagation(),this.lastAddedPortal===this.portal&&(this.host.contains(t.target)||(this.close.emit(),this.closePortal()))}handleKeyDown(t){if(t.stopPropagation(),this.lastAddedPortal===this.portal&&("Escape"===t.key&&(this.anchor.focus(),this.close.emit(),this.closePortal()),"Tab"===t.key&&this.trapFocus(t),"Enter"===t.key)){const s=this.getDeepActiveElement();s?.click&&(t.preventDefault(),s.click())}}handleResize(){this.calculatePosition()}handleWindowScroll(){if(!r.isElementInViewport(this.anchor))return this.anchor?.blur(),void this.closePortal();this.calculatePosition()}portal;id=`portal-${n.generateUUID()}`;defaultOffset=0;minLeft=0;focusFirstElement(){requestAnimationFrame((()=>{this.firstFocusableElement?.focus?.()}))}getDeepActiveElement(){let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}trapFocus(t){const s=r.getFocusableElements(this.host);if(0===s.length)return;const e=s[0],i=s[s.length-1],h=this.getDeepActiveElement();t.shiftKey?h===e&&(i.focus(),t.preventDefault()):h===i&&(e.focus(),t.preventDefault())}get firstFocusableElement(){const t=this.host.shadowRoot?.querySelector("slot"),s=t?.assignedElements({flatten:!0})[0];return s?r.getFocusableElements(s)[0]??s:null}get lastAddedPortal(){const t=Array.from(document.querySelectorAll('[id^="portal-"]'));return t.length?t[t.length-1]:null}calculateLeft(){if(!this.anchor||!this.portal)return 0;const t=this.anchor.getBoundingClientRect(),s=this.portal.getBoundingClientRect();let e=t.left+(this.offsetX??this.defaultOffset);const i=window.innerWidth-s.width-this.minLeft;return e<this.minLeft&&(e=this.minLeft),e>i&&(e=i),Math.round(e+window.scrollX)}calculateTop(){if(!this.anchor||!this.portal)return 0;const t=this.anchor.getBoundingClientRect(),s=this.portal.getBoundingClientRect(),e=this.offsetY??this.defaultOffset;let i=t.bottom+e;const h=window.innerHeight-t.bottom-e-8,o=t.top-e-8;return this.host.style.removeProperty("--kritzel-portal-max-height"),s.height<=h?i=t.bottom+e:s.height<=o?i=t.top-s.height-e:h>=o?(i=t.bottom+e,this.host.style.setProperty("--kritzel-portal-max-height",`${h}px`)):(i=8,this.host.style.setProperty("--kritzel-portal-max-height",`${o}px`)),Math.round(i+window.scrollY)}openPortal(){this.portal=document.createElement("div"),this.portal.setAttribute("id",this.id),this.portal.style.zIndex="1",this.portal.style.position="absolute",this.portal.style.top="0px",this.portal.style.left="0px",this.portal.appendChild(this.host),document.body.append(this.portal)}closePortal(){const t=document.getElementById(this.id);t&&(document.body.removeChild(t),this.host.remove())}calculatePosition(){if(!this.anchor||!this.portal)return;const t=this.calculateTop(),s=this.calculateLeft();this.portal.style.top=`${t}px`,this.portal.style.left=`${s}px`}render(){return i(h,{key:"9706a815c6f49853983a0fdb68b097d62e65e90b",style:{display:this.anchor?"block":"none"}},i("slot",{key:"1bd76deeb440cd25e3895dc8824f5200461e4ae0"}))}static get watchers(){return{anchor:[{anchorChanged:0}]}}},[769,"kritzel-portal",{anchor:[16],offsetX:[2,"offset-x"],offsetY:[2,"offset-y"],autoFocus:[4,"auto-focus"]},[[8,"click","handleOutsideClick"],[8,"keydown","handleKeyDown"],[11,"resize","handleResize"],[11,"scroll","handleWindowScroll"]],{anchor:[{anchorChanged:0}]}]);function l(){"undefined"!=typeof customElements&&["kritzel-portal"].forEach((t=>{"kritzel-portal"===t&&(customElements.get(o(t))||customElements.define(o(t),a))}))}export{a as K,l as d}
|