@sixb/app 0.2.4 → 0.2.6
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/assets/connector-icons/README.md +1 -0
- package/assets/connector-icons/ctm.png +0 -0
- package/dist/agent/activity-label.d.ts.map +1 -1
- package/dist/agent/agent-chat.d.ts +3 -1
- package/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/agent-panel.d.ts.map +1 -1
- package/dist/agent/artifact-panel.d.ts +3 -1
- package/dist/agent/artifact-panel.d.ts.map +1 -1
- package/dist/agent/components/agent-threads.d.ts.map +1 -1
- package/dist/agent/components/composer-place.d.ts.map +1 -1
- package/dist/agent/components/composer-settings.d.ts +1 -1
- package/dist/agent/components/composer-settings.d.ts.map +1 -1
- package/dist/agent/components/composer.d.ts +22 -5
- package/dist/agent/components/composer.d.ts.map +1 -1
- package/dist/agent/components/computer-place.d.ts +24 -6
- package/dist/agent/components/computer-place.d.ts.map +1 -1
- package/dist/agent/components/context-meter.d.ts +1 -1
- package/dist/agent/components/context-meter.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts +5 -2
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/message-parts.d.ts +2 -1
- package/dist/agent/components/message-parts.d.ts.map +1 -1
- package/dist/agent/components/message-view.d.ts +13 -3
- package/dist/agent/components/message-view.d.ts.map +1 -1
- package/dist/agent/components/pending-messages.d.ts +20 -0
- package/dist/agent/components/pending-messages.d.ts.map +1 -0
- package/dist/agent/components/sandbox-recovery.d.ts +11 -2
- package/dist/agent/components/sandbox-recovery.d.ts.map +1 -1
- package/dist/agent/components/threads-button.d.ts +1 -1
- package/dist/agent/components/threads-button.d.ts.map +1 -1
- package/dist/agent/components/transcript.d.ts +13 -0
- package/dist/agent/components/transcript.d.ts.map +1 -1
- package/dist/agent/conversation.d.ts +7 -6
- package/dist/agent/conversation.d.ts.map +1 -1
- package/dist/agent/delegation/interpret.d.ts +5 -0
- package/dist/agent/delegation/interpret.d.ts.map +1 -1
- package/dist/agent/delegation/use-children.d.ts.map +1 -1
- package/dist/agent/format.d.ts +7 -0
- package/dist/agent/format.d.ts.map +1 -1
- package/dist/agent/hooks/thread-queries.d.ts +1548 -0
- package/dist/agent/hooks/thread-queries.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +51 -6
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-lists.d.ts +80 -3
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
- package/dist/agent/hooks/use-thread-place.d.ts +49 -0
- package/dist/agent/hooks/use-thread-place.d.ts.map +1 -0
- package/dist/agent/hooks/use-thread-stream.d.ts.map +1 -1
- package/dist/agent/i18n/en.d.ts +107 -6
- package/dist/agent/i18n/en.d.ts.map +1 -1
- package/dist/agent/i18n/fr.d.ts.map +1 -1
- package/dist/agent/i18n/index.d.ts +180 -12
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/inbox-handoff.d.ts +10 -0
- package/dist/agent/inbox-handoff.d.ts.map +1 -0
- package/dist/agent/live-run.d.ts +8 -1
- package/dist/agent/live-run.d.ts.map +1 -1
- package/dist/agent/model-selection.d.ts +3 -2
- package/dist/agent/model-selection.d.ts.map +1 -1
- package/dist/agent/moves.d.ts +40 -0
- package/dist/agent/moves.d.ts.map +1 -0
- package/dist/agent/search/interpret.d.ts +101 -0
- package/dist/agent/search/interpret.d.ts.map +1 -0
- package/dist/agent/search/search-tool-view.d.ts +10 -0
- package/dist/agent/search/search-tool-view.d.ts.map +1 -0
- package/dist/agent/thread-reader-state.d.ts +30 -0
- package/dist/agent/thread-reader-state.d.ts.map +1 -0
- package/dist/agent/thread-state.d.ts +26 -0
- package/dist/agent/thread-state.d.ts.map +1 -0
- package/dist/agent/tool-views/built-in.d.ts.map +1 -1
- package/dist/agent/tool-views/registry.d.ts +5 -6
- package/dist/agent/tool-views/registry.d.ts.map +1 -1
- package/dist/agent/types.d.ts +9 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts +2 -1
- package/dist/agent/view-file/view-file-tool-view.d.ts.map +1 -1
- package/dist/artifacts/card-preview.d.ts.map +1 -1
- package/dist/artifacts/editor/block-handle.d.ts +20 -0
- package/dist/artifacts/editor/block-handle.d.ts.map +1 -0
- package/dist/artifacts/editor/blocks.d.ts +34 -0
- package/dist/artifacts/editor/blocks.d.ts.map +1 -0
- package/dist/artifacts/editor/callout-view.d.ts +7 -0
- package/dist/artifacts/editor/callout-view.d.ts.map +1 -0
- package/dist/artifacts/editor/document-editor.d.ts +30 -0
- package/dist/artifacts/editor/document-editor.d.ts.map +1 -0
- package/dist/artifacts/editor/figure-view.d.ts +12 -0
- package/dist/artifacts/editor/figure-view.d.ts.map +1 -0
- package/dist/artifacts/editor/find-blocks.d.ts +6 -0
- package/dist/artifacts/editor/find-blocks.d.ts.map +1 -0
- package/dist/artifacts/editor/markdown-document.d.ts +12 -0
- package/dist/artifacts/editor/markdown-document.d.ts.map +1 -0
- package/dist/artifacts/editor/messages.d.ts +4 -0
- package/dist/artifacts/editor/messages.d.ts.map +1 -0
- package/dist/artifacts/editor/schema.d.ts +21 -0
- package/dist/artifacts/editor/schema.d.ts.map +1 -0
- package/dist/artifacts/editor/selection-toolbar.d.ts +35 -0
- package/dist/artifacts/editor/selection-toolbar.d.ts.map +1 -0
- package/dist/artifacts/editor/slash-menu.d.ts +43 -0
- package/dist/artifacts/editor/slash-menu.d.ts.map +1 -0
- package/dist/artifacts/editor/upload.d.ts +12 -0
- package/dist/artifacts/editor/upload.d.ts.map +1 -0
- package/dist/artifacts/file-source.d.ts +5 -0
- package/dist/artifacts/file-source.d.ts.map +1 -1
- package/dist/artifacts/frame-editor/bundle.d.ts +7 -0
- package/dist/artifacts/frame-editor/bundle.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/commands.d.ts +93 -0
- package/dist/artifacts/frame-editor/commands.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/entry.d.ts +2 -0
- package/dist/artifacts/frame-editor/entry.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/frame.d.ts +5 -0
- package/dist/artifacts/frame-editor/frame.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/keys.d.ts +8 -0
- package/dist/artifacts/frame-editor/keys.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/protocol.d.ts +186 -0
- package/dist/artifacts/frame-editor/protocol.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/schema.d.ts +34 -0
- package/dist/artifacts/frame-editor/schema.d.ts.map +1 -0
- package/dist/artifacts/frame-editor/style.d.ts +2 -0
- package/dist/artifacts/frame-editor/style.d.ts.map +1 -0
- package/dist/artifacts/frame.d.ts +2 -2
- package/dist/artifacts/frame.d.ts.map +1 -1
- package/dist/artifacts/live/boards.d.ts +2 -0
- package/dist/artifacts/live/boards.d.ts.map +1 -1
- package/dist/artifacts/live/document.d.ts +32 -0
- package/dist/artifacts/live/document.d.ts.map +1 -0
- package/dist/artifacts/live/header.d.ts +4 -4
- package/dist/artifacts/live/header.d.ts.map +1 -1
- package/dist/artifacts/live/presence.d.ts.map +1 -1
- package/dist/artifacts/live/session.d.ts +2 -0
- package/dist/artifacts/live/session.d.ts.map +1 -1
- package/dist/artifacts/live/view.d.ts +4 -3
- package/dist/artifacts/live/view.d.ts.map +1 -1
- package/dist/artifacts/messages.d.ts +226 -2
- package/dist/artifacts/messages.d.ts.map +1 -1
- package/dist/artifacts/pdf.d.ts +8 -0
- package/dist/artifacts/pdf.d.ts.map +1 -0
- package/dist/artifacts/queries.d.ts +80 -0
- package/dist/artifacts/queries.d.ts.map +1 -1
- package/dist/artifacts/references/references.d.ts +3 -3
- package/dist/artifacts/references/references.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comment-pins.d.ts +4 -2
- package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -1
- package/dist/artifacts/renderers/canvas/comments.d.ts +2 -1
- package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -1
- package/dist/artifacts/renderers/designed-document.d.ts +28 -0
- package/dist/artifacts/renderers/designed-document.d.ts.map +1 -0
- package/dist/artifacts/renderers/document-tree.d.ts +2 -0
- package/dist/artifacts/renderers/document-tree.d.ts.map +1 -1
- package/dist/artifacts/renderers/document.d.ts +9 -1
- package/dist/artifacts/renderers/document.d.ts.map +1 -1
- package/dist/artifacts/renderers/live-frame.d.ts +145 -0
- package/dist/artifacts/renderers/live-frame.d.ts.map +1 -0
- package/dist/artifacts/renderers/page-editor.d.ts +16 -0
- package/dist/artifacts/renderers/page-editor.d.ts.map +1 -0
- package/dist/artifacts/renderers/page.d.ts +10 -1
- package/dist/artifacts/renderers/page.d.ts.map +1 -1
- package/dist/artifacts/viewer.d.ts.map +1 -1
- package/dist/{chunk-pxd07kvx.js → chunk-096d52h2.js} +1 -1
- package/dist/{chunk-yrcm1pbg.js → chunk-94d7enwc.js} +491 -2128
- package/dist/chunk-94d7enwc.js.map +27 -0
- package/dist/{chunk-970s5nkn.js → chunk-ezntd3yy.js} +1 -1
- package/dist/{chunk-kymx9y5e.js → chunk-qjw5r2vk.js} +12729 -5044
- package/dist/chunk-qjw5r2vk.js.map +242 -0
- package/dist/chunk-y51c4tsz.js +11 -0
- package/dist/chunk-y51c4tsz.js.map +10 -0
- package/dist/createCustomApp.d.ts +8 -1
- package/dist/createCustomApp.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -6
- package/dist/index.js.map +5 -5
- package/dist/pages/console/data/accounts.d.ts +94 -0
- package/dist/pages/console/data/accounts.d.ts.map +1 -0
- package/dist/pages/console/data/connectors.d.ts.map +1 -1
- package/dist/pages/console/data/live-updates.d.ts.map +1 -1
- package/dist/pages/console/data/messages.d.ts +52 -0
- package/dist/pages/console/data/messages.d.ts.map +1 -1
- package/dist/pages/console/data/shared.d.ts.map +1 -1
- package/dist/pages/console/data/sync-button.d.ts.map +1 -1
- package/dist/pages/console/data/syncs.d.ts.map +1 -1
- package/dist/pages/settings/usage/breakdown.d.ts.map +1 -1
- package/dist/pages/settings/usage/page.d.ts +4 -1
- package/dist/pages/settings/usage/page.d.ts.map +1 -1
- package/dist/pages/settings/usage/spend-model.d.ts +43 -19
- package/dist/pages/settings/usage/spend-model.d.ts.map +1 -1
- package/dist/pages.js +23044 -22570
- package/dist/pages.js.map +17 -16
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +40 -3
- package/dist/server.js.map +3 -3
- package/dist/shell/search-command.d.ts.map +1 -1
- package/package.json +22 -5
- package/src/agent/activity-label.ts +3 -0
- package/src/agent/agent-chat.tsx +58 -39
- package/src/agent/agent-execution-trace.tsx +2 -2
- package/src/agent/agent-panel.tsx +6 -4
- package/src/agent/agent.css +254 -0
- package/src/agent/artifact-panel.tsx +77 -22
- package/src/agent/components/agent-threads.tsx +42 -2
- package/src/agent/components/composer-place.tsx +2 -7
- package/src/agent/components/composer-settings.tsx +20 -10
- package/src/agent/components/composer.tsx +342 -104
- package/src/agent/components/computer-place.tsx +415 -70
- package/src/agent/components/context-meter.tsx +7 -3
- package/src/agent/components/conversation-panel.tsx +99 -54
- package/src/agent/components/message-parts.tsx +367 -59
- package/src/agent/components/message-view.tsx +428 -9
- package/src/agent/components/pending-messages.tsx +342 -0
- package/src/agent/components/sandbox-recovery.tsx +36 -17
- package/src/agent/components/threads-button.tsx +3 -2
- package/src/agent/components/transcript.tsx +198 -38
- package/src/agent/conversation.ts +219 -55
- package/src/agent/delegation/interpret.ts +31 -7
- package/src/agent/format.ts +52 -0
- package/src/agent/hooks/thread-queries.ts +75 -0
- package/src/agent/hooks/use-agent-conversation.ts +801 -211
- package/src/agent/hooks/use-thread-lists.ts +72 -7
- package/src/agent/hooks/use-thread-place.ts +239 -0
- package/src/agent/hooks/use-thread-stream.ts +10 -0
- package/src/agent/i18n/en.ts +150 -27
- package/src/agent/i18n/fr.ts +148 -31
- package/src/agent/inbox-handoff.ts +47 -0
- package/src/agent/live-run.ts +61 -2
- package/src/agent/model-selection.ts +3 -2
- package/src/agent/moves.ts +174 -0
- package/src/agent/react-router.tsx +2 -2
- package/src/agent/search/interpret.ts +367 -0
- package/src/agent/search/search-tool-view.tsx +235 -0
- package/src/agent/thread-reader-state.ts +75 -0
- package/src/agent/thread-state.ts +114 -0
- package/src/agent/tool-views/built-in.tsx +16 -0
- package/src/agent/tool-views/registry.tsx +28 -2
- package/src/agent/types.ts +13 -0
- package/src/agent/view-file/view-file-tool-view.tsx +33 -19
- package/src/artifacts/artifacts.css +398 -0
- package/src/artifacts/card-preview.tsx +6 -1
- package/src/artifacts/editor/block-handle.tsx +278 -0
- package/src/artifacts/editor/blocks.ts +216 -0
- package/src/artifacts/editor/callout-view.tsx +31 -0
- package/src/artifacts/editor/document-editor.tsx +484 -0
- package/src/artifacts/editor/figure-view.tsx +66 -0
- package/src/artifacts/editor/find-blocks.ts +19 -0
- package/src/artifacts/editor/markdown-document.tsx +72 -0
- package/src/artifacts/editor/messages.ts +4 -0
- package/src/artifacts/editor/schema.ts +159 -0
- package/src/artifacts/editor/selection-toolbar.tsx +364 -0
- package/src/artifacts/editor/slash-menu.tsx +251 -0
- package/src/artifacts/editor/upload.ts +40 -0
- package/src/artifacts/file-source.ts +11 -0
- package/src/artifacts/frame-editor/bundle.ts +8 -0
- package/src/artifacts/frame-editor/commands.ts +565 -0
- package/src/artifacts/frame-editor/entry.ts +6 -0
- package/src/artifacts/frame-editor/frame.ts +847 -0
- package/src/artifacts/frame-editor/generated/editor.txt +149 -0
- package/src/artifacts/frame-editor/generated.d.ts +5 -0
- package/src/artifacts/frame-editor/keys.ts +323 -0
- package/src/artifacts/frame-editor/protocol.ts +151 -0
- package/src/artifacts/frame-editor/schema.ts +293 -0
- package/src/artifacts/frame-editor/style.ts +58 -0
- package/src/artifacts/frame.tsx +11 -3
- package/src/artifacts/live/boards.ts +46 -3
- package/src/artifacts/live/document.ts +89 -0
- package/src/artifacts/live/header.tsx +9 -14
- package/src/artifacts/live/presence.ts +5 -1
- package/src/artifacts/live/session.ts +9 -2
- package/src/artifacts/live/view.ts +14 -8
- package/src/artifacts/messages.ts +138 -2
- package/src/artifacts/pdf.ts +50 -0
- package/src/artifacts/references/references.tsx +46 -11
- package/src/artifacts/renderers/canvas/board-editor.tsx +11 -144
- package/src/artifacts/renderers/canvas/comment-pins.tsx +5 -0
- package/src/artifacts/renderers/canvas/comments-panel.tsx +58 -1
- package/src/artifacts/renderers/canvas/comments.ts +8 -4
- package/src/artifacts/renderers/designed-document.tsx +277 -0
- package/src/artifacts/renderers/document-tree.ts +9 -0
- package/src/artifacts/renderers/document.tsx +13 -102
- package/src/artifacts/renderers/live-frame.ts +163 -0
- package/src/artifacts/renderers/page-editor.tsx +613 -0
- package/src/artifacts/renderers/page.tsx +21 -4
- package/src/artifacts/viewer.tsx +87 -41
- package/src/createCustomApp.ts +57 -3
- package/src/index.ts +10 -0
- package/src/pages/console/data/accounts.tsx +509 -0
- package/src/pages/console/data/connectors.tsx +7 -15
- package/src/pages/console/data/live-updates.ts +2 -0
- package/src/pages/console/data/messages.ts +79 -0
- package/src/pages/console/data/projections.tsx +4 -0
- package/src/pages/console/data/shared.tsx +1 -0
- package/src/pages/console/data/sync-button.tsx +56 -16
- package/src/pages/console/data/syncs.tsx +66 -41
- package/src/pages/console/ontology/lineage/trail.tsx +3 -0
- package/src/pages/section-ui.tsx +1 -1
- package/src/pages/settings/usage/breakdown.tsx +5 -2
- package/src/pages/settings/usage/filter-menu.tsx +1 -1
- package/src/pages/settings/usage/page.tsx +32 -13
- package/src/pages/settings/usage/spend-chart.tsx +2 -2
- package/src/pages/settings/usage/spend-model.ts +118 -50
- package/src/server.ts +1 -0
- package/src/shell/search-command.tsx +2 -0
- package/dist/chunk-kymx9y5e.js.map +0 -211
- package/dist/chunk-yrcm1pbg.js.map +0 -34
- /package/dist/{chunk-pxd07kvx.js.map → chunk-096d52h2.js.map} +0 -0
- /package/dist/{chunk-970s5nkn.js.map → chunk-ezntd3yy.js.map} +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
(()=>{var AO=new RegExp("^art_[0123456789abcdefghjkmnpqrstvwxyz]{10}$");var kT="artifact:";function Jo(e){return e.trim().toLowerCase().startsWith(kT)}var on={maxFiles:500,maxFileBytes:26214400,maxVersionBytes:262144000,maxPathLength:512,maxTitleLength:200,maxDocumentBytes:2097152,maxThemeBytes:4096,maxWorkbookBytes:262144,maxSheets:20,maxSheetRows:1e5,maxSheetFileBytes:5242880,maxSheetColumns:200,maxCharts:10,maxChartSeries:5,maxPieSlices:5,maxDeckBytes:2097152,maxPageBytes:2097152,maxSlides:100,maxCanvasBytes:524288,maxCanvasItems:1000,maxCanvasBoards:100,minCanvasItemSize:40,maxCanvasItemSize:8000,maxCanvasPosition:1e5,maxCanvasTextLength:2000,maxCanvasLabelLength:120,maxBoardBytes:2097152,maxReferences:200,maxQueries:20,maxQueryBytes:65536,maxQueryRows:1e4};var DO=on.maxCanvasTextLength,vO=on.maxCanvasLabelLength;var Ss={settleMs:15000,timeoutMs:300000,attempts:3,backoffMs:60000},NT=Ss.settleMs+Ss.attempts*Ss.timeoutMs+(Ss.attempts-1)*Ss.backoffMs;var LT=["--background","--foreground","--card","--card-foreground","--muted","--muted-foreground","--primary","--primary-foreground","--accent","--accent-foreground","--border","--chart-1","--chart-2","--chart-3","--chart-4","--chart-5"],PT=["--font-sans","--font-serif","--font-mono"],BT=[...LT,...PT,"--radius"];var dI=on.maxBoardBytes;var Qo={timeoutMs:120000,attempts:2,backoffMs:15000},UT=Qo.attempts*Qo.timeoutMs+(Qo.attempts-1)*Qo.backoffMs;var _e=()=>new Map,Zo=(e)=>{let t=_e();return e.forEach((n,r)=>{t.set(r,n)}),t},et=(e,t,n)=>{let r=e.get(t);if(r===void 0)e.set(t,r=n());return r},Td=(e,t)=>{let n=[];for(let[r,s]of e)n.push(t(s,r));return n},bd=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1};var ct=()=>new Set;var ti=(e)=>e[e.length-1];var Sd=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},At=Array.from,ni=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},As=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1};var xd=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n};var Ft=Array.isArray;class ri{constructor(){this._observers=_e()}on(e,t){return et(this._observers,e,ct).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);if(n!==void 0){if(n.delete(t),n.size===0)this._observers.delete(e)}}emit(e,t){return At((this._observers.get(e)||_e()).values()).forEach((n)=>n(...t))}destroy(){this._observers=_e()}}class ml{constructor(){this._observers=_e()}on(e,t){et(this._observers,e,ct).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);if(n!==void 0){if(n.delete(t),n.size===0)this._observers.delete(e)}}emit(e,t){return At((this._observers.get(e)||_e()).values()).forEach((n)=>n(...t))}destroy(){this._observers=_e()}}var Se=Math.floor;var Dn=Math.abs;var tt=(e,t)=>e<t?e:t,nt=(e,t)=>e>t?e:t;var si=(e)=>e!==0?e<0:1/e<0;var gl=1,yl=2,oi=4,ii=8;var Tr=32,ut=64,xe=128;var Ad=536870912;var Cs=31,ks=63,Ut=127;var wd=2147483647;var{MAX_SAFE_INTEGER:br,MIN_SAFE_INTEGER:El}=Number;var Cd=Number.isInteger||((e)=>typeof e==="number"&&isFinite(e)&&Se(e)===e);var{fromCharCode:_s,fromCodePoint:XT}=String,CM=_s(65535),GT=(e)=>e.toLowerCase(),JT=/^\s*/g,QT=(e)=>e.replace(JT,""),ZT=/([A-Z])/g,bl=(e,t)=>QT(e.replace(ZT,(n)=>`${t}${GT(n)}`));var eb=(e)=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=t.codePointAt(s);return r},xr=typeof TextEncoder<"u"?new TextEncoder:null,tb=(e)=>xr.encode(e),kd=xr?tb:eb;var Sr=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(Sr&&Sr.decode(new Uint8Array).length===1)Sr=null;var _d=(e,t)=>xd(t,()=>e).join("");class Ar{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var wr=()=>new Ar,Md=(e)=>{let t=wr();return e(t),dt(t)},nb=(e)=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t};var dt=(e)=>{let t=new Uint8Array(nb(e)),n=0;for(let r=0;r<e.bufs.length;r++){let s=e.bufs[r];t.set(s,n),n+=s.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},rb=(e,t)=>{let n=e.cbuf.length;if(n-e.cpos<t)e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(nt(n,t)*2),e.cpos=0},Ne=(e,t)=>{let n=e.cbuf.length;if(e.cpos===n)e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0;e.cbuf[e.cpos++]=t};var li=Ne;var G=(e,t)=>{while(t>Ut)Ne(e,xe|Ut&t),t=Se(t/128);Ne(e,Ut&t)},ci=(e,t)=>{let n=si(t);if(n)t=-t;Ne(e,(t>ks?xe:0)|(n?ut:0)|ks&t),t=Se(t/64);while(t>0)Ne(e,(t>Ut?xe:0)|Ut&t),t=Se(t/128)},Sl=new Uint8Array(30000),sb=Sl.length/3,ob=(e,t)=>{if(t.length<sb){let n=xr.encodeInto(t,Sl).written||0;G(e,n);for(let r=0;r<n;r++)Ne(e,Sl[r])}else Xe(e,kd(t))},ib=(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;G(e,r);for(let s=0;s<r;s++)Ne(e,n.codePointAt(s))},vn=xr&&xr.encodeInto?ob:ib;var Os=(e,t)=>{let n=e.cbuf.length,r=e.cpos,s=tt(n-r,t.length),o=t.length-s;if(e.cbuf.set(t.subarray(0,s),r),e.cpos+=s,o>0)e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(nt(n*2,o)),e.cbuf.set(t.subarray(s)),e.cpos=o},Xe=(e,t)=>{G(e,t.byteLength),Os(e,t)},xl=(e,t)=>{rb(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},ab=(e,t)=>xl(e,4).setFloat32(0,t,!1),lb=(e,t)=>xl(e,8).setFloat64(0,t,!1),cb=(e,t)=>xl(e,8).setBigInt64(0,t,!1);var Nd=new DataView(new ArrayBuffer(4)),ub=(e)=>(Nd.setFloat32(0,e),Nd.getFloat32(0)===e),ln=(e,t)=>{switch(typeof t){case"string":Ne(e,119),vn(e,t);break;case"number":if(Cd(t)&&Dn(t)<=wd)Ne(e,125),ci(e,t);else if(ub(t))Ne(e,124),ab(e,t);else Ne(e,123),lb(e,t);break;case"bigint":Ne(e,122),cb(e,t);break;case"object":if(t===null)Ne(e,126);else if(Ft(t)){Ne(e,117),G(e,t.length);for(let n=0;n<t.length;n++)ln(e,t[n])}else if(t instanceof Uint8Array)Ne(e,116),Xe(e,t);else{Ne(e,118);let n=Object.keys(t);G(e,n.length);for(let r=0;r<n.length;r++){let s=n[r];vn(e,s),ln(e,t[s])}}break;case"boolean":Ne(e,t?120:121);break;default:Ne(e,127)}};class ui extends Ar{constructor(e){super();this.w=e,this.s=null,this.count=0}write(e){if(this.s===e)this.count++;else{if(this.count>0)G(this,this.count-1);this.count=1,this.w(this,e),this.s=e}}}var Od=(e)=>{if(e.count>0){if(ci(e.encoder,e.count===1?e.s:-e.s),e.count>1)G(e.encoder,e.count-2)}};class Cr{constructor(){this.encoder=new Ar,this.s=0,this.count=0}write(e){if(this.s===e)this.count++;else Od(this),this.count=1,this.s=e}toUint8Array(){return Od(this),dt(this.encoder)}}var Id=(e)=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);if(ci(e.encoder,t),e.count>1)G(e.encoder,e.count-2)}};class Is{constructor(){this.encoder=new Ar,this.s=0,this.count=0,this.diff=0}write(e){if(this.diff===e-this.s)this.s=e,this.count++;else Id(this),this.count=1,this.diff=e-this.s,this.s=e}toUint8Array(){return Id(this),dt(this.encoder)}}class Al{constructor(){this.sarr=[],this.s="",this.lensE=new Cr}write(e){if(this.s+=e,this.s.length>19)this.sarr.push(this.s),this.s="";this.lensE.write(e.length)}toUint8Array(){let e=new Ar;return this.sarr.push(this.s),this.s="",vn(e,this.sarr.join("")),Os(e,this.lensE.toUint8Array()),dt(e)}}var rt=(e)=>Error(e),Ve=()=>{throw rt("Method unimplemented")},ce=()=>{throw rt("Unexpected case")};var fi=rt("Unexpected end of array"),Dd=rt("Integer out of Range"),db=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw fi;return new Uint8Array(e.buffer,e.byteOffset+t,n)},fb=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw fi;return new DataView(e.buffer,e.byteOffset+t,n)};class Ms{constructor(e){this.arr=e,this.pos=0}}var _r=(e)=>new Ms(e),vd=(e)=>e.pos!==e.arr.length;var hb=(e,t)=>{let n=db(e.arr,e.pos,t);return e.pos+=t,n},Ge=(e)=>hb(e,K(e));var Ln=(e)=>e.arr[e.pos++];var K=(e)=>{let t=0,n=1,r=e.arr.length;while(e.pos<r){let s=e.arr[e.pos++];if(t=t+(s&Ut)*n,n*=128,s<xe)return t;if(t>br)throw Dd}throw fi},hi=(e)=>{let t=e.arr[e.pos++],n=t&ks,r=64,s=(t&ut)>0?-1:1;if((t&xe)===0)return s*n;let o=e.arr.length;while(e.pos<o){if(t=e.arr[e.pos++],n=n+(t&Ut)*r,r*=128,t<xe)return s*n;if(n>br)throw Dd}throw fi};var pb=(e)=>{let t=K(e);if(t===0)return"";else{let n=String.fromCodePoint(Ln(e));if(--t<100)while(t--)n+=String.fromCodePoint(Ln(e));else while(t>0){let r=t<1e4?t:1e4,s=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,s),t-=r}return decodeURIComponent(escape(n))}},mb=(e)=>Sr.decode(Ge(e)),Ht=Sr?mb:pb;var wl=(e,t)=>{let n=fb(e.arr,e.pos,t);return e.pos+=t,n},gb=(e)=>wl(e,4).getFloat32(0,!1),yb=(e)=>wl(e,8).getFloat64(0,!1),Eb=(e)=>wl(e,8).getBigInt64(0,!1);var Tb=[(e)=>{return},(e)=>null,hi,gb,yb,Eb,(e)=>!1,(e)=>!0,Ht,(e)=>{let t=K(e),n={};for(let r=0;r<t;r++){let s=Ht(e);n[s]=kr(e)}return n},(e)=>{let t=K(e),n=[];for(let r=0;r<t;r++)n.push(kr(e));return n},Ge],kr=(e)=>Tb[127-Ln(e)](e);class pi extends Ms{constructor(e,t){super(e);this.reader=t,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),vd(this))this.count=K(this)+1;else this.count=-1;return this.count--,this.s}}class Nr extends Ms{constructor(e){super(e);this.s=0,this.count=0}read(){if(this.count===0){this.s=hi(this);let e=si(this.s);if(this.count=1,e)this.s=-this.s,this.count=K(this)+2}return this.count--,this.s}}class Rs extends Ms{constructor(e){super(e);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=hi(this),t=e&1;if(this.diff=Se(e/2),this.count=1,t)this.count=K(this)+2}return this.s+=this.diff,this.count--,this.s}}class Cl{constructor(e){this.decoder=new Nr(e),this.str=Ht(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}var NM=crypto.subtle,Pd=crypto.getRandomValues.bind(crypto);var bb=Math.random,kl=()=>Pd(new Uint32Array(1))[0];var Bd=(e)=>e[Se(bb()*e.length)],Sb=[1e7]+-1000+-4000+-8000+-100000000000,Fd=()=>Sb.replace(/[018]/g,(e)=>(e^kl()&15>>e/4).toString(16));var $t=Date.now;var Nl=(e)=>new Promise(e);var MM=Promise.all.bind(Promise);var Ol=(e)=>e===void 0?null:e;class Hd{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}var $d=new Hd,wb=!0;try{if(typeof localStorage<"u"&&localStorage)$d=localStorage,wb=!1}catch(e){}var Vd=$d;var Pn=Symbol("Equality"),mi=(e,t)=>e===t||!!e?.[Pn]?.(t)||!1;var zd=(e)=>typeof e==="object",{assign:Yd,keys:Ml}=Object;var jd=(e,t)=>{for(let n in e)t(e[n],n)};var Ds=(e)=>Ml(e).length;var Wd=(e)=>{for(let t in e)return!1;return!0},Or=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},vs=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Rl=(e,t)=>e===t||Ds(e)===Ds(t)&&Or(e,(n,r)=>(n!==void 0||vs(t,r))&&mi(t[r],n)),kb=Object.freeze,Dl=(e)=>{for(let t in e){let n=e[t];if(typeof n==="object"||typeof n==="function")Dl(e[t])}return kb(e)};var Ls=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{if(n<e.length)Ls(e,t,n+1)}};var cn=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Pn]!=null)return e[Pn](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:{if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break}case Set:{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break}case Map:{if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!cn(e.get(n),t.get(n)))return!1;break}case void 0:case Object:if(Ds(e)!==Ds(t))return!1;for(let n in e)if(!vs(e,n)||!cn(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!cn(e[n],t[n]))return!1;break;default:return!1}return!0},Kd=(e,t)=>t.includes(e);var Ir=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Bs=typeof window<"u"&&typeof document<"u"&&!Ir,RM=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,wt,_b=[],Nb=()=>{if(wt===void 0)if(Ir){wt=_e();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];if(r[0]==="-"){if(t!==null)wt.set(t,"");t=r}else if(t!==null)wt.set(t,r),t=null;else _b.push(r)}if(t!==null)wt.set(t,"")}else if(typeof location==="object")wt=_e(),(location.search||"?").slice(1).split("&").forEach((e)=>{if(e.length!==0){let[t,n]=e.split("=");wt.set(`--${bl(t,"-")}`,n),wt.set(`-${bl(t,"-")}`,n)}});else wt=_e();return wt},vl=(e)=>Nb().has(e);var Ps=(e)=>Ir?Ol(process.env[e.toUpperCase().replaceAll("-","_")]):Ol(Vd.getItem(e));var qd=(e)=>vl("--"+e)||Ps(e)!==null,Xd=qd("production"),Ob=Ir&&Kd(process.env.FORCE_COLOR,["true","1","2"]),Gd=Ob||!vl("--no-colors")&&!qd("no-color")&&(!Ir||process.stdout.isTTY)&&(!Ir||vl("--color")||Ps("COLORTERM")!==null||(Ps("TERM")||"").includes("color"));var Ib=(e)=>new Uint8Array(e);var Mb=(e)=>{let t="";for(let n=0;n<e.byteLength;n++)t+=_s(e[n]);return btoa(t)},Rb=(e)=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64");var Jd=Bs?Mb:Rb;var Qd=(e)=>{let t=Ib(e.byteLength);return t.set(e),t},Zd=(e)=>Md((t)=>ln(t,e));class tf{constructor(e,t){this.left=e,this.right=t}}var Ct=(e,t)=>new tf(e,t);var Ll=(e)=>e.next()>=0.5,Ei=(e,t,n)=>Se(e.next()*(n+1-t)+t);var Pl=(e,t,n)=>Se(e.next()*(n+1-t)+t);var Bl=(e,t,n)=>Pl(e,t,n);var vb=(e)=>_s(Bl(e,97,122)),nf=(e,t=0,n=20)=>{let r=Bl(e,t,n),s="";for(let o=0;o<r;o++)s+=vb(e);return s};var Ti=(e,t)=>t[Bl(e,0,t.length-1)];var Pb=Symbol("0schema");class sf{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(_d(" ",(this._rerrs.length-t)*2)+`${n.path!=null?`[${n.path}] `:""}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
2
|
+
`)}}var Fl=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor)return!1;if(e[Pn])return mi(e,t);if(Ft(e))return ni(e,(n)=>As(t,(r)=>Fl(n,r)));else if(zd(e))return Or(e,(n,r)=>Fl(n,t[r]));return!1};class Pe{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];if(this.constructor._dilutes)[n,t]=[t,n];return Fl(t,n)}equals(e){return this.constructor===e.constructor&&cn(this.shape,e.shape)}[Pb](){return!0}[Pn](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Ve()}get nullable(){return vr(this,Ni)}get optional(){return new Ul(this)}cast(e){return rf(e,this),e}expect(e){return rf(e,this),e}}class xi extends Pe{constructor(e,t){super();this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),n}}var Te=(e,t=null)=>new xi(e,t),vM=Te(xi);class Ai extends Pe{constructor(e){super();this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),n}}var Ae=(e)=>new Ai(e),LM=Te(Ai);class Hs extends Pe{constructor(e){super();this.shape=e}check(e,t){let n=this.shape.some((r)=>r===e);return!n&&t?.extend(null,this.shape.join(" | "),e.toString()),n}}var wi=(...e)=>new Hs(e),of=Te(Hs),Bb=RegExp.escape||((e)=>e.replace(/[().|&,$^[\]]/g,(t)=>"\\"+t)),af=(e)=>{if(Dr.check(e))return[Bb(e)];if(of.check(e))return e.shape.map((t)=>t+"");if(mf.check(e))return["[+-]?\\d+.?\\d*"];if(gf.check(e))return[".*"];if(bi.check(e))return e.shape.map(af).flat(1);ce()};class lf extends Pe{constructor(e){super();this.shape=e,this._r=new RegExp("^"+e.map(af).map((t)=>`(${t.join("|")})`).join("")+"$")}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),n}}var PM=Te(lf),Fb=Symbol("optional");class Ul extends Pe{constructor(e){super();this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,"undefined (optional)","()"),n}get[Fb](){return!0}}var Ub=Te(Ul);class Hl extends Pe{check(e,t){return t?.extend(null,"never",typeof e),!1}}var BM=new Hl,FM=Te(Hl);class Ci extends Pe{constructor(e,t=!1){super();this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new Ci(this.shape,!0)}check(e,t){if(e==null)return t?.extend(null,"object","null"),!1;return Or(this.shape,(n,r)=>{let s=this._isPartial&&!vs(e,r)||n.check(e[r],t);return!s&&t?.extend(r.toString(),n.toString(),typeof e[r],"Object property does not match"),s})}}var Hb=(e)=>new Ci(e),$b=Te(Ci),Vb=Ae((e)=>e!=null&&(e.constructor===Object||e.constructor==null));class $l extends Pe{constructor(e,t){super();this.shape={keys:e,values:t}}check(e,t){return e!=null&&Or(e,(n,r)=>{let s=this.shape.keys.check(r,t);return!s&&t?.extend(r+"","Record",typeof e,s?"Key doesn't match schema":"Value doesn't match value"),s&&this.shape.values.check(n,t)})}}var cf=(e,t)=>new $l(e,t),zb=Te($l);class Vl extends Pe{constructor(e){super();this.shape=e}check(e,t){return e!=null&&Or(this.shape,(n,r)=>{let s=n.check(e[r],t);return!s&&t?.extend(r.toString(),"Tuple",typeof n),s})}}var Yb=(...e)=>new Vl(e),UM=Te(Vl);class zl extends Pe{constructor(e){super();this.shape=e.length===1?e[0]:new ki(e)}check(e,t){let n=Ft(e)&&ni(e,(r)=>this.shape.check(r));return!n&&t?.extend(null,"Array",""),n}}var uf=(...e)=>new zl(e),jb=Te(zl),Wb=Ae((e)=>Ft(e));class Yl extends Pe{constructor(e,t){super();this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}}var Kb=(e,t=null)=>new Yl(e,t),HM=Te(Yl),qb=Kb(Pe);class df extends Pe{constructor(e){super();this.len=e.length-1,this.args=Yb(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,"function",typeof e),n}}var Xb=Te(df),Gb=Ae((e)=>typeof e==="function");class ff extends Pe{constructor(e){super();this.shape=e}check(e,t){let n=ni(this.shape,(r)=>r.check(e,t));return!n&&t?.extend(null,"Intersectinon",typeof e),n}}var $M=Te(ff,(e)=>e.shape.length>0);class ki extends Pe{static _dilutes=!0;constructor(e){super();this.shape=e}check(e,t){let n=As(this.shape,(r)=>r.check(e,t));return t?.extend(null,"Union",typeof e),n}}var vr=(...e)=>e.findIndex((t)=>bi.check(t))>=0?vr(...e.map((t)=>Us(t)).map((t)=>bi.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new ki(e),bi=Te(ki),hf=()=>!0,Si=Ae(hf),Jb=Te(Ai,(e)=>e.shape===hf),jl=Ae((e)=>typeof e==="bigint"),Qb=Ae((e)=>e===jl),pf=Ae((e)=>typeof e==="symbol"),VM=Ae((e)=>e===pf),Rr=Ae((e)=>typeof e==="number"),mf=Ae((e)=>e===Rr),Dr=Ae((e)=>typeof e==="string"),gf=Ae((e)=>e===Dr),_i=Ae((e)=>typeof e==="boolean"),Zb=Ae((e)=>e===_i),yf=wi(void 0),zM=Te(Hs,(e)=>e.shape.length===1&&e.shape[0]===void 0),YM=wi(void 0);var Ni=wi(null),eS=Te(Hs,(e)=>e.shape.length===1&&e.shape[0]===null),jM=Te(Uint8Array),WM=Te(xi,(e)=>e.shape===Uint8Array),tS=vr(Rr,Dr,Ni,yf,jl,_i,pf),KM=(()=>{let e=uf(Si),t=cf(Dr,Si),n=vr(Rr,Dr,Ni,_i,e,t);return e.shape=n,t.shape.values=n,n})(),Us=(e)=>{if(qb.check(e))return e;else if(Vb.check(e)){let t={};for(let n in e)t[n]=Us(e[n]);return Hb(t)}else if(Wb.check(e))return vr(...e.map(Us));else if(tS.check(e))return wi(e);else if(Gb.check(e))return Te(e);ce()},rf=Xd?()=>{}:(e,t)=>{let n=new sf;if(!t.check(e,n))throw rt(`Expected value to be of type ${t.constructor.name}.
|
|
3
|
+
${n.toString()}`)};class Ef{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Us(e),h:t}),this}else(e){return this.if(Si,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw rt("Unhandled pattern")}}}var nS=(e)=>new Ef(e),Tf=nS(Si).if(mf,(e,t)=>Ei(t,El,br)).if(gf,(e,t)=>nf(t)).if(Zb,(e,t)=>Ll(t)).if(Qb,(e,t)=>BigInt(Ei(t,El,br))).if(bi,(e,t)=>Mr(t,Ti(t,e.shape))).if($b,(e,t)=>{let n={};for(let r in e.shape){let s=e.shape[r];if(Ub.check(s)){if(Ll(t))continue;s=s.shape}n[r]=Tf(s,t)}return n}).if(jb,(e,t)=>{let n=[],r=Pl(t,0,42);for(let s=0;s<r;s++)n.push(Mr(t,e.shape));return n}).if(of,(e,t)=>Ti(t,e.shape)).if(eS,(e,t)=>null).if(Xb,(e,t)=>{let n=Mr(t,e.res);return()=>n}).if(Jb,(e,t)=>Mr(t,Ti(t,[Rr,Dr,Ni,yf,jl,_i,uf(Rr),cf(vr("a","b","c"),Rr)]))).if(zb,(e,t)=>{let n={},r=Ei(t,0,3);for(let s=0;s<r;s++){let o=Mr(t,e.shape.keys),i=Mr(t,e.shape.values);n[o]=i}return n}).done(),Mr=(e,t)=>Tf(Us(t),e);var Vt=typeof document<"u"?document:{};var qM=Ae((e)=>e.nodeType===aS);var XM=typeof DOMParser<"u"?new DOMParser:null;var GM=Ae((e)=>e.nodeType===sS);var JM=Ae((e)=>e.nodeType===oS);var bf=(e)=>Td(e,(t,n)=>`${n}:${t};`).join("");var{ELEMENT_NODE:sS,TEXT_NODE:oS,CDATA_SECTION_NODE:QM,COMMENT_NODE:ZM,DOCUMENT_NODE:iS,DOCUMENT_TYPE_NODE:eR,DOCUMENT_FRAGMENT_NODE:aS}=Vt,tR=Ae((e)=>e.nodeType===iS);var Oi=(e)=>class{constructor(n){this._=n}destroy(){e(this._)}},lS=Oi(clearTimeout),Lr=(e,t)=>new lS(setTimeout(t,e)),nR=Oi(clearInterval);var rR=Oi((e)=>typeof requestAnimationFrame<"u"&&cancelAnimationFrame(e));var sR=Oi((e)=>typeof cancelIdleCallback<"u"&&cancelIdleCallback(e));var kt=Symbol;var $s=kt(),Vs=kt(),Wl=kt(),Kl=kt(),ql=kt(),zs=kt(),Xl=kt(),Pr=kt(),Gl=kt(),xf=(e)=>{if(e.length===1&&e[0]?.constructor===Function)e=e[0]();let t=[],n=[],r=0;for(;r<e.length;r++){let s=e[r];if(s===void 0)break;else if(s.constructor===String||s.constructor===Number)t.push(s);else if(s.constructor===Object)break}if(r>0)n.push(t.join(""));for(;r<e.length;r++){let s=e[r];if(!(s instanceof Symbol))n.push(s)}return n};var oR=$t();var fS={[$s]:Ct("font-weight","bold"),[Vs]:Ct("font-weight","normal"),[Wl]:Ct("color","blue"),[ql]:Ct("color","green"),[Kl]:Ct("color","grey"),[zs]:Ct("color","red"),[Xl]:Ct("color","purple"),[Pr]:Ct("color","orange"),[Gl]:Ct("color","black")},hS=(e)=>{if(e.length===1&&e[0]?.constructor===Function)e=e[0]();let t=[],n=[],r=_e(),s=[],o=0;for(;o<e.length;o++){let i=e[o],a=fS[i];if(a!==void 0)r.set(a.left,a.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let l=bf(r);if(o>0||l.length>0)t.push("%c"+i),n.push(l);else t.push(i)}else break}}if(o>0)s=n,s.unshift(t.join(""));for(;o<e.length;o++){let i=e[o];if(!(i instanceof Symbol))s.push(i)}return s},Af=Gd?hS:xf,wf=(...e)=>{console.log(...Af(e)),Cf.forEach((t)=>t.print(e))},Jl=(...e)=>{console.warn(...Af(e)),e.unshift(Pr),Cf.forEach((t)=>t.print(e))};var Cf=ct();var kf=(e)=>({[Symbol.iterator](){return this},next:e}),_f=(e,t)=>kf(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),Ii=(e,t)=>kf(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});class Gs{constructor(e,t){this.clock=e,this.len=t}}class Hn{constructor(){this.clients=new Map}}var zt=(e,t,n)=>t.clients.forEach((r,s)=>{let o=e.doc.store.clients.get(s);if(o!=null){let i=o[o.length-1],a=i.id.clock+i.length;for(let l=0,c=r[l];l<r.length&&c.clock<a;c=r[++l])nh(e,o,c.clock,c.len,n)}}),gS=(e,t)=>{let n=0,r=e.length-1;while(n<=r){let s=Se((n+r)/2),o=e[s],i=o.clock;if(i<=t){if(t<i+o.len)return s;n=s+1}else r=s-1}return null},$n=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&gS(n,t.clock)!==null},rc=(e)=>{e.clients.forEach((t)=>{t.sort((s,o)=>s.clock-o.clock);let n,r;for(n=1,r=1;n<t.length;n++){let s=t[r-1],o=t[n];if(s.clock+s.len>=o.clock)t[r-1]=new Gs(s.clock,nt(s.len,o.clock+o.len-s.clock));else{if(r<n)t[r]=o;r++}}t.length=r})},Zl=(e)=>{let t=new Hn;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,s)=>{if(!t.clients.has(s)){let o=r.slice();for(let i=n+1;i<e.length;i++)Sd(o,e[i].clients.get(s)||[]);t.clients.set(s,o)}});return rc(t),t},js=(e,t,n,r)=>{et(e.clients,t,()=>[]).push(new Gs(n,r))},$i=()=>new Hn,yS=(e)=>{let t=$i();return e.clients.forEach((n,r)=>{let s=[];for(let o=0;o<n.length;o++){let i=n[o];if(i.deleted){let a=i.id.clock,l=i.length;if(o+1<n.length)for(let c=n[o+1];o+1<n.length&&c.deleted;c=n[++o+1])l+=c.length;s.push(new Gs(a,l))}}if(s.length>0)t.clients.set(r,s)}),t},sc=(e,t)=>{G(e.restEncoder,t.clients.size),At(t.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{e.resetDsCurVal(),G(e.restEncoder,n);let s=r.length;G(e.restEncoder,s);for(let o=0;o<s;o++){let i=r[o];e.writeDsClock(i.clock),e.writeDsLen(i.len)}})},ES=(e)=>{let t=new Hn,n=K(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let s=K(e.restDecoder),o=K(e.restDecoder);if(o>0){let i=et(t.clients,s,()=>[]);for(let a=0;a<o;a++)i.push(new Gs(e.readDsClock(),e.readDsLen()))}}return t},Nf=(e,t,n)=>{let r=new Hn,s=K(e.restDecoder);for(let o=0;o<s;o++){e.resetDsCurVal();let i=K(e.restDecoder),a=K(e.restDecoder),l=n.clients.get(i)||[],c=me(n,i);for(let u=0;u<a;u++){let d=e.readDsClock(),f=d+e.readDsLen();if(d<c){if(c<f)js(r,i,c,f-c);let h=ht(l,d),p=l[h];if(!p.deleted&&p.id.clock<d)l.splice(h+1,0,Hi(t,p,d-p.id.clock)),h++;while(h<l.length)if(p=l[h++],p.id.clock<f){if(!p.deleted){if(f<p.id.clock+p.length)l.splice(h,0,Hi(t,p,f-p.id.clock));p.delete(t)}}else break}else js(r,i,d,f-d)}}if(r.clients.size>0){let o=new Js;return G(o.restEncoder,0),sc(o,r),o.toUint8Array()}return null};var zf=kl;class _t extends ri{constructor({guid:e=Fd(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:i=!0}={}){super();this.gc=n,this.gcFilter=r,this.clientID=zf(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new lc,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=i,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Nl((l)=>{this.on("load",()=>{this.isLoaded=!0,l(this)})});let a=()=>Nl((l)=>{let c=(u)=>{if(u===void 0||u===!0)this.off("sync",c),l()};this.on("sync",c)});this.on("sync",(l)=>{if(l===!1&&this.isSynced)this.whenSynced=a();if(this.isSynced=l===void 0||l===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=a()}load(){let e=this._item;if(e!==null&&!this.shouldLoad)re(e.parent.doc,(t)=>{t.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(At(this.subdocs).map((e)=>e.guid))}transact(e,t=null){return re(this,e,t)}get(e,t=ge){let n=et(this.share,e,()=>{let s=new t;return s._integrate(this,null),s}),r=n.constructor;if(t!==ge&&r!==t)if(r===ge){let s=new t;s._map=n._map,n._map.forEach((o)=>{for(;o!==null;o=o.left)o.parent=s}),s._start=n._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=n._length,this.share.set(e,s),s._integrate(this,null),s}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=""){return this.get(e,Ur)}getText(e=""){return this.get(e,ot)}getMap(e=""){return this.get(e,dn)}getXmlElement(e=""){return this.get(e,ie)}getXmlFragment(e=""){return this.get(e,ze)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,At(this.subdocs).forEach((t)=>t.destroy());let e=this._item;if(e!==null){this._item=null;let t=e.content;t.doc=new _t({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,re(e.parent.doc,(n)=>{let r=t.doc;if(!e.deleted)n.subdocsAdded.add(r);n.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Yf{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return K(this.restDecoder)}readDsLen(){return K(this.restDecoder)}}class jf extends Yf{readLeftID(){return W(K(this.restDecoder),K(this.restDecoder))}readRightID(){return W(K(this.restDecoder),K(this.restDecoder))}readClient(){return K(this.restDecoder)}readInfo(){return Ln(this.restDecoder)}readString(){return Ht(this.restDecoder)}readParentInfo(){return K(this.restDecoder)===1}readTypeRef(){return K(this.restDecoder)}readLen(){return K(this.restDecoder)}readAny(){return kr(this.restDecoder)}readBuf(){return Qd(Ge(this.restDecoder))}readJSON(){return JSON.parse(Ht(this.restDecoder))}readKey(){return Ht(this.restDecoder)}}class Wf{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=K(this.restDecoder),this.dsCurrVal}readDsLen(){let e=K(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Ws extends Wf{constructor(e){super(e);this.keys=[],K(e),this.keyClockDecoder=new Rs(Ge(e)),this.clientDecoder=new Nr(Ge(e)),this.leftClockDecoder=new Rs(Ge(e)),this.rightClockDecoder=new Rs(Ge(e)),this.infoDecoder=new pi(Ge(e),Ln),this.stringDecoder=new Cl(Ge(e)),this.parentInfoDecoder=new pi(Ge(e),Ln),this.typeRefDecoder=new Nr(Ge(e)),this.lenDecoder=new Nr(Ge(e))}readLeftID(){return new Fn(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Fn(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return kr(this.restDecoder)}readBuf(){return Ge(this.restDecoder)}readJSON(){return kr(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];else{let t=this.stringDecoder.read();return this.keys.push(t),t}}}class Kf{constructor(){this.restEncoder=wr()}toUint8Array(){return dt(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){G(this.restEncoder,e)}writeDsLen(e){G(this.restEncoder,e)}}class qf extends Kf{writeLeftID(e){G(this.restEncoder,e.client),G(this.restEncoder,e.clock)}writeRightID(e){G(this.restEncoder,e.client),G(this.restEncoder,e.clock)}writeClient(e){G(this.restEncoder,e)}writeInfo(e){li(this.restEncoder,e)}writeString(e){vn(this.restEncoder,e)}writeParentInfo(e){G(this.restEncoder,e?1:0)}writeTypeRef(e){G(this.restEncoder,e)}writeLen(e){G(this.restEncoder,e)}writeAny(e){ln(this.restEncoder,e)}writeBuf(e){Xe(this.restEncoder,e)}writeJSON(e){vn(this.restEncoder,JSON.stringify(e))}writeKey(e){vn(this.restEncoder,e)}}class Xf{constructor(){this.restEncoder=wr(),this.dsCurrVal=0}toUint8Array(){return dt(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,G(this.restEncoder,t)}writeDsLen(e){if(e===0)ce();G(this.restEncoder,e-1),this.dsCurrVal+=e}}class Js extends Xf{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Is,this.clientEncoder=new Cr,this.leftClockEncoder=new Is,this.rightClockEncoder=new Is,this.infoEncoder=new ui(li),this.stringEncoder=new Al,this.parentInfoEncoder=new ui(li),this.typeRefEncoder=new Cr,this.lenEncoder=new Cr}toUint8Array(){let e=wr();return G(e,0),Xe(e,this.keyClockEncoder.toUint8Array()),Xe(e,this.clientEncoder.toUint8Array()),Xe(e,this.leftClockEncoder.toUint8Array()),Xe(e,this.rightClockEncoder.toUint8Array()),Xe(e,dt(this.infoEncoder)),Xe(e,this.stringEncoder.toUint8Array()),Xe(e,dt(this.parentInfoEncoder)),Xe(e,this.typeRefEncoder.toUint8Array()),Xe(e,this.lenEncoder.toUint8Array()),Os(e,dt(this.restEncoder)),dt(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){ln(this.restEncoder,e)}writeBuf(e){Xe(this.restEncoder,e)}writeJSON(e){ln(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);if(t===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e);else this.keyClockEncoder.write(t)}}var TS=(e,t,n,r)=>{r=nt(r,t[0].id.clock);let s=ht(t,r);G(e.restEncoder,t.length-s),e.writeClient(n),G(e.restEncoder,r);let o=t[s];o.write(e,r-o.id.clock);for(let i=s+1;i<t.length;i++)t[i].write(e,0)},Gf=(e,t,n)=>{let r=new Map;n.forEach((s,o)=>{if(me(t,o)>s)r.set(o,s)}),ji(t).forEach((s,o)=>{if(!n.has(o))r.set(o,0)}),G(e.restEncoder,r.size),At(r.entries()).sort((s,o)=>o[0]-s[0]).forEach(([s,o])=>{TS(e,t.clients.get(s),s,o)})},bS=(e,t)=>{let n=_e(),r=K(e.restDecoder);for(let s=0;s<r;s++){let o=K(e.restDecoder),i=Array(o),a=e.readClient(),l=K(e.restDecoder);n.set(a,{i:0,refs:i});for(let c=0;c<o;c++){let u=e.readInfo();switch(Cs&u){case 0:{let d=e.readLen();i[c]=new st(W(a,l),d),l+=d;break}case 10:{let d=K(e.restDecoder);i[c]=new ft(W(a,l),d),l+=d;break}default:{let d=(u&(ut|xe))===0,f=new Z(W(a,l),null,(u&xe)===xe?e.readLeftID():null,null,(u&ut)===ut?e.readRightID():null,d?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,d&&(u&Tr)===Tr?e.readString():null,Mh(e,u));i[c]=f,l+=f.length}}}}return n},SS=(e,t,n)=>{let r=[],s=At(n.keys()).sort((h,p)=>h-p);if(s.length===0)return null;let o=()=>{if(s.length===0)return null;let h=n.get(s[s.length-1]);while(h.refs.length===h.i)if(s.pop(),s.length>0)h=n.get(s[s.length-1]);else return null;return h},i=o();if(i===null)return null;let a=new lc,l=new Map,c=(h,p)=>{let m=l.get(h);if(m==null||m>p)l.set(h,p)},u=i.refs[i.i++],d=new Map,f=()=>{for(let h of r){let p=h.id.client,m=n.get(p);if(m)m.i--,a.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[];else a.clients.set(p,[h]);s=s.filter((g)=>g!==p)}r.length=0};while(!0){if(u.constructor!==ft){let p=et(d,u.id.client,()=>me(t,u.id.client))-u.id.clock;if(p<0)r.push(u),c(u.id.client,u.id.clock-1),f();else{let m=u.getMissing(e,t);if(m!==null){r.push(u);let g=n.get(m)||{refs:[],i:0};if(g.refs.length===g.i)c(m,me(t,m)),f();else{u=g.refs[g.i++];continue}}else if(p===0||p<u.length)u.integrate(e,p),d.set(u.id.client,u.id.clock+u.length)}}if(r.length>0)u=r.pop();else if(i!==null&&i.i<i.refs.length)u=i.refs[i.i++];else if(i=o(),i===null)break;else u=i.refs[i.i++]}if(a.clients.size>0){let h=new Js;return Gf(h,a,new Map),G(h.restEncoder,0),{missing:l,update:h.toUint8Array()}}return null},xS=(e,t)=>Gf(e,t.doc.store,t.beforeState),AS=(e,t,n,r=new Ws(e))=>re(t,(s)=>{s.local=!1;let o=!1,i=s.doc,a=i.store,l=bS(r,i),c=SS(s,a,l),u=a.pendingStructs;if(u){for(let[f,h]of u.missing)if(h<me(a,f)){o=!0;break}if(c){for(let[f,h]of c.missing){let p=u.missing.get(f);if(p==null||p>h)u.missing.set(f,h)}u.update=Bf([u.update,c.update])}}else a.pendingStructs=c;let d=Nf(r,s,a);if(a.pendingDs){let f=new Ws(_r(a.pendingDs));K(f.restDecoder);let h=Nf(f,s,a);if(d&&h)a.pendingDs=Bf([d,h]);else a.pendingDs=d||h}else a.pendingDs=d;if(o){let f=a.pendingStructs.update;a.pendingStructs=null,Qs(s.doc,f)}},n,!1);var Qs=(e,t,n,r=Ws)=>{let s=_r(t);AS(s,e,n,new r(s))},oc=(e,t,n)=>Qs(e,t,n,jf);class Jf{constructor(){this.l=[]}}var Of=()=>new Jf,If=(e,t)=>e.l.push(t),Mf=(e,t)=>{let n=e.l,r=n.length;if(e.l=n.filter((s)=>t!==s),r===e.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},Qf=(e,t,n)=>Ls(e.l,[t,n]);class Fn{constructor(e,t){this.client=e,this.clock=t}}var Br=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,W=(e,t)=>new Fn(e,t);var Vn=(e)=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw ce()},Hr=(e,t)=>{while(t!==null){if(t.parent===e)return!0;t=t.parent._item}return!1};class zn{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}}var Yn=(e)=>new zn(e.type==null?null:W(e.type.client,e.type.clock),e.tname??null,e.item==null?null:W(e.item.client,e.item.clock),e.assoc==null?0:e.assoc);class Zf{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}}var wS=(e,t,n=0)=>new Zf(e,t,n),Mi=(e,t,n)=>{let r=null,s=null;if(e._item===null)s=Vn(e);else r=W(e._item.id.client,e._item.id.clock);return new zn(r,s,t,n)},Vi=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Mi(e,null,n);t--}while(r!==null){if(!r.deleted&&r.countable){if(r.length>t)return Mi(e,W(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Mi(e,r.lastId,n);r=r.right}return Mi(e,null,n)};var CS=(e,t)=>{let n=Fr(e,t),r=t.clock-n.id.clock;return{item:n,diff:r}},ic=(e,t,n=!0)=>{let r=t.store,{item:s,type:o,tname:i,assoc:a}=e,l=null,c=0;if(s!==null){if(me(r,s.client)<=s.clock)return null;let u=n?nc(r,s):CS(r,s),d=u.item;if(!(d instanceof Z))return null;if(l=d.parent,l._item===null||!l._item.deleted){c=d.deleted||!d.countable?0:u.diff+(a>=0?0:1);let f=d.left;while(f!==null){if(!f.deleted&&f.countable)c+=f.length;f=f.left}}}else{if(i!==null)l=t.get(i);else if(o!==null){if(me(r,o.client)<=o.clock)return null;let{item:u}=n?nc(r,o):{item:Fr(r,o)};if(u instanceof Z&&u.content instanceof Me)l=u.content.type;else return null}else throw ce();if(a>=0)c=l._length;else c=0}return wS(l,c,e.assoc)},ac=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Br(e.item,t.item)&&Br(e.type,t.type)&&e.assoc===t.assoc;class Zs{constructor(e,t){this.ds=e,this.sv=t}}var zi=(e,t)=>new Zs(e,t),eh=zi($i(),new Map),Yi=(e)=>zi(yS(e.store),ji(e.store)),Bn=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!$n(t.ds,e.id),ec=(e,t)=>{let n=et(e.meta,ec,ct),r=e.doc.store;if(!n.has(t))t.sv.forEach((s,o)=>{if(s<me(r,o))Je(e,W(o,s))}),zt(e,t.ds,(s)=>{}),n.add(t)};class lc{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var ji=(e)=>{let t=new Map;return e.clients.forEach((n,r)=>{let s=n[n.length-1];t.set(r,s.id.clock+s.length)}),t},me=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},th=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==t.id.clock)throw ce()}n.push(t)},ht=(e,t)=>{let n=0,r=e.length-1,s=e[r],o=s.id.clock;if(o===t)return r;let i=Se(t/(o+s.length-1)*r);while(n<=r){if(s=e[i],o=s.id.clock,o<=t){if(t<o+s.length)return i;n=i+1}else r=i-1;i=Se((n+r)/2)}throw ce()},kS=(e,t)=>{let n=e.clients.get(t.client);return n[ht(n,t.clock)]},Fr=kS,tc=(e,t,n)=>{let r=ht(t,n),s=t[r];if(s.id.clock<n&&s instanceof Z)return t.splice(r+1,0,Hi(e,s,n-s.id.clock)),r+1;return r},Je=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[tc(e,n,t.clock)]},Rf=(e,t,n)=>{let r=t.clients.get(n.client),s=ht(r,n.clock),o=r[s];if(n.clock!==o.id.clock+o.length-1&&o.constructor!==st)r.splice(s+1,0,Hi(e,o,n.clock-o.id.clock+1));return o},_S=(e,t,n)=>{let r=e.clients.get(t.id.client);r[ht(r,t.id.clock)]=n},nh=(e,t,n,r,s)=>{if(r===0)return;let o=n+r,i=tc(e,t,n),a;do{if(a=t[i++],o<a.id.clock+a.length)tc(e,t,o);s(a)}while(i<t.length&&t[i].id.clock<o)};class rh{constructor(e,t,n){this.doc=e,this.deleteSet=new Hn,this.beforeState=ji(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var Df=(e,t)=>{if(t.deleteSet.clients.size===0&&!bd(t.afterState,(n,r)=>t.beforeState.get(r)!==n))return!1;return rc(t.deleteSet),xS(e,t),sc(e,t.deleteSet),!0},vf=(e,t,n)=>{let r=t._item;if(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)et(e.changed,t,ct).add(n)},vi=(e,t)=>{let n=e[t],r=e[t-1],s=t;for(;s>0;n=r,r=e[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor){if(r.mergeWith(n)){if(n instanceof Z&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n)n.parent._map.set(n.parentSub,r);continue}}break}let o=t-s;if(o)e.splice(t+1-o,o);return o},NS=(e,t,n)=>{for(let[r,s]of e.clients.entries()){let o=t.clients.get(r);for(let i=s.length-1;i>=0;i--){let a=s[i],l=a.clock+a.len;for(let c=ht(o,a.clock),u=o[c];c<o.length&&u.id.clock<l;u=o[++c]){let d=o[c];if(a.clock+a.len<=d.id.clock)break;if(d instanceof Z&&d.deleted&&!d.keep&&n(d))d.gc(t,!1)}}}},OS=(e,t)=>{e.clients.forEach((n,r)=>{let s=t.clients.get(r);for(let o=n.length-1;o>=0;o--){let i=n[o],a=tt(s.length-1,1+ht(s,i.clock+i.len-1));for(let l=a,c=s[l];l>0&&c.id.clock>=i.clock;c=s[l])l-=1+vi(s,l)}})};var sh=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,s=r.store,{deleteSet:o,_mergeStructs:i}=n;try{rc(o),n.afterState=ji(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let a=[];n.changed.forEach((l,c)=>a.push(()=>{if(c._item===null||!c._item.deleted)c._callObserver(n,l)})),a.push(()=>{n.changedParentTypes.forEach((l,c)=>{if(c._dEH.l.length>0&&(c._item===null||!c._item.deleted))a.push(()=>{l=l.filter((u)=>u.target._item===null||!u.target._item.deleted),l.forEach((u)=>{u.currentTarget=c,u._path=null}),l.sort((u,d)=>u.path.length-d.path.length),Qf(c._dEH,l,n)})}),a.push(()=>r.emit("afterTransaction",[n,r])),a.push(()=>{if(n._needFormattingCleanup)zS(n)})}),Ls(a,[])}finally{if(r.gc)NS(o,s,r.gcFilter);OS(o,s),n.afterState.forEach((u,d)=>{let f=n.beforeState.get(d)||0;if(f!==u){let h=s.clients.get(d),p=nt(ht(h,f),1);for(let m=h.length-1;m>=p;)m-=1+vi(h,m)}});for(let u=i.length-1;u>=0;u--){let{client:d,clock:f}=i[u].id,h=s.clients.get(d),p=ht(h,f);if(p+1<h.length){if(vi(h,p+1)>1)continue}if(p>0)vi(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID))wf(Pr,$s,"[yjs] ",Vs,zs,"Changed the client-id because another client seems to be using it."),r.clientID=zf();if(r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let u=new qf;if(Df(u,n))r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let u=new Js;if(Df(u,n))r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}let{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=n;if(a.size>0||c.size>0||l.size>0)a.forEach((u)=>{if(u.clientID=r.clientID,u.collectionid==null)u.collectionid=r.collectionid;r.subdocs.add(u)}),c.forEach((u)=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,n]),c.forEach((u)=>u.destroy());if(e.length<=t+1)r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e]);else sh(e,t+1)}}},re=(e,t,n=null,r=!0)=>{let s=e._transactionCleanups,o=!1,i=null;if(e._transaction===null){if(o=!0,e._transaction=new rh(e,n,r),s.push(e._transaction),s.length===1)e.emit("beforeAllTransactions",[e]);e.emit("beforeTransaction",[e._transaction,e])}try{i=t(e._transaction)}finally{if(o){let a=e._transaction===s[0];if(e._transaction=null,a)sh(s,0)}}return i};class oh{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}var Lf=(e,t,n)=>{zt(e,n.deletions,(r)=>{if(r instanceof Z&&t.scope.some((s)=>s===e.doc||Hr(s,r)))hc(r,!1)})},Pf=(e,t,n)=>{let r=null,{doc:s,scope:o}=e;re(s,(a)=>{while(t.length>0&&e.currStackItem===null){let l=s.store,c=t.pop(),u=new Set,d=[],f=!1;zt(a,c.insertions,(h)=>{if(h instanceof Z){if(h.redone!==null){let{item:p,diff:m}=nc(l,h.id);if(m>0)p=Je(a,W(p.id.client,p.id.clock+m));h=p}if(!h.deleted&&o.some((p)=>p===a.doc||Hr(p,h)))d.push(h)}}),zt(a,c.deletions,(h)=>{if(h instanceof Z&&o.some((p)=>p===a.doc||Hr(p,h))&&!$n(c.insertions,h.id))u.add(h)}),u.forEach((h)=>{f=Ih(a,h,u,c.insertions,e.ignoreRemoteMapChanges,e)!==null||f});for(let h=d.length-1;h>=0;h--){let p=d[h];if(e.deleteFilter(p))p.delete(a),f=!0}e.currStackItem=f?c:null}a.changed.forEach((l,c)=>{if(l.has(null)&&c._searchMarker)c._searchMarker.length=0}),r=a},e);let i=e.currStackItem;if(i!=null){let a=r.changedParentTypes;e.emit("stack-item-popped",[{stackItem:i,type:n,changedParentTypes:a,origin:e},e]),e.currStackItem=null}return i};class eo extends ri{constructor(e,{captureTimeout:t=500,captureTransaction:n=(a)=>!0,deleteFilter:r=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:i=Ft(e)?e[0].doc:e instanceof _t?e:e.doc}={}){super();this.scope=[],this.doc=i,this.addToScope(e),this.deleteFilter=r,s.add(this),this.trackedOrigins=s,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=t,this.afterTransactionHandler=(a)=>{if(!this.captureTransaction(a)||!this.scope.some((m)=>a.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(a.origin)&&(!a.origin||!this.trackedOrigins.has(a.origin.constructor)))return;let l=this.undoing,c=this.redoing,u=l?this.redoStack:this.undoStack;if(l)this.stopCapturing();else if(!c)this.clear(!1,!0);let d=new Hn;a.afterState.forEach((m,g)=>{let E=a.beforeState.get(g)||0,x=m-E;if(x>0)js(d,g,E,x)});let f=$t(),h=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&u.length>0&&!l&&!c){let m=u[u.length-1];m.deletions=Zl([m.deletions,a.deleteSet]),m.insertions=Zl([m.insertions,d])}else u.push(new oh(a.deleteSet,d)),h=!0;if(!l&&!c)this.lastChange=f;zt(a,a.deleteSet,(m)=>{if(m instanceof Z&&this.scope.some((g)=>g===a.doc||Hr(g,m)))hc(m,!0)});let p=[{stackItem:u[u.length-1],origin:a.origin,type:l?"redo":"undo",changedParentTypes:a.changedParentTypes},this];if(h)this.emit("stack-item-added",p);else this.emit("stack-item-updated",p)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(e){let t=new Set(this.scope);e=Ft(e)?e:[e],e.forEach((n)=>{if(!t.has(n)){if(t.add(n),n instanceof ge?n.doc!==this.doc:n!==this.doc)Jl("[yjs#509] Not same Y.Doc");this.scope.push(n)}})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){if(e&&this.canUndo()||t&&this.canRedo())this.doc.transact((n)=>{if(e)this.undoStack.forEach((r)=>Lf(n,this,r)),this.undoStack=[];if(t)this.redoStack.forEach((r)=>Lf(n,this,r)),this.redoStack=[];this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Pf(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Pf(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*IS(e){let t=K(e.restDecoder);for(let n=0;n<t;n++){let r=K(e.restDecoder),s=e.readClient(),o=K(e.restDecoder);for(let i=0;i<r;i++){let a=e.readInfo();if(a===10){let l=K(e.restDecoder);yield new ft(W(s,o),l),o+=l}else if((Cs&a)!==0){let l=(a&(ut|xe))===0,c=new Z(W(s,o),null,(a&xe)===xe?e.readLeftID():null,null,(a&ut)===ut?e.readRightID():null,l?e.readParentInfo()?e.readString():e.readLeftID():null,l&&(a&Tr)===Tr?e.readString():null,Mh(e,a));yield c,o+=c.length}else{let l=e.readLen();yield new st(W(s,o),l),o+=l}}}}class ih{constructor(e,t){this.gen=IS(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===ft);return this.curr}}class ah{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}var MS=(e,t)=>{if(e.constructor===st){let{client:n,clock:r}=e.id;return new st(W(n,r+t),e.length-t)}else if(e.constructor===ft){let{client:n,clock:r}=e.id;return new ft(W(n,r+t),e.length-t)}else{let n=e,{client:r,clock:s}=n.id;return new Z(W(r,s+t),null,W(r,s+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Bf=(e,t=Ws,n=Js)=>{if(e.length===1)return e[0];let r=e.map((u)=>new t(_r(u))),s=r.map((u)=>new ih(u,!0)),o=null,i=new n,a=new ah(i);while(!0){if(s=s.filter((f)=>f.curr!==null),s.sort((f,h)=>{if(f.curr.id.client===h.curr.id.client){let p=f.curr.id.clock-h.curr.id.clock;if(p===0)return f.curr.constructor===h.curr.constructor?0:f.curr.constructor===ft?1:-1;else return p}else return h.curr.id.client-f.curr.id.client}),s.length===0)break;let u=s[0],d=u.curr.id.client;if(o!==null){let f=u.curr,h=!1;while(f!==null&&f.id.clock+f.length<=o.struct.id.clock+o.struct.length&&f.id.client>=o.struct.id.client)f=u.next(),h=!0;if(f===null||f.id.client!==d||h&&f.id.clock>o.struct.id.clock+o.struct.length)continue;if(d!==o.struct.id.client)Ys(a,o.struct,o.offset),o={struct:f,offset:0},u.next();else if(o.struct.id.clock+o.struct.length<f.id.clock)if(o.struct.constructor===ft)o.struct.length=f.id.clock+f.length-o.struct.id.clock;else{Ys(a,o.struct,o.offset);let p=f.id.clock-o.struct.id.clock-o.struct.length;o={struct:new ft(W(d,o.struct.id.clock+o.struct.length),p),offset:0}}else{let p=o.struct.id.clock+o.struct.length-f.id.clock;if(p>0)if(o.struct.constructor===ft)o.struct.length-=p;else f=MS(f,p);if(!o.struct.mergeWith(f))Ys(a,o.struct,o.offset),o={struct:f,offset:0},u.next()}}else o={struct:u.curr,offset:0},u.next();for(let f=u.curr;f!==null&&f.id.client===d&&f.id.clock===o.struct.id.clock+o.struct.length&&f.constructor!==ft;f=u.next())Ys(a,o.struct,o.offset),o={struct:f,offset:0}}if(o!==null)Ys(a,o.struct,o.offset),o=null;RS(a);let l=r.map((u)=>ES(u)),c=Zl(l);return sc(i,c),i.toUint8Array()};var lh=(e)=>{if(e.written>0)e.clientStructs.push({written:e.written,restEncoder:dt(e.encoder.restEncoder)}),e.encoder.restEncoder=wr(),e.written=0},Ys=(e,t,n)=>{if(e.written>0&&e.currClient!==t.id.client)lh(e);if(e.written===0)e.currClient=t.id.client,e.encoder.writeClient(t.id.client),G(e.encoder.restEncoder,t.id.clock+n);t.write(e.encoder,n),e.written++},RS=(e)=>{lh(e);let t=e.encoder.restEncoder;G(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];G(t,r.written),Os(t,r.restEncoder)}};var Ff="You must not compute changes after the event-handler fired.";class to{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=DS(this.currentTarget,this.target))}deletes(e){return $n(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw rt(Ff);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach((r)=>{if(r!==null){let s=t._map.get(r),o,i;if(this.adds(s)){let a=s.left;while(a!==null&&this.adds(a))a=a.left;if(this.deletes(s))if(a!==null&&this.deletes(a))o="delete",i=ti(a.content.getContent());else return;else if(a!==null&&this.deletes(a))o="update",i=ti(a.content.getContent());else o="add",i=void 0}else if(this.deletes(s))o="delete",i=ti(s.content.getContent());else return;e.set(r,{action:o,oldValue:i})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw rt(Ff);let t=this.target,n=ct(),r=ct(),s=[];if(e={added:n,deleted:r,delta:s,keys:this.keys},this.transaction.changed.get(t).has(null)){let i=null,a=()=>{if(i)s.push(i)};for(let l=t._start;l!==null;l=l.right)if(l.deleted){if(this.deletes(l)&&!this.adds(l)){if(i===null||i.delete===void 0)a(),i={delete:0};i.delete+=l.length,r.add(l)}}else if(this.adds(l)){if(i===null||i.insert===void 0)a(),i={insert:[]};i.insert=i.insert.concat(l.content.getContent()),n.add(l)}else{if(i===null||i.retain===void 0)a(),i={retain:0};i.retain+=l.length}if(i!==null&&i.retain===void 0)a()}this._changes=e}return e}}var DS=(e,t)=>{let n=[];while(t._item!==null&&t!==e){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let r=0,s=t._item.parent._start;while(s!==t._item&&s!==null){if(!s.deleted&&s.countable)r+=s.length;s=s.right}n.unshift(r)}t=t._item.parent}return n},Be=()=>{Jl("Invalid access: Add Yjs type to a document before reading data.")},ch=80,cc=0;class uh{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=cc++}}var vS=(e)=>{e.timestamp=cc++},dh=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=cc++},LS=(e,t,n)=>{if(e.length>=ch){let r=e.reduce((s,o)=>s.timestamp<o.timestamp?s:o);return dh(r,t,n),r}else{let r=new uh(t,n);return e.push(r),r}},Wi=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((o,i)=>Dn(t-o.index)<Dn(t-i.index)?o:i),r=e._start,s=0;if(n!==null)r=n.p,s=n.index,vS(n);while(r.right!==null&&s<t){if(!r.deleted&&r.countable){if(t<s+r.length)break;s+=r.length}r=r.right}while(r.left!==null&&s>t)if(r=r.left,!r.deleted&&r.countable)s-=r.length;while(r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock)if(r=r.left,!r.deleted&&r.countable)s-=r.length;if(n!==null&&Dn(n.index-s)<r.parent.length/ch)return dh(n,r,s),n;else return LS(e._searchMarker,r,s)},Ks=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let s=e[r];if(n>0){let o=s.p;o.marker=!1;while(o&&(o.deleted||!o.countable))if(o=o.left,o&&!o.deleted&&o.countable)s.index-=o.length;if(o===null||o.marker===!0){e.splice(r,1);continue}s.p=o,o.marker=!0}if(t<s.index||n>0&&t===s.index)s.index=nt(t,s.index+n)}};var Ki=(e,t,n)=>{let r=e,s=t.changedParentTypes;while(!0){if(et(s,e,()=>[]).push(n),e._item===null)break;e=e._item.parent}Qf(r._eH,n,t)};class ge{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Of(),this._dEH=Of(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Ve()}clone(){throw Ve()}_write(e){}get _first(){let e=this._start;while(e!==null&&e.deleted)e=e.right;return e}_callObserver(e,t){if(!e.local&&this._searchMarker)this._searchMarker.length=0}observe(e){If(this._eH,e)}observeDeep(e){If(this._dEH,e)}unobserve(e){Mf(this._eH,e)}unobserveDeep(e){Mf(this._dEH,e)}toJSON(){}}var fh=(e,t,n)=>{if(e.doc??Be(),t<0)t=e._length+t;if(n<0)n=e._length+n;let r=n-t,s=[],o=e._start;while(o!==null&&r>0){if(o.countable&&!o.deleted){let i=o.content.getContent();if(i.length<=t)t-=i.length;else{for(let a=t;a<i.length&&r>0;a++)s.push(i[a]),r--;t=0}}o=o.right}return s},hh=(e)=>{e.doc??Be();let t=[],n=e._start;while(n!==null){if(n.countable&&!n.deleted){let r=n.content.getContent();for(let s=0;s<r.length;s++)t.push(r[s])}n=n.right}return t},uc=(e,t)=>{let n=[],r=e._start;while(r!==null){if(r.countable&&Bn(r,t)){let s=r.content.getContent();for(let o=0;o<s.length;o++)n.push(s[o])}r=r.right}return n},qs=(e,t)=>{let n=0,r=e._start;e.doc??Be();while(r!==null){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let o=0;o<s.length;o++)t(s[o],n++,e)}r=r.right}},ph=(e,t)=>{let n=[];return qs(e,(r,s)=>{n.push(t(r,s,e))}),n},PS=(e)=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){while(t!==null&&t.deleted)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let s=n[r++];if(n.length<=r)n=null;return{done:!1,value:s}}}},mh=(e,t)=>{e.doc??Be();let n=Wi(e,t),r=e._start;if(n!==null)r=n.p,t-=n.index;for(;r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},Pi=(e,t,n,r)=>{let s=n,o=e.doc,{clientID:i,store:a}=o,l=n===null?t._start:n.right,c=[],u=()=>{if(c.length>0)s=new Z(W(i,me(a,i)),s,s&&s.lastId,l,l&&l.id,t,null,new Un(c)),s.integrate(e,0),c=[]};r.forEach((d)=>{if(d===null)c.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(d);break;default:switch(u(),d.constructor){case Uint8Array:case ArrayBuffer:s=new Z(W(i,me(a,i)),s,s&&s.lastId,l,l&&l.id,t,null,new no(new Uint8Array(d))),s.integrate(e,0);break;case _t:s=new Z(W(i,me(a,i)),s,s&&s.lastId,l,l&&l.id,t,null,new ro(d)),s.integrate(e,0);break;default:if(d instanceof ge)s=new Z(W(i,me(a,i)),s,s&&s.lastId,l,l&&l.id,t,null,new Me(d)),s.integrate(e,0);else throw Error("Unexpected content type in insert operation")}}}),u()},gh=()=>rt("Length exceeded!"),yh=(e,t,n,r)=>{if(n>t._length)throw gh();if(n===0){if(t._searchMarker)Ks(t._searchMarker,n,r.length);return Pi(e,t,null,r)}let s=n,o=Wi(t,n),i=t._start;if(o!==null){if(i=o.p,n-=o.index,n===0)i=i.prev,n+=i&&i.countable&&!i.deleted?i.length:0}for(;i!==null;i=i.right)if(!i.deleted&&i.countable){if(n<=i.length){if(n<i.length)Je(e,W(i.id.client,i.id.clock+n));break}n-=i.length}if(t._searchMarker)Ks(t._searchMarker,s,r.length);return Pi(e,t,i,r)},BS=(e,t,n)=>{let s=(t._searchMarker||[]).reduce((o,i)=>i.index>o.index?i:o,{index:0,p:t._start}).p;if(s)while(s.right)s=s.right;return Pi(e,t,s,n)},Eh=(e,t,n,r)=>{if(r===0)return;let s=n,o=r,i=Wi(t,n),a=t._start;if(i!==null)a=i.p,n-=i.index;for(;a!==null&&n>0;a=a.right)if(!a.deleted&&a.countable){if(n<a.length)Je(e,W(a.id.client,a.id.clock+n));n-=a.length}while(r>0&&a!==null){if(!a.deleted){if(r<a.length)Je(e,W(a.id.client,a.id.clock+r));a.delete(e),r-=a.length}a=a.right}if(r>0)throw gh();if(t._searchMarker)Ks(t._searchMarker,s,-o+r)},Bi=(e,t,n)=>{let r=t._map.get(n);if(r!==void 0)r.delete(e)},dc=(e,t,n,r)=>{let s=t._map.get(n)||null,o=e.doc,i=o.clientID,a;if(r==null)a=new Un([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new Un([r]);break;case Uint8Array:a=new no(r);break;case _t:a=new ro(r);break;default:if(r instanceof ge)a=new Me(r);else throw Error("Unexpected content type")}new Z(W(i,me(o.store,i)),s,s&&s.lastId,null,null,t,n,a).integrate(e,0)},fc=(e,t)=>{e.doc??Be();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Th=(e)=>{let t={};return e.doc??Be(),e._map.forEach((n,r)=>{if(!n.deleted)t[r]=n.content.getContent()[n.length-1]}),t},bh=(e,t)=>{e.doc??Be();let n=e._map.get(t);return n!==void 0&&!n.deleted};var FS=(e,t)=>{let n={};return e._map.forEach((r,s)=>{let o=r;while(o!==null&&(!t.sv.has(o.id.client)||o.id.clock>=(t.sv.get(o.id.client)||0)))o=o.left;if(o!==null&&Bn(o,t))n[s]=o.content.getContent()[o.length-1]}),n},Ri=(e)=>(e.doc??Be(),_f(e._map.entries(),(t)=>!t[1].deleted));class Sh extends to{}class Ur extends ge{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(e){let t=new Ur;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ur}clone(){let e=new Ur;return e.insert(0,this.toArray().map((t)=>t instanceof ge?t.clone():t)),e}get length(){return this.doc??Be(),this._length}_callObserver(e,t){super._callObserver(e,t),Ki(this,e,new Sh(this,e))}insert(e,t){if(this.doc!==null)re(this.doc,(n)=>{yh(n,this,e,t)});else this._prelimContent.splice(e,0,...t)}push(e){if(this.doc!==null)re(this.doc,(t)=>{BS(t,this,e)});else this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){if(this.doc!==null)re(this.doc,(n)=>{Eh(n,this,e,t)});else this._prelimContent.splice(e,t)}get(e){return mh(this,e)}toArray(){return hh(this)}slice(e=0,t=this.length){return fh(this,e,t)}toJSON(){return this.map((e)=>e instanceof ge?e.toJSON():e)}map(e){return ph(this,e)}forEach(e){qs(this,e)}[Symbol.iterator](){return PS(this)}_write(e){e.writeTypeRef(ix)}}var US=(e)=>new Ur;class xh extends to{constructor(e,t,n){super(e,t);this.keysChanged=n}}class dn extends ge{constructor(e){super();if(this._prelimContent=null,e===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((n,r)=>{this.set(r,n)}),this._prelimContent=null}_copy(){return new dn}clone(){let e=new dn;return this.forEach((t,n)=>{e.set(n,t instanceof ge?t.clone():t)}),e}_callObserver(e,t){Ki(this,e,new xh(this,e,t))}toJSON(){this.doc??Be();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof ge?r.toJSON():r}}),e}get size(){return[...Ri(this)].length}keys(){return Ii(Ri(this),(e)=>e[0])}values(){return Ii(Ri(this),(e)=>e[1].content.getContent()[e[1].length-1])}entries(){return Ii(Ri(this),(e)=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Be(),this._map.forEach((t,n)=>{if(!t.deleted)e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){if(this.doc!==null)re(this.doc,(t)=>{Bi(t,this,e)});else this._prelimContent.delete(e)}set(e,t){if(this.doc!==null)re(this.doc,(n)=>{dc(n,this,e,t)});else this._prelimContent.set(e,t);return t}get(e){return fc(this,e)}has(e){return bh(this,e)}clear(){if(this.doc!==null)re(this.doc,(e)=>{this.forEach(function(t,n,r){Bi(e,r,n)})});else this._prelimContent.clear()}_write(e){e.writeTypeRef(ax)}}var HS=(e)=>new dn,un=(e,t)=>e===t||typeof e==="object"&&typeof t==="object"&&e&&t&&Rl(e,t);class Fi{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){if(this.right===null)ce();switch(this.right.content.constructor){case ye:if(!this.right.deleted)$r(this.currentAttributes,this.right.content);break;default:if(!this.right.deleted)this.index+=this.right.length;break}this.left=this.right,this.right=this.right.right}}var Uf=(e,t,n)=>{while(t.right!==null&&n>0){switch(t.right.content.constructor){case ye:if(!t.right.deleted)$r(t.currentAttributes,t.right.content);break;default:if(!t.right.deleted){if(n<t.right.length)Je(e,W(t.right.id.client,t.right.id.clock+n));t.index+=t.right.length,n-=t.right.length}break}t.left=t.right,t.right=t.right.right}return t},Di=(e,t,n,r)=>{let s=new Map,o=r?Wi(t,n):null;if(o){let i=new Fi(o.p.left,o.p,o.index,s);return Uf(e,i,n-o.index)}else{let i=new Fi(null,t._start,0,s);return Uf(e,i,n)}},Ah=(e,t,n,r)=>{while(n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===ye&&un(r.get(n.right.content.key),n.right.content.value))){if(!n.right.deleted)r.delete(n.right.content.key);n.forward()}let s=e.doc,o=s.clientID;r.forEach((i,a)=>{let{left:l,right:c}=n,u=new Z(W(o,me(s.store,o)),l,l&&l.lastId,c,c&&c.id,t,null,new ye(a,i));u.integrate(e,0),n.right=u,n.forward()})},$r=(e,t)=>{let{key:n,value:r}=t;if(r===null)e.delete(n);else e.set(n,r)},wh=(e,t)=>{while(!0){if(e.right===null)break;else if(e.right.deleted||e.right.content.constructor===ye&&un(t[e.right.content.key]??null,e.right.content.value));else break;e.forward()}},Ch=(e,t,n,r)=>{let s=e.doc,o=s.clientID,i=new Map;for(let a in r){let l=r[a],c=n.currentAttributes.get(a)??null;if(!un(c,l)){i.set(a,c);let{left:u,right:d}=n;n.right=new Z(W(o,me(s.store,o)),u,u&&u.lastId,d,d&&d.id,t,null,new ye(a,l)),n.right.integrate(e,0),n.forward()}}return i},Ql=(e,t,n,r,s)=>{n.currentAttributes.forEach((f,h)=>{if(s[h]===void 0)s[h]=null});let o=e.doc,i=o.clientID;wh(n,s);let a=Ch(e,t,n,s),l=r.constructor===String?new pt(r):r instanceof ge?new Me(r):new jn(r),{left:c,right:u,index:d}=n;if(t._searchMarker)Ks(t._searchMarker,n.index,l.getLength());u=new Z(W(i,me(o.store,i)),c,c&&c.lastId,u,u&&u.id,t,null,l),u.integrate(e,0),n.right=u,n.index=d,n.forward(),Ah(e,t,n,a)},Hf=(e,t,n,r,s)=>{let o=e.doc,i=o.clientID;wh(n,s);let a=Ch(e,t,n,s);e:while(n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===ye))){if(!n.right.deleted)switch(n.right.content.constructor){case ye:{let{key:l,value:c}=n.right.content,u=s[l];if(u!==void 0){if(un(u,c))a.delete(l);else{if(r===0)break e;a.set(l,c)}n.right.delete(e)}else n.currentAttributes.set(l,c);break}default:if(r<n.right.length)Je(e,W(n.right.id.client,n.right.id.clock+r));r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
|
4
|
+
`;n.right=new Z(W(i,me(o.store,i)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new pt(l)),n.right.integrate(e,0),n.forward()}Ah(e,t,n,a)},kh=(e,t,n,r,s)=>{let o=t,i=_e();while(o&&(!o.countable||o.deleted)){if(!o.deleted&&o.content.constructor===ye){let c=o.content;i.set(c.key,c)}o=o.right}let a=0,l=!1;while(t!==o){if(n===t)l=!0;if(!t.deleted){let c=t.content;switch(c.constructor){case ye:{let{key:u,value:d}=c,f=r.get(u)??null;if(i.get(u)!==c||f===d){if(t.delete(e),a++,!l&&(s.get(u)??null)===d&&f!==d)if(f===null)s.delete(u);else s.set(u,f)}if(!l&&!t.deleted)$r(s,c);break}}}t=t.right}return a},$S=(e,t)=>{while(t&&t.right&&(t.right.deleted||!t.right.countable))t=t.right;let n=new Set;while(t&&(t.deleted||!t.countable)){if(!t.deleted&&t.content.constructor===ye){let r=t.content.key;if(n.has(r))t.delete(e);else n.add(r)}t=t.left}},VS=(e)=>{let t=0;return re(e.doc,(n)=>{let{_start:r,_start:s}=e,o=_e(),i=Zo(o);while(s){if(s.deleted===!1)switch(s.content.constructor){case ye:$r(i,s.content);break;default:t+=kh(n,r,s,o,i),o=Zo(i),r=s;break}s=s.right}}),t},zS=(e)=>{let t=new Set,n=e.doc;for(let[r,s]of e.afterState.entries()){let o=e.beforeState.get(r)||0;if(s===o)continue;nh(e,n.store.clients.get(r),o,s,(i)=>{if(!i.deleted&&i.content.constructor===ye&&i.constructor!==st)t.add(i.parent)})}re(n,(r)=>{zt(e,e.deleteSet,(s)=>{if(s instanceof st||!s.parent._hasFormatting||t.has(s.parent))return;let o=s.parent;if(s.content.constructor===ye)t.add(o);else $S(r,s)});for(let s of t)VS(s)})},$f=(e,t,n)=>{let r=n,s=Zo(t.currentAttributes),o=t.right;while(n>0&&t.right!==null){if(t.right.deleted===!1)switch(t.right.content.constructor){case Me:case jn:case pt:if(n<t.right.length)Je(e,W(t.right.id.client,t.right.id.clock+n));n-=t.right.length,t.right.delete(e);break}t.forward()}if(o)kh(e,o,t.right,s,t.currentAttributes);let i=(t.left||t.right).parent;if(i._searchMarker)Ks(i._searchMarker,t.index,-r+n);return t};class _h extends to{constructor(e,t,n){super(e,t);this.childListChanged=!1,this.keysChanged=new Set,n.forEach((r)=>{if(r===null)this.childListChanged=!0;else this.keysChanged.add(r)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];re(e,(n)=>{let r=new Map,s=new Map,o=this.target._start,i=null,a={},l="",c=0,u=0,d=()=>{if(i!==null){let f=null;switch(i){case"delete":if(u>0)f={delete:u};u=0;break;case"insert":if(typeof l==="object"||l.length>0){if(f={insert:l},r.size>0)f.attributes={},r.forEach((h,p)=>{if(h!==null)f.attributes[p]=h})}l="";break;case"retain":if(c>0){if(f={retain:c},!Wd(a))f.attributes=Yd({},a)}c=0;break}if(f)t.push(f);i=null}};while(o!==null){switch(o.content.constructor){case Me:case jn:if(this.adds(o)){if(!this.deletes(o))d(),i="insert",l=o.content.getContent()[0],d()}else if(this.deletes(o)){if(i!=="delete")d(),i="delete";u+=1}else if(!o.deleted){if(i!=="retain")d(),i="retain";c+=1}break;case pt:if(this.adds(o)){if(!this.deletes(o)){if(i!=="insert")d(),i="insert";l+=o.content.str}}else if(this.deletes(o)){if(i!=="delete")d(),i="delete";u+=o.length}else if(!o.deleted){if(i!=="retain")d(),i="retain";c+=o.length}break;case ye:{let{key:f,value:h}=o.content;if(this.adds(o)){if(!this.deletes(o)){let p=r.get(f)??null;if(!un(p,h)){if(i==="retain")d();if(un(h,s.get(f)??null))delete a[f];else a[f]=h}else if(h!==null)o.delete(n)}}else if(this.deletes(o)){s.set(f,h);let p=r.get(f)??null;if(!un(p,h)){if(i==="retain")d();a[f]=p}}else if(!o.deleted){s.set(f,h);let p=a[f];if(p!==void 0){if(!un(p,h)){if(i==="retain")d();if(h===null)delete a[f];else a[f]=h}else if(p!==null)o.delete(n)}}if(!o.deleted){if(i==="insert")d();$r(r,o.content)}break}}o=o.right}d();while(t.length>0){let f=t[t.length-1];if(f.retain!==void 0&&f.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}}class ot extends ge{constructor(e){super();this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Be(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach((n)=>n())}catch(n){console.error(n)}this._pending=null}_copy(){return new ot}clone(){let e=new ot;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);let n=new _h(this,e,t);if(Ki(this,e,n),!e.local&&this._hasFormatting)e._needFormattingCleanup=!0}toString(){this.doc??Be();let e="",t=this._start;while(t!==null){if(!t.deleted&&t.countable&&t.content.constructor===pt)e+=t.content.str;t=t.right}return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){if(this.doc!==null)re(this.doc,(n)=>{let r=new Fi(null,this._start,0,new Map);for(let s=0;s<e.length;s++){let o=e[s];if(o.insert!==void 0){let i=!t&&typeof o.insert==="string"&&s===e.length-1&&r.right===null&&o.insert.slice(-1)===`
|
|
5
|
+
`?o.insert.slice(0,-1):o.insert;if(typeof i!=="string"||i.length>0)Ql(n,this,r,i,o.attributes||{})}else if(o.retain!==void 0)Hf(n,this,r,o.retain,o.attributes||{});else if(o.delete!==void 0)$f(n,r,o.delete)}});else this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,n){this.doc??Be();let r=[],s=new Map,o=this.doc,i="",a=this._start;function l(){if(i.length>0){let u={},d=!1;s.forEach((h,p)=>{d=!0,u[p]=h});let f={insert:i};if(d)f.attributes=u;r.push(f),i=""}}let c=()=>{while(a!==null){if(Bn(a,e)||t!==void 0&&Bn(a,t))switch(a.content.constructor){case pt:{let u=s.get("ychange");if(e!==void 0&&!Bn(a,e)){if(u===void 0||u.user!==a.id.client||u.type!=="removed")l(),s.set("ychange",n?n("removed",a.id):{type:"removed"})}else if(t!==void 0&&!Bn(a,t)){if(u===void 0||u.user!==a.id.client||u.type!=="added")l(),s.set("ychange",n?n("added",a.id):{type:"added"})}else if(u!==void 0)l(),s.delete("ychange");i+=a.content.str;break}case Me:case jn:{l();let u={insert:a.content.getContent()[0]};if(s.size>0){let d={};u.attributes=d,s.forEach((f,h)=>{d[h]=f})}r.push(u);break}case ye:if(Bn(a,e))l(),$r(s,a.content);break}a=a.right}l()};if(e||t)re(o,(u)=>{if(e)ec(u,e);if(t)ec(u,t);c()},"cleanup");else c();return r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;if(r!==null)re(r,(s)=>{let o=Di(s,this,e,!n);if(!n)n={},o.currentAttributes.forEach((i,a)=>{n[a]=i});Ql(s,this,o,t,n)});else this._pending.push(()=>this.insert(e,t,n))}insertEmbed(e,t,n){let r=this.doc;if(r!==null)re(r,(s)=>{let o=Di(s,this,e,!n);Ql(s,this,o,t,n||{})});else this._pending.push(()=>this.insertEmbed(e,t,n||{}))}delete(e,t){if(t===0)return;let n=this.doc;if(n!==null)re(n,(r)=>{$f(r,Di(r,this,e,!0),t)});else this._pending.push(()=>this.delete(e,t))}format(e,t,n){if(t===0)return;let r=this.doc;if(r!==null)re(r,(s)=>{let o=Di(s,this,e,!1);if(o.right===null)return;Hf(s,this,o,t,n)});else this._pending.push(()=>this.format(e,t,n))}removeAttribute(e){if(this.doc!==null)re(this.doc,(t)=>{Bi(t,this,e)});else this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){if(this.doc!==null)re(this.doc,(n)=>{dc(n,this,e,t)});else this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return fc(this,e)}getAttributes(){return Th(this)}_write(e){e.writeTypeRef(lx)}}var YS=(e)=>new ot;class Li{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Be()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===ie||t.constructor===ze)&&t._start!==null)e=t._start;else while(e!==null){let n=e.next;if(n!==null){e=n;break}else if(e.parent===this._root)e=null;else e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));if(this._firstCall=!1,e===null)return{value:void 0,done:!0};return this._currentNode=e,{value:e.content.type,done:!1}}}class ze extends ge{constructor(){super();this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ze}clone(){let e=new ze;return e.insert(0,this.toArray().map((t)=>t instanceof ge?t.clone():t)),e}get length(){return this.doc??Be(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Li(this,e)}querySelector(e){e=e.toUpperCase();let n=new Li(this,(r)=>r.nodeName&&r.nodeName.toUpperCase()===e).next();if(n.done)return null;else return n.value}querySelectorAll(e){return e=e.toUpperCase(),At(new Li(this,(t)=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Ki(this,e,new Nh(this,t,e))}toString(){return ph(this,(e)=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();if(n!==void 0)n._createAssociation(r,this);return qs(this,(s)=>{r.insertBefore(s.toDOM(e,t,n),null)}),r}insert(e,t){if(this.doc!==null)re(this.doc,(n)=>{yh(n,this,e,t)});else this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)re(this.doc,(n)=>{let r=e&&e instanceof ge?e._item:e;Pi(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex((s)=>s===e)+1;if(r===0&&e!==null)throw rt("Reference item not found");n.splice(r,0,...t)}}delete(e,t=1){if(this.doc!==null)re(this.doc,(n)=>{Eh(n,this,e,t)});else this._prelimContent.splice(e,t)}toArray(){return hh(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return mh(this,e)}slice(e=0,t=this.length){return fh(this,e,t)}forEach(e){qs(this,e)}_write(e){e.writeTypeRef(ux)}}var jS=(e)=>new ze;class ie extends ze{constructor(e="UNDEFINED"){super();this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((n,r)=>{this.setAttribute(r,n)}),this._prelimAttrs=null}_copy(){return new ie(this.nodeName)}clone(){let e=new ie(this.nodeName),t=this.getAttributes();return jd(t,(n,r)=>{e.setAttribute(r,n)}),e.insert(0,this.toArray().map((n)=>n instanceof ge?n.clone():n)),e}toString(){let e=this.getAttributes(),t=[],n=[];for(let i in e)n.push(i);n.sort();let r=n.length;for(let i=0;i<r;i++){let a=n[i];t.push(a+'="'+e[a]+'"')}let s=this.nodeName.toLocaleLowerCase(),o=t.length>0?" "+t.join(" "):"";return`<${s}${o}>${super.toString()}</${s}>`}removeAttribute(e){if(this.doc!==null)re(this.doc,(t)=>{Bi(t,this,e)});else this._prelimAttrs.delete(e)}setAttribute(e,t){if(this.doc!==null)re(this.doc,(n)=>{dc(n,this,e,t)});else this._prelimAttrs.set(e,t)}getAttribute(e){return fc(this,e)}hasAttribute(e){return bh(this,e)}getAttributes(e){return e?FS(this,e):Th(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),s=this.getAttributes();for(let o in s){let i=s[o];if(typeof i==="string")r.setAttribute(o,i)}if(qs(this,(o)=>{r.appendChild(o.toDOM(e,t,n))}),n!==void 0)n._createAssociation(r,this);return r}_write(e){e.writeTypeRef(cx),e.writeKey(this.nodeName)}}var WS=(e)=>new ie(e.readKey());class Nh extends to{constructor(e,t,n){super(e,n);this.childListChanged=!1,this.attributesChanged=new Set,t.forEach((r)=>{if(r===null)this.childListChanged=!0;else this.attributesChanged.add(r)})}}class Yt extends dn{constructor(e){super();this.hookName=e}_copy(){return new Yt(this.hookName)}clone(){let e=new Yt(this.hookName);return this.forEach((t,n)=>{e.set(n,t)}),e}toDOM(e=document,t={},n){let r=t[this.hookName],s;if(r!==void 0)s=r.createDom(this);else s=document.createElement(this.hookName);if(s.setAttribute("data-yjs-hook",this.hookName),n!==void 0)n._createAssociation(s,this);return s}_write(e){e.writeTypeRef(dx),e.writeKey(this.hookName)}}var KS=(e)=>new Yt(e.readKey());class Oe extends ot{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Oe}clone(){let e=new Oe;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());if(n!==void 0)n._createAssociation(r,this);return r}toString(){return this.toDelta().map((e)=>{let t=[];for(let r in e.attributes){let s=[];for(let o in e.attributes[r])s.push({key:o,value:e.attributes[r][o]});s.sort((o,i)=>o.key<i.key?-1:1),t.push({nodeName:r,attrs:s})}t.sort((r,s)=>r.nodeName<s.nodeName?-1:1);let n="";for(let r=0;r<t.length;r++){let s=t[r];n+=`<${s.nodeName}`;for(let o=0;o<s.attrs.length;o++){let i=s.attrs[o];n+=` ${i.key}="${i.value}"`}n+=">"}n+=e.insert;for(let r=t.length-1;r>=0;r--)n+=`</${t[r].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(fx)}}var qS=(e)=>new Oe;class qi{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Ve()}mergeWith(e){return!1}write(e,t,n){throw Ve()}integrate(e,t){throw Ve()}}var XS=0;class st extends qi{get deleted(){return!0}delete(){}mergeWith(e){if(this.constructor!==e.constructor)return!1;return this.length+=e.length,!0}integrate(e,t){if(t>0)this.id.clock+=t,this.length-=t;th(e.doc.store,this)}write(e,t){e.writeInfo(XS),e.writeLen(this.length-t)}getMissing(e,t){return null}}class no{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new no(this.content)}splice(e){throw Ve()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}var GS=(e)=>new no(e.readBuf());class Xs{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Xs(this.len)}splice(e){let t=new Xs(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){js(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}var JS=(e)=>new Xs(e.readLen()),Oh=(e,t)=>new _t({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class ro{constructor(e){if(e._item)console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid.");this.doc=e;let t={};if(this.opts=t,!e.gc)t.gc=!1;if(e.autoLoad)t.autoLoad=!0;if(e.meta!==null)t.meta=e.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new ro(Oh(this.doc.guid,this.opts))}splice(e){throw Ve()}mergeWith(e){return!1}integrate(e,t){if(this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad)e.subdocsLoaded.add(this.doc)}delete(e){if(e.subdocsAdded.has(this.doc))e.subdocsAdded.delete(this.doc);else e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}var QS=(e)=>new ro(Oh(e.readString(),e.readAny()));class jn{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new jn(this.embed)}splice(e){throw Ve()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}var ZS=(e)=>new jn(e.readJSON());class ye{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new ye(this.key,this.value)}splice(e){throw Ve()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}var ex=(e)=>new ye(e.readKey(),e.readJSON());class Ui{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ui(this.arr)}splice(e){let t=new Ui(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let s=this.arr[r];e.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}}var tx=(e)=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let s=e.readString();if(s==="undefined")n.push(void 0);else n.push(JSON.parse(s))}return new Ui(n)},nx=Ps("node_env")==="development";class Un{constructor(e){this.arr=e,nx&&Dl(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Un(this.arr)}splice(e){let t=new Un(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let s=this.arr[r];e.writeAny(s)}}getRef(){return 8}}var rx=(e)=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Un(n)};class pt{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new pt(this.str)}splice(e){let t=new pt(this.str.slice(e));this.str=this.str.slice(0,e);let n=this.str.charCodeAt(e-1);if(n>=55296&&n<=56319)this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1);return t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}}var sx=(e)=>new pt(e.readString()),ox=[US,HS,YS,WS,jS,KS,qS],ix=0,ax=1,lx=2,cx=3,ux=4,dx=5,fx=6;class Me{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Me(this.type._copy())}splice(e){throw Ve()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;while(t!==null){if(!t.deleted)t.delete(e);else if(t.id.clock<(e.beforeState.get(t.id.client)||0))e._mergeStructs.push(t);t=t.right}this.type._map.forEach((n)=>{if(!n.deleted)n.delete(e);else if(n.id.clock<(e.beforeState.get(n.id.client)||0))e._mergeStructs.push(n)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;while(t!==null)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach((n)=>{while(n!==null)n.gc(e,!0),n=n.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}var hx=(e)=>new Me(ox[e.readTypeRef()](e)),nc=(e,t)=>{let n=t,r=0,s;do{if(r>0)n=W(n.client,n.clock+r);s=Fr(e,n),r=n.clock-s.id.clock,n=s.redone}while(n!==null&&s instanceof Z);return{item:s,diff:r}},hc=(e,t)=>{while(e!==null&&e.keep!==t)e.keep=t,e=e.parent._item},Hi=(e,t,n)=>{let{client:r,clock:s}=t.id,o=new Z(W(r,s+n),t,W(r,s+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));if(t.deleted)o.markDeleted();if(t.keep)o.keep=!0;if(t.redone!==null)o.redone=W(t.redone.client,t.redone.clock+n);if(t.right=o,o.right!==null)o.right.left=o;if(e._mergeStructs.push(o),o.parentSub!==null&&o.right===null)o.parent._map.set(o.parentSub,o);return t.length=n,o},Vf=(e,t)=>As(e,(n)=>$n(n.deletions,t)),Ih=(e,t,n,r,s,o)=>{let i=e.doc,{store:a,clientID:l}=i,c=t.redone;if(c!==null)return Je(e,c);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Ih(e,u,n,r,s,o)===null))return null;while(u.redone!==null)u=Je(e,u.redone)}let h=u===null?t.parent:u.content.type;if(t.parentSub===null){d=t.left,f=t;while(d!==null){let E=d;while(E!==null&&E.parent._item!==u)E=E.redone===null?null:Je(e,E.redone);if(E!==null&&E.parent._item===u){d=E;break}d=d.left}while(f!==null){let E=f;while(E!==null&&E.parent._item!==u)E=E.redone===null?null:Je(e,E.redone);if(E!==null&&E.parent._item===u){f=E;break}f=f.right}}else{if(f=null,t.right&&!s){d=t;while(d!==null&&d.right!==null&&(d.right.redone||$n(r,d.right.id)||Vf(o.undoStack,d.right.id)||Vf(o.redoStack,d.right.id))){d=d.right;while(d.redone)d=Je(e,d.redone)}if(d&&d.right!==null)return null}else d=h._map.get(t.parentSub)||null;if(d!==null&&d.parent._item!==u)d=h._map.get(t.parentSub)||null}let p=me(a,l),m=W(l,p),g=new Z(m,d,d&&d.lastId,f,f&&f.id,h,t.parentSub,t.content.copy());return t.redone=m,hc(g,!0),g.integrate(e,0),g};class Z extends qi{constructor(e,t,n,r,s,o,i,a){super(e,a.getLength());this.origin=n,this.left=t,this.right=r,this.rightOrigin=s,this.parent=o,this.parentSub=i,this.redone=null,this.content=a,this.info=this.content.isCountable()?yl:0}set marker(e){if((this.info&ii)>0!==e)this.info^=ii}get marker(){return(this.info&ii)>0}get keep(){return(this.info&gl)>0}set keep(e){if(this.keep!==e)this.info^=gl}get countable(){return(this.info&yl)>0}get deleted(){return(this.info&oi)>0}set deleted(e){if(this.deleted!==e)this.info^=oi}markDeleted(){this.info|=oi}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=me(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=me(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Fn&&this.id.client!==this.parent.client&&this.parent.clock>=me(t,this.parent.client))return this.parent.client;if(this.origin)this.left=Rf(e,t,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=Je(e,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===st||this.right&&this.right.constructor===st)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===Z)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===Z)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===Fn){let n=Fr(t,this.parent);if(n.constructor===st)this.parent=null;else this.parent=n.content.type}return null}integrate(e,t){if(t>0)this.id.clock+=t,this.left=Rf(e,e.doc.store,W(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,r;if(n!==null)r=n.right;else if(this.parentSub!==null){r=this.parent._map.get(this.parentSub)||null;while(r!==null&&r.left!==null)r=r.left}else r=this.parent._start;let s=new Set,o=new Set;while(r!==null&&r!==this.right){if(o.add(r),s.add(r),Br(this.origin,r.origin)){if(r.id.client<this.id.client)n=r,s.clear();else if(Br(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&o.has(Fr(e.doc.store,r.origin))){if(!s.has(Fr(e.doc.store,r.origin)))n=r,s.clear()}else break;r=r.right}this.left=n}if(this.left!==null){let n=this.left.right;this.right=n,this.left.right=this}else{let n;if(this.parentSub!==null){n=this.parent._map.get(this.parentSub)||null;while(n!==null&&n.left!==null)n=n.left}else n=this.parent._start,this.parent._start=this;this.right=n}if(this.right!==null)this.right.left=this;else if(this.parentSub!==null){if(this.parent._map.set(this.parentSub,this),this.left!==null)this.left.delete(e)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(th(e.doc.store,this),this.content.integrate(e,this),vf(e,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(e)}else new st(this.id,this.length).integrate(e,0)}get next(){let e=this.right;while(e!==null&&e.deleted)e=e.right;return e}get prev(){let e=this.left;while(e!==null&&e.deleted)e=e.left;return e}get lastId(){return this.length===1?this.id:W(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Br(e.origin,this.lastId)&&this.right===e&&Br(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;if(t)t.forEach((n)=>{if(n.p===e){if(n.p=this,!this.deleted&&this.countable)n.index-=this.length}});if(e.keep)this.keep=!0;if(this.right=e.right,this.right!==null)this.right.left=this;return this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;if(this.countable&&this.parentSub===null)t._length-=this.length;this.markDeleted(),js(e.deleteSet,this.id.client,this.id.clock,this.length),vf(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw ce();if(this.content.gc(e),t)_S(e,this,new st(this.id,this.length));else this.content=new Xs(this.length)}write(e,t){let n=t>0?W(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&Cs|(n===null?0:xe)|(r===null?0:ut)|(s===null?0:Tr);if(e.writeInfo(o),n!==null)e.writeLeftID(n);if(r!==null)e.writeRightID(r);if(n===null&&r===null){let i=this.parent;if(i._item!==void 0){let a=i._item;if(a===null){let l=Vn(i);e.writeParentInfo(!0),e.writeString(l)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else if(i.constructor===String)e.writeParentInfo(!0),e.writeString(i);else if(i.constructor===Fn)e.writeParentInfo(!1),e.writeLeftID(i);else ce();if(s!==null)e.writeString(s)}this.content.write(e,t)}}var Mh=(e,t)=>px[t&Cs](e),px=[()=>{ce()},JS,tx,GS,sx,ZS,ex,hx,rx,QS,()=>{ce()}],mx=10;class ft extends qi{get deleted(){return!0}delete(){}mergeWith(e){if(this.constructor!==e.constructor)return!1;return this.length+=e.length,!0}integrate(e,t){ce()}write(e,t){e.writeInfo(mx),G(e.restEncoder,this.length-t)}getMissing(e,t){return null}}var Rh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Dh="__ $YJS$ __";if(Rh[Dh]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Rh[Dh]=!0;var so;(function(e){e[e.EOF=-1]="EOF",e[e.NULL=0]="NULL",e[e.TABULATION=9]="TABULATION",e[e.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",e[e.LINE_FEED=10]="LINE_FEED",e[e.FORM_FEED=12]="FORM_FEED",e[e.SPACE=32]="SPACE",e[e.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",e[e.QUOTATION_MARK=34]="QUOTATION_MARK",e[e.AMPERSAND=38]="AMPERSAND",e[e.APOSTROPHE=39]="APOSTROPHE",e[e.HYPHEN_MINUS=45]="HYPHEN_MINUS",e[e.SOLIDUS=47]="SOLIDUS",e[e.DIGIT_0=48]="DIGIT_0",e[e.DIGIT_9=57]="DIGIT_9",e[e.SEMICOLON=59]="SEMICOLON",e[e.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",e[e.EQUALS_SIGN=61]="EQUALS_SIGN",e[e.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",e[e.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",e[e.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",e[e.GRAVE_ACCENT=96]="GRAVE_ACCENT",e[e.LATIN_SMALL_A=97]="LATIN_SMALL_A",e[e.LATIN_SMALL_Z=122]="LATIN_SMALL_Z"})(so||(so={}));var Vr;(function(e){e.controlCharacterInInputStream="control-character-in-input-stream",e.noncharacterInInputStream="noncharacter-in-input-stream",e.surrogateInInputStream="surrogate-in-input-stream",e.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",e.endTagWithAttributes="end-tag-with-attributes",e.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",e.unexpectedSolidusInTag="unexpected-solidus-in-tag",e.unexpectedNullCharacter="unexpected-null-character",e.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",e.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",e.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",e.missingEndTagName="missing-end-tag-name",e.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",e.unknownNamedCharacterReference="unknown-named-character-reference",e.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",e.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",e.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",e.eofBeforeTagName="eof-before-tag-name",e.eofInTag="eof-in-tag",e.missingAttributeValue="missing-attribute-value",e.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",e.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",e.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",e.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",e.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",e.missingDoctypePublicIdentifier="missing-doctype-public-identifier",e.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",e.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",e.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",e.cdataInHtmlContent="cdata-in-html-content",e.incorrectlyOpenedComment="incorrectly-opened-comment",e.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",e.eofInDoctype="eof-in-doctype",e.nestedComment="nested-comment",e.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",e.eofInComment="eof-in-comment",e.incorrectlyClosedComment="incorrectly-closed-comment",e.eofInCdata="eof-in-cdata",e.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",e.nullCharacterReference="null-character-reference",e.surrogateCharacterReference="surrogate-character-reference",e.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",e.controlCharacterReference="control-character-reference",e.noncharacterCharacterReference="noncharacter-character-reference",e.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",e.missingDoctypeName="missing-doctype-name",e.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",e.duplicateAttribute="duplicate-attribute",e.nonConformingDoctype="non-conforming-doctype",e.missingDoctype="missing-doctype",e.misplacedDoctype="misplaced-doctype",e.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",e.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",e.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",e.openElementsLeftAfterEof="open-elements-left-after-eof",e.abandonedHeadElementChild="abandoned-head-element-child",e.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",e.nestedNoscriptInHead="nested-noscript-in-head",e.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})(Vr||(Vr={}));var Xi;(function(e){e[e.CHARACTER=0]="CHARACTER",e[e.NULL_CHARACTER=1]="NULL_CHARACTER",e[e.WHITESPACE_CHARACTER=2]="WHITESPACE_CHARACTER",e[e.START_TAG=3]="START_TAG",e[e.END_TAG=4]="END_TAG",e[e.COMMENT=5]="COMMENT",e[e.DOCTYPE=6]="DOCTYPE",e[e.EOF=7]="EOF",e[e.HIBERNATION=8]="HIBERNATION"})(Xi||(Xi={}));var ue;(function(e){e.HTML="http://www.w3.org/1999/xhtml",e.MATHML="http://www.w3.org/1998/Math/MathML",e.SVG="http://www.w3.org/2000/svg",e.XLINK="http://www.w3.org/1999/xlink",e.XML="http://www.w3.org/XML/1998/namespace",e.XMLNS="http://www.w3.org/2000/xmlns/"})(ue||(ue={}));var Gi;(function(e){e.TYPE="type",e.ACTION="action",e.ENCODING="encoding",e.PROMPT="prompt",e.NAME="name",e.COLOR="color",e.FACE="face",e.SIZE="size"})(Gi||(Gi={}));var oo;(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(oo||(oo={}));var T;(function(e){e.A="a",e.ADDRESS="address",e.ANNOTATION_XML="annotation-xml",e.APPLET="applet",e.AREA="area",e.ARTICLE="article",e.ASIDE="aside",e.B="b",e.BASE="base",e.BASEFONT="basefont",e.BGSOUND="bgsound",e.BIG="big",e.BLOCKQUOTE="blockquote",e.BODY="body",e.BR="br",e.BUTTON="button",e.CAPTION="caption",e.CENTER="center",e.CODE="code",e.COL="col",e.COLGROUP="colgroup",e.DD="dd",e.DESC="desc",e.DETAILS="details",e.DIALOG="dialog",e.DIR="dir",e.DIV="div",e.DL="dl",e.DT="dt",e.EM="em",e.EMBED="embed",e.FIELDSET="fieldset",e.FIGCAPTION="figcaption",e.FIGURE="figure",e.FONT="font",e.FOOTER="footer",e.FOREIGN_OBJECT="foreignObject",e.FORM="form",e.FRAME="frame",e.FRAMESET="frameset",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6",e.HEAD="head",e.HEADER="header",e.HGROUP="hgroup",e.HR="hr",e.HTML="html",e.I="i",e.IMG="img",e.IMAGE="image",e.INPUT="input",e.IFRAME="iframe",e.KEYGEN="keygen",e.LABEL="label",e.LI="li",e.LINK="link",e.LISTING="listing",e.MAIN="main",e.MALIGNMARK="malignmark",e.MARQUEE="marquee",e.MATH="math",e.MENU="menu",e.META="meta",e.MGLYPH="mglyph",e.MI="mi",e.MO="mo",e.MN="mn",e.MS="ms",e.MTEXT="mtext",e.NAV="nav",e.NOBR="nobr",e.NOFRAMES="noframes",e.NOEMBED="noembed",e.NOSCRIPT="noscript",e.OBJECT="object",e.OL="ol",e.OPTGROUP="optgroup",e.OPTION="option",e.P="p",e.PARAM="param",e.PLAINTEXT="plaintext",e.PRE="pre",e.RB="rb",e.RP="rp",e.RT="rt",e.RTC="rtc",e.RUBY="ruby",e.S="s",e.SCRIPT="script",e.SEARCH="search",e.SECTION="section",e.SELECT="select",e.SOURCE="source",e.SMALL="small",e.SPAN="span",e.STRIKE="strike",e.STRONG="strong",e.STYLE="style",e.SUB="sub",e.SUMMARY="summary",e.SUP="sup",e.TABLE="table",e.TBODY="tbody",e.TEMPLATE="template",e.TEXTAREA="textarea",e.TFOOT="tfoot",e.TD="td",e.TH="th",e.THEAD="thead",e.TITLE="title",e.TR="tr",e.TRACK="track",e.TT="tt",e.U="u",e.UL="ul",e.SVG="svg",e.VAR="var",e.WBR="wbr",e.XMP="xmp"})(T||(T={}));var y;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A=1]="A",e[e.ADDRESS=2]="ADDRESS",e[e.ANNOTATION_XML=3]="ANNOTATION_XML",e[e.APPLET=4]="APPLET",e[e.AREA=5]="AREA",e[e.ARTICLE=6]="ARTICLE",e[e.ASIDE=7]="ASIDE",e[e.B=8]="B",e[e.BASE=9]="BASE",e[e.BASEFONT=10]="BASEFONT",e[e.BGSOUND=11]="BGSOUND",e[e.BIG=12]="BIG",e[e.BLOCKQUOTE=13]="BLOCKQUOTE",e[e.BODY=14]="BODY",e[e.BR=15]="BR",e[e.BUTTON=16]="BUTTON",e[e.CAPTION=17]="CAPTION",e[e.CENTER=18]="CENTER",e[e.CODE=19]="CODE",e[e.COL=20]="COL",e[e.COLGROUP=21]="COLGROUP",e[e.DD=22]="DD",e[e.DESC=23]="DESC",e[e.DETAILS=24]="DETAILS",e[e.DIALOG=25]="DIALOG",e[e.DIR=26]="DIR",e[e.DIV=27]="DIV",e[e.DL=28]="DL",e[e.DT=29]="DT",e[e.EM=30]="EM",e[e.EMBED=31]="EMBED",e[e.FIELDSET=32]="FIELDSET",e[e.FIGCAPTION=33]="FIGCAPTION",e[e.FIGURE=34]="FIGURE",e[e.FONT=35]="FONT",e[e.FOOTER=36]="FOOTER",e[e.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",e[e.FORM=38]="FORM",e[e.FRAME=39]="FRAME",e[e.FRAMESET=40]="FRAMESET",e[e.H1=41]="H1",e[e.H2=42]="H2",e[e.H3=43]="H3",e[e.H4=44]="H4",e[e.H5=45]="H5",e[e.H6=46]="H6",e[e.HEAD=47]="HEAD",e[e.HEADER=48]="HEADER",e[e.HGROUP=49]="HGROUP",e[e.HR=50]="HR",e[e.HTML=51]="HTML",e[e.I=52]="I",e[e.IMG=53]="IMG",e[e.IMAGE=54]="IMAGE",e[e.INPUT=55]="INPUT",e[e.IFRAME=56]="IFRAME",e[e.KEYGEN=57]="KEYGEN",e[e.LABEL=58]="LABEL",e[e.LI=59]="LI",e[e.LINK=60]="LINK",e[e.LISTING=61]="LISTING",e[e.MAIN=62]="MAIN",e[e.MALIGNMARK=63]="MALIGNMARK",e[e.MARQUEE=64]="MARQUEE",e[e.MATH=65]="MATH",e[e.MENU=66]="MENU",e[e.META=67]="META",e[e.MGLYPH=68]="MGLYPH",e[e.MI=69]="MI",e[e.MO=70]="MO",e[e.MN=71]="MN",e[e.MS=72]="MS",e[e.MTEXT=73]="MTEXT",e[e.NAV=74]="NAV",e[e.NOBR=75]="NOBR",e[e.NOFRAMES=76]="NOFRAMES",e[e.NOEMBED=77]="NOEMBED",e[e.NOSCRIPT=78]="NOSCRIPT",e[e.OBJECT=79]="OBJECT",e[e.OL=80]="OL",e[e.OPTGROUP=81]="OPTGROUP",e[e.OPTION=82]="OPTION",e[e.P=83]="P",e[e.PARAM=84]="PARAM",e[e.PLAINTEXT=85]="PLAINTEXT",e[e.PRE=86]="PRE",e[e.RB=87]="RB",e[e.RP=88]="RP",e[e.RT=89]="RT",e[e.RTC=90]="RTC",e[e.RUBY=91]="RUBY",e[e.S=92]="S",e[e.SCRIPT=93]="SCRIPT",e[e.SEARCH=94]="SEARCH",e[e.SECTION=95]="SECTION",e[e.SELECT=96]="SELECT",e[e.SOURCE=97]="SOURCE",e[e.SMALL=98]="SMALL",e[e.SPAN=99]="SPAN",e[e.STRIKE=100]="STRIKE",e[e.STRONG=101]="STRONG",e[e.STYLE=102]="STYLE",e[e.SUB=103]="SUB",e[e.SUMMARY=104]="SUMMARY",e[e.SUP=105]="SUP",e[e.TABLE=106]="TABLE",e[e.TBODY=107]="TBODY",e[e.TEMPLATE=108]="TEMPLATE",e[e.TEXTAREA=109]="TEXTAREA",e[e.TFOOT=110]="TFOOT",e[e.TD=111]="TD",e[e.TH=112]="TH",e[e.THEAD=113]="THEAD",e[e.TITLE=114]="TITLE",e[e.TR=115]="TR",e[e.TRACK=116]="TRACK",e[e.TT=117]="TT",e[e.U=118]="U",e[e.UL=119]="UL",e[e.SVG=120]="SVG",e[e.VAR=121]="VAR",e[e.WBR=122]="WBR",e[e.XMP=123]="XMP"})(y||(y={}));var CR=new Map([[T.A,y.A],[T.ADDRESS,y.ADDRESS],[T.ANNOTATION_XML,y.ANNOTATION_XML],[T.APPLET,y.APPLET],[T.AREA,y.AREA],[T.ARTICLE,y.ARTICLE],[T.ASIDE,y.ASIDE],[T.B,y.B],[T.BASE,y.BASE],[T.BASEFONT,y.BASEFONT],[T.BGSOUND,y.BGSOUND],[T.BIG,y.BIG],[T.BLOCKQUOTE,y.BLOCKQUOTE],[T.BODY,y.BODY],[T.BR,y.BR],[T.BUTTON,y.BUTTON],[T.CAPTION,y.CAPTION],[T.CENTER,y.CENTER],[T.CODE,y.CODE],[T.COL,y.COL],[T.COLGROUP,y.COLGROUP],[T.DD,y.DD],[T.DESC,y.DESC],[T.DETAILS,y.DETAILS],[T.DIALOG,y.DIALOG],[T.DIR,y.DIR],[T.DIV,y.DIV],[T.DL,y.DL],[T.DT,y.DT],[T.EM,y.EM],[T.EMBED,y.EMBED],[T.FIELDSET,y.FIELDSET],[T.FIGCAPTION,y.FIGCAPTION],[T.FIGURE,y.FIGURE],[T.FONT,y.FONT],[T.FOOTER,y.FOOTER],[T.FOREIGN_OBJECT,y.FOREIGN_OBJECT],[T.FORM,y.FORM],[T.FRAME,y.FRAME],[T.FRAMESET,y.FRAMESET],[T.H1,y.H1],[T.H2,y.H2],[T.H3,y.H3],[T.H4,y.H4],[T.H5,y.H5],[T.H6,y.H6],[T.HEAD,y.HEAD],[T.HEADER,y.HEADER],[T.HGROUP,y.HGROUP],[T.HR,y.HR],[T.HTML,y.HTML],[T.I,y.I],[T.IMG,y.IMG],[T.IMAGE,y.IMAGE],[T.INPUT,y.INPUT],[T.IFRAME,y.IFRAME],[T.KEYGEN,y.KEYGEN],[T.LABEL,y.LABEL],[T.LI,y.LI],[T.LINK,y.LINK],[T.LISTING,y.LISTING],[T.MAIN,y.MAIN],[T.MALIGNMARK,y.MALIGNMARK],[T.MARQUEE,y.MARQUEE],[T.MATH,y.MATH],[T.MENU,y.MENU],[T.META,y.META],[T.MGLYPH,y.MGLYPH],[T.MI,y.MI],[T.MO,y.MO],[T.MN,y.MN],[T.MS,y.MS],[T.MTEXT,y.MTEXT],[T.NAV,y.NAV],[T.NOBR,y.NOBR],[T.NOFRAMES,y.NOFRAMES],[T.NOEMBED,y.NOEMBED],[T.NOSCRIPT,y.NOSCRIPT],[T.OBJECT,y.OBJECT],[T.OL,y.OL],[T.OPTGROUP,y.OPTGROUP],[T.OPTION,y.OPTION],[T.P,y.P],[T.PARAM,y.PARAM],[T.PLAINTEXT,y.PLAINTEXT],[T.PRE,y.PRE],[T.RB,y.RB],[T.RP,y.RP],[T.RT,y.RT],[T.RTC,y.RTC],[T.RUBY,y.RUBY],[T.S,y.S],[T.SCRIPT,y.SCRIPT],[T.SEARCH,y.SEARCH],[T.SECTION,y.SECTION],[T.SELECT,y.SELECT],[T.SOURCE,y.SOURCE],[T.SMALL,y.SMALL],[T.SPAN,y.SPAN],[T.STRIKE,y.STRIKE],[T.STRONG,y.STRONG],[T.STYLE,y.STYLE],[T.SUB,y.SUB],[T.SUMMARY,y.SUMMARY],[T.SUP,y.SUP],[T.TABLE,y.TABLE],[T.TBODY,y.TBODY],[T.TEMPLATE,y.TEMPLATE],[T.TEXTAREA,y.TEXTAREA],[T.TFOOT,y.TFOOT],[T.TD,y.TD],[T.TH,y.TH],[T.THEAD,y.THEAD],[T.TITLE,y.TITLE],[T.TR,y.TR],[T.TRACK,y.TRACK],[T.TT,y.TT],[T.U,y.U],[T.UL,y.UL],[T.SVG,y.SVG],[T.VAR,y.VAR],[T.WBR,y.WBR],[T.XMP,y.XMP]]);var C=y,wx={[ue.HTML]:new Set([C.ADDRESS,C.APPLET,C.AREA,C.ARTICLE,C.ASIDE,C.BASE,C.BASEFONT,C.BGSOUND,C.BLOCKQUOTE,C.BODY,C.BR,C.BUTTON,C.CAPTION,C.CENTER,C.COL,C.COLGROUP,C.DD,C.DETAILS,C.DIR,C.DIV,C.DL,C.DT,C.EMBED,C.FIELDSET,C.FIGCAPTION,C.FIGURE,C.FOOTER,C.FORM,C.FRAME,C.FRAMESET,C.H1,C.H2,C.H3,C.H4,C.H5,C.H6,C.HEAD,C.HEADER,C.HGROUP,C.HR,C.HTML,C.IFRAME,C.IMG,C.INPUT,C.LI,C.LINK,C.LISTING,C.MAIN,C.MARQUEE,C.MENU,C.META,C.NAV,C.NOEMBED,C.NOFRAMES,C.NOSCRIPT,C.OBJECT,C.OL,C.P,C.PARAM,C.PLAINTEXT,C.PRE,C.SCRIPT,C.SECTION,C.SELECT,C.SOURCE,C.STYLE,C.SUMMARY,C.TABLE,C.TBODY,C.TD,C.TEMPLATE,C.TEXTAREA,C.TFOOT,C.TH,C.THEAD,C.TITLE,C.TR,C.TRACK,C.UL,C.WBR,C.XMP]),[ue.MATHML]:new Set([C.MI,C.MO,C.MN,C.MS,C.MTEXT,C.ANNOTATION_XML]),[ue.SVG]:new Set([C.TITLE,C.FOREIGN_OBJECT,C.DESC]),[ue.XLINK]:new Set,[ue.XML]:new Set,[ue.XMLNS]:new Set},vh=new Set([C.H1,C.H2,C.H3,C.H4,C.H5,C.H6]),kR=new Set([T.STYLE,T.SCRIPT,T.XMP,T.IFRAME,T.NOEMBED,T.NOFRAMES,T.PLAINTEXT]);var fn;(function(e){e[e.DATA=0]="DATA",e[e.RCDATA=1]="RCDATA",e[e.RAWTEXT=2]="RAWTEXT",e[e.SCRIPT_DATA=3]="SCRIPT_DATA",e[e.PLAINTEXT=4]="PLAINTEXT",e[e.TAG_OPEN=5]="TAG_OPEN",e[e.END_TAG_OPEN=6]="END_TAG_OPEN",e[e.TAG_NAME=7]="TAG_NAME",e[e.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",e[e.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",e[e.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",e[e.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",e[e.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",e[e.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",e[e.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",e[e.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",e[e.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",e[e.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",e[e.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",e[e.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",e[e.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",e[e.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",e[e.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",e[e.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",e[e.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",e[e.BOGUS_COMMENT=40]="BOGUS_COMMENT",e[e.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",e[e.COMMENT_START=42]="COMMENT_START",e[e.COMMENT_START_DASH=43]="COMMENT_START_DASH",e[e.COMMENT=44]="COMMENT",e[e.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",e[e.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",e[e.COMMENT_END_DASH=49]="COMMENT_END_DASH",e[e.COMMENT_END=50]="COMMENT_END",e[e.COMMENT_END_BANG=51]="COMMENT_END_BANG",e[e.DOCTYPE=52]="DOCTYPE",e[e.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",e[e.DOCTYPE_NAME=54]="DOCTYPE_NAME",e[e.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",e[e.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",e[e.CDATA_SECTION=68]="CDATA_SECTION",e[e.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",e[e.CDATA_SECTION_END=70]="CDATA_SECTION_END",e[e.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",e[e.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND"})(fn||(fn={}));var Ph={DATA:fn.DATA,RCDATA:fn.RCDATA,RAWTEXT:fn.RAWTEXT,SCRIPT_DATA:fn.SCRIPT_DATA,PLAINTEXT:fn.PLAINTEXT,CDATA_SECTION:fn.CDATA_SECTION};var Nx=new Set([y.DD,y.DT,y.LI,y.OPTGROUP,y.OPTION,y.P,y.RB,y.RP,y.RT,y.RTC]),PR=new Set([...Nx,y.CAPTION,y.COLGROUP,y.TBODY,y.TD,y.TFOOT,y.TH,y.THEAD,y.TR]),Bh=new Set([y.APPLET,y.CAPTION,y.HTML,y.MARQUEE,y.OBJECT,y.TABLE,y.TD,y.TEMPLATE,y.TH]),BR=new Set([...Bh,y.OL,y.UL]),FR=new Set([...Bh,y.BUTTON]),UR=new Set([y.ANNOTATION_XML,y.MI,y.MN,y.MO,y.MS,y.MTEXT]),HR=new Set([y.DESC,y.FOREIGN_OBJECT,y.TITLE]),$R=new Set([y.TR,y.TEMPLATE,y.HTML]),VR=new Set([y.TBODY,y.TFOOT,y.THEAD,y.TEMPLATE,y.HTML]),zR=new Set([y.TABLE,y.TEMPLATE,y.HTML]),YR=new Set([y.TD,y.TH]);var Ji;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(Ji||(Ji={}));var WR={type:Ji.Marker};var Ox=["+//silmaril//dtd html pro v0r11 19970101//","-//as//dtd html 3.0 aswedit + extensions//","-//advasoft ltd//dtd html 3.0 aswedit + extensions//","-//ietf//dtd html 2.0 level 1//","-//ietf//dtd html 2.0 level 2//","-//ietf//dtd html 2.0 strict level 1//","-//ietf//dtd html 2.0 strict level 2//","-//ietf//dtd html 2.0 strict//","-//ietf//dtd html 2.0//","-//ietf//dtd html 2.1e//","-//ietf//dtd html 3.0//","-//ietf//dtd html 3.2 final//","-//ietf//dtd html 3.2//","-//ietf//dtd html 3//","-//ietf//dtd html level 0//","-//ietf//dtd html level 1//","-//ietf//dtd html level 2//","-//ietf//dtd html level 3//","-//ietf//dtd html strict level 0//","-//ietf//dtd html strict level 1//","-//ietf//dtd html strict level 2//","-//ietf//dtd html strict level 3//","-//ietf//dtd html strict//","-//ietf//dtd html//","-//metrius//dtd metrius presentational//","-//microsoft//dtd internet explorer 2.0 html strict//","-//microsoft//dtd internet explorer 2.0 html//","-//microsoft//dtd internet explorer 2.0 tables//","-//microsoft//dtd internet explorer 3.0 html strict//","-//microsoft//dtd internet explorer 3.0 html//","-//microsoft//dtd internet explorer 3.0 tables//","-//netscape comm. corp.//dtd html//","-//netscape comm. corp.//dtd strict html//","-//o'reilly and associates//dtd html 2.0//","-//o'reilly and associates//dtd html extended 1.0//","-//o'reilly and associates//dtd html extended relaxed 1.0//","-//sq//dtd html 2.0 hotmetal + extensions//","-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//","-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//","-//spyglass//dtd html 2.0 extended//","-//sun microsystems corp.//dtd hotjava html//","-//sun microsystems corp.//dtd hotjava strict html//","-//w3c//dtd html 3 1995-03-24//","-//w3c//dtd html 3.2 draft//","-//w3c//dtd html 3.2 final//","-//w3c//dtd html 3.2//","-//w3c//dtd html 3.2s draft//","-//w3c//dtd html 4.0 frameset//","-//w3c//dtd html 4.0 transitional//","-//w3c//dtd html experimental 19960712//","-//w3c//dtd html experimental 970421//","-//w3c//dtd w3 html//","-//w3o//dtd w3 html 3.0//","-//webtechs//dtd mozilla html 2.0//","-//webtechs//dtd mozilla html//"],JR=[...Ox,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];var Ix=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],QR=[...Ix,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];var eD=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map((e)=>[e.toLowerCase(),e])),tD=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:ue.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:ue.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:ue.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:ue.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:ue.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:ue.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:ue.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:ue.XML}],["xml:space",{prefix:"xml",name:"space",namespace:ue.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:ue.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:ue.XMLNS}]]),nD=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map((e)=>[e.toLowerCase(),e])),rD=new Set([y.B,y.BIG,y.BLOCKQUOTE,y.BODY,y.BR,y.CENTER,y.CODE,y.DD,y.DIV,y.DL,y.DT,y.EM,y.EMBED,y.H1,y.H2,y.H3,y.H4,y.H5,y.H6,y.HEAD,y.HR,y.I,y.IMG,y.LI,y.LISTING,y.MENU,y.META,y.NOBR,y.OL,y.P,y.PRE,y.RUBY,y.S,y.SMALL,y.SPAN,y.STRONG,y.STRIKE,y.SUB,y.SUP,y.TABLE,y.TT,y.U,y.UL,y.VAR]);var Uh;(function(e){e[e.INITIAL=0]="INITIAL",e[e.BEFORE_HTML=1]="BEFORE_HTML",e[e.BEFORE_HEAD=2]="BEFORE_HEAD",e[e.IN_HEAD=3]="IN_HEAD",e[e.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",e[e.AFTER_HEAD=5]="AFTER_HEAD",e[e.IN_BODY=6]="IN_BODY",e[e.TEXT=7]="TEXT",e[e.IN_TABLE=8]="IN_TABLE",e[e.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",e[e.IN_CAPTION=10]="IN_CAPTION",e[e.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",e[e.IN_TABLE_BODY=12]="IN_TABLE_BODY",e[e.IN_ROW=13]="IN_ROW",e[e.IN_CELL=14]="IN_CELL",e[e.IN_SELECT=15]="IN_SELECT",e[e.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",e[e.IN_TEMPLATE=17]="IN_TEMPLATE",e[e.AFTER_BODY=18]="AFTER_BODY",e[e.IN_FRAMESET=19]="IN_FRAMESET",e[e.AFTER_FRAMESET=20]="AFTER_FRAMESET",e[e.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",e[e.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET"})(Uh||(Uh={}));var SD=new Set([y.TABLE,y.TBODY,y.TFOOT,y.THEAD,y.TR]);var xD=new Set([y.CAPTION,y.COL,y.COLGROUP,y.TBODY,y.TD,y.TFOOT,y.TH,y.THEAD,y.TR]);var _D=new Set([T.AREA,T.BASE,T.BASEFONT,T.BGSOUND,T.BR,T.COL,T.EMBED,T.FRAME,T.HR,T.IMG,T.INPUT,T.KEYGEN,T.LINK,T.META,T.PARAM,T.SOURCE,T.TRACK,T.WBR]);var Wn=["a","span","strong","b","em","i","u","s","del","ins","mark","small","sub","sup","code","abbr","cite","q","dfn","kbd","samp","var","time","data","bdi","bdo"],io=new Set(["p","h1","h2","h3","h4","h5","h6","li","td","th","dt","dd","figcaption","blockquote","caption","pre","summary","legend","address"]);var KD=new Set([...Wn,"br","wbr","img","svg","math","input","button","select","textarea","label","output","meter","progress","picture","canvas","video","audio","iframe","object","embed","font","nobr","ruby","rt","rp","slot"]),qD=new Map(Wn.map((e,t)=>[e,t]));var ao="body";function Qi(e){return e instanceof dn&&e.get(ao)instanceof ze}var Zi="files";var Hh=Object.defineProperty,$h=(e,t)=>{let n={};for(var r in e)Hh(n,r,{get:e[r],enumerable:!0});if(!t)Hh(n,Symbol.toStringTag,{value:"Module"});return n};function Fe(e){this.content=e}Fe.prototype={constructor:Fe,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,s=r.find(e),o=r.content.slice();if(s==-1)o.push(n||e,t);else if(o[s+1]=t,n)o[s]=n;return new Fe(o)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new Fe(n)},addToStart:function(e,t){return new Fe([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Fe(n)},addBefore:function(e,t,n){var r=this.remove(t),s=r.content.slice(),o=r.find(e);return s.splice(o==-1?s.length:o,0,t,n),new Fe(s)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){if(e=Fe.from(e),!e.size)return this;return new Fe(e.content.concat(this.subtract(e).content))},append:function(e){if(e=Fe.from(e),!e.size)return this;return new Fe(this.subtract(e).content.concat(e.content))},subtract:function(e){var t=this;e=Fe.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}};Fe.from=function(e){if(e instanceof Fe)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Fe(t)};var yc=Fe;function Zh(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let s=e.child(r),o=t.child(r);if(s==o){n+=s.nodeSize;continue}if(!s.sameMarkup(o))return n;if(s.isText&&s.text!=o.text){let i=s.text,a=o.text,l=0;for(;i[l]==a[l];l++)n++;if(l&&l<i.length&&l<a.length&&np(i.charCodeAt(l-1))&&tp(i.charCodeAt(l)))n--;return n}if(s.content.size||o.content.size){let i=Zh(s.content,o.content,n+1);if(i!=null)return i}n+=s.nodeSize}}function ep(e,t,n,r){for(let s=e.childCount,o=t.childCount;;){if(s==0||o==0)return s==o?null:{a:n,b:r};let i=e.child(--s),a=t.child(--o),l=i.nodeSize;if(i==a){n-=l,r-=l;continue}if(!i.sameMarkup(a))return{a:n,b:r};if(i.isText&&i.text!=a.text){let c=i.text,u=a.text,d=c.length,f=u.length;while(d>0&&f>0&&c[d-1]==u[f-1])d--,f--,n--,r--;if(d&&f&&d<c.length&&np(c.charCodeAt(d-1))&&tp(c.charCodeAt(d)))n++,r++;return{a:n,b:r}}if(i.content.size||a.content.size){let c=ep(i.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}function tp(e){return e>=56320&&e<57344}function np(e){return e>=55296&&e<56320}class S{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,r=0,s){for(let o=0,i=0;i<t;o++){let a=this.content[o],l=i+a.nodeSize;if(l>e&&n(a,r+i,s||null,o)!==!1&&a.content.size){let c=i+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,t-c),n,r+c)}i=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let s="",o=!0;return this.nodesBetween(e,t,(i,a)=>{let l=i.isText?i.text.slice(Math.max(e,a)-a,t-a):!i.isLeaf?"":r?typeof r==="function"?r(i):r:i.type.spec.leafText?i.type.spec.leafText(i):"";if(i.isBlock&&(i.isLeaf&&l||i.isTextblock)&&n)if(o)o=!1;else s+=n;s+=l},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),s=0;if(t.isText&&t.sameMarkup(n))r[r.length-1]=t.withText(t.text+n.text),s=1;for(;s<e.content.length;s++)r.push(e.content[s]);return new S(r,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],r=0;if(t>e)for(let s=0,o=0;o<t;s++){let i=this.content[s],a=o+i.nodeSize;if(a>e){if(o<e||a>t)if(i.isText)i=i.cut(Math.max(0,e-o),Math.min(i.text.length,t-o));else i=i.cut(Math.max(0,e-o-1),Math.min(i.content.size,t-o-1));n.push(i),r+=i.nodeSize}o=a}return new S(n,r)}cutByIndex(e,t){if(e==t)return S.empty;if(e==0&&t==this.content.length)return this;return new S(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),s=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new S(r,s)}addToStart(e){return new S([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new S(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Zh(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return ep(this,e,t,n)}findIndex(e){if(e==0)return ea(0,e);if(e==this.size)return ea(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),s=n+r.nodeSize;if(s>=e){if(s==e)return ea(t+1,s);return ea(t,n)}n=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((e)=>e.toJSON()):null}static fromJSON(e,t){if(!t)return S.empty;if(!Array.isArray(t))throw RangeError("Invalid input for Fragment.fromJSON");return S.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return S.empty;let t,n=0;for(let r=0;r<e.length;r++){let s=e[r];if(n+=s.nodeSize,r&&s.isText&&e[r-1].sameMarkup(s)){if(!t)t=e.slice(0,r);t[t.length-1]=s.withText(t[t.length-1].text+s.text)}else if(t)t.push(s)}return new S(t||e,n)}static from(e){if(!e)return S.empty;if(e instanceof S)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new S([e],e.nodeSize);throw RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}S.empty=new S([],0);var Ec={index:0,offset:0};function ea(e,t){return Ec.index=e,Ec.offset=t,Ec}function ra(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!ra(e[r],t[r]))return!1}else{for(let r in e)if(!(r in t)||!ra(e[r],t[r]))return!1;for(let r in t)if(!(r in e))return!1}return!0}class J{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let s=e[r];if(this.eq(s))return e;if(this.type.excludes(s.type)){if(!t)t=e.slice(0,r)}else if(s.type.excludes(this.type))return e;else{if(!n&&s.type.rank>this.type.rank){if(!t)t=e.slice(0,r);t.push(this),n=!0}if(t)t.push(s)}}if(!t)t=e.slice();if(!n)t.push(this);return t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ra(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return J.none;if(e instanceof J)return[e];let t=e.slice();return t.sort((n,r)=>n.type.rank-r.type.rank),t}}J.none=[];class Xn extends Error{}class _{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=sp(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new _(n,this.openStart,this.openEnd)}removeBetween(e,t){return new _(rp(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};if(this.openStart>0)e.openStart=this.openStart;if(this.openEnd>0)e.openEnd=this.openEnd;return e}static fromJSON(e,t){if(!t)return _.empty;let n=t.openStart||0,r=t.openEnd||0;if(typeof n!="number"||typeof r!="number")throw RangeError("Invalid input for Slice.fromJSON");return new _(S.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)n++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)r++;return new _(e,n,r)}}_.empty=new _(S.empty,0,0);function rp(e,t,n){let{index:r,offset:s}=e.findIndex(t),o=e.maybeChild(r),{index:i,offset:a}=e.findIndex(n);if(s==t||o.isText){if(a!=n&&!e.child(i).isText)throw RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=i)throw RangeError("Removing non-flat range");return e.replaceChild(r,o.copy(rp(o.content,t-s-1,n-s-1)))}function sp(e,t,n,r,s,o){let{index:i,offset:a}=e.findIndex(t),l=e.maybeChild(i);if(a==t||l.isText){if(o&&r<=0&&s<=0&&!o.canReplace(i,i,n))return null;return e.cut(0,t).append(n).append(e.cut(t))}let c=sp(l.content,t-a-1,n,i==0?r-1:0,i==e.childCount-1?s-1:0,l);return c&&e.replaceChild(i,l.copy(c))}function Ux(e,t,n){if(n.openStart>e.depth)throw new Xn("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Xn("Inconsistent open depths");return op(e,t,n,0)}function op(e,t,n,r){let s=e.index(r),o=e.node(r);if(s==t.index(r)&&r<e.depth-n.openStart){let i=op(e,t,n,r+1);return o.copy(o.content.replaceChild(s,i))}else if(!n.content.size)return qn(o,sa(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let i=e.parent,a=i.content;return qn(i,a.cut(0,e.parentOffset).append(n.content).append(a.cut(t.parentOffset)))}else{let{start:i,end:a}=Hx(n,e);return qn(o,ap(e,i,a,t,r))}}function ip(e,t){if(!t.type.compatibleContent(e.type))throw new Xn("Cannot join "+t.type.name+" onto "+e.type.name)}function Tc(e,t,n){let r=e.node(n);return ip(r,t.node(n)),r}function Kn(e,t){let n=t.length-1;if(n>=0&&e.isText&&e.sameMarkup(t[n]))t[n]=e.withText(t[n].text+e.text);else t.push(e)}function co(e,t,n,r){let s=(t||e).node(n),o=0,i=t?t.index(n):s.childCount;if(e){if(o=e.index(n),e.depth>n)o++;else if(e.textOffset)Kn(e.nodeAfter,r),o++}for(let a=o;a<i;a++)Kn(s.child(a),r);if(t&&t.depth==n&&t.textOffset)Kn(t.nodeBefore,r)}function qn(e,t){if(!e.type.validContent(t))throw new Xn("Invalid content for node "+e.type.name);return e.copy(t)}function ap(e,t,n,r,s){let o=e.depth>s&&Tc(e,t,s+1),i=r.depth>s&&Tc(n,r,s+1),a=[];if(co(null,e,s,a),o&&i&&t.index(s)==n.index(s))ip(o,i),Kn(qn(o,ap(e,t,n,r,s+1)),a);else{if(o)Kn(qn(o,sa(e,t,s+1)),a);if(co(t,n,s,a),i)Kn(qn(i,sa(n,r,s+1)),a)}return co(r,null,s,a),new S(a)}function sa(e,t,n){let r=[];if(co(null,e,n,r),e.depth>n){let s=Tc(e,t,n+1);Kn(qn(s,sa(e,t,n+1)),r)}return co(t,null,n,r),new S(r)}function Hx(e,t){let n=t.depth-e.openStart,s=t.node(n).copy(e.content);for(let o=n-1;o>=0;o--)s=t.node(o).copy(S.from(s));return{start:s.resolveNoCache(e.openStart+n),end:s.resolveNoCache(s.content.size-e.openEnd-n)}}class fo{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){if(e==null)return this.depth;if(e<0)return this.depth+e;return e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];if(t)return this.parent.child(e).cut(0,t);return e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)r+=n.child(s).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return J.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let i=n;n=r,r=i}let s=n.marks;for(var o=0;o<s.length;o++)if(s[o].type.spec.inclusive===!1&&(!r||!s[o].isInSet(r.marks)))s=s[o--].removeFromSet(s);return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var s=0;s<n.length;s++)if(n[s].type.spec.inclusive===!1&&(!r||!n[s].isInSet(r.marks)))n=n[s--].removeFromSet(n);return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Yr(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw RangeError("Position "+t+" out of range");let n=[],r=0,s=t;for(let o=e;;){let{index:i,offset:a}=o.content.findIndex(s),l=s-a;if(n.push(o,i,r+a),!l)break;if(o=o.child(i),o.isText)break;s=l-1,r+=a+1}return new fo(t,n,s)}static resolveCached(e,t){let n=Vh.get(e);if(n)for(let s=0;s<n.elts.length;s++){let o=n.elts[s];if(o.pos==t)return o}else Vh.set(e,n=new lp);let r=n.elts[n.i]=fo.resolve(e,t);return n.i=(n.i+1)%$x,r}}class lp{constructor(){this.elts=[],this.i=0}}var $x=12,Vh=new WeakMap;class Yr{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}var Vx=Object.create(null);class Ye{constructor(e,t,n,r=J.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||S.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&ra(this.attrs,t||e.defaultAttrs||Vx)&&J.sameSet(this.marks,n||J.none)}copy(e=null){if(e==this.content)return this;return new Ye(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Ye(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){if(e==0&&t==this.content.size)return this;return this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return _.empty;let r=this.resolve(e),s=this.resolve(t),o=n?0:r.sharedDepth(t),i=r.start(o),l=r.node(o).content.cut(r.pos-i,s.pos-i);return new _(l,r.depth-o,s.depth-o)}replace(e,t,n){return Ux(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return fo.resolveCached(this,e)}resolveNoCache(e){return fo.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;if(t>e)this.nodesBetween(e,t,(s)=>{if(n.isInSet(s.marks))r=!0;return!r});return r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;if(this.content.size)e+="("+this.content.toStringInner()+")";return cp(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=S.empty,r=0,s=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,r,s),i=o&&o.matchFragment(this.content,t);if(!i||!i.validEnd)return!1;for(let a=r;a<s;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(e).matchType(n),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){if(e.content.size)return this.canReplace(this.childCount,this.childCount,e.content);else return this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Yh(this.type.attrs,this.attrs,"node",this.type.name);let e=J.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];Yh(n.type.attrs,n.attrs,"mark",n.type.name),e=n.addToSet(e)}if(!J.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t)=>t.type.name)}`);this.content.forEach((t)=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}if(this.content.size)e.content=this.content.toJSON();if(this.marks.length)e.marks=this.marks.map((t)=>t.toJSON());return e}static fromJSON(e,t){if(!t)throw RangeError("Invalid input for Node.fromJSON");let n=void 0;if(t.marks){if(!Array.isArray(t.marks))throw RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=S.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}}Ye.prototype.text=void 0;var zh=(()=>{let{stack:e}=Error("/");if(!e||!/\n\s*at\s/.test(e))return(n)=>n;let t=Object.create(null);return(n)=>(t[n],n)})();class oa extends Ye{constructor(e,t,n,r){super(e,t,null,r);if(!n)throw RangeError("Empty text nodes are not allowed");this.text=n}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);return cp(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return zh(this.text.slice(e,t))}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new oa(this.type,this.attrs,this.text,e)}withText(e){if(e==this.text)return this;return new oa(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){if(e==0&&t==this.text.length)return this;return this.withText(zh(this.text.slice(e,t)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function cp(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}function Yh(e,t,n,r){for(let s in t)if(!(s in e))throw RangeError(`Unsupported attribute ${s} for ${n} of type ${r}`);for(let s in e)if(e[s].validate)e[s].validate(t[s])}class Gn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new up(e,t);if(n.next==null)return Gn.empty;let r=dp(n);if(n.next)n.err("Unexpected trailing text");let s=Xx(qx(r));return Gx(s,n),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let s=t;r&&s<n;s++)r=r.matchType(e.child(s).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function s(o,i){let a=o.matchFragment(e,n);if(a&&(!t||a.validEnd))return S.from(i.map((l)=>l.createAndFill()));for(let l=0;l<o.next.length;l++){let{type:c,next:u}=o.next[l];if(!(c.isText||c.hasRequiredAttrs())&&r.indexOf(u)==-1){r.push(u);let d=s(u,i.concat(c));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];while(n.length){let r=n.shift(),s=r.match;if(s.matchType(e)){let o=[];for(let i=r;i.type;i=i.via)o.push(i.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:i,next:a}=s.next[o];if(!i.isLeaf&&!i.hasRequiredAttrs()&&!(i.name in t)&&(!r.type||a.validEnd))n.push({match:i.contentMatch,type:i,via:r}),t[i.name]=!0}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)if(e.indexOf(n.next[r].next)==-1)t(n.next[r].next)}return t(this),e.map((n,r)=>{let s=r+(n.validEnd?"*":" ")+" ";for(let o=0;o<n.next.length;o++)s+=(o?", ":"")+n.next[o].type.name+"->"+e.indexOf(n.next[o].next);return s}).join(`
|
|
6
|
+
`)}}Gn.empty=new Gn(!0);class up{constructor(e,t){if(this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]=="")this.tokens.pop();if(this.tokens[0]=="")this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+" (in content expression '"+this.string+"')")}}function dp(e){let t=[];do t.push(zx(e));while(e.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function zx(e){let t=[];do t.push(Yx(e));while(e.next&&e.next!=")"&&e.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function Yx(e){let t=Kx(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else if(e.eat("{"))t=jx(e,t);else break;return t}function jh(e){if(/\D/.test(e.next))e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function jx(e,t){let n=jh(e),r=n;if(e.eat(","))if(e.next!="}")r=jh(e);else r=-1;if(!e.eat("}"))e.err("Unclosed braced range");return{type:"range",min:n,max:r,expr:t}}function Wx(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let s=[];for(let o in n){let i=n[o];if(i.isInGroup(t))s.push(i)}if(s.length==0)e.err("No node type or group '"+t+"' found");return s}function Kx(e){if(e.eat("(")){let t=dp(e);if(!e.eat(")"))e.err("Missing closing paren");return t}else if(!/\W/.test(e.next)){let t=Wx(e,e.next).map((n)=>{if(e.inline==null)e.inline=n.isInline;else if(e.inline!=n.isInline)e.err("Mixing inline and block content");return{type:"name",value:n}});return e.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}else e.err("Unexpected token '"+e.next+"'")}function qx(e){let t=[[]];return s(o(e,0),n()),t;function n(){return t.push([])-1}function r(i,a,l){let c={term:l,to:a};return t[i].push(c),c}function s(i,a){i.forEach((l)=>l.to=a)}function o(i,a){if(i.type=="choice")return i.exprs.reduce((l,c)=>l.concat(o(c,a)),[]);else if(i.type=="seq")for(let l=0;;l++){let c=o(i.exprs[l],a);if(l==i.exprs.length-1)return c;s(c,a=n())}else if(i.type=="star"){let l=n();return r(a,l),s(o(i.expr,l),l),[r(l)]}else if(i.type=="plus"){let l=n();return s(o(i.expr,a),l),s(o(i.expr,l),l),[r(l)]}else if(i.type=="opt")return[r(a)].concat(o(i.expr,a));else if(i.type=="range"){let l=a;for(let c=0;c<i.min;c++){let u=n();s(o(i.expr,l),u),l=u}if(i.max==-1)s(o(i.expr,l),l);else for(let c=i.min;c<i.max;c++){let u=n();r(l,u),s(o(i.expr,l),u),l=u}return[r(l)]}else if(i.type=="name")return[r(a,void 0,i.value)];else throw Error("Unknown expr type")}}function fp(e,t){return t-e}function Wh(e,t){let n=[];return r(t),n.sort(fp);function r(s){let o=e[s];if(o.length==1&&!o[0].term)return r(o[0].to);n.push(s);for(let i=0;i<o.length;i++){let{term:a,to:l}=o[i];if(!a&&n.indexOf(l)==-1)r(l)}}}function Xx(e){let t=Object.create(null);return n(Wh(e,0));function n(r){let s=[];r.forEach((i)=>{e[i].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u<s.length;u++)if(s[u][0]==a)c=s[u][1];Wh(e,l).forEach((u)=>{if(!c)s.push([a,c=[]]);if(c.indexOf(u)==-1)c.push(u)})})});let o=t[r.join(",")]=new Gn(r.indexOf(e.length-1)>-1);for(let i=0;i<s.length;i++){let a=s[i][1].sort(fp);o.next.push({type:s[i][0],next:t[a.join(",")]||n(a)})}return o}}function Gx(e,t){for(let n=0,r=[e];n<r.length;n++){let s=r[n],o=!s.validEnd,i=[];for(let a=0;a<s.next.length;a++){let{type:l,next:c}=s.next[a];if(i.push(l.name),o&&!(l.isText||l.hasRequiredAttrs()))o=!1;if(r.indexOf(c)==-1)r.push(c)}if(o)t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function hp(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function pp(e,t){let n=Object.create(null);for(let r in e){let s=e[r],o=t&&t[r];if(o===void 0)if(s.hasDefault)o=s.default;else throw RangeError("No value supplied for attribute "+r);else if(s.validate)s.validate(o);n[r]=o}return n}function mp(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new gp(e,r,t[r]);return n}class zr{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=mp(e,n.attrs),this.defaultAttrs=hp(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Gn.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){if(!e&&this.defaultAttrs)return this.defaultAttrs;else return pp(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new Ye(this,this.computeAttrs(e),S.from(t),J.setFrom(n))}createChecked(e=null,t,n){return t=S.from(t),this.checkContent(t),new Ye(this,this.computeAttrs(e),t,J.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=S.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let r=this.contentMatch.matchFragment(t),s=r&&r.fillBefore(S.empty,!0);if(!s)return null;return new Ye(this,e,t.append(s),J.setFrom(n))}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type)){if(!t)t=e.slice(0,n)}else if(t)t.push(e[n]);return!t?e:t.length?t:J.none}static compile(e,t){let n=Object.create(null);e.forEach((s,o)=>n[s]=new zr(s,t,o));let r=t.spec.topNode||"doc";if(!n[r])throw RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw RangeError("Every schema needs a 'text' type");for(let s in n.text.attrs)throw RangeError("The text node type should not have attributes");return n}}function Jx(e,t,n){let r=n.split("|");return(s)=>{let o=s===null?"null":typeof s;if(r.indexOf(o)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${o}`)}}class gp{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Jx(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class po{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=mp(e,r.attrs),this.excluded=null;let s=hp(this.attrs);this.instance=s?new J(this,s):null}create(e=null){if(!e&&this.instance)return this.instance;return new J(this,pp(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((s,o)=>n[s]=new po(s,r++,t,o)),n}removeFromSet(e){for(var t=0;t<e.length;t++)if(e[t].type==this)e=e.slice(0,t).concat(e.slice(t+1)),t--;return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}}class jr{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=yc.from(e.nodes),t.marks=yc.from(e.marks||{}),this.nodes=zr.compile(this.spec.nodes,this),this.marks=po.compile(this.spec.marks,this);let n=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw RangeError(r+" can not be both a node and a mark");let s=this.nodes[r],o=s.spec.content||"",i=s.spec.marks;if(s.contentMatch=n[o]||(n[o]=Gn.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=i=="_"?null:i?Kh(this,i.split(" ")):i==""||!s.inlineContent?[]:null}for(let r in this.marks){let s=this.marks[r],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Kh(this,o.split(" "))}this.nodeFromJSON=(r)=>Ye.fromJSON(this,r),this.markFromJSON=(r)=>J.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e=="string")e=this.nodeType(e);else if(!(e instanceof zr))throw RangeError("Invalid node type: "+e);else if(e.schema!=this)throw RangeError("Node type from different schema used ("+e.name+")");return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new oa(n,n.defaultAttrs,e,J.setFrom(t))}mark(e,t){if(typeof e=="string")e=this.marks[e];return e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError("Unknown node type: "+e);return t}}function Kh(e,t){let n=[];for(let r=0;r<t.length;r++){let s=t[r],o=e.marks[s],i=o;if(o)n.push(o);else for(let a in e.marks){let l=e.marks[a];if(s=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(s)>-1)n.push(i=l)}if(!i)throw SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}function Qx(e){return e.tag!=null}function Zx(e){return e.style!=null}class Nt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach((r)=>{if(Qx(r))this.tags.push(r);else if(Zx(r)){let s=/[^=]*/.exec(r.style)[0];if(n.indexOf(s)<0)n.push(s);this.styles.push(r)}}),this.normalizeLists=!this.tags.some((r)=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let s=e.nodes[r.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let n=new Sc(this,t,!1);return n.addAll(e,J.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Sc(this,t,!0);return n.addAll(e,J.none,t.from,t.to),_.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let s=this.tags[r];if(nA(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,n,r){for(let s=r?this.styles.indexOf(r)+1:0;s<this.styles.length;s++){let o=this.styles[s],i=o.style;if(i.indexOf(e)!=0||o.context&&!n.matchesContext(o.context)||i.length>e.length&&(i.charCodeAt(e.length)!=61||i.slice(e.length+1)!=t))continue;if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}static schemaRules(e){let t=[];function n(r){let s=r.priority==null?50:r.priority,o=0;for(;o<t.length;o++){let i=t[o];if((i.priority==null?50:i.priority)<s)break}t.splice(o,0,r)}for(let r in e.marks){let s=e.marks[r].spec.parseDOM;if(s)s.forEach((o)=>{if(n(o=Xh(o)),!(o.mark||o.ignore||o.clearMark))o.mark=r})}for(let r in e.nodes){let s=e.nodes[r].spec.parseDOM;if(s)s.forEach((o)=>{if(n(o=Xh(o)),!(o.node||o.ignore||o.mark))o.node=r})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Nt(e,Nt.schemaRules(e)))}}var yp={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},eA={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ep={ol:!0,ul:!0},ho=1,bc=2,uo=4;function qh(e,t,n){if(t!=null)return(t?ho:0)|(t==="full"?bc:0);return e&&e.whitespace=="pre"?ho|bc:n&~uo}class lo{constructor(e,t,n,r,s,o){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=o,this.content=[],this.activeMarks=J.none,this.match=s||(o&uo?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(S.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,r;if(r=n.findWrapping(e.type))return this.match=n,r;else return null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ho)){let n=this.content[this.content.length-1],r;if(n&&n.isText&&(r=/[ \t\r\n\u000c]+$/.exec(n.text))){let s=n;if(n.text.length==r[0].length)this.content.pop();else this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-r[0].length))}}let t=S.from(this.content);if(!e&&this.match)t=t.append(this.match.fillBefore(S.empty,!0));return this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){if(this.type)return this.type.inlineContent;if(this.content.length)return this.content[0].isInline;return e.parentNode&&!yp.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Sc{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,s,o=qh(null,t.preserveWhitespace,0)|(n?uo:0);if(r)s=new lo(r.type,r.attrs,J.none,!0,t.topMatch||r.type.contentMatch,o);else if(n)s=new lo(null,null,J.none,!0,null,o);else s=new lo(e.schema.topNodeType,null,J.none,!0,null,o);this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){if(e.nodeType==3)this.addTextNode(e,t);else if(e.nodeType==1)this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,s=r.options&bc?"full":this.localPreserveWS||(r.options&ho)>0,{schema:o}=this.parser;if(s==="full"||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!s){if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let i=r.content[r.content.length-1],a=e.previousSibling;if(!i||a&&a.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))n=n.slice(1)}}else if(s==="full")n=n.replace(/\r\n?/g,`
|
|
7
|
+
`);else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let i=n.split(/\r?\n|\r/);for(let a=0;a<i.length;a++){if(a)this.insertNode(o.linebreakReplacement.create(),t,!0);if(i[a])this.insertNode(o.text(i[a]),t,!/\S/.test(i[a]))}n=""}else n=n.replace(/\r?\n|\r/g," ");if(n)this.insertNode(o.text(n),t,!/\S/.test(n));this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,s=this.top;if(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))this.localPreserveWS=!0;let o=e.nodeName.toLowerCase(),i;if(Ep.hasOwnProperty(o)&&this.parser.normalizeLists)tA(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(a?a.ignore:eA.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){if(a&&a.closeParent)this.open=Math.max(0,this.open-1);else if(a&&a.skip.nodeType)e=a.skip;let l,c=this.needsBlock;if(yp.hasOwnProperty(o)){if(s.content.length&&s.content[0].isInline&&this.open)this.open--,s=this.top;if(l=!0,!s.type)this.needsBlock=!0}else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);if(u)this.addAll(e,u);if(l)this.sync(s);this.needsBlock=c}else{let l=this.readStyles(e,t);if(l)this.addElementByRule(e,a,l,a.consuming===!1?i:void 0)}this.localPreserveWS=r}leafFallback(e,t){if(e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent)this.addTextNode(e.ownerDocument.createTextNode(`
|
|
8
|
+
`),t)}ignoreFallback(e,t){if(e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent))this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let s=this.parser.matchedStyles[r],o=n.getPropertyValue(s);if(o)for(let i=void 0;;){let a=this.parser.matchStyle(s,o,this,i);if(!a)break;if(a.ignore)return null;if(a.clearMark)t=t.filter((l)=>!a.clearMark(l));else t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs));if(a.consuming===!1)i=a;else break}}return t}addElementByRule(e,t,n,r){let s,o;if(t.node){if(o=this.parser.schema.nodes[t.node],!o.isLeaf){let a=this.enter(o,t.attrs||null,n,t.preserveWhitespace);if(a)s=!0,n=a}else if(!this.insertNode(o.create(t.attrs),n,e.nodeName=="BR"))this.leafFallback(e,n)}else{let a=this.parser.schema.marks[t.mark];n=n.concat(a.create(t.attrs))}let i=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((a)=>this.insertNode(a,n,!1));else{let a=e;if(typeof t.contentElement=="string")a=e.querySelector(t.contentElement);else if(typeof t.contentElement=="function")a=t.contentElement(e);else if(t.contentElement)a=t.contentElement;this.findAround(e,a,!0),this.addAll(a,n),this.findAround(e,a,!1)}if(s&&this.sync(i))this.open--}addAll(e,t,n,r){let s=n||0;for(let o=n?e.childNodes[n]:e.firstChild,i=r==null?null:e.childNodes[r];o!=i;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,n){let r,s;for(let o=this.open,i=0;o>=0;o--){let a=this.nodes[o],l=a.findWrapping(e);if(l&&(!r||r.length>l.length+i)){if(r=l,s=a,!l.length)break}if(a.solid){if(n)break;i+=2}}if(!r)return null;this.sync(s);for(let o=0;o<r.length;o++)t=this.enterInner(r[o],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();if(s)t=this.enterInner(s,null,t)}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let s=this.top;if(s.match)s.match=s.match.matchType(e.type);let o=J.none;for(let i of r.concat(e.marks))if(s.type?s.type.allowsMarkType(i.type):Gh(i.type,e.type))o=i.addToSet(o);return s.content.push(e.mark(o)),!0}return!1}enter(e,t,n,r){let s=this.findPlace(e.create(t),n,!1);if(s)s=this.enterInner(e,t,n,!0,r);return s}enterInner(e,t,n,r=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let i=qh(e,s,o.options);if(o.options&uo&&o.content.length==0)i|=uo;let a=J.none;return n=n.filter((l)=>{if(o.type?o.type.allowsMarkType(l.type):Gh(l.type,e))return a=l.addToSet(a),!1;return!0}),this.nodes.push(new lo(e,t,a,r,null,i)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else if(this.localPreserveWS)this.nodes[t].options|=ho;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let r=n.length-1;r>=0;r--)e+=n[r].nodeSize;if(t)e++}return e}findAtPoint(e,t){if(this.find){for(let n=0;n<this.find.length;n++)if(this.find[n].node==e&&this.find[n].offset==t)this.find[n].pos=this.currentPos}}findInside(e){if(this.find){for(let t=0;t<this.find.length;t++)if(this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node))this.find[t].pos=this.currentPos}}findAround(e,t,n){if(e!=t&&this.find){for(let r=0;r<this.find.length;r++)if(this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)){if(t.compareDocumentPosition(this.find[r].node)&(n?2:4))this.find[r].pos=this.currentPos}}}findInText(e){if(this.find){for(let t=0;t<this.find.length;t++)if(this.find[t].node==e)this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset)}}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),s=-(n?n.depth+1:0)+(r?0:1),o=(i,a)=>{for(;i>=0;i--){let l=t[i];if(l==""){if(i==t.length-1||i==0)continue;for(;a>=s;a--)if(o(i-1,a))return!0;return!1}else{let c=a>0||a==0&&r?this.nodes[a].type:n&&a>=s?n.node(a-s).type:null;if(!c||c.name!=l&&!c.isInGroup(l))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}}function tA(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let r=t.nodeType==1?t.nodeName.toLowerCase():null;if(r&&Ep.hasOwnProperty(r)&&n)n.appendChild(t),t=n;else if(r=="li")n=t;else if(r)n=null}}function nA(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Xh(e){let t={};for(let n in e)t[n]=e[n];return t}function Gh(e,t){let n=t.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(e))continue;let o=[],i=(a)=>{o.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:u}=a.edge(l);if(c==t)return!0;if(o.indexOf(u)<0&&i(u))return!0}};if(i(s.contentMatch))return!0}}class jt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){if(!n)n=ta(t).createDocumentFragment();let r=n,s=[];return e.forEach((o)=>{if(s.length||o.marks.length){let i=0,a=0;while(i<s.length&&a<o.marks.length){let l=o.marks[a];if(!this.marks[l.type.name]){a++;continue}if(!l.eq(s[i][0])||l.type.spec.spanning===!1)break;i++,a++}while(i<s.length)r=s.pop()[1];while(a<o.marks.length){let l=o.marks[a++],c=this.serializeMark(l,o.isInline,t);if(c)s.push([l,r]),r.appendChild(c.dom),r=c.contentDOM||c.dom}}r.appendChild(this.serializeNodeInner(o,t))}),n}serializeNodeInner(e,t){if(e.isText)return ta(t).createTextNode(e.text);let{dom:n,contentDOM:r}=na(ta(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let s=this.serializeMark(e.marks[r],e.isInline,t);if(s)(s.contentDOM||s.dom).appendChild(n),n=s.dom}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&na(ta(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){if(typeof t=="string")return{dom:e.createTextNode(t)};return na(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new jt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Jh(e.nodes);if(!t.text)t.text=(n)=>n.text;return t}static marksFromSchema(e){return Jh(e.marks)}}function Jh(e){let t={};for(let n in e){let r=e[n].spec.toDOM;if(r)t[n]=r}return t}function ta(e){return e.document||window.document}var Qh=new WeakMap;function rA(e){let t=Qh.get(e);if(t===void 0)Qh.set(e,t=sA(e));return t}function sA(e){let t=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string"){if(!t)t=[];t.push(r)}else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(e),t}function na(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let s=t[0],o;if(typeof s!="string")throw RangeError("Invalid array passed to renderSpec");if(r&&(o=rA(r))&&o.indexOf(t)>-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=s.indexOf(" ");if(i>0)n=s.slice(0,i),s=s.slice(i+1);let a,l=n?e.createElementNS(n,s):e.createElement(s),c=t[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");if(f>0)l.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]);else if(d=="style"&&l.style)l.style.cssText=c[d];else l.setAttribute(d,c[d])}}for(let d=u;d<t.length;d++){let f=t[d];if(f===0){if(d<t.length-1||d>u)throw RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else if(typeof f=="string")l.appendChild(e.createTextNode(f));else{let{dom:h,contentDOM:p}=na(e,f,n,r);if(l.appendChild(h),p){if(a)throw RangeError("Multiple content holes");a=p}}}return{dom:l,contentDOM:a}}var Ap=65535,wp=Math.pow(2,16);function iA(e,t){return e+t*wp}function Tp(e){return e&Ap}function aA(e){return(e-(e&Ap))/wp}var Cp=1,kp=2,ia=4,_p=8;class aa{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&_p)>0}get deletedBefore(){return(this.delInfo&(Cp|ia))>0}get deletedAfter(){return(this.delInfo&(kp|ia))>0}get deletedAcross(){return(this.delInfo&ia)>0}}class it{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&it.empty)return it.empty}recover(e){let t=0,n=Tp(e);if(!this.inverted)for(let r=0;r<n;r++)t+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[n*3]+t+aA(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let i=0;i<this.ranges.length;i+=3){let a=this.ranges[i]-(this.inverted?r:0);if(a>e)break;let l=this.ranges[i+s],c=this.ranges[i+o],u=a+l;if(e<=u){let d=!l?t:e==a?-1:e==u?1:t,f=a+r+(d<0?0:c);if(n)return f;let h=e==(t<0?a:u)?null:iA(i/3,e-a),p=0;if(l){if(p|=e==a?kp:e==u?Cp:ia,t<0?e!=a:e!=u)p|=_p}return new aa(f,p,h)}r+=c-l}return n?e+r:new aa(e+r,0,null)}touches(e,t){let n=0,r=Tp(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let i=0;i<this.ranges.length;i+=3){let a=this.ranges[i]-(this.inverted?n:0);if(a>e)break;let l=this.ranges[i+s],c=a+l;if(e<=c&&i==r*3)return!0;n+=this.ranges[i+o]-l}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,s=0;r<this.ranges.length;r+=3){let o=this.ranges[r],i=o-(this.inverted?s:0),a=o+(this.inverted?0:s),l=this.ranges[r+t],c=this.ranges[r+n];e(i,i+l,a,a+c),s+=c-l}}invert(){return new it(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?it.empty:new it(e<0?[0,-e,0]:[0,0,e])}}it.empty=new it([]);class Kr{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Kr(this._maps,this.mirror,e,t)}appendMap(e,t){if(!this.ownData)this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0;if(this.to=this._maps.push(e),t!=null)this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){if(!this.mirror)this.mirror=[];this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let e=new Kr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],i=o.mapResult(e,t);if(i.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new aa(e,r,null)}}var xc=Object.create(null);class be{getMap(){return it.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError("Invalid input for Step.fromJSON");let n=xc[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in xc)throw RangeError("Duplicate use of step JSON ID "+e);return xc[e]=t,t.prototype.jsonID=e,t}}class Ee{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Ee(e,null)}static fail(e){return new Ee(null,e)}static fromReplace(e,t,n,r){try{return Ee.ok(e.replace(t,n,r))}catch(s){if(s instanceof Xn)return Ee.fail(s.message);throw s}}}function Cc(e,t,n){let r=[];for(let s=0;s<e.childCount;s++){let o=e.child(s);if(o.content.size)o=o.copy(Cc(o.content,t,o));if(o.isInline)o=t(o,n,s);r.push(o)}return S.fromArray(r)}class Wt extends be{constructor(e,t,n){super();this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),s=new _(Cc(t.content,(o,i)=>{if(!o.isAtom||!i.type.allowsMarkType(this.mark.type))return o;return o.mark(this.mark.addToSet(o.marks))},r),t.openStart,t.openEnd);return Ee.fromReplace(e,this.from,this.to,s)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(n,r)=>{if(n.isInline&&n.isAtom){let s=this.mark.addToSet(n.marks);if(!J.sameSet(s,n.marks)){let o=Math.max(this.from,r),i=Math.min(this.to,r+n.nodeSize);la(Et,o,i,this.mark,t);for(let a of n.marks)if(!a.isInSet(s))la(Wt,o,i,a,t)}}}),t.length==1?t[0]:new Jn(t)}map(e){let t=e.map(this.from,1),n=e.map(this.to,-1);if(t>=n)return null;return new Wt(t,n,this.mark)}merge(e){if(e instanceof Wt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from)return new Wt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark);return null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw RangeError("Invalid input for AddMarkStep.fromJSON");return new Wt(t.from,t.to,e.markFromJSON(t.mark))}}be.jsonID("addMark",Wt);class Et extends be{constructor(e,t,n){super();this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new _(Cc(t.content,(r)=>r.mark(this.mark.removeFromSet(r.marks)),e),t.openStart,t.openEnd);return Ee.fromReplace(e,this.from,this.to,n)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(n,r)=>{if(n.isInline&&n.isAtom&&this.mark.isInSet(n.marks))la(Wt,Math.max(this.from,r),Math.min(this.to,r+n.nodeSize),this.mark,t)}),t.length==1?t[0]:new Jn(t)}map(e){let t=e.map(this.from,1),n=e.map(this.to,-1);if(t>=n)return null;return new Et(t,n,this.mark)}merge(e){if(e instanceof Et&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from)return new Et(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark);return null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Et(t.from,t.to,e.markFromJSON(t.mark))}}be.jsonID("removeMark",Et);function la(e,t,n,r,s){let o=s.length?s[s.length-1]:null;if(o&&o instanceof e&&o.to==t&&o.mark.eq(r))s[s.length-1]=new e(o.from,n,r);else s.push(new e(t,n,r))}class Jn extends be{constructor(e){super();this.steps=e}apply(e){for(let t of this.steps){let n=t.apply(e);if(!n.doc)return n;e=n.doc}return new Ee(e,null)}invert(e){return new Jn(this.steps.map((t)=>t.invert(e)))}map(e){let t=[];for(let n of this.steps){let r=n.map(e);if(r)t.push(r)}return t.length?new Jn(t):null}toJSON(){return{stepType:"markSet",steps:this.steps.map((e)=>e.toJSON())}}static fromJSON(e,t){if(!Array.isArray(t.steps)||!t.steps.every((n)=>n.stepType=="addMark"||n.stepType=="removeMark"))throw RangeError("Invalid JSON for MarkSetStep");return new Jn(t.steps.map((n)=>be.fromJSON(e,n)))}}be.jsonID("markSet",Jn);class hn extends be{constructor(e,t){super();this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ee.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Ee.fromReplace(e,this.pos,this.pos+1,new _(S.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let r=0;r<t.marks.length;r++)if(!t.marks[r].isInSet(n))return new hn(this.pos,t.marks[r]);return new hn(this.pos,this.mark)}}return new Qn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new hn(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new hn(t.pos,e.markFromJSON(t.mark))}}be.jsonID("addNodeMark",hn);class Qn extends be{constructor(e,t){super();this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ee.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Ee.fromReplace(e,this.pos,this.pos+1,new _(S.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(!t||!this.mark.isInSet(t.marks))return this;return new hn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Qn(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Qn(t.pos,e.markFromJSON(t.mark))}}be.jsonID("removeNodeMark",Qn);class se extends be{constructor(e,t,n,r=!1){super();this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){if(this.structure&&wc(e,this.from,this.to))return Ee.fail("Structure replace would overwrite content");return Ee.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new it([this.from,this.to-this.from,this.slice.size])}invert(e){return new se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&se.MAP_BIAS<0?t:e.mapResult(this.from,1);if(n.deletedAcross&&t.deletedAcross)return null;return new se(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof se)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?_.empty:new _(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new se(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?_.empty:new _(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new se(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};if(this.slice.size)e.slice=this.slice.toJSON();if(this.structure)e.structure=!0;return e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw RangeError("Invalid input for ReplaceStep.fromJSON");return new se(t.from,t.to,_.fromJSON(e,t.slice),!!t.structure)}}se.MAP_BIAS=1;be.jsonID("replace",se);class fe extends be{constructor(e,t,n,r,s,o,i=!1){super();this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=s,this.insert=o,this.structure=i}apply(e){if(this.structure&&(wc(e,this.from,this.gapFrom)||wc(e,this.gapTo,this.to)))return Ee.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Ee.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);if(!n)return Ee.fail("Content does not fit in gap");return Ee.fromReplace(e,this.from,this.to,n)}getMap(){return new it([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new fe(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);if(t.deletedAcross&&n.deletedAcross||r<t.pos||s>n.pos||r>s)return null;return new fe(t.pos,n.pos,r,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};if(this.slice.size)e.slice=this.slice.toJSON();if(this.structure)e.structure=!0;return e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new fe(t.from,t.to,t.gapFrom,t.gapTo,_.fromJSON(e,t.slice),t.insert,!!t.structure)}}be.jsonID("replaceAround",fe);function wc(e,t,n){let r=e.resolve(t),s=n-t,o=r.depth;while(s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount)o--,s--;if(s>0){let i=r.node(o).maybeChild(r.indexAfter(o));while(s>0){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function lA(e,t,n,r){let s=[];e.doc.nodesBetween(t,n,(o,i,a)=>{if(!o.isInline)return;let l=o.marks;if(!r.isInSet(l)&&a.type.allowsMarkType(r.type)){let c=Math.max(i,t),u=Math.min(i+o.nodeSize,n);la(Wt,c,u,r,s)}}),s.forEach((o)=>e.step(o))}function cA(e,t,n,r){let s=[],o=0;e.doc.nodesBetween(t,n,(i,a)=>{if(!i.isInline||!i.isAtom)return;o++;let l=null;if(r instanceof po){let c=i.marks,u;while(u=r.isInSet(c))(l||(l=[])).push(u),c=u.removeFromSet(c)}else if(r){if(r.isInSet(i.marks))l=[r]}else l=i.marks;if(l&&l.length){let c=Math.min(a+i.nodeSize,n);for(let u=0;u<l.length;u++){let d=l[u],f;for(let h=0;h<s.length;h++){let p=s[h];if(p.step==o-1&&d.eq(s[h].style))f=p}if(f)f.to=c,f.step=o;else s.push({style:d,from:Math.max(a,t),to:c,step:o})}}}),s.forEach((i)=>e.step(new Et(i.from,i.to,i.style)))}function kc(e,t,n,r=n.contentMatch,s=!0){let o=e.doc.nodeAt(t),i=[],a=t+1;for(let l=0;l<o.childCount;l++){let c=o.child(l),u=a+c.nodeSize,d=r.matchType(c.type);if(!d)i.push(new se(a,u,_.empty));else{r=d;for(let f=0;f<c.marks.length;f++)if(!n.allowsMarkType(c.marks[f].type))e.step(new Et(a,u,c.marks[f]));if(s&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;while(f=h.exec(c.text)){if(!p)p=new _(S.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0);i.push(new se(a+f.index,a+f.index+f[0].length,p))}}}a=u}if(!r.validEnd){let l=r.fillBefore(S.empty,!0);e.replace(a,a,new _(l,0,0))}for(let l=i.length-1;l>=0;l--)e.step(i[l])}function uA(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Kt(e){let n=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let r=e.depth,s=0,o=0;;--r){let i=e.$from.node(r),a=e.$from.index(r)+s,l=e.$to.indexAfter(r)-o;if(r<e.depth&&i.canReplace(a,l,n))return r;if(r==0||i.type.spec.isolating||!uA(i,a,l))break;if(a)s=1;if(l<i.childCount)o=1}return null}function dA(e,t,n){let{$from:r,$to:s,depth:o}=t,i=r.before(o+1),a=s.after(o+1),l=i,c=a,u=S.empty,d=0;for(let p=o,m=!1;p>n;p--)if(m||r.index(p)>0)m=!0,u=S.from(r.node(p).copy(u)),d++;else l--;let f=S.empty,h=0;for(let p=o,m=!1;p>n;p--)if(m||s.after(p+1)<s.end(p))m=!0,f=S.from(s.node(p).copy(f)),h++;else c++;e.step(new fe(l,c,i,a,new _(u.append(f),d,h),u.size-d,!0))}function Eo(e,t,n=null,r=e){let s=fA(e,t),o=s&&hA(r,t);if(!o)return null;return s.map(bp).concat({type:t,attrs:n}).concat(o.map(bp))}function bp(e){return{type:e,attrs:null}}function fA(e,t){let{parent:n,startIndex:r,endIndex:s}=e,o=n.contentMatchAt(r).findWrapping(t);if(!o)return null;let i=o.length?o[0]:t;return n.canReplaceWith(r,s,i)?o:null}function hA(e,t){let{parent:n,startIndex:r,endIndex:s}=e,o=n.child(r),i=t.contentMatch.findWrapping(o.type);if(!i)return null;let l=(i.length?i[i.length-1]:t).contentMatch;for(let c=r;l&&c<s;c++)l=l.matchType(n.child(c).type);if(!l||!l.validEnd)return null;return i}function pA(e,t,n){let r=S.empty;for(let i=n.length-1;i>=0;i--){if(r.size){let a=n[i].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=S.from(n[i].type.create(n[i].attrs,r))}let{start:s,end:o}=t;e.step(new fe(s,o,s,o,new _(r,0,0),n.length,!0))}function mA(e,t,n,r,s){if(!r.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let o=e.steps.length;e.doc.nodesBetween(t,n,(i,a)=>{let l=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(r,l)&&gA(e.doc,e.mapping.slice(o).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);if(h&&!p)c=!1;else if(!h&&p)c=!0}if(c===!1)Op(e,i,a,o);kc(e,e.mapping.slice(o).map(a,1),r,void 0,c===null);let u=e.mapping.slice(o),d=u.map(a,1),f=u.map(a+i.nodeSize,1);if(e.step(new fe(d,f,d+1,f-1,new _(S.from(r.create(l,null,i.marks)),0,0),1,!0)),c===!0)Np(e,i,a,o);return!1}})}function Np(e,t,n,r){t.forEach((s,o)=>{if(s.isText){let i,a=/\r?\n|\r/g;while(i=a.exec(s.text)){let l=e.mapping.slice(r).map(n+1+o+i.index);e.replaceWith(l,l+1,t.type.schema.linebreakReplacement.create())}}})}function Op(e,t,n,r){t.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+o);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
9
|
+
`))}})}function gA(e,t,n){let r=e.resolve(t),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function yA(e,t,n,r,s){let o=e.doc.nodeAt(t);if(!o)throw RangeError("No node at given position");if(!n)n=o.type;let i=n.create(r,null,s||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,i);if(!n.validContent(o.content))throw RangeError("Invalid content for node type "+n.name);e.step(new fe(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new _(S.from(i),0,0),1,!0))}function mt(e,t,n=1,r){let s=e.resolve(t),o=s.depth-n,i=r&&r[r.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=n-2;c>o;c--,u--){let d=s.node(c),f=s.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];if(p)h=h.replaceChild(0,p.type.create(p.attrs));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let a=s.indexAfter(o),l=r&&r[0];return s.node(o).canReplaceWith(a,a,l?l.type:s.node(o+1).type)}function EA(e,t,n=1,r){let s=e.doc.resolve(t),o=S.empty,i=S.empty;for(let a=s.depth,l=s.depth-n,c=n-1;a>l;a--,c--){o=S.from(s.node(a).copy(o));let u=r&&r[c];i=S.from(u?u.type.create(u.attrs,i):s.node(a).copy(i))}e.step(new se(t,t,new _(o.append(i),n,n),!0))}function Ot(e,t){let n=e.resolve(t),r=n.index();return Ip(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function TA(e,t){if(!t.content.size)e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let s=0;s<t.childCount;s++){let o=t.child(s),i=o.type==r?e.type.schema.nodes.text:o.type;if(n=n.matchType(i),!n)return!1;if(!e.type.allowsMarks(o.marks))return!1}return n.validEnd}function Ip(e,t){return!!(e&&t&&!e.isLeaf&&TA(e,t))}function Xr(e,t,n=-1){let r=e.resolve(t);for(let s=r.depth;;s--){let o,i,a=r.index(s);if(s==r.depth)o=r.nodeBefore,i=r.nodeAfter;else if(n>0)o=r.node(s+1),a++,i=r.node(s).maybeChild(a);else o=r.node(s).maybeChild(a-1),i=r.node(s+1);if(o&&!o.isTextblock&&Ip(o,i)&&r.node(s).canReplace(a,a+1))return t;if(s==0)break;t=n<0?r.before(s):r.after(s)}}function bA(e,t,n){let r=null,{linebreakReplacement:s}=e.doc.type.schema,o=e.doc.resolve(t-n),i=o.node().type;if(s&&i.inlineContent){let u=i.whitespace=="pre",d=!!i.contentMatch.matchType(s);if(u&&!d)r=!1;else if(!u&&d)r=!0}let a=e.steps.length;if(r===!1){let u=e.doc.resolve(t+n);Op(e,u.node(),u.before(),a)}if(i.inlineContent)kc(e,t+n-1,i,o.node().contentMatchAt(o.index()),r==null);let l=e.mapping.slice(a),c=l.map(t-n);if(e.step(new se(c,l.map(t+n,-1),_.empty,!0)),r===!0){let u=e.doc.resolve(c);Np(e,u.node(),u.before(),e.steps.length)}return e}function SA(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let o=r.index(s);if(r.node(s).canReplaceWith(o,o,n))return r.before(s+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let o=r.indexAfter(s);if(r.node(s).canReplaceWith(o,o,n))return r.after(s+1);if(o<r.node(s).childCount)return null}return null}function ca(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let s=n.content;for(let o=0;o<n.openStart;o++)s=s.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.size?2:1);o++)for(let i=r.depth;i>=0;i--){let a=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,l=r.index(i)+(a>0?1:0),c=r.node(i),u=!1;if(o==1)u=c.canReplace(l,l,s);else{let d=c.contentMatchAt(l).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(l,l,d[0])}if(u)return a==0?r.pos:a<0?r.before(i+1):r.after(i+1)}return null}function Zn(e,t,n=t,r=_.empty){if(t==n&&!r.size)return null;let s=e.resolve(t),o=e.resolve(n);if(Mp(s,o,r))return new se(t,n,r);return new Rp(s,o,r).fit()}function Mp(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}class Rp{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=S.empty;for(let r=0;r<=e.depth;r++){let s=e.node(r);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=S.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){while(this.unplaced.size){let l=this.findFittable();if(l)this.placeNodes(l);else this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let s=this.placed,o=n.depth,i=r.depth;while(o&&i&&s.childCount==1)s=s.firstChild.content,o--,i--;let a=new _(s,o,i);if(e>-1)return new fe(n.pos,e,this.$to.pos,this.$to.end(),a,t);if(a.size||n.pos!=this.$to.pos)return new se(n.pos,r.pos,a);return null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let s=t.firstChild;if(t.childCount>1)r=0;if(s.type.spec.isolating&&r<=n){e=n;break}t=s.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let r,s=null;if(n)s=Sp(this.unplaced.content,n-1).firstChild,r=s.content;else r=this.unplaced.content;let o=r.firstChild;for(let i=this.depth;i>=0;i--){let{type:a,match:l}=this.frontier[i],c,u=null;if(t==1&&(o?l.matchType(o.type)||(u=l.fillBefore(S.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:n,frontierDepth:i,parent:s,inject:u};else if(t==2&&o&&(c=l.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:i,parent:s,wrap:c};if(s&&l.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced;if(xp(e,-1)<=t)return!1;if(this.unplaced.size>1&&xp(e,1)>n)n++;return this.unplaced=new _(e,t+1,n),!0}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Sp(e,t);if(r.childCount<=1&&t>0){let s=e.size-t<=t+r.size;this.unplaced=new _(mo(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new _(mo(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:s}){while(this.depth>t)this.closeFrontierNode();if(s)for(let p=0;p<s.length;p++)this.openFrontierNode(s[p]);let o=this.unplaced,i=n?n.content:o.content,a=o.openStart-e,l=0,c=[],{match:u,type:d}=this.frontier[t];if(r){for(let p=0;p<r.childCount;p++)c.push(r.child(p));u=u.matchFragment(r)}let f=i.size+e-(o.content.size-o.openEnd);while(l<i.childCount){let p=i.child(l),m=u.matchType(p.type);if(!m)break;if(l++,l>1||a==0||p.content.size)u=m,c.push(Dp(p.mark(d.allowedMarks(p.marks)),l==1?a:0,l==i.childCount?f:-1))}let h=l==i.childCount;if(!h)f=-1;if(this.placed=go(this.placed,t,S.from(c)),this.frontier[t].match=u,h&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1)this.closeFrontierNode();for(let p=0,m=c[c.length-1];m&&p<f;p++)this.frontier.push({type:m.type,match:m.contentMatchAt(m.childCount)}),m=m.lastChild;this.unplaced=!h?new _(mo(o.content,e,l),e,o.openEnd):e==0?_.empty:new _(mo(o.content,e-1,1),e-1,f<0?o.openEnd:e-1)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ac(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);while(n>1&&r==this.$to.end(--n))++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Ac(e,t,r,n,s);if(!o)continue;for(let i=t-1;i>=0;i--){let{match:a,type:l}=this.frontier[i],c=Ac(e,i,l,a,!0);if(!c||c.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;while(this.depth>t.depth)this.closeFrontierNode();if(t.fit.childCount)this.placed=go(this.placed,t.depth,t.fit);e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let r=e.node(n),s=r.type.contentMatch.fillBefore(r.content,!0,e.index(n));this.openFrontierNode(r.type,r.attrs,s)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=go(this.placed,this.depth,S.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(S.empty,!0);if(t.childCount)this.placed=go(this.placed,this.frontier.length,t)}}function mo(e,t,n){if(t==0)return e.cutByIndex(n,e.childCount);return e.replaceChild(0,e.firstChild.copy(mo(e.firstChild.content,t-1,n)))}function go(e,t,n){if(t==0)return e.append(n);return e.replaceChild(e.childCount-1,e.lastChild.copy(go(e.lastChild.content,t-1,n)))}function Sp(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Dp(e,t,n){if(t<=0)return e;let r=e.content;if(t>1)r=r.replaceChild(0,Dp(r.firstChild,t-1,r.childCount==1?n-1:0));if(t>0){if(r=e.type.contentMatch.fillBefore(r).append(r),n<=0)r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(S.empty,!0))}return e.copy(r)}function Ac(e,t,n,r,s){let o=e.node(t),i=s?e.indexAfter(t):e.index(t);if(i==o.childCount&&!n.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,i);return a&&!xA(n,o.content,i)?a:null}function xA(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function AA(e){return e.spec.defining||e.spec.definingForContent}function xp(e,t){for(let n=0;;n++){let r=t<0?e.firstChild:e.lastChild;if(!r||r.isAtom)return n;e=r.content}}function wA(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let s=e.doc.resolve(t),o=e.doc.resolve(n);if(Mp(s,o,r))return e.step(new se(t,n,r));let i=Lp(s,o);if(i[i.length-1]==0)i.pop();let a=-(s.depth+1);i.unshift(a);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;if(i.indexOf(f)>-1)a=f;else if(s.before(f)==h)i.splice(1,0,-f)}let l=i.indexOf(a),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=AA(h.type);if(p&&!h.sameMarkup(s.node(Math.abs(a)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(!p)continue;for(let m=0;m<i.length;m++){let g=i[(m+l)%i.length],E=!0;if(g<0)E=!1,g=-g;let x=s.node(g-1),w=s.index(g-1);if(x.canReplaceWith(w,w,p.type,p.marks))return e.replace(s.before(g),E?o.after(g):n,new _(vp(r.content,0,r.openStart,h),h,r.openEnd))}}let d=e.steps.length;for(let f=i.length-1;f>=0;f--){if(e.replace(t,n,r),e.steps.length>d)break;let h=i[f];if(h<0)continue;t=s.before(h),n=o.after(h)}}function vp(e,t,n,r,s){if(t<n){let o=e.firstChild;e=e.replaceChild(0,o.copy(vp(o.content,t+1,n,r,o)))}if(t>r){let o=s.contentMatchAt(0),i=o.fillBefore(e).append(e);e=i.append(o.matchFragment(i).fillBefore(S.empty,!0))}return e}function CA(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let s=SA(e.doc,t,r.type);if(s!=null)t=n=s}e.replaceRange(t,n,new _(S.from(r),0,0))}function kA(e,t,n){let r=e.doc.resolve(t),s=e.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let i=r.sharedDepth(n),a=!1;for(let l=r.depth;l>i;l--)if(r.node(l).type.spec.isolating)a=!0;for(let l=s.depth;l>i;l--)if(s.node(l).type.spec.isolating)a=!0;if(!a){for(let l=r.depth;l>0&&t==r.start(l);l--)t=r.before(l);for(let l=s.depth;l>0&&n==s.start(l);l--)n=s.before(l);r=e.doc.resolve(t),s=e.doc.resolve(n)}}let o=Lp(r,s);for(let i=0;i<o.length;i++){let a=o[i],l=i==o.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return e.delete(r.start(a),s.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),s.indexAfter(a-1))))return e.delete(r.before(a),s.after(a))}for(let i=1;i<=r.depth&&i<=s.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&s.end(i)-n!=s.depth-i&&r.start(i-1)==s.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),s.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}function Lp(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let s=r;s>=0;s--){let o=e.start(s);if(o<e.pos-(e.depth-s)||t.end(s)>t.pos+(t.depth-s)||e.node(s).type.spec.isolating||t.node(s).type.spec.isolating)break;if(o==t.start(s)||s==e.depth&&s==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&s&&t.start(s-1)==o-1)n.push(s)}return n}class Wr extends be{constructor(e,t,n){super();this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return Ee.fail("No node at attribute step's position");let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return Ee.fromReplace(e,this.pos,this.pos+1,new _(S.from(r),0,t.isLeaf?0:1))}getMap(){return it.empty}invert(e){return new Wr(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Wr(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw RangeError("Invalid input for AttrStep.fromJSON");return new Wr(t.pos,t.attr,t.value)}}be.jsonID("attr",Wr);class yo extends be{constructor(e,t){super();this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return Ee.ok(n)}getMap(){return it.empty}invert(e){return new yo(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw RangeError("Invalid input for DocAttrStep.fromJSON");return new yo(t.attr,t.value)}}be.jsonID("docAttr",yo);var qr=class extends Error{};qr=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n};qr.prototype=Object.create(Error.prototype);qr.prototype.constructor=qr;qr.prototype.name="TransformError";class To{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Kr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new qr(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);if(!t.failed)this.addStep(e,t.doc);return t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];if(n)e=r.map(e,1),t=r.map(t,-1);r.forEach((s,o,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=_.empty){let r=Zn(this.doc,e,t,n);if(r)this.step(r);return this}replaceWith(e,t,n){return this.replace(e,t,new _(S.from(n),0,0))}delete(e,t){return this.replace(e,t,_.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return wA(this,e,t,n),this}replaceRangeWith(e,t,n){return CA(this,e,t,n),this}deleteRange(e,t){return kA(this,e,t),this}lift(e,t){return dA(this,e,t),this}join(e,t=1){return bA(this,e,t),this}wrap(e,t){return pA(this,e,t),this}setBlockType(e,t=e,n,r=null){return mA(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return yA(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Wr(e,t,n)),this}setDocAttribute(e,t){return this.step(new yo(e,t)),this}addNodeMark(e,t){return this.step(new hn(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError("No node at position "+e);if(t instanceof J){if(t.isInSet(n.marks))this.step(new Qn(e,t))}else{let r=n.marks,s,o=[];while(s=t.isInSet(r))o.push(new Qn(e,s)),r=s.removeFromSet(r);for(let i=o.length-1;i>=0;i--)this.step(o[i])}return this}split(e,t=1,n){return EA(this,e,t,n),this}addMark(e,t,n){return lA(this,e,t,n),this}removeMark(e,t,n){return cA(this,e,t,n),this}clearIncompatible(e,t,n){return kc(this,e,t,n),this}}var _c=Object.create(null);class U{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Oc(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=_.empty){let n=t.content.lastChild,r=null;for(let i=0;i<t.openEnd;i++)r=n,n=n.lastChild;let s=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:a,$to:l}=o[i],c=e.mapping.slice(s);if(e.replaceRange(c.map(a.pos),c.map(l.pos),i?_.empty:t),i==0)Fp(e,s,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:o,$to:i}=r[s],a=e.mapping.slice(n),l=a.map(o.pos),c=a.map(i.pos);if(s)e.deleteRange(l,c);else e.replaceRangeWith(l,c,t),Fp(e,n,t.isInline?-1:1)}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new I(e):Gr(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let s=e.depth-1;s>=0;s--){let o=t<0?Gr(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):Gr(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new we(e.node(0))}static atStart(e){return Gr(e,e,0,0,1)||new we(e)}static atEnd(e){return Gr(e,e,e.content.size,e.childCount,-1)||new we(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError("Invalid input for Selection.fromJSON");let n=_c[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in _c)throw RangeError("Duplicate use of selection JSON ID "+e);return _c[e]=t,t.prototype.jsonID=e,t}getBookmark(){return I.between(this.$anchor,this.$head).getBookmark()}}U.prototype.visible=!0;class Oc{constructor(e,t){this.$from=e,this.$to=t}}var Pp=!1;function Bp(e){if(!Pp&&!e.parent.inlineContent)Pp=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")")}class I extends U{constructor(e,t=e){Bp(e),Bp(t);super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return U.near(n);let r=e.resolve(t.map(this.anchor));return new I(r.parent.inlineContent?r:n,n)}replace(e,t=_.empty){if(super.replace(e,t),t==_.empty){let n=this.$from.marksAcross(this.$to);if(n)e.ensureMarks(n)}}eq(e){return e instanceof I&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new fa(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw RangeError("Invalid input for TextSelection.fromJSON");return new I(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(!n||r)n=r>=0?1:-1;if(!t.parent.inlineContent){let s=U.findFrom(t,n,!0)||U.findFrom(t,-n,!0);if(s)t=s.$head;else return U.near(t,n)}if(!e.parent.inlineContent){if(r==0)e=t;else if(e=(U.findFrom(e,-n,!0)||U.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=r<0)e=t}return new I(e,t)}}U.jsonID("text",I);class fa{constructor(e,t){this.anchor=e,this.head=t}map(e){return new fa(e.map(this.anchor),e.map(this.head))}resolve(e){return I.between(e.resolve(this.anchor),e.resolve(this.head))}}class M extends U{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n);this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),s=e.resolve(r);if(n)return U.near(s);return new M(s)}content(){return new _(S.from(this.node),0,0)}eq(e){return e instanceof M&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ic(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw RangeError("Invalid input for NodeSelection.fromJSON");return new M(e.resolve(t.anchor))}static create(e,t){return new M(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}M.prototype.visible=!1;U.jsonID("node",M);class Ic{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new fa(n,n):new Ic(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;if(n&&M.isSelectable(n))return new M(t);return U.near(t)}}class we extends U{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=_.empty){if(t==_.empty){e.delete(0,e.doc.content.size);let n=U.atStart(e.doc);if(!n.eq(e.selection))e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new we(e)}map(e){return new we(e)}eq(e){return e instanceof we}getBookmark(){return _A}}U.jsonID("all",we);var _A={map(){return this},resolve(e){return new we(e)}};function Gr(e,t,n,r,s,o=!1){if(t.inlineContent)return I.create(e,n);for(let i=r-(s>0?0:1);s>0?i<t.childCount:i>=0;i+=s){let a=t.child(i);if(!a.isAtom){let l=Gr(e,a,n+s,s<0?a.childCount:0,s,o);if(l)return l}else if(!o&&M.isSelectable(a))return M.create(e,n-(s<0?a.nodeSize:0));n+=a.nodeSize*s}return null}function Fp(e,t,n){let r=e.steps.length-1;if(r<t)return;let s=e.steps[r];if(!(s instanceof se||s instanceof fe))return;let o=e.mapping.maps[r],i;o.forEach((a,l,c,u)=>{if(i==null)i=u}),e.setSelection(U.near(e.doc.resolve(i),n))}var Up=1,ua=2,Hp=4;class Vp extends To{constructor(e){super(e.doc);this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){if(this.curSelectionFor<this.steps.length)this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length;return this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Up)&~ua,this.storedMarks=null,this}get selectionSet(){return(this.updated&Up)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ua,this}ensureMarks(e){if(!J.sameSet(this.storedMarks||this.selection.$from.marks(),e))this.setStoredMarks(e);return this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&ua)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~ua,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;if(t)e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||J.none));return n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null){if(!e)return this.deleteSelection();return this.replaceSelectionWith(r.text(e),!0)}else{if(n==null)n=t;if(!e)return this.deleteRange(t,n);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=n==t?o.marks():o.marksAcross(this.doc.resolve(n))}if(this.replaceRangeWith(t,n,r.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length)this.setSelection(U.near(this.selection.$to));return this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Hp,this}get scrolledIntoView(){return(this.updated&Hp)>0}}function $p(e,t){return!t||!e?e:e.bind(t)}class Jr{constructor(e,t,n){this.name=e,this.init=$p(t.init,n),this.apply=$p(t.apply,n)}}var NA=[new Jr("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new Jr("selection",{init(e,t){return e.selection||U.atStart(t.doc)},apply(e){return e.selection}}),new Jr("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new Jr("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})];class da{constructor(e,t){if(this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=NA.slice(),t)t.forEach((n)=>{if(this.pluginsByKey[n.key])throw RangeError("Adding different instances of a keyed plugin ("+n.key+")");if(this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state)this.fields.push(new Jr(n.key,n.spec.state,n))})}}class It{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let i=this.config.plugins[o];if(i.spec.appendTransaction){let a=r?r[o].n:0,l=r?r[o].state:this,c=a<t.length&&i.spec.appendTransaction.call(i,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,o)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let u=0;u<this.config.plugins.length;u++)r.push(u<o?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),s=!0}if(r)r[o]={state:n,n:t.length}}}if(!s)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw RangeError("Applying a mismatched transaction");let t=new It(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let s=n[r];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Vp(this)}static create(e){let t=new da(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new It(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new da(this.schema,e.plugins),n=t.fields,r=new It(t);for(let s=0;s<n.length;s++){let o=n[s].name;r[o]=this.hasOwnProperty(o)?this[o]:n[s].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks)t.storedMarks=this.storedMarks.map((n)=>n.toJSON());if(e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],s=r.spec.state;if(s&&s.toJSON)t[n]=s.toJSON.call(r,this[r.key])}return t}static fromJSON(e,t,n){if(!t)throw RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw RangeError("Required config field 'schema' missing");let r=new da(e.schema,e.plugins),s=new It(r);return r.fields.forEach((o)=>{if(o.name=="doc")s.doc=Ye.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=U.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks"){if(t.storedMarks)s.storedMarks=t.storedMarks.map(e.schema.markFromJSON)}else{if(n)for(let i in n){let a=n[i],l=a.spec.state;if(a.key==o.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(t,i)){s[o.name]=l.fromJSON.call(a,e,t[i],s);return}}s[o.name]=o.init(e,s)}}),s}}function zp(e,t,n){for(let r in e){let s=e[r];if(s instanceof Function)s=s.bind(t);else if(r=="handleDOMEvents")s=zp(s,t,{});n[r]=s}return n}class q{constructor(e){if(this.spec=e,this.props={},e.props)zp(e.props,this,this.props);this.key=e.key?e.key.key:Yp("plugin")}getState(e){return e[this.key]}}var Nc=Object.create(null);function Yp(e){if(e in Nc)return e+"$"+ ++Nc[e];return Nc[e]=0,e+"$"}class Q{constructor(e="key"){this.key=Yp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var Wp=(e,t)=>{if(e.selection.empty)return!1;if(t)t(e.tr.deleteSelection().scrollIntoView());return!0};function Kp(e,t){let{$cursor:n}=e.selection;if(!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0))return null;return n}var Rc=(e,t,n)=>{let r=Kp(e,n);if(!r)return!1;let s=vc(r);if(!s){let i=r.blockRange(),a=i&&Kt(i);if(a==null)return!1;if(t)t(e.tr.lift(i,a).scrollIntoView());return!0}let o=s.nodeBefore;if(nm(e,s,t,-1))return!0;if(r.parent.content.size==0&&(Qr(o,"end")||M.isSelectable(o)))for(let i=r.depth;;i--){let a=Zn(e.doc,r.before(i),r.after(i),_.empty);if(a&&a.slice.size<a.to-a.from){if(t){let l=e.tr.step(a);l.setSelection(Qr(o,"end")?U.findFrom(l.doc.resolve(l.mapping.map(s.pos,-1)),-1):M.create(l.doc,s.pos-o.nodeSize)),t(l.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}if(o.isAtom&&s.depth==r.depth-1){if(t)t(e.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView());return!0}return!1},qp=(e,t,n)=>{let r=Kp(e,n);if(!r)return!1;let s=vc(r);return s?Gp(e,s,t):!1},Xp=(e,t,n)=>{let r=Jp(e,n);if(!r)return!1;let s=Bc(r);return s?Gp(e,s,t):!1};function Gp(e,t,n){let r=t.nodeBefore,s=r,o=t.pos-1;for(;!s.isTextblock;o--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let i=t.nodeAfter,a=i,l=t.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let c=Zn(e.doc,o,l,_.empty);if(!c||c.from!=o||c instanceof se&&c.slice.size>=l-o)return!1;if(n){let u=e.tr.step(c);u.setSelection(I.create(u.doc,o)),n(u.scrollIntoView())}return!0}function Qr(e,t,n=!1){for(let r=e;r;r=t=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Dc=(e,t,n)=>{let{$head:r,empty:s}=e.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;o=vc(r)}let i=o&&o.nodeBefore;if(!i||!M.isSelectable(i))return!1;if(t)t(e.tr.setSelection(M.create(e.doc,o.pos-i.nodeSize)).scrollIntoView());return!0};function vc(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function Jp(e,t){let{$cursor:n}=e.selection;if(!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size))return null;return n}var Lc=(e,t,n)=>{let r=Jp(e,n);if(!r)return!1;let s=Bc(r);if(!s)return!1;let o=s.nodeAfter;if(nm(e,s,t,1))return!0;if(r.parent.content.size==0&&(Qr(o,"start")||M.isSelectable(o))){let i=Zn(e.doc,r.before(),r.after(),_.empty);if(i&&i.slice.size<i.to-i.from){if(t){let a=e.tr.step(i);a.setSelection(Qr(o,"start")?U.findFrom(a.doc.resolve(a.mapping.map(s.pos)),1):M.create(a.doc,a.mapping.map(s.pos))),t(a.scrollIntoView())}return!0}}if(o.isAtom&&s.depth==r.depth-1){if(t)t(e.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView());return!0}return!1},Pc=(e,t,n)=>{let{$head:r,empty:s}=e.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;o=Bc(r)}let i=o&&o.nodeAfter;if(!i||!M.isSelectable(i))return!1;if(t)t(e.tr.setSelection(M.create(e.doc,o.pos)).scrollIntoView());return!0};function Bc(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var Qp=(e,t)=>{let n=e.selection,r=n instanceof M,s;if(r){if(n.node.isTextblock||!Ot(e.doc,n.from))return!1;s=n.from}else if(s=Xr(e.doc,n.from,-1),s==null)return!1;if(t){let o=e.tr.join(s);if(r)o.setSelection(M.create(o.doc,s-e.doc.resolve(s).nodeBefore.nodeSize));t(o.scrollIntoView())}return!0},Zp=(e,t)=>{let n=e.selection,r;if(n instanceof M){if(n.node.isTextblock||!Ot(e.doc,n.to))return!1;r=n.to}else if(r=Xr(e.doc,n.to,1),r==null)return!1;if(t)t(e.tr.join(r).scrollIntoView());return!0},em=(e,t)=>{let{$from:n,$to:r}=e.selection,s=n.blockRange(r),o=s&&Kt(s);if(o==null)return!1;if(t)t(e.tr.lift(s,o).scrollIntoView());return!0},Fc=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;if(t)t(e.tr.insertText(`
|
|
10
|
+
`).scrollIntoView());return!0};function Uc(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Hc=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),o=n.indexAfter(-1),i=Uc(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(t){let a=n.after(),l=e.tr.replaceWith(a,a,i.createAndFill());l.setSelection(U.near(l.doc.resolve(a),1)),t(l.scrollIntoView())}return!0},$c=(e,t)=>{let n=e.selection,{$from:r,$to:s}=n;if(n instanceof we||r.parent.inlineContent||s.parent.inlineContent)return!1;let o=Uc(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){let i=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,a=e.tr.insert(i,o.createAndFill());a.setSelection(I.create(a.doc,i+1)),t(a.scrollIntoView())}return!0},Vc=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(mt(e.doc,o)){if(t)t(e.tr.split(o).scrollIntoView());return!0}}let r=n.blockRange(),s=r&&Kt(r);if(s==null)return!1;if(t)t(e.tr.lift(r,s).scrollIntoView());return!0};function OA(e){return(t,n)=>{if(t.selection instanceof M&&t.selection.node.isBlock){let{$from:h}=t.selection;if(!h.parentOffset||!mt(t.doc,h.pos))return!1;if(n)n(t.tr.split(h.pos).scrollIntoView());return!0}if(!t.selection.$from.depth)return!1;let r=t.tr;if(!t.selection.empty&&(t.selection instanceof I||t.selection instanceof we))r.deleteSelection();let{$from:s}=r.selection,o=r.steps.length,i=[],a,l,c=!1,u=!1;for(let h=s.depth;;h--)if(s.node(h).isBlock){c=s.end(h)==s.pos+(s.depth-h),u=s.start(h)==s.pos-(s.depth-h),l=Uc(s.node(h-1).contentMatchAt(s.indexAfter(h-1)));let m=e&&e(s.parent,c,s);i.unshift(m||(c&&l?{type:l}:null)),a=h;break}else{if(h==1)return!1;i.unshift(null)}let d=s.pos,f=mt(r.doc,d,i.length,i);if(!f)i[0]=l?{type:l}:null,f=mt(r.doc,d,i.length,i);if(!f)return!1;if(r.split(d,i.length,i),!c&&u&&s.node(a).type!=l){let h=r.mapping.slice(o),p=h.map(s.before(a)),m=r.doc.resolve(p);if(l&&s.node(a-1).canReplaceWith(m.index(),m.index()+1,l))r.setNodeMarkup(h.map(s.before(a)),l)}if(n)n(r.scrollIntoView());return!0}}var IA=OA();var tm=(e,t)=>{let{$from:n,to:r}=e.selection,s,o=n.sharedDepth(r);if(o==0)return!1;if(s=n.before(o),t)t(e.tr.setSelection(M.create(e.doc,s)));return!0},MA=(e,t)=>{if(t)t(e.tr.setSelection(new we(e.doc)));return!0};function RA(e,t,n){let{nodeBefore:r,nodeAfter:s}=t,o=t.index();if(!r||!s||!r.type.compatibleContent(s.type))return!1;if(!r.content.size&&t.parent.canReplace(o-1,o)){if(n)n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView());return!0}if(!t.parent.canReplace(o,o+1)||!(s.isTextblock||Ot(e.doc,t.pos)))return!1;if(n)n(e.tr.join(t.pos).scrollIntoView());return!0}function nm(e,t,n,r){let{nodeBefore:s,nodeAfter:o}=t,i,a,l=s.type.spec.isolating||o.type.spec.isolating;if(!l&&RA(e,t,n))return!0;let c=!l&&t.parent.canReplace(t.index(),t.index()+1);if(c&&(i=(a=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&a.matchType(i[0]||o.type).validEnd){if(n){let h=t.pos+o.nodeSize,p=S.empty;for(let E=i.length-1;E>=0;E--)p=S.from(i[E].create(null,p));p=S.from(s.copy(p));let m=e.tr.step(new fe(t.pos-1,h,t.pos,h,new _(p,1,0),i.length,!0)),g=m.doc.resolve(h+2*i.length);if(g.nodeAfter&&g.nodeAfter.type==s.type&&Ot(m.doc,g.pos))m.join(g.pos);n(m.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&l?null:U.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&Kt(d);if(f!=null&&f>=t.depth){if(n)n(e.tr.lift(d,f).scrollIntoView());return!0}if(c&&Qr(o,"start",!0)&&Qr(s,"end")){let h=s,p=[];for(;;){if(p.push(h),h.isTextblock)break;h=h.lastChild}let m=o,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let E=S.empty;for(let w=p.length-1;w>=0;w--)E=S.from(p[w].copy(E));let x=e.tr.step(new fe(t.pos-p.length,t.pos+o.nodeSize,t.pos+g,t.pos+o.nodeSize-g,new _(E,p.length,0),0,!0));n(x.scrollIntoView())}return!0}}return!1}function rm(e){return function(t,n){let r=t.selection,s=e<0?r.$from:r.$to,o=s.depth;while(s.node(o).isInline){if(!o)return!1;o--}if(!s.node(o).isTextblock)return!1;if(n)n(t.tr.setSelection(I.create(t.doc,e<0?s.start(o):s.end(o))));return!0}}var zc=rm(-1),Yc=rm(1);function sm(e,t=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o),a=i&&Eo(i,e,t);if(!a)return!1;if(r)r(n.tr.wrap(i,a).scrollIntoView());return!0}}function jc(e,t=null){return function(n,r){let s=!1;for(let o=0;o<n.selection.ranges.length&&!s;o++){let{$from:{pos:i},$to:{pos:a}}=n.selection.ranges[o];n.doc.nodesBetween(i,a,(l,c)=>{if(s)return!1;if(!l.isTextblock||l.hasMarkup(e,t))return;if(l.type==e)s=!0;else{let u=n.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,e)}})}if(!s)return!1;if(r){let o=n.tr;for(let i=0;i<n.selection.ranges.length;i++){let{$from:{pos:a},$to:{pos:l}}=n.selection.ranges[i];o.setBlockType(a,l,e,t)}r(o.scrollIntoView())}return!0}}function Wc(...e){return function(t,n,r){for(let s=0;s<e.length;s++)if(e[s](t,n,r))return!0;return!1}}var Mc=Wc(Wp,Rc,Dc),jp=Wc(Wp,Lc,Pc),pn={Enter:Wc(Fc,$c,Vc,IA),"Mod-Enter":Hc,Backspace:Mc,"Mod-Backspace":Mc,"Shift-Backspace":Mc,Delete:jp,"Mod-Delete":jp,"Mod-a":MA},DA={"Ctrl-h":pn.Backspace,"Alt-Backspace":pn["Mod-Backspace"],"Ctrl-d":pn.Delete,"Ctrl-Alt-Backspace":pn["Mod-Delete"],"Alt-Delete":pn["Mod-Delete"],"Alt-d":pn["Mod-Delete"],"Ctrl-a":zc,"Ctrl-e":Yc};for(let e in pn)DA[e]=pn[e];var t1=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;function om(e,t=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o);if(!i)return!1;let a=r?n.tr:null;if(!vA(a,i,e,t))return!1;if(r)r(a.scrollIntoView());return!0}}function vA(e,t,n,r=null){let s=!1,o=t,i=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let l=i.resolve(t.start-2);if(o=new Yr(l,l,t.depth),t.endIndex<t.parent.childCount)t=new Yr(t.$from,i.resolve(t.$to.end(t.depth)),t.depth);s=!0}let a=Eo(o,n,r,t);if(!a)return!1;if(e)LA(e,t,a,s,n);return!0}function LA(e,t,n,r,s){let o=S.empty;for(let u=n.length-1;u>=0;u--)o=S.from(n[u].type.create(n[u].attrs,o));e.step(new fe(t.start-(r?2:0),t.end,t.start,t.end,new _(o,0,0),n.length,!0));let i=0;for(let u=0;u<n.length;u++)if(n[u].type==s)i=u+1;let a=n.length-i,l=t.start+n.length-(r?2:0),c=t.parent;for(let{startIndex:u,endIndex:d}=t,f=!0;u<d;u++,f=!1){if(!f&&a&&mt(e.doc,l,a))e.split(l,a),l+=2*a;l+=c.child(u).nodeSize}return e}function ha(e,t){return e instanceof zr?t==e:e.indexOf(t)>-1}function im(e){return function(t,n){let{$from:r,$to:s}=t.selection,o=r.blockRange(s,(i)=>i.childCount>0&&ha(e,i.firstChild.type));if(!o)return!1;if(!n)return!0;if(ha(e,r.node(o.depth-1).type))return PA(t,n,o);else return BA(t,n,o)}}function PA(e,t,n){let r=e.tr,s=n.end,o=n.$to.end(n.depth),i=n.parent.child(n.endIndex-1).type;if(s<o)r.step(new fe(s-1,o,s,o,new _(S.from(i.create(null,n.parent.copy())),1,0),1,!0)),n=new Yr(r.doc.resolve(n.$from.pos),r.doc.resolve(o),n.depth);let a=Kt(n);if(a==null)return!1;r.lift(n,a);let l=r.doc.resolve(r.mapping.map(s,-1)-1);if(Ot(r.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type)r.join(l.pos);return t(r.scrollIntoView()),!0}function BA(e,t,n){let r=e.tr,s=n.parent;for(let h=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)h-=s.child(p).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(n.start),i=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==s.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(a?0:1),u+1,i.content.append(l?S.empty:S.from(s))))return!1;let d=o.pos,f=d+i.nodeSize;return r.step(new fe(d-(a?1:0),f+(l?1:0),d+1,f-1,new _((a?S.empty:S.from(s.copy(S.empty))).append(l?S.empty:S.from(s.copy(S.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}function am(e){return function(t,n){let{$from:r,$to:s}=t.selection,o=r.blockRange(s,(c)=>c.childCount>0&&ha(e,c.firstChild.type));if(!o)return!1;let i=o.startIndex;if(i==0)return!1;let a=o.parent,l=a.child(i-1);if(!ha(e,l.type))return!1;if(n){let c=l.lastChild&&l.lastChild.type==a.type,u=S.from(c?l.lastChild.lastChild.type.create():null),d=new _(S.from(l.type.create(null,S.from(a.type.create(null,u)))),c?3:1,0),{start:f,end:h}=o;n(t.tr.step(new fe(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}var Re=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},ns=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},Jc=null,Xt=function(e,t,n){let r=Jc||(Jc=document.createRange());return r.setEnd(e,n==null?e.nodeValue.length:n),r.setStart(e,t||0),r},FA=function(){Jc=null},sr=function(e,t,n,r){return n&&(lm(e,t,n,r,-1)||lm(e,t,n,r,1))},UA=/^(img|br|input|textarea|hr)$/i;function lm(e,t,n,r,s){var o;for(;;){if(e==n&&t==r)return!0;if(t==(s<0?0:He(e))){let i=e.parentNode;if(!i||!V(i)||_o(e)||UA.test(e.nodeName)||e.contentEditable=="false")return!1;t=Re(e)+(s<0?0:1),e=i}else if(V(e)){let i=e.childNodes[t+(s<0?-1:0)];if(V(i)&&i.contentEditable=="false")if((o=i.pmViewDesc)===null||o===void 0?void 0:o.ignoreForSelection)t+=s;else return!1;else e=i,t=s<0?He(e):0}else return!1}}function He(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function V(e){return e.nodeType==1}function Ce(e){return e.nodeType==3}function or(e,t){return t?e.contains(V(t)?t:t.parentNode):!1}function HA(e,t){for(;;){if(Ce(e)&&t)return e;if(V(e)&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=He(e)}else if(e.parentNode&&!_o(e))t=Re(e),e=e.parentNode;else return null}}function $A(e,t){for(;;){if(Ce(e)&&t<e.nodeValue.length)return e;if(V(e)&&t<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!_o(e))t=Re(e)+1,e=e.parentNode;else return null}}function VA(e,t,n){for(let r=t==0,s=t==He(e);r||s;){if(e==n)return!0;let o=Re(e);if(e=e.parentNode,!e)return!1;r=r&&o==0,s=s&&o==He(e)}}function _o(e){let t;for(let n=e;n;n=n.parentNode)if(t=n.pmViewDesc)break;return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var Ta=function(e){return e.focusNode&&sr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function zA(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function YA(e){let t=e.activeElement;while(t&&t.shadowRoot)t=t.shadowRoot.activeElement;return t}function jA(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(He(r.offsetNode),r.offset)}}catch(r){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(He(r.startContainer),r.startOffset)}}}var Mt=typeof navigator<"u"?navigator:null,cm=typeof document<"u"?document:null,An=Mt&&Mt.userAgent||"",Qc=/Edge\/(\d+)/.exec(An),Fm=/MSIE \d/.exec(An),Zc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(An),Qe=!!(Fm||Zc||Qc),Tn=Fm?document.documentMode:Zc?+Zc[1]:Qc?+Qc[1]:0,at=!Qe&&/gecko\/(\d+)/i.test(An);at&&+(/Firefox\/(\d+)/.exec(An)||[0,0])[1];var eu=!Qe&&/Chrome\/(\d+)/.exec(An),De=!!eu,Um=eu?+eu[1]:0,$e=!Qe&&!!Mt&&/Apple Computer/.test(Mt.vendor),rs=$e&&(/Mobile\/\w+/.test(An)||!!Mt&&Mt.maxTouchPoints>2),gt=rs||(Mt?/Mac/.test(Mt.platform):!1),Hm=Mt?/Win/.test(Mt.platform):!1,Gt=/Android \d/.test(An),ba=!!cm&&"webkitFontSmoothing"in cm.documentElement.style,WA=ba?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function KA(e){let t=e.defaultView&&e.defaultView.visualViewport;if(t)return{left:0,right:t.width,top:0,bottom:t.height};return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function qt(e,t){return typeof e=="number"?e:e[t]}function qA(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function um(e,t,n){if(!tu(t)&&t.left==0)return;let r=e.someProp("scrollThreshold")||0,s=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let i=n||e.dom;;){if(!i)break;if(!V(i)){i=ns(i);continue}let a=i==o.body,l=a?KA(o):qA(i),c=0,u=0;if(t.top<l.top+qt(r,"top"))u=-(l.top-t.top+qt(s,"top"));else if(t.bottom>l.bottom-qt(r,"bottom"))u=t.bottom-t.top>l.bottom-l.top?t.top+qt(s,"top")-l.top:t.bottom-l.bottom+qt(s,"bottom");if(t.left<l.left+qt(r,"left"))c=-(l.left-t.left+qt(s,"left"));else if(t.right>l.right-qt(r,"right"))c=t.right-l.right+qt(s,"right");if(c||u)if(a)o.defaultView.scrollBy(c,u);else{let f=i.scrollLeft,h=i.scrollTop;if(u)i.scrollTop+=u;if(c)i.scrollLeft+=c;let p=i.scrollLeft-f,m=i.scrollTop-h;t={left:t.left-p,top:t.top-m,right:t.right-p,bottom:t.bottom-m}}let d=a?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(d))break;i=d=="absolute"?i.offsetParent:ns(i)}}function XA(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,s;for(let o=(t.left+t.right)/2,i=n+1;i<Math.min(innerHeight,t.bottom);i+=5){let a=e.root.elementFromPoint(o,i);if(!a||a==e.dom||!e.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=n-20){r=a,s=l.top;break}}return{refDOM:r,refTop:s,stack:$m(e.dom)}}function $m(e){let t=[],n=e.ownerDocument;for(let r=e;r;r=ns(r))if(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e==n)break;return t}function GA({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Vm(n,r==0?0:r-t)}function Vm(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:s,left:o}=e[n];if(r.scrollTop!=s+t)r.scrollTop=s+t;if(r.scrollLeft!=o)r.scrollLeft=o}}var Zr=null;function JA(e){if(e.setActive)return e.setActive();if(Zr)return e.focus(Zr);let t=$m(e);if(e.focus(Zr==null?{get preventScroll(){return Zr={preventScroll:!0},!0}}:void 0),!Zr)Zr=!1,Vm(t,0)}function zm(e,t){let n,r=200000000,s,o=0,{top:i,top:a}=t,l,c;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(V(u))f=u.getClientRects();else if(Ce(u))f=Xt(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=i&&p.bottom>=a){i=Math.max(p.bottom,i),a=Math.min(p.top,a);let m=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(m<r){if(n=u,r=m,s=m&&Ce(n)?{left:p.right<t.left?p.right:p.left,top:t.top}:t,V(u)&&m)o=d+(t.left>=(p.left+p.right)/2?1:0);continue}}else if(p.top>t.top&&!l&&p.left<=t.left&&p.right>=t.left)l=u,c={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top};if(!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom))o=d+1}}if(!n&&l)n=l,s=c,r=0;if(n&&Ce(n))return QA(n,s);if(!n||r)return{node:e,offset:o};return zm(n,s)}function QA(e,t){let n=e.nodeValue.length,r=document.createRange(),s;for(let o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);let i=mn(r,1);if(i.top==i.bottom)continue;if(lu(t,i)){s={node:e,offset:o+(t.left>=(i.left+i.right)/2?1:0)};break}}return r.detach(),s||{node:e,offset:0}}function lu(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function ZA(e,t){let n=e.parentNode;if(n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left)return n;return e}function ew(e,t,n){let{node:r,offset:s}=zm(t,n),o=-1;if(V(r)&&!r.firstChild){let i=r.getBoundingClientRect();o=i.left!=i.right&&n.left>(i.left+i.right)/2?1:-1}return e.docView.posFromDOM(r,s,o)}function tw(e,t,n,r){let s=-1;for(let o=t,i=!1;;){if(o==e.dom)break;let a=e.docView.nearestDesc(o,!0),l;if(!a)return null;if(V(a.dom)&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)){if(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)){if(!i&&l.left>r.left||l.top>r.top)s=a.posBefore;else if(!i&&l.right<r.left||l.bottom<r.top)s=a.posAfter;i=!0}if(!a.contentDOM&&s<0&&!a.node.isText)return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter}o=a.dom.parentNode}return s>-1?s:e.docView.posFromDOM(t,n,-1)}function Ym(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),o=s;;){let i=e.childNodes[o];if(V(i)){let a=i.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(lu(t,c))return Ym(i,t,c)}}if((o=(o+1)%r)==s)break}return e}function nw(e,t){let n=e.dom.ownerDocument,r,s=0,o=jA(n,t.left,t.top);if(o)({node:r,offset:s}=o);let i=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),a;if(!i||!e.dom.contains(i)){let c=e.dom.getBoundingClientRect();if(!lu(t,c))return null;if(i=Ym(e.dom,t,c),!i)return null}if($e){for(let c=i;r&&c;c=ns(c))if(c.draggable)r=void 0}if(i=ZA(i,t),r){if(at&&V(r)){if(s=Math.min(s,r.childNodes.length),s<r.childNodes.length){let u=r.childNodes[s],d;if(u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=t.left&&d.bottom>t.top)s++}}let c;if(ba&&s&&V(r)&&V(c=r.childNodes[s-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=t.top)s--;if(r==e.dom&&s==r.childNodes.length-1&&V(r.lastChild)&&t.top>r.lastChild.getBoundingClientRect().bottom)a=e.state.doc.content.size;else if(s==0||!V(r)||r.childNodes[s-1].nodeName!="BR")a=tw(e,r,s,t)}if(a==null)a=ew(e,i,t);let l=e.docView.nearestDesc(i,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function tu(e){return e.top<e.bottom||e.left<e.right}function mn(e,t){let n=e.getClientRects();if(n.length){let r=n[t<0?0:n.length-1];if(tu(r))return r}return Array.prototype.find.call(n,tu)||e.getBoundingClientRect()}var rw=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function jm(e,t,n){let{node:r,offset:s,atom:o}=e.docView.domFromPos(t,n<0?-1:1),i=ba||at;if(Ce(r))if(i&&(rw.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let l=mn(Xt(r,s,s),n);if(at&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=mn(Xt(r,s-1,s-1),-1);if(c.top==l.top){let u=mn(Xt(r,s,s+1),-1);if(u.top!=l.top)return bo(u,u.left<c.left)}}return l}else{let l=s,c=s,u=n<0?1:-1;if(n<0&&!s)c++,u=-1;else if(n>=0&&s==r.nodeValue.length)l--,u=1;else if(n<0)l--;else c++;return bo(mn(Xt(r,l,c),u),u<0)}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(o==null&&s&&(n<0||s==He(r))){let l=r.childNodes[s-1];if(V(l))return Kc(l.getBoundingClientRect(),!1)}if(o==null&&s<He(r)){let l=r.childNodes[s];if(V(l))return Kc(l.getBoundingClientRect(),!0)}return Kc(r.getBoundingClientRect(),n>=0)}if(o==null&&s&&(n<0||s==He(r))){let l=r.childNodes[s-1],c=Ce(l)?Xt(l,He(l)-(i?0:1)):V(l)&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return bo(mn(c,1),!1)}if(o==null&&s<He(r)){let l=r.childNodes[s];while(l.pmViewDesc&&l.pmViewDesc.ignoreForCoords)l=l.nextSibling;let c=!l?null:Ce(l)?Xt(l,0,i?0:1):V(l)?l:null;if(c)return bo(mn(c,-1),!0)}return bo(mn(Ce(r)?Xt(r):r,-n),n>=0)}function bo(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Kc(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Wm(e,t,n){let r=e.state,s=e.root.activeElement;if(r!=t)e.updateState(t);if(s!=e.dom)e.focus();try{return n()}finally{if(r!=t)e.updateState(r);if(s!=e.dom&&s)s.focus()}}function sw(e,t,n){let r=t.selection,s=n=="up"?r.$from:r.$to;return Wm(e,t,()=>{let{node:o}=e.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let a=e.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let i=jm(e,s.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let l;if(V(a))l=a.getClientRects();else if(Ce(a))l=Xt(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let u=l[c];if(u.bottom>u.top+1&&(n=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}var ow=/[\u0590-\u08ac]/;function iw(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,o=!s,i=s==r.parent.content.size,a=e.domSelection();if(!a)return r.pos==r.start()||r.pos==r.end();if(!ow.test(r.parent.textContent)||!a.modify)return n=="left"||n=="backward"?o:i;return Wm(e,t,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:d}=e.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",n,"character");let h=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:p,focusOffset:m}=e.domSelectionRange(),g=p&&!or(h,p)||l==p&&c==m;try{if(a.collapse(u,d),l&&(l!=u||c!=d)&&a.extend)a.extend(l,c)}catch(E){}if(f!=null)a.caretBidiLevel=f;return g})}var dm=null,fm=null,hm=!1;function aw(e,t,n){if(dm==t&&fm==n)return hm;return dm=t,fm=n,hm=n=="up"||n=="down"?sw(e,t,n):iw(e,t,n)}var yt=0,pm=1,er=2,Tt=3;class ss{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=yt,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){if(this.parent=void 0,this.dom.pmViewDesc==this)this.dom.pmViewDesc=void 0;for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&or(this.contentDOM,e))if(n<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{while(e.parentNode!=this.contentDOM)e=e.parentNode;s=e.previousSibling}while(s&&!((o=s.pmViewDesc)&&o.parent==this))s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{while(e.parentNode!=this.contentDOM)e=e.parentNode;s=e.nextSibling}while(s&&!((o=s.pmViewDesc)&&o.parent==this))s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>Re(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let s=e.compareDocumentPosition(this.contentDOM);if(s&16)r=t>Array.from(e.childNodes).findIndex((o)=>o.contains(this.contentDOM));else r=!(s&4)}else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!1;break}if(s.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!0;break}if(s.nextSibling)break}}return(r==null?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let s=this.getDesc(r),o;if(s&&(!t||s.node))if(n&&(o=s.nodeDOM)&&!(V(o)?or(o,e):o==e))n=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let s=this.getDesc(r);if(s)return s.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],s=n+r.size;if(n==e&&s!=n){while(!r.border&&r.children.length)for(let o=0;o<r.children.length;o++){let i=r.children[o];if(i.size){r=i;break}}return r}if(e<s)return r.descAt(e-n-r.border);n=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let s=0;n<this.children.length;n++){let o=this.children[n],i=s+o.size;if(i>e){r=e-s;break}s=i}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(;n>0;n--){let s=this.children[n-1];if(s.size||!(s instanceof uu||s instanceof cu&&s.side>=0))break}if(t<=0){let s,o=!0;for(;;n--,o=!1)if(s=n?this.children[n-1]:null,!s||s.dom.parentNode==this.contentDOM)break;if(s&&t&&o&&!s.border&&!s.domAtom)return s.domFromPos(s.size,t);return{node:this.contentDOM,offset:s?Re(s.dom)+1:0}}else{let s,o=!0;for(;;n++,o=!1)if(s=n<this.children.length?this.children[n]:null,!s||s.dom.parentNode==this.contentDOM)break;if(s&&o&&!s.border&&!s.domAtom)return s.domFromPos(0,t);return{node:this.contentDOM,offset:s?Re(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,s=-1;for(let o=n,i=0;;i++){let a=this.children[i],l=o+a.size;if(r==-1&&e<=l){let c=o+a.border;if(e>=c&&t<=l-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=o;for(let u=i;u>0;u--){let d=this.children[u-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){r=Re(d.dom)+1;break}e-=d.size}if(r==-1)r=0}if(r>-1&&(l>t||i==this.children.length-1)){t=l;for(let c=i+1;c<this.children.length;c++){let u=this.children[c];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){s=Re(u.dom);break}t+=u.size}if(s==-1)s=this.contentDOM.childNodes.length;break}o=l}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(!V(t)||n==t.childNodes.length)throw RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let f=0,h=0;f<this.children.length;f++){let p=this.children[f],m=h+p.size;if(s>h&&o<m)return p.setSelection(e-h-p.border,t-h-p.border,n,r);h=m}let i=this.domFromPos(e,e?-1:1),a=t==e?i:this.domFromPos(t,t?-1:1),l=n.root.getSelection(),c=n.domSelectionRange(),u=!1;if((at||$e)&&e==t){let{node:f,offset:h}=i;if(Ce(f)){if(u=!!(h&&f.nodeValue[h-1]==`
|
|
11
|
+
`),u&&h==f.nodeValue.length)for(let p=f,m;p;p=p.parentNode){if(m=p.nextSibling){if(m.nodeName=="BR")i=a={node:m.parentNode,offset:Re(m)+1};break}let g=p.pmViewDesc;if(g&&g.node&&g.node.isBlock)break}}else{let p=f.childNodes[h-1];u=p&&(p.nodeName=="BR"||p.contentEditable=="false")}}if(at&&c.focusNode&&c.focusNode!=a.node&&V(c.focusNode)){let f=c.focusNode.childNodes[c.focusOffset];if(f&&f.contentEditable=="false")r=!0}if(!(r||u&&$e)&&sr(i.node,i.offset,c.anchorNode,c.anchorOffset)&&sr(a.node,a.offset,c.focusNode,c.focusOffset))return;let d=!1;if((l.extend||e==t)&&!(u&&at)){l.collapse(i.node,i.offset);try{if(e!=t)l.extend(a.node,a.offset);d=!0}catch(f){}}if(!d){if(e>t){let h=i;i=a,a=h}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(i.node,i.offset),l.removeAllRanges(),l.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let s=this.children[r],o=n+s.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let i=n+s.border,a=o-s.border;if(e>=i&&t<=a){if(this.dirty=e==n||t==o?er:pm,e==i&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM))s.dirty=Tt;else s.markDirty(e-i,t-i);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?er:Tt}n=o}this.dirty=er}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?er:pm;if(t.dirty<n)t.dirty=n}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class cu extends ss{constructor(e,t,n,r){let s,o=t.type.toDOM;if(typeof o=="function")o=o(n,()=>{if(!s)return r;if(s.parent)return s.parent.posBeforeChild(s)});if(!t.type.spec.raw){let i=V(o)?o:document.createElement("span");if(i!=o)i.appendChild(o),o=i;if(!i.hasAttribute("contenteditable"))i.contentEditable="false";i.classList.add("ProseMirror-widget")}super(e,[],o,null);this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==yt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Km extends ss{constructor(e,t,n,r){super(e,[],t,null);this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){if(e!=this.textDOM)return this.posAtStart+(t?this.size:0);return this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class bn extends ss{constructor(e,t,n,r,s){super(e,[],n,r);this.mark=t,this.spec=s}static create(e,t,n,r){let s=r.nodeViews[t.type.name],o=s&&s(t,r,n);if(!o||!o.dom)o=jt.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs);return new bn(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){if(this.dirty&Tt||this.mark.type.spec.reparseInView)return null;return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Tt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=yt){let n=this.parent;while(!n.node)n=n.parent;if(n.dirty<this.dirty)n.dirty=this.dirty;this.dirty=yt}}slice(e,t,n){let r=bn.create(this.parent,this.mark,!0,n),s=this.children,o=this.size;if(t<o)s=ru(s,t,o,n);if(e>0)s=ru(s,0,e,n);for(let i=0;i<s.length;i++)s[i].parent=r;return r.children=s,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}}class Sn extends ss{constructor(e,t,n,r,s,o,i){super(e,[],s,o);this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=i}static create(e,t,n,r,s,o){let i=s.nodeViews[t.type.name],a,l=i&&i(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},n,r),c=l&&l.dom,u=l&&l.contentDOM;if(t.isText){if(!c)c=document.createTextNode(t.text);else if(!Ce(c))throw RangeError("Text must be rendered as a DOM text node")}else if(!c)({dom:c,contentDOM:u}=jt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));if(!u&&!t.isText&&c.nodeName!="BR"){if(!c.hasAttribute("contenteditable"))c.contentEditable="false";if(t.type.spec.draggable)c.draggable=!0}let d=c;if(c=Jm(c,n,t),l)return a=new qm(e,t,n,r,c,u||null,d,l);else if(t.isText)return new Sa(e,t,n,r,c,d);else return new Sn(e,t,n,r,c,u||null,d)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre")t.preserveWhitespace="full";if(!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find((r)=>V(r)&&e.indexOf(r.parentNode)<0&&this.dom.contains(r));if(n)t.contentElement=n;else t.getContent=()=>S.empty}}return t}matchesNode(e,t,n){return this.dirty==yt&&e.eq(this.node)&&pa(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,i=s&&s.pos<0,a=new Qm(this,o&&o.node,e),l=this.node.inlineContent,c=l&&this.node.isBlock;if(dw(this.node,this.innerDeco,(u,d,f)=>{if(u.spec.marks)a.syncToMarks(u.spec.marks,n,e,d);else if(u.type.side>=0&&!f)a.syncToMarks(d==this.node.childCount?J.none:this.node.child(d).marks,n,e,d);a.placeWidget(u,e,r)},(u,d,f,h)=>{if(a.syncToMarks(u.marks,n,e,h),c&&u.isAtom&&!u.isText)a.addHackNode("IMG",a.top);let p;if(a.findNodeMatch(u,d,f,h));else if(i&&e.state.selection.from>r&&e.state.selection.to<r+u.nodeSize&&(p=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(u,d,f,p,e));else if(a.updateNextNode(u,d,f,e,h,r));else a.addNode(u,d,f,e,r);if(r+=u.nodeSize,l)c=u.isAtom&&!u.isText}),a.syncToMarks([],n,e,0),this.node.isTextblock)a.addTextblockHacks();if(a.destroyRest(),a.changed||this.dirty==er){if(o)this.protectLocalComposition(e,o);if(Xm(this.contentDOM,this.children,e),rs)fw(this.dom)}}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof I)||n<t||r>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,i=hw(this.node.content,o,n-t,r-t);return i<0?null:{node:s,pos:i,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let s=t;for(;;s=s.parentNode){if(s.parentNode==this.contentDOM)break;while(s.previousSibling)s.parentNode.removeChild(s.previousSibling);while(s.nextSibling)s.parentNode.removeChild(s.nextSibling);if(s.pmViewDesc)s.pmViewDesc=void 0}let o=new Km(this,s,t,r);e.input.compositionNodes.push(o),this.children=ru(this.children,n,n+r.length,e,o)}update(e,t,n,r){if(this.dirty==Tt||!e.sameMarkup(this.node))return!1;return this.updateInner(e,t,n,r),!0}updateInner(e,t,n,r){if(this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM)this.updateChildren(r,this.posAtStart);this.dirty=yt}updateOuterDeco(e){if(pa(e,this.outerDeco))return;let t=!V(this.nodeDOM),n=this.dom;if(this.dom=Gm(this.dom,this.nodeDOM,nu(this.outerDeco,this.node,t),nu(e,this.node,t)),this.dom!=n)n.pmViewDesc=void 0,this.dom.pmViewDesc=this;this.outerDeco=e}selectNode(){if(V(this.nodeDOM)){if(this.nodeDOM.classList.add("ProseMirror-selectednode"),this.contentDOM||!this.node.type.spec.draggable)this.nodeDOM.draggable=!0}}deselectNode(){if(V(this.nodeDOM)){if(this.nodeDOM.classList.remove("ProseMirror-selectednode"),this.contentDOM||!this.node.type.spec.draggable)this.nodeDOM.removeAttribute("draggable")}}get domAtom(){return this.node.isAtom}}function mm(e,t,n,r,s){Jm(r,t,e);let o=new Sn(void 0,e,t,n,r,r,r);if(o.contentDOM)o.updateChildren(s,0);return o}class Sa extends Sn{constructor(e,t,n,r,s,o){super(e,t,n,r,s,null,o)}parseRule(){let e=this.nodeDOM.parentNode;while(e&&e!=this.dom&&!e.pmIsDeco)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){if(this.dirty==Tt||this.dirty!=yt&&!this.inParent()||!e.sameMarkup(this.node))return!1;if(this.updateOuterDeco(t),(this.dirty!=yt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue){if(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM)r.trackWrites=null}return this.node=e,this.dirty=yt,!0}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){if(e==this.nodeDOM)return this.posAtStart+Math.min(t,this.node.text.length);return super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let r=this.node.cut(e,t),s=document.createTextNode(r.text);return new Sa(this.parent,r,this.outerDeco,this.innerDeco,s,s)}markDirty(e,t){if(super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length))this.dirty=Tt}get domAtom(){return!1}isText(e){return this.node.text==e}}class uu extends ss{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==yt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class qm extends Sn{constructor(e,t,n,r,s,o,i,a){super(e,t,n,r,s,o,i);this.spec=a}update(e,t,n,r){if(this.dirty==Tt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,n);if(s)this.updateInner(e,t,n,r);return s}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Xm(e,t,n){let r=e.firstChild,s=!1;for(let o=0;o<t.length;o++){let i=t[o],a=i.dom;if(a.parentNode==e){while(a!=r)r=gm(r),s=!0;r=r.nextSibling}else s=!0,e.insertBefore(a,r);if(i instanceof bn){let l=r?r.previousSibling:e.lastChild;Xm(i.contentDOM,i.children,n),r=l?l.nextSibling:e.firstChild}}while(r)r=gm(r),s=!0;if(s&&n.trackWrites==e)n.trackWrites=null}var xo=function(e){if(e)this.nodeName=e};xo.prototype=Object.create(null);var tr=[new xo];function nu(e,t,n){if(e.length==0)return tr;let r=n?tr[0]:new xo,s=[r];for(let o=0;o<e.length;o++){let i=e[o].type.attrs;if(!i)continue;if(i.nodeName)s.push(r=new xo(i.nodeName));for(let a in i){let l=i[a];if(l==null)continue;if(n&&s.length==1)s.push(r=new xo(t.isInline?"span":"div"));if(a=="class")r.class=(r.class?r.class+" ":"")+l;else if(a=="style")r.style=(r.style?r.style+";":"")+l;else if(a!="nodeName")r[a]=l}}return s}function Gm(e,t,n,r){if(n==tr&&r==tr)return t;let s=t;for(let o=0;o<r.length;o++){let i=r[o],a=n[o];if(o){let l;if(a&&a.nodeName==i.nodeName&&s!=e&&(l=s.parentNode)&&l.nodeName.toLowerCase()==i.nodeName)s=l;else l=document.createElement(i.nodeName),l.pmIsDeco=!0,l.appendChild(s),a=tr[0],s=l}lw(s,a||tr[0],i)}return s}function lw(e,t,n){for(let r in t)if(r!="class"&&r!="style"&&r!="nodeName"&&!(r in n))e.removeAttribute(r);for(let r in n)if(r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=t[r])e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)if(s.indexOf(r[o])==-1)e.classList.remove(r[o]);for(let o=0;o<s.length;o++)if(r.indexOf(s[o])==-1)e.classList.add(s[o]);if(e.classList.length==0)e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;while(s=r.exec(t.style))e.style.removeProperty(s[1])}if(n.style)e.style.cssText+=n.style}}function Jm(e,t,n){return Gm(e,e,tr,nu(t,n,!V(e)))}function pa(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function gm(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Qm{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=cw(e.node.content,e)}destroyBetween(e,t){if(e==t)return;for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let s=0,o=this.stack.length>>1,i=Math.min(o,e.length);while(s<i&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1)s++;while(s<o)this.destroyRest(),this.top.dirty=yt,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;while(o<e.length){this.stack.push(this.top,this.index+1);let a=-1,l=this.top.children.length;if(r<this.preMatch.index)l=Math.min(this.index+3,l);for(let c=this.index;c<l;c++){let u=this.top.children[c];if(u.matchesMark(e[o])&&!this.isLocked(u.dom)){a=c;break}}if(a<0&&this.index<this.top.children.length){let c=this.top.children[this.index];if(c instanceof bn&&c.dirty!=Tt&&c.mark.type==e[o].type&&c.spec.update&&!this.isLocked(c.dom)&&c.spec.update(e[o]))c.mark=e[o],a=this.index,this.changed=!0}if(a>-1){if(a>this.index)this.changed=!0,this.destroyBetween(this.index,a);this.top=this.top.children[this.index]}else{let c=bn.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let s=-1,o;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))s=this.top.children.indexOf(o,this.index);else for(let i=this.index,a=Math.min(this.top.children.length,i+5);i<a;i++){let l=this.top.children[i];if(l.matchesNode(e,t,n)&&!this.preMatch.matched.has(l)){s=i;break}}if(s<0)return!1;return this.destroyBetween(this.index,s),this.index++,!0}updateNodeAt(e,t,n,r,s){let o=this.top.children[r];if(o.dirty==Tt&&o.dom==o.contentDOM)o.dirty=er;if(!o.update(e,t,n,s))return!1;return this.destroyBetween(this.index,r),this.index++,!0}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==n)return r}return-1}e=t}}updateNextNode(e,t,n,r,s,o){for(let i=this.index;i<this.top.children.length;i++){let a=this.top.children[i];if(a instanceof Sn){let l=this.preMatch.matched.get(a);if(l!=null&&l!=s)return!1;let c=a.dom,u,d=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Tt&&pa(t,a.outerDeco));if(!d&&a.update(e,t,n,r)){if(this.destroyBetween(this.index,i),a.dom!=c)this.changed=!0;return this.index++,!0}else if(!d&&(u=this.recreateWrapper(a,e,t,n,r,o))){if(this.destroyBetween(this.index,i),this.top.children[this.index]=u,u.contentDOM)u.dirty=er,u.updateChildren(r,o+1),u.dirty=yt;return this.changed=!0,this.index++,!0}break}}return!1}recreateWrapper(e,t,n,r,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!pa(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let i=Sn.create(this.top,t,n,r,s,o);if(i.contentDOM){i.children=e.children,e.children=[];for(let a of i.children)a.parent=i}return e.destroy(),i}addNode(e,t,n,r,s){let o=Sn.create(this.top,e,t,n,r,s);if(o.contentDOM)o.updateChildren(r,s+1);this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let s=new cu(this.top,e,t,n);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;while(e instanceof bn)t=e,e=t.children[t.children.length-1];if(!e||!(e instanceof Sa)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text)){if(($e||De)&&e&&e.dom.contentEditable=="false")this.addHackNode("IMG",t);this.addHackNode("BR",this.top)}}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);if(e=="IMG")n.className="ProseMirror-separator",n.alt="";if(e=="BR")n.className="ProseMirror-trailingBreak";let r=new uu(this.top,[],n,null);if(t!=this.top)t.children.push(r);else t.children.splice(this.index++,0,r);this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||V(e)&&e.contains(this.lock.parentNode))}}function cw(e,t){let n=t,r=n.children.length,s=e.childCount,o=new Map,i=[];e:while(s>0){let a;for(;;)if(r){let c=n.children[r-1];if(c instanceof bn)n=c,r=c.children.length;else{a=c,r--;break}}else if(n==t)break e;else r=n.parent.children.indexOf(n),n=n.parent;let l=a.node;if(!l)continue;if(l!=e.child(s-1))break;--s,o.set(a,s),i.push(a)}return{index:s,matched:o,matches:i.reverse()}}function uw(e,t){return e.type.side-t.type.side}function dw(e,t,n,r){let s=t.locals(e),o=0;if(s.length==0){for(let c=0;c<e.childCount;c++){let u=e.child(c);r(u,s,t.forChild(o,u),c),o+=u.nodeSize}return}let i=0,a=[],l=null;for(let c=0;;){let u,d;while(i<s.length&&s[i].to==o){let g=s[i++];if(g.widget)if(!u)u=g;else(d||(d=[u])).push(g)}if(u)if(d){d.sort(uw);for(let g=0;g<d.length;g++)n(d[g],c,!!l)}else n(u,c,!!l);let f,h;if(l)h=-1,f=l,l=null;else if(c<e.childCount)h=c,f=e.child(c++);else break;for(let g=0;g<a.length;g++)if(a[g].to<=o)a.splice(g--,1);while(i<s.length&&s[i].from<=o&&s[i].to>o)a.push(s[i++]);let p=o+f.nodeSize;if(f.isText){let g=p;if(i<s.length&&s[i].from<g)g=s[i].from;for(let E=0;E<a.length;E++)if(a[E].to<g)g=a[E].to;if(g<p)l=f.cut(g-o),f=f.cut(0,g-o),p=g,h=-1}else while(i<s.length&&s[i].to<p)i++;let m=f.isInline&&!f.isLeaf?a.filter((g)=>!g.inline):a.slice();r(f,m,t.forChild(o,f),h),o=p}}function fw(e){if(e.nodeName=="UL"||e.nodeName=="OL"){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function hw(e,t,n,r){for(let s=0,o=0;s<e.childCount&&o<=r;){let i=e.child(s++),a=o;if(o+=i.nodeSize,!i.isText)continue;let l=i.text;while(s<e.childCount){let c=e.child(s++);if(o+=c.nodeSize,!c.isText)break;l+=c.text}if(o>=n){if(o>=r&&l.slice(r-t.length-a,r-a)==t)return r-t.length;let c=a<r?l.lastIndexOf(t,r-a-1):-1;if(c>=0&&c+t.length+a>=n)return a+c;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return-1}function ru(e,t,n,r,s){let o=[];for(let i=0,a=0;i<e.length;i++){let l=e[i],c=a,u=a+=l.size;if(c>=n||u<=t)o.push(l);else{if(c<t)o.push(l.slice(0,t-c,r));if(s)o.push(s),s=void 0;if(u>n)o.push(l.slice(n-c,l.size,r))}}return o}function du(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let s=e.docView.nearestDesc(n.focusNode),o=s&&s.size==0,i=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(i<0)return null;let a=r.resolve(i),l,c;if(Ta(n)){l=i;while(s&&!s.node)s=s.parent;if(s&&s.node.isAtom&&M.isSelectable(s.node)&&s.parent&&!(s.node.isInline&&VA(n.focusNode,n.focusOffset,s.dom))){let d=s.posBefore;c=new M(i==d?a:r.resolve(d))}else if(at&&t=="key"&&i>e.state.selection.to&&V(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&s&&s.posAtStart>e.state.selection.to)for(let d=n.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){c=U.findFrom(r.resolve(s.posAtStart),1);break}if(d==s.dom||d.nextSibling||!d.parentNode||!V(d.parentNode))break}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=i,f=i;for(let h=0;h<n.rangeCount;h++){let p=n.getRangeAt(h);d=Math.min(d,e.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,e.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[l,i]=f==e.state.selection.anchor?[f,d]:[d,f],a=r.resolve(i)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!c){let d=t=="pointer"||e.state.selection.head<a.pos&&!o?1:-1;c=fu(e,u,a,d)}return c}function Zm(e){return e.editable?e.hasFocus():tg(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Qt(e,t=!1){let n=e.state.selection;if(eg(e,n),!Zm(e))return;let r=e.input.mouseDown;if(!t&&De&&r){let s=e.domSelectionRange(),o=e.domObserver.currentSelection;if(s.anchorNode&&o.anchorNode&&sr(s.anchorNode,s.anchorOffset,o.anchorNode,o.anchorOffset)&&r.delaySelUpdate()){e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)mw(e);else{let{anchor:s,head:o}=n,i,a;if(ym&&!(n instanceof I)){if(!n.$from.parent.inlineContent)i=Em(e,n.from);if(!n.empty&&!n.$from.parent.inlineContent)a=Em(e,n.to)}if(e.docView.setSelection(s,o,e,t),ym){if(i)Tm(i);if(a)Tm(a)}if(n.visible)e.dom.classList.remove("ProseMirror-hideselection");else if(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document)pw(e)}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}var ym=$e||De&&Um<63;function Em(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),s=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if($e&&s&&s.contentEditable=="false")return qc(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return qc(s);else if(o)return qc(o)}}function qc(e){if(e.contentEditable="true",$e&&e.draggable)e.draggable=!1,e.wasDraggable=!0;return e}function Tm(e){if(e.contentEditable="false",e.wasDraggable)e.draggable=!0,e.wasDraggable=null}function pw(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),{anchorNode:r,anchorOffset:s}=n;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{if(n.anchorNode!=r||n.anchorOffset!=s)t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{if(!Zm(e)||e.state.selection.visible)e.dom.classList.remove("ProseMirror-hideselection")},20)})}function mw(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName=="IMG";if(r)t.collapse(n.parentNode,Re(n)+1);else t.collapse(n,0);if(!r&&!e.state.selection.visible&&Qe&&Tn<=11)n.disabled=!0,n.disabled=!1}function eg(e,t){if(t instanceof M){let n=e.docView.descAt(t.from);if(n!=e.lastSelectedViewDesc){if(bm(e),n)n.selectNode();e.lastSelectedViewDesc=n}}else bm(e)}function bm(e){if(e.lastSelectedViewDesc){if(e.lastSelectedViewDesc.parent)e.lastSelectedViewDesc.deselectNode();e.lastSelectedViewDesc=void 0}}function fu(e,t,n,r){return e.someProp("createSelectionBetween",(s)=>s(e,t,n))||I.between(t,n,r)}function Sm(e){if(e.editable&&!e.hasFocus())return!1;return tg(e)}function tg(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return or(e.dom,t.anchorNode)&&(e.editable||or(e.dom,t.focusNode))}catch(n){return!1}}function gw(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return sr(t.node,t.offset,n.anchorNode,n.anchorOffset)}function su(e,t){let{$anchor:n,$head:r}=e.selection,s=t>0?n.max(r):n.min(r),o=!s.parent.inlineContent?s:s.depth?e.doc.resolve(t>0?s.after():s.before()):null;return o&&U.findFrom(o,t)}function gn(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function xm(e,t,n){let r=e.state.selection;if(r instanceof I){if(n.indexOf("s")>-1){let{$head:s}=r,o=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=e.state.doc.resolve(s.pos+o.nodeSize*(t<0?-1:1));return gn(e,new I(r.$anchor,i))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?"forward":"backward")){let s=su(e.state,t);if(s&&s instanceof M)return gn(e,s);return!1}else if(!gt||n.indexOf("m")<0){let s=r.$head,o=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter,i;if(!o||o.isText)return!1;let a=t<0?s.pos-o.nodeSize:s.pos;if(!(o.isAtom||(i=e.docView.descAt(a))&&!i.contentDOM))return!1;if(M.isSelectable(o))return gn(e,new M(t<0?e.state.doc.resolve(s.pos-o.nodeSize):s));else return gn(e,new I(e.state.doc.resolve(t<0?a:a+o.nodeSize)))}}else if(r instanceof M&&r.node.isInline)return gn(e,new I(t>0?r.$to:r.$from));else{let s=su(e.state,t);if(s)return gn(e,s);return!1}}function Ao(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!="BR"):V(e)&&e.contentEditable=="false"}function es(e,t){return t<0?yw(e):Ew(e)}function yw(e){let t=e.domSelectionRange(),{focusNode:n,focusOffset:r}=t;if(!n)return;let s,o,i=!1;if(at&&V(n)&&r<He(n)&&Ao(n.childNodes[r],-1))i=!0;for(;;)if(r>0){if(!V(n))break;let a=n.childNodes[r-1];if(Ao(a,-1))s=n,o=--r;else if(Ce(a))n=a,r=n.nodeValue.length;else break}else if(ng(n))break;else{let a=n.previousSibling;while(a&&Ao(a,-1))s=n.parentNode,o=Re(a),a=a.previousSibling;if(!a){if(n=n.parentNode,n==e.dom)break;r=0}else n=a,r=He(n)}if(i)ou(e,n,r);else if(s)ou(e,s,o)}function Ew(e){let t=e.domSelectionRange(),{focusNode:n,focusOffset:r}=t;if(!n)return;let s=He(n),o,i;for(;;)if(r<s){if(!V(n))break;let a=n.childNodes[r];if(Ao(a,1))o=n,i=++r;else break}else if(ng(n))break;else{let a=n.nextSibling;while(a&&Ao(a,1))o=a.parentNode,i=Re(a)+1,a=a.nextSibling;if(!a){if(n=n.parentNode,n==e.dom)break;r=s=0}else n=a,r=0,s=He(n)}if(o)ou(e,o,i)}function ng(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Tw(e,t){while(e&&t==e.childNodes.length&&!_o(e))t=Re(e)+1,e=e.parentNode;while(e&&t<e.childNodes.length){let n=e.childNodes[t];if(Ce(n))return n;if(V(n)&&n.contentEditable=="false")break;e=n,t=0}}function bw(e,t){while(e&&!t&&!_o(e))t=Re(e),e=e.parentNode;while(e&&t){let n=e.childNodes[t-1];if(Ce(n))return n;if(V(n)&&n.contentEditable=="false")break;e=n,t=e.childNodes.length}}function ou(e,t,n){if(!Ce(t)){let i,a;if(a=Tw(t,n))t=a,n=0;else if(i=bw(t,n))t=i,n=i.nodeValue.length}let r=e.domSelection(),s=e.domSelectionRange();if(!r)return;if(Ta(s))r.collapse(t,n);else if(r.extend)r.collapse(s.anchorNode,s.anchorOffset),r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{if(e.state==o)Qt(e)},50)}function Am(e,t){let n=e.state.doc.resolve(t);if(!(De||Hm)&&n.parent.inlineContent){let o=e.coordsAtPos(t);if(t>n.start()){let i=e.coordsAtPos(t-1),a=(i.top+i.bottom)/2;if(a>o.top&&a<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(t<n.end()){let i=e.coordsAtPos(t+1),a=(i.top+i.bottom)/2;if(a>o.top&&a<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}let r=e.dom;for(let o=n.depth;o>0;o--)if(n.node(o).isBlock){r=e.nodeDOM(n.before(o))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function wm(e,t,n){let r=e.state.selection;if(r instanceof I&&!r.empty||n.indexOf("s")>-1)return!1;if(gt&&n.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let i=su(e.state,t);if(i&&i instanceof M)return gn(e,i)}if(!s.parent.inlineContent){let i=t<0?s:o,a=r instanceof we?U.near(i,t):U.findFrom(i,t);return a?gn(e,a):!1}return!1}function Cm(e,t){if(!(e.state.selection instanceof I))return!0;let{$head:n,$anchor:r,empty:s}=e.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let o=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let i=e.state.tr;if(t<0)i.delete(n.pos-o.nodeSize,n.pos);else i.delete(n.pos,n.pos+o.nodeSize);return e.dispatch(i),!0}return!1}function km(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Sw(e){if(!$e||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&V(t)&&n==0&&t.firstChild&&V(t.firstChild)&&t.firstChild.contentEditable=="false"){let r=t.firstChild;km(e,r,"true"),setTimeout(()=>km(e,r,"false"),20)}return!1}function xw(e){let t="";if(e.ctrlKey)t+="c";if(e.metaKey)t+="m";if(e.altKey)t+="a";if(e.shiftKey)t+="s";return t}function Aw(e,t){let n=t.keyCode,r=xw(t);if(n==8||gt&&n==72&&r=="c")return Cm(e,-1)||es(e,-1);else if(n==46&&!t.shiftKey||gt&&n==68&&r=="c")return Cm(e,1)||es(e,1);else if(n==13||n==27)return!0;else if(n==37||gt&&n==66&&r=="c"){let s=n==37?Am(e,e.state.selection.from)=="ltr"?-1:1:-1;return xm(e,s,r)||es(e,s)}else if(n==39||gt&&n==70&&r=="c"){let s=n==39?Am(e,e.state.selection.from)=="ltr"?1:-1:1;return xm(e,s,r)||es(e,s)}else if(n==38||gt&&n==80&&r=="c")return wm(e,-1,r)||es(e,-1);else if(n==40||gt&&n==78&&r=="c")return Sw(e)||wm(e,1,r)||es(e,1);else if(r==(gt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0;return!1}function hu(e,t){e.someProp("transformCopied",(h)=>{t=h(t,e)});let n=[],{content:r,openStart:s,openEnd:o}=t;while(s>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1){s--,o--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=e.someProp("clipboardSerializer")||jt.fromSchema(e.state.schema),a=lg(),l=a.createElement("div");l.appendChild(i.serializeFragment(r,{document:a}));let c=l.firstChild,u,d=0;while(c&&V(c)&&(u=ag[c.nodeName.toLowerCase()])){for(let h=u.length-1;h>=0;h--){let p=a.createElement(u[h]);while(l.firstChild)p.appendChild(l.firstChild);l.appendChild(p),d++}c=l.firstChild}if(c&&V(c))c.setAttribute("data-pm-slice",`${s} ${o}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=e.someProp("clipboardTextSerializer",(h)=>h(t,e))||t.content.textBetween(0,t.content.size,`
|
|
12
|
+
|
|
13
|
+
`);return{dom:l,text:f,slice:t}}function rg(e,t,n,r,s){let o=s.parent.type.spec.code,i,a;if(!n&&!t)return null;let l=!!t&&(r||o||!n);if(l){if(e.someProp("transformPastedText",(f)=>{t=f(t,o||r,e)}),o)return a=new _(S.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
14
|
+
`))),0,0),e.someProp("transformPasted",(f)=>{a=f(a,e,!0)}),a;let d=e.someProp("clipboardTextParser",(f)=>f(t,s,r,e));if(d)a=d;else{let f=s.marks(),{schema:h}=e.state,p=jt.fromSchema(h);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((m)=>{let g=i.appendChild(document.createElement("p"));if(m)g.appendChild(p.serializeNode(h.text(m,f)))})}}else if(e.someProp("transformPastedHTML",(d)=>{n=d(n,e)}),i=_w(n),ba)Nw(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=i.firstChild;while(f&&!V(f))f=f.nextSibling;if(!f)break;i=f}if(!a)a=(e.someProp("clipboardParser")||e.someProp("domParser")||Nt.fromSchema(e.state.schema)).parseSlice(i,{preserveWhitespace:!!(l||u),context:s,ruleFromNode(f){if(f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!ww.test(f.parentNode.nodeName))return{ignore:!0};return null}});if(u)a=Ow(_m(a,+u[1],+u[2]),u[4]);else if(a=_.maxOpen(Cw(a.content,s),!0),a.openStart||a.openEnd){let d=0,f=0;for(let h=a.content.firstChild;d<a.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=a.content.lastChild;f<a.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);a=_m(a,d,f)}return e.someProp("transformPasted",(d)=>{a=d(a,e,l)}),a}var ww=/^(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 Cw(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let s=t.node(n).contentMatchAt(t.index(n)),o,i=[];if(e.forEach((a)=>{if(!i)return;let l=s.findWrapping(a.type),c;if(!l)return i=null;if(c=i.length&&o.length&&og(l,o,a,i[i.length-1],0))i[i.length-1]=c;else{if(i.length)i[i.length-1]=ig(i[i.length-1],o.length);let u=sg(a,l);i.push(u),s=s.matchType(u.type),o=l}}),i)return S.from(i)}return e}function sg(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,S.from(e));return e}function og(e,t,n,r,s){if(s<e.length&&s<t.length&&e[s]==t[s]){let o=og(e,t,n,r.lastChild,s+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(s==e.length-1?n.type:e[s+1]))return r.copy(r.content.append(S.from(sg(n,e,s+1))))}}function ig(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,ig(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(S.empty,!0);return e.copy(n.append(r))}function iu(e,t,n,r,s,o){let i=t<0?e.firstChild:e.lastChild,a=i.content;if(e.childCount>1)o=0;if(s<r-1)a=iu(a,t,n,r,s+1,o);if(s>=n)a=t<0?i.contentMatchAt(0).fillBefore(a,o<=s).append(a):a.append(i.contentMatchAt(i.childCount).fillBefore(S.empty,!0));return e.replaceChild(t<0?0:e.childCount-1,i.copy(a))}function _m(e,t,n){if(t<e.openStart)e=new _(iu(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd);if(n<e.openEnd)e=new _(iu(e.content,1,n,e.openEnd,0,0),e.openStart,n);return e}var ag={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function lg(){return document.implementation.createHTMLDocument("title")}var So=null;function kw(e){let t=window.trustedTypes;if(!t)return e;if(!So){if(So=t.defaultPolicy)try{return So.createHTML(e)}catch(n){}So=t.createPolicy("ProseMirrorClipboard",{createHTML:(n)=>n})}return So.createHTML(e)}function _w(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);if(t)e=e.slice(t[0].length);let n=lg(),r=n.body,s=/<([a-z][^>\s]+)/i.exec(e),o;if(o=s&&ag[s[1].toLowerCase()])e=o.map((i)=>"<"+i+">").join("")+e+o.map((i)=>"</"+i+">").reverse().join("");if(r.innerHTML=kw(e),o)for(let i=0;i<o.length;i++)r=r.querySelector(o[i])||r;for(let i=0;i<n.styleSheets.length;i++){let a=n.styleSheets[i];for(let l=0;l<a.rules.length;l++){let c=a.rules[l];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return r}function Nw(e){let t=e.querySelectorAll(De?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];if(r.childNodes.length==1&&r.textContent==" "&&r.parentNode)r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}function Ow(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch(a){return e}let{content:s,openStart:o,openEnd:i}=e;for(let a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;try{s=S.from(l.create(r[a+1],s))}catch(c){break}o++,i++}return new _(s,o,i)}var je={},We={},Iw={touchstart:!0,touchmove:!0};class cg{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-200000000,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Mw(e){for(let t in je){let n=je[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=(r)=>{if(Dw(e,r)&&!pu(e,r)&&(e.editable||!(r.type in We)))n(e,r)},Iw[t]?{passive:!0}:void 0)}if($e)e.dom.addEventListener("input",()=>null);au(e)}function Jt(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Rw(e){if(e.input.mouseDown)e.input.mouseDown.done();e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function au(e){e.someProp("handleDOMEvents",(t)=>{for(let n in t)if(!e.input.eventHandlers[n])e.dom.addEventListener(n,e.input.eventHandlers[n]=(r)=>pu(e,r))})}function pu(e,t){return e.someProp("handleDOMEvents",(n)=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function Dw(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function vw(e,t){if(!pu(e,t)&&je[t.type]&&(e.editable||!(t.type in We)))je[t.type](e,t)}function yn(e,t){let{input:n}=e;if(n.lastKeyDispatched||e.composing)return!1;if(n.lastKeyDispatched=!0,typeof t=="string")t=zA(t=="Backspace"?8:13,t);return e.someProp("handleKeyDown",(r)=>r(e,t))}We.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,pg(e))return;if(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),e.input.lastKeyDispatched=!1,Gt&&De&&n.keyCode==13)return;if(n.keyCode!=229)e.domObserver.forceFlush();if(rs&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();e.input.lastIOSEnter=r,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{if(e.input.lastIOSEnter==r)yn(e,"Enter"),e.input.lastIOSEnter=0},200)}else if(yn(e,n)||Aw(e,n))n.preventDefault();else Jt(e,"key")};We.keyup=(e,t)=>{if(t.keyCode==16)e.input.shiftKey=!1};We.keypress=(e,t)=>{let n=t;if(pg(e)||!n.charCode||n.ctrlKey&&!n.altKey||gt&&n.metaKey)return;if(e.someProp("handleKeyPress",(s)=>s(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof I)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),o=()=>e.state.tr.insertText(s).scrollIntoView();if(!/[\r\n]/.test(s)&&!e.someProp("handleTextInput",(i)=>i(e,r.$from.pos,r.$to.pos,s,o)))e.dispatch(o());n.preventDefault()}};function No(e){return{left:e.clientX,top:e.clientY}}function Lw(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function mu(e,t,n,r,s){if(r==-1)return!1;let o=e.state.doc.resolve(r);for(let i=o.depth+1;i>0;i--)if(e.someProp(t,(a)=>i>o.depth?a(e,n,o.nodeAfter,o.before(i),s,!0):a(e,n,o.node(i),o.before(i),s,!1)))return!0;return!1}function Oo(e,t,n){if(!e.focused)e.focus();if(e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function Pw(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;if(r&&r.isAtom&&M.isSelectable(r))return Oo(e,new M(n)),!0;return!1}function Bw(e,t){if(t==-1)return!1;let n=e.state.selection,r,s;if(n instanceof M)r=n.node;let o=e.state.doc.resolve(t);for(let i=o.depth+1;i>0;i--){let a=i>o.depth?o.nodeAfter:o.node(i);if(M.isSelectable(a)){if(r&&n.$from.depth>0&&i>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos)s=o.before(n.$from.depth);else s=o.before(i);break}}if(s!=null)return Oo(e,M.create(e.state.doc,s)),!0;else return!1}function Fw(e,t,n,r,s){return mu(e,"handleClickOn",t,n,r)||e.someProp("handleClick",(o)=>o(e,t,r))||(s?Bw(e,n):Pw(e,n))}function Uw(e,t,n,r){return mu(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",(s)=>s(e,t,r))}function Hw(e,t,n,r){return mu(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",(s)=>s(e,t,r))||$w(e,n,r)}function $w(e,t,n){if(n.button!=0)return!1;let r=ug(e,t,!0),s=e.state.doc;if(!r)return!1;if(Oo(e,r),r instanceof I&&s.eq(e.state.doc))e.input.mouseDown=new hg(e,r);return!0}function ug(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?I.create(r,0,r.content.size):null;let s=r.resolve(t);for(let o=s.depth+1;o>0;o--){let i=o>s.depth?s.nodeAfter:s.node(o),a=s.before(o);if(i.inlineContent)return I.create(r,a+1,a+1+i.content.size);else if(n&&M.isSelectable(i))return M.create(r,a)}return null}function gu(e){return ma(e)}var dg=gt?"metaKey":"ctrlKey";je.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=gu(e),s=Date.now(),o="singleClick";if(s-e.input.lastClick.time<500&&Lw(n,e.input.lastClick)&&!n[dg]&&e.input.lastClick.button==n.button){if(e.input.lastClick.type=="singleClick")o="doubleClick";else if(e.input.lastClick.type=="doubleClick")o="tripleClick"}if(e.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:o,button:n.button},e.input.mouseDown)e.input.mouseDown.done();let i=e.posAtCoords(No(n));if(!i)return;if(o=="singleClick")e.input.mouseDown=new fg(e,i,n,!!r);else if((o=="doubleClick"?Uw:Hw)(e,i.pos,i.inside,n))n.preventDefault();else Jt(e,"pointer")};class yu{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){if(e.buttons==0)this.done()}done(){if(this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this)this.view.input.mouseDown=null}delaySelUpdate(){return!1}}class fg extends yu{constructor(e,t,n,r){super(e);this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[dg],this.allowDefault=n.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let c=e.state.doc.resolve(t.pos);s=c.parent,o=c.depth?c.before():0}let i=r?null:n.target,a=i?e.docView.nearestDesc(i,!0):null;this.target=a&&V(a.nodeDOM)?a.nodeDOM:null;let{selection:l}=e.state;if(n.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||l instanceof M&&l.from<=o&&l.to>o))this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&at&&!this.target.hasAttribute("contentEditable"))};if(this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)){if(this.view.domObserver.stop(),this.mightDrag.addAttr)this.target.draggable=!0;if(this.mightDrag.setUneditable)setTimeout(()=>{if(this.view.input.mouseDown==this)this.target.setAttribute("contentEditable","false")},20);this.view.domObserver.start()}Jt(e,"pointer")}done(){if(super.done(),this.mightDrag&&this.target){if(this.view.domObserver.stop(),this.mightDrag.addAttr)this.target.removeAttribute("draggable");if(this.mightDrag.setUneditable)this.target.removeAttribute("contentEditable");this.view.domObserver.start()}if(this.delayedSelectionSync)setTimeout(()=>{if(!this.view.isDestroyed)Qt(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;if(this.view.state.doc!=this.startDoc)t=this.view.posAtCoords(No(e));if(this.updateAllowDefault(e),this.allowDefault||!t)Jt(this.view,"pointer");else if(Fw(this.view,t.pos,t.inside,e,this.selectNode))e.preventDefault();else if(e.button==0&&(this.flushed||$e&&this.mightDrag&&!this.mightDrag.node.isAtom||De&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2))Oo(this.view,U.near(this.view.state.doc.resolve(t.pos))),e.preventDefault();else Jt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Jt(this.view,"pointer"),super.move(e)}updateAllowDefault(e){if(!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4))this.allowDefault=!0}delaySelUpdate(){if(!this.allowDefault)return!1;return this.delayedSelectionSync=!0,!0}}class hg extends yu{constructor(e,t){super(e);this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Jt(this.view,"pointer");let t=this.view.posAtCoords(No(e)),n=t&&ug(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,s=this.startSelection,[o,i]=n.from<s.from?[s.to,n.from]:[s.from,n.to];Oo(this.view,I.create(r,o,i))}}je.touchstart=(e)=>{e.input.lastTouch=Date.now(),gu(e),Jt(e,"pointer")};je.touchmove=(e)=>{e.input.lastTouch=Date.now(),Jt(e,"pointer")};je.contextmenu=(e)=>gu(e);function pg(e,t){if(e.composing)return!0;if($e&&Math.abs(Date.now()-e.input.compositionEndedAt)<500)return e.input.compositionEndedAt=-200000000,!0;return!1}var Vw=Gt?5000:-1;We.compositionstart=We.compositionupdate=(e)=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof I&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((r)=>r.type.spec.inclusive===!1)||De&&Hm&&zw(e)))e.markCursor=e.state.storedMarks||n.marks(),ma(e,!0),e.markCursor=null;else if(ma(e,!t.selection.empty),at&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=e.domSelectionRange();for(let{focusNode:s,focusOffset:o}=r;s&&V(s)&&o!=0;){let i=o<0?s.lastChild:s.childNodes[o-1];if(!i)break;if(Ce(i)){let a=e.domSelection();if(a)a.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}e.input.composing=!0}mg(e,Vw)};function zw(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!V(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return V(r)&&r.contentEditable=="false"}We.compositionend=(e,t)=>{if(e.composing){if(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition)e.domObserver.forceFlush();else if(e.input.compositionPendingChanges)Promise.resolve().then(()=>e.domObserver.flush());e.input.compositionID++,mg(e,20)}};function mg(e,t){if(clearTimeout(e.input.composingTimeout),t>-1)e.input.composingTimeout=setTimeout(()=>ma(e),t)}function gg(e){if(e.composing)e.input.composing=!1,e.input.compositionEndedAt=Date.now();while(e.input.compositionNodes.length>0)e.input.compositionNodes.pop().markParentsDirty()}function Yw(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=HA(t.focusNode,t.focusOffset),r=$A(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!s||!s.isText(r.nodeValue))return r;else if(e.input.compositionNode==r){let i=n.pmViewDesc;if(!(!i||!i.isText(n.nodeValue)))return r}}return n||r}function ma(e,t=!1){if(Gt&&e.domObserver.flushingSoon>=0)return;if(e.domObserver.forceFlush(),gg(e),t||e.docView&&e.docView.dirty){let n=du(e),r=e.state.selection;if(n&&!n.eq(r))e.dispatch(e.state.tr.setSelection(n));else if((e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent)e.dispatch(e.state.tr.deleteSelection());else e.updateState(e.state);return!0}return!1}function jw(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{if(n.parentNode)n.parentNode.removeChild(n);e.focus()},50)}var wo=Qe&&Tn<15||rs&&WA<604;je.copy=We.cut=(e,t)=>{let n=t,r=e.state.selection,s=n.type=="cut";if(r.empty)return;let o=wo?null:n.clipboardData,i=r.content(),{dom:a,text:l}=hu(e,i);if(o)n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l);else jw(e,a);if(s)e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Ww(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Kw(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));if(!n)r.contentEditable="true";r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{if(e.focus(),r.parentNode)r.parentNode.removeChild(r);if(n)Co(e,r.value,null,s,t);else Co(e,r.textContent,r.innerHTML,s,t)},50)}function Co(e,t,n,r,s){let o=rg(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",(l)=>l(e,s,o||_.empty)))return!0;if(!o)return!1;let i=Ww(o),a=i?e.state.tr.replaceSelectionWith(i,r):e.state.tr.replaceSelection(o);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function yg(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}We.paste=(e,t)=>{let n=t;if(e.composing&&!Gt)return;let r=wo?null:n.clipboardData,s=e.input.shiftKey&&e.input.lastKeyCode!=45;if(r&&Co(e,yg(r),r.getData("text/html"),s,n))n.preventDefault();else Kw(e,n)};class Eu{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}var qw=gt?"altKey":"ctrlKey";function Eg(e,t){let n;return e.someProp("dragCopies",(r)=>{n=n||r(t)}),n!=null?!n:!t[qw]}je.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r)r.done();if(!n.dataTransfer)return;let s=e.state.selection,o=s.empty?null:e.posAtCoords(No(n)),i;if(o&&o.pos>=s.from&&o.pos<=(s instanceof M?s.to-1:s.to));else if(r&&r.mightDrag)i=M.create(e.state.doc,r.mightDrag.pos);else if(n.target&&V(n.target)){let d=e.docView.nearestDesc(n.target,!0);if(d&&d.node.type.spec.draggable&&d!=e.docView)i=M.create(e.state.doc,d.posBefore)}let a=(i||e.state.selection).content(),{dom:l,text:c,slice:u}=hu(e,a);if(!n.dataTransfer.files.length||!De||Um>120)n.dataTransfer.clearData();if(n.dataTransfer.setData(wo?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",!wo)n.dataTransfer.setData("text/plain",c);e.dragging=new Eu(u,Eg(e,n),i)};je.dragend=(e)=>{let t=e.dragging;window.setTimeout(()=>{if(e.dragging==t)e.dragging=null},50)};We.dragover=We.dragenter=(e,t)=>t.preventDefault();We.drop=(e,t)=>{try{Xw(e,t,e.dragging)}finally{e.dragging=null}};function Xw(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(No(t));if(!r)return;let s=e.state.doc.resolve(r.pos),o=n&&n.slice;if(o)e.someProp("transformPasted",(h)=>{o=h(o,e,!1)});else o=rg(e,yg(t.dataTransfer),wo?null:t.dataTransfer.getData("text/html"),!1,s);let i=!!(n&&Eg(e,t));if(e.someProp("handleDrop",(h)=>h(e,t,o||_.empty,i))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?ca(e.state.doc,s.pos,o):s.pos;if(a==null)a=s.pos;let l=e.state.tr;if(i){let{node:h}=n;if(h)h.replace(l);else l.deleteSelection()}let c=l.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=l.doc;if(u)l.replaceRangeWith(c,c,o.content.firstChild);else l.replaceRange(c,c,o);if(l.doc.eq(d))return;let f=l.doc.resolve(c);if(u&&M.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new M(f));else{let h=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((p,m,g,E)=>h=E),l.setSelection(fu(e,f,l.doc.resolve(h)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}je.focus=(e)=>{if(e.input.lastFocus=Date.now(),!e.focused){e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0;let t=e.domSelectionRange();if(!e.domObserver.currentSelection.eq(t)){let{focusNode:n,focusOffset:r}=t;setTimeout(()=>{let s=e.domSelectionRange();if(s.focusNode==n&&s.focusOffset==r&&e.docView&&e.hasFocus())Qt(e)},20)}}};je.blur=(e,t)=>{let n=t;if(e.focused){if(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget))e.domObserver.currentSelection.clear();e.focused=!1}};je.beforeinput=(e,t)=>{if(Gt&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:r}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=r||e.domObserver.pendingRecords().length)return;if(e.dom.blur(),e.focus(),yn(e,"Backspace"))return;let{$cursor:s}=e.state.selection;if(s&&s.pos>0)e.dispatch(e.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let e in We)je[e]=We[e];function ko(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class ga{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){while(this.off<=e&&this.index<this.frag.childCount){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}}class ya{constructor(e,t){this.toDOM=e,this.spec=t||nr,this.side=this.spec.side||0}map(e,t,n,r){let{pos:s,deleted:o}=e.mapResult(t.from+r,this.side<0?-1:1);return o?null:new ae(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof ya&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ko(this.spec,e.spec))}destroy(e){if(this.spec.destroy)this.spec.destroy(e)}}class xn{constructor(e,t){this.attrs=e,this.spec=t||nr}map(e,t,n,r){let s=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return s>=o?null:new ae(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof xn&&ko(this.attrs,e.attrs)&&ko(this.spec,e.spec)}static is(e){return e.type instanceof xn}destroy(){}}class Tu{constructor(e,t){this.attrs=e,this.spec=t||nr}map(e,t,n,r){let s=e.mapResult(t.from+r,1);if(s.deleted)return null;let o=e.mapResult(t.to+r,-1);if(o.deleted||o.pos<=s.pos)return null;return new ae(s.pos-n,o.pos-n,this)}valid(e,t,n){let r=n.nodeAt(t.from);return!!r&&!r.isText&&t.from+r.nodeSize==t.to}eq(e){return this==e||e instanceof Tu&&ko(this.attrs,e.attrs)&&ko(this.spec,e.spec)}destroy(){}}class ae{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new ae(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new ae(e,e,new ya(t,n))}static inline(e,t,n,r){return new ae(e,t,new xn(n,r))}static node(e,t,n,r){return new ae(e,t,new Tu(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof xn}get widget(){return this.type instanceof ya}}var ts=[],nr={};class j{constructor(e,t){this.local=e.length?e:ts,this.children=t.length?t:ts}static create(e,t){return t.length?Ea(t,e,0,nr):Ue}find(e,t,n){let r=[];return this.findInner(e==null?0:e,t==null?1e9:t,r,0,n),r}findInner(e,t,n,r,s){for(let o=0;o<this.local.length;o++){let i=this.local[o];if(i.from<=t&&i.to>=e&&(!s||s(i.spec)))n.push(i.copy(i.from+r,i.to+r))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let i=this.children[o]+1;this.children[o+2].findInner(e-i,t-i,n,r+i,s)}}map(e,t,n){if(this==Ue||e.maps.length==0)return this;return this.mapInner(e,t,0,0,n||nr)}mapInner(e,t,n,r,s){let o;if(this.local.length){let i=new ga(t.content);for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,n,r);if(l&&l.type.valid(t,l,i))(o||(o=[])).push(l);else if(s.onRemove)s.onRemove(this.local[a].spec)}}if(this.children.length)return Gw(this.children,o||[],e,t,n,r,s);else return o?new j(o.sort(rr),ts):Ue}add(e,t){if(!t.length)return this;if(this==Ue)return j.create(e,t);return this.addInner(e,t,0)}addInner(e,t,n){let r,s=0;e.forEach((i,a)=>{let l=a+n,c;if(!(c=bg(t,i,l)))return;if(!r)r=this.children.slice();while(s<r.length&&r[s]<a)s+=3;if(r[s]==a)r[s+2]=r[s+2].addInner(i,c,l+1);else r.splice(s,0,a,a+i.nodeSize,Ea(c,i,l+1,nr));s+=3});let o=Tg(s?Sg(t):t,-n);if(o.length){let i=new ga(e.content);for(let a=0;a<o.length;a++)if(!o[a].type.valid(e,o[a],i))o.splice(a--,1)}return new j(o.length?this.local.concat(o).sort(rr):this.local,r||this.children)}remove(e){if(e.length==0||this==Ue)return this;return this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let s=0;s<n.length;s+=3){let o,i=n[s]+t,a=n[s+1]+t;for(let c=0,u;c<e.length;c++)if(u=e[c]){if(u.from>i&&u.to<a)e[c]=null,(o||(o=[])).push(u)}if(!o)continue;if(n==this.children)n=this.children.slice();let l=n[s+2].removeInner(o,i+1);if(l!=Ue)n[s+2]=l;else n.splice(s,3),s-=3}if(r.length){for(let s=0,o;s<e.length;s++)if(o=e[s]){for(let i=0;i<r.length;i++)if(r[i].eq(o,t)){if(r==this.local)r=this.local.slice();r.splice(i--,1)}}}if(n==this.children&&r==this.local)return this;return r.length||n.length?new j(r,n):Ue}forChild(e,t){if(this==Ue)return this;if(t.isLeaf)return j.empty;let n,r;for(let i=0;i<this.children.length;i+=3)if(this.children[i]>=e){if(this.children[i]==e)n=this.children[i+2];break}let s=e+1,o=s+t.content.size;for(let i=0;i<this.local.length;i++){let a=this.local[i];if(a.from<o&&a.to>s&&a.type instanceof xn){let l=Math.max(s,a.from)-s,c=Math.min(o,a.to)-s;if(l<c)(r||(r=[])).push(a.copy(l,c))}}if(r){let i=new j(r.sort(rr),ts);return n?new En([i,n]):i}return n||Ue}eq(e){if(this==e)return!0;if(!(e instanceof j)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return bu(this.localsInner(e))}localsInner(e){if(this==Ue)return ts;if(e.inlineContent||!this.local.some(xn.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)if(!(this.local[n].type instanceof xn))t.push(this.local[n]);return t}forEachSet(e){e(this)}}j.empty=new j([],[]);j.removeOverlap=bu;var Ue=j.empty;class En{constructor(e){this.members=e}map(e,t){let n=this.members.map((r)=>r.map(e,t,nr));return En.from(n)}forChild(e,t){if(t.isLeaf)return j.empty;let n=[];for(let r=0;r<this.members.length;r++){let s=this.members[r].forChild(e,t);if(s==Ue)continue;if(s instanceof En)n=n.concat(s.members);else n.push(s)}return En.from(n)}eq(e){if(!(e instanceof En)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let s=this.members[r].localsInner(e);if(!s.length)continue;if(!t)t=s;else{if(n)t=t.slice(),n=!1;for(let o=0;o<s.length;o++)t.push(s[o])}}return t?bu(n?t:t.sort(rr)):ts}static from(e){switch(e.length){case 0:return Ue;case 1:return e[0];default:return new En(e.every((t)=>t instanceof j)?e:e.reduce((t,n)=>t.concat(n instanceof j?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Gw(e,t,n,r,s,o,i){let a=e.slice();for(let c=0,u=o;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let E=0;E<a.length;E+=3){let x=a[E+1];if(x<0||f>x+u-d)continue;let w=a[E]+u-d;if(h>=w)a[E+1]=f<=w?-2:-1;else if(f>=u&&g)a[E]+=g,a[E+1]+=g}d+=g}),u=n.maps[c].map(u,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let u=n.map(e[c]+o),d=u-s;if(d<0||d>=r.content.size){l=!0;continue}let f=n.map(e[c+1]+o,-1),h=f-s,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let E=a[c+2].mapInner(n,g,u+1,e[c]+o+1,i);if(E!=Ue)a[c]=d,a[c+1]=h,a[c+2]=E;else a[c+1]=-2,l=!0}else l=!0}if(l){let c=Jw(a,e,t,n,s,o,i),u=Ea(c,r,0,i);t=u.local;for(let d=0;d<a.length;d+=3)if(a[d+1]<0)a.splice(d,3),d-=3;for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];while(f<a.length&&a[f]<h)f+=3;a.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new j(t.sort(rr),a)}function Tg(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let s=e[r];n.push(new ae(s.from+t,s.to+t,s.type))}return n}function Jw(e,t,n,r,s,o,i){function a(l,c){for(let u=0;u<l.local.length;u++){let d=l.local[u].map(r,s,c);if(d)n.push(d);else if(i.onRemove)i.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<e.length;l+=3)if(e[l+1]==-1)a(e[l+2],t[l]+o+1);return n}function bg(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,s=null;for(let o=0,i;o<e.length;o++)if((i=e[o])&&i.from>n&&i.to<r)(s||(s=[])).push(i),e[o]=null;return s}function Sg(e){let t=[];for(let n=0;n<e.length;n++)if(e[n]!=null)t.push(e[n]);return t}function Ea(e,t,n,r){let s=[],o=!1;t.forEach((a,l)=>{let c=bg(e,a,l+n);if(c){o=!0;let u=Ea(c,a,n+l+1,r);if(u!=Ue)s.push(l,l+a.nodeSize,u)}});let i=Tg(o?Sg(e):e,-n).sort(rr);if(i.length){let a=new ga(t.content);for(let l=0;l<i.length;l++)if(!i[l].type.valid(t,i[l],a)){if(r.onRemove)r.onRemove(i[l].spec);i.splice(l--,1)}}return i.length||s.length?new j(i,s):Ue}function rr(e,t){return e.from-t.from||e.to-t.to}function bu(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let s=n+1;s<t.length;s++){let o=t[s];if(o.from==r.from){if(o.to!=r.to){if(t==e)t=e.slice();t[s]=o.copy(o.from,r.to),Nm(t,s+1,o.copy(r.to,o.to))}continue}else{if(o.from<r.to){if(t==e)t=e.slice();t[n]=r.copy(r.from,o.from),Nm(t,s,r.copy(o.from,r.to))}break}}}return t}function Nm(e,t,n){while(t<e.length&&rr(n,e[t])>0)t++;e.splice(t,0,n)}function Xc(e){let t=[];if(e.someProp("decorations",(n)=>{let r=n(e.state);if(r&&r!=Ue)t.push(r)}),e.cursorWrapper)t.push(j.create(e.state.doc,[e.cursorWrapper.deco]));return En.from(t)}var Qw={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Zw=Qe&&Tn<=11;class xg{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Ag{constructor(e,t){if(this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new xg,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((n)=>{for(let r=0;r<n.length;r++)this.queue.push(n[r]);if(Qe&&Tn<=11&&n.some((r)=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length))this.flushSoon();else if($e&&e.composing&&n.some((r)=>r.type=="childList"&&r.target.nodeName=="TR"))e.input.badSafariComposition=!0,this.flushSoon();else this.flush()}),Zw)this.onCharData=(n)=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()};this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){if(this.flushingSoon<0)this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20)}forceFlush(){if(this.flushingSoon>-1)window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush()}start(){if(this.observer)this.observer.takeRecords(),this.observer.observe(this.view.dom,Qw);if(this.onCharData)this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData);this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}if(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(!Sm(this.view))return;if(this.suppressingSelectionUpdates)return Qt(this.view);if(Qe&&Tn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&sr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let s=e.focusNode;s;s=ns(s))t.add(s);for(let s=e.anchorNode;s;s=ns(s))if(t.has(s)){n=s;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:"selection",target:Ce(n)?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();if(t.length)this.queue=[];let n,r=!1;if(!this.suppressingSelectionUpdates&&Sm(e))n=e.domSelectionRange(),r=!this.currentSelection.eq(n)&&!this.ignoreSelectionChange(n);let s=-1,o=-1,i=!1,a=[];if(e.editable)for(let c=0;c<t.length;c++){let u=this.registerMutation(t[c],a);if(u){if(s=s<0?u.from:Math.min(u.from,s),o=o<0?u.to:Math.max(u.to,o),u.typeOver)i=!0}}if(a.some((c)=>c.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||De&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some((c)=>c.type=="childList"&&c.removedNodes.length))){for(let c of a)if(c.nodeName=="BR"&&c.parentNode){let u=c.nextSibling;while(u&&V(u)){if(u.contentEditable=="false"){c.parentNode.removeChild(c);break}u=u.firstChild}}}else if(at&&a.length){let c=a.filter((u)=>u.nodeName=="BR");if(c.length==2){let[u,d]=c;if(u.parentNode&&u.parentNode.parentNode==d.parentNode)d.remove();else u.remove()}else{let{focusNode:u}=this.currentSelection;for(let d of c){let f=d.parentNode;if(f&&f.nodeName=="LI"&&(!u||nC(e,u)!=f))d.remove()}}}let l=null;if(s<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ta(n)&&(l=du(e))&&l.eq(U.near(e.state.doc.resolve(0),1)))e.input.lastFocus=0,Qt(e),this.currentSelection.set(n),e.scrollToSelection();else if(s>-1||r){if(s>-1)e.docView.markDirty(s,o),eC(e);if(e.input.badSafariComposition)e.input.badSafariComposition=!1,rC(e,a);if(this.handleDOMChange(s,o,i,a),e.docView&&e.docView.dirty)e.updateState(e.state);else if(n&&!this.currentSelection.eq(n))Qt(e);if(n)this.currentSelection.set(n)}}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;c<e.addedNodes.length;c++){let u=e.addedNodes[c];if(t.push(u),Ce(u))this.lastChangedTextNode=u}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let{previousSibling:r,nextSibling:s}=e;if(Qe&&Tn<=11&&e.addedNodes.length)for(let c=0;c<e.addedNodes.length;c++){let{previousSibling:u,nextSibling:d}=e.addedNodes[c];if(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)r=u;if(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)s=d}let o=r&&r.parentNode==e.target?Re(r)+1:0,i=n.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?Re(s):e.target.childNodes.length,l=n.localPosFromDOM(e.target,a,1);return{from:i,to:l}}else if(e.type=="attributes")return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}var Om=new WeakMap,Im=!1;function eC(e){if(Om.has(e))return;if(Om.set(e,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1){if(e.requiresGeckoHackNode=at,Im)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."),Im=!0}}function Mm(e,t){let{startContainer:n,startOffset:r,endContainer:s,endOffset:o}=t,i=e.domAtPos(e.state.selection.anchor);if(sr(i.node,i.offset,s,o))[n,r,s,o]=[s,o,n,r];return{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function tC(e,t){if(t.getComposedRanges){let s=t.getComposedRanges(e.root)[0];if(s)return Mm(e,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?Mm(e,n):null}function nC(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let r=e.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function rC(e,t){var n;let{focusNode:r,focusOffset:s}=e.domSelectionRange();for(let o of t)if(((n=o.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let i=o.nextSibling;while(i&&(i.nodeName!="TD"&&i.nodeName!="TH"))i=i.nextSibling;if(i){let a=i;for(;;){let l=a.firstChild;if(!l||!V(l)||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;a=l}if(a.insertBefore(o,a.firstChild),r==o)e.domSelection().collapse(o,s)}else o.parentNode.removeChild(o)}}function sC(e,t,n,r){let{node:s,fromOffset:o,toOffset:i,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelectionRange(),u,d=c.anchorNode;if(d&&or(e.dom,d)){if(u=[{node:d,offset:c.anchorOffset}],!Ta(c))u.push({node:c.focusNode,offset:c.focusOffset})}if(De&&e.input.lastKeyCode===8)for(let E=i;E>o;E--){let x=s.childNodes[E-1],w=x.pmViewDesc;if(x.nodeName=="BR"&&!w){i=E;break}if(!w||w.size)break}let f=e.state.doc,h=e.someProp("domParser")||Nt.fromSchema(e.state.schema),p=f.resolve(a),m=null,g=h.parse(s,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:i,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:oC(r),context:p});if(u&&u[0].pos!=null){let E=u[0].pos,x=u[1]&&u[1].pos;if(x==null)x=E;m={anchor:E+a,head:x+a}}return{doc:g,sel:m,from:a,to:l}}var oC=(e)=>(t)=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);else if(t.nodeName=="BR"&&t.parentNode){if($e&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(t.parentNode.lastChild==t||$e&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},iC=/^(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 aC(e,t,n,r,s){let o=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let R=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,P=du(e,R);if(P&&!e.state.selection.eq(P)){if(De&&Gt&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&yn(e,"Enter"))return;let H=e.state.tr.setSelection(P);if(R=="pointer")H.setMeta("pointer",!0);else if(R=="key")H.scrollIntoView();if(o)H.setMeta("composition",o);e.dispatch(H)}return}let i=e.state.doc.resolve(t),a=i.sharedDepth(n);t=i.before(a+1),n=e.state.doc.resolve(n).after(a+1);let l=e.state.selection,c=sC(e,t,n,s),u=e.state.doc,d=u.slice(c.from,c.to),f,h;if(e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime)f=e.state.selection.to,h="end";else f=e.state.selection.from,h="start";e.input.lastKeyCode=null;let p=dC(d.content,c.doc.content,c.from,f,h);if(p)e.input.domChangeCount++;if((rs&&e.input.lastIOSEnter>Date.now()-225||Gt)&&s.some((R)=>V(R)&&!iC.test(R.nodeName))&&(!p||p.endA>=p.endB)&&yn(e,"Enter")){e.input.lastIOSEnter=0;return}if(!p)if(r&&l instanceof I&&!l.empty&&l.$head.sameParent(l.$anchor)&&!e.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let R=Rm(e,e.state.doc,c.sel);if(R&&!R.eq(e.state.selection)){let P=e.state.tr.setSelection(R);if(o)P.setMeta("composition",o);e.dispatch(P)}}return}if(e.state.selection.from<e.state.selection.to&&p.start==p.endB&&e.state.selection instanceof I){if(p.start>e.state.selection.from&&p.start<=e.state.selection.from+2&&e.state.selection.from>=c.from)p.start=e.state.selection.from;else if(p.endA<e.state.selection.to&&p.endA>=e.state.selection.to-2&&e.state.selection.to<=c.to)p.endB+=e.state.selection.to-p.endA,p.endA=e.state.selection.to}if(Qe&&Tn<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" ")p.start--,p.endA--,p.endB--;let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),E=u.resolve(p.start),x=m.sameParent(g)&&m.parent.inlineContent&&E.end()>=p.endA;if((rs&&e.input.lastIOSEnter>Date.now()-225&&(!x||s.some((R)=>R.nodeName=="DIV"||R.nodeName=="P"))||!x&&uC(c.doc,m.pos,g.pos))&&yn(e,"Enter")){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>p.start&&(x?p.endA>p.start&&p.endB==p.start:cC(u,p.start,p.endA,m,g))&&yn(e,"Backspace")){if(Gt&&De)e.domObserver.suppressSelectionUpdates();return}if(De&&p.endB==p.start)e.input.lastChromeDelete=Date.now();if(Gt&&!x&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA)p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>yn(e,"Enter"),20);let w=p.start,b=p.endA,v=(R)=>{let P=R||e.state.tr.replace(w,b,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let H=Rm(e,P.doc,c.sel);if(H&&!(De&&e.composing&&H.empty&&(p.start!=p.endB||e.input.lastChromeDelete<Date.now()-100)&&(H.head==w||H.head==P.mapping.map(b)-1)||Qe&&H.empty&&H.head==w))P.setSelection(H)}if(o)P.setMeta("composition",o);return P.scrollIntoView()},D;if(x)if(m.pos==g.pos){if(Qe&&Tn<=11&&m.parentOffset==0)e.domObserver.suppressSelectionUpdates(),setTimeout(()=>Qt(e),20);let R=v(e.state.tr.delete(w,b)),P=u.resolve(p.start).marksAcross(u.resolve(p.endA));if(P)R.ensureMarks(P);e.dispatch(R)}else if(p.endA==p.endB&&(D=lC(m.parent.content.cut(m.parentOffset,g.parentOffset),E.parent.content.cut(E.parentOffset,p.endA-E.start())))){let R=v(e.state.tr);if(D.type=="add")R.addMark(w,b,D.mark);else R.removeMark(w,b,D.mark);e.dispatch(R)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let R=m.parent.textBetween(m.parentOffset,g.parentOffset),P=()=>v(e.state.tr.insertText(R,w,b));if(!e.someProp("handleTextInput",(H)=>H(e,w,b,R,P)))e.dispatch(P())}else e.dispatch(v());else e.dispatch(v())}function Rm(e,t,n){if(Math.max(n.anchor,n.head)>t.content.size)return null;return fu(e,t.resolve(n.anchor),t.resolve(n.head))}function lC(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,s=n,o=r,i,a,l;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<n.length;u++)o=n[u].removeFromSet(o);if(s.length==1&&o.length==0)a=s[0],i="add",l=(u)=>u.mark(a.addToSet(u.marks));else if(s.length==0&&o.length==1)a=o[0],i="remove",l=(u)=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<t.childCount;u++)c.push(l(t.child(u)));if(S.from(c).eq(e))return{mark:a,type:i}}function cC(e,t,n,r,s){if(n-t<=s.pos-r.pos||Gc(r,!0,!1)<s.pos)return!1;let o=e.resolve(t);if(!r.parent.inlineContent){let a=o.nodeAfter;return a!=null&&n==t+a.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let i=e.resolve(Gc(o,!0,!0));if(!i.parent.isTextblock||i.pos>n||Gc(i,!0,!1)<n)return!1;return r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function uC(e,t,n){let r=0,s=0;return e.nodesBetween(t,n,(o,i)=>{if(o.isTextblock&&i>=t&&i<n)r++;else if(o.isText?/\S/.test(o.text.slice(Math.max(0,t-i),Math.min(o.nodeSize,n-i))):o.isLeaf)s++}),s==0&&r==1}function Gc(e,t,n){let r=e.depth,s=t?e.end():e.pos;while(r>0&&(t||e.indexAfter(r)==e.node(r).childCount))r--,s++,t=!1;if(n){let o=e.node(r).maybeChild(e.indexAfter(r));while(o&&!o.isLeaf)o=o.firstChild,s++}return s}function dC(e,t,n,r,s){let o=e.findDiffStart(t,n),i=n+e.size,a=n+t.size;if(o==null)return null;let{a:l,b:c}=e.findDiffEnd(t,i,a);if(s=="end"){let u=Math.max(0,o-Math.min(l,c));r-=l+u-o}if(l<o&&i<a){let u=r<=o&&r>=l?o-r:0;o-=u,c=o+(c-l),l=o}else if(c<o){let u=r<=o&&r>=c?o-r:0;o-=u,l=o+(l-c),c=o}return{start:o,endA:l,endB:c}}class xa{constructor(e,t){if(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 cg,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Bm),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e){if(e.appendChild)e.appendChild(this.dom);else if(typeof e=="function")e(this.dom);else if(e.mount)this.mounted=!0}this.editable=Lm(this),vm(this),this.nodeViews=Pm(this),this.docView=mm(this.state.doc,Dm(this),Xc(this),this.dom,this),this.domObserver=new Ag(this,(n,r,s,o)=>aC(this,n,r,s,o)),this.domObserver.start(),Mw(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){if(e.handleDOMEvents!=this._props.handleDOMEvents)au(this);let t=this._props;if(this._props=e,e.plugins)e.plugins.forEach(Bm),this.directPlugins=e.plugins;this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let r=this.state,s=!1,o=!1;if(e.storedMarks&&this.composing)gg(this),o=!0;this.state=e;let i=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(i||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=Pm(this);if(hC(f,this.nodeViews))this.nodeViews=f,s=!0}if(i||t.handleDOMEvents!=this._props.handleDOMEvents)au(this);this.editable=Lm(this),vm(this);let a=Xc(this),l=Dm(this),c=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",u=s||!this.docView.matchesNode(e.doc,l,a);if(u||!e.selection.eq(r.selection))o=!0;let d=c=="preserve"&&o&&this.dom.style.overflowAnchor==null&&XA(this);if(o){this.domObserver.stop();let f=u&&(Qe||De)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&fC(r.selection,e.selection);if(u){let p=De?this.trackWrites=this.domSelectionRange().focusNode:null;if(this.composing)this.input.compositionNode=Yw(this);if(s||!this.docView.update(e.doc,l,a,this))this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=mm(e.doc,l,a,this.dom,this);if(p&&(!this.trackWrites||!this.dom.contains(this.trackWrites)))f=!0}let h=this.input.mouseDown;if(f||!(h&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&gw(this)&&h.delaySelUpdate()))Qt(this,f);else eg(this,e.selection),this.domObserver.setCurSelection();this.domObserver.start()}if(this.updatePluginViews(r),((n=this.dragging)===null||n===void 0?void 0:n.node)&&!r.doc.eq(e.doc))this.updateDraggedNode(this.dragging,r);if(c=="reset")this.dom.scrollTop=0;else if(c=="to selection")this.scrollToSelection();else if(d)GA(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!e||!or(this.dom,e));else if(this.someProp("handleScrollToSelection",(t)=>t(this)));else if(this.state.selection instanceof M){let t=this.docView.domAfterPos(this.state.selection.from);if(V(t))um(this,t.getBoundingClientRect(),e)}else um(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;while(e=this.pluginViews.pop())if(e.destroy)e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];if(n.spec.view)this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];if(n.spec.view)this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];if(n.update)n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let s=n.from+(this.state.doc.content.size-t.doc.content.size);if((s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==n.node)r=s}this.dragging=new Eu(e.slice,e.move,r<0?void 0:M.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let o=0;o<this.directPlugins.length;o++){let i=this.directPlugins[o].props[e];if(i!=null&&(r=t?t(i):i))return r}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let i=s[o].props[e];if(i!=null&&(r=t?t(i):i))return r}}hasFocus(){if(Qe){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;while(e&&this.dom!=e&&this.dom.contains(e)){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){if(this.domObserver.stop(),this.editable)JA(this.dom);Qt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host){if(!t.getSelection)Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection();return this._root=t}}return e||document}updateRoot(){this._root=null}posAtCoords(e){return nw(this,e)}coordsAtPos(e,t=1){return jm(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return aw(this,t||this.state,e)}pasteHTML(e,t){return Co(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Co(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return hu(this,e)}destroy(){if(!this.docView)return;if(Rw(this),this.destroyPluginViews(),this.mounted)this.docView.update(this.state.doc,[],Xc(this),this),this.dom.textContent="";else if(this.dom.parentNode)this.dom.parentNode.removeChild(this.dom);this.docView.destroy(),this.docView=null,FA()}get isDestroyed(){return this.docView==null}dispatchEvent(e){return vw(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();if(!e)return{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0};return $e&&this.root.nodeType===11&&YA(this.dom.ownerDocument)==this.dom&&tC(this,e)||e}domSelection(){return this.root.getSelection()}}xa.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;if(t)t.call(this,e);else this.updateState(this.state.apply(e))};function Dm(e){let t=Object.create(null);if(t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",(n)=>{if(typeof n=="function")n=n(e.state);if(n){for(let r in n)if(r=="class")t.class+=" "+n[r];else if(r=="style")t.style=(t.style?t.style+";":"")+n[r];else if(!t[r]&&r!="contenteditable"&&r!="nodeName")t[r]=String(n[r])}}),!t.translate)t.translate="no";return[ae.node(0,e.state.doc.content.size,t)]}function vm(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:ae.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Lm(e){return!e.someProp("editable",(t)=>t(e.state)===!1)}function fC(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function Pm(e){let t=Object.create(null);function n(r){for(let s in r)if(!Object.prototype.hasOwnProperty.call(t,s))t[s]=r[s]}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function hC(e,t){let n=0,r=0;for(let s in e){if(e[s]!=t[s])return!0;n++}for(let s in t)r++;return n!=r}function Bm(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}var Zt={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:"'"},Aa={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},pC=typeof navigator<"u"&&/Mac/.test(navigator.platform),mC=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(de=0;de<10;de++)Zt[48+de]=Zt[96+de]=String(de);var de;for(de=1;de<=24;de++)Zt[de+111]="F"+de;var de;for(de=65;de<=90;de++)Zt[de]=String.fromCharCode(de+32),Aa[de]=String.fromCharCode(de);var de;for(Io in Zt)if(!Aa.hasOwnProperty(Io))Aa[Io]=Zt[Io];var Io;function wg(e){var t=pC&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||mC&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?Aa:Zt)[e.keyCode]||e.key||"Unidentified";if(n=="Esc")n="Escape";if(n=="Del")n="Delete";if(n=="Left")n="ArrowLeft";if(n=="Up")n="ArrowUp";if(n=="Right")n="ArrowRight";if(n=="Down")n="ArrowDown";return n}var gC=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),yC=typeof navigator<"u"&&/Win/.test(navigator.platform);function EC(e){let t=e.split(/-(?!$)/),n=t[t.length-1];if(n=="Space")n=" ";let r,s,o,i;for(let a=0;a<t.length-1;a++){let l=t[a];if(/^(cmd|meta|m)$/i.test(l))i=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))if(gC)i=!0;else s=!0;else throw Error("Unrecognized modifier name: "+l)}if(r)n="Alt-"+n;if(s)n="Ctrl-"+n;if(i)n="Meta-"+n;if(o)n="Shift-"+n;return n}function TC(e){let t=Object.create(null);for(let n in e)t[EC(n)]=e[n];return t}function Su(e,t,n=!0){if(t.altKey)e="Alt-"+e;if(t.ctrlKey)e="Ctrl-"+e;if(t.metaKey)e="Meta-"+e;if(n&&t.shiftKey)e="Shift-"+e;return e}function Cg(e){return new q({props:{handleKeyDown:xu(e)}})}function xu(e){let t=TC(e);return function(n,r){let s=wg(r),o,i=t[Su(s,r)];if(i&&i(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let a=t[Su(s,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(yC&&r.ctrlKey&&r.altKey)&&(o=Zt[r.keyCode])&&o!=s){let a=t[Su(o,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}var wa=200,ve=function(){};ve.prototype.append=function(t){if(!t.length)return this;return t=ve.from(t),!this.length&&t||t.length<wa&&this.leafAppend(t)||this.length<wa&&t.leafPrepend(this)||this.appendInner(t)};ve.prototype.prepend=function(t){if(!t.length)return this;return ve.from(t).append(this)};ve.prototype.appendInner=function(t){return new bC(this,t)};ve.prototype.slice=function(t,n){if(t===void 0)t=0;if(n===void 0)n=this.length;if(t>=n)return ve.empty;return this.sliceInner(Math.max(0,t),Math.min(this.length,n))};ve.prototype.get=function(t){if(t<0||t>=this.length)return;return this.getInner(t)};ve.prototype.forEach=function(t,n,r){if(n===void 0)n=0;if(r===void 0)r=this.length;if(n<=r)this.forEachInner(t,n,r,0);else this.forEachInvertedInner(t,n,r,0)};ve.prototype.map=function(t,n,r){if(n===void 0)n=0;if(r===void 0)r=this.length;var s=[];return this.forEach(function(o,i){return s.push(t(o,i))},n,r),s};ve.from=function(t){if(t instanceof ve)return t;return t&&t.length?new kg(t):ve.empty};var kg=function(e){function t(r){e.call(this),this.values=r}if(e)t.__proto__=e;t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(s,o){if(s==0&&o==this.length)return this;return new t(this.values.slice(s,o))},t.prototype.getInner=function(s){return this.values[s]},t.prototype.forEachInner=function(s,o,i,a){for(var l=o;l<i;l++)if(s(this.values[l],a+l)===!1)return!1},t.prototype.forEachInvertedInner=function(s,o,i,a){for(var l=o-1;l>=i;l--)if(s(this.values[l],a+l)===!1)return!1},t.prototype.leafAppend=function(s){if(this.length+s.length<=wa)return new t(this.values.concat(s.flatten()))},t.prototype.leafPrepend=function(s){if(this.length+s.length<=wa)return new t(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(ve);ve.empty=new kg([]);var bC=function(e){function t(n,r){e.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}if(e)t.__proto__=e;return t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},t.prototype.forEachInner=function(r,s,o,i){var a=this.left.length;if(s<a&&this.left.forEachInner(r,s,Math.min(o,a),i)===!1)return!1;if(o>a&&this.right.forEachInner(r,Math.max(s-a,0),Math.min(this.length,o)-a,i+a)===!1)return!1},t.prototype.forEachInvertedInner=function(r,s,o,i){var a=this.left.length;if(s>a&&this.right.forEachInvertedInner(r,s-a,Math.max(o,a)-a,i+a)===!1)return!1;if(o<a&&this.left.forEachInvertedInner(r,Math.min(s,a),o,i)===!1)return!1},t.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var o=this.left.length;if(s<=o)return this.left.slice(r,s);if(r>=o)return this.right.slice(r-o,s-o);return this.left.slice(r,o).append(this.right.slice(0,s-o))},t.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new t(this.left,s)},t.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new t(s,this.right)},t.prototype.appendInner=function(r){if(this.left.depth>=Math.max(this.right.depth,r.depth)+1)return new t(this.left,new t(this.right,r));return new t(this,r)},t}(ve),Au=ve;var SC=500;class bt{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let r,s;if(t)r=this.remapping(n,this.items.length),s=r.maps.length;let o=e.tr,i,a,l=[],c=[];return this.items.forEach((u,d)=>{if(!u.step){if(!r)r=this.remapping(n,d+1),s=r.maps.length;s--,c.push(u);return}if(r){c.push(new Rt(u.map));let f=u.step.map(r.slice(s)),h;if(f&&o.maybeStep(f).doc)h=o.mapping.maps[o.mapping.maps.length-1],l.push(new Rt(h,void 0,void 0,l.length+c.length));if(s--,h)r.appendMap(h,s)}else o.maybeStep(u.step);if(u.selection)return i=r?u.selection.map(r.slice(s)):u.selection,a=new bt(this.items.slice(0,n).append(c.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:i}}addTransform(e,t,n,r){let s=[],o=this.eventCount,i=this.items,a=!r&&i.length?i.get(i.length-1):null;for(let c=0;c<e.steps.length;c++){let u=e.steps[c].invert(e.docs[c]),d=new Rt(e.mapping.maps[c],u,t),f;if(f=a&&a.merge(d))if(d=f,c)s.pop();else i=i.slice(0,i.length-1);if(s.push(d),t)o++,t=void 0;if(!r)a=d}let l=o-n.depth;if(l>AC)i=xC(i,l),o-=l;return new bt(i.append(s),o)}remapping(e,t){let n=new Kr;return this.items.forEach((r,s)=>{let o=r.mirrorOffset!=null&&s-r.mirrorOffset>=e?n.maps.length-r.mirrorOffset:void 0;n.appendMap(r.map,o)},e,t),n}addMaps(e){if(this.eventCount==0)return this;return new bt(this.items.append(e.map((t)=>new Rt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let n=[],r=this.items.length-t,s=e.mapping,o=e.steps.length,i=this.eventCount;this.items.forEach((d)=>{if(d.selection)i--},r);let a=t;this.items.forEach((d)=>{let f=s.getMirror(--a);if(f==null)return;o=Math.min(o,f);let h=s.maps[f];if(d.step){let p=e.steps[f].invert(e.docs[f]),m=d.selection&&d.selection.map(s.slice(a+1,f));if(m)i++;n.push(new Rt(h,p,m))}else n.push(new Rt(h))},r);let l=[];for(let d=t;d<o;d++)l.push(new Rt(s.maps[d]));let c=this.items.slice(0,r).append(l).append(n),u=new bt(c,i);if(u.emptyItemCount()>SC)u=u.compress(this.items.length-n.length);return u}emptyItemCount(){let e=0;return this.items.forEach((t)=>{if(!t.step)e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],s=0;return this.items.forEach((o,i)=>{if(i>=e){if(r.push(o),o.selection)s++}else if(o.step){let a=o.step.map(t.slice(n)),l=a&&a.getMap();if(n--,l)t.appendMap(l,n);if(a){let c=o.selection&&o.selection.map(t.slice(n));if(c)s++;let u=new Rt(l.invert(),a,c),d,f=r.length-1;if(d=r.length&&r[f].merge(u))r[f]=d;else r.push(u)}}else if(o.map)n--},this.items.length,0),new bt(Au.from(r.reverse()),s)}}bt.empty=new bt(Au.empty,0);function xC(e,t){let n;return e.forEach((r,s)=>{if(r.selection&&t--==0)return n=s,!1}),e.slice(n)}class Rt{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Rt(t.getMap().invert(),t,this.selection)}}}class en{constructor(e,t,n,r,s){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=s}}var AC=20;function wC(e,t,n,r){let s=n.getMeta(ir),o;if(s)return s.historyState;if(n.getMeta(Ig))e=new en(e.done,e.undone,null,0,-1);let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return e;else if(i&&i.getMeta(ir))if(i.getMeta(ir).redo)return new en(e.done.addTransform(n,void 0,r,Ca(t)),e.undone,_g(n.mapping.maps),e.prevTime,e.prevComposition);else return new en(e.done,e.undone.addTransform(n,void 0,r,Ca(t)),null,e.prevTime,e.prevComposition);else if(n.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=e.prevTime==0||!i&&e.prevComposition!=a&&(e.prevTime<(n.time||0)-r.newGroupDelay||!CC(n,e.prevRanges)),c=i?wu(e.prevRanges,n.mapping):_g(n.mapping.maps);return new en(e.done.addTransform(n,l?t.selection.getBookmark():void 0,r,Ca(t)),bt.empty,c,n.time,a==null?e.prevComposition:a)}else if(o=n.getMeta("rebased"))return new en(e.done.rebased(n,o),e.undone.rebased(n,o),wu(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new en(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),wu(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function CC(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<t.length;o+=2)if(r<=t[o+1]&&s>=t[o])n=!0}),n}function _g(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((r,s,o,i)=>t.push(o,i));return t}function wu(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let s=t.map(e[r],1),o=t.map(e[r+1],-1);if(s<=o)n.push(s,o)}return n}function kC(e,t,n){let r=Ca(t),s=ir.get(t).spec.config,o=(n?e.undone:e.done).popEvent(t,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),a=(n?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),s,r),l=new en(n?a:o.remaining,n?o.remaining:a,null,0,-1);return o.transform.setSelection(i).setMeta(ir,{redo:n,historyState:l})}var Cu=!1,Ng=null;function Ca(e){let t=e.plugins;if(Ng!=t){Cu=!1,Ng=t;for(let n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){Cu=!0;break}}return Cu}function Og(e){return e.setMeta(Ig,!0)}var ir=new Q("history"),Ig=new Q("closeHistory");function Mg(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new q({key:ir,state:{init(){return new en(bt.empty,bt.empty,null,0,-1)},apply(t,n,r){return wC(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(t,n){let r=n.inputType,s=r=="historyUndo"?ku:r=="historyRedo"?_u:null;if(!s||!t.editable)return!1;return n.preventDefault(),s(t.state,t.dispatch)}}}})}function ka(e,t){return(n,r)=>{let s=ir.getState(n);if(!s||(e?s.undone:s.done).eventCount==0)return!1;if(r){let o=kC(s,n,e);if(o)r(t?o.scrollIntoView():o)}return!0}}var ku=ka(!1,!0),_u=ka(!0,!0),I1=ka(!1,!1),M1=ka(!0,!1);function Pa(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:s}=n,{storedMarks:o}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return o},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,o=n.storedMarks,n}}}var us=class e{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:t,editor:n,state:r}=this,{view:s}=n,{tr:o}=r,i=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(([a,l])=>[a,(...u)=>{let d=l(...u)(i);if(!o.getMeta("preventDispatch")&&!this.hasCustomState)s.dispatch(o);return d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){let{rawCommands:r,editor:s,state:o}=this,{view:i}=s,a=[],l=!!t,c=t||o.tr,u=()=>{if(!l&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState)i.dispatch(c);return a.every((f)=>f===!0)},d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{let g=this.buildProps(c,n),E=h(...m)(g);return a.push(E),d}])),run:u};return d}static createFakeChain(){let t=new Proxy({},{get:(n,r)=>{if(r==="then")return;if(r==="run")return()=>!1;return()=>t}});return t}createCan(t){let{rawCommands:n,state:r}=this,s=!1,o=t||r.tr,i=this.buildProps(o,!1);return{...Object.fromEntries(Object.entries(n).map(([a,l])=>[a,(...c)=>l(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(o,!1)}}static createFallbackCan(){let t=e.createFakeChain();return new Proxy({chain:()=>t},{get:(n,r)=>{if(r==="then")return;if(r==="chain")return n.chain;return()=>!1}})}buildProps(t,n=!0){let{rawCommands:r,editor:s,state:o}=this,{view:i}=s,a={tr:t,editor:s,view:i,state:Pa({state:o,transaction:t}),dispatch:n?()=>{return}:void 0,chain:()=>this.createChain(t,n),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...u)=>c(...u)(a)]))}};return a}},_C=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{if(!e.isDestroyed){var n;t.dom.blur(),(n=window)===null||n===void 0||(n=n.getSelection())===null||n===void 0||n.removeAllRanges()}}),!0),NC=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),OC=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{ranges:r}=n;if(!t)return!0;let s=e.mapping.maps.length;return r.forEach(({$from:o,$to:i})=>{let a=o.pos,l=i.pos,c=e.mapping.slice(s),u=1;e.doc.nodesBetween(c.map(a),c.map(l),(d,f)=>{u=Math.max(u,e.doc.resolve(f).depth+1)});for(let d=0;d<u;d+=1){let f=e.doc,h=e.mapping.maps.length,p=e.mapping.slice(s),m=h,g=e.mapping.slice(h),E=p.map(a),x=p.map(l);if(f.nodesBetween(E,x,(w,b)=>{if(w.type.isText)return;if(e.mapping.maps.length!==m)m=e.mapping.maps.length,g=e.mapping.slice(h);let v=e.doc.resolve(g.map(b)),D=e.doc.resolve(g.map(b+w.nodeSize)),R=v.blockRange(D);if(!R)return;let P=Kt(R);if(w.type.isTextblock){let{defaultType:H}=v.parent.contentMatchAt(v.index()),F=e.doc.nodeAt(R.start);if(H&&F&&!F.hasMarkup(H)&&H.validContent(F.content))e.setNodeMarkup(R.start,H)}if(P||P===0)e.lift(R,P)}),e.doc.eq(f))break}}),!0},IC=(e)=>(t)=>e(t),MC=()=>({state:e,dispatch:t})=>$c(e,t),RC=(e,t)=>({editor:n,tr:r})=>{let{state:s}=n,o=s.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let i=r.mapping.map(t);return r.insert(i,o.content),r.setSelection(new I(r.doc.resolve(Math.max(i-1,0)))),!0},DC=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===r.type){if(t){let i=s.before(o),a=s.after(o);e.delete(i,a).scrollIntoView()}return!0}return!1};function Ie(e,t){if(typeof e==="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var vC=(e)=>({tr:t,state:n,dispatch:r})=>{let s=Ie(e,n.schema),o=t.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===s){if(r){let a=o.before(i),l=o.after(i);t.delete(a,l).scrollIntoView()}return!0}return!1},LC=(e)=>({tr:t,dispatch:n})=>{let{from:r,to:s}=e;if(n)t.delete(r,s);return!0},PC=(e)=>{if(!e.content)return!1;return/^text(\*|\+)/.test(e.content)},Rg=(e,t,n)=>{if(!e.parent.isInline)return e.pos;if(n==="left"&&e.pos>e.start()||n==="right"&&e.pos<e.end())return e.pos;let r=t.nodes[e.parent.type.name].spec;if(!PC(r))return e.pos;return n==="left"?e.start()-1:e.end()+1},BC=(e,t,n)=>({from:Rg(e,n,"left"),to:Rg(t,n,"right")}),FC=()=>({state:e,dispatch:t})=>{if(e.selection.empty)return!1;if(t){let n=e.tr,{ranges:r}=e.selection,s=e.selection instanceof I?e.selection.$from.marksAcross(e.selection.$to):null,o=n.steps.length;if(r.forEach((i)=>{let a=n.mapping.slice(o),l=n.doc.resolve(a.map(i.$from.pos)),c=n.doc.resolve(a.map(i.$to.pos)),{from:u,to:d}=BC(l,c,e.schema);n.deleteRange(u,d)}),!n.selection.empty)n.setSelection(I.near(n.doc.resolve(n.selection.from)));if(s)n.ensureMarks(s);n.scrollIntoView(),t(n)}return!0},UC=()=>({commands:e})=>e.keyboardShortcut("Enter"),HC=()=>({state:e,dispatch:t})=>Hc(e,t);function Ru(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function Da(e,t,n={strict:!0}){let r=Object.keys(t);if(!r.length)return!0;return r.every((s)=>{if(n.strict)return t[s]===e[s];if(Ru(t[s]))return t[s].test(e[s]);return t[s]===e[s]})}function Gg(e,t,n={}){return e.find((r)=>r.type===t&&Da(Object.fromEntries(Object.keys(n).map((s)=>[s,r.attrs[s]])),n))}function Dg(e,t,n={}){return!!Gg(e,t,n)}function Jg(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(!r.node||!r.node.marks.some((l)=>l.type===t))r=e.parent.childBefore(e.parentOffset);if(!r.node||!r.node.marks.some((l)=>l.type===t))return;if(!n){let l=r.node.marks.find((c)=>c.type===t);if(l)n=l.attrs}if(!Gg([...r.node.marks],t,n))return;let s=r.index,o=e.start()+r.offset,i=s+1,a=o+r.node.nodeSize;while(s>0&&Dg([...e.parent.child(s-1).marks],t,n))s-=1,o-=e.parent.child(s).nodeSize;while(i<e.parent.childCount&&Dg([...e.parent.child(i).marks],t,n))a+=e.parent.child(i).nodeSize,i+=1;return{from:o,to:a}}function tn(e,t){if(typeof e==="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var $C=(e,t)=>({tr:n,state:r,dispatch:s})=>{let o=tn(e,r.schema),{doc:i,selection:a}=n,{$from:l,from:c,to:u}=a;if(s){let d=Jg(l,o,t);if(d&&d.from<=c&&d.to>=u){let f=I.create(i,d.from,d.to);n.setSelection(f)}}return!0},VC=(e)=>(t)=>{let n=typeof e==="function"?e(t):e;for(let r=0;r<n.length;r+=1)if(n[r](t))return!0;return!1};function Qg(e){return e instanceof I}function ar(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function Nu(e,t=null){if(!t)return null;let n=U.atStart(e),r=U.atEnd(e);if(t==="start"||t===!0)return n;if(t==="end")return r;let s=n.from,o=r.to;if(t==="all")return I.create(e,ar(0,s,o),ar(e.content.size,s,o));return I.create(e,ar(t,s,o),ar(t,s,o))}function vg(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function va(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function zC(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var YC=(e=null,t={})=>({editor:n,view:r,tr:s,dispatch:o})=>{t={scrollIntoView:!0,...t};let i=()=>{if(va()||vg())r.dom.focus();if(zC()&&!va()&&!vg())r.dom.focus({preventScroll:!0});requestAnimationFrame(()=>{if(!n.isDestroyed){if(r.focus(),t===null||t===void 0?void 0:t.scrollIntoView)n.commands.scrollIntoView()}})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(o&&e===null&&!Qg(n.state.selection))return i(),!0;let a=Nu(s.doc,e)||n.state.selection,l=n.state.selection.eq(a);if(o){if(!l)s.setSelection(a);if(l&&s.storedMarks)s.setStoredMarks(s.storedMarks);i()}return!0},jC=(e,t)=>(n)=>e.every((r,s)=>t(r,{...n,index:s})),WC=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),Zg=(e)=>{let t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){let r=t[n];if(r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue))e.removeChild(r);else if(r.nodeType===1)Zg(r)}return e};function _a(e){if(typeof window>"u")throw Error("[tiptap error]: there is no window object available, so this function cannot be used");let t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,"text/html").body;return Zg(n)}function ey(e){return typeof(e===null||e===void 0?void 0:e.nodesBetween)==="function"}function ds(e,t,n){if(ey(e))return e;let r=typeof e==="object"&&e!==null;n={slice:!0,parseOptions:{},...n};let s=typeof e==="string";if(r)try{if(Array.isArray(e)&&e.length>0)return S.fromArray(e.map((i)=>t.nodeFromJSON(i)));let o=t.nodeFromJSON(e);if(n.errorOnInvalidContent)o.check();return o}catch(o){if(n.errorOnInvalidContent)throw Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",o),ds("",t,n)}if(s){if(n.errorOnInvalidContent){let i=!1,a="",l=new jr({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:(c)=>(i=!0,a=typeof c==="string"?c:c.outerHTML,null)}]}})});if(n.slice)Nt.fromSchema(l).parseSlice(_a(e),n.parseOptions);else Nt.fromSchema(l).parse(_a(e),n.parseOptions);if(n.errorOnInvalidContent&&i)throw Error("[tiptap error]: Invalid HTML content",{cause:Error(`Invalid element found: ${a}`)})}let o=Nt.fromSchema(t);if(n.slice)return o.parseSlice(_a(e),n.parseOptions).content;return o.parse(_a(e),n.parseOptions)}return ds("",t,n)}function ty(e){return!("type"in e)}function ny(e,t,n){let r=e.steps.length-1;if(r<t)return;let s=e.steps[r];if(!(s instanceof se||s instanceof fe))return;let o=e.mapping.maps[r],i=0;o.forEach((a,l,c,u)=>{if(i===0)i=u}),e.setSelection(U.near(e.doc.resolve(i),n))}var KC=(e,t,n)=>({tr:r,dispatch:s,editor:o})=>{if(s){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a,l=(g)=>{o.emit("contentError",{editor:o,error:g,disableCollaboration:()=>{if("collaboration"in o.storage&&typeof o.storage.collaboration==="object"&&o.storage.collaboration)o.storage.collaboration.isDisabled=!0}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{ds(t,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{var i;a=ds(t,o.schema,{parseOptions:c,errorOnInvalidContent:(i=n.errorOnInvalidContent)!==null&&i!==void 0?i:o.options.enableContentCheck})}catch(g){return l(g),!1}let{from:u,to:d}=typeof e==="number"?{from:e,to:e}:{from:e.from,to:e.to},f=!0,h=!0,p=ty(a)?a.content:[a];if(p.forEach((g)=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),u===d&&h){let{parent:g}=r.doc.resolve(u);if(g.isTextblock&&!g.type.spec.code&&!g.childCount)u-=1,d+=1}let m;if(f){if(Array.isArray(t))m=t.map((g)=>g.text||"").join("");else if(ey(t))m=p.map((g)=>{var E;return(E=g.text)!==null&&E!==void 0?E:""}).join("");else if(typeof t==="object"&&!!t&&!!t.text)m=t.text;else m=t;r.insertText(m,u,d)}else{m=S.from(p);let g=r.doc.resolve(u),E=g.node(),x=g.parentOffset===0,w=E.isText||E.isTextblock,b=E.content.size>0;if(x&&w&&b&&h)u=Math.max(0,u-1);r.replaceWith(u,d,p)}if(n.updateSelection)ny(r,r.steps.length-1,-1);if(n.applyInputRules)r.setMeta("applyInputRules",{from:u,text:m});if(n.applyPasteRules)r.setMeta("applyPasteRules",{from:u,text:m})}return!0};function ry(e){for(let t=0;t<e.edgeCount;t+=1){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var qC=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{pos:s,attrs:o,content:i,updateSelection:a=!0}=e,l;if(typeof s==="number")l=t.doc.resolve(s);else if(s)l=s;else l=t.selection.$from;let c=ry(l.parent.contentMatchAt(l.index()));if(!c)return!1;let u=Object.keys(c.spec.attrs||{}),d=o?Object.fromEntries(Object.entries(o).filter(([h])=>u.includes(h))):{},f;if(i){let h=ds(i,r.schema);f=c.createAndFill(d,h)}else f=c.createAndFill(d);if(!f)return!1;if(n){if(t.insert(l.pos,f),a)ny(t,t.steps.length-1,-1)}return!0},XC=()=>({state:e,dispatch:t})=>Qp(e,t),GC=()=>({state:e,dispatch:t})=>Zp(e,t),JC=()=>({state:e,dispatch:t})=>Rc(e,t),QC=()=>({state:e,dispatch:t})=>Lc(e,t),sy=(e,t)=>{let n=e.resolve(t),{nodeBefore:r,nodeAfter:s}=n;if(!r||!s)return!1;return!r.type.spec.isolating&&!s.type.spec.isolating},ZC=()=>({state:e,dispatch:t,tr:n})=>{try{let r=Xr(e.doc,e.selection.$from.pos,-1);if(r===null||r===void 0)return!1;if(!sy(e.doc,r))return!1;if(n.join(r,2),t)t(n);return!0}catch{return!1}},e0=()=>({state:e,dispatch:t,tr:n})=>{try{let r=Xr(e.doc,e.selection.$from.pos,1);if(r===null||r===void 0)return!1;if(!sy(e.doc,r))return!1;if(n.join(r,2),t)t(n);return!0}catch{return!1}},t0=()=>({state:e,dispatch:t})=>qp(e,t),n0=()=>({state:e,dispatch:t})=>Xp(e,t);function oy(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function r0(e){let t=e.split(/-(?!$)/),n=t[t.length-1];if(n==="Space")n=" ";let r,s,o,i;for(let a=0;a<t.length-1;a+=1){let l=t[a];if(/^(cmd|meta|m)$/i.test(l))i=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))o=!0;else if(/^mod$/i.test(l))if(va()||oy())i=!0;else s=!0;else throw Error(`Unrecognized modifier name: ${l}`)}if(r)n=`Alt-${n}`;if(s)n=`Ctrl-${n}`;if(i)n=`Meta-${n}`;if(o)n=`Shift-${n}`;return n}var s0=(e)=>({editor:t,view:n,tr:r,dispatch:s})=>{let o=r0(e).split(/-(?!$)/),i=o.find((c)=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction(()=>{n.someProp("handleKeyDown",(c)=>c(n,a))});return l===null||l===void 0||l.steps.forEach((c)=>{let u=c.map(r.mapping);if(u&&s)r.maybeStep(u)}),!0};function Do(e,t,n={}){let{from:r,to:s,empty:o}=e.selection,i=t?Ie(t,e.schema):null,a=[];e.doc.nodesBetween(r,s,(u,d)=>{if(u.isText)return;let f=Math.max(r,d),h=Math.min(s,d+u.nodeSize);a.push({node:u,from:f,to:h})});let l=s-r,c=a.filter((u)=>{if(!i)return!0;return i.name===u.node.type.name}).filter((u)=>Da(u.node.attrs,n,{strict:!1}));if(o)return!!c.length;return c.reduce((u,d)=>u+d.to-d.from,0)>=l}var o0=(e,t={})=>({state:n,dispatch:r})=>{if(!Do(n,Ie(e,n.schema),t))return!1;return em(n,r)},i0=()=>({state:e,dispatch:t})=>Vc(e,t),a0=(e)=>({state:t,dispatch:n})=>{let r=Ie(e,t.schema);return im(r)(t,n)},l0=()=>({state:e,dispatch:t})=>Fc(e,t);function Ba(e,t){if(t.nodes[e])return"node";if(t.marks[e])return"mark";return null}function Lg(e,t){let n=typeof t==="string"?[t]:t;return Object.keys(e).reduce((r,s)=>{if(!n.includes(s))r[s]=e[s];return r},{})}var c0=(e,t)=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null,a=Ba(typeof e==="string"?e:e.name,r.schema);if(!a)return!1;if(a==="node")o=Ie(e,r.schema);if(a==="mark")i=tn(e,r.schema);let l=!1;return n.selection.ranges.forEach((c)=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{if(o&&o===u.type){if(l=!0,s)n.setNodeMarkup(d,void 0,Lg(u.attrs,t))}if(i&&u.marks.length)u.marks.forEach((f)=>{if(i===f.type){if(l=!0,s)n.addMark(d,d+u.nodeSize,i.create(Lg(f.attrs,t)))}})})}),l},u0=()=>({tr:e,dispatch:t})=>{if(t)e.scrollIntoView();return!0},d0=()=>({tr:e,dispatch:t})=>{if(t){let n=new we(e.doc);e.setSelection(n)}return!0},f0=()=>({state:e,dispatch:t})=>Dc(e,t),h0=()=>({state:e,dispatch:t})=>Pc(e,t),p0=()=>({state:e,dispatch:t})=>tm(e,t),m0=()=>({state:e,dispatch:t})=>Yc(e,t),g0=()=>({state:e,dispatch:t})=>zc(e,t);function Ou(e,t,n={},r={}){return ds(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var y0=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:o,dispatch:i,commands:a})=>{let{doc:l}=o;if(r.preserveWhitespace!=="full"){let c=Ou(e,s.schema,r,{errorOnInvalidContent:t!==null&&t!==void 0?t:s.options.enableContentCheck});if(i){let u=ty(c)?c.content:[c];o.replaceWith(0,l.content.size,u).setMeta("preventUpdate",!n)}return!0}if(i)o.setMeta("preventUpdate",!n);return a.insertContentAt({from:0,to:l.content.size},e,{parseOptions:r,errorOnInvalidContent:t!==null&&t!==void 0?t:s.options.enableContentCheck})};function iy(e,t){let n=tn(t,e.schema),{from:r,to:s,empty:o}=e.selection,i=[];if(o){if(e.storedMarks)i.push(...e.storedMarks);i.push(...e.selection.$head.marks())}else e.doc.nodesBetween(r,s,(l)=>{i.push(...l.marks)});let a=i.find((l)=>l.type.name===n.name);if(!a)return{};return{...a.attrs}}function E0(e,t){let n=new To(e);return t.forEach((r)=>{r.steps.forEach((s)=>{n.step(s)})}),n}function T0(e,t){for(let n=e.depth;n>0;n-=1){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function Du(e){return(t)=>T0(t.$from,e)}function B(e,t,n){if(e.config[t]===void 0&&e.parent)return B(e.parent,t,n);if(typeof e.config[t]==="function")return e.config[t].bind({...n,parent:e.parent?B(e.parent,t,n):null});return e.config[t]}function vu(e){return e.map((t)=>{let n=B(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});if(n)return[t,...vu(n())];return t}).flat(10)}function Lu(e,t){let n=jt.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function ay(e,t){let n=new Map;for(let s of e){var r;let o=(r=n.get(s.type))!==null&&r!==void 0?r:new Map;o.set(s.name,s),n.set(s.type,o)}return[...Object.values(t.nodes),...Object.values(t.marks)].flatMap((s)=>{var o;return Object.entries((o=s.spec.attrs)!==null&&o!==void 0?o:{}).map(([i,a])=>{var l;let c=(l=n.get(s.name))===null||l===void 0?void 0:l.get(i),u=Object.hasOwn(a,"default");return{type:s.name,name:i,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...c===null||c===void 0?void 0:c.attribute,default:a.default,isRequired:!u,validate:a.validate}}})})}var b0={content:"string",marks:"string",group:"string",inline:"boolean",atom:"boolean",selectable:"boolean",draggable:"boolean",code:"boolean",whitespace:["pre","normal"],definingAsContext:"boolean",definingForContent:"boolean",defining:"boolean",isolating:"boolean",linebreakReplacement:"boolean"},S0={inclusive:"boolean",excludes:"string",group:"string",spanning:"boolean",code:"boolean"};function x0(e,t,n){return Object.fromEntries(Object.entries(t).flatMap(([r,s])=>{let o=e[r];if(o===void 0)return[];if(!(typeof s==="string"?typeof o===s:typeof o==="string"&&s.includes(o)))throw RangeError(`Invalid schemaSpec field '${n}.${r}'`);return[[r,o]]}))}function Pg(e,t,n,r){return{...Object.fromEntries(Object.entries(t).filter(([s])=>s!=="attrs"&&!Object.hasOwn(r,s))),...x0(n,r,e),attrs:n.attrs}}function Bg(e,t,n){for(let r of Object.keys(t))if(!Object.hasOwn(e,r))throw RangeError(`schemaSpec requires a local ${n} extension named '${r}'`);for(let r of Object.keys(e))if(!Object.hasOwn(t,r))throw RangeError(`Local ${n} extension '${r}' is not in schemaSpec`)}function A0(e,t){Bg(e.nodes,t.nodes,"node"),Bg(e.marks,t.marks,"mark");let n=t.spec.nodes,r=t.spec.marks;return t.spec.nodes.forEach((s,o)=>{n=n.update(s,Pg(s,e.nodes[s],o,b0))}),t.spec.marks.forEach((s,o)=>{r=r.update(s,Pg(s,e.marks[s],o,S0))}),{topNode:t.topNodeType.name,nodes:n,marks:r}}function ly(e){let t=e.filter((n,r)=>e.indexOf(n)!==r);return Array.from(new Set(t))}function fs(e){return{baseExtensions:e.filter((t)=>t.type==="extension"),nodeExtensions:e.filter((t)=>t.type==="node"),markExtensions:e.filter((t)=>t.type==="mark")}}function Pu(e){let t=[],{nodeExtensions:n,markExtensions:r}=fs(e),s=[...n,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},i=n.filter((c)=>c.name!=="text").map((c)=>c.name),a=r.map((c)=>c.name),l=[...i,...a];return e.forEach((c)=>{let u=B(c,"addGlobalAttributes",{name:c.name,options:c.options,storage:c.storage,extensions:s});if(!u)return;u().forEach((d)=>{let f;if(Array.isArray(d.types))f=d.types;else if(d.types==="*")f=l;else if(d.types==="nodes")f=i;else if(d.types==="marks")f=a;else f=[];f.forEach((h)=>{Object.entries(d.attributes).forEach(([p,m])=>{t.push({type:h,name:p,attribute:{...o,...m}})})})})}),s.forEach((c)=>{let u=B(c,"addAttributes",{name:c.name,options:c.options,storage:c.storage});if(!u)return;let d=u();Object.entries(d).forEach(([f,h])=>{let p={...o,...h};if(typeof(p===null||p===void 0?void 0:p.default)==="function")p.default=p.default();if((p===null||p===void 0?void 0:p.isRequired)&&(p===null||p===void 0?void 0:p.default)===void 0)delete p.default;t.push({type:c.name,name:f,attribute:p})})}),t}function Iu(e){return typeof e==="function"}function oe(e,t=void 0,...n){if(Iu(e)){if(t)return e.bind(t)(...n);return e(...n)}return e}function w0(e={}){return Object.keys(e).length===0&&e.constructor===Object}function C0(e){let t=[],n="",r=!1,s=!1,o=0,i=e.length;for(let a=0;a<i;a+=1){let l=e[a];if(l==="'"&&!s){r=!r,n+=l;continue}if(l==='"'&&!r){s=!s,n+=l;continue}if(!r&&!s){if(l==="("){o+=1,n+=l;continue}if(l===")"&&o>0){o-=1,n+=l;continue}if(l===";"&&o===0){t.push(n),n="";continue}}n+=l}if(n)t.push(n);return t}function Fg(e){let t=[],n=C0(e||""),r=n.length;for(let s=0;s<r;s+=1){let o=n[s],i=o.indexOf(":");if(i===-1)continue;let a=o.slice(0,i).trim(),l=o.slice(i+1).trim();if(a&&l)t.push([a,l])}return t}function k0(...e){return e.filter((t)=>!!t).reduce((t,n)=>{let r={...t};return Object.entries(n).forEach(([s,o])=>{if(s==="__proto__"){Object.defineProperty(r,s,{configurable:!0,enumerable:!0,value:o,writable:!0});return}if(!r[s]){r[s]=o;return}if(s==="class"){let i=o?String(o).split(" "):[],a=r[s]?r[s].split(" "):[],l=i.filter((c)=>!a.includes(c));r[s]=[...a,...l].join(" ")}else if(s==="style"){let i=new Map([...Fg(r[s]),...Fg(o)]);r[s]=Array.from(i.entries()).map(([a,l])=>`${a}: ${l}`).join("; ")}else r[s]=o}),r},{})}function La(e,t){return t.filter((n)=>n.type===e.type.name).filter((n)=>n.attribute.rendered).map((n)=>{if(!n.attribute.renderHTML)return{[n.name]:e.attrs[n.name]};return n.attribute.renderHTML(e.attrs)||{}}).reduce((n,r)=>k0(n,r),{})}function _0(e){if(typeof e!=="string")return e;if(e.match(/^[+-]?(?:\d*\.)?\d+$/))return Number(e);if(e==="true")return!0;if(e==="false")return!1;return e}function Ug(e,t){if("style"in e)return e;return{...e,getAttrs:(n)=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let s=t.reduce((o,i)=>{let a=i.attribute.parseHTML?i.attribute.parseHTML(n):_0(n.getAttribute(i.name));if(a===null||a===void 0)return o;return{...o,[i.name]:a}},{});return{...r,...s}}}}function Hg(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>{if(t==="attrs"&&w0(n))return!1;return n!==null&&n!==void 0}))}function $g(e){var t,n;let r={};if(!(e===null||e===void 0||(t=e.attribute)===null||t===void 0?void 0:t.isRequired)&&"default"in((e===null||e===void 0?void 0:e.attribute)||{}))r.default=e.attribute.default;if((e===null||e===void 0||(n=e.attribute)===null||n===void 0?void 0:n.validate)!==void 0)r.validate=e.attribute.validate;return[e.name,r]}function Vg(e,t,n=Pu(e)){var r;let{nodeExtensions:s,markExtensions:o}=fs(e);return{topNode:(r=s.find((i)=>B(i,"topNode")))===null||r===void 0?void 0:r.name,nodes:Object.fromEntries(s.map((i)=>{let a=n.filter((h)=>h.type===i.name),l={name:i.name,options:i.options,storage:i.storage,editor:t},c=Hg({...e.reduce((h,p)=>{let m=B(p,"extendNodeSchema",l);return{...h,...m?m(i):{}}},{}),content:oe(B(i,"content",l)),marks:oe(B(i,"marks",l)),group:oe(B(i,"group",l)),inline:oe(B(i,"inline",l)),atom:oe(B(i,"atom",l)),selectable:oe(B(i,"selectable",l)),draggable:oe(B(i,"draggable",l)),code:oe(B(i,"code",l)),whitespace:oe(B(i,"whitespace",l)),linebreakReplacement:oe(B(i,"linebreakReplacement",l)),defining:oe(B(i,"defining",l)),isolating:oe(B(i,"isolating",l)),attrs:Object.fromEntries(a.map($g))}),u=oe(B(i,"parseHTML",l));if(u)c.parseDOM=u.map((h)=>Ug(h,a));let d=B(i,"renderHTML",l);if(d)c.toDOM=(h)=>d({node:h,HTMLAttributes:La(h,a)});let f=B(i,"renderText",l);if(f)c.toText=f;return[i.name,c]})),marks:Object.fromEntries(o.map((i)=>{let a=n.filter((f)=>f.type===i.name),l={name:i.name,options:i.options,storage:i.storage,editor:t},c=Hg({...e.reduce((f,h)=>{let p=B(h,"extendMarkSchema",l);return{...f,...p?p(i):{}}},{}),inclusive:oe(B(i,"inclusive",l)),excludes:oe(B(i,"excludes",l)),group:oe(B(i,"group",l)),spanning:oe(B(i,"spanning",l)),code:oe(B(i,"code",l)),attrs:Object.fromEntries(a.map($g))}),u=oe(B(i,"parseHTML",l));if(u)c.parseDOM=u.map((f)=>Ug(f,a));let d=B(i,"renderHTML",l);if(d)c.toDOM=(f)=>d({mark:f,HTMLAttributes:La(f,a)});return[i.name,c]}))}}function N0(e,t,n){if(n===void 0)return new jr(Vg(e,t));let r=ly(e.filter((i)=>i.type!=="extension").map((i)=>i.name));if(r.length)throw RangeError(`Duplicate local schema types: ${r.join(", ")}`);let s=new jr(n),o=Vg(e,t,ay(Pu(e),s));return new jr(A0(o,s))}function Ro(e){return e.sort((n,r)=>{let s=B(n,"priority")||100,o=B(r,"priority")||100;if(s>o)return-1;if(s<o)return 1;return 0})}function cy(e){let t=Ro(vu(e)),n=ly(t.map((r)=>r.name));if(n.length)console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((r)=>`'${r}'`).join(", ")}]. This can lead to issues.`);return t}function uy(e,t,n){let{from:r,to:s}=t,{blockSeparator:o=`
|
|
15
|
+
|
|
16
|
+
`,textSerializers:i={}}=n||{},a="";return e.nodesBetween(r,s,(l,c,u,d)=>{if(l.isBlock&&c>r)a+=o;let f=i===null||i===void 0?void 0:i[l.type.name];if(f){if(u)a+=f({node:l,pos:c,parent:u,index:d,range:t});return!1}if(l.isText){var h;a+=l===null||l===void 0||(h=l.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,s-c)}}),a}function O0(e,t){return uy(e,{from:0,to:e.content.size},t)}function dy(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}function I0(e,t){let n=Ie(t,e.schema),{from:r,to:s}=e.selection,o=[];e.doc.nodesBetween(r,s,(a)=>{o.push(a)});let i=o.reverse().find((a)=>a.type.name===n.name);if(!i)return{};return{...i.attrs}}function M0(e,t){let n=Ba(typeof t==="string"?t:t.name,e.schema);if(n==="node")return I0(e,t);if(n==="mark")return iy(e,t);return{}}function R0(e,t=JSON.stringify){let n={};return e.filter((r)=>{let s=t(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function D0(e){let t=R0(e);return t.length===1?t:t.filter((n,r)=>!t.filter((s,o)=>o!==r).some((s)=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function Fa(e){let{mapping:t,steps:n}=e,r=[],s=t.invert();return t.maps.forEach((o,i)=>{let a=[];if(!o.ranges.length){let{from:c,to:u}=n[i];if(c===void 0||u===void 0)return;a.push({from:c,to:u})}else o.forEach((c,u)=>{a.push({from:c,to:u})});let l=t.slice(i);a.forEach(({from:c,to:u})=>{let d=l.map(c,-1),f=l.map(u),h=s.map(d,-1),p=s.map(f);r.push({oldRange:{from:h,to:p},newRange:{from:d,to:f}})})}),D0(r)}function is(e,t){return t.nodes[e]||t.marks[e]||null}function Ra(e,t,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let s=e.find((o)=>o.type===t&&o.name===r);if(!s)return!1;return s.attribute.keepOnSplit}))}var v0=(e,t=500)=>{let n="",r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(s,o,i,a)=>{var l,c;let u=((l=(c=s.type.spec).toText)===null||l===void 0?void 0:l.call(c,{node:s,pos:o,parent:i,index:a}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-o))}),n};function Mu(e,t,n={}){let{empty:r,ranges:s}=e.selection,o=t?tn(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter((u)=>{if(!o)return!0;return o.name===u.type.name}).find((u)=>Da(u.attrs,n,{strict:!1}));let i=0,a=[];if(s.forEach(({$from:u,$to:d})=>{let f=u.pos,h=d.pos;e.doc.nodesBetween(f,h,(p,m)=>{if(o&&p.inlineContent&&!p.type.allowsMarkType(o))return!1;if(!p.isText&&!p.marks.length)return;let g=Math.max(f,m),E=Math.min(h,m+p.nodeSize),x=E-g;i+=x,a.push(...p.marks.map((w)=>({mark:w,from:g,to:E})))})}),i===0)return!1;let l=a.filter((u)=>{if(!o)return!0;return o.name===u.mark.type.name}).filter((u)=>Da(u.mark.attrs,n,{strict:!1})).reduce((u,d)=>u+d.to-d.from,0),c=a.filter((u)=>{if(!o)return!0;return u.mark.type!==o&&u.mark.type.excludes(o)}).reduce((u,d)=>u+d.to-d.from,0);return(l>0?l+c:l)>=i}function L0(e,t,n={}){if(!t)return Do(e,null,n)||Mu(e,null,n);let r=Ba(t,e.schema);if(r==="node")return Do(e,t,n);if(r==="mark")return Mu(e,t,n);return!1}function zg(e,t){if(Array.isArray(t))return t.some((n)=>(typeof n==="string"?n:n.name)===e.name);return t}function Mo(e,t){let{nodeExtensions:n}=fs(t),r=n.find((o)=>o.name===e);if(!r)return!1;let s=oe(B(r,"group",{name:r.name,options:r.options,storage:r.storage}));if(typeof s!=="string")return!1;return s.split(" ").includes("list")}function hs(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name==="hardBreak")return!0;if(e.isText){var r;return!/\S/.test((r=e.text)!==null&&r!==void 0?r:"")}}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let s=!0;return e.content.forEach((o)=>{if(s===!1)return;if(!hs(o,{ignoreWhitespace:n,checkChildren:t}))s=!1}),s}return!1}function fy(e){return e instanceof M}function P0(e){if(e===null||typeof e!=="object")return!1;let t=e;if(typeof t.apply!=="function"||typeof t.getMap!=="function"||typeof t.invert!=="function"||typeof t.map!=="function"||typeof t.merge!=="function"||typeof t.toJSON!=="function")return!1;return!0}function B0(e){if(e===null||typeof e!=="object")return!1;let t=e;if(!P0(t))return!1;let n=t.toJSON();if(n===null||typeof n!=="object"||n.stepType!=="replace")return!1;return!0}var Ua=class e{constructor(t){this.position=t}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function Bu(e,t){let n=t.mapping.mapResult(e.position);return{position:new Ua(n.pos),mapResult:n}}function F0(e){return new Ua(e)}function U0(e,t,n){let{selection:r}=t,s=null;if(Qg(r))s=r.$cursor;if(s){var o;let a=(o=e.storedMarks)!==null&&o!==void 0?o:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(a)||!a.some((l)=>l.type.excludes(n)))}let{ranges:i}=r;return i.some(({$from:a,$to:l})=>{let c=a.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(a.pos,l.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){let h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some((m)=>m.type.excludes(n));c=h&&p}return!c}),c})}var H0=(e,t={})=>({tr:n,state:r,dispatch:s})=>{let{selection:o}=n,{empty:i,ranges:a}=o,l=tn(e,r.schema);if(s)if(i){let c=iy(r,l);n.addStoredMark(l.create({...c,...t}))}else a.forEach((c)=>{let u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{let p=Math.max(h,u),m=Math.min(h+f.nodeSize,d);if(f.marks.find((g)=>g.type===l))f.marks.forEach((g)=>{if(l===g.type)n.addMark(p,m,l.create({...g.attrs,...t}))});else n.addMark(p,m,l.create(t))})});return U0(r,n,l)},$0=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),V0=(e,t={})=>({state:n,dispatch:r,chain:s})=>{let o=Ie(e,n.schema),i;if(n.selection.$anchor.sameParent(n.selection.$head))i=n.selection.$anchor.parent.attrs;if(!o.isTextblock)return console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1;return s().command(({commands:a})=>{if(jc(o,{...i,...t})(n))return!0;return a.clearNodes()}).command(({state:a})=>jc(o,{...i,...t})(a,r)).run()},z0=(e)=>({tr:t,dispatch:n})=>{if(n){let{doc:r}=t,s=ar(e,0,r.content.size),o=M.create(r,s);t.setSelection(o)}return!0},Y0=(e,t)=>({tr:n,state:r,dispatch:s})=>{let{selection:o}=r,i,a;if(typeof t==="number")i=t,a=t;else if(t&&"from"in t&&"to"in t)i=t.from,a=t.to;else i=o.from,a=o.to;if(s)n.doc.nodesBetween(i,a,(l,c)=>{if(l.isText)return;n.setNodeMarkup(c,void 0,{...l.attrs,dir:e})});return!0},j0=(e)=>({tr:t,dispatch:n})=>{if(n){let{doc:r}=t,{from:s,to:o}=typeof e==="number"?{from:e,to:e}:e,i=I.atStart(r).from,a=I.atEnd(r).to,l=ar(s,i,a),c=ar(o,i,a),u=I.create(r,l,c);t.setSelection(u)}return!0},W0=(e)=>({state:t,dispatch:n})=>{let r=Ie(e,t.schema);return am(r)(t,n)};function Yg(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter((s)=>t===null||t===void 0?void 0:t.includes(s.type.name));e.tr.ensureMarks(r)}}var K0=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:s})=>{let{selection:o,doc:i}=t,{$from:a,$to:l}=o,c=s.extensionManager.attributes,u=Ra(c,a.node().type.name,a.node().attrs);if(o instanceof M&&o.node.isBlock){if(!a.parentOffset||!mt(i,a.pos))return!1;if(r){if(e)Yg(n,s.extensionManager.splittableMarks);t.split(a.pos).scrollIntoView()}return!0}if(!a.parent.isBlock)return!1;let d=l.parentOffset===l.parent.content.size,f=a.depth===0?void 0:ry(a.node(-1).contentMatchAt(a.indexAfter(-1))),h=d&&f?[{type:f,attrs:u}]:void 0,p=o instanceof I&&!o.empty?It.create({doc:t.doc,selection:o}).tr.deleteSelection():null,m=p?p.doc:t.doc,g=p?p.mapping.map(a.pos):a.pos,E=mt(m,g,1,h);if(!h&&!E&&mt(m,g,1,f?[{type:f}]:void 0))E=!0,h=f?[{type:f,attrs:u}]:void 0;if(r){if(E){let x=t.steps.length;if(o instanceof I)t.deleteSelection();if(t.split(t.mapping.slice(x).map(a.pos),1,h),f&&!d&&!a.parentOffset&&a.parent.type!==f){let w=t.mapping.slice(x).map(a.before()),b=t.doc.resolve(w);if(a.node(-1).canReplaceWith(b.index(),b.index()+1,f))t.setNodeMarkup(t.mapping.slice(x).map(a.before()),f)}}if(e)Yg(n,s.extensionManager.splittableMarks);t.scrollIntoView()}return E},q0=(e,t={})=>({tr:n,state:r,dispatch:s,editor:o})=>{let i=Ie(e,r.schema),{$from:a,$to:l}=r.selection,c=r.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(l))return!1;let u=a.node(-1);if(u.type!==i)return!1;let d=o.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==i||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){var f;let b=S.empty,v=a.index(-1)?1:a.index(-2)?2:3;for(let ke=a.depth-v;ke>=a.depth-3;ke-=1)b=S.from(a.node(ke).copy(b));let D=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,R={...Ra(d,a.node().type.name,a.node().attrs),...t},P=((f=i.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(R))||void 0;b=b.append(S.from(i.createAndFill(null,P)||void 0));let H=a.before(a.depth-(v-1));n.replace(H,a.after(-D),new _(b,4-v,0));let F=-1;if(n.doc.nodesBetween(H,n.doc.content.size,(ke,qe)=>{if(F>-1)return!1;if(ke.isTextblock&&ke.content.size===0)F=qe+1}),F>-1)n.setSelection(I.near(n.doc.resolve(F)));n.scrollIntoView()}return!0}let h=l.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...Ra(d,u.type.name,u.attrs),...t},m={...Ra(d,a.node().type.name,a.node().attrs),...t},g=a.parentOffset===0&&a.index(-1)===0,E=a.before(-1);n.delete(a.pos,l.pos);let x=g?u.attrs:p,w=h?[{type:i,attrs:x},{type:h,attrs:m}]:[{type:i,attrs:x}];if(!mt(n.doc,a.pos,2))return!1;if(s){let{selection:b,storedMarks:v}=r,{splittableMarks:D}=o.extensionManager,R=v||b.$to.parentOffset&&b.$from.marks();if(n.split(a.pos,2,w).scrollIntoView(),g)n.setNodeMarkup(E,void 0,p);if(!R||!s)return!0;let P=R.filter((H)=>D.includes(H.type.name));n.ensureMarks(P)}return!0};function hy(e,t,n){if(!e.validContent(t))return null;try{return e.create(n,t)}catch{return null}}function Fu(e,t){if(e.pendingContent.length===0)return!0;let n=hy(t,S.from(e.pendingContent));if(!n)return!1;return e.items.push(n),e.pendingContent=[],!0}function X0(e,t,n){if(n.validContent(S.from([...t.pendingContent,e])))return t.pendingContent.push(e),!0;if(!Fu(t,n)||!n.validContent(S.from(e)))return!1;return t.pendingContent.push(e),!0}function G0(e,t,n,r){let s=r(e,n);if(!s)return!1;let o=hy(n.listType,S.from(s),e.attrs);if(!o)return!1;if(n.itemType.validContent(S.from([...t.pendingContent,o])))return t.pendingContent.push(o),!0;if(!Fu(t,n.itemType))return!1;return t.items.push(...s),!0}function J0(e,t,n){let r={items:[],pendingContent:[]};for(let s=0;s<e.childCount;s+=1){let o=e.child(s);if(!(t.isListNode(o)?G0(o,r,t,n):X0(o,r,t.itemType)))return null}return Fu(r,t.itemType)?r.items:null}function py(e,t){let n=[];for(let r=0;r<e.childCount;r+=1){let s=J0(e.child(r),t,py);if(!s)return null;n.push(...s)}return n}function jg(e,t){let n=null;return e.descendants((r,s)=>{if(r!==t)return!0;return n=s,!1}),n}function Wg(e){return!e||e==="1"?null:e}function my(e,t){return Wg(e)===Wg(t)}var Na=(e,t)=>{let n=Du((o)=>o.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let s=e.doc.nodeAt(r);if(!(n.node.type===(s===null||s===void 0?void 0:s.type)&&Ot(e.doc,n.pos)))return!0;if(!my(n.node.attrs.type,s===null||s===void 0?void 0:s.attrs.type))return!0;return e.join(n.pos),!0},Oa=(e,t)=>{let n=Du((o)=>o.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let s=e.doc.nodeAt(r);if(!(n.node.type===(s===null||s===void 0?void 0:s.type)&&Ot(e.doc,r)))return!0;if(!my(n.node.attrs.type,s===null||s===void 0?void 0:s.attrs.type))return!0;return e.join(r),!0};function Q0(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),s=t.resolve(n.nodeSize-1);return I.between(r,s)}var Z0=(e,t,n,r={})=>({editor:s,tr:o,state:i,dispatch:a,chain:l,commands:c,can:u})=>{let{extensions:d,splittableMarks:f}=s.extensionManager,h=Ie(e,i.schema),p=Ie(t,i.schema),{selection:m,storedMarks:g}=i,{$from:E,$to:x}=m,w=E.blockRange(x),b=g||m.$to.parentOffset&&m.$from.marks();if(!w)return!1;let v=Du((A)=>Mo(A.type.name,d))(m),D=m.from===0&&m.to===i.doc.content.size,R=i.doc.content.content,P=R.length===1?R[0]:null,H=D&&P&&Mo(P.type.name,d)?{node:P,pos:0,depth:0}:null,F=v!==null&&v!==void 0?v:H,ke=!!v&&w.depth>=1&&w.depth-v.depth<=1,qe=!!H;if((ke||qe)&&F){if(F.node.type===h){if(D&&qe)return l().command(({tr:A,dispatch:N})=>{let O=Q0(A);if(!O)return!1;if(A.setSelection(O),N)N(A);return!0}).liftListItem(p).run();return c.liftListItem(p)}if(Mo(F.node.type.name,d)&&h.validContent(F.node.content))return l().command(()=>(o.setNodeMarkup(F.pos,h),!0)).command(()=>Na(o,h)).command(()=>Oa(o,h)).run();if(Mo(F.node.type.name,d)){var lt;let A=(lt=F.node.firstChild)===null||lt===void 0?void 0:lt.type;if(A&&A!==p){let N=py(F.node,{listType:h,itemType:p,isListNode:(k)=>Mo(k.type.name,d)}),O=N?S.from(N):null;if(!O||!h.validContent(O))return!1;return l().command(()=>{let{$anchor:k,$head:L}=o.selection,Y=k.parent,te=L.parent,z=k.parentOffset,ee=L.parentOffset,Le;try{Le=h.create(r,O)}catch{return!1}if(o.replaceWith(F.pos,F.pos+F.node.nodeSize,Le),Y.inlineContent&&te.inlineContent){let Mn=jg(Le,Y),Rn=jg(Le,te);if(Mn!==null&&Rn!==null){let hl=F.pos+Mn+2+z,CT=F.pos+Rn+2+ee;o.setSelection(I.create(o.doc,hl,CT))}}return!0}).command(()=>Na(o,h)).command(()=>Oa(o,h)).run()}}}if(!n||!b||!a)return l().command(()=>{if(u().wrapInList(h,r))return!0;return c.clearNodes()}).wrapInList(h,r).command(()=>Na(o,h)).command(()=>Oa(o,h)).run();return l().command(()=>{let A=u().wrapInList(h,r),N=b.filter((O)=>f.includes(O.type.name));if(o.ensureMarks(N),A)return!0;return c.clearNodes()}).wrapInList(h,r).command(()=>Na(o,h)).command(()=>Oa(o,h)).run()},ek=(e,t={},n={})=>({state:r,commands:s})=>{let{extendEmptyMarkRange:o=!1}=n,i=tn(e,r.schema);if(Mu(r,i,t))return s.unsetMark(i,{extendEmptyMarkRange:o});return s.setMark(i,t)},tk=(e,t,n={})=>({state:r,commands:s})=>{let o=Ie(e,r.schema),i=Ie(t,r.schema),a=Do(r,o,n),l;if(r.selection.$anchor.sameParent(r.selection.$head))l=r.selection.$anchor.parent.attrs;if(a)return s.setNode(i,l);return s.setNode(o,{...l,...n})},nk=(e,t={})=>({state:n,commands:r})=>{let s=Ie(e,n.schema);if(Do(n,s,t))return r.lift(s);return r.wrapIn(s,t)},rk=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let s=n[r],o;if(s.spec.isInputRules&&(o=s.getState(e))){if(t){let i=e.tr,a=o.transform;for(let l=a.steps.length-1;l>=0;l-=1)i.step(a.steps[l].invert(a.docs[l]));if(o.text){let l=i.doc.resolve(o.from).marks();i.replaceWith(o.from,o.to,e.schema.text(o.text,l))}else i.delete(o.from,o.to)}return!0}}return!1},sk=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{ignoreClearable:s=!1}=e,{selection:o}=t,{empty:i,ranges:a}=o;if(i)return!0;let{nonClearableMarks:l}=r.extensionManager;if(n){let c=Object.values(r.schema.marks).filter((u)=>s||!l.includes(u.name));a.forEach((u)=>{for(let d of c)t.removeMark(u.$from.pos,u.$to.pos,d)})}return!0},ok=(e,t={})=>({tr:n,state:r,dispatch:s})=>{let{extendEmptyMarkRange:o=!1}=t,{selection:i}=n,a=tn(e,r.schema),{$from:l,empty:c,ranges:u}=i;if(!s)return!0;if(c&&o){var d;let{from:f,to:h}=i,p=Jg(l,a,(d=l.marks().find((m)=>m.type===a))===null||d===void 0?void 0:d.attrs);if(p)f=p.from,h=p.to;n.removeMark(f,h,a)}else u.forEach((f)=>{n.removeMark(f.$from.pos,f.$to.pos,a)});return n.removeStoredMark(a),!0},ik=(e)=>({tr:t,state:n,dispatch:r})=>{let{selection:s}=n,o,i;if(typeof e==="number")o=e,i=e;else if(e&&"from"in e&&"to"in e)o=e.from,i=e.to;else o=s.from,i=s.to;if(r)t.doc.nodesBetween(o,i,(a,l)=>{if(a.isText)return;let c={...a.attrs};delete c.dir,t.setNodeMarkup(l,void 0,c)});return!0},ak=(e,t={})=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null,a=Ba(typeof e==="string"?e:e.name,r.schema);if(!a)return!1;if(a==="node")o=Ie(e,r.schema);if(a==="mark")i=tn(e,r.schema);let l=!1;return n.selection.ranges.forEach((c)=>{let u=c.$from.pos,d=c.$to.pos,f,h,p,m;if(n.selection.empty)r.doc.nodesBetween(u,d,(g,E)=>{if(o&&o===g.type)l=!0,p=Math.max(E,u),m=Math.min(E+g.nodeSize,d),f=E,h=g});else r.doc.nodesBetween(u,d,(g,E)=>{if(E<u&&o&&o===g.type)l=!0,p=Math.max(E,u),m=Math.min(E+g.nodeSize,d),f=E,h=g;if(E>=u&&E<=d){if(o&&o===g.type){if(l=!0,s)n.setNodeMarkup(E,void 0,{...g.attrs,...t})}if(i&&g.marks.length)g.marks.forEach((x)=>{if(i===x.type){if(l=!0,s){let w=Math.max(E,u),b=Math.min(E+g.nodeSize,d);n.addMark(w,b,i.create({...x.attrs,...t}))}}})}});if(h){if(f!==void 0&&s)n.setNodeMarkup(f,void 0,{...h.attrs,...t});if(i&&h.marks.length)h.marks.forEach((g)=>{if(i===g.type&&s)n.addMark(p,m,i.create({...g.attrs,...t}))})}}),l},ls=new Q("__tiptap_decorations__"),lk=(e)=>({tr:t,dispatch:n})=>{if(n)t.setMeta(ls,{type:"force",name:e});return!0},ck=(e,t={})=>({state:n,dispatch:r})=>{let s=Ie(e,n.schema);return sm(s,t)(n,r)},uk=(e,t={})=>({state:n,dispatch:r})=>{let s=Ie(e,n.schema);return om(s,t)(n,r)},dk=$h({blur:()=>_C,clearContent:()=>NC,clearNodes:()=>OC,command:()=>IC,createParagraphNear:()=>MC,cut:()=>RC,deleteCurrentNode:()=>DC,deleteNode:()=>vC,deleteRange:()=>LC,deleteSelection:()=>FC,enter:()=>UC,exitCode:()=>HC,extendMarkRange:()=>$C,first:()=>VC,focus:()=>YC,forEach:()=>jC,insertContent:()=>WC,insertContentAt:()=>KC,insertDefaultBlock:()=>qC,joinBackward:()=>JC,joinDown:()=>GC,joinForward:()=>QC,joinItemBackward:()=>ZC,joinItemForward:()=>e0,joinTextblockBackward:()=>t0,joinTextblockForward:()=>n0,joinUp:()=>XC,keyboardShortcut:()=>s0,lift:()=>o0,liftEmptyBlock:()=>i0,liftListItem:()=>a0,newlineInCode:()=>l0,resetAttributes:()=>c0,scrollIntoView:()=>u0,selectAll:()=>d0,selectNodeBackward:()=>f0,selectNodeForward:()=>h0,selectParentNode:()=>p0,selectTextblockEnd:()=>m0,selectTextblockStart:()=>g0,setContent:()=>y0,setMark:()=>H0,setMeta:()=>$0,setNode:()=>V0,setNodeSelection:()=>z0,setTextDirection:()=>Y0,setTextSelection:()=>j0,sinkListItem:()=>W0,splitBlock:()=>K0,splitListItem:()=>q0,toggleList:()=>Z0,toggleMark:()=>ek,toggleNode:()=>tk,toggleWrap:()=>nk,undoInputRule:()=>rk,unsetAllMarks:()=>sk,unsetMark:()=>ok,unsetTextDirection:()=>ik,updateAttributes:()=>ak,updateDecorations:()=>lk,wrapIn:()=>ck,wrapInList:()=>uk}),cs=new WeakMap;function fk(e,t){var n;cs.set(e,((n=cs.get(e))!==null&&n!==void 0?n:0)+1);try{return t()}finally{var r;let s=((r=cs.get(e))!==null&&r!==void 0?r:1)-1;if(s>0)cs.set(e,s);else cs.delete(e)}}function hk(e){return cs.has(e)}var pk=class{constructor(){this.callbacks={}}on(e,t){if(!this.callbacks[e])this.callbacks[e]=[];return this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];if(n)n.forEach((r)=>r.apply(this,t));return this}off(e,t){let n=this.callbacks[e];if(n)if(t)this.callbacks[e]=n.filter((r)=>r!==t);else delete this.callbacks[e];return this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},gy=typeof process<"u"&&!0;function mk(e){return e.kind==="widget"}function yy(e,t){let n=[],r=new Set;for(let s of e){if(s.kind==="widget"){if(mk(s))r.add(s.key)}n.push(s.toPMDecoration(t))}return{decorations:n,widgetKeys:r}}function gk(e,t,n){let{decorations:r,widgetKeys:s}=yy(t,n);return{set:j.create(e,r),widgetKeys:s}}function Ey({position:e,from:t,to:n,docSize:r}){if(e<t)return!1;if(e<n)return!0;return e===n&&n===r}function yk({decorations:e,from:t,to:n,docSize:r,extensionName:s,warnedExtensions:o}){return e.filter((i)=>{if(Ey({position:i.anchor,from:t,to:n,docSize:r}))return!0;if(i.anchor===n)return!1;if(!o.has(s))o.add(s),console.warn(`[tiptap warn]: Extension "${s}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`);return!1})}function Ty(e){var t;let n=(t=e.spec)===null||t===void 0?void 0:t.key;return typeof n==="string"?n:void 0}function Ek(e){let t=new Map,n=new Map;for(let i of e.find()){var r,s,o;let a=Ty(i);if(!a)continue;let l=(r=i.spec.extensionName)!==null&&r!==void 0?r:"unknown",c=(s=t.get(a))!==null&&s!==void 0?s:new Set;c.add(l),t.set(a,c),n.set(a,((o=n.get(a))!==null&&o!==void 0?o:0)+1)}return Array.from(t,([i,a])=>({key:i,extensions:a})).filter(({key:i})=>{var a;return((a=n.get(i))!==null&&a!==void 0?a:0)>1})}function by(e){return e.jsonID==="attr"}function Tk(e){let t=!1;if(e.getMap().forEach(()=>{t=!0}),t||by(e))return!0;let n=e;return typeof n.from==="number"&&typeof n.to==="number"}function bk(e,t){let n=null,r=0,s=0;for(let o=0;o<e.childCount;o+=1){if(s>t.to)break;let i=s+e.child(o).nodeSize;if(i>=t.from){if(n===null)n=s;r=i}s=i}return n===null?null:{from:n,to:r}}function Sk(e,t){if(e.steps.some((o)=>!Tk(o)))return{type:"full"};let n=Fa(e).map(({newRange:o})=>o);e.steps.forEach((o,i)=>{if(!by(o))return;let a=e.mapping.slice(i);n.push({from:a.map(o.pos,-1),to:a.map(o.pos+1)})});let r=[];for(let o of n){let i=bk(t,o);if(i)r.push(i)}r.sort((o,i)=>o.from-i.from);let s=[];for(let o of r){let i=s[s.length-1];if(i&&o.from<=i.to)i.to=Math.max(i.to,o.to);else s.push({...o})}return{type:"ranges",ranges:s}}function Sy(e,t,n,r){return e.map(t,n,{onRemove:(s)=>{let o=s===null||s===void 0?void 0:s.key;if(typeof o==="string")r.delete(o)}})}function xk(e,t,n){var r,s;let o=(r=t.decorationSetsByExtension[e])!==null&&r!==void 0?r:j.empty,i=new Set((s=t.widgetKeysByExtension[e])!==null&&s!==void 0?s:[]);return{set:Sy(o,n.mapping,n.doc,i),widgetKeys:i}}function Kg(e,t){let n=Object.values(t).flatMap((r)=>r.find());return j.create(e,n)}function qg(e){let t=new Set;for(let n of Object.values(e))for(let r of n)t.add(r);return t}function Ak(e,t){var n;switch((n=t.update)!==null&&n!==void 0?n:"document"){case"document":if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(t.shouldUpdate)throw Error(`[tiptap error]: Extension "${e}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function wk(e,t,n){if(n)return!0;if(e.update==="manual")return!1;return e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var Ck=new Set;var kk=class{constructor(e){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:t})=>{let n=ls.getState(t);if(n)this.warnDuplicateWidgetKeys(n)},this.editor=e.editor,this.entries=this.resolveEntries(e.entries),this.entries.forEach(({name:t,spec:n})=>Ak(t,n)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)}destroy(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}liveWidgetKeys(){var e,t;return(e=(t=ls.getState(this.editor.state))===null||t===void 0?void 0:t.widgetKeys)!==null&&e!==void 0?e:Ck}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(e){let t=[];for(let{name:n,addDecorations:r}of e){let s=r();if(s)t.push({name:n,spec:s})}return t}createPlugin(){let{editor:e,entries:t}=this;return new q({key:ls,state:{init:(n,r)=>{let s={},o={};for(let{name:a,spec:l}of t){let{set:c,widgetKeys:u}=this.buildFullSet(a,l,r);s[a]=c,o[a]=u}let i={decorationSetsByExtension:s,widgetKeysByExtension:o,mergedDecorationSet:this.buildMergedSet(r.doc,s),widgetKeys:qg(o)};return this.warnDuplicateWidgetKeys(i),i},apply:(n,r,s,o)=>{let i=n.getMeta(ls),a=(i===null||i===void 0?void 0:i.type)==="force"&&!i.name,l=(i===null||i===void 0?void 0:i.type)==="force"?i.name:void 0,c={},u={},d=new Set;if(fk(e,()=>{for(let{name:f,spec:h}of t){let p=a||l===f;if(!wk(h,{editor:e,tr:n,oldState:s,newState:o},p)){let m=xk(f,r,n);c[f]=m.set,u[f]=m.widgetKeys}else if(h.update==="changedRanges"&&n.docChanged&&!p){let m=this.applyChangedRangesRecompute(f,h,r,n,o);c[f]=m.set,u[f]=m.widgetKeys,d.add(f)}else{let{set:m,widgetKeys:g}=this.buildFullSet(f,h,o);c[f]=m,u[f]=g,d.add(f)}}}),d.size===0&&!n.docChanged)return r;return{decorationSetsByExtension:c,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:t,previous:r,tr:n,decorationSetsByExtension:c,recomputedNames:d}),widgetKeys:qg(u)}}},props:{decorations(n){var r,s;return(r=(s=ls.getState(n))===null||s===void 0?void 0:s.mergedDecorationSet)!==null&&r!==void 0?r:j.empty}}})}applyChangedRangesRecompute(e,t,n,r,s){let o=Sk(r,s.doc);if(o.type==="full")return this.buildFullSet(e,t,s);return this.rebuildRanges(e,t,n,r,s,o.ranges)}rebuildRanges(e,t,n,r,s,o){var i,a;let l=(i=n.decorationSetsByExtension[e])!==null&&i!==void 0?i:j.empty,c=new Set((a=n.widgetKeysByExtension[e])!==null&&a!==void 0?a:[]),u=Sy(l,r.mapping,r.doc,c),d=s.doc.content.size;for(let{from:f,to:h}of o){let p=u.find(f,h).filter((E)=>Ey({position:E.from,from:f,to:h,docSize:d}));for(let E of p){let x=Ty(E);if(x)c.delete(x)}u=u.remove(p);let{decorations:m,widgetKeys:g}=yy(yk({decorations:this.runCreate(e,"createInRange",()=>t.createInRange({editor:this.editor,state:s,view:this.mountedView,from:f,to:h})),from:f,to:h,docSize:d,extensionName:e,warnedExtensions:this.warnedOutOfRangeExtensions}),e);u=u.add(s.doc,m);for(let E of g)c.add(E)}return{set:u,widgetKeys:c}}buildFullSet(e,t,n){let r=this.runCreate(e,"create",()=>t.create({editor:this.editor,state:n,view:this.mountedView}));return gk(n.doc,r,e)}runCreate(e,t,n){try{return n()}catch(r){return console.error(`[tiptap error]: Extension "${e}" threw in \`addDecorations().${t}()\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(e){if(!gy)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=Ek(e.mergedDecorationSet),n=new Set(t.map(({key:r})=>r));for(let{key:r,extensions:s}of t){if(this.warnedWidgetKeys.has(r))continue;let o=Array.from(s).map((i)=>`"${i}"`).join(", ");console.warn(`[tiptap warn]: Duplicate widget decoration key "${r}" in extension${s.size===1?"":"s"} ${o}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(e,t){let n=Object.keys(t);if(n.length===1)return t[n[0]];return Kg(e,t)}mergeAfterApply({entries:e,previous:t,tr:n,decorationSetsByExtension:r,recomputedNames:s}){if(e.length===1)return r[e[0].name];if(s.size===0)return t.mergedDecorationSet.map(n.mapping,n.doc);return Kg(n.doc,r)}};function _k(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;let s=document.createElement("style");if(t)s.setAttribute("nonce",t);return s.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),s.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(s),s}function Uu(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function Nk(e){return typeof e==="number"}function Ok(e){return Object.prototype.toString.call(e).slice(8,-1)}function Ia(e){if(Ok(e)!=="Object")return!1;return e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function xy(e){return typeof e==="string"&&e.trim().length>0&&!/[;{}]/.test(e)}function Ay(e,t){let n={...e};if(Ia(e)&&Ia(t))Object.keys(t).forEach((r)=>{if(Ia(t[r])&&Ia(e[r]))n[r]=Ay(e[r],t[r]);else n[r]=t[r]});return n}function Ik(e,t,n={}){let{state:r}=t,{doc:s,tr:o}=r,i=e;if(s.descendants((a,l)=>{let c=o.mapping.map(l),u=o.mapping.map(l)+a.nodeSize,d=null;if(a.marks.forEach((h)=>{if(h!==i)return!1;d=h}),!d)return;let f=!1;if(Object.keys(n).forEach((h)=>{if(n[h]!==d.attrs[h])f=!0}),f){let h=e.type.create({...e.attrs,...n});o.removeMark(c,u,e.type),o.addMark(c,u,h)}}),o.docChanged)t.view.dispatch(o)}var Mk=(e,t)=>{if(Ru(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];if(r.index=n.index,r.input=e,r.data=n.data,n.replaceWith){if(!n.text.includes(n.replaceWith))console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".');r.push(n.replaceWith)}return r};function Rk(e){let{editor:t,from:n,to:r,text:s,insertText:o}=e;if(!o)return{inputTransaction:null,tr:t.view.state.tr};let i=t.view.state.tr.insertText(s,n,r);return{inputTransaction:i,tr:It.create({doc:i.doc,selection:i.selection,storedMarks:i.storedMarks}).tr}}function Dk(e){let{editor:t,from:n,to:r,text:s,rule:o,match:i,plugin:a,insertText:l}=e,{view:c}=t,{inputTransaction:u,tr:d}=Rk({editor:t,from:n,to:r,text:s,insertText:l}),f=u?n+s.length:r,h=Pa({state:c.state,transaction:d}),p={from:n-(i[0].length-s.length),to:f},{commands:m,chain:g,can:E}=new us({editor:t,state:h});if(o.handler({state:h,range:p,match:i,commands:m,chain:g,can:E})===null||!d.steps.length)return!1;if(u){if(c.dispatch(u),!c.state.doc.eq(u.doc))return!0}if(Og(d),d.setMeta("inputRule",!0),o.undoable)d.setMeta(a,{transform:d,from:n,to:f,text:s});return c.dispatch(d),!0}function vk(e,t,n){let r=t[0].length-n.length;if(r<=0)return!0;let s=e.parentOffset-r;return s>=0&&e.parent.textBetween(s,e.parentOffset)===t[0].slice(0,r)}function Ma(e){var t;let{editor:n,from:r,to:s,text:o,rules:i,plugin:a,insertText:l}=e,{view:c}=n;if(c.composing)return!1;let u=c.state.doc.resolve(r);if(u.parent.type.spec.code||!!((t=u.nodeBefore||u.nodeAfter)===null||t===void 0?void 0:t.marks.find((f)=>f.type.spec.code)))return!1;let d=v0(u)+o;for(let f of i){let h=Mk(d,f.find);if(!h||!vk(u,h,o))continue;if(Dk({editor:n,from:r,to:s,text:o,rule:f,match:h,plugin:a,insertText:l}))return!0}return!1}function Lk(e){let{editor:t,rules:n}=e,r=new q({state:{init(){return null},apply(s,o,i){let a=s.getMeta(r);if(a)return a;let l=s.getMeta("applyInputRules");if(l)setTimeout(()=>{let{text:c}=l;if(typeof c==="string")c=c;else c=Lu(S.from(c),i.schema);let{from:u}=l,d=u+c.length;Ma({editor:t,from:u,to:d,text:c,rules:n,plugin:r})});return s.selectionSet||s.docChanged?null:o}},props:{handleTextInput(s,o,i,a){return Ma({editor:t,from:o,to:i,text:a,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:(s)=>(setTimeout(()=>{let{$cursor:o}=s.state.selection;if(o)Ma({editor:t,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,o){if(o.key!=="Enter")return!1;let{$cursor:i}=s.state.selection;if(i)return Ma({editor:t,from:i.pos,to:i.pos,text:`
|
|
17
|
+
`,rules:n,plugin:r});return!1}},isInputRules:!0});return r}var Hu=class{constructor(e={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...oe(B(this,"addOptions",{name:this.name}))}}get storage(){return{...oe(B(this,"addStorage",{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>Ay(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name="name"in e?e.name:t.parent.name,t}},$u=class e extends Hu{constructor(...t){super(...t);this.type="mark"}static create(t={}){let n=typeof t==="function"?t():t;return new e(n)}static handleExit({editor:t,mark:n}){let{tr:r}=t.state,s=t.state.selection.$from;if(s.pos===s.end()){let o=s.marks();if(!o.find((a)=>(a===null||a===void 0?void 0:a.type.name)===n.name))return!1;let i=o.find((a)=>(a===null||a===void 0?void 0:a.type.name)===n.name);if(i)r.removeStoredMark(i);return r.insertText(" ",s.pos),t.view.dispatch(r),!0}return!1}configure(t){return super.configure(t)}extend(t){let n=typeof t==="function"?t():t;return super.extend(n)}};var Pk=(e,t,n)=>{if(Ru(t))return[...e.matchAll(t)];let r=t(e,n);if(!r)return[];return r.map((s)=>{let o=[s.text];if(o.index=s.index,o.input=e,o.data=s.data,s.replaceWith){if(!s.text.includes(s.replaceWith))console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".');o.push(s.replaceWith)}return o})};function Bk(e){let{editor:t,state:n,from:r,to:s,rule:o,pasteEvent:i,dropEvent:a}=e,{commands:l,chain:c,can:u}=new us({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,s,(f,h)=>{var p,m,g,E;if(((p=f.type)===null||p===void 0||(p=p.spec)===null||p===void 0?void 0:p.code)||!(f.isText||f.isTextblock||f.isInline))return;let x=(m=(g=(E=f.content)===null||E===void 0?void 0:E.size)!==null&&g!==void 0?g:f.nodeSize)!==null&&m!==void 0?m:0,w=Math.max(r,h),b=Math.min(s,h+x);if(w>=b)return;let v=f.isText?f.text||"":f.textBetween(w-h,b-h,void 0,"");Pk(v,o.find,i).forEach((D)=>{if(D.index===void 0)return;let R=w+D.index+1,P=R+D[0].length,H={from:n.tr.mapping.map(R),to:n.tr.mapping.map(P)},F=o.handler({state:n,range:H,match:D,commands:l,chain:c,can:u,pasteEvent:i,dropEvent:a});d.push(F)})}),d.every((f)=>f!==null)}var as=null,Fk=(e)=>{var t;let n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(t=n.clipboardData)===null||t===void 0||t.setData("text/html",e),n};function Uk(e){let{editor:t,rules:n}=e,r=null,s=!1,o=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}let l=({state:c,from:u,to:d,rule:f,pasteEvt:h})=>{let p=c.tr,m=Pa({state:c,transaction:p});if(!Bk({editor:t,state:m,from:Math.max(u-1,0),to:d.b-1,rule:f,pasteEvent:h,dropEvent:a})||!p.steps.length)return;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,p};return t.on("destroy",()=>{if(as===t)as=null}),n.map((c)=>new q({view(u){let d=(h)=>{var p;if(r=((p=u.dom.parentElement)===null||p===void 0?void 0:p.contains(h.target))?u.dom.parentElement:null,r)as=t},f=()=>{if(as)as=null};return window.addEventListener("dragstart",d),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",d),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(u,d)=>{if(o=r===u.dom.parentElement,a=d,!o){let f=as;if(f===null||f===void 0?void 0:f.isEditable)setTimeout(()=>{if(f.isDestroyed)return;let h=f.state.selection;if(h)f.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(u,d)=>{var f;let h=(f=d.clipboardData)===null||f===void 0?void 0:f.getData("text/html");return i=d,s=!!(h===null||h===void 0?void 0:h.includes("data-pm-slice")),!1}}},appendTransaction:(u,d,f)=>{let h=u[0],p=h.getMeta("uiEvent")==="paste"&&!s,m=h.getMeta("uiEvent")==="drop"&&!o,g=h.getMeta("applyPasteRules"),E=!!g;if(!p&&!m&&!E)return;if(E){let{text:b}=g;if(typeof b==="string")b=b;else b=Lu(S.from(b),f.schema);let{from:v}=g,D=v+b.length,R=Fk(b);return l({rule:c,state:f,from:v,to:{b:D},pasteEvt:R})}let x=d.doc.content.findDiffStart(f.doc.content),w=d.doc.content.findDiffEnd(f.doc.content);if(!Nk(x)||!w||x===w.b)return;return l({rule:c,state:f,from:x,to:w,pasteEvt:i})}}))}var Ha=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=cy(e),this.hasSchemaSpec=t.options.schemaSpec!==void 0,this.schema=N0(this.extensions,t,t.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=B(t,"addCommands",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:is(t.name,this.schema)});if(!n)return e;return{...e,...n()}},{})}get plugins(){let{editor:e}=this,t=Ro([...this.extensions].reverse()).flatMap((r)=>{let s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:is(r.name,this.schema)},o=[],i=B(r,"addKeyboardShortcuts",s),a={};if(r.type==="mark"&&B(r,"exitable",s))a.ArrowRight=()=>$u.handleExit({editor:e,mark:r});if(i){let f=Object.fromEntries(Object.entries(i()).map(([h,p])=>[h,()=>p({editor:e})]));a={...a,...f}}let l=Cg(a);o.push(l);let c=B(r,"addInputRules",s);if(zg(r,e.options.enableInputRules)&&c){let f=c();if(f&&f.length){let h=Lk({editor:e,rules:f}),p=Array.isArray(h)?h:[h];o.push(...p)}}let u=B(r,"addPasteRules",s);if(zg(r,e.options.enablePasteRules)&&u){let f=u();if(f&&f.length){let h=Uk({editor:e,rules:f});o.push(...h)}}let d=B(r,"addProseMirrorPlugins",s);if(d){let f=d();o.push(...f)}return o}),n=this.createDecorationPlugin();if(n)t.push(n);return t}createDecorationPlugin(){var e;let{editor:t}=this;(e=this.decorationManager)===null||e===void 0||e.destroy();let n=[];return this.extensions.forEach((r)=>{let s=B(r,"addDecorations",{name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:is(r.name,this.schema)});if(!s)return;n.push({name:r.name,addDecorations:s})}),this.decorationManager=new kk({editor:t,entries:n}),this.decorationManager.plugin}get attributes(){let e=Pu(this.extensions);return this.hasSchemaSpec?ay(e,this.schema):e}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=fs(this.extensions);return Object.fromEntries(t.filter((n)=>!!B(n,"addNodeView")).map((n)=>{let r=this.attributes.filter((a)=>a.type===n.name),s=B(n,"addNodeView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:Ie(n.name,this.schema)});if(!s)return[];let o=s();if(!o)return[];let i=(a,l,c,u,d)=>{let f=La(a,r);return o({node:a,view:l,getPos:c,decorations:u,innerDecorations:d,editor:e,extension:n,HTMLAttributes:f})};return[n.name,i]}))}dispatchTransaction(e){let{editor:t}=this;return Ro([...this.extensions].reverse()).reduceRight((n,r)=>{let s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:is(r.name,this.schema)},o=B(r,"dispatchTransaction",s);if(!o)return n;return(i)=>{o.call(s,{transaction:i,next:n})}},e)}transformPastedHTML(e){let{editor:t}=this;return Ro([...this.extensions]).reduce((n,r)=>{let s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:is(r.name,this.schema)},o=B(r,"transformPastedHTML",s);if(!o)return n;return(i,a)=>{let l=n(i,a);return o.call(s,l)}},e||((n)=>n))}get markViews(){let{editor:e}=this,{markExtensions:t}=fs(this.extensions);return Object.fromEntries(t.filter((n)=>!!B(n,"addMarkView")).map((n)=>{let r=this.attributes.filter((i)=>i.type===n.name),s=B(n,"addMarkView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:tn(n.name,this.schema)});if(!s)return[];let o=(i,a,l)=>{let c=La(i,r);return s()({mark:i,view:a,inline:l,editor:e,extension:n,HTMLAttributes:c,updateAttributes:(u)=>{Ik(i,e,u)}})};return[n.name,o]}))}destroy(){var e;(e=this.decorationManager)===null||e===void 0||e.destroy(),this.extensions.forEach((t)=>{let n=t;while(n.parent){let r=n.parent;if(r.child===n)r.child=null;n=r}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map((t)=>[t.name,t.storage])),e.forEach((t)=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:is(t.name,this.schema)};if(t.type==="mark"){var r,s;if((r=oe(B(t,"keepOnSplit",n)))!==null&&r!==void 0?r:!0)this.splittableMarks.push(t.name);if(!((s=oe(B(t,"clearable",n)))!==null&&s!==void 0?s:!0))this.nonClearableMarks.push(t.name)}let o=B(t,"onBeforeCreate",n),i=B(t,"onCreate",n),a=B(t,"onUpdate",n),l=B(t,"onSelectionUpdate",n),c=B(t,"onTransaction",n),u=B(t,"onFocus",n),d=B(t,"onBlur",n),f=B(t,"onDestroy",n);if(o)this.editor.on("beforeCreate",o);if(i)this.editor.on("create",i);if(a)this.editor.on("update",a);if(l)this.editor.on("selectionUpdate",l);if(c)this.editor.on("transaction",c);if(u)this.editor.on("focus",u);if(d)this.editor.on("blur",d);if(f)this.editor.on("destroy",f)})}};Ha.resolve=cy;Ha.sort=Ro;Ha.flatten=vu;var ne=class e extends Hu{constructor(...t){super(...t);this.type="extension"}static create(t={}){let n=typeof t==="function"?t():t;return new e(n)}configure(t){return super.configure(t)}extend(t){let n=typeof t==="function"?t():t;return super.extend(n)}},Hk=ne.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new q({key:new Q("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:s}=t,o=dy(n),{blockSeparator:i}=this.options,a={...i!==void 0?{blockSeparator:i}:{},textSerializers:o};return[...s.ranges].sort((l,c)=>l.$from.pos-c.$from.pos).map(({$from:l,$to:c})=>uy(r,{from:l.pos,to:c.pos},a)).join(i!==null&&i!==void 0?i:`
|
|
18
|
+
|
|
19
|
+
`)}}})]}}),$k=ne.create({name:"commands",addCommands(){return{...dk}}}),Vk=ne.create({name:"delete",onUpdate({transaction:e,appendedTransactions:t}){var n,r;let s=()=>{var o,i,a;if((o=(i=this.editor.options.coreExtensionOptions)===null||i===void 0||(i=i.delete)===null||i===void 0||(a=i.filterTransaction)===null||a===void 0?void 0:a.call(i,e))!==null&&o!==void 0?o:e.getMeta("y-sync$"))return;let l=E0(e.before,[e,...t]);Fa(l).forEach((u)=>{if(l.mapping.mapResult(u.oldRange.from).deletedAfter&&l.mapping.mapResult(u.oldRange.to).deletedBefore)l.before.nodesBetween(u.oldRange.from,u.oldRange.to,(d,f)=>{let h=f+d.nodeSize-2,p=u.oldRange.from<=f&&h<=u.oldRange.to;this.editor.emit("delete",{type:"node",node:d,from:f,to:h,newFrom:l.mapping.map(f),newTo:l.mapping.map(h),deletedRange:u.oldRange,newRange:u.newRange,partial:!p,editor:this.editor,transaction:e,combinedTransform:l})})});let c=l.mapping;l.steps.forEach((u,d)=>{if(u instanceof Et){var f,h;let p=c.slice(d).map(u.from,-1),m=c.slice(d).map(u.to),g=c.invert().map(p,-1),E=c.invert().map(m),x=p>0?(f=l.doc.nodeAt(p-1))===null||f===void 0?void 0:f.marks.some((b)=>b.eq(u.mark)):!1,w=(h=l.doc.nodeAt(m))===null||h===void 0?void 0:h.marks.some((b)=>b.eq(u.mark));this.editor.emit("delete",{type:"mark",mark:u.mark,from:u.from,to:u.to,deletedRange:{from:g,to:E},newRange:{from:p,to:m},partial:Boolean(w||x),editor:this.editor,transaction:e,combinedTransform:l})}})};if((n=(r=this.editor.options.coreExtensionOptions)===null||r===void 0||(r=r.delete)===null||r===void 0?void 0:r.async)!==null&&n!==void 0?n:!0)setTimeout(s,0);else s()}}),zk=ne.create({name:"drop",addProseMirrorPlugins(){return[new q({key:new Q("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Yk=ne.create({name:"editable",addProseMirrorPlugins(){return[new q({key:new Q("editable"),props:{editable:()=>this.editor.options.editable}})]}}),jk=new Q("focusEvents"),Wk=ne.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:e}=this;return[new q({key:jk,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}});function Kk(e){let{empty:t,from:n,to:r}=e.selection;if(t)return!1;return n===U.atStart(e.doc).from&&r===U.atEnd(e.doc).to}var qk=ne.create({name:"keymap",addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:a})=>{let{selection:l,doc:c}=a,{empty:u,$anchor:d}=l,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?a.doc.resolve(f-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,E=m&&p.parent.childCount===1?g===d.pos:U.atStart(c).from===f;if(!u||!h.type.isTextblock||h.textContent.length||!E||E&&d.parent.type.name==="paragraph")return!1;return i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},o={...r,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};if(va()||oy())return o;return s},addProseMirrorPlugins(){return[new q({key:new Q("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some((l)=>l.getMeta("composition")))return;let r=e.some((l)=>l.docChanged)&&!t.doc.eq(n.doc),s=e.some((l)=>l.getMeta("preventClearDocument"));if(!r||s)return;if(!Kk(t))return;if(!hs(n.doc))return;let o=n.tr,i=Pa({state:n,transaction:o}),{commands:a}=new us({editor:this.editor,state:i});if(a.clearNodes(),!o.steps.length&&!n.storedMarks)return;return o.setStoredMarks(null)}})]}}),Xk=ne.create({name:"paste",addProseMirrorPlugins(){return[new q({key:new Q("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),Gk=ne.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new q({key:new Q("tabindex"),props:{attributes:()=>{var e;if(!this.editor.isEditable&&this.options.value===void 0)return{};return{tabindex:(e=this.options.value)!==null&&e!==void 0?e:"0"}}}})]}}),Jk=ne.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=fs(this.extensions);return[{types:e.filter((t)=>t.name!=="text").map((t)=>t.name),attributes:{dir:{default:this.options.direction,parseHTML:(t)=>{let n=t.getAttribute("dir");if(n&&(n==="ltr"||n==="rtl"||n==="auto"))return n;return this.options.direction},renderHTML:(t)=>{if(!t.dir)return{};return{dir:t.dir}}}}}]},addProseMirrorPlugins(){return[new q({key:new Q("textDirection"),props:{attributes:()=>{let e=this.options.direction;if(!e)return{};return{dir:e}}}})]}});var Xg=!1;function Qk(e){if(Xg)return;Xg=!0;let t;try{let n=se.fromJSON(e,{from:0,to:0});if(!B0(n))return;t=n.slice.content}catch{return}if(t instanceof S)return;console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.")}var Zk=class e{get name(){return this.node.type.name}constructor(t,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=t,this.editor=n,this.currentNode=s}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!==null&&t!==void 0?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){if(this.isBlock)return this.pos;return this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){if(this.isBlock)return this.pos+this.size;return this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new e(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));if(t.depth!==this.depth)t=this.resolvedPos.doc.resolve(this.from-3);return new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));if(t.depth!==this.depth)t=this.resolvedPos.doc.resolve(this.to+3);return new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let s=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,i=n.isInline,a=this.pos+r+(o?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;let l=this.resolvedPos.doc.resolve(a);if(!s&&!i&&l.depth<=this.depth)return;let c=new e(l,this.editor,s,s||i?n:null);if(s)c.actualDepth=this.depth+1;t.push(c)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let t=this.children;return t[t.length-1]||null}closest(t,n={}){let r=null,s=this.parent;while(s&&!r){if(s.node.type.name===t)if(Object.keys(n).length>0){let o=s.node.attrs,i=Object.keys(n);for(let a=0;a<i.length;a+=1){let l=i[a];if(o[l]!==n[l])break}}else r=s;s=s.parent}return r}querySelector(t,n={}){return this.querySelectorAll(t,n,!0)[0]||null}querySelectorAll(t,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;let o=Object.keys(n);return this.children.forEach((i)=>{if(r&&s.length>0)return;if(i.node.type.name===t){if(o.every((a)=>n[a]===i.node.attrs[a]))s.push(i)}if(r&&s.length>0)return;s=s.concat(i.querySelectorAll(t,n,r))}),s}setAttribute(t){let{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(n)}},e_=`.ProseMirror {
|
|
20
|
+
position: relative;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ProseMirror {
|
|
24
|
+
word-wrap: break-word;
|
|
25
|
+
white-space: pre-wrap;
|
|
26
|
+
white-space: break-spaces;
|
|
27
|
+
-webkit-font-variant-ligatures: none;
|
|
28
|
+
font-variant-ligatures: none;
|
|
29
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ProseMirror [contenteditable="false"] {
|
|
33
|
+
white-space: normal;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
37
|
+
white-space: pre-wrap;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ProseMirror pre {
|
|
41
|
+
white-space: pre-wrap;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
img.ProseMirror-separator {
|
|
45
|
+
display: inline !important;
|
|
46
|
+
border: none !important;
|
|
47
|
+
margin: 0 !important;
|
|
48
|
+
width: 0 !important;
|
|
49
|
+
height: 0 !important;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.ProseMirror-gapcursor {
|
|
53
|
+
display: none;
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
position: absolute;
|
|
56
|
+
margin: 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.ProseMirror-gapcursor:after {
|
|
60
|
+
content: "";
|
|
61
|
+
display: block;
|
|
62
|
+
position: absolute;
|
|
63
|
+
top: -2px;
|
|
64
|
+
width: 20px;
|
|
65
|
+
border-top: 1px solid black;
|
|
66
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@keyframes ProseMirror-cursor-blink {
|
|
70
|
+
to {
|
|
71
|
+
visibility: hidden;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.ProseMirror-hideselection *::selection {
|
|
76
|
+
background: transparent;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
80
|
+
background: transparent;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.ProseMirror-hideselection * {
|
|
84
|
+
caret-color: transparent;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
88
|
+
display: block;
|
|
89
|
+
}`,wy=class extends pk{constructor(e={}){super();this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Bu,createMappablePosition:F0},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:n,slice:r,moved:s})=>this.options.onDrop(n,r,s)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),this.on("delete",this.options.onDelete);let t=this.createDoc();if(!this.editorState){let n=Nu(t,this.options.autofocus);this.editorState=It.create({doc:t,schema:this.schema,selection:n||void 0})}if(Qk(this.schema),this.options.element)this.mount(this.options.element)}mount(e){if(typeof document>"u")throw Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");if(this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css))document.head.appendChild(this.css);window.setTimeout(()=>{if(this.isDestroyed)return;if(this.options.autofocus!==!1&&this.options.autofocus!==null)this.commands.focus(this.options.autofocus);this.emit("create",{editor:this}),this.isInitialized=!0},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let e=this.editorView.dom;if(e===null||e===void 0?void 0:e.editor)delete e.editor;this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{if(typeof this.css.remove==="function")this.css.remove();else if(this.css.parentNode)this.css.parentNode.removeChild(this.css)}catch(e){console.warn("Failed to remove CSS element:",e)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){if(!this.commandManager)return us.createFakeChain();return this.commandManager.chain()}can(){if(!this.commandManager)return us.createFallbackCan();return this.commandManager.can()}injectCSS(){if(this.options.injectCSS&&typeof document<"u")this.css=_k(e_,this.options.injectNonce)}setOptions(e={}){if(this.options={...this.options,...e},!this.editorView||!this.state||this.isDestroyed)return;if(this.options.editorProps)this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()});this.view.updateState(this.state)}setEditable(e,t=!0){if(this.setOptions({editable:e}),t)this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){if(this.editorView)return this.editorView;return new Proxy({state:this.editorState,updateState:(e)=>{this.editorState=e},dispatch:(e)=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t==="state")return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){if(gy&&!this.hasWarnedStaleDecorationRead&&hk(this))this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.");if(this.editorView)this.editorState=this.view.state;return this.editorState}registerPlugin(e,t){let n=Iu(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach((s)=>{let o=typeof s==="string"?`${s}$`:s.key;n=n.filter((i)=>!i.key.startsWith(o))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;let n=[...this.options.enableCoreExtensions?[Yk,Hk.configure({blockSeparator:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.clipboardTextSerializer)===null||e===void 0?void 0:e.blockSeparator}),$k,Wk,qk,Gk.configure({value:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.tabindex)===null||t===void 0?void 0:t.value}),zk,Xk,Vk,Jk.configure({direction:this.options.textDirection})].filter((r)=>{if(typeof this.options.enableCoreExtensions==="object")return this.options.enableCoreExtensions[r.name]!==!1;return!0}):[],...this.options.extensions].filter((r)=>["extension","node","mark"].includes(r===null||r===void 0?void 0:r.type));this.extensionManager=new Ha(n,this)}createCommandManager(){this.commandManager=new us({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=Ou(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message))throw t;let n=Ou(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=It.create({doc:n,schema:this.schema,selection:Nu(n,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:t,disableCollaboration:()=>{if("collaboration"in this.storage&&typeof this.storage.collaboration==="object"&&this.storage.collaboration)this.storage.collaboration.isDisabled=!0;this.options.extensions=this.options.extensions.filter((r)=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return e}getEditorViewAttributes(){var e;let t=(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes;if(Iu(t))return(n)=>({role:"textbox",...t(n)});return{role:"textbox",...t}}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r,o=t.transformPastedHTML,i=this.extensionManager.transformPastedHTML(o);this.editorView=new xa(e,{...t,attributes:this.getEditorViewAttributes(),dispatchTransaction:s,transformPastedHTML:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();let l=this.view.dom;l.editor=this}createNodeViews(){if(this.view.isDestroyed)return;this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach((c)=>{var u;return(u=this.capturedTransaction)===null||u===void 0?void 0:u.step(c)});return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),s=n.includes(e),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),!s)return;if(this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r)this.emit("selectionUpdate",{editor:this,transaction:e});let i=n.findLast((c)=>c.getMeta("focus")||c.getMeta("blur")),a=i===null||i===void 0?void 0:i.getMeta("focus"),l=i===null||i===void 0?void 0:i.getMeta("blur");if(a)this.emit("focus",{editor:this,event:a.event,transaction:i});if(l)this.emit("blur",{editor:this,event:l.event,transaction:i});if(e.getMeta("preventUpdate")||!n.some((c)=>c.docChanged)||o.doc.eq(t.doc))return;this.emit("update",{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return M0(this.state,e)}isActive(e,t){let n=typeof e==="string"?e:null,r=typeof e==="string"?t:e;return L0(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Lu(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=`
|
|
90
|
+
|
|
91
|
+
`,textSerializers:n={}}=e||{};return O0(this.state.doc,{blockSeparator:t,textSerializers:{...dy(this.schema),...n}})}get isEmpty(){return hs(this.state.doc)}destroy(){if(this.destroyed)return;this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={}}get isDestroyed(){var e,t;return(e=(t=this.editorView)===null||t===void 0?void 0:t.isDestroyed)!==null&&e!==void 0?e:!0}$node(e,t){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(e,t))||null}$nodes(e,t){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(e,t))||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new Zk(t,this,!1,n)}get $doc(){return this.$pos(0)}};var nn=class e extends Hu{constructor(...t){super(...t);this.type="node"}static create(t={}){let n=typeof t==="function"?t():t;return new e(n)}configure(t){return super.configure(t)}extend(t){let n=typeof t==="function"?t():t;return super.extend(n)}};var Cy=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else if(n!==void 0)n()}};var Dt=(e,t)=>e>>>t|e<<32-t,t_=(e)=>Dt(e,2)^Dt(e,13)^Dt(e,22),n_=(e)=>Dt(e,6)^Dt(e,11)^Dt(e,25),r_=(e)=>Dt(e,7)^Dt(e,18)^e>>>3,s_=(e)=>Dt(e,17)^Dt(e,19)^e>>>10,o_=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),i_=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class ky{constructor(){let e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(i_),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let u=16;u<64;u++)t[u]=s_(t[u-2])+t[u-7]+r_(t[u-15])+t[u-16];let n=e[0],r=e[1],s=e[2],o=e[3],i=e[4],a=e[5],l=e[6],c=e[7];for(let u=0,d,f;u<64;u++)d=c+n_(i)+(i&a^~i&l)+o_[u]+t[u]>>>0,f=t_(n)+(n&r^n&s^r&s)>>>0,c=l,l=a,a=i,i=o+d>>>0,o=s,s=r,r=n,n=d+f>>>0;e[0]+=n,e[1]+=r,e[2]+=s,e[3]+=o,e[4]+=i,e[5]+=a,e[6]+=l,e[7]+=c}digest(e){let t=0;for(;t+56<=e.length;){let o=0;for(;o<16&&t+3<e.length;o++)this._W[o]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!==0){this._W.fill(0,o,16);while(t<e.length)this._W[o]|=e[t]<<(3-t%4)*8,t++;this._W[o]|=xe<<(3-t%4)*8}this._updateHash()}let n=t%64!==0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let o=3;o>=0&&t<e.length;o--)this._W[r]|=e[t++]<<o*8;if(!n)this._W[r-(t%4===0?0:1)]|=xe<<(3-t%4)*8;this._W[14]=e.byteLength/Ad,this._W[15]=e.byteLength*8,this._updateHash();let s=new Uint8Array(32);for(let o=0;o<this._H.length;o++)for(let i=0;i<4;i++)s[o*4+i]=this._H[o]>>>(3-i)*8;return s}}var _y=(e)=>new ky().digest(e);var l_=/[\uD800-\uDBFF]/,c_=/[\uDC00-\uDFFF]/,u_=(e,t)=>{let n=0,r=0;while(n<e.length&&n<t.length&&e[n]===t[n])n++;if(n>0&&l_.test(e[n-1]))n--;while(r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1])r++;if(r>0&&c_.test(e[e.length-r]))r--;return{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}},Ny=u_;function wn(e){if(!e)return null;if(!(e.content instanceof Me))return null;let t=e.content.type;if(!(t instanceof ze||t instanceof ot||t instanceof Yt))throw Error("Expected a Yjs XML type");return t}function vo(e){if(e===null)return null;if(!(e.parent instanceof ge))throw Error("Expected an integrated Yjs parent");let t=e.parent;if(!(t instanceof ze||t instanceof ot||t instanceof Yt))throw Error("Expected a Yjs XML type");return t}var d_=(e,t)=>{let n=null,r=null;if(e._item===null)r=Vn(e);else n=W(e._item.id.client,e._item.id.clock);return new zn(n,r,t.id)},ms=(e,t,n)=>{if(e===0)return Vi(t,0,-1);let r=wn(t._first);while(r!==null&&t!==r){if(r instanceof Oe){if(r._length>=e)return Vi(r,e,-1);else e-=r._length;if(r._item!==null&&r._item.next!==null)r=wn(r._item.next);else{do r=vo(r._item),e--;while(r!==t&&r!==null&&r._item!==null&&r._item.next===null);if(r!==null&&r!==t)r=r._item===null?null:wn(r._item.next)}}else{let i=n.get(r),a=i instanceof Ye?i.nodeSize:0;if(r._first!==null&&e<a)r=wn(r._first),e--;else{if(e===1&&r._length===0&&a>1)return new zn(r._item===null?null:r._item.id,r._item===null?Vn(r):null,null);if(e-=a,r._item!==null&&r._item.next!==null)r=wn(r._item.next);else{var s;if(e===0){if(r=r._item===null?r:vo(r._item),r===null)throw ce();return new zn(r._item===null?null:r._item.id,r._item===null?Vn(r):null,null)}do{if(r=vo(r._item),r===null)throw ce();e--}while(r!==t&&((s=r._item)===null||s===void 0?void 0:s.next)===null);if(r!==t){var o;r=wn((o=r._item)===null||o===void 0?void 0:o.next)}}}}if(r===null)throw ce();if(e===0&&r.constructor!==Oe&&r!==t){let i=r._item,a=vo(i);if(i===null||a===null)throw ce();return d_(a,i)}}return Vi(t,t._length,-1)},f_=(e,t)=>{if(!e.docChanged)return!1;if(e.doc.childCount!==t.childCount)return!0;for(let n of e.steps)if(n instanceof se){if(n.from===0&&n.to===t.content.size)return!0;if(n.slice.content.size>0){let r=!1;if(n.slice.content.forEach((s)=>{if(s.isBlock)r=!0}),r)return!0}else if(n.to>n.from){let r=t.resolve(n.from),s=t.resolve(n.to);if(r.depth===0&&s.depth===0&&r.index()!==s.index())return!0}}return!1};function Py(e,t){if(e instanceof Oe)return e._length;let n=t.get(e);return n instanceof Ye?n.nodeSize:null}function h_(e,t,n){let r=0,s=e._first;while(s!==null){let o=wn(s);if(o===t)break;let i=s.deleted;if(s=s.right,i)continue;if(o===null)return null;let a=Py(o,n);if(a===null)return null;r+=a}return r}function p_(e,t,n){let r=0,s=0,o=e._first;while(s<e._length&&s<t&&o!==null){let i=o;if(o=o.right,i.deleted)continue;let a=wn(i);if(a===null)return null;let l=Py(a,n);if(l===null)return null;s++,r+=l}return r}var m_=(e,t,n)=>{var r;if(n===null)return!1;let s=ic(t,e);return s!==null&&s.type instanceof Oe&&t.item!==null&&((r=s.type._item)===null||r===void 0?void 0:r.deleted)===!0},rn=(e,t,n,r)=>{var s;let o=ic(n,e);if(o===null||o.type!==t&&!Hr(t,o.type._item))return null;let i=o.type,a=0;if(i.constructor===Oe)a=o.index;else if(!((s=i._item)===null||s===void 0?void 0:s.deleted)){let u=p_(i,o.index,r);if(u===null)return null;a=u+1}while(i!==t&&i._item!==null){var l;let u=vo(i._item);if(u===null)return null;if((l=u._item)===null||l===void 0?void 0:l.deleted){i=u;continue}let d=h_(u,i,r);if(d===null)return null;a+=d+1,i=u}let c=a-1;if(m_(e,n,c))return null;return c},le=new Q("y-sync"),Po=new Q("y-undo"),$a=new Q("yjs-cursor"),ps=null;function g_(){let e=ps;ps=null;let t=[];return e===null||e===void 0||e.forEach((n,r)=>{n.forEach((s,o)=>t.push({view:r,key:o,value:s}))}),t}function By(e=g_(),t=!1){let n=!0;while(e.length>0){let{view:r,key:s,value:o}=e[0];try{let i=le.getState(r.state);if(i&&i.binding.prosemirrorView!==null)r.dispatch(r.state.tr.setMeta(s,o))}catch(i){if(!(i instanceof RangeError))throw i;if(t&&n)e.shift();if(e.length>0)Lr(0,()=>By(e,!0));return}n=!1,e.shift()}}function y_(e,t,n){if(ps===null)ps=new Map,Lr(0,By);let r=ps.get(e);if(!r)r=new Map,ps.set(e,r);r.set(t,n)}var E_=(e,t,n)=>e!==t,T_=(e)=>{let t=document.createElement("span");t.classList.add("ProseMirror-yjs-cursor"),t.setAttribute("style",`border-color: ${e.color}`);let n=document.createElement("div");n.setAttribute("style",`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode(""),s=document.createTextNode("");return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(s,null),t},Wu=(e)=>({style:`background-color: ${e.color}70`,class:"ProseMirror-yjs-selection"}),Fy=(e)=>{let t=le.getState(e);return(t===null||t===void 0?void 0:t.binding)&&t.binding.invalidContentError===null?t:null},b_=/^#[0-9a-fA-F]{6}$/,S_=(e)=>typeof e.name==="string"&&typeof e.color==="string",Oy=(e,t,n,r,s)=>{let o=Fy(e);if(o==null||o.doc==null)return j.create(e.doc,[]);let i=o.doc,a=[];if(o.snapshot!=null||o.prevSnapshot!=null||o.binding.mapping.size===0)return j.create(e.doc,[]);return t.getStates().forEach((l,c)=>{if(!n(i.clientID,c,l))return;if(l&&l.cursor!=null){let u={...l.user};if(u.color==null)u.color="#ffa500";else if(!b_.test(u.color))console.warn("A user uses an unsupported color format",u);if(u.name==null)u.name=`User: ${c}`;if(!S_(u))return;let d=rn(i,o.type,Yn(l.cursor.anchor),o.binding.mapping),f=rn(i,o.type,Yn(l.cursor.head),o.binding.mapping);if(d!==null&&f!==null){let h=nt(e.doc.content.size-1,0);d=tt(d,h),f=tt(f,h),a.push(ae.widget(f,()=>r(u,c),{key:c+"",side:10}));let p=tt(d,f),m=nt(d,f);a.push(ae.inline(p,m,s(u,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),j.create(e.doc,a)},x_=(e,t)=>e!=null&&ac(Yn(e.anchor),Yn(t.anchor))&&ac(Yn(e.head),Yn(t.head)),Uy=(e,{awarenessStateFilter:t=E_,cursorBuilder:n=T_,selectionBuilder:r=Wu,getSelection:s=(i)=>i.selection}={},o="cursor")=>{if(o==="lastSelection")throw Error('yCursorPlugin: "lastSelection" is reserved and cannot be the cursor field');return new q({key:$a,state:{init(i,a){return Oy(a,e,t,n,r)},apply(i,a,l,c){let u=le.getState(c),d=i.getMeta($a),f=u&&u.isChangeOrigin;if(i.docChanged&&!f&&f_(i,l.doc))return j.empty;if(f||d&&d.awarenessUpdated)return Oy(c,e,t,n,r);if(i.docChanged)return a.map(i.mapping,i.doc);return a}},props:{decorations:(i)=>{var a;return(a=$a.getState(i))!==null&&a!==void 0?a:j.empty}},view:(i)=>{var a;let l=(a=le.getState(i.state))===null||a===void 0?void 0:a.type,c=l&&l._item===null?Vn(l):void 0,u=null,d=null,f=()=>{if(!i.isDestroyed)y_(i,$a,{awarenessUpdated:!0})},h=(E,x,w,b)=>{if(c===void 0||typeof e.setLocalState!=="function"){if(b!==E[o])e.setLocalStateField(o,b);return}d={...x,time:Date.now(),focused:w},e.setLocalState({...E,[o]:b,lastSelection:{...E.lastSelection,[c]:d}})},p=(E)=>{var x;if(u===null)return;let w=E[o],b=w===u;if(c!==void 0&&((x=E.lastSelection)===null||x===void 0?void 0:x[c])===d)h(E,u,!1,b?null:w);else if(b)e.setLocalStateField(o,null);u=null,d=null},m=(E)=>{let x=Fy(E.state);if(!x){let H=e.getLocalState();if(H!==null)p(H);return}let w=e.getLocalState();if(w===null)return;let b=w||{};if(!E.hasFocus()){p(b);return}let v=s(E.state),D=ms(v.anchor,x.type,x.binding.mapping),R=ms(v.head,x.type,x.binding.mapping),P=b[o];if(P===u&&x_(P,{anchor:D,head:R}))return;u={anchor:D,head:R},h(b,u,!0,u)},g=()=>m(i);return e.on("change",f),i.dom.addEventListener("focusin",g),i.dom.addEventListener("focusout",g),{update:m,destroy:()=>{if(i.dom.removeEventListener("focusin",g),i.dom.removeEventListener("focusout",g),e.off("change",f),u===null)return;let E=e.getLocalState();if(E!==null)p(E)}}}})};function Cn(e){let t=le.getState(e);if(!t)throw Error("The editor requires ySyncPlugin");return t}var za=(e,t)=>{var n;return t===void 0?!e.deleted:t.sv.has(e.id.client)&&((n=t.sv.get(e.id.client))!==null&&n!==void 0?n:0)>e.id.clock&&!$n(t.ds,e.id)},A_=(e,t,n)=>{if(!e.has(n)){if(e.size<t.length){let s=ct();e.forEach((o)=>s.add(o)),t=t.filter((o)=>!s.has(o))}e.set(n,Bd(t))}let r=e.get(n);if(!r)throw Error("At least one snapshot color is required");return r},Hy=(e,t)=>{if(e===t)return!0;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every((r)=>e[r]===t[r])},w_=(e)=>{let t=e.type.spec.attrs||{};return Object.keys(e.attrs).some((n)=>{let r=t[n];return r==null||!Object.prototype.hasOwnProperty.call(r,"default")||r.default!==e.attrs[n]})},Ku=(e,t,n)=>{let r=0,s=0;for(;s<e.childCount;s++){let h=e.child(s);if(r+h.nodeSize>n)break;r+=h.nodeSize}if(s>=e.childCount)return null;let o=e.child(s),i=e.resolve(n),a=(h,p)=>{if(i.depth===0){let m=h+(n-r),g=h+1,E=h+p.nodeSize-1;return Math.max(g,Math.min(m,E))}if(i.depth>1){let m=Ku(i.node(1),p,i.pos-i.start(1));return m===null?null:h+1+m}if(!p.isTextblock)return null;return h+1+Math.min(i.parentOffset,p.content.size)},l=(h,p=!1)=>{let m=0;for(let b=0;b<=s;b++)if(h(e.child(b)))m++;let g=0,E=-1,x=null,w=0;for(let b=0;b<t.childCount;b++){let v=t.child(b);if(h(v)){if(g++,g===m)E=w,x=v}w+=v.nodeSize}if(x===null||p&&(m!==1||g!==1))return null;return a(E,x)},c=(h)=>h.type===o.type&&Hy(h.attrs,o.attrs),u=o.textContent,d=l((h)=>c(h)&&h.textContent===u);if(d!==null)return d;let f=l((h)=>h.type===o.type&&h.textContent===u);if(f!==null)return f;if(!o.isTextblock||w_(o)){let h=l(c,!0);if(h!==null)return h}return l((h)=>c(h)&&u!==""&&h.textContent!==""&&(u.startsWith(h.textContent)||h.textContent.startsWith(u)),!0)},C_=(e,t,n,r)=>{if(r===null)return!1;let s=e.resolve(n),o=t.resolve(r);if(!s.parent.isTextblock)return!1;if(!o.parent.isTextblock)return!0;if(s.parent.textContent!==o.parent.textContent)return!0;if(s.parentOffset!==0&&o.parentOffset===0)return!0;let i=s.parentOffset===0&&o.parentOffset===0,a=s.parentOffset!==o.parentOffset||s.parent.type!==o.parent.type||!Hy(s.parent.attrs,o.parent.attrs);if(i||a){let l=Ku(e,t,n);return l!==null&&l!==r}return!1},Iy=(e,t,n,r)=>{if(n==null||n<0||n>t.content.size)return r;if(!(r===null||n>1&&r<=1||C_(t,e,n,r)))return r;let s=Ku(t,e,n);return s!==null?s:r},k_=(e,t,n,r)=>{if(t!==null&&t.anchor!==null&&t.head!==null)if(t.type==="all")e.setSelection(new we(e.doc));else if(t.type==="node"){let s=rn(n.doc,n.type,t.anchor,n.mapping);if(s!==null)e.setSelection(__(e,s))}else if(t.type==="nodeRange"){let s=rn(n.doc,n.type,t.anchor,n.mapping),o=rn(n.doc,n.type,t.head,n.mapping),i=N_(e,s,o,t.depth);if(i!==null)e.setSelection(i)}else{let s=rn(n.doc,n.type,t.anchor,n.mapping),o=rn(n.doc,n.type,t.head,n.mapping);if(r!=null)s=Iy(e.doc,r,t.absAnchor,s),o=Iy(e.doc,r,t.absHead,o);if(s===null)s=o;if(o===null)o=s;if(s!==null&&o!==null)e.setSelection(I.between(e.doc.resolve(s),e.doc.resolve(o)))}},__=(e,t)=>{let n=e.doc.resolve(t);if(n.nodeAfter)return M.create(e.doc,t);else return I.near(n)},N_=(e,t,n,r)=>{if(t===null||n===null)return null;let s=Math.min(Math.max(t,0),e.doc.content.size),o=Math.min(Math.max(n,0),e.doc.content.size);try{let i=U.fromJSON(e.doc,{type:"nodeRange",anchor:s,head:o,depth:r});if(!i.ranges.length)return I.near(e.doc.resolve(s));return i}catch{return I.near(e.doc.resolve(s))}},Vu=(e,t)=>{let n=t.selection,r=n.toJSON(),s=typeof r.type==="string"?r.type:"text";return{type:s,depth:s==="nodeRange"&&"depth"in n&&typeof n.depth==="number"?n.depth:void 0,anchor:ms(t.selection.anchor,e.type,e.mapping),head:ms(t.selection.head,e.type,e.mapping),absAnchor:t.selection.anchor,absHead:t.selection.head}},lr=new WeakMap,kn=(e,t)=>{var n;if(!(t instanceof ze||t instanceof ot||t instanceof Yt))return;e.delete(t),(n=lr.get(e))===null||n===void 0||n.delete(t)},O_=/(.*)(--[a-zA-Z0-9+/=]{8})$/,$y=(e)=>{var t,n;return(t=(n=O_.exec(e))===null||n===void 0?void 0:n[1])!==null&&t!==void 0?t:e},I_=(e,t)=>{let n=[];for(let r in e)n.push(t.mark($y(r),e[r]));return n},Vy=(e)=>{let{doc:t,_item:n}=e;if(!t||!n)throw ce();t.transact((r)=>{n.delete(r)},le)},zy=(e)=>e instanceof Error?e:Error(String(e)),M_=(e,t,n,r,s,o)=>{let i=e.toDelta(r,s,o);try{return i.map((a)=>t.text(a.insert,I_(a.attributes,t)))}catch(a){if(n.reportInvalidContent)n.reportInvalidContent(zy(a));else Vy(e);return null}},Yy=(e)=>{var t;let n=(t=e._item)===null||t===void 0||(t=t.right)===null||t===void 0?void 0:t.content,r=n instanceof Me?n.type:null;if(!(r instanceof ot))return;let{_item:s,doc:o}=r;if(!s||!o||s.deleted||s.id.client!==o.clientID)return;e.applyDelta([{retain:e.length},...r.toDelta()]),o.transact((i)=>{s.delete(i)})},R_=(e,t,n,r)=>{if(!e._item)return;if(!za(e._item,t))return r?r("removed",e._item.id):{type:"removed"};if(!za(e._item,n))return r?r("added",e._item.id):{type:"added"}},D_=(e,t,n)=>{e.mapping.set(t,n);let r=lr.get(e.mapping);if(r===void 0)r=new WeakMap,lr.set(e.mapping,r);r.set(t,n)},zu=(e,t,n,r,s,o)=>{var i;let a=n.mapping.get(e),l=Array.isArray(a)?void 0:a;if(l!==void 0&&((i=lr.get(n.mapping))===null||i===void 0?void 0:i.get(e))===l)return l;let c=[],u=!1,d=(f)=>{if(f instanceof ie){let p=zu(f,t,n,r,s,o);if(p===null||n.mapping.get(f)!==p)u=!0;if(p!==null)c.push(p);return}if(!(f instanceof Oe))return;if(n.deferTextMerge)n.deferTextMerge(f);else Yy(f);let h=M_(f,t,n,r,s,o);if(h===null)u=!0;h===null||h===void 0||h.forEach((p)=>c.push(p))};if(r===void 0||s===void 0)e.toArray().forEach(d);else uc(e,new Zs(s.ds,r.sv)).forEach(d);try{let f=e.getAttributes(r),h=r?R_(e,r,s,o):void 0;if(h!==void 0)f.ychange=h;let p=t.node(e.nodeName,f,c);if(l===null||l===void 0?void 0:l.eq(p))p=l;if(u&&n.reportInvalidContent)return kn(n.mapping,e),p;return D_(n,e,p),p}catch(f){if(kn(n.mapping,e),n.reportInvalidContent)return n.reportInvalidContent(zy(f)),null;return Vy(e),null}},v_=(e)=>{for(let n=6;n<e.length;n++)e[n%6]=e[n%6]^e[n];return e.slice(0,6)},L_=(e)=>Jd(v_(_y(Zd(e)))),jy=(e,t)=>{let n={};return e.forEach((r)=>{if(r.type.name!=="ychange"){let s=et(t.isOMark,r.type,()=>!r.type.excludes(r.type));n[s?`${r.type.name}--${L_(r.toJSON())}`:r.type.name]=r.attrs}}),n},P_=(e,t)=>{let n=new Oe,r=e.map((s)=>{var o;return{insert:(o=s.text)!==null&&o!==void 0?o:"",attributes:jy(s.marks,t)}});return n.applyDelta(r),t.mapping.set(n,e),n},Wa=(e)=>{let t=e.content.content,n=[];for(let r=0;r<t.length;r++){let s=t[r];if(s.isText){let o=[];for(let i=t[r];r<t.length&&i.isText;i=t[++r])o.push(i);r--,n.push(o)}else n.push(s)}return n},Ya=(e,t)=>e instanceof Array?P_(e,t):B_(e,t),B_=(e,t)=>{let n=new ie(e.type.name);for(let r in e.attrs){let s=e.attrs[r];if(s!==null&&r!=="ychange")n.setAttribute(r,s)}return n.insert(0,Wa(e).map((r)=>Ya(r,t))),t.mapping.set(n,e),n},My=(e)=>typeof e==="object"&&e!==null,qu=(e,t)=>{let n=Object.keys(e).filter((s)=>e[s]!==null),r=n.length===Object.keys(t).filter((s)=>t[s]!==null).length;for(let s=0;s<n.length&&r;s++){let o=n[s],i=e[o],a=t[o];r=o==="ychange"||i===a||My(i)&&My(a)&&qu(i,a)}return r},Xu=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((r,s)=>{var o;return r.insert===t[s].text&&Ml(r.attributes||{}).length===t[s].marks.length&&Object.entries((o=r.attributes)!==null&&o!==void 0?o:{}).every(([i,a])=>{let l=$y(i),c=t[s].marks.find((u)=>u.type.name===l);if(!c)return!1;return qu(a,c.attrs)})})},ja=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,gs=(e,t)=>{if(e instanceof ie&&!(t instanceof Array)&&ja(e,t)){let n=Wa(t);return e._length===n.length&&qu(e.getAttributes(),t.attrs)&&e.toArray().every((r,s)=>gs(r,n[s]))}return e instanceof Oe&&t instanceof Array&&Xu(e,t)},Lo=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((n,r)=>t[r]===n),F_=(e,t,n)=>{let r=new Map;t.forEach((l,c)=>{if(!r.has(l))r.set(l,c)});let s=[];if(e.forEach((l,c)=>{let u=n.mapping.get(l),d=u===void 0?void 0:r.get(u);if(d!==void 0&&Lo(u,t[d]))s.push({yIndex:c,pIndex:d,yChild:l})}),s.length===0)return[];let o=[],i=[];for(let l=0;l<s.length;l++){let c=0,u=i.length;while(c<u){let d=c+u>>1;if(s[i[d]].pIndex<s[l].pIndex)c=d+1;else u=d}o[l]=c>0?i[c-1]:-1,i[c]=l}let a=[];for(let l=i[i.length-1];l!==-1;l=o[l])a.push(s[l]);return a.reverse()},U_=(e)=>{let t="",n=e._start,r={};while(n!==null){if(!n.deleted){if(n.countable&&n.content instanceof pt)t+=n.content.str;else if(n.content instanceof ye)r[n.content.key]=null}n=n.right}return{str:t,nAttrs:r}},Wy=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:s}=U_(e),o=t.map((c)=>{var u;return{insert:(u=c.text)!==null&&u!==void 0?u:"",attributes:Object.assign({},r,jy(c.marks,n))}}),{insert:i,remove:a,index:l}=Ny(s,o.map((c)=>c.insert).join(""));e.delete(l,a),e.insert(l,i),e.applyDelta(o.map((c)=>({retain:c.insert.length,attributes:c.attributes})))},Ky=(e,t,n,r,s)=>{if(t instanceof Oe&&n instanceof Array){if(Xu(t,n))r.mapping.set(t,n);else Wy(t,n,r);return!0}if(t instanceof ie&&!(n instanceof Array)&&ja(t,n)){if(gs(t,n))r.mapping.set(t,n);else s(e,t,n,r);return!0}return!1},Ry=(e,t,n,r)=>{if(n>0)e.slice(t,t+n).forEach((s)=>kn(r.mapping,s)),e.delete(t,n)},Dy=(e,t,n,r,s,o)=>{if(r<s){let i=[];for(let a=r;a<s;a++)i.push(Ya(n[a],o));e.insert(t,i)}},vy=(e,t,n,r,s,o,i,a,l,c)=>{let u=tt(o-s,a-i);for(let d=0;d<u;d++){let f=r[s+d],h=n[i+d];if(!Ky(e,f,h,l,c))Ry(t,i+d,1,l),Dy(t,i+d,n,i+d,i+d+1,l)}Ry(t,i+u,o-s-u,l),Dy(t,i+u,n,i+u,a,l)},H_=(e,t,n,r,s,o)=>{let i=F_(r,n,s);if(i.length<2||!i.some((c)=>c.yIndex!==c.pIndex)||i.some((c)=>{let u=n[c.pIndex];return!(c.yChild instanceof Oe&&u instanceof Array||c.yChild instanceof ie&&!(u instanceof Array))}))return!1;let a=0,l=0;for(let c of i){vy(e,t,n,r,a,c.yIndex,l,c.pIndex,s,o);let u=n[c.pIndex];Ky(e,c.yChild,u,s,o),a=c.yIndex+1,l=c.pIndex+1}return vy(e,t,n,r,a,r.length,l,n.length,s,o),!0},Ly=(e,t,n)=>{let r=e.toArray(),s=Wa(t),o=s.length,i=r.length,a=tt(i,o),l=0,c=0,u=!1;for(;l<a;l++){let d=r[l],f=s[l];if(Lo(n.mapping.get(d),f))u=!0;else if(!gs(d,f))break}for(;l+c<a;c++){let d=r[i-c-1],f=s[o-c-1];if(Lo(n.mapping.get(d),f))u=!0;else if(!gs(d,f))break}return{equalityFactor:l+c,foundMappedChild:u}},Va=(e,t,n,r)=>{if(t instanceof ie&&t.nodeName!==n.type.name)throw Error("node name mismatch!");if(r.mapping.set(t,n),t instanceof ie){let f=t.getAttributes(),h=n.attrs;for(let p in h){if(h[p]===null){t.removeAttribute(p);continue}if(f[p]!==h[p]&&p!=="ychange")t.setAttribute(p,h[p])}for(let p in f)if(h[p]===void 0)t.removeAttribute(p)}let s=Wa(n),o=s.length,i=t.toArray(),a=i.length,l=tt(o,a),c=!1;if(e.transact(()=>{c=H_(e,t,s,i,r,Va)},le),c)return;let u=0,d=0;for(;u<l;u++){let f=i[u],h=s[u];if(Lo(r.mapping.get(f),h))continue;if(!gs(f,h))break;r.mapping.set(f,h)}for(;d+u+1<l;d++){let f=i[a-d-1],h=s[o-d-1];if(Lo(r.mapping.get(f),h))continue;if(!gs(f,h))break;r.mapping.set(f,h)}e.transact(()=>{while(a-u-d>0&&o-u-d>0){let p=i[u],m=s[u],g=i[a-d-1],E=s[o-d-1];if(p instanceof Oe&&m instanceof Array){if(!Xu(p,m))Wy(p,m,r);u+=1;continue}let x=p instanceof ie&&ja(p,m),w=g instanceof ie&&ja(g,E);if(x&&w&&p instanceof ie&&g instanceof ie&&!Array.isArray(m)&&!Array.isArray(E)){let b=Ly(p,m,r),v=Ly(g,E,r);if(b.foundMappedChild&&!v.foundMappedChild)w=!1;else if(!b.foundMappedChild&&v.foundMappedChild)x=!1;else if(b.equalityFactor<v.equalityFactor)x=!1;else w=!1}if(x&&p instanceof ie&&!Array.isArray(m)){Va(e,p,m,r),u+=1;continue}if(w&&g instanceof ie&&!Array.isArray(E)){Va(e,g,E,r),d+=1;continue}kn(r.mapping,t.get(u)),t.delete(u,1),t.insert(u,[Ya(m,r)]),u+=1}let f=a-u-d;if(a===1&&o===0&&i[0]instanceof Oe)kn(r.mapping,i[0]),i[0].delete(0,i[0].length);else if(f>0)t.slice(u,u+f).forEach((p)=>kn(r.mapping,p)),t.delete(u,f);if(u+d>=o)return;let h=[];for(let p=u;p<o-d;p++)h.push(Ya(s[p],r));t.insert(u,h)},le)},$_=(e,t)=>{var n;let r=e.doc.content,s=0,o=0;while(s<r.childCount&&s<t.childCount&&r.child(s)===t.child(s))o+=r.child(s).nodeSize,s++;let i=r.childCount,a=t.childCount,l=0;while(i>s&&a>s&&r.child(i-1)===t.child(a-1))l+=r.child(i-1).nodeSize,i--,a--;if(s===i&&s===a)return e;let c=new _(t.cut(o,t.size-l),0,0),u=Zn(e.doc,o,r.size-l,c);if(u!==null&&((n=u.apply(e.doc).doc)===null||n===void 0?void 0:n.content.eq(t)))return e.step(u);return e.replace(0,r.size,new _(t,0,0))},V_=class{constructor(e,t=new Map,n){if(this.prosemirrorView=null,this.mux=Cy(),this.isOMark=new Map,this.beforeTransactionSelection=null,this._domSelectionInView=null,this._invalidContentError=null,this.projectionError=null,this.hasSharedContent=!1,this.pendingTextMerges=[],this.type=e,this.mapping=t,this._observeFunction=this._typeChanged.bind(this),n)this.onInvalidContent=n,this.reportInvalidContent=(r)=>{var s;(s=this.projectionError)!==null&&s!==void 0||(this.projectionError=r)},this.deferTextMerge=(r)=>{this.pendingTextMerges.push(r)};if(e.doc===null)throw Error("The Yjs fragment must belong to a document");this.doc=e.doc,this.beforeAllTransactions=()=>{if(this._invalidContentError===null&&this.beforeTransactionSelection===null&&this.prosemirrorView!=null)this.beforeTransactionSelection=Vu(this,this.view.state)},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null}}get invalidContentError(){return this._invalidContentError}get view(){if(!this.prosemirrorView)throw Error("The binding has no editor view");return this.prosemirrorView}get _tr(){return this.view.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){if(!this.view.hasFocus())return!1;if(Bs&&this._domSelectionInView===null)Lr(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView();return this._domSelectionInView}_isDomSelectionInView(){let e=this.view.root,t="getSelection"in e&&typeof e.getSelection==="function"?e.getSelection():this.view.dom.ownerDocument.getSelection();if(t==null||t.anchorNode==null||t.focusNode==null)return!1;let n=this.view.dom.ownerDocument.createRange();if(n.setStart(t.anchorNode,t.anchorOffset),n.setEnd(t.focusNode,t.focusOffset),n.getClientRects().length===0){if(n.startContainer&&n.collapsed)n.selectNodeContents(n.startContainer)}let r=n.getBoundingClientRect(),s=Vt.documentElement;return r.bottom>=0&&r.right>=0&&r.left<=(window.innerWidth||s.clientWidth||0)&&r.top<=(window.innerHeight||s.clientHeight||0)}renderSnapshot(e,t){if(!t)t=zi($i(),new Map);this.view.dispatch(this._tr.setMeta(le,{snapshot:e,prevSnapshot:t}))}createDocumentContent(){this.projectionError=null,this.pendingTextMerges=[];let e=this.type.toArray().map((s)=>{if(!(s instanceof ie))throw Ve();return zu(s,this.view.state.schema,this)}).filter((s)=>s!==null),t=S.from(e),{topNodeType:n}=this.view.state.schema;this.hasSharedContent||(this.hasSharedContent=this.type.length>0);let r=t.childCount===0&&!this.hasSharedContent;if(this.reportInvalidContent&&!r&&!n.validContent(t))this.reportInvalidContent(RangeError("Shared content does not fit the document schema"));if(this.projectionError===null)this.pendingTextMerges.forEach(Yy);return t}updateInvalidContentError(){let e=this.projectionError,t=e!==null&&this._invalidContentError===null;return this._invalidContentError=e,t?e:null}notifyInvalidContent(e){var t;if(e)(t=this.onInvalidContent)===null||t===void 0||t.call(this,e)}createDocumentTransaction(){let e=this.createDocumentContent();return this._tr.replace(0,this.view.state.doc.content.size,new _(e,0,0))}unrenderSnapshot(){this.mapping.clear(),lr.delete(this.mapping);let e=null;this.mux(()=>{let t=this.createDocumentTransaction();e=this.updateInvalidContentError(),t.setMeta(le,{snapshot:null,prevSnapshot:null}),this.view.dispatch(t)}),this.notifyInvalidContent(e)}_forceRerender(){this.mapping.clear(),lr.delete(this.mapping);let e=null;this.mux(()=>{let t=this.beforeTransactionSelection!==null?null:this.view.state.selection,n=this.createDocumentTransaction();if(e=this.updateInvalidContentError(),t){let r=tt(nt(t.anchor,0),n.doc.content.size),s=tt(nt(t.head,0),n.doc.content.size);n.setSelection(I.create(n.doc,r,s))}this.view.dispatch(n.setMeta(le,{isChangeOrigin:!0,binding:this}))}),this.notifyInvalidContent(e)}_renderSnapshot(e,t,n){var r;let s=this.doc,o=this.type;if(!e)e=Yi(this.doc);if(e instanceof Uint8Array||t instanceof Uint8Array){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array))throw ce();if(s=new _t({gc:!1}),Qs(s,t),t=Yi(s),Qs(s,e),e=Yi(s),o._item===null){let c=Array.from(this.doc.share.keys()).find((u)=>Object.is(this.doc.share.get(u),o));o=s.getXmlFragment(c)}else{var i;let c=(i=s.store.clients.get(o._item.id.client))!==null&&i!==void 0?i:[],u=c[ht(c,o._item.id.clock)];if(!(u instanceof Z&&u.content instanceof Me&&u.content.type instanceof ze))throw ce();o=u.content.type}}let a=e,l=(r=t)!==null&&r!==void 0?r:eh;this.mapping.clear(),lr.delete(this.mapping),this.mux(()=>{s.transact((c)=>{let u=n.permanentUserData;if(u)u.dss.forEach((p)=>{zt(c,p,(m)=>{})});let d=(p,m)=>{let g=u?p==="added"?u.getUserByClientId(m.client):u.getUserByDeletedId(m):null;return{user:g,type:p,color:A_(n.colorMapping,n.colors,g)}},f=uc(o,new Zs(l.ds,a.sv)).map((p)=>{if(!(p instanceof ie)||!p._item)return null;if(!p._item.deleted||za(p._item,a)||za(p._item,l))return zu(p,this.view.state.schema,{mapping:new Map,isOMark:new Map,reportInvalidContent:this.reportInvalidContent?()=>{}:void 0,deferTextMerge:this.reportInvalidContent?()=>{}:void 0},a,l,d);else return null}).filter((p)=>p!==null),h=this._tr.replace(0,this.view.state.doc.content.size,new _(S.from(f),0,0));this.view.dispatch(h.setMeta(le,{isChangeOrigin:!0}))},le)})}_typeChanged(e,t){var n;if(this.prosemirrorView==null)return;let r=Cn(this.view.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}let s=t.origin instanceof eo,o=s?(n=t.origin.currStackItem)===null||n===void 0?void 0:n.meta.get(this):void 0,i=o||this.beforeTransactionSelection,a=o?void 0:this.view.state.doc,l=null;this.mux(()=>{let c=(d,f)=>kn(this.mapping,f);zt(t,t.deleteSet,(d)=>{if(d instanceof Z&&d.content instanceof Me)kn(this.mapping,d.content.type)}),t.changed.forEach(c),t.changedParentTypes.forEach(c);let u=$_(this._tr,this.createDocumentContent());if(l=this.updateInvalidContentError(),this._invalidContentError===null)k_(u,i,this,a);if(u=u.setMeta(le,{isChangeOrigin:!0,isUndoRedoOperation:s}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView())u.scrollIntoView();this.view.dispatch(u)}),this.notifyInvalidContent(l)}_prosemirrorChanged(e){if(this._invalidContentError!==null)return;let t=Cn(this.view.state);if(t.snapshot!=null||t.prevSnapshot!=null)return;this.doc.transact(()=>{Va(this.doc,this.type,e,this),this.hasSharedContent||(this.hasSharedContent=this.type.length>0),this.beforeTransactionSelection=Vu(this,this.view.state)},le)}initView(e){if(this.prosemirrorView!=null)this.destroy();this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){if(this.prosemirrorView==null)return;this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions)}},z_="__tiptap_position_migrations:",Yu=(e,t)=>{let n=[];if(e.share.forEach((r,s)=>{if(!s.startsWith(z_)||t&&!t.changed.has(r))return;let o=e.getMap(s);if(o.size>0)n.push(o)}),n.length===0)return;e.transact((r)=>{r.meta.set("addToHistory",!1),n.forEach((s)=>s.clear())},Yu)},Y_=[{light:"#ecd44433",dark:"#ecd444"}],qy=(e,{colors:t=Y_,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:s=()=>{},mapping:o,onInvalidContent:i}={})=>{let a=!1,l=new V_(e,o,i);return new q({filterTransaction:(c)=>l.invalidContentError===null||!c.docChanged||c.getMeta(le)!==void 0,props:{editable:(c)=>{let u=Cn(c);return l.invalidContentError===null&&u.snapshot==null&&u.prevSnapshot==null}},key:le,state:{init:(c,u)=>({type:e,doc:l.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(c,u)=>{let d=c.getMeta(le);if(d!==void 0)u=Object.assign({},u,d);if(c.docChanged)u.addToHistory=c.getMeta("addToHistory")!==!1;if(u.isChangeOrigin=d!==void 0&&!!d.isChangeOrigin,u.isUndoRedoOperation=d!==void 0&&!!d.isChangeOrigin&&!!d.isUndoRedoOperation,l.prosemirrorView===null||d===void 0||d.snapshot==null&&d.prevSnapshot==null)return u;return Lr(0,()=>{if(l.prosemirrorView==null)return;if(d.restore==null){l._renderSnapshot(d.snapshot,d.prevSnapshot,u);return}if(l.invalidContentError!==null){l.unrenderSnapshot();return}l._renderSnapshot(d.snapshot,d.snapshot,u),l.mux(()=>{let f=l.prosemirrorView;if(!f)return;f.dispatch(l._tr.setMeta(le,{restore:!1,snapshot:null,prevSnapshot:null,isChangeOrigin:!0})),l._prosemirrorChanged(f.state.doc)})}),u}},view:(c)=>{let u=(d)=>Yu(l.doc,d);if(Yu(l.doc),l.doc.on("afterTransaction",u),l.initView(c),o==null)l._forceRerender();return s(),{update:()=>{let d=Cn(c.state);if(d.snapshot==null&&d.prevSnapshot==null){let f=c.state.doc.type.createAndFill();if(!f)throw Error("The schema cannot create an empty document");if(a||c.state.doc.content.findDiffStart(f.content)!==null){if(a=!0,d.addToHistory===!1&&!d.isChangeOrigin){let h=Po.getState(c.state),p=h&&h.undoManager;if(p)p.stopCapturing()}l.mux(()=>{d.doc.transact((h)=>{h.meta.set("addToHistory",d.addToHistory),l._prosemirrorChanged(c.state.doc)},le)})}}},destroy:()=>{l.doc.off("afterTransaction",u),l.destroy()}}}})};function ju(e){let t=Po.getState(e);if(!t)throw Error("The editor requires yUndoPlugin");return t}var Xy=(e,t)=>{let n=Cn(e);if(n.binding.invalidContentError!==null||n.snapshot!=null||n.prevSnapshot!=null)return!1;let r=ju(e).undoManager;if(r!=null)return r[t](),!0},Gy=(e)=>Xy(e,"undo"),Jy=(e)=>Xy(e,"redo"),j_=new Set(["paragraph"]),W_=(e,t)=>!(e instanceof Z)||!(e.content instanceof Me)||!(e.content.type instanceof ot||e.content.type instanceof ie&&t.has(e.content.type.nodeName))||e.content.type._length===0,Qy=({protectedNodes:e=j_,trackedOrigins:t=[],undoManager:n=null}={})=>new q({key:Po,state:{init:(r,s)=>{let o=Cn(s),i=new Set,a=n;if(!a){var l;let c=new Set(o.doc._observers.get("destroy"));a=new eo(o.type,{trackedOrigins:new Set([le,...t]),deleteFilter:(u)=>W_(u,e),captureTransaction:(u)=>u.meta.get("addToHistory")!==!1}),((l=o.doc._observers.get("destroy"))!==null&&l!==void 0?l:new Set).forEach((u)=>{if(!c.has(u))i.add(u)})}return{undoManager:a,prevSel:null,hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0,destroyListeners:i}},apply:(r,s,o,i)=>{let a=Cn(i).binding,l=a&&a.invalidContentError===null;return{...s,prevSel:l?Vu(a,o):s.prevSel,hasUndoOps:s.undoManager.undoStack.length>0,hasRedoOps:s.undoManager.redoStack.length>0}}},view:(r)=>{let s=Cn(r.state),{undoManager:o,destroyListeners:i}=ju(r.state);return o.on("stack-item-added",({stackItem:a})=>{let l=s.binding;if(l){let c=o.undoing||o.redoing?l.beforeTransactionSelection:ju(r.state).prevSel;a.meta.set(l,c)}}),{destroy:()=>{o.destroy(),i.forEach((a)=>o.doc.off("destroy",a)),i.clear()}}}});function Zy(e){return!!e.getMeta(le)}function K_(e,t){if(t===null)return 0;let n=tE(e);return rn(n.doc,n.type,t,n.binding.mapping)||0}function eE(e,t){let n=tE(e);return ms(t,n.type,n.binding.mapping)}function tE(e){let t=le.getState(e);if(!t)throw Error("Collaboration requires the Yjs sync plugin");return t}var qa=class e extends Ua{constructor(t,n){super(t);this.yRelativePosition=n}static fromJSON(t){return new e(t.position,t.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function q_(e,t){return new qa(e,eE(t,e))}function X_(e,t,n){let r=e instanceof qa?e.yRelativePosition:null;if(Zy(t)&&r)return{position:new qa(K_(n,r),r),mapResult:null};let s=Bu(e,t),o=s.position.position;return{position:new qa(o,r!==null&&r!==void 0?r:eE(n,o)),mapResult:s.mapResult}}function Ka(e){let t=Po.getState(e);if(!t)throw Error("Collaboration requires the Yjs undo plugin");return t.undoManager}var nE=ne.create({name:"collaboration",priority:1000,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){if(this.editor.extensionManager.extensions.find((e)=>e.name==="undoRedo"))console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(e,t)=>X_(e,t,this.editor.state),this.editor.utils.createMappablePosition=(e)=>q_(e,this.editor.state)},addCommands(){return{undo:()=>({tr:e,state:t,dispatch:n})=>{var r;if(e.setMeta("preventDispatch",!0),Ka(t).undoStack.length===0)return!1;if(!n)return!0;return(r=Gy(t))!==null&&r!==void 0?r:!1},redo:()=>({tr:e,state:t,dispatch:n})=>{var r;if(e.setMeta("preventDispatch",!0),Ka(t).redoStack.length===0)return!1;if(!n)return!0;return(r=Jy(t))!==null&&r!==void 0?r:!1}}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){let e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),t=Qy(this.options.yUndoOptions),n=t.spec.view;t.spec.view=(s)=>{let o=Ka(s.state);if(o.restore)o.restore(),o.restore=()=>{};let i=n?n(s):void 0;return{destroy:()=>{let a=o.trackedOrigins.has(o),l=o._observers;if(o.restore=()=>{if(a)o.trackedOrigins.add(o);o.doc.on("afterTransaction",o.afterTransactionHandler),o._observers=l},i===null||i===void 0?void 0:i.destroy)i.destroy()}}};let r={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender};if(this.editor.options.enableContentCheck)r.onInvalidContent=(s)=>{this.editor.emit("contentError",{error:s,editor:this.editor,disableCollaboration:()=>{var o;this.storage.isDisabled=!0,(o=e.doc)===null||o===void 0||o.destroy()}})};return[qy(e,r),t,new q({filterTransaction:(s,o)=>{if(s.getMeta("inputRule"))Ka(o).stopCapturing();return!0}}),this.editor.options.enableContentCheck&&new q({key:new Q("filterInvalidContent"),filterTransaction:(s)=>{if(!Zy(s))return!0;if(this.storage.isDisabled)return!1;if(!s.docChanged)return!0;try{return s.doc.check(),!0}catch(o){return this.storage.isDisabled=!0,this.editor.emit("contentError",{error:o,editor:this.editor,disableCollaboration:()=>{var i;(i=e.doc)===null||i===void 0||i.destroy()}}),!0}}})].filter((s)=>s!==!1)}});var rE=(e)=>Array.from(e.entries()).map(([t,n])=>{if(n&&n.user)return{clientId:t,...n.user};return{clientId:t}}),sE=()=>null,oE=(e)=>xy(e)&&/^#[0-9a-fA-F]{6}$/.test(e),Gu=(e)=>({...e,color:oE(e.color)?e.color:"transparent"}),iE=ne.create({name:"collaborationCaret",priority:999,addOptions(){return{provider:null,user:{name:null,color:null},render:(e)=>{let t=document.createElement("span"),{color:n}=Gu(e);t.classList.add("collaboration-carets__caret"),t.style.borderColor=n;let r=document.createElement("div");return r.classList.add("collaboration-carets__label"),r.style.backgroundColor=n,r.insertBefore(document.createTextNode(e.name),null),t.insertBefore(r,null),t},selectionRender:(e)=>{if(!oE(e.color))return{};return Wu({name:e.name,color:e.color})},onUpdate:sE}},onCreate(){if(this.options.onUpdate!==sE)console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret');if(!this.options.provider)throw Error('The "provider" option is required for the CollaborationCaret extension')},addStorage(){return{users:[]}},addCommands(){return{updateUser:(e)=>()=>(this.options.provider.awareness.setLocalStateField("user",e),!0),user:(e)=>({editor:t})=>(console.warn('[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret'),t.commands.updateUser(e))}},addProseMirrorPlugins(){let{provider:e}=this.options,t=this.storage,n=this.options.user;return[new q({key:new Q("collaborationCaretAwarenessListener"),view:()=>{let r=()=>{t.users=rE(e.awareness.states)};return e.awareness.setLocalStateField("user",n),t.users=rE(e.awareness.states),e.awareness.on("update",r),{destroy:()=>{e.awareness.off("update",r),t.users=[]}}}}),Uy(e.awareness,{cursorBuilder:(r)=>this.options.render(Gu(r)),selectionBuilder:(r)=>this.options.selectionRender(Gu(r))})]}});function aE(e={}){return new q({view(t){return new lE(t,e)}})}class lE{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(n=t.width)!==null&&n!==void 0?n:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map((r)=>{let s=(o)=>{this[r](o)};return e.dom.addEventListener(r,s),{name:r,handler:s}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let n=this.computeTarget(this.lastDragEvent);if(n==this.cursorPos)this.updateOverlay();else this.setCursor(n)}else this.updateOverlay()}setCursor(e){if(e==this.cursorPos)return;if(this.cursorPos=e,e==null)this.element.parentNode.removeChild(this.element),this.element=null;else this.updateOverlay()}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,s=r.getBoundingClientRect(),o=s.width/r.offsetWidth,i=s.height/r.offsetHeight;if(t){let{nodeBefore:u,nodeAfter:d}=e;if(u||d){let f=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(f){let h=f.getBoundingClientRect(),p=u?h.bottom:h.top;if(u&&d)p=(p+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2;let m=this.width/2*i;n={left:h.left,right:h.right,top:p-m,bottom:p+m}}}}if(!n){let u=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*o;n={left:u.left-d,right:u.left+d,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;if(!this.element){if(this.element=a.appendChild(document.createElement("div")),this.class)this.element.className=this.class;if(this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color)this.element.style.backgroundColor=this.color}this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let l,c;if(!a||a==document.body&&getComputedStyle(a).position=="static")l=-pageXOffset,c=-pageYOffset;else{let u=a.getBoundingClientRect(),d=u.width/a.offsetWidth,f=u.height/a.offsetHeight;l=u.left-a.scrollLeft*d,c=u.top-a.scrollTop*f}this.element.style.left=(n.left-l)/o+"px",this.element.style.top=(n.top-c)/i+"px",this.element.style.width=(n.right-n.left)/o+"px",this.element.style.height=(n.bottom-n.top)/i+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,s=typeof r=="function"?r(this.editorView,t,e):r;if(!t||s)return null;let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let i=ca(this.editorView.state.doc,o,this.editorView.dragging.slice);if(i!=null)o=i}return o}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);if(t!=null)this.setCursor(t),this.scheduleRemoval(5000)}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){if(!this.editorView.dom.contains(e.relatedTarget))this.setCursor(null)}}class he extends U{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return he.valid(n)?new he(n):U.near(n)}content(){return _.empty}eq(e){return e instanceof he&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw RangeError("Invalid input for GapCursor.fromJSON");return new he(e.resolve(t.pos))}getBookmark(){return new Ju(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!G_(e)||!J_(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&he.valid(e))return e;let r=e.pos,s=null;for(let o=e.depth;;o--){let i=e.node(o);if(t>0?e.indexAfter(o)<i.childCount:e.index(o)>0){s=i.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;r+=t;let a=e.doc.resolve(r);if(he.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!M.isSelectable(s)){e=e.doc.resolve(r+s.nodeSize*t),n=!1;continue e}break}s=o,r+=t;let i=e.doc.resolve(r);if(he.valid(i))return i}return null}}}he.prototype.visible=!1;he.findFrom=he.findGapCursorFrom;U.jsonID("gapcursor",he);class Ju{constructor(e){this.pos=e}map(e){return new Ju(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return he.valid(t)?new he(t):U.near(t)}}function cE(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function G_(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||cE(s.type))return!0;if(s.inlineContent)return!1}}return!0}function J_(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||cE(s.type))return!0;if(s.inlineContent)return!1}}return!0}function uE(){return new q({props:{decorations:tN,createSelectionBetween(e,t,n){return t.pos==n.pos&&he.valid(n)?new he(n):null},handleClick:Z_,handleKeyDown:Q_,handleDOMEvents:{beforeinput:eN}}})}var Q_=xu({ArrowLeft:Xa("horiz",-1),ArrowRight:Xa("horiz",1),ArrowUp:Xa("vert",-1),ArrowDown:Xa("vert",1)});function Xa(e,t){let n=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(r,s,o){let i=r.selection,a=t>0?i.$to:i.$from,l=i.empty;if(i instanceof I){if(!o.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(t>0?a.after():a.before())}let c=he.findGapCursorFrom(a,t,l);if(!c)return!1;if(s)s(r.tr.setSelection(new he(c)));return!0}}function Z_(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!he.valid(r))return!1;let s=e.posAtCoords({left:n.clientX,top:n.clientY});if(s&&s.inside>-1&&M.isSelectable(e.state.doc.nodeAt(s.inside)))return!1;return e.dispatch(e.state.tr.setSelection(new he(r))),!0}function eN(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof he))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let s=S.empty;for(let i=r.length-1;i>=0;i--)s=S.from(r[i].createAndFill(null,s));let o=e.state.tr.replace(n.pos,n.pos,new _(s,0,0));return o.setSelection(I.near(o.doc.resolve(n.pos+1))),e.dispatch(o),!1}function tN(e){if(!(e.selection instanceof he))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",j.create(e.doc,[ae.widget(e.selection.head,t,{key:"gapcursor"})])}var vL=ne.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:(e)=>e.length,wordCounter:(e)=>e.split(" ").filter((t)=>t!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=(e)=>{let t=(e===null||e===void 0?void 0:e.node)||this.editor.state.doc;if(((e===null||e===void 0?void 0:e.mode)||this.options.mode)==="textSize"){let n=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(n)}return t.nodeSize},this.storage.words=(e)=>{let t=(e===null||e===void 0?void 0:e.node)||this.editor.state.doc,n=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new q({key:new Q("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;let s=this.options.limit,o=this.options.autoTrim;if(s===null||s===void 0||s===0||o===!1){e=!0;return}let i=this.storage.characters({node:r.doc});if(i>s){let a=i-s,l=0,c=a;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);let u=r.tr.deleteRange(0,c);return e=!0,u}e=!0},filterTransaction:(t,n)=>{let r=this.options.limit;if(!t.docChanged||r===0||r===null||r===void 0)return!0;let s=this.storage.characters({node:n.doc}),o=this.storage.characters({node:t.doc});if(o<=r)return!0;if(s>r&&o>r&&o<=s)return!0;if(s>r&&o>r&&o>s)return!1;if(!t.getMeta("paste"))return!1;let i=t.selection.$head.pos,a=i-(o-r),l=i;if(t.deleteRange(a,l),this.storage.characters({node:t.doc})>r)return!1;return!0}})]}}),LL=ne.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[aE(this.options)]}}),PL=ne.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new q({key:new Q("focus"),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:s}=t,o=[];if(!n||!r)return j.create(e,[]);let i=0;if(this.options.mode==="deepest")e.descendants((l,c)=>{if(l.isText)return;if(!(s>=c&&s<=c+l.nodeSize-1))return!1;i+=1});let a=0;return e.descendants((l,c)=>{if(l.isText)return!1;if(!(s>=c&&s<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&i-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";o.push(ae.node(c,c+l.nodeSize,{class:this.options.className}))}),j.create(e,o)}}})]}}),BL=ne.create({name:"gapCursor",addProseMirrorPlugins(){return[uE()]},extendNodeSchema(e){var t;let n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=oe(B(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),hE="placeholder",dE=new Q("tiptap__placeholder");function pE(e){let{editor:t,placeholder:n,dataAttribute:r,pos:s,node:o,isEmptyDoc:i,hasAnchor:a,classes:{emptyNode:l,emptyEditor:c}}=e,u=[l];if(i)u.push(c);return ae.node(s,s+o.nodeSize,{class:u.join(" "),[r]:typeof n==="function"?n({editor:t,node:o,pos:s,hasAnchor:a}):n})}function mE(e,t){return typeof e==="function"?e(t):e}function gE({editor:e,options:t,dataAttribute:n,doc:r,selection:s,from:o,to:i}){let{anchor:a}=s,l=[],c=e.isEmpty;return r.nodesBetween(o,i,(u,d)=>{let f=a>=d&&a<=d+u.nodeSize,h=!u.isLeaf&&hs(u);if(!u.type.isTextblock)return t.includeChildren;if((f||!t.showOnlyCurrent)&&h)l.push(pE({editor:e,isEmptyDoc:c,dataAttribute:n,hasAnchor:f,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:mE(t.emptyNodeClass,{editor:e,node:u,pos:d,hasAnchor:f})},node:u,pos:d}));return t.includeChildren}),l}function yE({editor:e,options:t,dataAttribute:n,doc:r,selection:s}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:o}=s,i=[],a=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let l=r.resolve(o),c=l.depth>0?l.node(1):l.nodeAfter,u=l.depth>0?l.before(1):o;if(c&&c.type.isTextblock&&hs(c)){let d=o>=u&&o<=u+c.nodeSize;i.push(pE({editor:e,isEmptyDoc:a,dataAttribute:n,hasAnchor:d,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:mE(t.emptyNodeClass,{editor:e,node:c,pos:u,hasAnchor:d})},node:c,pos:u}))}}else i.push(...gE({editor:e,options:t,dataAttribute:n,doc:r,selection:s,from:0,to:r.content.size}));return j.create(r,i)}function Bo(e,t){let n=e.resolve(t);if(n.depth===0){var r;let o=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!o)return{from:t,to:t};let i=n.nodeAfter?t:t-o.nodeSize;return{from:i,to:i+o.nodeSize}}let s=n.before(1);return{from:s,to:s+n.node(1).nodeSize}}function Fo(e,t){return{from:Math.max(0,t.from),to:Math.min(e.content.size,t.to)}}function nN(e,t,n){let r=[];return e.forEach((s,o)=>{let i=o,a=i+s.nodeSize,l=i+1,c=a+1;if(l<n&&c>t)r.push({from:i,to:a})}),r}function rN(e){if(e.length===0)return[];let t=[...e].sort((r,s)=>r.from-s.from),n=[{...t[0]}];for(let r=1;r<t.length;r+=1){let s=n[n.length-1],o=t[r];if(o.from<=s.to)s.to=Math.max(s.to,o.to);else n.push({...o})}return n}function sN(e,t){let n=nN(e,t.from,t.to);if(n.push(Fo(e,Bo(e,t.from))),t.to>t.from)n.push(Fo(e,Bo(e,Math.min(t.to,e.content.size+1)-1)));else if(t.from<e.content.size+1)n.push(Fo(e,Bo(e,Math.min(t.from+1,e.content.size))));return n}function oN(e,t,n){let r=[];if(e.docChanged){let s=Fa(e);for(let o of s)r.push(...sN(n.doc,o.newRange))}if(e.selectionSet)r.push(Fo(n.doc,Bo(n.doc,e.mapping.map(t.selection.anchor)))),r.push(Fo(n.doc,Bo(n.doc,n.selection.anchor)));return rN(r)}function iN(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function aN({decorations:e,ranges:t,editor:n,options:r,dataAttribute:s,doc:o,selection:i}){let a=e;for(let l of t){let{from:c,to:u}=iN(l.from,l.to,o),d=a.find(c,u).filter((h)=>h.from>=c&&h.to<=u);if(d.length)a=a.remove(d);let f=gE({editor:n,options:r,dataAttribute:s,doc:o,selection:i,from:c,to:u});if(f.length)a=a.add(o,f)}return a}function lN({editor:e,options:t,dataAttribute:n}){return{init(r,s){let o=yE({editor:e,options:t,dataAttribute:n,doc:s.doc,selection:s.selection});return o!==null&&o!==void 0?o:j.empty},apply(r,s,o,i){if(!r.docChanged&&!r.selectionSet)return s;return aN({decorations:s.map(r.mapping,r.doc),ranges:oN(r,o,i),editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})}}}function cN(e){return e.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function uN({editor:e,options:t}){let n=t.dataAttribute?`data-${cN(t.dataAttribute)}`:`data-${hE}`,r=t.showOnlyCurrent&&!t.includeChildren;return new q({key:dE,...r?{}:{state:lN({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:s,selection:o})=>yE({editor:e,options:t,dataAttribute:n,doc:s,selection:o}):(s)=>{var o;if(t.showOnlyWhenEditable&&!e.isEditable)return j.empty;return(o=dE.getState(s))!==null&&o!==void 0?o:j.empty}}})}var EE=ne.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:hE,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[uN({editor:this.editor,options:this.options})]}});function Qu(e,t){return!e.selection.empty&&!fy(e.selection)&&t.isEditable}function dN(e,t){return Qu(e,t)&&!t.isFocused&&!t.view.dragging}function fN(){var e;(e=window.getSelection())===null||e===void 0||e.removeAllRanges()}function hN(e){e.focus()}var FL=ne.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new q({key:new Q("selection"),props:{decorations(n){if(!dN(n,e))return null;return j.create(n.doc,[ae.inline(n.selection.from,n.selection.to,{class:t.className})])},handleDOMEvents:{blur(n){if(!Qu(n.state,e))return!1;return fN(),!1},focus(n){if(!Qu(n.state,e))return!1;return requestAnimationFrame(()=>{if(!e.isDestroyed&&n.hasFocus())hN(n)}),!1}}}})]}});function fE({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||(t===null||t===void 0?void 0:t.type)===e}var UL=ne.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var e;let t=new Q(this.name),n=this.options.node||((e=this.editor.schema.topNodeType.contentMatch.defaultType)===null||e===void 0?void 0:e.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter((s)=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new q({key:t,appendTransaction:(s,o,i)=>{let{doc:a,tr:l,schema:c}=i,u=t.getState(i),d=a.content.size,f=c.nodes[n];if(s.some((h)=>h.getMeta("skipTrailingNode")))return;if(!u)return;return l.insert(d,f.create())},state:{init:(s,o)=>{let i=o.tr.doc.lastChild;return!fE({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged)return o;if(s.getMeta("__uniqueIDTransaction"))return o;let i=s.doc.lastChild;return!fE({node:i,types:r})}}})]}}),HL=ne.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>ku(e,t),redo:()=>({state:e,dispatch:t})=>_u(e,t)}},addProseMirrorPlugins(){return[Mg(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});var{min:Ho,max:_n,round:$o,floor:Vo}=Math,vt=(e)=>({x:e,y:e}),pN={left:"right",right:"left",bottom:"top",top:"bottom"};function Ja(e,t){return typeof e==="function"?e(t):e}function cr(e){return e.split("-")[0]}function zo(e){return e.split("-")[1]}function SE(e){return e==="x"?"y":"x"}function Zu(e){return e==="y"?"height":"width"}function Nn(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function ed(e){return SE(Nn(e))}function xE(e,t,n){if(n===void 0)n=!1;let r=zo(e),s=ed(e),o=Zu(s),i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";if(t.reference[o]>t.floating[o])i=Uo(i);return[i,Uo(i)]}function AE(e){let t=Uo(e);return[Ga(e),t,Ga(t)]}function Ga(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var TE=["left","right"],bE=["right","left"],mN=["top","bottom"],gN=["bottom","top"];function yN(e,t,n){switch(e){case"top":case"bottom":if(n)return t?bE:TE;return t?TE:bE;case"left":case"right":return t?mN:gN;default:return[]}}function wE(e,t,n,r){let s=zo(e),o=yN(cr(e),n==="start",r);if(s){if(o=o.map((i)=>i+"-"+s),t)o=o.concat(o.map(Ga))}return o}function Uo(e){let t=cr(e);return pN[t]+e.slice(t.length)}function EN(e){var t,n,r,s;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(s=e.left)!=null?s:0}}function CE(e){return typeof e!=="number"?EN(e):{top:e,right:e,bottom:e,left:e}}function ur(e){let{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function kE(e,t,n){let{reference:r,floating:s}=e,o=Nn(t),i=ed(t),a=Zu(i),l=cr(t),c=o==="y",u=r.x+r.width/2-s.width/2,d=r.y+r.height/2-s.height/2,f=r[a]/2-s[a]/2,h;switch(l){case"top":h={x:u,y:r.y-s.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-s.width,y:d};break;default:h={x:r.x,y:r.y}}let p=zo(t);if(p)h[i]+=f*(p==="end"?1:-1)*(n&&c?-1:1);return h}async function _E(e,t){var n;if(t===void 0)t={};let{x:r,y:s,platform:o,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=Ja(t,e),p=CE(h),g=a[f?d==="floating"?"reference":"floating":d],E=ur(await o.getClippingRect({element:((n=await(o.isElement==null?void 0:o.isElement(g)))!=null?n:!0)?g:g.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),x=d==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,w=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),b=await(o.isElement==null?void 0:o.isElement(w))&&await(o.getScale==null?void 0:o.getScale(w))||{x:1,y:1},v=ur(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:w,strategy:l}):x);return{top:(E.top-v.top+p.top)/b.y,bottom:(v.bottom-E.bottom+p.bottom)/b.y,left:(E.left-v.left+p.left)/b.x,right:(v.right-E.right+p.right)/b.x}}var TN=50,NE=async(e,t,n)=>{let{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,a=i.detectOverflow?i:{...i,detectOverflow:_E},l=await(i.isRTL==null?void 0:i.isRTL(t)),c=await i.getElementRects({reference:e,floating:t,strategy:s}),{x:u,y:d}=kE(c,r,l),f=r,h=0,p={};for(let m=0;m<o.length;m++){let g=o[m];if(!g)continue;let{name:E,fn:x}=g,{x:w,y:b,data:v,reset:D}=await x({x:u,y:d,initialPlacement:r,placement:f,strategy:s,middlewareData:p,rects:c,platform:a,elements:{reference:e,floating:t}});if(u=w!=null?w:u,d=b!=null?b:d,p[E]={...p[E],...v},D&&h<TN){if(h++,typeof D==="object"){if(D.placement)f=D.placement;if(D.rects)c=D.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:s}):D.rects;({x:u,y:d}=kE(c,f,l))}m=-1}}return{x:u,y:d,placement:f,strategy:s,middlewareData:p}};var OE=function(e){if(e===void 0)e={};return{name:"flip",options:e,async fn(t){var n,r;let{placement:s,middlewareData:o,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=Ja(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};let E=cr(s),x=Nn(a),w=cr(a)===a,b=await(l.isRTL==null?void 0:l.isRTL(c.floating)),v=f||(w||!m?[Uo(a)]:AE(a)),D=p!=="none";if(!f&&D)v.push(...wE(a,m,p,b));let R=[a,...v],P=await l.detectOverflow(t,g),H=[],F=((r=o.flip)==null?void 0:r.overflows)||[];if(u)H.push(P[E]);if(d){let A=xE(s,i,b);H.push(P[A[0]],P[A[1]])}if(F=[...F,{placement:s,overflows:H}],!H.every((A)=>A<=0)){var ke,qe;let A=(((ke=o.flip)==null?void 0:ke.index)||0)+1,N=R[A];if(N){if(!(d==="alignment"?x!==Nn(N):!1)||F.every((L)=>Nn(L.placement)===x?L.overflows[0]>0:!0))return{data:{index:A,overflows:F},reset:{placement:N}}}let O=(qe=F.filter((k)=>k.overflows[0]<=0).sort((k,L)=>k.overflows[1]-L.overflows[1])[0])==null?void 0:qe.placement;if(!O)switch(h){case"bestFit":{var lt;let k=(lt=F.filter((L)=>{if(D){let Y=Nn(L.placement);return Y===x||Y==="y"}return!0}).map((L)=>[L.placement,L.overflows.filter((Y)=>Y>0).reduce((Y,te)=>Y+te,0)]).sort((L,Y)=>L[1]-Y[1])[0])==null?void 0:lt[0];if(k)O=k;break}case"initialPlacement":O=a;break}if(s!==O)return{reset:{placement:O}}}return{}}}};var bN=new Set(["left","top"]);async function SN(e,t){let{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=cr(n),a=zo(n),l=Nn(n)==="y",c=bN.has(i)?-1:1,u=o&&l?-1:1,d=Ja(t,e),{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof d==="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};if(a&&typeof p==="number")h=a==="end"?p*-1:p;return l?{x:h*u,y:f*c}:{x:f*c,y:h*u}}var IE=function(e){if(e===void 0)e=0;return{name:"offset",options:e,async fn(t){var n,r;let{x:s,y:o,placement:i,middlewareData:a}=t,l=await SN(t,e);if(i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset)return{};return{x:s+l.x,y:o+l.y,data:{...l,placement:i}}}}};function Qa(){return typeof window<"u"}function fr(e){if(RE(e))return(e.nodeName||"").toLowerCase();return"#document"}function Ke(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Lt(e){var t;return(t=(RE(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function RE(e){if(!Qa())return!1;return e instanceof Node||e instanceof Ke(e).Node}function St(e){if(!Qa())return!1;return e instanceof Element||e instanceof Ke(e).Element}function sn(e){if(!Qa())return!1;return e instanceof HTMLElement||e instanceof Ke(e).HTMLElement}function ME(e){if(!Qa()||typeof ShadowRoot>"u")return!1;return e instanceof ShadowRoot||e instanceof Ke(e).ShadowRoot}function Yo(e){let{overflow:t,overflowX:n,overflowY:r,display:s}=xt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function DE(e){return/^(table|td|th)$/.test(fr(e))}function jo(e){try{if(e.matches(":popover-open"))return!0}catch(t){}try{return e.matches(":modal")}catch(t){return!1}}var xN=/transform|translate|scale|rotate|perspective|filter/,AN=/paint|layout|strict|content/,dr=(e)=>!!e&&e!=="none",td;function Za(e){let t=St(e)?xt(e):e;return dr(t.transform)||dr(t.translate)||dr(t.scale)||dr(t.rotate)||dr(t.perspective)||!el()&&(dr(t.backdropFilter)||dr(t.filter))||xN.test(t.willChange||"")||AN.test(t.contain||"")}function vE(e){let t=On(e);while(sn(t)&&!Es(t)){if(Za(t))return t;else if(jo(t))return null;t=On(t)}return null}function el(){if(td==null)td=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none");return td}function Es(e){return/^(html|body|#document)$/.test(fr(e))}function xt(e){return Ke(e).getComputedStyle(e)}function Wo(e){if(St(e))return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop};return{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function On(e){if(fr(e)==="html")return e;let t=e.assignedSlot||e.parentNode||ME(e)&&e.host||Lt(e);return ME(t)?t.host:t}function LE(e){let t=On(e);if(Es(t))return(e.ownerDocument||e).body;if(sn(t)&&Yo(t))return t;return LE(t)}function ys(e,t,n){var r;if(t===void 0)t=[];if(n===void 0)n=!0;let s=LE(e),o=s===((r=e.ownerDocument)==null?void 0:r.body),i=Ke(s);if(o){let a=tl(i);return t.concat(i,i.visualViewport||[],Yo(s)?s:[],a&&n?ys(a):[])}else return t.concat(s,ys(s,[],n))}function tl(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function FE(e){let t=xt(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,s=sn(e),o=s?e.offsetWidth:n,i=s?e.offsetHeight:r,a=$o(n)!==o||$o(r)!==i;if(a)n=o,r=i;return{width:n,height:r,$:a}}function rd(e){return!St(e)?e.contextElement:e}function Ts(e){let t=rd(e);if(!sn(t))return vt(1);let n=t.getBoundingClientRect(),{width:r,height:s,$:o}=FE(t),i=(o?$o(n.width):n.width)/r,a=(o?$o(n.height):n.height)/s;if(!i||!Number.isFinite(i))i=1;if(!a||!Number.isFinite(a))a=1;return{x:i,y:a}}var wN=vt(0);function UE(e){let t=Ke(e);if(!el()||!t.visualViewport)return wN;return{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function CN(e,t,n){if(t===void 0)t=!1;return!!n&&t&&n===Ke(e)}function hr(e,t,n,r){if(t===void 0)t=!1;if(n===void 0)n=!1;let s=e.getBoundingClientRect(),o=rd(e),i=vt(1);if(t)if(r){if(St(r))i=Ts(r)}else i=Ts(e);let a=CN(o,n,r)?UE(o):vt(0),l=(s.left+a.x)/i.x,c=(s.top+a.y)/i.y,u=s.width/i.x,d=s.height/i.y;if(o&&r){let f=Ke(o),h=St(r)?Ke(r):r,p=f,m=tl(p);while(m&&h!==p){let g=Ts(m),E=m.getBoundingClientRect(),x=xt(m),w=E.left+(m.clientLeft+parseFloat(x.paddingLeft))*g.x,b=E.top+(m.clientTop+parseFloat(x.paddingTop))*g.y;l*=g.x,c*=g.y,u*=g.x,d*=g.y,l+=w,c+=b,p=Ke(m),m=tl(p)}}return ur({width:u,height:d,x:l,y:c})}function nl(e,t){let n=Wo(e).scrollLeft;if(!t)return hr(Lt(e)).left+n;return t.left+n}function HE(e,t){let n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-nl(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function kN(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e,o=s==="fixed",i=Lt(r),a=t?jo(t.floating):!1;if(r===i||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=vt(1),u=vt(0),d=sn(r);if(d||!o){if(fr(r)!=="body"||Yo(i))l=Wo(r);if(d){let h=hr(r);c=Ts(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}}let f=i&&!d&&!o?HE(i,l):vt(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function _N(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function NN(e){let t=Wo(e),n=e.ownerDocument.body,r=_n(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),s=_n(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),o=-t.scrollLeft+nl(e),i=-t.scrollTop;if(xt(n).direction==="rtl")o+=_n(e.clientWidth,n.clientWidth)-r;return{width:r,height:s,x:o,y:i}}var ON=25;function IN(e,t,n){if(n===void 0)n="viewport";let r=n==="layoutViewport",s=Ke(e),o=Lt(e),i=s.visualViewport,{clientWidth:a,clientHeight:l}=o,c=0,u=0;if(i){let f=!el()||t==="fixed";if(r){if(!f)c=-i.offsetLeft,u=-i.offsetTop}else if(a=i.width,l=i.height,f)c=i.offsetLeft,u=i.offsetTop}if(nl(o)<=0){let f=o.ownerDocument,h=f.body,p=getComputedStyle(h),m=f.compatMode==="CSS1Compat"?parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0:0,g=Math.abs(o.clientWidth-h.clientWidth-m),E=getComputedStyle(o).scrollbarGutter==="stable both-edges"?g/2:g;if(E<=ON)a-=E}return{width:a,height:l,x:c,y:u}}function MN(e,t){let n=hr(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=Ts(e),i=e.clientWidth*o.x,a=e.clientHeight*o.y,l=s*o.x,c=r*o.y;return{width:i,height:a,x:l,y:c}}function PE(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=IN(e,n,t);else if(t==="document")r=NN(Lt(e));else if(St(t))r=MN(t,n);else{let s=UE(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return ur(r)}function RN(e,t){let n=t.get(e);if(n)return n;let r=ys(e,[],!1).filter((a)=>St(a)&&fr(a)!=="body"),s=null,o=xt(e).position==="fixed",i=o?On(e):e;while(St(i)&&!Es(i)){let a=xt(i),l=Za(i),c=s?s.position:o?"fixed":"";if(!l&&(c==="fixed"||c==="absolute"&&a.position==="static"))r=r.filter((d)=>d!==i);else s=a;i=On(i)}return t.set(e,r),r}function DN(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e,i=[...n==="clippingAncestors"?jo(t)?[]:RN(t,this._c):[].concat(n),r],a=PE(t,i[0],s),{top:l,right:c,bottom:u,left:d}=a;for(let f=1;f<i.length;f++){let h=PE(t,i[f],s);l=_n(h.top,l),c=Ho(h.right,c),u=Ho(h.bottom,u),d=_n(h.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function vN(e){let{width:t,height:n}=FE(e);return{width:t,height:n}}function LN(e,t,n){let r=sn(t),s=Lt(t),o=n==="fixed",i=hr(e,!0,o,t),a={scrollLeft:0,scrollTop:0},l=vt(0);if(r||!o){if(fr(t)!=="body"||Yo(s))a=Wo(t);if(r){let f=hr(t,!0,o,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}}if(!r&&s)l.x=nl(s);let c=s&&!r&&!o?HE(s,a):vt(0),u=i.left+a.scrollLeft-l.x-c.x,d=i.top+a.scrollTop-l.y-c.y;return{x:u,y:d,width:i.width,height:i.height}}function nd(e){return xt(e).position==="static"}function BE(e,t){if(!sn(e)||xt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;if(Lt(e)===n)n=n.ownerDocument.body;return n}function $E(e,t){let n=Ke(e);if(jo(e))return n;if(!sn(e)){let s=On(e);while(s&&!Es(s)){if(St(s)&&!nd(s))return s;s=On(s)}return n}let r=BE(e,t);while(r&&DE(r)&&nd(r))r=BE(r,t);if(r&&Es(r)&&nd(r)&&!Za(r))return n;return r||vE(e)||n}var PN=async function(e){let t=this.getOffsetParent||$E,n=this.getDimensions,r=await n(e.floating);return{reference:LN(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function BN(e){return xt(e).direction==="rtl"}var FN={convertOffsetParentRelativeRectToViewportRelativeRect:kN,getDocumentElement:Lt,getClippingRect:DN,getOffsetParent:$E,getElementRects:PN,getClientRects:_N,getDimensions:vN,getScale:Ts,isElement:St,isRTL:BN};function VE(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function UN(e,t,n){let r=null,s,o=Lt(e);function i(){var u;clearTimeout(s),(u=r)==null||u.disconnect(),r=null}function a(u,d){if(u===void 0)u=!1;if(d===void 0)d=1;i();let f=e.getBoundingClientRect(),{left:h,top:p,width:m,height:g}=f;if(!u)t();if(!m||!g)return;let E=Vo(p),x=Vo(o.clientWidth-(h+m)),w=Vo(o.clientHeight-(p+g)),b=Vo(h),D={rootMargin:-E+"px "+-x+"px "+-w+"px "+-b+"px",threshold:_n(0,Ho(1,d))||1},R=!0;function P(H){let F=H[0].intersectionRatio;if(!VE(f,e.getBoundingClientRect()))return a();if(F!==d){if(!R)return a();if(!F)s=setTimeout(()=>{a(!1,0.0000001)},1000);else a(!1,F)}R=!1}try{r=new IntersectionObserver(P,{...D,root:o.ownerDocument})}catch(H){r=new IntersectionObserver(P,D)}r.observe(e)}let l=Ke(e),c=()=>a(n);return l.addEventListener("resize",c),a(!0),()=>{l.removeEventListener("resize",c),i()}}function zE(e,t,n,r){if(r===void 0)r={};let{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver==="function",layoutShift:a=typeof IntersectionObserver==="function",animationFrame:l=!1}=r,c=rd(e),u=s||o?[...c?ys(c):[],...t?ys(t):[]]:[];u.forEach((E)=>{s&&E.addEventListener("scroll",n),o&&E.addEventListener("resize",n)});let d=c&&a?UN(c,n,o):null,f=-1,h=null;if(i){if(h=new ResizeObserver((E)=>{let[x]=E;if(x&&x.target===c&&h&&t)h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var w;(w=h)==null||w.observe(t)});n()}),c&&!l)h.observe(c);if(t)h.observe(t)}let p,m=l?hr(e):null;if(l)g();function g(){let E=hr(e);if(m&&!VE(m,E))n();m=E,p=requestAnimationFrame(g)}return n(),()=>{var E;if(u.forEach((x)=>{s&&x.removeEventListener("scroll",n),o&&x.removeEventListener("resize",n)}),d==null||d(),(E=h)==null||E.disconnect(),h=null,l)cancelAnimationFrame(p)}}var YE=IE;var jE=OE;var WE=(e,t,n)=>{let r=new Map,s=n!=null?n:{},o={...FN,...s.platform,_c:r};return NE(e,t,{...s,platform:o})};function HN(e){var t;let{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:a}=e,l=r&&!s,c=Uu(n),u=new RegExp(`\\s${c}$`),d=i?"^":"",f=s?"":c,h=l?new RegExp(`${d}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((t=a.nodeBefore)===null||t===void 0?void 0:t.isText)&&a.nodeBefore.text;if(!p)return null;let m=a.pos-p.length,g=Array.from(p.matchAll(h)).pop();if(!g||g.input===void 0||g.index===void 0)return null;let E=g.input.slice(Math.max(0,g.index-1),g.index),x=new RegExp(`^[${o===null||o===void 0?void 0:o.map(Uu).join("")}\x00]?$`).test(E);if(o!==null&&!x)return null;let w=m+g.index,b=w+g[0].length;if(l&&u.test(p.slice(b-1,b+1)))g[0]+=" ",b+=1;if(w<a.pos&&b>=a.pos)return{range:{from:w,to:b},query:g[0].slice(n.length),text:g[0]};return null}function $N(e){if(!e.docChanged)return!1;return e.steps.some((t)=>{let n=t.slice;if(!(n===null||n===void 0?void 0:n.content))return!1;let r=n.content.textBetween(0,n.content.size,`
|
|
92
|
+
`);return/\s/.test(r)})}function VN(e){return()=>{let t=e.state.selection.$anchor.pos,{top:n,right:r,bottom:s,left:o}=e.view.coordsAtPos(t);try{return new DOMRect(o,n,r-o,s-n)}catch{return null}}}function zN(e,t,n,r){if(!n)return VN(e);return()=>{let s=r.getState(e.state),o=s===null||s===void 0?void 0:s.decorationId,i=t.dom.querySelector(`[data-decoration-id="${o}"]`);return(i===null||i===void 0?void 0:i.getBoundingClientRect())||null}}function YN({match:e,dismissedRange:t,state:n,transaction:r,editor:s,shouldResetDismissed:o,effectiveAllowSpaces:i}){if(o===null||o===void 0?void 0:o({editor:s,state:n,range:t,match:e,transaction:r,allowSpaces:i}))return!1;if(i)return e.range.from===t.from;return e.range.from===t.from&&!$N(r)}function jN({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function WN({pluginKey:e,decorationTag:t,decorationClass:n,decorationContent:r,decorationEmptyClass:s,renderer:o,dispatchExit:i}){return{handleKeyDown(a,l){var c;let u=e.getState(a.state);if(!u.active)return!1;if(l.key==="Escape"||l.key==="Esc"){var d;return o===null||o===void 0||(d=o.onKeyDown)===null||d===void 0||d.call(o,{view:a,event:l,range:u.range}),i(a),!0}return(o===null||o===void 0||(c=o.onKeyDown)===null||c===void 0?void 0:c.call(o,{view:a,event:l,range:u.range}))||!1},decorations(a){let{active:l,range:c,decorationId:u,query:d}=e.getState(a);if(!l)return null;let f=!(d===null||d===void 0?void 0:d.length),h=[n];if(f)h.push(s);return j.create(a.doc,[ae.inline(c.from,c.to,{nodeName:t,class:h.join(" "),"data-decoration-id":u||void 0,"data-decoration-content":r})])}}}function KN({editor:e,char:t,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:s,startOfLine:o,findSuggestionMatch:i,allow:a,shouldShow:l,shouldKeepDismissed:c,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,f,h,p){let{isEditable:m}=e,{composing:g}=e.view,{selection:E}=d,{empty:x,from:w}=E,b={...f},v=d.getMeta(u);if(v&&v.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=g,d.docChanged&&b.dismissedRange!==null)b.dismissedRange={from:d.mapping.map(b.dismissedRange.from),to:d.mapping.map(b.dismissedRange.to)};if(m&&(x||e.view.composing)){if((w<f.range.from||w>f.range.to)&&!g&&!f.composing)b.active=!1;let D=i({char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:s,startOfLine:o,$position:E.$from}),R=`id_${Math.floor(Math.random()*4294967295)}`;if(D&&a({editor:e,state:p,range:D.range,isActive:f.active})&&(!l||l({editor:e,range:D.range,query:D.query,text:D.text,transaction:d}))){if(b.dismissedRange!==null&&!c({match:D,dismissedRange:b.dismissedRange,state:p,transaction:d}))b.dismissedRange=null;if(b.dismissedRange===null)b.active=!0,b.decorationId=f.decorationId||R,b.range=D.range,b.query=D.query,b.text=D.text;else b.active=!1}else{if(!D)b.dismissedRange=null;b.active=!1}}else b.active=!1;if(!b.active)b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null;return b}}}function qN({editor:e,items:t}){let n=null,r=null,s=null,o=()=>{if(r!==null)clearTimeout(r),r=null;s===null||s===void 0||s(),s=null},i=(c)=>new Promise((u)=>{s=u,r=setTimeout(()=>{r=null;let d=s;s=null,d===null||d===void 0||d()},c)}),a=()=>{n===null||n===void 0||n.abort(),o(),n=null};return{abort:a,fetch:async(c,u)=>{a(),n=new AbortController;let d=n;if(u>0)await i(u);if(n!==d||d.signal.aborted)return{status:"aborted"};try{let f=await t({editor:e,query:c,signal:d.signal});if(n!==d||d.signal.aborted)return{status:"aborted"};return{status:"resolved",items:f}}catch{if(n!==d||d.signal.aborted)return{status:"aborted"};return{status:"error"}}}}}function XN({placement:e,offset:t,flip:n,floatingUi:r}){var s,o,i,a;let l=[YE({mainAxis:(s=t.mainAxis)!==null&&s!==void 0?s:4,crossAxis:(o=t.crossAxis)!==null&&o!==void 0?o:0})];if(n)l.push(jE());if(r===null||r===void 0||(i=r.middleware)===null||i===void 0?void 0:i.length)l.push(...r.middleware);return{placement:e,strategy:(a=r===null||r===void 0?void 0:r.strategy)!==null&&a!==void 0?a:"absolute",middleware:l}}function GN(e){if(e instanceof HTMLElement)return e;if(typeof e==="string")try{let t=document.querySelector(e);if(t)return t}catch{return document.body}return document.body}function JN({getReferenceRect:e,contextElement:t,config:n,container:r,dismissOnOutsideClick:s,dismiss:o}){return(i,a={})=>{let l={getBoundingClientRect:()=>{var p;return(p=e())!==null&&p!==void 0?p:new DOMRect},contextElement:t},c=!1,u=!i.isConnected;if(u)GN(r).appendChild(i);if(!a.onPosition)i.style.visibility="hidden",i.style.width="max-content";let f=zE(l,i,()=>{WE(l,i,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:p,y:m,placement:g,strategy:E})=>{if(a.onPosition){a.onPosition({x:p,y:m,placement:g,strategy:E});return}if(Object.assign(i.style,{position:E,left:`${p}px`,top:`${m}px`}),!c)c=!0,i.style.visibility=""})},a.autoUpdate),h;if(s)h=(p)=>{let m=p.target;if(!(m instanceof Node)||i.contains(m)||t.contains(m))return;o()},document.addEventListener("pointerdown",h,!0);return()=>{if(f(),h)document.removeEventListener("pointerdown",h,!0);if(u)i.remove()}}}function QN({editor:e,pluginKey:t,items:n,renderer:r,minQueryLength:s,debounce:o,initialItems:i,placement:a,offset:l,container:c,flip:u,floatingUi:d,dismissOnOutsideClick:f,command:h,clientRectFor:p,dispatchExit:m}){let g,E=qN({editor:e,items:n}),x=XN({placement:a,offset:l,flip:u,floatingUi:d});function w(b,v){switch(b){case"started":var D;r===null||r===void 0||(D=r.onStart)===null||D===void 0||D.call(r,v);break;case"updated":var R;r===null||r===void 0||(R=r.onUpdate)===null||R===void 0||R.call(r,v);break;case"stopped":var P;r===null||r===void 0||(P=r.onExit)===null||P===void 0||P.call(r,v)}}return{update:async(b,v)=>{var D,R;let P=t.getState(v),H=t.getState(b.state);if(!P||!H)return;let F=null,ke=P.query!==H.query,qe=P.text!==H.text,lt=P.range.from!==H.range.from||P.range.to!==H.range.to,A=ke||qe||lt;if(!P.active&&H.active)F="started";else if(P.active&&!H.active)F="stopped";else if(H.active&&A)F="updated";else return;let N=F==="stopped"?P:H,O=b.dom.querySelector(`[data-decoration-id="${N.decorationId}"]`),k=p(b,O),L=s===0||(N.query?N.query.length>=s:!1),Y=(F==="started"||F==="updated")&&L;if(g={editor:e,range:N.range,query:N.query||"",text:N.text||"",items:i!==null&&i!==void 0?i:[],command:(ee)=>h({editor:e,range:N.range,props:ee}),decorationNode:O,clientRect:k,loading:Y,placement:a,offset:{mainAxis:(D=l.mainAxis)!==null&&D!==void 0?D:4,crossAxis:(R=l.crossAxis)!==null&&R!==void 0?R:0},container:c,flip:u,floatingUi:x,mount:JN({getReferenceRect:k,contextElement:b.dom,config:x,container:c,dismissOnOutsideClick:f,dismiss:()=>m(e.view)})},F==="started"){var te;r===null||r===void 0||(te=r.onBeforeStart)===null||te===void 0||te.call(r,g)}if(F==="updated"){var z;r===null||r===void 0||(z=r.onBeforeUpdate)===null||z===void 0||z.call(r,g)}if(F==="started")w(F,g);if(F==="started"||F==="updated")if(!Y)E.abort(),g={...g,items:i!==null&&i!==void 0?i:[],loading:!1};else{g={...g,items:i!==null&&i!==void 0?i:[],loading:!0},F="updated",w(F,g);let ee=await E.fetch(N.query||"",o);if(ee.status==="aborted")return;let Le=t.getState(b.state);if(!(Le===null||Le===void 0?void 0:Le.active)){E.abort();return}g=ee.status==="resolved"?{...g,items:ee.items,loading:!1}:{...g,loading:!1}}if(F==="stopped"){E.abort(),w(F,g),g=void 0;return}if(F==="updated")w(F,g)},destroy:()=>{var b;if(E.abort(),!g)return;r===null||r===void 0||(b=r.onExit)===null||b===void 0||b.call(r,g)}}}var KE=new Q("suggestion");function qE({pluginKey:e=KE,editor:t,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:o=[" "],startOfLine:i=!1,decorationTag:a="span",decorationClass:l="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:f=()=>[],minQueryLength:h=0,debounce:p=0,initialItems:m,placement:g="bottom-start",offset:E={},container:x,flip:w=!0,floatingUi:b,dismissOnOutsideClick:v=!0,render:D=()=>({}),allow:R=()=>!0,findSuggestionMatch:P=HN,shouldShow:H,shouldResetDismissed:F}){let ke=D===null||D===void 0?void 0:D(),qe=r&&!s,lt=(O,k)=>zN(t,O,k,e);function A(O){return YN({...O,editor:t,shouldResetDismissed:F,effectiveAllowSpaces:qe})}let N=(O)=>jN({view:O,pluginKeyRef:e});return new q({key:e,view:()=>QN({editor:t,pluginKey:e,items:f,renderer:ke,minQueryLength:h,debounce:p,initialItems:m,placement:g,offset:E,container:x,flip:w,floatingUi:b,dismissOnOutsideClick:v,command:d,clientRectFor:lt,dispatchExit:N}),state:KN({editor:t,char:n,effectiveAllowSpaces:qe,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,findSuggestionMatch:P,allow:R,shouldShow:H,shouldKeepDismissed:A,pluginKey:e}),props:WN({pluginKey:e,decorationTag:a,decorationClass:l,decorationContent:c,decorationEmptyClass:u,renderer:ke,dispatchExit:N})})}function XE(e,t=KE){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}var sd=30000;class od extends ml{constructor(e){super();this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let t=$t();if(this.getLocalState()!==null&&sd/2<=t-this.meta.get(this.clientID).lastUpdated)this.setLocalState(this.getLocalState());let n=[];if(this.meta.forEach((r,s)=>{if(s!==this.clientID&&sd<=t-r.lastUpdated&&this.states.has(s))n.push(s)}),n.length>0)ZN(this,n,"timeout")},Se(sd/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,s=this.states.get(t);if(e===null)this.states.delete(t);else this.states.set(t,e);this.meta.set(t,{clock:r,lastUpdated:$t()});let o=[],i=[],a=[],l=[];if(e===null)l.push(t);else if(s==null){if(e!=null)o.push(t)}else if(i.push(t),!cn(s,e))a.push(t);if(o.length>0||a.length>0||l.length>0)this.emit("change",[{added:o,updated:a,removed:l},"local"]);this.emit("update",[{added:o,updated:i,removed:l},"local"])}setLocalStateField(e,t){let n=this.getLocalState();if(n!==null)this.setLocalState({...n,[e]:t})}getStates(){return this.states}}var ZN=(e,t,n)=>{let r=[];for(let s=0;s<t.length;s++){let o=t[s];if(e.states.has(o)){if(e.states.delete(o),o===e.clientID){let i=e.meta.get(o);e.meta.set(o,{clock:i.clock+1,lastUpdated:$t()})}r.push(o)}}if(r.length>0)e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n])};var GE=(e,t,n)=>{let r=_r(t),s=$t(),o=[],i=[],a=[],l=[],c=K(r);for(let u=0;u<c;u++){let d=K(r),f=K(r),h=JSON.parse(Ht(r)),p=e.meta.get(d),m=e.states.get(d),g=p===void 0?0:p.clock;if(g<f||g===f&&h===null&&e.states.has(d)){if(h===null)if(d===e.clientID&&e.getLocalState()!=null)f++;else e.states.delete(d);else e.states.set(d,h);if(e.meta.set(d,{clock:f,lastUpdated:s}),p===void 0&&h!==null)o.push(d);else if(p!==void 0&&h===null)l.push(d);else if(h!==null){if(!cn(h,m))a.push(d);i.push(d)}}}if(o.length>0||a.length>0||l.length>0)e.emit("change",[{added:o,updated:a,removed:l},n]);if(o.length>0||i.length>0||l.length>0)e.emit("update",[{added:o,updated:i,removed:l},n])};function JE(e,t){let n=t.trim().toLowerCase();if(!n)return[...e];let r=(s)=>{let o=s.label.toLowerCase();if(o.startsWith(n))return 0;if(o.includes(n))return 1;if(s.keywords.some((i)=>i.startsWith(n)))return 2;return-1};return e.map((s)=>({type:s,rank:r(s)})).filter(({rank:s})=>s>=0).sort((s,o)=>s.rank-o.rank).map(({type:s})=>s)}function pr(e,t={}){return Object.fromEntries(e.map((n)=>[n,{default:t[n]??null,rendered:!1}]))}var rl=new Map;function Pt(e){if(!e)return{};let t=rl.get(e);if(t)return t;if(rl.size>2000)rl.clear();let n=document.createElement("template"),r=/^<([a-zA-Z][\w-]*)/.exec(e)?.[1]??"span";n.innerHTML=`${e}</${r}>`;let s=n.content.firstElementChild,o={};for(let i of Array.from(s?.attributes??[]))if(QE(i.name,i.value))o[i.name]=i.value;return rl.set(e,o),o}function QE(e,t){if(/^on/i.test(e))return!1;if(/^(href|src|action|formaction|xlink:href|srcdoc|data)$/i.test(e)){let n=t.replace(/[\u0000-\u0020\u007f]/g,"");return!/^(javascript|vbscript):/i.test(n)&&e.toLowerCase()!=="srcdoc"}return!0}var ZE=/^(script|iframe|object|embed|base|meta|link|form|frame|frameset|portal|noscript|template|set|animate|animatemotion|animatetransform)$/i;function eT(e){let t=String(e??"");return/^[a-z][a-z0-9-]*$/i.test(t)&&!ZE.test(t)?t:"div"}function tT(e){for(let t of Array.from(e.querySelectorAll("*"))){if(ZE.test(t.localName)){t.remove();continue}for(let n of Array.from(t.attributes))if(!QE(n.name,n.value))t.removeAttribute(n.name)}}function Ko(e,t={}){let n=Object.entries(t).map(([r,s])=>` ${r}="${s.replace(/&/g,"&").replace(/"/g,""")}"`).join("");return`<${e}${n}>`}function nT(e){return e.tagName.toLowerCase()}function sl(e){let t=e.cloneNode(!1);for(let r of t.getAttributeNames())if(r==="data-pm-slice"||r.startsWith("data-sixb-raw")||r==="contenteditable")t.removeAttribute(r);let n=t.outerHTML;return n.slice(0,n.indexOf(">")+1)}var rT=new Set(["div","section","article","aside","header","footer","main","nav","ul","ol","dl","table","thead","tbody","tfoot","tr","figure","details","fieldset","hgroup","search"]);function sT(e){return Array.from(e.children).some((t)=>{let n=t.localName;return rT.has(n)||io.has(n)||n==="hr"||n==="img"})}var eO=nn.create({name:"doc",topNode:!0,content:"block+"}),tO=nn.create({name:"text",group:"inline"}),nO=nn.create({name:"box",group:"block",content:"block+",defining:!0,addAttributes:()=>pr(["tag","open","close","before","end"],{tag:"div"}),parseHTML:()=>[{tag:"*",priority:10,getAttrs:(e)=>{let t=nT(e);return rT.has(t)||io.has(t)&&sT(e)?{tag:t,open:sl(e)}:!1}}],renderHTML:({node:e})=>[eT(e.attrs.tag),{...Pt(e.attrs.open)},0]}),rO=nn.create({name:"textBlock",group:"block",content:"inline*",defining:!0,addAttributes:()=>pr(["tag","open","close","before","inner"],{tag:"p"}),parseHTML:()=>[{tag:[...io].join(","),getAttrs:(e)=>sT(e)?!1:{tag:nT(e),open:sl(e)}}],renderHTML:({node:e})=>[eT(e.attrs.tag),{...Pt(e.attrs.open)},0]}),ol=nn.create({name:"image",group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes:()=>pr(["source","before"]),parseHTML:()=>[{tag:"img[src]",getAttrs:(e)=>({source:e.outerHTML})}],renderHTML:({node:e})=>["img",{...Pt(e.attrs.source)}]}),il=nn.create({name:"raw",group:"block",atom:!0,draggable:!0,selectable:!0,addAttributes:()=>pr(["source","before"]),parseHTML:()=>[{tag:"[data-sixb-raw]",priority:60,getAttrs:(e)=>({source:e.textContent??""})},{tag:"hr",getAttrs:(e)=>({source:sl(e)})}],renderHTML:({node:e})=>["div",{"data-sixb-raw":""},String(e.attrs.source??"")]}),al=nn.create({name:"rawInline",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes:()=>pr(["source"]),parseHTML:()=>[{tag:"[data-sixb-raw-inline]",priority:60,getAttrs:(e)=>({source:e.textContent??""})}],renderHTML:({node:e})=>["span",{"data-sixb-raw-inline":""},String(e.attrs.source??"")]}),sO=nn.create({name:"hardBreak",group:"inline",inline:!0,selectable:!1,linebreakReplacement:!0,addAttributes:()=>pr(["source"]),parseHTML:()=>[{tag:"br"}],renderHTML:()=>["br"],renderText:()=>`
|
|
93
|
+
`}),oO=Wn.map((e)=>$u.create({name:e,inclusive:e!=="a",addAttributes:()=>pr(["open","close"]),parseHTML:()=>[{tag:e,getAttrs:(t)=>({open:sl(t),close:`</${e}>`})}],renderHTML:({mark:t})=>[e,{...Pt(t.attrs.open)},0]}));function oT(){return[eO,tO,rO,nO,ol,il,al,sO,...oO]}var Bt=new Set(["td","th","caption","figcaption","summary","legend","label",...Wn]),gr=new Set(["ul","ol","menu"]),iO=new Set([...gr,"dl","table","thead","tbody","tfoot","tr"]),id={heading1:"h1",heading2:"h2",heading3:"h3"};function Ze(e){let{$from:t}=e;if(t.parent.type.name!=="textBlock"||t.depth===0)return null;return{node:t.parent,pos:t.before()}}function X(e){return typeof e?.attrs.tag==="string"?e.attrs.tag:""}function pe(e,t,n,r){return e.nodes.textBlock.create({tag:t,open:n??`<${t}>`,close:`</${t}>`},r??null)}function mr(e,t,n,r){return e.nodes.box.create({tag:t,open:r??`<${t}>`,close:`</${t}>`},n)}function iT(e,t){return e.nodes.raw.create({source:t})}function In(e,t){let n={...Pt(e)};if(!("id"in n))return e;return delete n.id,Ko(t,n)}function ad(e,t,n){let r=null,s=null;e.descendants((i,a)=>{if(X(i)!==n||typeof i.attrs.open!=="string")return!0;if(a<t)r=i.attrs.open;else s??=i.attrs.open;return!0});let o=r??s;return o?In(o,n):`<${n}>`}function aO(e,t,n,r){let s=id[r];if(s)return pe(e,s,ad(t,n,s));switch(r){case"paragraph":return pe(e,"p");case"quote":return pe(e,"blockquote");case"bulletList":return mr(e,"ul",[pe(e,"li")]);case"orderedList":return mr(e,"ol",[pe(e,"li")]);case"table":{let o=(i)=>mr(e,"tr",[1,2,3].map(()=>pe(e,i)));return mr(e,"table",[mr(e,"thead",[o("th")]),mr(e,"tbody",[o("td"),o("td")])],ad(t,n,"table"))}case"divider":return iT(e,"<hr>");case"pageBreak":return iT(e,'<div style="break-after: page"></div>');default:return null}}function ld(e,t){let n=e.nodeAt(t),r=e.resolve(t),s=t+(n?.nodeSize??0);for(let o=r.depth;o>0;o-=1)if(iO.has(X(r.node(o))))s=r.after(o);return s}function cd(e,t,n){let r=e.doc.nodeAt(t),s=ld(e.doc,t),o=r?.type.name==="textBlock"&&r.content.size===0&&s===t+r.nodeSize&&!Bt.has(X(r));if(r&&o)return e.replaceWith(t,t+r.nodeSize,n),t;return e.insert(s,n),s}function ud(e,t){let n=e.doc.nodeAt(t);if(!n)return;if(!n.isAtom){e.setSelection(I.near(e.doc.resolve(t+1)));return}let r=t+n.nodeSize;if(e.doc.resolve(r).nodeAfter?.type.name!=="textBlock")e.insert(r,pe(e.doc.type.schema,"p"));e.setSelection(I.create(e.doc,r+1))}function cT(e,t,n){let r=e.state.tr;if(n)r.delete(n.from,n.to);let s=Ze(r.selection);if(!s)return!1;let o=aO(e.schema,r.doc,s.pos,t);if(!o)return!1;return ud(r,cd(r,s.pos,o)),e.view.dispatch(r.scrollIntoView()),e.view.focus(),!0}function uT(e,t,n){let{state:r}=e,s=n===void 0?Ze(r.selection):{node:r.doc.nodeAt(n),pos:n};if(!s||!ll(r.doc,s.pos))return!1;let{node:o}=s,i=r.doc.resolve(s.pos),a=i.parent,l=X(o)==="li"&&gr.has(X(a)),c=r.tr,u=Math.min(Math.max(r.selection.from-s.pos-1,0),o.content.size),d=s.pos;if(t==="bulletList"||t==="orderedList"){let f=t==="bulletList"?"ul":"ol";if(l){if(X(a)===f)return!0;c.setNodeMarkup(i.before(),void 0,{...a.attrs,tag:f,open:`<${f}>`,close:`</${f}>`})}else c.replaceWith(s.pos,s.pos+o.nodeSize,mr(e.schema,f,[pe(e.schema,"li",void 0,o.content)])),d=s.pos+1}else{let f=id[t]??(t==="paragraph"?"p":t==="quote"?"blockquote":null);if(!f)return!1;let h=id[t]?ad(r.doc,s.pos,f):`<${f}>`;if(l)d=qo(c,s.pos,pe(e.schema,f,h,o.content));else c.setNodeMarkup(s.pos,void 0,{...o.attrs,tag:f,open:h,close:`</${f}>`})}return c.setSelection(I.create(c.doc,d+1+u)),e.view.dispatch(c.scrollIntoView()),e.view.focus(),!0}function ll(e,t){let n=e.nodeAt(t);if(n?.type.name!=="textBlock"||Bt.has(X(n)))return!1;let r=e.resolve(t);for(let s=r.depth;s>0;s-=1){let o=X(r.node(s));if(o==="table"||o==="tr"||o==="thead"||o==="tbody"||o==="tfoot")return!1}return!0}function qo(e,t,n){let r=e.doc.nodeAt(t);if(!r)return t;let s=e.doc.resolve(t),o=s.parent,i=s.before(),a=s.index(),l;if(o.childCount===1)e.replaceWith(i,i+o.nodeSize,n),l=i;else if(a===0)e.delete(t,t+r.nodeSize),e.insert(i,n),l=i;else if(a===o.childCount-1)e.delete(t,t+r.nodeSize),l=e.mapping.map(i+o.nodeSize),e.insert(l,n);else e.delete(t,t+r.nodeSize),e.split(t,1),l=t+1,e.insert(l,n);return e.setSelection(I.near(e.doc.resolve(l+1))),l}function cl(e,t){let n=e.state.doc.nodeAt(t);if(!n)return!1;let r=X(n);if(Bt.has(r))return!1;let s=n.attrs.open,o=typeof s==="string"&&r?n.type.create({...n.attrs,open:In(s,r)},n.content,n.marks):n,i=t+n.nodeSize,a=e.state.tr.insert(i,o);return a.setSelection(o.isAtom?M.create(a.doc,i):U.near(a.doc.resolve(i+o.nodeSize-1),-1)),e.view.dispatch(a.scrollIntoView()),e.view.focus(),!0}function dT(e,t){let{doc:n}=e.state,r=t,s=n.nodeAt(t);if(!s)return!1;let o=n.resolve(r);while(o.depth>0&&o.parent.childCount===1)r=o.before(),s=o.parent,o=n.resolve(r);let i=e.state.tr;if(o.depth===0&&n.childCount===1)i.replaceWith(0,n.content.size,pe(e.schema,"p"));else i.delete(r,r+s.nodeSize);return i.setSelection(U.near(i.doc.resolve(Math.min(r,i.doc.content.size)),-1)),e.view.dispatch(i.scrollIntoView()),e.view.focus(),!0}function Xo(e,t,n){let{doc:r}=e.state,s=r.nodeAt(t);if(!s)return null;let o=r.resolve(t),i=o.parent.maybeChild(o.index()+n);if(!i)return null;let a=e.state.selection.from-t,l=n===1?t+i.nodeSize:t-i.nodeSize,c=e.state.tr.delete(t,t+s.nodeSize).insert(l,s),u=l+Math.min(Math.max(a,0),s.nodeSize);return c.setSelection(s.isAtom?M.create(c.doc,l):U.near(c.doc.resolve(u))),e.view.dispatch(c.scrollIntoView()),e.view.focus(),l}function ul(e,t,n){let r=lT(e,t,n);if(r?.node.type.name!=="box"||X(r.node)==="table")return r;for(let s=t+aT;s<=t+lO;s+=aT){let o=lT(e,s,n);if(o&&(o.node.type.name!=="box"||X(o.node)==="table")){let i=yr(e.nodeDOM(o.pos));if(i&&n>=i.top&&n<=i.bottom)return o}}return r}var lO=240,aT=12;function lT(e,t,n){let r=e.posAtCoords({left:t,top:n});if(!r)return null;let{doc:s}=e.state,o=r.inside,i=o>=0?s.nodeAt(o):null;if(!i||i.isInline){let l=s.resolve(r.pos);if(l.parent.isTextblock)o=l.before(l.depth),i=l.parent;else{let{nodeBefore:c,nodeAfter:u}=l,d=(p,m)=>{if(!p)return Number.POSITIVE_INFINITY;let g=yr(e.nodeDOM(m));if(!g)return Number.POSITIVE_INFINITY;return n<g.top?g.top-n:n>g.bottom?n-g.bottom:0},f=c?r.pos-c.nodeSize:-1,h=d(c,f)<=d(u,r.pos)?{node:c,pos:f}:{node:u,pos:r.pos};if(h.node)i=h.node,o=h.pos;else if(l.depth>0)o=l.before(l.depth),i=l.parent;else return null}}let a=s.resolve(o);for(let l=1;l<=a.depth;l+=1)if(X(a.node(l))==="table")return{node:a.node(l),pos:a.before(l)};return i?{node:i,pos:o}:null}function yr(e){if(!(e instanceof Element))return null;let t=e.getBoundingClientRect();if(t.width>0||t.height>0)return{left:t.left,top:t.top,right:t.right,bottom:t.bottom};let n=null;for(let r of Array.from(e.children)){let s=yr(r);if(!s)continue;n=n?{left:Math.min(n.left,s.left),top:Math.min(n.top,s.top),right:Math.max(n.right,s.right),bottom:Math.max(n.bottom,s.bottom)}:s}return n}function dd(e,t,n,r){let s=e.state.doc.nodeAt(t),o=ul(e,n,r);if(!s||!o)return null;let i=(u)=>X(u)==="li";if(i(s)&&!i(o.node))return null;if(!i(s)&&i(o.node)){let u=e.state.doc.resolve(o.pos);o={node:u.parent,pos:u.before()}}if(o.pos>=t&&o.pos<t+s.nodeSize)return null;let a=yr(e.nodeDOM(o.pos));if(!a)return null;let l=r<(a.top+a.bottom)/2,c=l?a.top:a.bottom;return{at:l?o.pos:o.pos+o.node.nodeSize,line:{left:a.left,right:a.right,top:c,bottom:c}}}function fT(e,t,n){let{doc:r}=e.state,s=r.nodeAt(t);if(!s||n===t||n===t+s.nodeSize)return!1;let o=t,i=s.nodeSize,a=r.resolve(o);while(a.depth>0&&a.parent.childCount===1)o=a.before(),i=a.parent.nodeSize,a=r.resolve(o);if(n>o&&n<o+i)return!1;let l=e.state.tr.delete(o,o+i),c=l.mapping.map(n);return l.insert(c,s),l.setSelection(s.isAtom?M.create(l.doc,c):U.near(l.doc.resolve(c+s.nodeSize-1),-1)),e.view.dispatch(l.scrollIntoView()),e.view.focus(),!0}function hT(e){let t=e.parent;if(t.type.name!=="textBlock")return null;let n=X(t);if(n==="p")return"paragraph";if(n==="h1")return"heading1";if(n==="h2")return"heading2";if(n==="h3")return"heading3";if(n==="blockquote")return"quote";if(n==="li"){let r=e.depth>1?X(e.node(e.depth-1)):"";return r==="ol"?"orderedList":r==="ul"?"bulletList":null}return null}var fd=new Set(["h1","h2","h3","h4","h5","h6","blockquote","address"]),mT=ne.create({name:"pageKeys",addOptions:()=>({toggleMark:()=>{},onLink:()=>{}}),addKeyboardShortcuts(){let e=this.editor,t=(r)=>()=>(this.options.toggleMark(e,r),!0),n=()=>{let r=Ze(e.state.selection);if(r)return r;let{selection:s}=e.state;return s instanceof M?{node:s.node,pos:s.from}:null};return{Enter:()=>cO(e),"Shift-Enter":()=>gT(e),Backspace:()=>dO(e),Delete:()=>fO(e),Home:()=>dl(e,"backward",!1),End:()=>dl(e,"forward",!1),"Shift-Home":()=>dl(e,"backward",!0),"Shift-End":()=>dl(e,"forward",!0),Tab:()=>pT(e,1),"Shift-Tab":()=>pT(e,-1),"Mod-b":t("bold"),"Mod-i":t("italic"),"Mod-u":t("underline"),"Mod-Shift-s":t("strike"),"Mod-e":t("code"),"Mod-k":()=>{if(e.state.selection.empty)return!1;return this.options.onLink(),!0},"Mod-d":()=>{let r=n();return r?cl(e,r.pos):!1},"Alt-Shift-ArrowUp":()=>{let r=n();if(r)Xo(e,r.pos,-1);return!0},"Alt-Shift-ArrowDown":()=>{let r=n();if(r)Xo(e,r.pos,1);return!0}}}});function dl(e,t,n){let r=e.view.dom.ownerDocument.getSelection();if(!r||typeof r.modify!=="function")return!1;return r.modify(n?"extend":"move",t,"lineboundary"),!0}function gT(e){let t=Ze(e.state.selection);if(!t)return!1;if(X(t.node)==="pre")return e.commands.insertContent(`
|
|
94
|
+
`);return e.commands.insertContent({type:"hardBreak"})}function cO(e){if(!(e.state.selection instanceof I))return!1;let t=Ze(e.state.selection);if(!t)return!1;let n=X(t.node);if(n==="pre")return e.commands.insertContent(`
|
|
95
|
+
`);if(Bt.has(n))return gT(e);let r=e.state.tr;if(!r.selection.empty)r.deleteSelection();let s=Ze(r.selection);if(!s)return!1;let{node:o,pos:i}=s,a=r.doc.resolve(i),l=n==="li"&&gr.has(X(a.parent));if(o.content.size===0){if(l||(n==="dd"||n==="dt")&&X(a.parent)==="dl")return qo(r,i,pe(e.schema,"p")),e.view.dispatch(r.scrollIntoView()),!0;let h=a.parent,p=a.depth>0?a.before():-1,m=p>=0?r.doc.resolve(p).parent:null;if(X(h)==="li"&&gr.has(X(m))&&a.index()===h.childCount-1){if(h.childCount===1)qo(r,p,pe(e.schema,"p"));else{r.delete(i,i+o.nodeSize);let g=r.mapping.map(p+h.nodeSize),E=typeof h.attrs.open==="string"?In(h.attrs.open,"li"):"<li>";r.insert(g,h.type.create({...h.attrs,open:E,before:null,end:null},[pe(e.schema,"p")])),r.setSelection(I.create(r.doc,g+2))}return e.view.dispatch(r.scrollIntoView()),!0}}let c=r.selection.$from.parentOffset,u=typeof o.attrs.open==="string"?In(o.attrs.open,n):`<${n}>`,d=a.depth>0?a.parent:null;if(d&&c>0&&X(d)==="li"&&gr.has(X(r.doc.resolve(a.before()).parent))&&a.index()===d.childCount-1){let h=typeof d.attrs.open==="string"?In(d.attrs.open,"li"):"<li>";return r.split(r.selection.from,2,[{type:d.type,attrs:{...d.attrs,open:h,before:null,end:null}},{type:o.type,attrs:{...o.attrs,open:u,before:null,inner:null}}]),e.view.dispatch(r.scrollIntoView()),!0}let f=fd.has(n)||!l&&n!=="dt"&&n!=="dd"?pe(e.schema,"p"):pe(e.schema,n,u);if(c===0&&o.content.size>0)r.insert(i,fd.has(n)?pe(e.schema,"p"):uO(o,u));else if(c===o.content.size)r.insert(i+o.nodeSize,f),r.setSelection(I.create(r.doc,i+o.nodeSize+1));else r.split(r.selection.from,1,[{type:o.type,attrs:{...o.attrs,open:u,before:null,inner:null}}]);return e.view.dispatch(r.scrollIntoView()),!0}function uO(e,t){return e.type.create({...e.attrs,open:t,before:null,inner:null})}function dO(e){let{selection:t}=e.state;if(!(t instanceof I)||!t.empty)return!1;let n=Ze(t);if(!n||t.$from.parentOffset>0)return!1;let{node:r,pos:s}=n,o=X(r),i=e.state.doc.resolve(s),a=i.index(),l=e.state.tr;if(fd.has(o)&&r.content.size>0)return l.setNodeMarkup(s,void 0,{...r.attrs,tag:"p",open:"<p>",close:"</p>"}),e.view.dispatch(l),!0;if(o==="li"&&gr.has(X(i.parent))){if(a>0)return!1;return qo(l,s,pe(e.schema,"p",void 0,r.content)),e.view.dispatch(l.scrollIntoView()),!0}if(Bt.has(o))return!0;let c=a>0?i.parent.child(a-1):null;if(!c){if(r.content.size>0||i.depth===0||i.parent.childCount===1)return!0;return l.delete(s,s+r.nodeSize),l.setSelection(U.near(l.doc.resolve(s),-1)),e.view.dispatch(l.scrollIntoView()),!0}if(c.type.name==="textBlock")return!1;let u=s-c.nodeSize;if(r.content.size===0)l.delete(s,s+r.nodeSize),l.setSelection(c.isAtom?M.create(l.doc,u):U.near(l.doc.resolve(s),-1));else if(c.isAtom)l.setSelection(M.create(l.doc,u));else l.setSelection(U.near(l.doc.resolve(s),-1));return e.view.dispatch(l.scrollIntoView()),!0}function fO(e){let{selection:t}=e.state;if(!(t instanceof I)||!t.empty)return!1;let n=Ze(t);if(!n||t.$from.parentOffset<n.node.content.size)return!1;if(Bt.has(X(n.node)))return!0;let r=e.state.doc.resolve(n.pos),s=r.parent.maybeChild(r.index()+1);if(!s)return!0;if(s.type.name!=="textBlock"){let o=n.pos+n.node.nodeSize,i=e.state.tr;if(n.node.content.size===0)i.delete(n.pos,o);else if(s.isAtom)i.setSelection(M.create(i.doc,o));return e.view.dispatch(i.scrollIntoView()),!0}return!1}function pT(e,t){let n=Ze(e.state.selection),r=X(n?.node);if(!n||r!=="td"&&r!=="th")return!1;let s=[],o=e.state.doc.resolve(n.pos),i=0;for(let f=o.depth;f>0;f-=1)if(X(o.node(f))==="table")i=f;if(i===0)return!0;let a=o.node(i),l=o.start(i);a.descendants((f,h)=>{if(f.type.name==="textBlock"&&(X(f)==="td"||X(f)==="th"))s.push(l+h);return f.type.name!=="textBlock"});let c=s[s.indexOf(n.pos)+t];if(c===void 0)return!0;let u=e.state.doc.nodeAt(c),d=e.state.tr.setSelection(I.create(e.state.doc,c+1,c+1+u.content.size));return e.view.dispatch(d.scrollIntoView()),!0}var yT=`
|
|
96
|
+
body.ProseMirror { outline: none; white-space: pre-wrap; word-wrap: break-word; }
|
|
97
|
+
body.ProseMirror :where([data-sixb-raw]) { white-space: normal; cursor: default; }
|
|
98
|
+
body.ProseMirror .ProseMirror-selectednode { outline: 2px solid #0a84ff; outline-offset: 2px; border-radius: 2px; }
|
|
99
|
+
body.ProseMirror ::selection { background: rgba(10, 132, 255, 0.22); }
|
|
100
|
+
body.ProseMirror .ProseMirror-selectednode::selection,
|
|
101
|
+
body.ProseMirror .ProseMirror-selectednode ::selection { background: transparent; }
|
|
102
|
+
body.ProseMirror :where([data-sixb-field]) {
|
|
103
|
+
border-radius: 3px;
|
|
104
|
+
background: rgba(10, 132, 255, 0.08);
|
|
105
|
+
box-shadow: 0 0 0 1px rgba(10, 132, 255, 0.28);
|
|
106
|
+
}
|
|
107
|
+
body.ProseMirror .is-empty[data-placeholder]::before {
|
|
108
|
+
content: attr(data-placeholder);
|
|
109
|
+
float: left;
|
|
110
|
+
height: 0;
|
|
111
|
+
color: currentColor;
|
|
112
|
+
opacity: 0.38;
|
|
113
|
+
pointer-events: none;
|
|
114
|
+
}
|
|
115
|
+
body.ProseMirror .sixb-page-break { position: relative; user-select: none; }
|
|
116
|
+
body.ProseMirror .sixb-page-break::after {
|
|
117
|
+
content: attr(data-label);
|
|
118
|
+
position: absolute;
|
|
119
|
+
inset: 0;
|
|
120
|
+
display: flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
justify-content: center;
|
|
123
|
+
color: #71717a;
|
|
124
|
+
font: 500 10px/1 system-ui, -apple-system, sans-serif;
|
|
125
|
+
letter-spacing: 0.06em;
|
|
126
|
+
text-transform: uppercase;
|
|
127
|
+
}
|
|
128
|
+
.sixb-caret {
|
|
129
|
+
position: relative;
|
|
130
|
+
margin-inline: -1px;
|
|
131
|
+
border-left: 2px solid var(--caret);
|
|
132
|
+
word-break: normal;
|
|
133
|
+
pointer-events: none;
|
|
134
|
+
}
|
|
135
|
+
.sixb-caret-label {
|
|
136
|
+
position: absolute;
|
|
137
|
+
bottom: 100%;
|
|
138
|
+
left: -2px;
|
|
139
|
+
padding: 1px 6px;
|
|
140
|
+
border-radius: 6px 6px 6px 0;
|
|
141
|
+
background: var(--caret);
|
|
142
|
+
color: #fff;
|
|
143
|
+
font: 600 11px/1.5 system-ui, -apple-system, sans-serif;
|
|
144
|
+
font-style: normal;
|
|
145
|
+
white-space: nowrap;
|
|
146
|
+
user-select: none;
|
|
147
|
+
}
|
|
148
|
+
.sixb-caret-selection { background: color-mix(in oklab, var(--caret) 22%, transparent); }
|
|
149
|
+
`;var Go=Symbol("app"),ET=new Q("sixb-page-slash"),fl=new Q("sixb-page-breaks"),bs={bold:["strong","b"],italic:["em","i"],underline:["u"],strike:["s","del"],code:["code"]},TT=["page","left","right","recto","verso"];function xT({port:e,body:t}){let n=(A)=>e.postMessage(A),r=new _t,s=new od(r),o=new Map,i=null,a=[],l=null,c=null,u=!1,d={selection:"",slash:"",hover:""},f=new Map,h=(A)=>{if(A===null)return null;if(f.delete(A),f.set(A,A),f.size>64)f.delete(f.keys().next().value);return A},p=(A)=>{for(let[N,O]of f){if(O===null)continue;let k=A.mapResult(O,1);f.set(N,k.deletedAfter?null:k.pos)}},m=(A)=>f.has(A)?f.get(A)??null:A,g=(A,N,O)=>{let k=JSON.stringify(N);if(d[A]===k)return;d[A]=k,n(O)},E=0,x=()=>{if(E)return;E=requestAnimationFrame(()=>{E=0,w()})},w=()=>{if(!i)return;let A=hO(i);g("selection",A,{type:"selection",selection:A});let N=l&&i.isEditable?{rect:pO(i.view,l.range.from),items:l.items.map((O)=>O.id),index:l.index}:null;if(g("slash",N,{type:"slash",slash:N}),!u){let O=b(i);if(O)h(O.pos);g("hover",O,{type:"hover",hover:O})}},b=(A)=>{if(!c||!A.isEditable)return null;let N=ul(A.view,c.x,c.y),O=N?yr(A.view.nodeDOM(N.pos)):null;if(!N||!O)return null;return{pos:N.pos,rect:O,textual:ll(A.state.doc,N.pos)}};document.addEventListener("mousemove",(A)=>{c={x:A.clientX,y:A.clientY},x()}),document.documentElement.addEventListener("mouseleave",()=>{c=null,x()}),window.addEventListener("scroll",x,{passive:!0}),window.addEventListener("resize",x);let v=(A)=>{let N=l!==null&&l.items.length===A.items.length;l={items:A.items,index:N&&l?Math.min(l.index,Math.max(0,A.items.length-1)):0,range:A.range},x()},D=(A)=>{let N=i,O=l?.items[A],k=l?.range;if(!N||!O||!k)return;if(l=null,O.id==="image"){N.chain().focus().deleteRange(k).run(),n({type:"pickImage",at:h(Ze(N.state.selection)?.pos??null)});return}cT(N,O.id,k)},R=ne.create({name:"pageSlash",addProseMirrorPlugins(){return[qE({editor:this.editor,pluginKey:ET,char:"/",allow:({state:A,range:N})=>{let O=A.doc.resolve(N.from).parent;return O.type.name==="textBlock"&&X(O)!=="pre"},items:({query:A})=>JE(a,A),command:()=>{},render:()=>({onStart:v,onUpdate:v,onKeyDown:({event:A})=>{if(!l)return!1;let N=l.items.length;if(A.key==="ArrowDown"||A.key==="ArrowUp"){if(N>0){let O=A.key==="ArrowDown"?1:-1;l.index=(l.index+O+N)%N,x()}return!0}if(A.key==="Enter"||A.key==="Tab"){if(N===0)return!1;return D(l.index),!0}return!1},onExit:()=>{l=null,x()}})})]}}),P="",H=ne.create({name:"pageBreaks",addProseMirrorPlugins(){return[new q({key:fl,state:{init:()=>j.empty,apply:(A,N)=>A.getMeta(fl)??N.map(A.mapping,A.doc)},props:{decorations:(A)=>fl.getState(A)},view:(A)=>{let N,O="",k=()=>{let Y=mO(A),te=Y.join(",");if(te===O)return;O=te;let z=j.create(A.state.doc,Y.map((ee)=>ae.widget(ee,()=>gO(P),{side:-1,ignoreSelection:!0,key:`break-${ee}`})));A.dispatch(A.state.tr.setMeta(fl,z).setMeta("addToHistory",!1))},L=()=>{clearTimeout(N),N=setTimeout(k,120)};return L(),document.fonts?.ready.then(L),window.addEventListener("resize",L),{update:(Y,te)=>{if(A.state.doc!==te.doc)L()},destroy:()=>{clearTimeout(N),window.removeEventListener("resize",L)}}}})]}}),F=(A,N)=>{let O=bs[N],k=A.chain().focus();if(O.some((L)=>A.isActive(L)))for(let L of O)k.unsetMark(L);else{let L=O[0];k.setMark(L,{open:`<${L}>`,close:`</${L}>`})}k.run()},ke=(A,N)=>{let O=A.chain().focus().extendMarkRange("a");if(N===null){O.unsetMark("a").run();return}let k={...Pt(A.getAttributes("a").open),href:N};O.setMark("a",{open:Ko("a",k),close:"</a>"}).run()},qe=(A,N)=>{let{state:O}=A,k=N;if("pos"in k&&k.pos!==void 0){let L=m(k.pos);if(L===null||!O.doc.nodeAt(L)?.isBlock){if(k.name==="drag"||k.name==="drop")n({type:"drop",line:null});return}k={...k,pos:L}}if(k.name==="image"&&k.at!==void 0){let{at:L,...Y}=k,te=m(L);k=te===null?Y:{...Y,at:te}}switch(k.name){case"mark":return F(A,k.mark);case"link":return ke(A,k.href);case"turnInto":return void uT(A,k.block,k.pos);case"choose":return D(k.index);case"point":if(l)l.index=k.index;return x();case"closeMenu":return XE(A.view,ET);case"addBelow":{let L=O.doc.nodeAt(k.pos);if(!L)return;let Y=O.tr,te=k.pos;if(L.type.name==="textBlock"&&X(L)==="li"){te=k.pos+L.nodeSize;let z=typeof L.attrs.open==="string"?In(L.attrs.open,"li"):void 0;Y.insert(te,pe(A.schema,"li",z))}else if(L.type.name!=="textBlock"||L.content.size>0||Bt.has(X(L)))te=ld(O.doc,k.pos),Y.insert(te,pe(A.schema,"p"));Y.setSelection(I.create(Y.doc,te+1)).insertText("/"),A.view.dispatch(Y.scrollIntoView()),A.view.focus();return}case"duplicate":return void cl(A,k.pos);case"remove":return void dT(A,k.pos);case"move":return void Xo(A,k.pos,k.by);case"pick":{if(!O.doc.nodeAt(k.pos))return;A.view.dispatch(O.tr.setSelection(M.create(O.doc,k.pos)));return}case"drag":{u=!0;let L=dd(A.view,k.pos,k.x,k.y);n({type:"drop",line:L?.line??null});let Y=56;if(k.y<Y)window.scrollBy(0,-Math.ceil((Y-k.y)/3));else if(k.y>window.innerHeight-Y)window.scrollBy(0,Math.ceil((k.y-window.innerHeight+Y)/3));return}case"drop":{let L=dd(A.view,k.pos,k.x,k.y);if(L)fT(A,k.pos,L.at);return u=!1,n({type:"drop",line:null}),x()}case"endDrag":return u=!1,n({type:"drop",line:null}),x();case"image":{if(k.preview)o.set(k.src,URL.createObjectURL(k.preview));let L=A.schema.nodes.image.create({source:Ko("img",{src:k.src,alt:k.alt})}),Y=O.tr,te=k.at??Ze(O.selection)?.pos,z=Y.doc.content.size;if(te===void 0||te===null||!Y.doc.nodeAt(te))Y.insert(z,L);else z=cd(Y,te,L);ud(Y,z),A.view.dispatch(Y.scrollIntoView()),A.view.focus();return}case"focus":A.commands.focus();return}},lt=(A,N,O)=>{P=O.pageBreak;let k=document.createElement("style");k.id="sixb-page-editor",k.textContent=yT,document.head.append(k);let L=t.getAttribute("class");t.replaceChildren();let Y=oT().map((z)=>{if(z.name===il.name)return il.extend({addNodeView:()=>({node:ee})=>bT(ee,!1)});if(z.name===al.name)return al.extend({addNodeView:()=>({node:ee})=>bT(ee,!0)});if(z.name===ol.name)return ol.extend({addNodeView:()=>({node:ee})=>yO(ee,o)});return z});i=new wy({element:{mount:t},injectCSS:!1,editable:N,extensions:[...Y,nE.configure({fragment:A}),iE.configure({provider:{awareness:s},user:{},render:EO,selectionRender:(z)=>({nodeName:"span",class:"sixb-caret-selection",style:`--caret: ${z.color??"#888"}`})}),EE.configure({includeChildren:!0,showOnlyCurrent:!0,placeholder:({node:z})=>TO(z,O)}),mT.configure({toggleMark:F,onLink:()=>n({type:"linkRequest"})}),R,H],editorProps:{attributes:L?{class:L}:{},handleDOMEvents:{click:(z,ee)=>{if(ee.target?.closest?.("a[href]"))ee.preventDefault();return!1}},handlePaste:(z,ee)=>{let Le=ST(ee.clipboardData);if(Le.length===0)return!1;return n({type:"upload",files:Le,at:h(Ze(z.state.selection)?.pos??null)}),!0},handleDrop:(z,ee,Le,Mn)=>{let Rn=ST(ee.dataTransfer);if(Mn||Rn.length===0)return!1;ee.preventDefault();let hl=ul(z,ee.clientX,ee.clientY);return n({type:"upload",files:Rn,at:h(hl?.pos??null)}),!0},transformPastedHTML:(z)=>z.includes("data-pm-slice")?z:xO(z),transformPasted:(z)=>{let ee=r.getMap(Zi),Le=AT(z.content,(Rn)=>SO(Rn,ee));if(Le===z.content)return z;let Mn=_.maxOpen(Le);return new _(Le,Math.min(z.openStart,Mn.openStart),Math.min(z.openEnd,Mn.openEnd))}},onCreate:({editor:z})=>{if(z.isEditable&&A.length===0)z.view.dispatch(z.state.tr.replaceWith(0,z.state.doc.content.size,pe(z.schema,"p")));let ee=U.atStart(z.state.doc);z.view.dispatch(z.state.tr.setSelection(ee).setMeta("addToHistory",!1))},onTransaction:({transaction:z})=>{if(z.docChanged)p(z.mapping);x()},onSelectionUpdate:x,onFocus:()=>{n({type:"focus",focused:!0}),x()},onBlur:()=>n({type:"focus",focused:!1})}),x()};e.onmessage=(A)=>{let N=A.data;switch(N.type){case"start":{oc(r,N.state,Go),a=N.blocks;let O=r.getMap(Zi),k=O.get(N.path);if(!Qi(k)){n({type:"gone"});return}r.on("update",(L,Y)=>{if(Y!==Go)n({type:"update",update:L})}),O.observe((L)=>{if(!L.keysChanged.has(N.path)||O.get(N.path)===k)return;i?.setEditable(!1),n({type:"gone"})}),s.on("update",(L,Y)=>{if(Y===Go)return;n({type:"cursor",cursor:s.getLocalState()?.cursor??null})}),lt(k.get(ao),N.editable,N.words);return}case"update":oc(r,N.update,Go);return;case"awareness":GE(s,N.update,Go);return;case"editable":i?.setEditable(N.editable),x();return;case"run":if(i)qe(i,N.command);return}},n({type:"ready"})}function hO(e){let{selection:t}=e.state;if(!e.isEditable||!(t instanceof I)||t.empty)return null;let n=t.$from.parent;if(n.type.name!=="textBlock"||X(n)==="pre")return null;let r=e.view,s=r.coordsAtPos(t.from),o=r.coordsAtPos(t.to),i=yr(r.nodeDOM(t.$from.before())),a=Math.abs(s.top-o.top)<2,l={left:a?Math.min(s.left,o.left):i?.left??s.left,right:a?Math.max(s.right,o.right):i?.right??o.right,top:Math.min(s.top,o.top),bottom:Math.max(s.bottom,o.bottom)},c=(d)=>d.some((f)=>e.isActive(f)),u=e.isActive("a")?Pt(e.getAttributes("a").open).href??"":null;return{rect:l,marks:{bold:c(bs.bold),italic:c(bs.italic),underline:c(bs.underline),strike:c(bs.strike),code:c(bs.code)},link:u,block:hT(t.$from),turnable:ll(e.state.doc,t.$from.before())}}function pO(e,t){let n=e.coordsAtPos(t);return{left:n.left,top:n.top,right:n.right,bottom:n.bottom}}function mO(e){let t=new Set,n=e.dom.getBoundingClientRect().top+Number.parseFloat(getComputedStyle(e.dom).paddingTop||"0");return e.state.doc.descendants((r,s)=>{if(!r.isBlock)return!1;let o=e.nodeDOM(s);if(!(o instanceof HTMLElement))return!1;let i=o.parentElement;if(i&&/flex|grid/.test(getComputedStyle(i).display))return!1;let a=getComputedStyle(o);if(TT.includes(a.breakBefore)&&o.getBoundingClientRect().top>n+1)t.add(s);if(TT.includes(a.breakAfter))t.add(s+r.nodeSize);return r.type.name==="box"}),[...t].sort((r,s)=>r-s)}function gO(e){let t=document.createElement("div");return t.className="sixb-page-break",t.contentEditable="false",t.setAttribute("aria-hidden","true"),t.setAttribute("data-label",e),t}function bT(e,t){let n=document.createElement("template");n.innerHTML=String(e.attrs.source??""),tT(n.content);let r=Array.from(n.content.childNodes),s=r.length===1&&r[0]instanceof HTMLElement?r[0]:null,o=s??document.createElement(t?"span":"div");if(!s)o.style.display="contents",o.append(...r);return o.setAttribute("data-sixb-raw",""),o.contentEditable="false",{dom:o,ignoreMutation:()=>!0,update:(i)=>i.type===e.type&&i.attrs.source===e.attrs.source}}function yO(e,t){let n=document.createElement("img"),r=(s)=>{let o=Pt(s.attrs.source);for(let a of n.getAttributeNames())if(!(a in o))n.removeAttribute(a);for(let[a,l]of Object.entries(o))n.setAttribute(a,l);let i=t.get(o.src??"");if(i)n.src=i};return r(e),n.draggable=!1,{dom:n,ignoreMutation:()=>!0,update:(s)=>{if(s.type!==e.type)return!1;return r(s),!0}}}function EO(e){let t=document.createElement("span");t.className="sixb-caret",t.style.setProperty("--caret",e.color??"#888");let n=document.createElement("span");return n.className="sixb-caret-label",n.textContent=e.name||"·",t.append(n),t}function TO(e,t){if(e.type.name!=="textBlock")return"";let n=X(e);if(n==="li")return t.listItem;let r=/^h([1-6])$/.exec(n);if(r)return t.headings[Number(r[1])-1]??"";return Bt.has(n)?"":t.placeholder}function ST(e){return Array.from(e?.files??[]).filter((t)=>t.type.startsWith("image/"))}function AT(e,t){let n=!1,r=[];return e.forEach((s)=>{let o=s.attrs.source;if(s.isAtom&&typeof o==="string"&&!bO(o).every(t)){n=!0;return}let i=s.isLeaf?s.content:AT(s.content,t);if(i===s.content){r.push(s);return}if(n=!0,s.isTextblock&&i.size===0)return;let a=s.type.createAndFill(s.attrs,i,s.marks);if(a)r.push(a)}),n?S.from(r):e}function bO(e){let t=document.createElement("template");return t.innerHTML=e,Array.from(t.content.querySelectorAll("img[src]"),(n)=>(n.getAttribute("src")??"").trim())}function SO(e,t){if(Jo(e))return!0;if(e===""||e.startsWith("/")||/^[a-z][a-z\d+.-]*:/i.test(e))return!1;let n=e.split(/[?#]/)[0]??"";try{n=decodeURI(n)}catch{}let r=[];for(let s of n.split("/"))if(s==="..")r.pop();else if(s!==""&&s!==".")r.push(s);return t.has(r.join("/"))}function xO(e){let t=document.createElement("template");t.innerHTML=e;let n=new Set(["href","src","alt","colspan","rowspan"]);for(let r of Array.from(t.content.querySelectorAll("*")))for(let s of r.getAttributeNames())if(!n.has(s))r.removeAttribute(s);return t.innerHTML}var wT="__sixbFrameEditor";globalThis[wT]=xT;})();
|