cli-jaw 2.2.11 → 2.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/commands/doctor.js +20 -0
- package/dist/bin/commands/doctor.js.map +1 -1
- package/dist/bin/commands/init.js +7 -0
- package/dist/bin/commands/init.js.map +1 -1
- package/dist/bin/commands/slack.js +47 -5
- package/dist/bin/commands/slack.js.map +1 -1
- package/dist/bin/commands/tui/slash-command-runner.js +11 -2
- package/dist/bin/commands/tui/slash-command-runner.js.map +1 -1
- package/dist/server.js +18 -2
- package/dist/server.js.map +1 -1
- package/dist/src/agent/error-classifier.js +11 -2
- package/dist/src/agent/error-classifier.js.map +1 -1
- package/dist/src/agent/events/claude.js +7 -1
- package/dist/src/agent/events/claude.js.map +1 -1
- package/dist/src/agent/events/fulltext-bound.js +32 -0
- package/dist/src/agent/events/fulltext-bound.js.map +1 -0
- package/dist/src/agent/events/grok.js +7 -1
- package/dist/src/agent/events/grok.js.map +1 -1
- package/dist/src/agent/events/helpers.js +17 -4
- package/dist/src/agent/events/helpers.js.map +1 -1
- package/dist/src/agent/lifecycle-handler.js +56 -5
- package/dist/src/agent/lifecycle-handler.js.map +1 -1
- package/dist/src/agent/pi-runtime.js +30 -1
- package/dist/src/agent/pi-runtime.js.map +1 -1
- package/dist/src/agent/spawn/exit-drain.js +96 -0
- package/dist/src/agent/spawn/exit-drain.js.map +1 -0
- package/dist/src/agent/spawn/line-buffer.js +26 -0
- package/dist/src/agent/spawn/line-buffer.js.map +1 -0
- package/dist/src/agent/spawn/process-kill.js +31 -0
- package/dist/src/agent/spawn/process-kill.js.map +1 -1
- package/dist/src/agent/spawn.js +80 -23
- package/dist/src/agent/spawn.js.map +1 -1
- package/dist/src/agent/watchdog.js +21 -5
- package/dist/src/agent/watchdog.js.map +1 -1
- package/dist/src/cli/commands.js +68 -15
- package/dist/src/cli/commands.js.map +1 -1
- package/dist/src/cli/opencodex-models.js +67 -14
- package/dist/src/cli/opencodex-models.js.map +1 -1
- package/dist/src/cli/registry-live.js +55 -2
- package/dist/src/cli/registry-live.js.map +1 -1
- package/dist/src/cli/registry.js +8 -2
- package/dist/src/cli/registry.js.map +1 -1
- package/dist/src/core/config.js +26 -1
- package/dist/src/core/config.js.map +1 -1
- package/dist/src/messaging/channel-health.js +6 -0
- package/dist/src/messaging/channel-health.js.map +1 -1
- package/dist/src/messaging/channel-validate.js +85 -0
- package/dist/src/messaging/channel-validate.js.map +1 -0
- package/dist/src/routes/link-preview.js +14 -0
- package/dist/src/routes/link-preview.js.map +1 -1
- package/dist/src/routes/messaging.js +9 -0
- package/dist/src/routes/messaging.js.map +1 -1
- package/dist/src/routes/system.js +5 -0
- package/dist/src/routes/system.js.map +1 -1
- package/dist/src/slack/api.js +32 -3
- package/dist/src/slack/api.js.map +1 -1
- package/dist/src/slack/bot.js +37 -1
- package/dist/src/slack/bot.js.map +1 -1
- package/dist/src/slack/events.js +23 -0
- package/dist/src/slack/events.js.map +1 -1
- package/dist/src/slack/hot-notify.js +33 -0
- package/dist/src/slack/hot-notify.js.map +1 -0
- package/dist/src/slack/manifest.js +2 -1
- package/dist/src/slack/manifest.js.map +1 -1
- package/dist/src/slack/progress.js +98 -0
- package/dist/src/slack/progress.js.map +1 -0
- package/dist/src/slack/send-only-client.js +3 -2
- package/dist/src/slack/send-only-client.js.map +1 -1
- package/dist/src/slack/slack-file.js +4 -2
- package/dist/src/slack/slack-file.js.map +1 -1
- package/package.json +3 -1
- package/public/css/sidebar.css +200 -0
- package/public/dist/assets/Agent-BjbZVZ9p.js +1 -0
- package/public/dist/assets/CodeCanvas-CbfPP7Ad.js +3 -0
- package/public/dist/assets/{DocPanel-DtYwv3n3.js → DocPanel-Dz-J_l5M.js} +1 -1
- package/public/dist/assets/{Heartbeat-vDGhPfct.js → Heartbeat-DDmZARWw.js} +1 -1
- package/public/dist/assets/MarkdownRenderer-CXrilOsG.js +15 -0
- package/public/dist/assets/MarkdownRenderer-DZVh_xX2.js +1 -0
- package/public/dist/assets/{Memory-B_UZ-iCA.js → Memory-CUbviW7N.js} +1 -1
- package/public/dist/assets/{MilkdownWysiwygEditor-BNoLGbFC.js → MilkdownWysiwygEditor-Em7iC6y9.js} +8 -8
- package/public/dist/assets/ModelProvider-ngg8xTuB.js +1 -0
- package/public/dist/assets/{agent-meta-C8DqYXM6.js → agent-meta-Y3DE6sxh.js} +1 -1
- package/public/dist/assets/app-BzD_ZLvt.js +55 -0
- package/public/dist/assets/{app-Nu2VPaO5.css → app-DX4e6isX.css} +1 -1
- package/public/dist/assets/bgtask-badge-Dqbp-Y4e.js +1 -0
- package/public/dist/assets/{bgtask-badge-DXca8E7c.js → bgtask-badge-qMkKOZx0.js} +1 -1
- package/public/dist/assets/{react-dom-AWKMTIe7.js → bounded-set-CFlZiEF4.js} +1 -1
- package/public/dist/assets/{constants-CSZ011-j.js → constants-Df7-7Rky.js} +1 -1
- package/public/dist/assets/{employees-BL4qMxJj.js → employees-BnobWM_2.js} +1 -1
- package/public/dist/assets/{iframe-renderer-DUI0LYBy.js → iframe-renderer-C5vRbbl9.js} +2 -2
- package/public/dist/assets/iframe-renderer-Df4KIVyx.js +1 -0
- package/public/dist/assets/manager-DaN201mN.js +13 -0
- package/public/dist/assets/memory-D-bULTHl.js +1 -0
- package/public/dist/assets/{memory-B_Y0L0KD.js → memory-DF4kPwwC.js} +1 -1
- package/public/dist/assets/{message-history-Dl8dJzez.js → message-history-C4WOisGx.js} +1 -1
- package/public/dist/assets/message-history-ZBoza6ew.js +1 -0
- package/public/dist/assets/{render-BI1aqKoc.js → render-DYX6GRQ0.js} +1 -1
- package/public/dist/assets/{settings-B0Sj4sUH.js → settings-DbJpGoaX.js} +1 -1
- package/public/dist/assets/settings-SreihUje.js +1 -0
- package/public/dist/assets/settings-core-B1Y5Nb4Z.js +1 -0
- package/public/dist/assets/settings-core-DobZWIZ7.js +140 -0
- package/public/dist/assets/{sidebar-DOR9fTgN.js → sidebar-Cp22g0Gv.js} +3 -3
- package/public/dist/assets/skills-DwPIP08e.js +1 -0
- package/public/dist/assets/{skills-wt0fkV9Y.js → skills-IGquen_j.js} +1 -1
- package/public/dist/assets/slash-commands-BBVfwcnW.js +1 -0
- package/public/dist/assets/{slash-commands-BZbqTg3v.js → slash-commands-ZRDOL99E.js} +1 -1
- package/public/dist/assets/{trace-drawer-kMYzaVFW.js → trace-drawer-D8To8fYt.js} +1 -1
- package/public/dist/assets/ui-CAicpUZc.js +1 -0
- package/public/dist/assets/{ui-D4D5HUfo.js → ui-Hx_mNoDf.js} +1 -1
- package/public/dist/assets/{wiki-link-resolver-BfNXN9px.js → wiki-link-resolver-DyFzBTIQ.js} +1 -1
- package/public/dist/index.html +90 -47
- package/public/dist/manager/index.html +1 -1
- package/public/index.html +88 -45
- package/public/js/constants.ts +50 -0
- package/public/js/features/channel-onboarding-flow.ts +197 -0
- package/public/js/features/channel-onboarding.ts +322 -0
- package/public/js/features/channel-setup-guide.ts +26 -0
- package/public/js/features/channel-setup-rules.ts +32 -0
- package/public/js/features/notifications.ts +38 -0
- package/public/js/features/settings-channel.ts +4 -0
- package/public/js/features/settings-core.ts +73 -9
- package/public/js/features/settings-discord.ts +2 -0
- package/public/js/features/settings-slack.ts +60 -2
- package/public/js/features/settings-telegram.ts +2 -0
- package/public/js/features/settings-types.ts +1 -1
- package/public/js/features/settings.ts +1 -1
- package/public/js/features/transport-status-row.ts +7 -3
- package/public/js/main.ts +5 -1
- package/public/locales/en.json +65 -3
- package/public/locales/ja.json +76 -3
- package/public/locales/ko.json +65 -3
- package/public/locales/zh.json +76 -3
- package/public/manager/src/SidebarRailRouter.tsx +9 -3
- package/public/manager/src/browser-panel/use-embedded-target-sync.ts +19 -1
- package/public/manager/src/code/CodeCanvas.tsx +14 -2
- package/public/manager/src/code/CodeTranscript.tsx +33 -9
- package/public/manager/src/code/CodeWorkbench.tsx +1 -1
- package/public/manager/src/code/code-event-dedupe.ts +27 -3
- package/public/manager/src/code/use-code-transcript-scroll.ts +28 -3
- package/public/manager/src/code/use-throttled-markdown.ts +75 -0
- package/public/manager/src/code/useCodeTranscriptVirtualRows.ts +19 -0
- package/public/manager/src/electron-metrics.tsx +7 -0
- package/public/manager/src/jaw-ceo/useJawCeo.ts +6 -1
- package/public/manager/src/jaw-ceo/useJawCeoVirtualTimeline.ts +5 -0
- package/public/manager/src/lib/bounded-set.ts +15 -0
- package/public/manager/src/lib/fnv1a.ts +14 -0
- package/public/manager/src/notes/rendering/CodeBlock.tsx +13 -4
- package/public/manager/src/notes/rendering/MarkdownRenderer.tsx +14 -2
- package/public/manager/src/notes/rendering/highlight-cache.ts +111 -0
- package/public/manager/src/notes/useNotesExternalSync.ts +6 -1
- package/public/manager/src/settings/pages/Agent.tsx +25 -4
- package/public/manager/src/settings/pages/components/PerCliRow.tsx +13 -5
- package/public/manager/src/settings/pages/components/agent/agent-meta.ts +98 -0
- package/scripts/bundle-sidecar.sh +8 -0
- package/scripts/check-electron-no-native.cjs +90 -4
- package/scripts/check-native-load.cjs +157 -0
- package/scripts/check-sidecar-smoke.mjs +151 -0
- package/scripts/ensure-native-modules.cjs +222 -18
- package/scripts/release-gates.mjs +29 -0
- package/public/dist/assets/Agent-BgkP4EnS.js +0 -1
- package/public/dist/assets/CodeCanvas-BZo3dohZ.js +0 -3
- package/public/dist/assets/MarkdownRenderer-CHacL2M_.js +0 -15
- package/public/dist/assets/MarkdownRenderer-DyrB9FbZ.js +0 -1
- package/public/dist/assets/ModelProvider-CgUvs6pE.js +0 -1
- package/public/dist/assets/app-BGIAy4he.js +0 -55
- package/public/dist/assets/bgtask-badge-GRSiNILQ.js +0 -1
- package/public/dist/assets/iframe-renderer-BUSk0Rw9.js +0 -1
- package/public/dist/assets/manager-B-gpf-3j.js +0 -13
- package/public/dist/assets/memory-CX6YahTc.js +0 -1
- package/public/dist/assets/message-history-Det7u76S.js +0 -1
- package/public/dist/assets/settings-C7NutP6X.js +0 -1
- package/public/dist/assets/settings-core-CyX-px6_.js +0 -100
- package/public/dist/assets/settings-core-DVpFmrhY.js +0 -1
- package/public/dist/assets/skills-BWhKreQ2.js +0 -1
- package/public/dist/assets/slash-commands-Di4NDA4w.js +0 -1
- package/public/dist/assets/ui-BghexWrB.js +0 -1
package/public/dist/assets/{MilkdownWysiwygEditor-BNoLGbFC.js → MilkdownWysiwygEditor-Em7iC6y9.js}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XQCOJYun.js";import{A as t}from"./vendor-render-DCb9B75Q.js";import{n,t as r}from"./jsx-runtime-gFMgZ0TQ.js";import{t as i}from"./copy-text-BDs2wKjA.js";import{n as a,t as o}from"./w3c-keyname-a_sRwNLm.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XQCOJYun.js";import{A as t}from"./vendor-render-DCb9B75Q.js";import{n,t as r}from"./jsx-runtime-gFMgZ0TQ.js";import{t as i}from"./copy-text-BDs2wKjA.js";import{n as a,t as o}from"./w3c-keyname-a_sRwNLm.js";import{E as s,O as c,S as l,T as u,_ as d,a as f,d as p,g as m,h,i as g,k as _,l as v,m as y,o as b,p as x,t as S,u as ee,v as te,w as ne,y as re}from"./wiki-link-resolver-DyFzBTIQ.js";import{n as C,o as ie,r as ae,s as oe,t as se}from"./wiki-link-suggestions-DZQc78gj.js";import{M as ce}from"./vendor-utils-DJY0EWnQ.js";var le={}.hasOwnProperty;function ue(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&le.call(t,e)){let n=String(t[e]);i=le.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var de={}.hasOwnProperty;function fe(e,t){let n=-1,r;if(t.extensions)for(;++n<t.extensions.length;)fe(e,t.extensions[n]);for(r in t)if(de.call(t,r))switch(r){case`extensions`:break;case`unsafe`:pe(e[r],t[r]);break;case`join`:pe(e[r],t[r]);break;case`handlers`:me(e[r],t[r]);break;default:e.options[r]=t[r]}return e}function pe(e,t){t&&e.push(...t)}function me(e,t){t&&Object.assign(e,t)}var he=[ge];function ge(e,t,n,r){if(t.type===`code`&&te(t,r)&&(e.type===`list`||e.type===t.type&&te(e,r)))return!1;if(`spread`in n&&typeof n.spread==`boolean`)return e.type===`paragraph`&&(e.type===t.type||t.type===`definition`||t.type===`heading`&&m(t,r))?void 0:+!!n.spread}var _e=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`],ve=[{character:` `,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,before:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`]},{character:`\r`,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`,`codeFencedMetaGraveAccent`,`codeFencedMetaTilde`,`destinationLiteral`,`headingAtx`]},{character:`
|
|
2
2
|
`,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`,`codeFencedMetaGraveAccent`,`codeFencedMetaTilde`,`destinationLiteral`,`headingAtx`]},{character:` `,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,before:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`]},{character:`!`,after:`\\[`,inConstruct:`phrasing`,notInConstruct:_e},{character:`"`,inConstruct:`titleQuote`},{atBreak:!0,character:`#`},{character:`#`,inConstruct:`headingAtx`,after:`(?:[\r
|
|
3
3
|
]|$)`},{character:`&`,after:`[#A-Za-z]`,inConstruct:`phrasing`},{character:`'`,inConstruct:`titleApostrophe`},{character:`(`,inConstruct:`destinationRaw`},{before:`\\]`,character:`(`,inConstruct:`phrasing`,notInConstruct:_e},{atBreak:!0,before:`\\d+`,character:`)`},{character:`)`,inConstruct:`destinationRaw`},{atBreak:!0,character:`*`,after:`(?:[ \r
|
|
4
4
|
*])`},{character:`*`,inConstruct:`phrasing`,notInConstruct:_e},{atBreak:!0,character:`+`,after:`(?:[ \r
|
|
5
5
|
])`},{atBreak:!0,character:`-`,after:`(?:[ \r
|
|
6
6
|
-])`},{atBreak:!0,before:`\\d+`,character:`.`,after:`(?:[ \r
|
|
7
|
-
]|$)`},{atBreak:!0,character:`<`,after:`[!/?A-Za-z]`},{character:`<`,after:`[!/?A-Za-z]`,inConstruct:`phrasing`,notInConstruct:_e},{character:`<`,inConstruct:`destinationLiteral`},{atBreak:!0,character:`=`},{atBreak:!0,character:`>`},{character:`>`,inConstruct:`destinationLiteral`},{atBreak:!0,character:`[`},{character:`[`,inConstruct:`phrasing`,notInConstruct:_e},{character:`[`,inConstruct:[`label`,`reference`]},{character:`\\`,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:`]`,inConstruct:[`label`,`reference`]},{atBreak:!0,character:`_`},{character:`_`,inConstruct:`phrasing`,notInConstruct:_e},{atBreak:!0,character:"`"},{character:"`",inConstruct:[`codeFencedLangGraveAccent`,`codeFencedMetaGraveAccent`]},{character:"`",inConstruct:`phrasing`,notInConstruct:_e},{atBreak:!0,character:`~`}];function ye(e){return e.label||!e.identifier?e.label||``:
|
|
8
|
-
`)&&u.type===`html`&&(a[a.length-1]=a[a.length-1].replace(/(\r?\n|\r)$/,` `),s=` `,l=t.createTracker(n),l.move(a.join(``)));let
|
|
7
|
+
]|$)`},{atBreak:!0,character:`<`,after:`[!/?A-Za-z]`},{character:`<`,after:`[!/?A-Za-z]`,inConstruct:`phrasing`,notInConstruct:_e},{character:`<`,inConstruct:`destinationLiteral`},{atBreak:!0,character:`=`},{atBreak:!0,character:`>`},{character:`>`,inConstruct:`destinationLiteral`},{atBreak:!0,character:`[`},{character:`[`,inConstruct:`phrasing`,notInConstruct:_e},{character:`[`,inConstruct:[`label`,`reference`]},{character:`\\`,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:`]`,inConstruct:[`label`,`reference`]},{atBreak:!0,character:`_`},{character:`_`,inConstruct:`phrasing`,notInConstruct:_e},{atBreak:!0,character:"`"},{character:"`",inConstruct:[`codeFencedLangGraveAccent`,`codeFencedMetaGraveAccent`]},{character:"`",inConstruct:`phrasing`,notInConstruct:_e},{atBreak:!0,character:`~`}];function ye(e){return e.label||!e.identifier?e.label||``:_(e.identifier)}function be(e){if(!e._compiled){let t=(e.atBreak?`[\\r\\n][\\t ]*`:``)+(e.before?`(?:`+e.before+`)`:``);e._compiled=RegExp((t?`(`+t+`)`:``)+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?`\\`:``)+e.character+(e.after?`(?:`+e.after+`)`:``),`g`)}return e._compiled}function xe(e,t,n){let r=t.indexStack,i=e.children||[],a=[],o=-1,s=n.before,c;r.push(-1);let l=t.createTracker(n);for(;++o<i.length;){let u=i[o],f;if(r[r.length-1]=o,o+1<i.length){let n=t.handle.handlers[i[o+1].type];n&&n.peek&&(n=n.peek),f=n?n(i[o+1],e,t,{before:``,after:``,...l.current()}).charAt(0):``}else f=n.after;a.length>0&&(s===`\r`||s===`
|
|
8
|
+
`)&&u.type===`html`&&(a[a.length-1]=a[a.length-1].replace(/(\r?\n|\r)$/,` `),s=` `,l=t.createTracker(n),l.move(a.join(``)));let p=t.handle(u,e,t,{...l.current(),after:f,before:s});c&&c===p.slice(0,1)&&(p=d(c.charCodeAt(0))+p.slice(1));let m=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,c=void 0,m&&(a.length>0&&m.before&&s===a[a.length-1].slice(-1)&&(a[a.length-1]=a[a.length-1].slice(0,-1)+d(s.charCodeAt(0))),m.after&&(c=f)),l.move(p),a.push(p),s=p.slice(-1)}return r.pop(),a.join(``)}function Se(e,t,n){let r=t.indexStack,i=e.children||[],a=t.createTracker(n),o=[],s=-1;for(r.push(-1);++s<i.length;){let n=i[s];r[r.length-1]=s,o.push(a.move(t.handle(n,e,t,{before:`
|
|
9
9
|
`,after:`
|
|
10
10
|
`,...a.current()}))),n.type!==`list`&&(t.bulletLastUsed=void 0),s<i.length-1&&o.push(a.move(Ce(n,i[s+1],e,t)))}return r.pop(),o.join(``)}function Ce(e,t,n,r){let i=r.join.length;for(;i--;){let a=r.join[i](e,t,n,r);if(a===!0||a===1)break;if(typeof a==`number`)return`
|
|
11
11
|
`.repeat(1+a);if(a===!1)return`
|
|
@@ -14,7 +14,7 @@ import{r as e}from"./rolldown-runtime-XQCOJYun.js";import{A as t}from"./vendor-r
|
|
|
14
14
|
|
|
15
15
|
`}return`
|
|
16
16
|
|
|
17
|
-
`}var we=/\r?\n|\r/g;function Te(e,t){let n=[],r=0,i=0,a;for(;a=we.exec(e);)o(e.slice(r,a.index)),n.push(a[0]),r=a.index+a[0].length,i++;return o(e.slice(r)),n.join(``);function o(e){n.push(t(e,i,!e))}}function Ee(e,t,n){let r=(n.before||``)+(t||``)+(n.after||``),i=[],a=[],o={},s=-1;for(;++s<e.unsafe.length;){let t=e.unsafe[s];if(!
|
|
17
|
+
`}var we=/\r?\n|\r/g;function Te(e,t){let n=[],r=0,i=0,a;for(;a=we.exec(e);)o(e.slice(r,a.index)),n.push(a[0]),r=a.index+a[0].length,i++;return o(e.slice(r)),n.join(``);function o(e){n.push(t(e,i,!e))}}function Ee(e,t,n){let r=(n.before||``)+(t||``)+(n.after||``),i=[],a=[],o={},s=-1;for(;++s<e.unsafe.length;){let t=e.unsafe[s];if(!re(e.stack,t))continue;let n=e.compilePattern(t),a;for(;a=n.exec(r);){let e=`before`in t||!!t.atBreak,n=`after`in t,r=a.index+(e?a[1].length:0);i.includes(r)?(o[r].before&&!e&&(o[r].before=!1),o[r].after&&!n&&(o[r].after=!1)):(i.push(r),o[r]={before:e,after:n})}}i.sort(De);let c=n.before?n.before.length:0,l=r.length-(n.after?n.after.length:0);for(s=-1;++s<i.length;){let e=i[s];e<c||e>=l||e+1<l&&i[s+1]===e+1&&o[e].after&&!o[e+1].before&&!o[e+1].after||i[s-1]===e-1&&o[e].before&&!o[e-1].before&&!o[e-1].after||(c!==e&&a.push(Oe(r.slice(c,e),`\\`)),c=e,/[!-/:-@[-`{-~]/.test(r.charAt(e))&&(!n.encode||!n.encode.includes(r.charAt(e)))?a.push(`\\`):(a.push(d(r.charCodeAt(e))),c++))}return a.push(Oe(r.slice(c,l),n.after)),a.join(``)}function De(e,t){return e-t}function Oe(e,t){let n=/\\(?=[!-/:-@[-`{-~])/g,r=[],i=[],a=e+t,o=-1,s=0,c;for(;c=n.exec(a);)r.push(c.index);for(;++o<r.length;)s!==r[o]&&i.push(e.slice(s,r[o])),i.push(`\\`),s=r[o];return i.push(e.slice(s)),i.join(``)}function ke(e){let t=e||{},n=t.now||{},r=t.lineShift||0,i=n.line||1,a=n.column||1;return{move:c,current:o,shift:s};function o(){return{now:{line:i,column:a},lineShift:r}}function s(e){r+=e}function c(e){let t=e||``,n=t.split(/\r?\n|\r/g),o=n[n.length-1];return i+=n.length-1,a=n.length===1?a+o.length:1+o.length+r,t}}function Ae(e,t){let n=t||{},r={associationId:ye,containerPhrasing:Pe,containerFlow:Fe,createTracker:ke,compilePattern:be,enter:a,handlers:{...h},handle:void 0,indentLines:Te,indexStack:[],join:[...he],options:{},safe:Ie,stack:[],unsafe:[...ve]};fe(r,n),r.options.tightDefinitions&&r.join.push(Ne),r.handle=ue(`type`,{invalid:je,unknown:Me,handlers:r.handlers});let i=r.handle(e,void 0,r,{before:`
|
|
18
18
|
`,after:`
|
|
19
19
|
`,now:{line:1,column:1},lineShift:0});return i&&i.charCodeAt(i.length-1)!==10&&i.charCodeAt(i.length-1)!==13&&(i+=`
|
|
20
20
|
`),i;function a(e){return r.stack.push(e),t;function t(){r.stack.pop()}}}function je(e){throw Error("Cannot handle value `"+e+"`, expected node")}function Me(e){throw Error("Cannot handle unknown node `"+e.type+"`")}function Ne(e,t){if(e.type===`definition`&&e.type===t.type)return 0}function Pe(e,t){return xe(e,this,t)}function Fe(e,t){return Se(e,this,t)}function Ie(e,t){return Ee(this,e,t)}var Le=function(e){return e.docTypeError=`docTypeError`,e.contextNotFound=`contextNotFound`,e.timerNotFound=`timerNotFound`,e.ctxCallOutOfScope=`ctxCallOutOfScope`,e.createNodeInParserFail=`createNodeInParserFail`,e.stackOverFlow=`stackOverFlow`,e.parserMatchError=`parserMatchError`,e.serializerMatchError=`serializerMatchError`,e.getAtomFromSchemaFail=`getAtomFromSchemaFail`,e.expectDomTypeError=`expectDomTypeError`,e.callCommandBeforeEditorView=`callCommandBeforeEditorView`,e.missingRootElement=`missingRootElement`,e.missingNodeInSchema=`missingNodeInSchema`,e.missingMarkInSchema=`missingMarkInSchema`,e.ctxNotBind=`ctxNotBind`,e.missingYjsDoc=`missingYjsDoc`,e}({}),Re=class extends Error{constructor(e,t){super(t),this.name=`MilkdownError`,this.code=e}},ze=(e,t)=>typeof t==`function`?`[Function]`:t,Be=e=>JSON.stringify(e,ze);function Ve(e){return new Re(Le.docTypeError,`Doc type error, unsupported type: ${Be(e)}`)}function He(e){return new Re(Le.contextNotFound,`Context "${e}" not found, do you forget to inject it?`)}function Ue(e){return new Re(Le.timerNotFound,`Timer "${e}" not found, do you forget to record it?`)}function We(){return new Re(Le.ctxCallOutOfScope,`Should not call a context out of the plugin.`)}function Ge(e,t,n){let r=`Cannot create node for ${`name`in e?e.name:e}`,i=e=>{if(e==null)return`null`;if(Array.isArray(e))return`[${e.map(i).join(`, `)}]`;if(typeof e==`object`)return`toJSON`in e&&typeof e.toJSON==`function`?JSON.stringify(e.toJSON()):`spec`in e?JSON.stringify(e.spec):JSON.stringify(e);if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return JSON.stringify(e);if(typeof e==`function`)return`[Function: ${e.name||`anonymous`}]`;try{return String(e)}catch{return`[Unserializable]`}},a=[[`[Description]`,r],[`[Attributes]`,t],[`[Content]`,(n??[]).map(e=>e?typeof e==`object`&&`type`in e?`${e}`:i(e):`null`)]].reduce((e,[t,n])=>{let r=`${t}: ${i(n)}.`;return e.concat(r)},[]);return new Re(Le.createNodeInParserFail,a.join(`
|
|
@@ -28,9 +28,9 @@ import{r as e}from"./rolldown-runtime-XQCOJYun.js";import{A as t}from"./vendor-r
|
|
|
28
28
|
`),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:P(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(ao&&l.focusNode&&l.focusNode!=s.node&&l.focusNode.nodeType==1){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&co)&&za(o.node,o.offset,l.anchorNode,l.anchorOffset)&&za(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&ao)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?Xo:Yo,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Zo:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Xo:Zo}n=a}this.dirty=Xo}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Xo:Yo;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},$o=class extends Qo{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Jo&&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}},es=class extends Qo{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},ts=class e extends Qo{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=wn.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Zo||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Zo&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Jo){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=Jo}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=Cs(a,n,o,r)),t>0&&(a=Cs(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},ns=class e extends Qo{constructor(e,t,n,r,i,a,o,s,c){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=wn.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=ms(u,r,n),l?c=new ss(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new is(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(e.preserveWhitespace=`full`),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>E.empty)}return e}matchesNode(e,t,n){return this.dirty==Jo&&e.eq(this.node)&&hs(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new _s(this,a&&a.node,e);bs(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?D.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==Xo)&&(a&&this.protectLocalComposition(e,a),cs(this.contentDOM,this.children,e),lo&&xs(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof A)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=Ss(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new es(this,i,t,r);e.input.compositionNodes.push(a),this.children=Cs(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==Zo||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Jo}updateOuterDeco(e){if(hs(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=fs(this.dom,this.nodeDOM,ds(this.outerDeco,this.node,t),ds(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function rs(e,t,n,r,i){ms(r,t,e);let a=new ns(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var is=class e extends ns{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==Zo||this.dirty!=Jo&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Jo||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Jo,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Zo)}get domAtom(){return!1}isText(e){return this.node.text==e}},as=class extends Qo{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Jo&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},ss=class extends ns{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==Zo)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function cs(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=gs(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof ts){let t=r?r.previousSibling:e.lastChild;cs(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=gs(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var ls=function(e){e&&(this.nodeName=e)};ls.prototype=Object.create(null);var us=[new ls];function ds(e,t,n){if(e.length==0)return us;let r=n?us[0]:new ls,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new ls(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new ls(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function fs(e,t,n,r){if(n==us&&r==us)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName?i=t:(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=us[0],i=t)}ps(i,o||us[0],a)}return i}function ps(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function ms(e,t,n){return fs(e,e,us,ds(t,n,e.nodeType!=1))}function hs(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 gs(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var _s=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=vs(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=Jo,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=ts.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==Zo&&a.dom==a.contentDOM&&(a.dirty=Xo),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof ns){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=Zo&&hs(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Xo,u.updateChildren(r,a+1),u.dirty=Jo),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!hs(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=ns.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=ns.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new $o(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ts;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof is)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((co||F)&&e&&e.dom.contentEditable==`false`&&this.addHackNode(`IMG`,t),this.addHackNode(`BR`,this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new as(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function vs(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];outer:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof ts)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function ys(e,t){return e.type.side-t.type.side}function bs(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u)if(d){d.sort(ys);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function xs(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 Ss(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function Cs(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function ws(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(qa(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&j.isSelectable(e)&&i.parent&&!(e.isInline&&Ga(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new j(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=Fs(e,u,s,n)}return l}function Ts(e){return e.editable?e.hasFocus():Ls(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Es(e,t=!1){let n=e.state.selection;if(Ns(e,n),Ts(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&F){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&za(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)Ms(e);else{let{anchor:r,head:i}=n,a,o;Ds&&!(n instanceof A)&&(n.$from.parent.inlineContent||(a=Os(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Os(e,n.to))),e.docView.setSelection(r,i,e,t),Ds&&(a&&As(a),o&&As(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&js(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var Ds=co||F&&so<63;function Os(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(co&&i&&i.contentEditable==`false`)return ks(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return ks(i);if(a)return ks(a)}}function ks(e){return e.contentEditable=`true`,co&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function As(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function js(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!Ts(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function Ms(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,P(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&ro&&io<=11&&(n.disabled=!0,n.disabled=!1)}function Ns(e,t){if(t instanceof j){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Ps(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Ps(e)}function Ps(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function Fs(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||A.between(t,n,r)}function Is(e){return e.editable&&!e.hasFocus()?!1:Ls(e)}function Ls(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Rs(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return za(t.node,t.offset,n.anchorNode,n.anchorOffset)}function zs(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&k.findFrom(a,t)}function Bs(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Vs(e,t,n){let r=e.state.selection;if(r instanceof A){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Bs(e,new A(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=zs(e.state,t);return n&&n instanceof j?Bs(e,n):!1}else if(!(uo&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?j.isSelectable(i)?Bs(e,new j(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):mo?Bs(e,new A(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof j&&r.node.isInline)return Bs(e,new A(t>0?r.$to:r.$from));else{let n=zs(e.state,t);return n?Bs(e,n):!1}}function Hs(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Us(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function Ws(e,t){return t<0?Gs(e):Ks(e)}function Gs(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(ao&&n.nodeType==1&&r<Hs(n)&&Us(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(Us(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(qs(n))break;else{let t=n.previousSibling;for(;t&&Us(t,-1);)i=n.parentNode,a=P(t),t=t.previousSibling;if(t)n=t,r=Hs(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?Xs(e,n,r):i&&Xs(e,i,a)}function Ks(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=Hs(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(Us(e,1))a=n,o=++r;else break}else if(qs(n))break;else{let t=n.nextSibling;for(;t&&Us(t,1);)a=t.parentNode,o=P(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=Hs(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&Xs(e,a,o)}function qs(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Js(e,t){for(;e&&t==e.childNodes.length&&!Ka(e);)t=P(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=0}}function Ys(e,t){for(;e&&!t&&!Ka(e);)t=P(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function Xs(e,t,n){if(t.nodeType!=3){let e,r;(r=Js(t,n))?(t=r,n=0):(e=Ys(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(qa(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&Es(e)},50)}function Zs(e,t){let n=e.state.doc.resolve(t);if(!(F||fo)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?`ltr`:`rtl`}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function Qs(e,t,n){let r=e.state.selection;if(r instanceof A&&!r.empty||n.indexOf(`s`)>-1||uo&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=zs(e.state,t);if(n&&n instanceof j)return Bs(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof Yr?k.near(n,t):k.findFrom(n,t);return o?Bs(e,o):!1}return!1}function $s(e,t){if(!(e.state.selection instanceof A))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function ec(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function tc(e){if(!co||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;ec(e,n,`true`),setTimeout(()=>ec(e,n,`false`),20)}return!1}function nc(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function rc(e,t){let n=t.keyCode,r=nc(t);if(n==8||uo&&n==72&&r==`c`)return $s(e,-1)||Ws(e,-1);if(n==46&&!t.shiftKey||uo&&n==68&&r==`c`)return $s(e,1)||Ws(e,1);if(n==13||n==27)return!0;if(n==37||uo&&n==66&&r==`c`){let t=n==37?Zs(e,e.state.selection.from)==`ltr`?-1:1:-1;return Vs(e,t,r)||Ws(e,t)}else if(n==39||uo&&n==70&&r==`c`){let t=n==39?Zs(e,e.state.selection.from)==`ltr`?1:-1:1;return Vs(e,t,r)||Ws(e,t)}else if(n==38||uo&&n==80&&r==`c`)return Qs(e,-1,r)||Ws(e,-1);else if(n==40||uo&&n==78&&r==`c`)return tc(e)||Qs(e,1,r)||Ws(e,1);else if(r==(uo?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function ic(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||wn.fromSchema(e.state.schema),s=hc(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=pc[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
|
|
29
29
|
|
|
30
30
|
`),slice:t}}function ac(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new O(E.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
31
|
-
`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=wn.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=vc(n),mo&&yc(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||un.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!oc.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=bc(fc(s,+u[1],+u[2]),u[4]);else if(s=O.maxOpen(sc(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=fc(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var oc=/^(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 sc(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&lc(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=uc(a[a.length-1],i.length));let n=cc(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return E.from(a)}return e}function cc(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,E.from(e));return e}function lc(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=lc(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(E.from(cc(n,e,i+1))))}}function uc(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,uc(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(E.empty,!0);return e.copy(n.append(r))}function dc(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=dc(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(E.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function fc(e,t,n){return t<e.openStart&&(e=new O(dc(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new O(dc(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var pc={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},mc=null;function hc(){return mc||=document.implementation.createHTMLDocument(`title`)}var gc=null;function _c(e){let t=window.trustedTypes;return t?(gc||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),gc.createHTML(e)):e}function vc(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=hc().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&pc[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=_c(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function yc(e){let t=e.querySelectorAll(F?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function bc(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=E.from(t.create(r[e+1],i)),a++,o++}return new O(i,a,o)}var xc={},Sc={},Cc={touchstart:!0,touchmove:!0},wc=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Tc(e){for(let t in xc){let n=xc[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{Ac(e,t)&&!kc(e,t)&&(e.editable||!(t.type in Sc))&&n(e,t)},Cc[t]?{passive:!0}:void 0)}co&&e.dom.addEventListener(`input`,()=>null),Oc(e)}function Ec(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Dc(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function Oc(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>kc(e,t))})}function kc(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function Ac(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 jc(e,t){!kc(e,t)&&xc[t.type]&&(e.editable||!(t.type in Sc))&&xc[t.type](e,t)}Sc.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Gc(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(po&&F&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),lo&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,Ja(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||rc(e,n)?n.preventDefault():Ec(e,`key`)},Sc.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},Sc.keypress=(e,t)=>{let n=t;if(Gc(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||uo&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof A)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function Mc(e){return{left:e.clientX,top:e.clientY}}function Nc(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Pc(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function Fc(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function Ic(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&j.isSelectable(r)?(Fc(e,new j(n),`pointer`),!0):!1}function Lc(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof j&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(j.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(Fc(e,j.create(e.state.doc,i),`pointer`),!0)}function Rc(e,t,n,r,i){return Pc(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?Lc(e,n):Ic(e,n))}function zc(e,t,n,r){return Pc(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Bc(e,t,n,r){return Pc(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Vc(e,n,r)}function Vc(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(Fc(e,A.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)Fc(e,A.create(r,a+1,a+1+n.content.size),`pointer`);else if(j.isSelectable(n))Fc(e,j.create(r,a),`pointer`);else continue;return!0}}function Hc(e){return Qc(e)}var Uc=uo?`metaKey`:`ctrlKey`;xc.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Hc(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&Nc(n,e.input.lastClick)&&!n[Uc]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(Mc(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Wc(e,o,n,!!r)):(a==`doubleClick`?zc:Bc)(e,o.pos,o.inside,n)?n.preventDefault():Ec(e,`pointer`))};var Wc=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Uc],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof j&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ao&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this)),Ec(e,`pointer`)}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Es(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Mc(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ec(this.view,`pointer`):Rc(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||co&&this.mightDrag&&!this.mightDrag.node.isAtom||F&&!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)?(Fc(this.view,k.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):Ec(this.view,`pointer`)}move(e){this.updateAllowDefault(e),Ec(this.view,`pointer`),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};xc.touchstart=e=>{e.input.lastTouch=Date.now(),Hc(e),Ec(e,`pointer`)},xc.touchmove=e=>{e.input.lastTouch=Date.now(),Ec(e,`pointer`)},xc.contextmenu=e=>Hc(e);function Gc(e,t){return e.composing?!0:co&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Kc=po?5e3:-1;Sc.compositionstart=Sc.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof A&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||F&&fo&&qc(e)))e.markCursor=e.state.storedMarks||n.marks(),Qc(e,!0),e.markCursor=null;else if(Qc(e,!t.selection.empty),ao&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}Jc(e,Kc)};function qc(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}Sc.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Jc(e,20))};function Jc(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Qc(e),t))}function Yc(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Zc());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Xc(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Ua(t.focusNode,t.focusOffset),r=Wa(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function Zc(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function Qc(e,t=!1){if(!(po&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Yc(e),t||e.docView&&e.docView.dirty){let n=ws(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function $c(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var el=ro&&io<15||lo&&ho<604;xc.copy=Sc.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=el?null:n.clipboardData,{dom:o,text:s}=ic(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):$c(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function tl(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function nl(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?rl(e,r.value,null,i,t):rl(e,r.textContent,r.innerHTML,i,t)},50)}function rl(e,t,n,r,i){let a=ac(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||O.empty)))return!0;if(!a)return!1;let o=tl(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function il(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,` `):``}Sc.paste=(e,t)=>{let n=t;if(e.composing&&!po)return;let r=el?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&rl(e,il(r),r.getData(`text/html`),i,n)?n.preventDefault():nl(e,n)};var al=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},ol=uo?`altKey`:`ctrlKey`;function sl(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[ol]:!n}xc.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(Mc(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof j?i.to-1:i.to))){if(r&&r.mightDrag)o=j.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=j.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=ic(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!F||so>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(el?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,el||n.dataTransfer.setData(`text/plain`,c),e.dragging=new al(l,sl(e,n),o)},xc.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},Sc.dragover=Sc.dragenter=(e,t)=>t.preventDefault(),Sc.drop=(e,t)=>{try{cl(e,t,e.dragging)}finally{e.dragging=null}};function cl(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Mc(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=ac(e,il(t.dataTransfer),el?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&sl(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||O.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?Cr(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&j.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new j(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(Fs(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}xc.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Es(e)},20))},xc.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},xc.beforeinput=(e,t)=>{if(F&&po&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,Ja(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in Sc)xc[e]=Sc[e];function ll(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var ul=class e{constructor(e,t){this.toDOM=e,this.spec=t||hl,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new pl(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&ll(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},dl=class e{constructor(e,t){this.attrs=e,this.spec=t||hl}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new pl(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&ll(this.attrs,t.attrs)&&ll(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},fl=class e{constructor(e,t){this.attrs=e,this.spec=t||hl}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new pl(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&ll(this.attrs,t.attrs)&&ll(this.spec,t.spec)}destroy(){}},pl=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new ul(n,r))}static inline(t,n,r,i){return new e(t,n,new dl(r,i))}static node(t,n,r,i){return new e(t,n,new fl(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof dl}get widget(){return this.type instanceof ul}},ml=[],hl={},I=class e{constructor(e,t){this.local=e.length?e:ml,this.children=t.length?t:ml}static create(e,t){return t.length?Cl(t,e,0,hl):gl}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==gl||e.maps.length==0?this:this.mapInner(e,t,0,0,n||hl)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?vl(this.children,o||[],t,n,r,i,a):o?new e(o.sort(wl),ml):gl}add(t,n){return n.length?this==gl?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=xl(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,Cl(s,e,o+1,hl)),a+=3}});let o=yl(a?Sl(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(wl):this.local,i||this.children)}remove(e){return e.length==0||this==gl?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==gl?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):gl}forChild(t,n){if(this==gl)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof dl){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(wl),ml);return r?new _l([t,r]):t}return r||gl}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return Tl(this.localsInner(e))}localsInner(e){if(this==gl)return ml;if(e.inlineContent||!this.local.some(dl.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof dl||t.push(this.local[e]);return t}forEachSet(e){e(this)}};I.empty=new I([],[]),I.removeOverlap=Tl;var gl=I.empty,_l=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,hl));return e.from(r)}forChild(t,n){if(n.isLeaf)return I.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=gl&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?Tl(n?t:t.sort(wl)):ml}static from(t){switch(t.length){case 0:return gl;case 1:return t[0];default:return new e(t.every(e=>e instanceof I)?t:t.reduce((e,t)=>e.concat(t instanceof I?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function vl(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==gl?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=Cl(bl(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new I(t.sort(wl),s)}function yl(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new pl(i.from+t,i.to+t,i.type))}return n}function bl(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function xl(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function Sl(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function Cl(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=xl(e,t,o+n);if(s){a=!0;let e=Cl(s,t,n+o+1,r);e!=gl&&i.push(o,o+t.nodeSize,e)}});let o=yl(a?Sl(e):e,-n).sort(wl);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new I(o,i):gl}function wl(e,t){return e.from-t.from||e.to-t.to}function Tl(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),El(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),El(t,i,r.copy(a.from,r.to)));break}}}return t}function El(e,t,n){for(;t<e.length&&wl(n,e[t])>0;)t++;e.splice(t,0,n)}function Dl(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=gl&&t.push(r)}),e.cursorWrapper&&t.push(I.create(e.state.doc,[e.cursorWrapper.deco])),_l.from(t)}var Ol={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},kl=ro&&io<=11,Al=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},jl=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Al,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);ro&&io<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():co&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),kl&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Ol)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Is(this.view)){if(this.suppressingSelectionUpdates)return Es(this.view);if(ro&&io<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&za(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=Fa(n))t.add(n);for(let r=e.anchorNode;r;r=Fa(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Is(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(ao&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Ll(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&qa(n)&&(c=ws(e))&&c.eq(k.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Es(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Pl(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Rl(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Es(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(ro&&io<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?P(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?P(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},Ml=new WeakMap,Nl=!1;function Pl(e){if(!Ml.has(e)&&(Ml.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=ao,Nl)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.`),Nl=!0}}function Fl(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return za(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Il(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Fl(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?Fl(e,n):null}function Ll(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Rl(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function zl(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,u=c.anchorNode;if(u&&e.dom.contains(u.nodeType==1?u:u.parentNode)&&(l=[{node:u,offset:c.anchorOffset}],qa(c)||l.push({node:c.focusNode,offset:c.focusOffset})),F&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||un.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:Bl,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function Bl(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(co&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||co&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var Vl=/^(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 Hl(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=ws(e,t);if(n&&!e.state.selection.eq(n)){if(F&&po&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,Ja(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=zl(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=ql(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(lo&&e.input.lastIOSEnter>Date.now()-225||po)&&i.some(e=>e.nodeType==1&&!Vl.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,Ja(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof A&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Ul(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof A&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),ro&&io<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((lo&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,Ja(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&Gl(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,Ja(8,`Backspace`)))){po&&F&&e.domObserver.suppressSelectionUpdates();return}F&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),po&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,Ja(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Ul(e,n.doc,l.sel);t&&!(F&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||ro&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},S;if(v)if(h.pos==g.pos){ro&&io<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>Es(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=Wl(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function Ul(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Fs(e,t.resolve(n.anchor),t.resolve(n.head))}function Wl(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(E.from(l).eq(e))return{mark:s,type:o}}function Gl(e,t,n,r,i){if(n-t<=i.pos-r.pos||Kl(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(Kl(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Kl(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Kl(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function ql(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&Jl(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&Jl(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function Jl(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var Yl=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new wc,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(nu),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Ql(this),Zl(this),this.nodeViews=eu(this),this.docView=rs(this.state.doc,Xl(this),Dl(this),this.dom,this),this.domObserver=new jl(this,(e,t,n,r)=>Hl(this,e,t,n,r)),this.domObserver.start(),Tc(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Oc(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(nu),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Yc(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=eu(this);tu(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Oc(this),this.editable=Ql(this),Zl(this);let o=Dl(this),s=Xl(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&bo(this);if(i){this.domObserver.stop();let t=l&&(ro||F)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&$l(n.selection,e.selection);if(l){let n=F?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Xc(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=rs(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Rs(this))?Es(this,t):(Ns(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&So(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof j){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&yo(this,t.getBoundingClientRect(),e)}else yo(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new al(e.slice,e.move,r<0?void 0:j.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(ro){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable==`false`)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&To(this.dom),Es(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return No(this,e)}coordsAtPos(e,t=1){return Lo(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 qo(this,t||this.state,e)}pasteHTML(e,t){return rl(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return rl(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return ic(this,e)}destroy(){this.docView&&(Dc(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Dl(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ra())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return jc(this,e)}domSelectionRange(){let e=this.domSelection();return e?co&&this.root.nodeType===11&&Ya(this.dom.ownerDocument)==this.dom&&Il(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Yl.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Xl(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[pl.node(0,e.state.doc.content.size,t)]}function Zl(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:pl.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Ql(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function $l(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 eu(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function tu(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function nu(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}function ru(e,t){return e.meta={package:`@milkdown/core`,group:`System`,...t},e}var iu={text:(e,t,n,r)=>{let i=e.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},strong:(e,t,n,r)=>{let i=e.marker||n.options.strong||`*`,a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i+i),a(),s},emphasis:(e,t,n,r)=>{let i=e.marker||n.options.emphasis||`*`,a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i),a(),s}},L=w({},`editorView`),au=w({},`editorState`),ou=w([],`initTimer`),su=w({},`editor`),cu=w([],`inputRules`),lu=w([],`prosePlugins`),uu=w([],`remarkPlugins`),du=w([],`nodeView`),fu=w([],`markView`),pu=w(re().use(c).use(lt),`remark`),mu=w({handlers:iu,encode:[]},`remarkStringifyOptions`),hu=ct(`ConfigReady`);function gu(e){let t=t=>(t.record(hu),async()=>(await e(t),t.done(hu),()=>{t.clearTimer(hu)}));return ru(t,{displayName:`Config`}),t}var _u=ct(`InitReady`);function vu(e){let t=t=>(t.inject(su,e).inject(lu,[]).inject(uu,[]).inject(cu,[]).inject(du,[]).inject(fu,[]).inject(mu,{handlers:iu,encode:[]}).inject(pu,re().use(c).use(lt)).inject(ou,[hu]).record(_u),async()=>{await t.waitTimers(ou);let e=t.get(mu);return t.set(pu,re().use(c).use(lt,e)),t.done(_u),()=>{t.remove(su).remove(lu).remove(uu).remove(cu).remove(du).remove(fu).remove(mu).remove(pu).remove(ou).clearTimer(_u)}});return ru(t,{displayName:`Init`}),t}var yu=ct(`SchemaReady`),bu=w([],`schemaTimer`),xu=w({},`schema`),Su=w([],`nodes`),Cu=w([],`marks`);function wu(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var Tu=e=>(e.inject(xu,{}).inject(Su,[]).inject(Cu,[]).inject(bu,[_u]).record(yu),async()=>{await e.waitTimers(bu);let t=e.get(pu),n=e.get(uu).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(pu,n);let r=new on({nodes:Object.fromEntries(e.get(Su).map(([e,t])=>[e,wu(t)])),marks:Object.fromEntries(e.get(Cu).map(([e,t])=>[e,wu(t)]))});return e.set(xu,r),e.done(yu),()=>{e.remove(xu).remove(Su).remove(Cu).remove(bu).clearTimer(yu)}});ru(Tu,{displayName:`Schema`});var Eu=class{constructor(){this.setCtx=e=>{this.#t=e},this.chain=()=>{if(this.#t==null)throw Ze();let e=this.#t,t=[],n=this.get.bind(this),r={run:()=>{let n=Vi(...t),r=e.get(L);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:i.bind(this)};function i(e,i){let a=n(e);return t.push(a(i)),r}return r}}#e=new et;#t=null;get ctx(){return this.#t}create(e,t){let n=e.create(this.#e.sliceMap);return n.set(t),n}get(e){return this.#e.get(e).get()}remove(e){return this.#e.remove(e)}call(e,t){if(this.#t==null)throw Ze();let n=this.get(e)(t),r=this.#t.get(L);return n(r.state,r.dispatch,r)}inline(e){if(this.#t==null)throw Ze();let t=this.#t.get(L);return e(t.state,t.dispatch,t)}};function Du(e=`cmdKey`){return w((()=>()=>!1),e)}var R=w(new Eu,`commands`),Ou=w([yu],`commandsTimer`),ku=ct(`CommandsReady`),Au=e=>{let t=new Eu;return t.setCtx(e),e.inject(R,t).inject(Ou,[yu]).record(ku),async()=>(await e.waitTimers(Ou),e.done(ku),()=>{e.remove(R).remove(Ou).clearTimer(ku)})};ru(Au,{displayName:`Commands`});function ju(e){return e.Backspace=Vi(Yi,di,mi,_i),e}var Mu=class{constructor(){this.setCtx=e=>{this.#e=e},this.add=e=>(this.#t.push(e),()=>{this.#t=this.#t.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([e,n])=>{if(typeof n==`function`){let r={key:e,onRun:()=>n};this.#t.push(r),t.push(()=>{this.#t=this.#t.filter(e=>e!==r)})}else this.#t.push(n),t.push(()=>{this.#t=this.#t.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{let e=ju(Ki);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#t.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,r)=>{let i=this.#e;if(i==null)throw We();return Vi(...n.map(e=>e.onRun(i)))(e,t,r)}]}))}}#e=null;#t=[];get ctx(){return this.#e}},Nu=w(new Mu,`keymap`),Pu=w([yu],`keymapTimer`),Fu=ct(`KeymapReady`),Iu=e=>{let t=new Mu;return t.setCtx(e),e.inject(Nu,t).inject(Pu,[yu]).record(Fu),async()=>(await e.waitTimers(Pu),e.done(Fu),()=>{e.remove(Nu).remove(Pu).clearTimer(Fu)})},Lu=ct(`ParserReady`),Ru=(()=>{throw We()}),zu=w(Ru,`parser`),Bu=w([],`parserTimer`),Vu=e=>(e.inject(zu,Ru).inject(Bu,[yu]).record(Lu),async()=>{await e.waitTimers(Bu);let t=e.get(pu),n=e.get(xu);return e.set(zu,ja.create(n,t)),e.done(Lu),()=>{e.remove(zu).remove(Bu).clearTimer(Lu)}});ru(Vu,{displayName:`Parser`});var Hu=ct(`SerializerReady`),Uu=w([],`serializerTimer`),Wu=(()=>{throw We()}),Gu=w(Wu,`serializer`),Ku=e=>(e.inject(Gu,Wu).inject(Uu,[yu]).record(Hu),async()=>{await e.waitTimers(Uu);let t=e.get(pu),n=e.get(xu);return e.set(Gu,Pa.create(n,t)),e.done(Hu),()=>{e.remove(Gu).remove(Uu).clearTimer(Hu)}});ru(Ku,{displayName:`Serializer`});var qu=w(``,`defaultValue`),Ju=w(e=>e,`stateOptions`),Yu=w([],`editorStateTimer`),Xu=ct(`EditorStateReady`);function Zu(e,t,n){if(typeof e==`string`)return t(e);if(e.type===`html`)return un.fromSchema(n).parse(e.dom);if(e.type===`json`)return Pt.fromJSON(n,e.value);throw Ve(e)}var Qu=new N(`MILKDOWN_STATE_TRACKER`),$u=e=>(e.inject(qu,``).inject(au,{}).inject(Ju,e=>e).inject(Yu,[Lu,Hu,ku,Fu]).record(Xu),async()=>{await e.waitTimers(Yu);let t=e.get(xu),n=e.get(zu),r=e.get(cu),i=e.get(Ju),a=e.get(lu),o=Zu(e.get(qu),n,t),s=e.get(Nu),c=s.addBaseKeymap(),l=[...a,new M({key:Qu,state:{init:()=>{},apply:(t,n,r,i)=>{e.set(au,i)}}}),ua({rules:r}),Ea(s.build())];e.set(lu,l);let u=i({schema:t,doc:o,plugins:l}),d=si.create(u);return e.set(au,d),e.done(Xu),()=>{c(),e.remove(qu).remove(au).remove(Ju).remove(Yu).clearTimer(Xu)}});ru($u,{displayName:`EditorState`});var ed=w([],`pasteRule`),td=w([yu],`pasteRuleTimer`),nd=ct(`PasteRuleReady`),rd=e=>(e.inject(ed,[]).inject(td,[yu]).record(nd),async()=>(await e.waitTimers(td),e.done(nd),()=>{e.remove(ed).remove(td).clearTimer(nd)}));ru(rd,{displayName:`PasteRule`});var id=ct(`EditorViewReady`),ad=w([],`editorViewTimer`),od=w({},`editorViewOptions`),sd=w(null,`root`),cd=w(null,`rootDOM`),ld=w({},`rootAttrs`);function ud(e,t){let n=document.createElement(`div`);n.className=`milkdown`,e.appendChild(n),t.set(cd,n);let r=t.get(ld);return Object.entries(r).forEach(([e,t])=>n.setAttribute(e,t)),n}function dd(e){e.classList.add(`editor`),e.setAttribute(`role`,`textbox`)}var fd=new N(`MILKDOWN_VIEW_CLEAR`),pd=e=>(e.inject(sd,document.body).inject(L,{}).inject(od,{}).inject(cd,null).inject(ld,{}).inject(ad,[Xu,nd]).record(id),async()=>{await e.wait(_u);let t=e.get(sd)||document.body,n=typeof t==`string`?document.querySelector(t):t;e.update(lu,t=>[new M({key:fd,view:t=>{let r=n?ud(n,e):void 0;return(()=>{if(r&&n){let e=t.dom;n.replaceChild(r,e),r.appendChild(e)}})(),{destroy:()=>{r?.parentNode&&r?.parentNode.replaceChild(t.dom,r),r?.remove()}}}}),...t]),await e.waitTimers(ad);let r=e.get(au),i=e.get(od),a=new Yl(n,{state:r,nodeViews:Object.fromEntries(e.get(du)),markViews:Object.fromEntries(e.get(fu)),transformPasted:(t,n,r)=>(e.get(ed).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...i});return dd(a.dom),e.set(L,a),e.done(id),()=>{a?.destroy(),e.remove(sd).remove(L).remove(od).remove(cd).remove(ld).remove(ad).clearTimer(id)}});ru(pd,{displayName:`EditorView`});var md=function(e){return e.Idle=`Idle`,e.OnCreate=`OnCreate`,e.Created=`Created`,e.OnDestroy=`OnDestroy`,e.Destroyed=`Destroyed`,e}({}),hd=class e{constructor(){this.enableInspector=(e=!0)=>(this.#e=e,this),this.onStatusChange=e=>(this.#r=e,this),this.config=e=>(this.#n.push(e),this),this.removeConfig=e=>(this.#n=this.#n.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(e=>{this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#t===md.Created&&this.#u(t,this.#o),this},this.remove=async e=>this.#t===md.OnCreate?(console.warn(`[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code.`),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#d([e].flat(),!0),this),this.create=async()=>this.#t===md.OnCreate?this:(this.#t===md.Created&&await this.destroy(),this.#p(md.OnCreate),this.#l(),this.#u([...this.#o.keys()],this.#o),await Promise.all([this.#m(this.#s),this.#m(this.#o)].flat()),this.#p(md.Created),this),this.destroy=async(e=!1)=>this.#t===md.Destroyed||this.#t===md.OnDestroy?this:this.#t===md.OnCreate?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#n=[]),this.#p(md.OnDestroy),await this.#d([...this.#o.keys()],e),await this.#f(),this.#p(md.Destroyed),this),this.action=e=>e(this.#c),this.inspect=()=>this.#e?[...this.#s.values(),...this.#o.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}#e=!1;#t=md.Idle;#n=[];#r=()=>void 0;#i=new et;#a=new at;#o=new Map;#s=new Map;#c=new it(this.#i,this.#a);#l=()=>{let e=gu(async e=>{await Promise.all(this.#n.map(t=>Promise.resolve(t(e))))}),t=[Tu,Vu,Ku,Au,Iu,rd,$u,pd,vu(this),e];this.#u(t,this.#s)};#u=(e,t)=>{e.forEach(e=>{let n=this.#c.produce(this.#e?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})};#d=(e,t=!1)=>Promise.all([e].flat().map(async e=>{let n=this.#o.get(e)?.cleanup;return t?this.#o.delete(e):this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof n==`function`?n():n}));#f=async()=>{await Promise.all([...this.#s.entries()].map(async([e,{cleanup:t}])=>typeof t==`function`?t():t)),this.#s.clear()};#p=e=>{this.#t=e,this.#r(e)};#m=e=>[...e.entries()].map(async([t,n])=>{let{ctx:r,handler:i}=n;if(!i)return;let a=await i();e.set(t,{ctx:r,handler:i,cleanup:a})});get ctx(){return this.#c}get status(){return this.#t}},gd=e=>crypto.getRandomValues(new Uint8Array(e)),_d=(e,t,n)=>{let r=256-256%e.length;if(r===256){let r=e.length-1;return(i=t)=>{if(!i)return``;let a=``;for(;;){let t=n(i),o=i;for(;o--;)if(a+=e[t[o]&r],a.length>=i)return a}}}let i=Math.ceil(1.6*256*t/r);return(a=t)=>{if(!a)return``;let o=``;for(;;){let t=n(i),s=i;for(;s--;)if(t[s]<r&&(o+=e[t[s]%e.length],o.length>=a))return o}}};((e,t=21)=>_d(e,t|0,gd))(`abcedfghicklmn`,10);function z(e,t){let n=Du(e),r=i=>async()=>{r.key=n,await i.wait(ku);let a=t(i);return i.get(R).create(n,a),r.run=t=>i.get(R).call(e,t),()=>{i.get(R).remove(n)}};return r}function vd(e){let t=n=>async()=>{await n.wait(yu);let r=e(n);return n.update(cu,e=>[...e,r]),t.inputRule=r,()=>{n.update(cu,e=>e.filter(e=>e!==r))}};return t}function yd(e){let t=n=>async()=>{await n.wait(yu);let r=e(n);return n.update(ed,e=>[...e,r]),t.pasteRule=r,()=>{n.update(ed,e=>e.filter(e=>e!==r))}};return t}function bd(e,t){let n=r=>async()=>{let i=t(r);return r.update(Cu,t=>[...t.filter(t=>t[0]!==e),[e,i]]),n.id=e,n.schema=i,()=>{r.update(Cu,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{let n=t.get(xu).marks[e];if(!n)throw $e(e);return n},n}function xd(e,t){let n=r=>async()=>{let i=t(r);return r.update(Su,t=>[...t.filter(t=>t[0]!==e),[e,i]]),n.id=e,n.schema=i,()=>{r.update(Su,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{let n=t.get(xu).nodes[e];if(!n)throw Qe(e);return n},n}function Sd(e){let t,n=n=>async()=>(await n.wait(yu),t=e(n),n.update(lu,e=>[...e,t]),()=>{n.update(lu,e=>e.filter(e=>e!==t))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function Cd(e){let t=n=>async()=>{await n.wait(Fu);let r=n.get(Nu),i=e(n),a=r.addObjectKeymap(i);return t.keymap=i,()=>{a()}};return t}function wd(e,t){let n=r=>async()=>{await r.wait(yu);let i=t(r);return e.type(r)instanceof tn?r.update(du,t=>[...t,[e.id,i]]):r.update(fu,t=>[...t,[e.id,i]]),n.view=i,n.type=e,()=>{e.type(r)instanceof tn?r.update(du,t=>t.filter(t=>t[0]!==e.id)):r.update(fu,t=>t.filter(t=>t[0]!==e.id))}};return n}function Td(e,t){let n=w(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}function B(e,t){let n=Td(t,e),r=xd(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.node=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>B(e,n(t)),i}function Ed(e,t){let n=Td(t,e),r=bd(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.mark=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>Ed(e,n(t)),i}function Dd(e,t){let n=Td(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),r=Cd(e=>{let r=e.get(n.key),i=Object.entries(t).flatMap(([e,{command:t}])=>{let n=r[e],i=[n.shortcuts].flat(),a=n.priority;return i.map(e=>[e,{key:e,onRun:t,priority:a}])});return Object.fromEntries(i)}),i=[n,r];return i.ctx=n,i.shortcuts=r,i.key=n.key,i.keymap=r.keymap,i}var Od=(e,t=()=>({}))=>Td(t,`${e}Attr`),kd=(e,t=()=>({}))=>Td(t,`${e}Attr`);function Ad(e,t,n){let r=Td(n??{},e),i=e=>async()=>{await e.wait(_u);let n={plugin:t(e),options:e.get(r.key)};return e.update(uu,e=>[...e,n]),()=>{e.update(uu,e=>e.filter(e=>e!==n))}},a=[r,i];return a.id=e,a.plugin=i,a.options=r,a}function V(e,t){return n=>n.get(R).call(e,t)}function jd(e){return t=>{let n=t.get(L),r=t.get(xu),i=t.get(Gu);if(!e)return i(n.state.doc);let a=n.state.doc.slice(e.from,e.to,!0),o=r.topNodeType.createAndFill(null,a.content);return o?i(o):(console.error(`No document found`),``)}}function Md(e,t=!1){return n=>{let r=n.get(L),i=n.get(zu)(e);if(!i)return;if(!t){let e=r.state.selection.content();return r.dispatch(r.state.tr.replaceSelection(new O(i.content,e.openStart,e.openEnd)).scrollIntoView())}let a=n.get(xu),o=wn.fromSchema(a).serializeFragment(i.content),s=un.fromSchema(a).parseSlice(o),c=ma(s);if(c){r.dispatch(r.state.tr.replaceSelectionWith(c,!0));return}r.dispatch(r.state.tr.replaceSelection(s))}}function Nd(e,t=!1){return n=>{let r=n.get(L),i=n.get(zu)(e);if(!i)return;if(!t){let{state:e}=r;return r.dispatch(e.tr.replace(0,e.doc.content.size,new O(i.content,0,0)))}let a=n.get(xu),o=n.get(Ju)({schema:a,doc:i,plugins:n.get(lu)}),s=si.create(o);r.updateState(s)}}function Pd(e){return t=>{let n=t.get(zu)(e),r=t.get(xu),i=wn.fromSchema(r).serializeFragment(n.content);return un.fromSchema(r).parseSlice(i)}}function Fd(e,t,n=!1){return r=>{let i=Pd(e)(r),a=r.get(L),o=a.state.doc.resolve(t),s=a.state.doc.content.size,c=n?o.pos:o.after(o.depth-1),l=Math.min(Math.max(c,0),s);a.dispatch(a.state.tr.replace(c,l,i))}}function Id(e,t){return function(n,r){let{$from:i,$to:a,node:o}=n.selection;if(o&&o.isBlock||i.depth<2||!i.sameParent(a))return!1;let s=i.node(-1);if(s.type!=e)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=e||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let t=E.empty,a=i.index(-1)?1:i.index(-2)?2:3;for(let e=i.depth-a;e>=i.depth-3;e--)t=E.from(i.node(e).copy(t));let o=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;t=t.append(E.from(e.createAndFill()));let s=i.before(i.depth-(a-1)),c=n.tr.replace(s,i.after(-o),new O(t,4-a,0)),l=-1;c.doc.nodesBetween(s,c.doc.content.size,(e,t)=>{if(l>-1)return!1;e.isTextblock&&e.content.size==0&&(l=t+1)}),l>-1&&c.setSelection(k.near(c.doc.resolve(l))),r(c.scrollIntoView())}return!0}let c=a.pos==i.end()?s.contentMatchAt(0).defaultType:null,l=n.tr.delete(i.pos,a.pos),u=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return gr(l.doc,i.pos,2,u)?(r&&r(l.split(i.pos,2,u).scrollIntoView()),!0):!1}}function Ld(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?Rd(t,n,e,a):zd(t,n,a):!0:!1}}function Rd(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new Qn(a-1,o,a,o,new O(E.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Mt(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=ir(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return vr(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function zd(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?E.empty:E.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new Qn(d-+!!s,f+ +!!c,d+1,f-1,new O((s?E.empty:E.from(i.copy(E.empty))).append(c?E.empty:E.from(i.copy(E.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function Bd(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=E.from(r?e.create():null),o=new O(E.from(e.create(null,E.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new Qn(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}function Vd(e){let t=new Map;if(!e||!e.type)throw Error(`mdast-util-definitions expected node`);return s(e,`definition`,function(e){let n=Hd(e.identifier);n&&!t.get(n)&&t.set(n,e)}),n;function n(e){let n=Hd(e);return t.get(n)}}function Hd(e){return String(e||``).toUpperCase()}function Ud(){return function(e){let t=Vd(e);s(e,function(e,n,r){if(e.type===`definition`&&r!==void 0&&typeof n==`number`)return r.children.splice(n,1),[ne,n];if(e.type===`imageReference`||e.type===`linkReference`){let i=t(e.identifier);if(i&&r&&typeof n==`number`)return r.children[n]=e.type===`imageReference`?{type:`image`,url:i.url,title:i.title,alt:e.alt}:{type:`link`,url:i.url,title:i.title,children:e.children},[ne,n]}})}}function Wd(e,t){if(!(t.childCount>=1&&t.lastChild?.type.name===`hardbreak`)){e.next(t.content);return}let n=[];t.content.forEach((e,r,i)=>{i!==t.childCount-1&&n.push(e)}),e.next(E.fromArray(n))}function H(e,t){return Object.assign(e,{meta:{package:`@milkdown/preset-commonmark`,...t}}),e}var Gd=kd(`emphasis`);H(Gd,{displayName:`Attr<emphasis>`,group:`Emphasis`});var Kd=Ed(`emphasis`,e=>({attrs:{marker:{default:e.get(mu).emphasis||`*`,validate:`string`}},parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style`,getAttrs:e=>e===`italic`}],toDOM:t=>[`em`,e.get(Gd.key)(t)],parseMarkdown:{match:e=>e.type===`emphasis`,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`emphasis`,runner:(e,t)=>{e.withMark(t,`emphasis`,void 0,{marker:t.attrs.marker})}}}));H(Kd.mark,{displayName:`MarkSchema<emphasis>`,group:`Emphasis`}),H(Kd.ctx,{displayName:`MarkSchemaCtx<emphasis>`,group:`Emphasis`});var qd=z(`ToggleEmphasis`,e=>()=>Bi(Kd.type(e)));H(qd,{displayName:`Command<toggleEmphasisCommand>`,group:`Emphasis`});var Jd=vd(e=>da(/(?:^|[^*])\*([^*]+)\*$/,Kd.type(e),{getAttr:()=>({marker:`*`}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith(`*`)?{}:{fullMatch:e.slice(1),start:t+1}}));H(Jd,{displayName:`InputRule<emphasis>|Star`,group:`Emphasis`});var Yd=vd(e=>da(/\b_(?![_\s])(.*?[^_\s])_\b/,Kd.type(e),{getAttr:()=>({marker:`_`}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith(`_`)?{}:{fullMatch:e.slice(1),start:t+1}}));H(Yd,{displayName:`InputRule<emphasis>|Underscore`,group:`Emphasis`});var Xd=Dd(`emphasisKeymap`,{ToggleEmphasis:{shortcuts:`Mod-i`,command:e=>{let t=e.get(R);return()=>t.call(qd.key)}}});H(Xd.ctx,{displayName:`KeymapCtx<emphasis>`,group:`Emphasis`}),H(Xd.shortcuts,{displayName:`Keymap<emphasis>`,group:`Emphasis`});var Zd=kd(`strong`);H(Zd,{displayName:`Attr<strong>`,group:`Strong`});var Qd=Ed(`strong`,e=>({attrs:{marker:{default:e.get(mu).strong||`*`,validate:`string`}},parseDOM:[{tag:`b`,getAttrs:e=>e.style.fontWeight!=`normal`&&null},{tag:`strong`},{style:`font-style`,getAttrs:e=>e===`bold`},{style:`font-weight=400`,clearMark:e=>e.type.name==`strong`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:t=>[`strong`,e.get(Zd.key)(t)],parseMarkdown:{match:e=>e.type===`strong`,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`strong`,runner:(e,t)=>{e.withMark(t,`strong`,void 0,{marker:t.attrs.marker})}}}));H(Qd.mark,{displayName:`MarkSchema<strong>`,group:`Strong`}),H(Qd.ctx,{displayName:`MarkSchemaCtx<strong>`,group:`Strong`});var $d=z(`ToggleStrong`,e=>()=>Bi(Qd.type(e)));H($d,{displayName:`Command<toggleStrongCommand>`,group:`Strong`});var ef=vd(e=>da(/(?<![\w:/])(?:\*\*|__)([^*_]+?)(?:\*\*|__)(?![\w/])$/,Qd.type(e),{getAttr:e=>({marker:e[0].startsWith(`*`)?`*`:`_`})}));H(ef,{displayName:`InputRule<strong>`,group:`Strong`});var tf=Dd(`strongKeymap`,{ToggleBold:{shortcuts:[`Mod-b`],command:e=>{let t=e.get(R);return()=>t.call($d.key)}}});H(tf.ctx,{displayName:`KeymapCtx<strong>`,group:`Strong`}),H(tf.shortcuts,{displayName:`Keymap<strong>`,group:`Strong`});var nf=kd(`inlineCode`);H(nf,{displayName:`Attr<inlineCode>`,group:`InlineCode`});var rf=Ed(`inlineCode`,e=>({priority:100,code:!0,parseDOM:[{tag:`code`}],toDOM:t=>[`code`,e.get(nf.key)(t)],parseMarkdown:{match:e=>e.type===`inlineCode`,runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`inlineCode`,runner:(e,t,n)=>(e.withMark(t,`inlineCode`,n.text||``),!0)}}));H(rf.mark,{displayName:`MarkSchema<inlineCode>`,group:`InlineCode`}),H(rf.ctx,{displayName:`MarkSchemaCtx<inlineCode>`,group:`InlineCode`});var af=z(`ToggleInlineCode`,e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(r.empty)return!1;let{from:a,to:o}=r;return t.doc.rangeHasMark(a,o,rf.type(e))?(n?.(i.removeMark(a,o,rf.type(e))),!0):(Object.keys(t.schema.marks).filter(e=>e!==rf.type.name).map(e=>t.schema.marks[e]).forEach(e=>{i.removeMark(a,o,e)}),n?.(i.addMark(a,o,rf.type(e).create())),!0)});H(af,{displayName:`Command<toggleInlineCodeCommand>`,group:`InlineCode`});var of=vd(e=>da(/(?:`)([^`]+)(?:`)$/,rf.type(e)));H(of,{displayName:`InputRule<inlineCodeInputRule>`,group:`InlineCode`});var sf=Dd(`inlineCodeKeymap`,{ToggleInlineCode:{shortcuts:`Mod-e`,command:e=>{let t=e.get(R);return()=>t.call(af.key)}}});H(sf.ctx,{displayName:`KeymapCtx<inlineCode>`,group:`InlineCode`}),H(sf.shortcuts,{displayName:`Keymap<inlineCode>`,group:`InlineCode`});var cf=kd(`link`);H(cf,{displayName:`Attr<link>`,group:`Link`});var lf=Ed(`link`,e=>({attrs:{href:{validate:`string`},title:{default:null,validate:`string|null`}},parseDOM:[{tag:`a[href]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM:t=>[`a`,{...e.get(cf.key)(t),...t.attrs}],parseMarkdown:{match:e=>e.type===`link`,runner:(e,t,n)=>{let r=t.url,i=t.title;e.openMark(n,{href:r,title:i}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`link`,runner:(e,t)=>{e.withMark(t,`link`,void 0,{title:t.attrs.title,url:t.attrs.href})}}}));H(lf.mark,{displayName:`MarkSchema<link>`,group:`Link`});var uf=z(`ToggleLink`,e=>(t={})=>Bi(lf.type(e),t));H(uf,{displayName:`Command<toggleLinkCommand>`,group:`Link`});var df=z(`UpdateLink`,e=>(t={})=>(n,r)=>{if(!r)return!1;let i,a=-1,{selection:o}=n,{from:s,to:c}=o;if(n.doc.nodesBetween(s,s===c?c+1:c,(t,n)=>{if(lf.type(e).isInSet(t.marks))return i=t,a=n,!1}),!i)return!1;let l=i.marks.find(({type:t})=>t===lf.type(e));if(!l)return!1;let u=a,d=a+i.nodeSize,{tr:f}=n,p=lf.type(e).create({...l.attrs,...t});return p?(r(f.removeMark(u,d,l).addMark(u,d,p).setSelection(new A(f.selection.$anchor)).scrollIntoView()),!0):!1});H(df,{displayName:`Command<updateLinkCommand>`,group:`Link`});var ff=xd(`doc`,()=>({content:`block+`,parseMarkdown:{match:({type:e})=>e===`root`,runner:(e,t,n)=>{e.injectRoot(t,n)}},toMarkdown:{match:e=>e.type.name===`doc`,runner:(e,t)=>{e.openNode(`root`),e.next(t.content)}}}));H(ff,{displayName:`NodeSchema<doc>`,group:`Doc`});function pf(e){return u(e,e=>e.type===`html`&&[`<br />`,`<br>`,`<br >`,`<br/>`].includes(e.value?.trim()),(e,t)=>{if(!t.length)return;let n=t[t.length-1];if(!n)return;let r=n.children.indexOf(e);r!==-1&&n.children.splice(r,1)},!0)}var mf=Ad(`remark-preserve-empty-line`,()=>()=>pf);H(mf.plugin,{displayName:`Remark<remarkPreserveEmptyLine>`,group:`Remark`}),H(mf.options,{displayName:`RemarkConfig<remarkPreserveEmptyLine>`,group:`Remark`});var hf=Od(`paragraph`);H(hf,{displayName:`Attr<paragraph>`,group:`Paragraph`});var gf=B(`paragraph`,e=>({content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM:t=>[`p`,e.get(hf.key)(t),0],parseMarkdown:{match:e=>e.type===`paragraph`,runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||``),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`paragraph`,runner:(t,n)=>{let r=e.get(L).state?.doc.lastChild;t.openNode(`paragraph`),(!n.content||n.content.size===0)&&n!==r&&_f(e)?t.addNode(`html`,void 0,`<br />`):Wd(t,n),t.closeNode()}}}));function _f(e){let t=!1;try{e.get(mf.id),t=!0}catch{t=!1}return t}H(gf.node,{displayName:`NodeSchema<paragraph>`,group:`Paragraph`}),H(gf.ctx,{displayName:`NodeSchemaCtx<paragraph>`,group:`Paragraph`});var vf=z(`TurnIntoText`,e=>()=>Li(gf.type(e)));H(vf,{displayName:`Command<turnIntoTextCommand>`,group:`Paragraph`});var yf=Dd(`paragraphKeymap`,{TurnIntoText:{shortcuts:`Mod-Alt-0`,command:e=>{let t=e.get(R);return()=>t.call(vf.key)}}});H(yf.ctx,{displayName:`KeymapCtx<paragraph>`,group:`Paragraph`}),H(yf.shortcuts,{displayName:`Keymap<paragraph>`,group:`Paragraph`});var bf=[,,,,,,].fill(0).map((e,t)=>t+1);function xf(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,`-`)}var Sf=Td(xf,`headingIdGenerator`);H(Sf,{displayName:`Ctx<HeadingIdGenerator>`,group:`Heading`});var Cf=Od(`heading`);H(Cf,{displayName:`Attr<heading>`,group:`Heading`});var wf=B(`heading`,e=>{let t=e.get(Sf.key);return{content:`inline*`,group:`block`,defining:!0,attrs:{id:{default:``,validate:`string`},level:{default:1,validate:`number`}},parseDOM:bf.map(e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw Xe(t);return{level:e,id:t.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...e.get(Cf.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>e===`heading`,runner:(e,t,n)=>{let r=t.depth;e.openNode(n,{level:r}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`heading`,runner:(e,t)=>{e.openNode(`heading`,void 0,{depth:t.attrs.level}),Wd(e,t),e.closeNode()}}}});H(wf.node,{displayName:`NodeSchema<heading>`,group:`Heading`}),H(wf.ctx,{displayName:`NodeSchemaCtx<heading>`,group:`Heading`});var Tf=vd(e=>Zi(/^(?<hashes>#+)\s$/,wf.type(e),t=>{let n=t.groups?.hashes?.length||0,{$from:r}=e.get(L).state.selection,i=r.node();if(i.type.name===`heading`){let e=Number(i.attrs.level)+Number(n);return e>6&&(e=6),{level:e}}return{level:n}}));H(Tf,{displayName:`InputRule<wrapInHeadingInputRule>`,group:`Heading`});var Ef=z(`WrapInHeading`,e=>t=>(t??=1,t<1?Li(gf.type(e)):Li(wf.type(e),{level:t})));H(Ef,{displayName:`Command<wrapInHeadingCommand>`,group:`Heading`});var Df=z(`DowngradeHeading`,e=>()=>(t,n,r)=>{let{$from:i}=t.selection,a=i.node();if(a.type!==wf.type(e)||!t.selection.empty||i.parentOffset!==0)return!1;let o=a.attrs.level-1;return o?(n?.(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...a.attrs,level:o})),!0):Li(gf.type(e))(t,n,r)});H(Df,{displayName:`Command<downgradeHeadingCommand>`,group:`Heading`});var Of=Dd(`headingKeymap`,{TurnIntoH1:{shortcuts:`Mod-Alt-1`,command:e=>{let t=e.get(R);return()=>t.call(Ef.key,1)}},TurnIntoH2:{shortcuts:`Mod-Alt-2`,command:e=>{let t=e.get(R);return()=>t.call(Ef.key,2)}},TurnIntoH3:{shortcuts:`Mod-Alt-3`,command:e=>{let t=e.get(R);return()=>t.call(Ef.key,3)}},TurnIntoH4:{shortcuts:`Mod-Alt-4`,command:e=>{let t=e.get(R);return()=>t.call(Ef.key,4)}},TurnIntoH5:{shortcuts:`Mod-Alt-5`,command:e=>{let t=e.get(R);return()=>t.call(Ef.key,5)}},TurnIntoH6:{shortcuts:`Mod-Alt-6`,command:e=>{let t=e.get(R);return()=>t.call(Ef.key,6)}},DowngradeHeading:{shortcuts:[`Delete`,`Backspace`],command:e=>{let t=e.get(R);return()=>t.call(Df.key)}}});H(Of.ctx,{displayName:`KeymapCtx<heading>`,group:`Heading`}),H(Of.shortcuts,{displayName:`Keymap<heading>`,group:`Heading`});var kf=Od(`blockquote`);H(kf,{displayName:`Attr<blockquote>`,group:`Blockquote`});var Af=B(`blockquote`,e=>({content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM:t=>[`blockquote`,e.get(kf.key)(t),0],parseMarkdown:{match:({type:e})=>e===`blockquote`,runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`blockquote`,runner:(e,t)=>{e.openNode(`blockquote`).next(t.content).closeNode()}}}));H(Af.node,{displayName:`NodeSchema<blockquote>`,group:`Blockquote`}),H(Af.ctx,{displayName:`NodeSchemaCtx<blockquote>`,group:`Blockquote`});var jf=vd(e=>Xi(/^\s*>\s$/,Af.type(e)));H(jf,{displayName:`InputRule<wrapInBlockquoteInputRule>`,group:`Blockquote`});var Mf=z(`WrapInBlockquote`,e=>()=>Ii(Af.type(e)));H(Mf,{displayName:`Command<wrapInBlockquoteCommand>`,group:`Blockquote`});var Nf=Dd(`blockquoteKeymap`,{WrapInBlockquote:{shortcuts:`Mod-Shift-b`,command:e=>{let t=e.get(R);return()=>t.call(Mf.key)}}});H(Nf.ctx,{displayName:`KeymapCtx<blockquote>`,group:`Blockquote`}),H(Nf.shortcuts,{displayName:`Keymap<blockquote>`,group:`Blockquote`});var Pf=Od(`codeBlock`,()=>({pre:{},code:{}}));H(Pf,{displayName:`Attr<codeBlock>`,group:`CodeBlock`});var Ff=B(`code_block`,e=>({content:`text*`,group:`block`,marks:``,defining:!0,code:!0,attrs:{language:{default:``,validate:`string`}},parseDOM:[{tag:`pre`,preserveWhitespace:`full`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{language:e.dataset.language}}}],toDOM:t=>{let n=e.get(Pf.key)(t),r=t.attrs.language,i=r&&r.length>0?{"data-language":r}:void 0;return[`pre`,{...n.pre,...i},[`code`,n.code,0]]},parseMarkdown:{match:({type:e})=>e===`code`,runner:(e,t,n)=>{let r=t.lang??``,i=t.value;e.openNode(n,{language:r}),i&&e.addText(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`code_block`,runner:(e,t)=>{e.addNode(`code`,void 0,t.content.firstChild?.text||``,{lang:t.attrs.language})}}}));H(Ff.node,{displayName:`NodeSchema<codeBlock>`,group:`CodeBlock`}),H(Ff.ctx,{displayName:`NodeSchemaCtx<codeBlock>`,group:`CodeBlock`});var If=vd(e=>Zi(/^```(?<language>[a-z]*)?[\s\n]$/,Ff.type(e),e=>({language:e.groups?.language??``})));H(If,{displayName:`InputRule<createCodeBlockInputRule>`,group:`CodeBlock`});var Lf=z(`CreateCodeBlock`,e=>(t=``)=>Li(Ff.type(e),{language:t}));H(Lf,{displayName:`Command<createCodeBlockCommand>`,group:`CodeBlock`}),H(z(`UpdateCodeBlockLanguage`,()=>({pos:e,language:t}={pos:-1,language:``})=>(n,r)=>e>=0?(r?.(n.tr.setNodeAttribute(e,`language`,t)),!0):!1),{displayName:`Command<updateCodeBlockLanguageCommand>`,group:`CodeBlock`});var Rf=Dd(`codeBlockKeymap`,{CreateCodeBlock:{shortcuts:`Mod-Alt-c`,command:e=>{let t=e.get(R);return()=>t.call(Lf.key)}}});H(Rf.ctx,{displayName:`KeymapCtx<codeBlock>`,group:`CodeBlock`}),H(Rf.shortcuts,{displayName:`Keymap<codeBlock>`,group:`CodeBlock`});var zf=Od(`image`);H(zf,{displayName:`Attr<image>`,group:`Image`});var Bf=B(`image`,e=>({inline:!0,group:`inline`,selectable:!0,draggable:!0,marks:``,atom:!0,defining:!0,isolating:!0,attrs:{src:{default:``,validate:`string`},alt:{default:``,validate:`string`},title:{default:``,validate:`string`}},parseDOM:[{tag:`img[src]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{src:e.getAttribute(`src`)||``,alt:e.getAttribute(`alt`)||``,title:e.getAttribute(`title`)||e.getAttribute(`alt`)||``}}}],toDOM:t=>[`img`,{...e.get(zf.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>e===`image`,runner:(e,t,n)=>{let r=t.url,i=t.alt,a=t.title;e.addNode(n,{src:r,alt:i,title:a})}},toMarkdown:{match:e=>e.type.name===`image`,runner:(e,t)=>{e.addNode(`image`,void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));H(Bf.node,{displayName:`NodeSchema<image>`,group:`Image`}),H(Bf.ctx,{displayName:`NodeSchemaCtx<image>`,group:`Image`});var Vf=z(`InsertImage`,e=>(t={})=>(n,r)=>{if(!r)return!0;let{src:i=``,alt:a=``,title:o=``}=t,s=Bf.type(e).create({src:i,alt:a,title:o});return s&&r(n.tr.replaceSelectionWith(s).scrollIntoView()),!0});H(Vf,{displayName:`Command<insertImageCommand>`,group:`Image`});var Hf=z(`UpdateImage`,e=>(t={})=>(n,r)=>{let i=ya(n.selection,Bf.type(e));if(!i)return!1;let{node:a,pos:o}=i,s={...a.attrs},{src:c,alt:l,title:u}=t;return c!==void 0&&(s.src=c),l!==void 0&&(s.alt=l),u!==void 0&&(s.title=u),r?.(n.tr.setNodeMarkup(o,void 0,s).scrollIntoView()),!0});H(Hf,{displayName:`Command<updateImageCommand>`,group:`Image`}),H(vd(e=>new qi(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,n,r,i)=>{let[a,o,s=``,c]=n;return a?t.tr.replaceWith(r,i,Bf.type(e).create({src:s,alt:o,title:c})):null})),{displayName:`InputRule<insertImageInputRule>`,group:`Image`});var Uf=Od(`hardbreak`,e=>({"data-type":`hardbreak`,"data-is-inline":e.attrs.isInline}));H(Uf,{displayName:`Attr<hardbreak>`,group:`Hardbreak`});var Wf=B(`hardbreak`,e=>({inline:!0,group:`inline`,attrs:{isInline:{default:!1,validate:`boolean`}},selectable:!1,parseDOM:[{tag:`br`},{tag:`span[data-type="hardbreak"]`,getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?[`span`,e.get(Uf.key)(t),` `]:[`br`,e.get(Uf.key)(t)],parseMarkdown:{match:({type:e})=>e===`break`,runner:(e,t,n)=>{e.addNode(n,{isInline:!!t.data?.isInline})}},leafText:()=>`
|
|
31
|
+
`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=wn.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=vc(n),mo&&yc(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||un.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!oc.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=bc(fc(s,+u[1],+u[2]),u[4]);else if(s=O.maxOpen(sc(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=fc(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var oc=/^(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 sc(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&lc(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=uc(a[a.length-1],i.length));let n=cc(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return E.from(a)}return e}function cc(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,E.from(e));return e}function lc(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=lc(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(E.from(cc(n,e,i+1))))}}function uc(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,uc(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(E.empty,!0);return e.copy(n.append(r))}function dc(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=dc(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(E.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function fc(e,t,n){return t<e.openStart&&(e=new O(dc(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new O(dc(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var pc={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},mc=null;function hc(){return mc||=document.implementation.createHTMLDocument(`title`)}var gc=null;function _c(e){let t=window.trustedTypes;return t?(gc||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),gc.createHTML(e)):e}function vc(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=hc().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&pc[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=_c(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function yc(e){let t=e.querySelectorAll(F?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function bc(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=E.from(t.create(r[e+1],i)),a++,o++}return new O(i,a,o)}var xc={},Sc={},Cc={touchstart:!0,touchmove:!0},wc=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Tc(e){for(let t in xc){let n=xc[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{Ac(e,t)&&!kc(e,t)&&(e.editable||!(t.type in Sc))&&n(e,t)},Cc[t]?{passive:!0}:void 0)}co&&e.dom.addEventListener(`input`,()=>null),Oc(e)}function Ec(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Dc(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function Oc(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>kc(e,t))})}function kc(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function Ac(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 jc(e,t){!kc(e,t)&&xc[t.type]&&(e.editable||!(t.type in Sc))&&xc[t.type](e,t)}Sc.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Gc(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(po&&F&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),lo&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,Ja(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||rc(e,n)?n.preventDefault():Ec(e,`key`)},Sc.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},Sc.keypress=(e,t)=>{let n=t;if(Gc(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||uo&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof A)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function Mc(e){return{left:e.clientX,top:e.clientY}}function Nc(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Pc(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function Fc(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function Ic(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&j.isSelectable(r)?(Fc(e,new j(n),`pointer`),!0):!1}function Lc(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof j&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(j.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(Fc(e,j.create(e.state.doc,i),`pointer`),!0)}function Rc(e,t,n,r,i){return Pc(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?Lc(e,n):Ic(e,n))}function zc(e,t,n,r){return Pc(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Bc(e,t,n,r){return Pc(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Vc(e,n,r)}function Vc(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(Fc(e,A.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)Fc(e,A.create(r,a+1,a+1+n.content.size),`pointer`);else if(j.isSelectable(n))Fc(e,j.create(r,a),`pointer`);else continue;return!0}}function Hc(e){return Qc(e)}var Uc=uo?`metaKey`:`ctrlKey`;xc.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Hc(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&Nc(n,e.input.lastClick)&&!n[Uc]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(Mc(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Wc(e,o,n,!!r)):(a==`doubleClick`?zc:Bc)(e,o.pos,o.inside,n)?n.preventDefault():Ec(e,`pointer`))};var Wc=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Uc],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof j&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ao&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this)),Ec(e,`pointer`)}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Es(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Mc(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ec(this.view,`pointer`):Rc(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||co&&this.mightDrag&&!this.mightDrag.node.isAtom||F&&!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)?(Fc(this.view,k.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):Ec(this.view,`pointer`)}move(e){this.updateAllowDefault(e),Ec(this.view,`pointer`),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};xc.touchstart=e=>{e.input.lastTouch=Date.now(),Hc(e),Ec(e,`pointer`)},xc.touchmove=e=>{e.input.lastTouch=Date.now(),Ec(e,`pointer`)},xc.contextmenu=e=>Hc(e);function Gc(e,t){return e.composing?!0:co&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Kc=po?5e3:-1;Sc.compositionstart=Sc.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof A&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||F&&fo&&qc(e)))e.markCursor=e.state.storedMarks||n.marks(),Qc(e,!0),e.markCursor=null;else if(Qc(e,!t.selection.empty),ao&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}Jc(e,Kc)};function qc(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}Sc.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Jc(e,20))};function Jc(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Qc(e),t))}function Yc(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Zc());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Xc(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Ua(t.focusNode,t.focusOffset),r=Wa(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function Zc(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function Qc(e,t=!1){if(!(po&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Yc(e),t||e.docView&&e.docView.dirty){let n=ws(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function $c(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var el=ro&&io<15||lo&&ho<604;xc.copy=Sc.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=el?null:n.clipboardData,{dom:o,text:s}=ic(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):$c(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function tl(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function nl(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?rl(e,r.value,null,i,t):rl(e,r.textContent,r.innerHTML,i,t)},50)}function rl(e,t,n,r,i){let a=ac(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||O.empty)))return!0;if(!a)return!1;let o=tl(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function il(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,` `):``}Sc.paste=(e,t)=>{let n=t;if(e.composing&&!po)return;let r=el?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&rl(e,il(r),r.getData(`text/html`),i,n)?n.preventDefault():nl(e,n)};var al=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},ol=uo?`altKey`:`ctrlKey`;function sl(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[ol]:!n}xc.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(Mc(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof j?i.to-1:i.to))){if(r&&r.mightDrag)o=j.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=j.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=ic(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!F||so>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(el?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,el||n.dataTransfer.setData(`text/plain`,c),e.dragging=new al(l,sl(e,n),o)},xc.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},Sc.dragover=Sc.dragenter=(e,t)=>t.preventDefault(),Sc.drop=(e,t)=>{try{cl(e,t,e.dragging)}finally{e.dragging=null}};function cl(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Mc(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=ac(e,il(t.dataTransfer),el?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&sl(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||O.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?Cr(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&j.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new j(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(Fs(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}xc.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Es(e)},20))},xc.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},xc.beforeinput=(e,t)=>{if(F&&po&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,Ja(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in Sc)xc[e]=Sc[e];function ll(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var ul=class e{constructor(e,t){this.toDOM=e,this.spec=t||hl,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new pl(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&ll(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},dl=class e{constructor(e,t){this.attrs=e,this.spec=t||hl}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new pl(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&ll(this.attrs,t.attrs)&&ll(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},fl=class e{constructor(e,t){this.attrs=e,this.spec=t||hl}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new pl(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&ll(this.attrs,t.attrs)&&ll(this.spec,t.spec)}destroy(){}},pl=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new ul(n,r))}static inline(t,n,r,i){return new e(t,n,new dl(r,i))}static node(t,n,r,i){return new e(t,n,new fl(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof dl}get widget(){return this.type instanceof ul}},ml=[],hl={},I=class e{constructor(e,t){this.local=e.length?e:ml,this.children=t.length?t:ml}static create(e,t){return t.length?Cl(t,e,0,hl):gl}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==gl||e.maps.length==0?this:this.mapInner(e,t,0,0,n||hl)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?vl(this.children,o||[],t,n,r,i,a):o?new e(o.sort(wl),ml):gl}add(t,n){return n.length?this==gl?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=xl(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,Cl(s,e,o+1,hl)),a+=3}});let o=yl(a?Sl(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(wl):this.local,i||this.children)}remove(e){return e.length==0||this==gl?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==gl?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):gl}forChild(t,n){if(this==gl)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof dl){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(wl),ml);return r?new _l([t,r]):t}return r||gl}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return Tl(this.localsInner(e))}localsInner(e){if(this==gl)return ml;if(e.inlineContent||!this.local.some(dl.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof dl||t.push(this.local[e]);return t}forEachSet(e){e(this)}};I.empty=new I([],[]),I.removeOverlap=Tl;var gl=I.empty,_l=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,hl));return e.from(r)}forChild(t,n){if(n.isLeaf)return I.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=gl&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?Tl(n?t:t.sort(wl)):ml}static from(t){switch(t.length){case 0:return gl;case 1:return t[0];default:return new e(t.every(e=>e instanceof I)?t:t.reduce((e,t)=>e.concat(t instanceof I?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function vl(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==gl?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=Cl(bl(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new I(t.sort(wl),s)}function yl(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new pl(i.from+t,i.to+t,i.type))}return n}function bl(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function xl(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function Sl(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function Cl(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=xl(e,t,o+n);if(s){a=!0;let e=Cl(s,t,n+o+1,r);e!=gl&&i.push(o,o+t.nodeSize,e)}});let o=yl(a?Sl(e):e,-n).sort(wl);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new I(o,i):gl}function wl(e,t){return e.from-t.from||e.to-t.to}function Tl(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),El(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),El(t,i,r.copy(a.from,r.to)));break}}}return t}function El(e,t,n){for(;t<e.length&&wl(n,e[t])>0;)t++;e.splice(t,0,n)}function Dl(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=gl&&t.push(r)}),e.cursorWrapper&&t.push(I.create(e.state.doc,[e.cursorWrapper.deco])),_l.from(t)}var Ol={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},kl=ro&&io<=11,Al=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},jl=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Al,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);ro&&io<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():co&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),kl&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Ol)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Is(this.view)){if(this.suppressingSelectionUpdates)return Es(this.view);if(ro&&io<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&za(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=Fa(n))t.add(n);for(let r=e.anchorNode;r;r=Fa(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Is(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(ao&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Ll(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&qa(n)&&(c=ws(e))&&c.eq(k.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Es(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Pl(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Rl(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Es(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(ro&&io<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?P(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?P(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},Ml=new WeakMap,Nl=!1;function Pl(e){if(!Ml.has(e)&&(Ml.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=ao,Nl)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.`),Nl=!0}}function Fl(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return za(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Il(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Fl(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?Fl(e,n):null}function Ll(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Rl(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function zl(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,u=c.anchorNode;if(u&&e.dom.contains(u.nodeType==1?u:u.parentNode)&&(l=[{node:u,offset:c.anchorOffset}],qa(c)||l.push({node:c.focusNode,offset:c.focusOffset})),F&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||un.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:Bl,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function Bl(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(co&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||co&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var Vl=/^(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 Hl(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=ws(e,t);if(n&&!e.state.selection.eq(n)){if(F&&po&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,Ja(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=zl(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=ql(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(lo&&e.input.lastIOSEnter>Date.now()-225||po)&&i.some(e=>e.nodeType==1&&!Vl.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,Ja(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof A&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Ul(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof A&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),ro&&io<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((lo&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,Ja(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&Gl(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,Ja(8,`Backspace`)))){po&&F&&e.domObserver.suppressSelectionUpdates();return}F&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),po&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,Ja(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Ul(e,n.doc,l.sel);t&&!(F&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||ro&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},S;if(v)if(h.pos==g.pos){ro&&io<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>Es(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=Wl(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function Ul(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Fs(e,t.resolve(n.anchor),t.resolve(n.head))}function Wl(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(E.from(l).eq(e))return{mark:s,type:o}}function Gl(e,t,n,r,i){if(n-t<=i.pos-r.pos||Kl(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(Kl(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Kl(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Kl(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function ql(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&Jl(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&Jl(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function Jl(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var Yl=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new wc,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(nu),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Ql(this),Zl(this),this.nodeViews=eu(this),this.docView=rs(this.state.doc,Xl(this),Dl(this),this.dom,this),this.domObserver=new jl(this,(e,t,n,r)=>Hl(this,e,t,n,r)),this.domObserver.start(),Tc(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Oc(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(nu),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Yc(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=eu(this);tu(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Oc(this),this.editable=Ql(this),Zl(this);let o=Dl(this),s=Xl(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&bo(this);if(i){this.domObserver.stop();let t=l&&(ro||F)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&$l(n.selection,e.selection);if(l){let n=F?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Xc(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=rs(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Rs(this))?Es(this,t):(Ns(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&So(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof j){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&yo(this,t.getBoundingClientRect(),e)}else yo(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new al(e.slice,e.move,r<0?void 0:j.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(ro){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable==`false`)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&To(this.dom),Es(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return No(this,e)}coordsAtPos(e,t=1){return Lo(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 qo(this,t||this.state,e)}pasteHTML(e,t){return rl(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return rl(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return ic(this,e)}destroy(){this.docView&&(Dc(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Dl(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ra())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return jc(this,e)}domSelectionRange(){let e=this.domSelection();return e?co&&this.root.nodeType===11&&Ya(this.dom.ownerDocument)==this.dom&&Il(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Yl.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Xl(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[pl.node(0,e.state.doc.content.size,t)]}function Zl(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:pl.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Ql(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function $l(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 eu(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function tu(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function nu(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}function ru(e,t){return e.meta={package:`@milkdown/core`,group:`System`,...t},e}var iu={text:(e,t,n,r)=>{let i=e.value;return/^[^*_\\]*\s+$/.test(i)?i:n.safe(i,{...r,encode:[]})},strong:(e,t,n,r)=>{let i=e.marker||n.options.strong||`*`,a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i+i),a(),s},emphasis:(e,t,n,r)=>{let i=e.marker||n.options.emphasis||`*`,a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i);return s+=o.move(n.containerPhrasing(e,{before:s,after:i,...o.current()})),s+=o.move(i),a(),s}},L=w({},`editorView`),au=w({},`editorState`),ou=w([],`initTimer`),su=w({},`editor`),cu=w([],`inputRules`),lu=w([],`prosePlugins`),uu=w([],`remarkPlugins`),du=w([],`nodeView`),fu=w([],`markView`),pu=w(l().use(c).use(lt),`remark`),mu=w({handlers:iu,encode:[]},`remarkStringifyOptions`),hu=ct(`ConfigReady`);function gu(e){let t=t=>(t.record(hu),async()=>(await e(t),t.done(hu),()=>{t.clearTimer(hu)}));return ru(t,{displayName:`Config`}),t}var _u=ct(`InitReady`);function vu(e){let t=t=>(t.inject(su,e).inject(lu,[]).inject(uu,[]).inject(cu,[]).inject(du,[]).inject(fu,[]).inject(mu,{handlers:iu,encode:[]}).inject(pu,l().use(c).use(lt)).inject(ou,[hu]).record(_u),async()=>{await t.waitTimers(ou);let e=t.get(mu);return t.set(pu,l().use(c).use(lt,e)),t.done(_u),()=>{t.remove(su).remove(lu).remove(uu).remove(cu).remove(du).remove(fu).remove(mu).remove(pu).remove(ou).clearTimer(_u)}});return ru(t,{displayName:`Init`}),t}var yu=ct(`SchemaReady`),bu=w([],`schemaTimer`),xu=w({},`schema`),Su=w([],`nodes`),Cu=w([],`marks`);function wu(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var Tu=e=>(e.inject(xu,{}).inject(Su,[]).inject(Cu,[]).inject(bu,[_u]).record(yu),async()=>{await e.waitTimers(bu);let t=e.get(pu),n=e.get(uu).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(pu,n);let r=new on({nodes:Object.fromEntries(e.get(Su).map(([e,t])=>[e,wu(t)])),marks:Object.fromEntries(e.get(Cu).map(([e,t])=>[e,wu(t)]))});return e.set(xu,r),e.done(yu),()=>{e.remove(xu).remove(Su).remove(Cu).remove(bu).clearTimer(yu)}});ru(Tu,{displayName:`Schema`});var Eu=class{constructor(){this.setCtx=e=>{this.#t=e},this.chain=()=>{if(this.#t==null)throw Ze();let e=this.#t,t=[],n=this.get.bind(this),r={run:()=>{let n=Vi(...t),r=e.get(L);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:i.bind(this)};function i(e,i){let a=n(e);return t.push(a(i)),r}return r}}#e=new et;#t=null;get ctx(){return this.#t}create(e,t){let n=e.create(this.#e.sliceMap);return n.set(t),n}get(e){return this.#e.get(e).get()}remove(e){return this.#e.remove(e)}call(e,t){if(this.#t==null)throw Ze();let n=this.get(e)(t),r=this.#t.get(L);return n(r.state,r.dispatch,r)}inline(e){if(this.#t==null)throw Ze();let t=this.#t.get(L);return e(t.state,t.dispatch,t)}};function Du(e=`cmdKey`){return w((()=>()=>!1),e)}var R=w(new Eu,`commands`),Ou=w([yu],`commandsTimer`),ku=ct(`CommandsReady`),Au=e=>{let t=new Eu;return t.setCtx(e),e.inject(R,t).inject(Ou,[yu]).record(ku),async()=>(await e.waitTimers(Ou),e.done(ku),()=>{e.remove(R).remove(Ou).clearTimer(ku)})};ru(Au,{displayName:`Commands`});function ju(e){return e.Backspace=Vi(Yi,di,mi,_i),e}var Mu=class{constructor(){this.setCtx=e=>{this.#e=e},this.add=e=>(this.#t.push(e),()=>{this.#t=this.#t.filter(t=>t!==e)}),this.addObjectKeymap=e=>{let t=[];return Object.entries(e).forEach(([e,n])=>{if(typeof n==`function`){let r={key:e,onRun:()=>n};this.#t.push(r),t.push(()=>{this.#t=this.#t.filter(e=>e!==r)})}else this.#t.push(n),t.push(()=>{this.#t=this.#t.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{let e=ju(Ki);return this.addObjectKeymap(e)},this.build=()=>{let e={};return this.#t.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,r)=>{let i=this.#e;if(i==null)throw We();return Vi(...n.map(e=>e.onRun(i)))(e,t,r)}]}))}}#e=null;#t=[];get ctx(){return this.#e}},Nu=w(new Mu,`keymap`),Pu=w([yu],`keymapTimer`),Fu=ct(`KeymapReady`),Iu=e=>{let t=new Mu;return t.setCtx(e),e.inject(Nu,t).inject(Pu,[yu]).record(Fu),async()=>(await e.waitTimers(Pu),e.done(Fu),()=>{e.remove(Nu).remove(Pu).clearTimer(Fu)})},Lu=ct(`ParserReady`),Ru=(()=>{throw We()}),zu=w(Ru,`parser`),Bu=w([],`parserTimer`),Vu=e=>(e.inject(zu,Ru).inject(Bu,[yu]).record(Lu),async()=>{await e.waitTimers(Bu);let t=e.get(pu),n=e.get(xu);return e.set(zu,ja.create(n,t)),e.done(Lu),()=>{e.remove(zu).remove(Bu).clearTimer(Lu)}});ru(Vu,{displayName:`Parser`});var Hu=ct(`SerializerReady`),Uu=w([],`serializerTimer`),Wu=(()=>{throw We()}),Gu=w(Wu,`serializer`),Ku=e=>(e.inject(Gu,Wu).inject(Uu,[yu]).record(Hu),async()=>{await e.waitTimers(Uu);let t=e.get(pu),n=e.get(xu);return e.set(Gu,Pa.create(n,t)),e.done(Hu),()=>{e.remove(Gu).remove(Uu).clearTimer(Hu)}});ru(Ku,{displayName:`Serializer`});var qu=w(``,`defaultValue`),Ju=w(e=>e,`stateOptions`),Yu=w([],`editorStateTimer`),Xu=ct(`EditorStateReady`);function Zu(e,t,n){if(typeof e==`string`)return t(e);if(e.type===`html`)return un.fromSchema(n).parse(e.dom);if(e.type===`json`)return Pt.fromJSON(n,e.value);throw Ve(e)}var Qu=new N(`MILKDOWN_STATE_TRACKER`),$u=e=>(e.inject(qu,``).inject(au,{}).inject(Ju,e=>e).inject(Yu,[Lu,Hu,ku,Fu]).record(Xu),async()=>{await e.waitTimers(Yu);let t=e.get(xu),n=e.get(zu),r=e.get(cu),i=e.get(Ju),a=e.get(lu),o=Zu(e.get(qu),n,t),s=e.get(Nu),c=s.addBaseKeymap(),l=[...a,new M({key:Qu,state:{init:()=>{},apply:(t,n,r,i)=>{e.set(au,i)}}}),ua({rules:r}),Ea(s.build())];e.set(lu,l);let u=i({schema:t,doc:o,plugins:l}),d=si.create(u);return e.set(au,d),e.done(Xu),()=>{c(),e.remove(qu).remove(au).remove(Ju).remove(Yu).clearTimer(Xu)}});ru($u,{displayName:`EditorState`});var ed=w([],`pasteRule`),td=w([yu],`pasteRuleTimer`),nd=ct(`PasteRuleReady`),rd=e=>(e.inject(ed,[]).inject(td,[yu]).record(nd),async()=>(await e.waitTimers(td),e.done(nd),()=>{e.remove(ed).remove(td).clearTimer(nd)}));ru(rd,{displayName:`PasteRule`});var id=ct(`EditorViewReady`),ad=w([],`editorViewTimer`),od=w({},`editorViewOptions`),sd=w(null,`root`),cd=w(null,`rootDOM`),ld=w({},`rootAttrs`);function ud(e,t){let n=document.createElement(`div`);n.className=`milkdown`,e.appendChild(n),t.set(cd,n);let r=t.get(ld);return Object.entries(r).forEach(([e,t])=>n.setAttribute(e,t)),n}function dd(e){e.classList.add(`editor`),e.setAttribute(`role`,`textbox`)}var fd=new N(`MILKDOWN_VIEW_CLEAR`),pd=e=>(e.inject(sd,document.body).inject(L,{}).inject(od,{}).inject(cd,null).inject(ld,{}).inject(ad,[Xu,nd]).record(id),async()=>{await e.wait(_u);let t=e.get(sd)||document.body,n=typeof t==`string`?document.querySelector(t):t;e.update(lu,t=>[new M({key:fd,view:t=>{let r=n?ud(n,e):void 0;return(()=>{if(r&&n){let e=t.dom;n.replaceChild(r,e),r.appendChild(e)}})(),{destroy:()=>{r?.parentNode&&r?.parentNode.replaceChild(t.dom,r),r?.remove()}}}}),...t]),await e.waitTimers(ad);let r=e.get(au),i=e.get(od),a=new Yl(n,{state:r,nodeViews:Object.fromEntries(e.get(du)),markViews:Object.fromEntries(e.get(fu)),transformPasted:(t,n,r)=>(e.get(ed).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...i});return dd(a.dom),e.set(L,a),e.done(id),()=>{a?.destroy(),e.remove(sd).remove(L).remove(od).remove(cd).remove(ld).remove(ad).clearTimer(id)}});ru(pd,{displayName:`EditorView`});var md=function(e){return e.Idle=`Idle`,e.OnCreate=`OnCreate`,e.Created=`Created`,e.OnDestroy=`OnDestroy`,e.Destroyed=`Destroyed`,e}({}),hd=class e{constructor(){this.enableInspector=(e=!0)=>(this.#e=e,this),this.onStatusChange=e=>(this.#r=e,this),this.config=e=>(this.#n.push(e),this),this.removeConfig=e=>(this.#n=this.#n.filter(t=>t!==e),this),this.use=e=>{let t=[e].flat();return t.flat().forEach(e=>{this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#t===md.Created&&this.#u(t,this.#o),this},this.remove=async e=>this.#t===md.OnCreate?(console.warn(`[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code.`),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#d([e].flat(),!0),this),this.create=async()=>this.#t===md.OnCreate?this:(this.#t===md.Created&&await this.destroy(),this.#p(md.OnCreate),this.#l(),this.#u([...this.#o.keys()],this.#o),await Promise.all([this.#m(this.#s),this.#m(this.#o)].flat()),this.#p(md.Created),this),this.destroy=async(e=!1)=>this.#t===md.Destroyed||this.#t===md.OnDestroy?this:this.#t===md.OnCreate?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#n=[]),this.#p(md.OnDestroy),await this.#d([...this.#o.keys()],e),await this.#f(),this.#p(md.Destroyed),this),this.action=e=>e(this.#c),this.inspect=()=>this.#e?[...this.#s.values(),...this.#o.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}#e=!1;#t=md.Idle;#n=[];#r=()=>void 0;#i=new et;#a=new at;#o=new Map;#s=new Map;#c=new it(this.#i,this.#a);#l=()=>{let e=gu(async e=>{await Promise.all(this.#n.map(t=>Promise.resolve(t(e))))}),t=[Tu,Vu,Ku,Au,Iu,rd,$u,pd,vu(this),e];this.#u(t,this.#s)};#u=(e,t)=>{e.forEach(e=>{let n=this.#c.produce(this.#e?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})};#d=(e,t=!1)=>Promise.all([e].flat().map(async e=>{let n=this.#o.get(e)?.cleanup;return t?this.#o.delete(e):this.#o.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof n==`function`?n():n}));#f=async()=>{await Promise.all([...this.#s.entries()].map(async([e,{cleanup:t}])=>typeof t==`function`?t():t)),this.#s.clear()};#p=e=>{this.#t=e,this.#r(e)};#m=e=>[...e.entries()].map(async([t,n])=>{let{ctx:r,handler:i}=n;if(!i)return;let a=await i();e.set(t,{ctx:r,handler:i,cleanup:a})});get ctx(){return this.#c}get status(){return this.#t}},gd=e=>crypto.getRandomValues(new Uint8Array(e)),_d=(e,t,n)=>{let r=256-256%e.length;if(r===256){let r=e.length-1;return(i=t)=>{if(!i)return``;let a=``;for(;;){let t=n(i),o=i;for(;o--;)if(a+=e[t[o]&r],a.length>=i)return a}}}let i=Math.ceil(1.6*256*t/r);return(a=t)=>{if(!a)return``;let o=``;for(;;){let t=n(i),s=i;for(;s--;)if(t[s]<r&&(o+=e[t[s]%e.length],o.length>=a))return o}}};((e,t=21)=>_d(e,t|0,gd))(`abcedfghicklmn`,10);function z(e,t){let n=Du(e),r=i=>async()=>{r.key=n,await i.wait(ku);let a=t(i);return i.get(R).create(n,a),r.run=t=>i.get(R).call(e,t),()=>{i.get(R).remove(n)}};return r}function vd(e){let t=n=>async()=>{await n.wait(yu);let r=e(n);return n.update(cu,e=>[...e,r]),t.inputRule=r,()=>{n.update(cu,e=>e.filter(e=>e!==r))}};return t}function yd(e){let t=n=>async()=>{await n.wait(yu);let r=e(n);return n.update(ed,e=>[...e,r]),t.pasteRule=r,()=>{n.update(ed,e=>e.filter(e=>e!==r))}};return t}function bd(e,t){let n=r=>async()=>{let i=t(r);return r.update(Cu,t=>[...t.filter(t=>t[0]!==e),[e,i]]),n.id=e,n.schema=i,()=>{r.update(Cu,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{let n=t.get(xu).marks[e];if(!n)throw $e(e);return n},n}function xd(e,t){let n=r=>async()=>{let i=t(r);return r.update(Su,t=>[...t.filter(t=>t[0]!==e),[e,i]]),n.id=e,n.schema=i,()=>{r.update(Su,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{let n=t.get(xu).nodes[e];if(!n)throw Qe(e);return n},n}function Sd(e){let t,n=n=>async()=>(await n.wait(yu),t=e(n),n.update(lu,e=>[...e,t]),()=>{n.update(lu,e=>e.filter(e=>e!==t))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function Cd(e){let t=n=>async()=>{await n.wait(Fu);let r=n.get(Nu),i=e(n),a=r.addObjectKeymap(i);return t.keymap=i,()=>{a()}};return t}function wd(e,t){let n=r=>async()=>{await r.wait(yu);let i=t(r);return e.type(r)instanceof tn?r.update(du,t=>[...t,[e.id,i]]):r.update(fu,t=>[...t,[e.id,i]]),n.view=i,n.type=e,()=>{e.type(r)instanceof tn?r.update(du,t=>t.filter(t=>t[0]!==e.id)):r.update(fu,t=>t.filter(t=>t[0]!==e.id))}};return n}function Td(e,t){let n=w(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}function B(e,t){let n=Td(t,e),r=xd(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.node=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>B(e,n(t)),i}function Ed(e,t){let n=Td(t,e),r=bd(e,e=>e.get(n.key)(e)),i=[n,r];return i.id=r.id,i.mark=r,i.type=e=>r.type(e),i.ctx=n,i.key=n.key,i.extendSchema=n=>Ed(e,n(t)),i}function Dd(e,t){let n=Td(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),r=Cd(e=>{let r=e.get(n.key),i=Object.entries(t).flatMap(([e,{command:t}])=>{let n=r[e],i=[n.shortcuts].flat(),a=n.priority;return i.map(e=>[e,{key:e,onRun:t,priority:a}])});return Object.fromEntries(i)}),i=[n,r];return i.ctx=n,i.shortcuts=r,i.key=n.key,i.keymap=r.keymap,i}var Od=(e,t=()=>({}))=>Td(t,`${e}Attr`),kd=(e,t=()=>({}))=>Td(t,`${e}Attr`);function Ad(e,t,n){let r=Td(n??{},e),i=e=>async()=>{await e.wait(_u);let n={plugin:t(e),options:e.get(r.key)};return e.update(uu,e=>[...e,n]),()=>{e.update(uu,e=>e.filter(e=>e!==n))}},a=[r,i];return a.id=e,a.plugin=i,a.options=r,a}function V(e,t){return n=>n.get(R).call(e,t)}function jd(e){return t=>{let n=t.get(L),r=t.get(xu),i=t.get(Gu);if(!e)return i(n.state.doc);let a=n.state.doc.slice(e.from,e.to,!0),o=r.topNodeType.createAndFill(null,a.content);return o?i(o):(console.error(`No document found`),``)}}function Md(e,t=!1){return n=>{let r=n.get(L),i=n.get(zu)(e);if(!i)return;if(!t){let e=r.state.selection.content();return r.dispatch(r.state.tr.replaceSelection(new O(i.content,e.openStart,e.openEnd)).scrollIntoView())}let a=n.get(xu),o=wn.fromSchema(a).serializeFragment(i.content),s=un.fromSchema(a).parseSlice(o),c=ma(s);if(c){r.dispatch(r.state.tr.replaceSelectionWith(c,!0));return}r.dispatch(r.state.tr.replaceSelection(s))}}function Nd(e,t=!1){return n=>{let r=n.get(L),i=n.get(zu)(e);if(!i)return;if(!t){let{state:e}=r;return r.dispatch(e.tr.replace(0,e.doc.content.size,new O(i.content,0,0)))}let a=n.get(xu),o=n.get(Ju)({schema:a,doc:i,plugins:n.get(lu)}),s=si.create(o);r.updateState(s)}}function Pd(e){return t=>{let n=t.get(zu)(e),r=t.get(xu),i=wn.fromSchema(r).serializeFragment(n.content);return un.fromSchema(r).parseSlice(i)}}function Fd(e,t,n=!1){return r=>{let i=Pd(e)(r),a=r.get(L),o=a.state.doc.resolve(t),s=a.state.doc.content.size,c=n?o.pos:o.after(o.depth-1),l=Math.min(Math.max(c,0),s);a.dispatch(a.state.tr.replace(c,l,i))}}function Id(e,t){return function(n,r){let{$from:i,$to:a,node:o}=n.selection;if(o&&o.isBlock||i.depth<2||!i.sameParent(a))return!1;let s=i.node(-1);if(s.type!=e)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=e||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let t=E.empty,a=i.index(-1)?1:i.index(-2)?2:3;for(let e=i.depth-a;e>=i.depth-3;e--)t=E.from(i.node(e).copy(t));let o=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;t=t.append(E.from(e.createAndFill()));let s=i.before(i.depth-(a-1)),c=n.tr.replace(s,i.after(-o),new O(t,4-a,0)),l=-1;c.doc.nodesBetween(s,c.doc.content.size,(e,t)=>{if(l>-1)return!1;e.isTextblock&&e.content.size==0&&(l=t+1)}),l>-1&&c.setSelection(k.near(c.doc.resolve(l))),r(c.scrollIntoView())}return!0}let c=a.pos==i.end()?s.contentMatchAt(0).defaultType:null,l=n.tr.delete(i.pos,a.pos),u=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return gr(l.doc,i.pos,2,u)?(r&&r(l.split(i.pos,2,u).scrollIntoView()),!0):!1}}function Ld(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?Rd(t,n,e,a):zd(t,n,a):!0:!1}}function Rd(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new Qn(a-1,o,a,o,new O(E.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Mt(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=ir(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return vr(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function zd(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?E.empty:E.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new Qn(d-+!!s,f+ +!!c,d+1,f-1,new O((s?E.empty:E.from(i.copy(E.empty))).append(c?E.empty:E.from(i.copy(E.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function Bd(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=E.from(r?e.create():null),o=new O(E.from(e.create(null,E.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new Qn(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}function Vd(e){let t=new Map;if(!e||!e.type)throw Error(`mdast-util-definitions expected node`);return ne(e,`definition`,function(e){let n=Hd(e.identifier);n&&!t.get(n)&&t.set(n,e)}),n;function n(e){let n=Hd(e);return t.get(n)}}function Hd(e){return String(e||``).toUpperCase()}function Ud(){return function(e){let t=Vd(e);ne(e,function(e,n,r){if(e.type===`definition`&&r!==void 0&&typeof n==`number`)return r.children.splice(n,1),[u,n];if(e.type===`imageReference`||e.type===`linkReference`){let i=t(e.identifier);if(i&&r&&typeof n==`number`)return r.children[n]=e.type===`imageReference`?{type:`image`,url:i.url,title:i.title,alt:e.alt}:{type:`link`,url:i.url,title:i.title,children:e.children},[u,n]}})}}function Wd(e,t){if(!(t.childCount>=1&&t.lastChild?.type.name===`hardbreak`)){e.next(t.content);return}let n=[];t.content.forEach((e,r,i)=>{i!==t.childCount-1&&n.push(e)}),e.next(E.fromArray(n))}function H(e,t){return Object.assign(e,{meta:{package:`@milkdown/preset-commonmark`,...t}}),e}var Gd=kd(`emphasis`);H(Gd,{displayName:`Attr<emphasis>`,group:`Emphasis`});var Kd=Ed(`emphasis`,e=>({attrs:{marker:{default:e.get(mu).emphasis||`*`,validate:`string`}},parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style`,getAttrs:e=>e===`italic`}],toDOM:t=>[`em`,e.get(Gd.key)(t)],parseMarkdown:{match:e=>e.type===`emphasis`,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`emphasis`,runner:(e,t)=>{e.withMark(t,`emphasis`,void 0,{marker:t.attrs.marker})}}}));H(Kd.mark,{displayName:`MarkSchema<emphasis>`,group:`Emphasis`}),H(Kd.ctx,{displayName:`MarkSchemaCtx<emphasis>`,group:`Emphasis`});var qd=z(`ToggleEmphasis`,e=>()=>Bi(Kd.type(e)));H(qd,{displayName:`Command<toggleEmphasisCommand>`,group:`Emphasis`});var Jd=vd(e=>da(/(?:^|[^*])\*([^*]+)\*$/,Kd.type(e),{getAttr:()=>({marker:`*`}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith(`*`)?{}:{fullMatch:e.slice(1),start:t+1}}));H(Jd,{displayName:`InputRule<emphasis>|Star`,group:`Emphasis`});var Yd=vd(e=>da(/\b_(?![_\s])(.*?[^_\s])_\b/,Kd.type(e),{getAttr:()=>({marker:`_`}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith(`_`)?{}:{fullMatch:e.slice(1),start:t+1}}));H(Yd,{displayName:`InputRule<emphasis>|Underscore`,group:`Emphasis`});var Xd=Dd(`emphasisKeymap`,{ToggleEmphasis:{shortcuts:`Mod-i`,command:e=>{let t=e.get(R);return()=>t.call(qd.key)}}});H(Xd.ctx,{displayName:`KeymapCtx<emphasis>`,group:`Emphasis`}),H(Xd.shortcuts,{displayName:`Keymap<emphasis>`,group:`Emphasis`});var Zd=kd(`strong`);H(Zd,{displayName:`Attr<strong>`,group:`Strong`});var Qd=Ed(`strong`,e=>({attrs:{marker:{default:e.get(mu).strong||`*`,validate:`string`}},parseDOM:[{tag:`b`,getAttrs:e=>e.style.fontWeight!=`normal`&&null},{tag:`strong`},{style:`font-style`,getAttrs:e=>e===`bold`},{style:`font-weight=400`,clearMark:e=>e.type.name==`strong`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:t=>[`strong`,e.get(Zd.key)(t)],parseMarkdown:{match:e=>e.type===`strong`,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`strong`,runner:(e,t)=>{e.withMark(t,`strong`,void 0,{marker:t.attrs.marker})}}}));H(Qd.mark,{displayName:`MarkSchema<strong>`,group:`Strong`}),H(Qd.ctx,{displayName:`MarkSchemaCtx<strong>`,group:`Strong`});var $d=z(`ToggleStrong`,e=>()=>Bi(Qd.type(e)));H($d,{displayName:`Command<toggleStrongCommand>`,group:`Strong`});var ef=vd(e=>da(/(?<![\w:/])(?:\*\*|__)([^*_]+?)(?:\*\*|__)(?![\w/])$/,Qd.type(e),{getAttr:e=>({marker:e[0].startsWith(`*`)?`*`:`_`})}));H(ef,{displayName:`InputRule<strong>`,group:`Strong`});var tf=Dd(`strongKeymap`,{ToggleBold:{shortcuts:[`Mod-b`],command:e=>{let t=e.get(R);return()=>t.call($d.key)}}});H(tf.ctx,{displayName:`KeymapCtx<strong>`,group:`Strong`}),H(tf.shortcuts,{displayName:`Keymap<strong>`,group:`Strong`});var nf=kd(`inlineCode`);H(nf,{displayName:`Attr<inlineCode>`,group:`InlineCode`});var rf=Ed(`inlineCode`,e=>({priority:100,code:!0,parseDOM:[{tag:`code`}],toDOM:t=>[`code`,e.get(nf.key)(t)],parseMarkdown:{match:e=>e.type===`inlineCode`,runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`inlineCode`,runner:(e,t,n)=>(e.withMark(t,`inlineCode`,n.text||``),!0)}}));H(rf.mark,{displayName:`MarkSchema<inlineCode>`,group:`InlineCode`}),H(rf.ctx,{displayName:`MarkSchemaCtx<inlineCode>`,group:`InlineCode`});var af=z(`ToggleInlineCode`,e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(r.empty)return!1;let{from:a,to:o}=r;return t.doc.rangeHasMark(a,o,rf.type(e))?(n?.(i.removeMark(a,o,rf.type(e))),!0):(Object.keys(t.schema.marks).filter(e=>e!==rf.type.name).map(e=>t.schema.marks[e]).forEach(e=>{i.removeMark(a,o,e)}),n?.(i.addMark(a,o,rf.type(e).create())),!0)});H(af,{displayName:`Command<toggleInlineCodeCommand>`,group:`InlineCode`});var of=vd(e=>da(/(?:`)([^`]+)(?:`)$/,rf.type(e)));H(of,{displayName:`InputRule<inlineCodeInputRule>`,group:`InlineCode`});var sf=Dd(`inlineCodeKeymap`,{ToggleInlineCode:{shortcuts:`Mod-e`,command:e=>{let t=e.get(R);return()=>t.call(af.key)}}});H(sf.ctx,{displayName:`KeymapCtx<inlineCode>`,group:`InlineCode`}),H(sf.shortcuts,{displayName:`Keymap<inlineCode>`,group:`InlineCode`});var cf=kd(`link`);H(cf,{displayName:`Attr<link>`,group:`Link`});var lf=Ed(`link`,e=>({attrs:{href:{validate:`string`},title:{default:null,validate:`string|null`}},parseDOM:[{tag:`a[href]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM:t=>[`a`,{...e.get(cf.key)(t),...t.attrs}],parseMarkdown:{match:e=>e.type===`link`,runner:(e,t,n)=>{let r=t.url,i=t.title;e.openMark(n,{href:r,title:i}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`link`,runner:(e,t)=>{e.withMark(t,`link`,void 0,{title:t.attrs.title,url:t.attrs.href})}}}));H(lf.mark,{displayName:`MarkSchema<link>`,group:`Link`});var uf=z(`ToggleLink`,e=>(t={})=>Bi(lf.type(e),t));H(uf,{displayName:`Command<toggleLinkCommand>`,group:`Link`});var df=z(`UpdateLink`,e=>(t={})=>(n,r)=>{if(!r)return!1;let i,a=-1,{selection:o}=n,{from:s,to:c}=o;if(n.doc.nodesBetween(s,s===c?c+1:c,(t,n)=>{if(lf.type(e).isInSet(t.marks))return i=t,a=n,!1}),!i)return!1;let l=i.marks.find(({type:t})=>t===lf.type(e));if(!l)return!1;let u=a,d=a+i.nodeSize,{tr:f}=n,p=lf.type(e).create({...l.attrs,...t});return p?(r(f.removeMark(u,d,l).addMark(u,d,p).setSelection(new A(f.selection.$anchor)).scrollIntoView()),!0):!1});H(df,{displayName:`Command<updateLinkCommand>`,group:`Link`});var ff=xd(`doc`,()=>({content:`block+`,parseMarkdown:{match:({type:e})=>e===`root`,runner:(e,t,n)=>{e.injectRoot(t,n)}},toMarkdown:{match:e=>e.type.name===`doc`,runner:(e,t)=>{e.openNode(`root`),e.next(t.content)}}}));H(ff,{displayName:`NodeSchema<doc>`,group:`Doc`});function pf(e){return s(e,e=>e.type===`html`&&[`<br />`,`<br>`,`<br >`,`<br/>`].includes(e.value?.trim()),(e,t)=>{if(!t.length)return;let n=t[t.length-1];if(!n)return;let r=n.children.indexOf(e);r!==-1&&n.children.splice(r,1)},!0)}var mf=Ad(`remark-preserve-empty-line`,()=>()=>pf);H(mf.plugin,{displayName:`Remark<remarkPreserveEmptyLine>`,group:`Remark`}),H(mf.options,{displayName:`RemarkConfig<remarkPreserveEmptyLine>`,group:`Remark`});var hf=Od(`paragraph`);H(hf,{displayName:`Attr<paragraph>`,group:`Paragraph`});var gf=B(`paragraph`,e=>({content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM:t=>[`p`,e.get(hf.key)(t),0],parseMarkdown:{match:e=>e.type===`paragraph`,runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||``),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`paragraph`,runner:(t,n)=>{let r=e.get(L).state?.doc.lastChild;t.openNode(`paragraph`),(!n.content||n.content.size===0)&&n!==r&&_f(e)?t.addNode(`html`,void 0,`<br />`):Wd(t,n),t.closeNode()}}}));function _f(e){let t=!1;try{e.get(mf.id),t=!0}catch{t=!1}return t}H(gf.node,{displayName:`NodeSchema<paragraph>`,group:`Paragraph`}),H(gf.ctx,{displayName:`NodeSchemaCtx<paragraph>`,group:`Paragraph`});var vf=z(`TurnIntoText`,e=>()=>Li(gf.type(e)));H(vf,{displayName:`Command<turnIntoTextCommand>`,group:`Paragraph`});var yf=Dd(`paragraphKeymap`,{TurnIntoText:{shortcuts:`Mod-Alt-0`,command:e=>{let t=e.get(R);return()=>t.call(vf.key)}}});H(yf.ctx,{displayName:`KeymapCtx<paragraph>`,group:`Paragraph`}),H(yf.shortcuts,{displayName:`Keymap<paragraph>`,group:`Paragraph`});var bf=[,,,,,,].fill(0).map((e,t)=>t+1);function xf(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,`-`)}var Sf=Td(xf,`headingIdGenerator`);H(Sf,{displayName:`Ctx<HeadingIdGenerator>`,group:`Heading`});var Cf=Od(`heading`);H(Cf,{displayName:`Attr<heading>`,group:`Heading`});var wf=B(`heading`,e=>{let t=e.get(Sf.key);return{content:`inline*`,group:`block`,defining:!0,attrs:{id:{default:``,validate:`string`},level:{default:1,validate:`number`}},parseDOM:bf.map(e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw Xe(t);return{level:e,id:t.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...e.get(Cf.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>e===`heading`,runner:(e,t,n)=>{let r=t.depth;e.openNode(n,{level:r}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`heading`,runner:(e,t)=>{e.openNode(`heading`,void 0,{depth:t.attrs.level}),Wd(e,t),e.closeNode()}}}});H(wf.node,{displayName:`NodeSchema<heading>`,group:`Heading`}),H(wf.ctx,{displayName:`NodeSchemaCtx<heading>`,group:`Heading`});var Tf=vd(e=>Zi(/^(?<hashes>#+)\s$/,wf.type(e),t=>{let n=t.groups?.hashes?.length||0,{$from:r}=e.get(L).state.selection,i=r.node();if(i.type.name===`heading`){let e=Number(i.attrs.level)+Number(n);return e>6&&(e=6),{level:e}}return{level:n}}));H(Tf,{displayName:`InputRule<wrapInHeadingInputRule>`,group:`Heading`});var Ef=z(`WrapInHeading`,e=>t=>(t??=1,t<1?Li(gf.type(e)):Li(wf.type(e),{level:t})));H(Ef,{displayName:`Command<wrapInHeadingCommand>`,group:`Heading`});var Df=z(`DowngradeHeading`,e=>()=>(t,n,r)=>{let{$from:i}=t.selection,a=i.node();if(a.type!==wf.type(e)||!t.selection.empty||i.parentOffset!==0)return!1;let o=a.attrs.level-1;return o?(n?.(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...a.attrs,level:o})),!0):Li(gf.type(e))(t,n,r)});H(Df,{displayName:`Command<downgradeHeadingCommand>`,group:`Heading`});var Of=Dd(`headingKeymap`,{TurnIntoH1:{shortcuts:`Mod-Alt-1`,command:e=>{let t=e.get(R);return()=>t.call(Ef.key,1)}},TurnIntoH2:{shortcuts:`Mod-Alt-2`,command:e=>{let t=e.get(R);return()=>t.call(Ef.key,2)}},TurnIntoH3:{shortcuts:`Mod-Alt-3`,command:e=>{let t=e.get(R);return()=>t.call(Ef.key,3)}},TurnIntoH4:{shortcuts:`Mod-Alt-4`,command:e=>{let t=e.get(R);return()=>t.call(Ef.key,4)}},TurnIntoH5:{shortcuts:`Mod-Alt-5`,command:e=>{let t=e.get(R);return()=>t.call(Ef.key,5)}},TurnIntoH6:{shortcuts:`Mod-Alt-6`,command:e=>{let t=e.get(R);return()=>t.call(Ef.key,6)}},DowngradeHeading:{shortcuts:[`Delete`,`Backspace`],command:e=>{let t=e.get(R);return()=>t.call(Df.key)}}});H(Of.ctx,{displayName:`KeymapCtx<heading>`,group:`Heading`}),H(Of.shortcuts,{displayName:`Keymap<heading>`,group:`Heading`});var kf=Od(`blockquote`);H(kf,{displayName:`Attr<blockquote>`,group:`Blockquote`});var Af=B(`blockquote`,e=>({content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM:t=>[`blockquote`,e.get(kf.key)(t),0],parseMarkdown:{match:({type:e})=>e===`blockquote`,runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`blockquote`,runner:(e,t)=>{e.openNode(`blockquote`).next(t.content).closeNode()}}}));H(Af.node,{displayName:`NodeSchema<blockquote>`,group:`Blockquote`}),H(Af.ctx,{displayName:`NodeSchemaCtx<blockquote>`,group:`Blockquote`});var jf=vd(e=>Xi(/^\s*>\s$/,Af.type(e)));H(jf,{displayName:`InputRule<wrapInBlockquoteInputRule>`,group:`Blockquote`});var Mf=z(`WrapInBlockquote`,e=>()=>Ii(Af.type(e)));H(Mf,{displayName:`Command<wrapInBlockquoteCommand>`,group:`Blockquote`});var Nf=Dd(`blockquoteKeymap`,{WrapInBlockquote:{shortcuts:`Mod-Shift-b`,command:e=>{let t=e.get(R);return()=>t.call(Mf.key)}}});H(Nf.ctx,{displayName:`KeymapCtx<blockquote>`,group:`Blockquote`}),H(Nf.shortcuts,{displayName:`Keymap<blockquote>`,group:`Blockquote`});var Pf=Od(`codeBlock`,()=>({pre:{},code:{}}));H(Pf,{displayName:`Attr<codeBlock>`,group:`CodeBlock`});var Ff=B(`code_block`,e=>({content:`text*`,group:`block`,marks:``,defining:!0,code:!0,attrs:{language:{default:``,validate:`string`}},parseDOM:[{tag:`pre`,preserveWhitespace:`full`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{language:e.dataset.language}}}],toDOM:t=>{let n=e.get(Pf.key)(t),r=t.attrs.language,i=r&&r.length>0?{"data-language":r}:void 0;return[`pre`,{...n.pre,...i},[`code`,n.code,0]]},parseMarkdown:{match:({type:e})=>e===`code`,runner:(e,t,n)=>{let r=t.lang??``,i=t.value;e.openNode(n,{language:r}),i&&e.addText(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`code_block`,runner:(e,t)=>{e.addNode(`code`,void 0,t.content.firstChild?.text||``,{lang:t.attrs.language})}}}));H(Ff.node,{displayName:`NodeSchema<codeBlock>`,group:`CodeBlock`}),H(Ff.ctx,{displayName:`NodeSchemaCtx<codeBlock>`,group:`CodeBlock`});var If=vd(e=>Zi(/^```(?<language>[a-z]*)?[\s\n]$/,Ff.type(e),e=>({language:e.groups?.language??``})));H(If,{displayName:`InputRule<createCodeBlockInputRule>`,group:`CodeBlock`});var Lf=z(`CreateCodeBlock`,e=>(t=``)=>Li(Ff.type(e),{language:t}));H(Lf,{displayName:`Command<createCodeBlockCommand>`,group:`CodeBlock`}),H(z(`UpdateCodeBlockLanguage`,()=>({pos:e,language:t}={pos:-1,language:``})=>(n,r)=>e>=0?(r?.(n.tr.setNodeAttribute(e,`language`,t)),!0):!1),{displayName:`Command<updateCodeBlockLanguageCommand>`,group:`CodeBlock`});var Rf=Dd(`codeBlockKeymap`,{CreateCodeBlock:{shortcuts:`Mod-Alt-c`,command:e=>{let t=e.get(R);return()=>t.call(Lf.key)}}});H(Rf.ctx,{displayName:`KeymapCtx<codeBlock>`,group:`CodeBlock`}),H(Rf.shortcuts,{displayName:`Keymap<codeBlock>`,group:`CodeBlock`});var zf=Od(`image`);H(zf,{displayName:`Attr<image>`,group:`Image`});var Bf=B(`image`,e=>({inline:!0,group:`inline`,selectable:!0,draggable:!0,marks:``,atom:!0,defining:!0,isolating:!0,attrs:{src:{default:``,validate:`string`},alt:{default:``,validate:`string`},title:{default:``,validate:`string`}},parseDOM:[{tag:`img[src]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{src:e.getAttribute(`src`)||``,alt:e.getAttribute(`alt`)||``,title:e.getAttribute(`title`)||e.getAttribute(`alt`)||``}}}],toDOM:t=>[`img`,{...e.get(zf.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>e===`image`,runner:(e,t,n)=>{let r=t.url,i=t.alt,a=t.title;e.addNode(n,{src:r,alt:i,title:a})}},toMarkdown:{match:e=>e.type.name===`image`,runner:(e,t)=>{e.addNode(`image`,void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));H(Bf.node,{displayName:`NodeSchema<image>`,group:`Image`}),H(Bf.ctx,{displayName:`NodeSchemaCtx<image>`,group:`Image`});var Vf=z(`InsertImage`,e=>(t={})=>(n,r)=>{if(!r)return!0;let{src:i=``,alt:a=``,title:o=``}=t,s=Bf.type(e).create({src:i,alt:a,title:o});return s&&r(n.tr.replaceSelectionWith(s).scrollIntoView()),!0});H(Vf,{displayName:`Command<insertImageCommand>`,group:`Image`});var Hf=z(`UpdateImage`,e=>(t={})=>(n,r)=>{let i=ya(n.selection,Bf.type(e));if(!i)return!1;let{node:a,pos:o}=i,s={...a.attrs},{src:c,alt:l,title:u}=t;return c!==void 0&&(s.src=c),l!==void 0&&(s.alt=l),u!==void 0&&(s.title=u),r?.(n.tr.setNodeMarkup(o,void 0,s).scrollIntoView()),!0});H(Hf,{displayName:`Command<updateImageCommand>`,group:`Image`}),H(vd(e=>new qi(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,n,r,i)=>{let[a,o,s=``,c]=n;return a?t.tr.replaceWith(r,i,Bf.type(e).create({src:s,alt:o,title:c})):null})),{displayName:`InputRule<insertImageInputRule>`,group:`Image`});var Uf=Od(`hardbreak`,e=>({"data-type":`hardbreak`,"data-is-inline":e.attrs.isInline}));H(Uf,{displayName:`Attr<hardbreak>`,group:`Hardbreak`});var Wf=B(`hardbreak`,e=>({inline:!0,group:`inline`,attrs:{isInline:{default:!1,validate:`boolean`}},selectable:!1,parseDOM:[{tag:`br`},{tag:`span[data-type="hardbreak"]`,getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?[`span`,e.get(Uf.key)(t),` `]:[`br`,e.get(Uf.key)(t)],parseMarkdown:{match:({type:e})=>e===`break`,runner:(e,t,n)=>{e.addNode(n,{isInline:!!t.data?.isInline})}},leafText:()=>`
|
|
32
32
|
`,toMarkdown:{match:e=>e.type.name===`hardbreak`,runner:(e,t)=>{t.attrs.isInline?e.addNode(`text`,void 0,`
|
|
33
|
-
`):e.addNode(`break`)}}}));H(Wf.node,{displayName:`NodeSchema<hardbreak>`,group:`Hardbreak`}),H(Wf.ctx,{displayName:`NodeSchemaCtx<hardbreak>`,group:`Hardbreak`});var Gf=z(`InsertHardbreak`,e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(!(r instanceof A))return!1;if(r.empty){let e=r.$from.node();if(e.childCount>0&&e.lastChild?.type.name===`hardbreak`)return n?.(i.replaceRangeWith(r.to-1,r.to,t.schema.node(`paragraph`)).setSelection(k.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return n?.(i.setMeta(`hardbreak`,!0).replaceSelectionWith(Wf.type(e).create()).scrollIntoView()),!0});H(Gf,{displayName:`Command<insertHardbreakCommand>`,group:`Hardbreak`});var Kf=Dd(`hardbreakKeymap`,{InsertHardbreak:{shortcuts:`Shift-Enter`,command:e=>{let t=e.get(R);return()=>t.call(Gf.key)}}});H(Kf.ctx,{displayName:`KeymapCtx<hardbreak>`,group:`Hardbreak`}),H(Kf.shortcuts,{displayName:`Keymap<hardbreak>`,group:`Hardbreak`});var qf=Od(`hr`);H(qf,{displayName:`Attr<hr>`,group:`Hr`});var Jf=B(`hr`,e=>({group:`block`,parseDOM:[{tag:`hr`}],toDOM:t=>[`hr`,e.get(qf.key)(t)],parseMarkdown:{match:({type:e})=>e===`thematicBreak`,runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>e.type.name===`hr`,runner:e=>{e.addNode(`thematicBreak`)}}}));H(Jf.node,{displayName:`NodeSchema<hr>`,group:`Hr`}),H(Jf.ctx,{displayName:`NodeSchemaCtx<hr>`,group:`Hr`});var Yf=vd(e=>new qi(/^(?:---|___\s|\*\*\*\s)$/,(t,n,r,i)=>{let{tr:a}=t;return n[0]&&a.replaceWith(r-1,i,Jf.type(e).create()),a}));H(Yf,{displayName:`InputRule<insertHrInputRule>`,group:`Hr`});var Xf=z(`InsertHr`,e=>()=>(t,n)=>{if(!n)return!0;let r=gf.node.type(e).create(),{tr:i,selection:a}=t,{from:o}=a,s=Jf.type(e).create();if(!s)return!0;let c=i.replaceSelectionWith(s).insert(o,r),l=k.findFrom(c.doc.resolve(o),1,!0);return l&&n(c.setSelection(l).scrollIntoView()),!0});H(Xf,{displayName:`Command<insertHrCommand>`,group:`Hr`});var Zf=Od(`bulletList`);H(Zf,{displayName:`Attr<bulletList>`,group:`BulletList`});var Qf=B(`bullet_list`,e=>({content:`listItem+`,group:`block`,attrs:{spread:{default:!1,validate:`boolean`}},parseDOM:[{tag:`ul`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{spread:e.dataset.spread===`true`}}}],toDOM:t=>[`ul`,{...e.get(Zf.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e===`list`&&!t,runner:(e,t,n)=>{let r=t.spread==null?`false`:`${t.spread}`;e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`bullet_list`,runner:(e,t)=>{e.openNode(`list`,void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));H(Qf.node,{displayName:`NodeSchema<bulletList>`,group:`BulletList`}),H(Qf.ctx,{displayName:`NodeSchemaCtx<bulletList>`,group:`BulletList`});var $f=vd(e=>Xi(/^\s*([-+*])\s$/,Qf.type(e)));H($f,{displayName:`InputRule<wrapInBulletListInputRule>`,group:`BulletList`});var ep=z(`WrapInBulletList`,e=>()=>Ii(Qf.type(e)));H(ep,{displayName:`Command<wrapInBulletListCommand>`,group:`BulletList`});var tp=Dd(`bulletListKeymap`,{WrapInBulletList:{shortcuts:`Mod-Alt-8`,command:e=>{let t=e.get(R);return()=>t.call(ep.key)}}});H(tp.ctx,{displayName:`KeymapCtx<bulletListKeymap>`,group:`BulletList`}),H(tp.shortcuts,{displayName:`Keymap<bulletListKeymap>`,group:`BulletList`});var np=Od(`orderedList`);H(np,{displayName:`Attr<orderedList>`,group:`OrderedList`});var rp=B(`ordered_list`,e=>({content:`listItem+`,group:`block`,attrs:{order:{default:1,validate:`number`},spread:{default:!1,validate:`boolean`}},parseDOM:[{tag:`ol`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{spread:e.dataset.spread,order:e.hasAttribute(`start`)?Number(e.getAttribute(`start`)):1}}}],toDOM:t=>[`ol`,{...e.get(np.key)(t),...t.attrs.order===1?{}:{start:t.attrs.order},"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e===`list`&&!!t,runner:(e,t,n)=>{let r=t.spread==null?`true`:`${t.spread}`;e.openNode(n,{spread:r,order:t.start??1}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`ordered_list`,runner:(e,t)=>{e.openNode(`list`,void 0,{ordered:!0,start:t.attrs.order??1,spread:t.attrs.spread===`true`}),e.next(t.content),e.closeNode()}}}));H(rp.node,{displayName:`NodeSchema<orderedList>`,group:`OrderedList`}),H(rp.ctx,{displayName:`NodeSchemaCtx<orderedList>`,group:`OrderedList`});var ip=vd(e=>Xi(/^\s*(\d+)\.\s$/,rp.type(e),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));H(ip,{displayName:`InputRule<wrapInOrderedListInputRule>`,group:`OrderedList`});var ap=z(`WrapInOrderedList`,e=>()=>Ii(rp.type(e)));H(ap,{displayName:`Command<wrapInOrderedListCommand>`,group:`OrderedList`});var op=Dd(`orderedListKeymap`,{WrapInOrderedList:{shortcuts:`Mod-Alt-7`,command:e=>{let t=e.get(R);return()=>t.call(ap.key)}}});H(op.ctx,{displayName:`KeymapCtx<orderedList>`,group:`OrderedList`}),H(op.shortcuts,{displayName:`Keymap<orderedList>`,group:`OrderedList`});var sp=Od(`listItem`);H(sp,{displayName:`Attr<listItem>`,group:`ListItem`});var cp=B(`list_item`,e=>({group:`listItem`,content:`paragraph block*`,attrs:{label:{default:`•`,validate:`string`},listType:{default:`bullet`,validate:`string`},spread:{default:!0,validate:`boolean`}},defining:!0,parseDOM:[{tag:`li`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread===`true`}}}],toDOM:t=>[`li`,{...e.get(sp.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e})=>e===`listItem`,runner:(e,t,n)=>{let r=t.label==null?`•`:`${t.label}.`,i=t.label==null?`bullet`:`ordered`,a=t.spread==null?`true`:`${t.spread}`;e.openNode(n,{label:r,listType:i,spread:a}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`list_item`,runner:(e,t)=>{e.openNode(`listItem`,void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));H(cp.node,{displayName:`NodeSchema<listItem>`,group:`ListItem`}),H(cp.ctx,{displayName:`NodeSchemaCtx<listItem>`,group:`ListItem`});var lp=z(`SinkListItem`,e=>()=>Bd(cp.type(e)));H(lp,{displayName:`Command<sinkListItemCommand>`,group:`ListItem`});var up=z(`LiftListItem`,e=>()=>Ld(cp.type(e)));H(up,{displayName:`Command<liftListItemCommand>`,group:`ListItem`});var dp=z(`SplitListItem`,e=>()=>Id(cp.type(e)));H(dp,{displayName:`Command<splitListItemCommand>`,group:`ListItem`});function fp(e){return(t,n,r)=>{let{selection:i}=t;if(!(i instanceof A))return!1;let{empty:a,$from:o}=i;return!a||o.parentOffset!==0||o.node(-1).type!==cp.type(e)?!1:pi(t,n,r)}}var pp=z(`LiftFirstListItem`,e=>()=>fp(e));H(pp,{displayName:`Command<liftFirstListItemCommand>`,group:`ListItem`});var mp=Dd(`listItemKeymap`,{NextListItem:{shortcuts:`Enter`,command:e=>{let t=e.get(R);return()=>t.call(dp.key)}},SinkListItem:{shortcuts:[`Tab`,`Mod-]`],command:e=>{let t=e.get(R);return()=>t.call(lp.key)}},LiftListItem:{shortcuts:[`Shift-Tab`,`Mod-[`],command:e=>{let t=e.get(R);return()=>t.call(up.key)}},LiftFirstListItem:{shortcuts:[`Backspace`,`Delete`],command:e=>{let t=e.get(R);return()=>t.call(pp.key)}}});H(mp.ctx,{displayName:`KeymapCtx<listItem>`,group:`ListItem`}),H(mp.shortcuts,{displayName:`Keymap<listItem>`,group:`ListItem`});var hp=xd(`text`,()=>({group:`inline`,parseMarkdown:{match:({type:e})=>e===`text`,runner:(e,t)=>{e.addText(t.value)}},toMarkdown:{match:e=>e.type.name===`text`,runner:(e,t)=>{e.addNode(`text`,void 0,t.text)}}}));H(hp,{displayName:`NodeSchema<text>`,group:`Text`});var gp=Od(`html`);H(gp,{displayName:`Attr<html>`,group:`Html`});var _p=B(`html`,e=>({atom:!0,group:`inline`,inline:!0,attrs:{value:{default:``,validate:`string`}},toDOM:t=>{let n=document.createElement(`span`),r={...e.get(gp.key)(t),"data-value":t.attrs.value,"data-type":`html`};return n.textContent=t.attrs.value,[`span`,r,t.attrs.value]},parseDOM:[{tag:`span[data-type="html"]`,getAttrs:e=>({value:e.dataset.value??``})}],parseMarkdown:{match:({type:e})=>e===`html`,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name===`html`,runner:(e,t)=>{e.addNode(`html`,void 0,t.attrs.value)}}}));H(_p.node,{displayName:`NodeSchema<html>`,group:`Html`}),H(_p.ctx,{displayName:`NodeSchemaCtx<html>`,group:`Html`});var vp=[ff,hf,gf,Sf,Cf,wf,Uf,Wf,kf,Af,Pf,Ff,qf,Jf,zf,Bf,Zf,Qf,np,rp,sp,cp,Gd,Kd,Zd,Qd,nf,rf,cf,lf,gp,_p,hp].flat(),yp=[jf,$f,ip,If,Yf,Tf].flat(),bp=[Jd,Yd,of,ef],xp=[vf,Mf,Ef,Df,Lf,Gf,Xf,Vf,Hf,ap,ep,lp,dp,up,pp,qd,af,$d,uf,df,z(`IsMarkSelected`,()=>e=>t=>{if(!e)return!1;let{doc:n,selection:r}=t;return n.rangeHasMark(r.from,r.to,e)}),z(`IsNoteSelected`,()=>e=>t=>e?ba(t,e).hasNode:!1),z(`ClearTextInCurrentBlock`,()=>()=>(e,t)=>{let n=e.tr,{$from:r,$to:i}=n.selection,{pos:a}=r,{pos:o}=i,s=a-r.node().content.size;return s<0?!1:(n=n.deleteRange(s,o),t?.(n),!0)}),z(`SetBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr,{from:o,to:s}=a.selection;try{a.setBlockType(o,s,r,i)}catch{return!1}return n?.(a),!0}),z(`WrapInBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr;try{let{$from:e,$to:t}=a.selection,n=e.blockRange(t),o=n&&or(n,r,i);if(!o)return!1;a=a.wrap(n,o)}catch{return!1}return n?.(a),!0}),z(`AddBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr;try{let e=r instanceof Pt?r:r.createAndFill(i);if(!e)return!1;a.replaceSelectionWith(e)}catch{return!1}return n?.(a),!0}),z(`SelectTextNearPos`,()=>e=>(t,n)=>{let{pos:r}=e??{};if(r==null)return!1;let i=(e,t,n)=>Math.min(Math.max(e,t),n),a=t.tr;try{let e=t.doc.resolve(i(r,0,t.doc.content.size));a.setSelection(A.near(e))}catch{return!1}return n?.(a.scrollIntoView()),!0})],Sp=[Nf,Rf,Kf,Of,mp,op,tp,yf,Xd,sf,tf].flat(),Cp=Ad(`remarkAddOrderInList`,()=>()=>e=>{s(e,`list`,e=>{if(e.ordered){let t=e.start??1;e.children.forEach((e,n)=>{e.label=n+t})}})});H(Cp.plugin,{displayName:`Remark<remarkAddOrderInListPlugin>`,group:`Remark`}),H(Cp.options,{displayName:`RemarkConfig<remarkAddOrderInListPlugin>`,group:`Remark`});var wp=Ad(`remarkLineBreak`,()=>()=>e=>{let t=/[\t ]*(?:\r?\n|\r)/g;s(e,`text`,(e,n,r)=>{if(!e.value||typeof e.value!=`string`)return;let i=[],a=0;t.lastIndex=0;let o=t.exec(e.value);for(;o;){let n=o.index;a!==n&&i.push({type:`text`,value:e.value.slice(a,n)}),i.push({type:`break`,data:{isInline:!0}}),a=n+o[0].length,o=t.exec(e.value)}if(i.length>0&&r&&typeof n==`number`)return a<e.value.length&&i.push({type:`text`,value:e.value.slice(a)}),r.children.splice(n,1,...i),n+i.length})});H(wp.plugin,{displayName:`Remark<remarkLineBreak>`,group:`Remark`}),H(wp.options,{displayName:`RemarkConfig<remarkLineBreak>`,group:`Remark`});var Tp=Ad(`remarkInlineLink`,()=>Ud);H(Tp.plugin,{displayName:`Remark<remarkInlineLinkPlugin>`,group:`Remark`}),H(Tp.options,{displayName:`RemarkConfig<remarkInlineLinkPlugin>`,group:`Remark`});var Ep=e=>!!e.children,Dp=e=>e.type===`html`;function Op(e,t){return n(e,0,null)[0];function n(e,r,i){if(Ep(e)){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i){let a=n(i,r,e);if(a)for(let e=0,n=a.length;e<n;e++){let n=a[e];n&&t.push(n)}}}e.children=t}return t(e,r,i)}}var kp=[`root`,`blockquote`,`listItem`],Ap=Ad(`remarkHTMLTransformer`,()=>()=>e=>{Op(e,(e,t,n)=>(Dp(e)&&n&&kp.includes(n.type)&&(e.children=[{...e}],delete e.value,e.type=`paragraph`),[e]))});H(Ap.plugin,{displayName:`Remark<remarkHtmlTransformer>`,group:`Remark`}),H(Ap.options,{displayName:`RemarkConfig<remarkHtmlTransformer>`,group:`Remark`});var jp=Ad(`remarkMarker`,()=>()=>(e,t)=>{let n=e=>t.value.charAt(e.position.start.offset);s(e,e=>[`strong`,`emphasis`].includes(e.type),e=>{e.marker=n(e)})});H(jp.plugin,{displayName:`Remark<remarkMarker>`,group:`Remark`}),H(jp.options,{displayName:`RemarkConfig<remarkMarker>`,group:`Remark`});var Mp=Sd(()=>{let e=!1,t=new M({key:new N(`MILKDOWN_INLINE_NODES_CURSOR`),state:{init(){return!1},apply(e){if(!e.selection.empty)return!1;let t=e.selection.$from,n=t.nodeBefore,r=t.nodeAfter;return!!(n&&r&&n.isInline&&!n.isText&&r.isInline&&!r.isText)}},props:{handleDOMEvents:{compositionend:(n,r)=>e?(e=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){let e=n.state.selection.from;r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||``,e))}}),!0):!1,compositionstart:n=>(t.getState(n.state)&&(e=!0),!1),beforeinput:(n,r)=>{if(t.getState(n.state)&&r instanceof InputEvent&&r.data&&!e){let e=n.state.selection.from;return r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||``,e)),!0}return!1}},decorations(e){if(t.getState(e)){let t=e.selection.$from.pos,n=document.createElement(`span`),r=pl.widget(t,n,{side:-1}),i=document.createElement(`span`),a=pl.widget(t,i);return setTimeout(()=>{n.contentEditable=`true`,i.contentEditable=`true`}),I.create(e.doc,[r,a])}return I.empty}}});return t});H(Mp,{displayName:`Prose<inlineNodesCursorPlugin>`,group:`Prose`});var Np=Sd(e=>new M({key:new N(`MILKDOWN_HARDBREAK_MARKS`),appendTransaction:(t,n,r)=>{if(!t.length)return;let[i]=t;if(!i)return;let[a]=i.steps;if(i.getMeta(`hardbreak`)){if(!(a instanceof Zn))return;let{from:t}=a;return r.tr.setNodeMarkup(t,Wf.type(e),void 0,[])}if(a instanceof qn){let t=r.tr,{from:n,to:i}=a;return r.doc.nodesBetween(n,i,(n,r)=>{n.type===Wf.type(e)&&(t=t.setNodeMarkup(r,Wf.type(e),void 0,[]))}),t}}}));H(Np,{displayName:`Prose<hardbreakClearMarkPlugin>`,group:`Prose`});var Pp=Td([`table`,`code_block`],`hardbreakFilterNodes`);H(Pp,{displayName:`Ctx<hardbreakFilterNodes>`,group:`Prose`});var Fp=Sd(e=>{let t=e.get(Pp.key);return new M({key:new N(`MILKDOWN_HARDBREAK_FILTER`),filterTransaction:(e,n)=>{let r=e.getMeta(`hardbreak`),[i]=e.steps;if(r&&i){let{from:e}=i,r=n.doc.resolve(e),a=r.depth,o=!0;for(;a>0;)t.includes(r.node(a).type.name)&&(o=!1),a--;return o}return!0}})});H(Fp,{displayName:`Prose<hardbreakFilterPlugin>`,group:`Prose`});var Ip=Sd(e=>{let t=new N(`MILKDOWN_HEADING_ID`),n=n=>{if(n.composing)return;let r=e.get(Sf.key),i=n.state.tr.setMeta(`addToHistory`,!1),a=!1,o={};n.state.doc.descendants((n,s)=>{if(n.type===wf.type(e)){if(n.textContent.trim().length===0)return;let e=n.attrs,c=r(n);o[c]?(o[c]+=1,c+=`-#${o[c]}`):o[c]=1,e.id!==c&&(a=!0,i.setMeta(t,!0).setNodeMarkup(s,void 0,{...e,id:c}))}}),a&&n.dispatch(i)};return new M({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})});H(Ip,{displayName:`Prose<syncHeadingIdPlugin>`,group:`Prose`});var Lp=Sd(e=>new M({key:new N(`MILKDOWN_KEEP_LIST_ORDER`),appendTransaction:(t,n,r)=>{if(!r.selection||t.some(e=>e.getMeta(`addToHistory`)===!1||!e.isGeneric))return null;let i=rp.type(e),a=Qf.type(e),o=cp.type(e),s=(e,t,n=1)=>{let r=!1,i=`${t+n}.`;return e.label!==i&&(e.label=i,r=!0),r},c=r.tr,l=!1;return r.doc.descendants((e,t,n,r)=>{if(e.type===a){let n=e.maybeChild(0);n?.type===o&&n.attrs.listType===`ordered`&&(l=!0,c.setNodeMarkup(t,i,{spread:`true`}),e.descendants((e,t,n,r)=>{if(e.type===o){let n={...e.attrs};s(n,r)&&(c=c.setNodeMarkup(t,void 0,n))}return!1}))}else if(e.type===o&&n?.type===i){let i={...e.attrs},a=!1;i.listType!==`ordered`&&(i.listType=`ordered`,a=!0),n?.maybeChild(0)&&(a=s(i,r,n?.attrs.order??1)),a&&(c=c.setNodeMarkup(t,void 0,i),l=!0)}}),l?c.setMeta(`addToHistory`,!1):null}}));H(Lp,{displayName:`Prose<syncListOrderPlugin>`,group:`Prose`});var Rp=[vp,yp,bp,xp,Sp,[Np,Pp,Fp,Mp,Cp,Tp,wp,Ap,jp,mf,Ip,Lp].flat()].flat(),zp,Bp;if(typeof WeakMap<`u`){let e=new WeakMap;zp=t=>e.get(t),Bp=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;zp=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},Bp=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var U=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return zp(e)||Bp(e,Vp(e))}};function Vp(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=Hp(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new U(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&Up(s,o,e),s}function Hp(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function Up(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!c.colwidth||c.colwidth[n]!=r)&&((s||=Wp(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function Wp(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Gp(e,t){if(typeof e==`string`)return{};let n=e.getAttribute(`data-colwidth`),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(`,`).map(e=>Number(e)):null,i=Number(e.getAttribute(`colspan`)||1),a={colspan:i,rowspan:Number(e.getAttribute(`rowspan`)||1),colwidth:r&&r.length==i?r:null};for(let n in t){let r=t[n].getFromDOM,i=r&&r(e);i!=null&&(a[n]=i)}return a}function Kp(e,t){let n={};e.attrs.colspan!=1&&(n.colspan=e.attrs.colspan),e.attrs.rowspan!=1&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n[`data-colwidth`]=e.attrs.colwidth.join(`,`));for(let r in t){let i=t[r].setDOMAttr;i&&i(e.attrs[r],n)}return n}function qp(e){if(e!==null){if(!Array.isArray(e))throw TypeError(`colwidth must be null or an array`);for(let t of e)if(typeof t!=`number`)throw TypeError(`colwidth must be null or an array of numbers`)}}function Jp(e){let t=e.cellAttributes||{},n={colspan:{default:1,validate:`number`},rowspan:{default:1,validate:`number`},colwidth:{default:null,validate:qp}};for(let e in t)n[e]={default:t[e].default,validate:t[e].validate};return{table:{content:`table_row+`,tableRole:`table`,isolating:!0,group:e.tableGroup,parseDOM:[{tag:`table`}],toDOM(){return[`table`,[`tbody`,0]]}},table_row:{content:`(table_cell | table_header)*`,tableRole:`row`,parseDOM:[{tag:`tr`}],toDOM(){return[`tr`,0]}},table_cell:{content:e.cellContent,attrs:n,tableRole:`cell`,isolating:!0,parseDOM:[{tag:`td`,getAttrs:e=>Gp(e,t)}],toDOM(e){return[`td`,Kp(e,t),0]}},table_header:{content:e.cellContent,attrs:n,tableRole:`header_cell`,isolating:!0,parseDOM:[{tag:`th`,getAttrs:e=>Gp(e,t)}],toDOM(e){return[`th`,Kp(e,t),0]}}}}function Yp(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var Xp=new N(`selectingCells`);function Zp(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function Qp(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function $p(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=Zp(t.$head)||em(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function em(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function tm(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function nm(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function rm(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function im(e,t,n){let r=e.node(-1),i=U.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function am(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function om(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function sm(e,t,n){let r=Yp(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var W=class e extends k{constructor(e,t=e){let n=e.node(-1),r=U.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Wr(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(tm(r)&&tm(i)&&rm(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return A.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=U.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=am(e,0,l)),u>0&&(e=am(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(E.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new O(E.from(o),1,1)}replace(e,t=O.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?O.empty:t)}let i=k.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new O(E.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=U.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=U.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=U.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=U.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new cm(this.$anchorCell.pos,this.$headCell.pos)}};W.prototype.visible=!1,k.jsonID(`cell`,W);var cm=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&rm(t,n)?new W(t,n):k.near(n,1)}};function lm(e){if(!(e.selection instanceof W))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(pl.node(n,n+e.nodeSize,{class:`selectedCell`}))}),I.create(e.doc,t)}function um({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function dm({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function fm(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof j&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=W.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=W.rowSelection(e,e)}else if(!n){let e=U.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=W.create(i,t+1,n)}}else r instanceof A&&um(r)?a=A.create(i,r.from):r instanceof A&&dm(r)&&(a=A.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var pm=new N(`fix-tables`);function mm(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?mm(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function hm(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=gm(e,t,r,n))};return t?t.doc!=e.doc&&mm(t.doc,e.doc,0,r):e.doc.descendants(r),n}function gm(e,t,n,r){let i=U.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e<i.height;e++)a.push(0);for(let e=0;e<i.problems.length;e++){let o=i.problems[e];if(o.type==`collision`){let e=t.nodeAt(o.pos);if(!e)continue;let i=e.attrs;for(let e=0;e<i.rowspan;e++)a[o.row+e]+=o.n;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,am(i,i.colspan-o.n,o.n))}else if(o.type==`missing`)a[o.row]+=o.n;else if(o.type==`overlong_rowspan`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-o.n})}else if(o.type==`colwidth mismatch`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,colwidth:o.colwidth})}else if(o.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let o,s;for(let e=0;e<a.length;e++)a[e]&&(o??=e,s=e);for(let c=0,l=n+1;c<i.height;c++){let n=t.child(c),i=l+n.nodeSize,u=a[c];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<u;n++){let n=Yp(e.schema)[t].createAndFill();n&&a.push(n)}let d=(c==0||o==c-1)&&s==c?l+1:i-1;r.insert(r.mapping.map(d),a)}l=i}return r.setMeta(pm,{fixTables:!0})}function _m(e){let t=U.get(e),n=[],r=t.height,i=t.width;for(let a=0;a<r;a++){let r=[];for(let n=0;n<i;n++){let o=a*i+n,s=t.map[o];if(a>0){let e=o-i;if(s===t.map[e]){r.push(null);continue}}if(n>0){let e=o-1;if(s===t.map[e]){r.push(null);continue}}r.push(e.nodeAt(s))}n.push(r)}return n}function vm(e,t){let n=[],r=U.get(e),i=r.height,a=r.width;for(let o=0;o<i;o++){let i=e.child(o),s=[];for(let n=0;n<a;n++){let i=t[o][n];if(!i)continue;let a=r.map[o*r.width+n],c=e.nodeAt(a);if(!c)continue;let l=c.type.createChecked(i.attrs,i.content,i.marks);s.push(l)}let c=i.type.createChecked(i.attrs,s,i.marks);n.push(c)}return e.type.createChecked(e.attrs,n,e.marks)}function ym(e,t,n,r){let i=t[0]>n[0]?-1:1,a=e.splice(t[0],t.length),o=+(a.length%2==0),s;return s=r===-1&&i===1?n[0]-1:r===1&&i===-1?n[n.length-1]-o+1:i===-1?n[0]:n[n.length-1]-o,e.splice(s,0,...a),e}function bm(e){return xm(e=>e.type.spec.tableRole===`table`,e)}function xm(e,t){for(let n=t.depth;n>=0;--n){let r=t.node(n);if(e(r))return{node:r,pos:n===0?0:t.before(n),start:t.start(n),depth:n}}return null}function Sm(e,t){let n=bm(t.$from);if(!n)return;let r=U.get(n.node);if(!(e<0||e>r.width-1))return r.cellsInRect({left:e,right:e+1,top:0,bottom:r.height}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function Cm(e,t){let n=bm(t.$from);if(!n)return;let r=U.get(n.node);if(!(e<0||e>r.height-1))return r.cellsInRect({left:0,right:r.width,top:e,bottom:e+1}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function wm(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=Sm(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=Sm(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;e.node.attrs.colspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=Sm(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=Sm(r,e.selection),s=Cm(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=Sm(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function Tm(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=Cm(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=Cm(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;e.node.attrs.rowspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=Cm(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=Cm(r,e.selection),s=Sm(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=Cm(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function Em(e){return e[0].map((t,n)=>e.map(e=>e[n]))}function Dm(e){let{tr:t,originIndex:n,targetIndex:r,select:i,pos:a}=e,o=bm(t.doc.resolve(a));if(!o)return!1;let s=wm(t,n)?.indexes,c=wm(t,r)?.indexes;if(!s||!c||s.includes(r))return!1;let l=Om(o.node,s,c,0);if(t.replaceWith(o.pos,o.pos+o.node.nodeSize,l),!i)return!0;let u=U.get(l),d=o.start,f=r,p=u.positionAt(u.height-1,f,l),m=t.doc.resolve(d+p),h=u.positionAt(0,f,l),g=t.doc.resolve(d+h);return t.setSelection(W.colSelection(m,g)),!0}function Om(e,t,n,r){let i=Em(_m(e));return i=ym(i,t,n,r),i=Em(i),vm(e,i)}function km(e){let{tr:t,originIndex:n,targetIndex:r,select:i,pos:a}=e,o=bm(t.doc.resolve(a));if(!o)return!1;let s=Tm(t,n)?.indexes,c=Tm(t,r)?.indexes;if(!s||!c||s.includes(r))return!1;let l=Am(o.node,s,c,0);if(t.replaceWith(o.pos,o.pos+o.node.nodeSize,l),!i)return!0;let u=U.get(l),d=o.start,f=r,p=u.positionAt(f,u.width-1,l),m=t.doc.resolve(d+p),h=u.positionAt(f,0,l),g=t.doc.resolve(d+h);return t.setSelection(W.rowSelection(m,g)),!0}function Am(e,t,n,r){let i=_m(e);return i=ym(i,t,n,r),vm(e,i)}function jm(e){let t=e.selection,n=$p(e),r=n.node(-1),i=n.start(-1),a=U.get(r);return{...t instanceof W?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function Mm(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;sm(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,om(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?Yp(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function Nm(e,t){if(!Qp(e))return!1;if(t){let n=jm(e);t(Mm(e.tr,n,n.left))}return!0}function Pm(e,t){if(!Qp(e))return!1;if(t){let n=jm(e);t(Mm(e.tr,n,n.right))}return!0}function Fm(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,am(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function Im(e,t){if(!Qp(e))return!1;if(t){let n=jm(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;Fm(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=U.get(e)}t(r)}return!0}function Lm(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function Rm(e,t){if(!Qp(e))return!1;if(t){let n=jm(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;Lm(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=U.get(n.table)}t(r)}return!0}function zm(e,t){return function(n,r){if(!Qp(n))return!1;let i=$p(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof W?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function Bm(e){return function(t,n){if(!Qp(t))return!1;if(n){let r=Yp(t.schema),i=jm(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function Vm(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function Hm(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?Bm(e):function(t,n){if(!Qp(t))return!1;if(n){let r=Yp(t.schema),i=jm(t),a=t.tr,o=Vm(`row`,i,r),s=Vm(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}Hm(`row`,{useDeprecatedLogic:!0}),Hm(`column`,{useDeprecatedLogic:!0}),Hm(`cell`,{useDeprecatedLogic:!0});function Um(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function Wm(e){return function(t,n){if(!Qp(t))return!1;let r=Um($p(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(A.between(e,nm(e))).scrollIntoView())}return!0}}function Gm(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Km(e,t){let n=e.selection;if(!(n instanceof W))return!1;if(t){let r=e.tr,i=Yp(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new O(i,0,0))}),r.docChanged&&t(r)}return!0}function qm(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return km({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function Jm(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return Dm({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function Ym(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e<t.childCount;e++){let i=t.child(e).content,a=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(a||c)&&(i=Zm(Yp(o).row,new O(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?Zm(Yp(o).row,new O(t,n,r)).content:t);else return null;return Xm(o,s)}function Xm(e,t){let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let t=r.childCount-1;t>=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+a}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(E.empty),n[i]<r){let a=Yp(e).cell.createAndFill(),o=[];for(let e=n[i];e<r;e++)o.push(a);t[i]=t[i].append(E.from(o))}return{height:t.length,width:r,rows:t}}function Zm(e,t){let n=e.createAndFill();return new Hr(n).replace(0,n.content.size,t).doc}function Qm({width:e,height:t,rows:n},r,i){if(e!=r){let t=[],i=[];for(let e=0;e<n.length;e++){let a=n[e],o=[];for(let n=t[e]||0,i=0;n<r;i++){let s=a.child(i%a.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(am(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}i.push(E.from(o))}n=i,e=r}if(t!=i){let e=[];for(let r=0,a=0;r<i;r++,a++){let o=[],s=n[a%t];for(let e=0;e<s.childCount;e++){let t=s.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(E.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function $m(e,t,n,r,i,a,o){let s=e.doc.type.schema,c=Yp(s),l,u;if(i>t.width)for(let a=0,s=0;a<t.height;a++){let d=n.child(a);s+=d.nodeSize;let f=[],p;p=d.lastChild==null||d.lastChild.type==c.cell?l||=c.cell.createAndFill():u||=c.header_cell.createAndFill();for(let e=t.width;e<i;e++)f.push(p);e.insert(e.mapping.slice(o).map(s-1+r),f)}if(a>t.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){let i=e>=t.width?!1:n.nodeAt(t.map[r+e]).type==c.header_cell;s.push(i?u||=c.header_cell.createAndFill():l||=c.cell.createAndFill())}let d=c.row.create(null,E.from(s)),f=[];for(let e=t.height;e<a;e++)f.push(d);e.insert(e.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(l||u)}function eh(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function th(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,am(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(am(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function nh(e,t,n,r,i){let a=n?e.doc.nodeAt(n-1):e.doc;if(!a)throw Error(`No table found`);let o=U.get(a),{top:s,left:c}=r,l=c+i.width,u=s+i.height,d=e.tr,f=0;function p(){if(a=n?d.doc.nodeAt(n-1):d.doc,!a)throw Error(`No table found`);o=U.get(a),f=d.mapping.maps.length}$m(d,o,a,n,l,u,f)&&p(),eh(d,o,a,n,c,l,s,f)&&p(),eh(d,o,a,n,c,l,u,f)&&p(),th(d,o,a,n,s,u,c,f)&&p(),th(d,o,a,n,s,u,l,f)&&p();for(let e=s;e<u;e++){let t=o.positionAt(e,c,a),r=o.positionAt(e,l,a);d.replace(d.mapping.slice(f).map(t+n),d.mapping.slice(f).map(r+n),new O(i.rows[e-s],0,0))}p(),d.setSelection(new W(d.doc.resolve(n+o.positionAt(s,c,a)),d.doc.resolve(n+o.positionAt(u-1,l-1,a)))),t(d)}var rh=Da({ArrowLeft:ah(`horiz`,-1),ArrowRight:ah(`horiz`,1),ArrowUp:ah(`vert`,-1),ArrowDown:ah(`vert`,1),"Shift-ArrowLeft":oh(`horiz`,-1),"Shift-ArrowRight":oh(`horiz`,1),"Shift-ArrowUp":oh(`vert`,-1),"Shift-ArrowDown":oh(`vert`,1),Backspace:Km,"Mod-Backspace":Km,Delete:Km,"Mod-Delete":Km});function ih(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function ah(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof W)return ih(n,r,k.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=uh(i,e,t);if(o==null)return!1;if(e==`horiz`)return ih(n,r,k.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=im(i,e,t),s;return s=a?k.near(a,1):t<0?k.near(n.doc.resolve(i.before(-1)),-1):k.near(n.doc.resolve(i.after(-1)),1),ih(n,r,s)}}}function oh(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof W)o=a;else{let r=uh(i,e,t);if(r==null)return!1;o=new W(n.doc.resolve(r))}let s=im(o.$headCell,e,t);return s?ih(n,r,new W(o.$anchorCell,s)):!1}}function sh(e,t){let n=e.state.doc,r=Zp(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new W(r))),!0):!1}function ch(e,t,n){if(!Qp(e.state))return!1;let r=Ym(n),i=e.state.selection;if(i instanceof W){r||={width:1,height:1,rows:[E.from(Zm(Yp(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=U.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=Qm(r,o.right-o.left,o.bottom-o.top),nh(e.state,e.dispatch,a,o,r),!0}else if(r){let t=$p(e.state),n=t.start(-1);return nh(e.state,e.dispatch,n,U.get(t.node(-1)).findCell(t.pos-n),r),!0}else return!1}function lh(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=dh(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof W)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=Zp(e.state.selection.$anchor))!=null&&fh(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=fh(e,n),i=Xp.getState(e.state)==null;if(!r||!rm(t,r))if(i)r=t;else return;let a=new W(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(Xp,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),Xp.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Xp,-1))}function o(r){let o=r,s=Xp.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(dh(e,o.target)!=n&&(c=fh(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function uh(e,t,n){if(!(e.state.selection instanceof A))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function dh(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function fh(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Zp(e.state.doc.resolve(r))||Zp(e.state.doc.resolve(i))}var ph=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),mh(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type?(this.node=e,mh(e,this.colgroup,this.table,this.defaultCellMinWidth),!0):!1}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function mh(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var hh=new N(`tableColumnResizing`);function gh({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=ph,lastColumnResizable:i=!0}={}){let a=new M({key:hh,state:{init(e,t){var i;let o=(i=a.spec)==null||(i=i.props)==null?void 0:i.nodeViews,s=Yp(t.schema).table.name;return r&&o&&(o[s]=(e,t)=>new r(e,n,t)),new _h(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=hh.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{vh(t,n,e,i)},mouseleave:e=>{yh(e)},mousedown:(e,r)=>{bh(e,r,t,n)}},decorations:e=>{let t=hh.getState(e);if(t&&t.activeHandle>-1)return kh(e,t.activeHandle)},nodeViews:{}}});return a}var _h=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(hh);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return tm(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function vh(e,t,n,r){if(!e.editable)return;let i=hh.getState(e.state);if(i&&!i.dragging){let a=Sh(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=Ch(e,t,`left`,n):i-t.clientX<=n&&(o=Ch(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=U.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}Th(e,o)}}}function yh(e){if(!e.editable)return;let t=hh.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Th(e,-1)}function bh(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=hh.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=xh(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(hh,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=hh.getState(e.state);r?.dragging&&(Eh(e,r.activeHandle,wh(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(hh,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=hh.getState(e.state);if(i&&i.dragging){let a=wh(i.dragging,t,n);Dh(e,i.activeHandle,a,r)}}return Dh(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function xh(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function Sh(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function Ch(e,t,n,r){let i=n==`right`?-r:r,a=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!a)return-1;let{pos:o}=a,s=Zp(e.state.doc.resolve(o));if(!s)return-1;if(n==`right`)return s.pos;let c=U.get(s.node(-1)),l=s.start(-1),u=c.map.indexOf(s.pos-l);return u%c.width==0?-1:l+c.map[u-1]}function wh(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function Th(e,t){e.dispatch(e.state.tr.setMeta(hh,{setHandle:t}))}function Eh(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),a=U.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,c=e.state.tr;for(let e=0;e<a.height;e++){let t=e*a.width+s;if(e&&a.map[t]==a.map[t-a.width])continue;let r=a.map[t],l=i.nodeAt(r).attrs,u=l.colspan==1?0:s-a.colCount(r);if(l.colwidth&&l.colwidth[u]==n)continue;let d=l.colwidth?l.colwidth.slice():Oh(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function Dh(e,t,n,r){let i=e.state.doc.resolve(t),a=i.node(-1),o=i.start(-1),s=U.get(a).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,c=e.domAtPos(i.start(-1)).node;for(;c&&c.nodeName!=`TABLE`;)c=c.parentNode;c&&mh(a,c.firstChild,c,r,s,n)}function Oh(e){return Array(e).fill(0)}function kh(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return I.empty;let a=U.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<a.height;t++){let r=s+t*a.width;if((s==a.width-1||a.map[r]!=a.map[r+1])&&(t==0||a.map[r]!=a.map[r-a.width])){let t=a.map[r],s=o+t+i.nodeAt(t).nodeSize-1,c=document.createElement(`div`);c.className=`column-resize-handle`,hh.getState(e)?.dragging&&n.push(pl.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(pl.widget(s,c))}}return I.create(e.doc,n)}function Ah({allowTableNodeSelection:e=!1}={}){return new M({key:Xp,state:{init(){return null},apply(e,t){let n=e.getMeta(Xp);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:lm,handleDOMEvents:{mousedown:lh},createSelectionBetween(e){return Xp.getState(e.state)==null?null:e.state.selection},handleTripleClick:sh,handleKeyDown:rh,handlePaste:ch},appendTransaction(t,n,r){return fm(r,hm(r,n),e)}})}var jh=typeof navigator<`u`?navigator:null,Mh=jh&&jh.userAgent||``,Nh=/Edge\/(\d+)/.exec(Mh),Ph=/MSIE \d/.exec(Mh),Fh=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Mh),Ih=!(Ph||Fh||Nh)&&!!jh&&/Apple Computer/.test(jh.vendor),Lh=new N(`safari-ime-span`),Rh=!1,zh={key:Lh,props:{decorations:Bh,handleDOMEvents:{compositionstart:()=>{Rh=!0},compositionend:()=>{Rh=!1}}}};function Bh(e){let{$from:t,$to:n,to:r}=e.selection;if(Rh&&t.sameParent(n)){let t=pl.widget(r,Vh,{ignoreSelection:!0,key:`safari-ime-span`});return I.create(e.doc,[t])}}function Vh(e){let t=e.dom.ownerDocument.createElement(`span`);return t.className=`ProseMirror-safari-ime-span`,t}var Hh=new M(Ih?zh:{key:Lh});function G(e,t){return Object.assign(e,{meta:{package:`@milkdown/preset-gfm`,...t}}),e}var Uh=kd(`strike_through`);G(Uh,{displayName:`Attr<strikethrough>`,group:`Strikethrough`});var Wh=Ed(`strike_through`,e=>({parseDOM:[{tag:`del`},{style:`text-decoration`,getAttrs:e=>e===`line-through`}],toDOM:t=>[`del`,e.get(Uh.key)(t)],parseMarkdown:{match:e=>e.type===`delete`,runner:(e,t,n)=>{e.openMark(n),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`strike_through`,runner:(e,t)=>{e.withMark(t,`delete`)}}}));G(Wh.mark,{displayName:`MarkSchema<strikethrough>`,group:`Strikethrough`}),G(Wh.ctx,{displayName:`MarkSchemaCtx<strikethrough>`,group:`Strikethrough`});var Gh=z(`ToggleStrikeThrough`,e=>()=>Bi(Wh.type(e)));G(Gh,{displayName:`Command<ToggleStrikethrough>`,group:`Strikethrough`});var Kh=vd(e=>da(/(?<![\w:/])(~{1,2})(.+?)\1(?!\w|\/)/,Wh.type(e)));G(Kh,{displayName:`InputRule<strikethrough>`,group:`Strikethrough`});var qh=Dd(`strikeThroughKeymap`,{ToggleStrikethrough:{shortcuts:`Mod-Alt-x`,command:e=>{let t=e.get(R);return()=>t.call(Gh.key)}}});G(qh.ctx,{displayName:`KeymapCtx<strikethrough>`,group:`Strikethrough`}),G(qh.shortcuts,{displayName:`Keymap<strikethrough>`,group:`Strikethrough`});var Jh=Jp({tableGroup:`block`,cellContent:`paragraph`,cellAttributes:{alignment:{default:`left`,getFromDOM:e=>e.style.textAlign||`left`,setDOMAttr:(e,t)=>{t.style=`text-align: ${e||`left`}`}}}}),Yh=B(`table`,()=>({...Jh.table,content:`table_header_row table_row+`,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`table`,runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,t)=>({...e,align:r,isHeader:t===0}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table`,runner:(e,t)=>{let n=t.content.firstChild?.content;if(!n)return;let r=[];n.forEach(e=>{r.push(e.attrs.alignment)}),e.openNode(`table`,void 0,{align:r}),e.next(t.content),e.closeNode()}}}));G(Yh.node,{displayName:`NodeSchema<table>`,group:`Table`}),G(Yh.ctx,{displayName:`NodeSchemaCtx<table>`,group:`Table`});var Xh=B(`table_header_row`,()=>({...Jh.table_row,disableDropCursor:!0,content:`(table_header)*`,parseDOM:[{tag:`tr[data-is-header]`},{tag:`tr`,getAttrs:e=>e instanceof HTMLElement&&e.querySelector(`th`)?{}:!1}],toDOM(){return[`tr`,{"data-is-header":!0},0]},parseMarkdown:{match:e=>!!(e.type===`tableRow`&&e.isHeader),runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,n)=>({...e,align:r[n],isHeader:t.isHeader}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_header_row`,runner:(e,t)=>{t.content.size!==0&&(e.openNode(`tableRow`,void 0,{isHeader:!0}),e.next(t.content),e.closeNode())}}}));G(Xh.node,{displayName:`NodeSchema<tableHeaderRow>`,group:`Table`}),G(Xh.ctx,{displayName:`NodeSchemaCtx<tableHeaderRow>`,group:`Table`});var Zh=B(`table_row`,()=>({...Jh.table_row,disableDropCursor:!0,content:`(table_cell)*`,parseMarkdown:{match:e=>e.type===`tableRow`,runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,t)=>({...e,align:r[t]}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_row`,runner:(e,t)=>{t.content.size!==0&&(e.openNode(`tableRow`),e.next(t.content),e.closeNode())}}}));G(Zh.node,{displayName:`NodeSchema<tableRow>`,group:`Table`}),G(Zh.ctx,{displayName:`NodeSchemaCtx<tableRow>`,group:`Table`});var Qh=B(`table_cell`,()=>({...Jh.table_cell,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`tableCell`&&!e.isHeader,runner:(e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode()}},toMarkdown:{match:e=>e.type.name===`table_cell`,runner:(e,t)=>{e.openNode(`tableCell`).next(t.content).closeNode()}}}));G(Qh.node,{displayName:`NodeSchema<tableCell>`,group:`Table`}),G(Qh.ctx,{displayName:`NodeSchemaCtx<tableCell>`,group:`Table`});var $h=B(`table_header`,()=>({...Jh.table_header,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`tableCell`&&!!e.isHeader,runner:(e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}),e.openNode(e.schema.nodes.paragraph),e.next(t.children),e.closeNode(),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_header`,runner:(e,t)=>{e.openNode(`tableCell`),e.next(t.content),e.closeNode()}}}));G($h.node,{displayName:`NodeSchema<tableHeader>`,group:`Table`}),G($h.ctx,{displayName:`NodeSchemaCtx<tableHeader>`,group:`Table`});function eg(e,t=3,n=3){let r=Array(n).fill(0).map(()=>Qh.type(e).createAndFill()),i=Array(n).fill(0).map(()=>$h.type(e).createAndFill()),a=Array(t).fill(0).map((t,n)=>n===0?Xh.type(e).create(null,i):Zh.type(e).create(null,r));return Yh.type(e).create(null,a)}function tg(e){return(t,n)=>r=>{n??=r.selection.from;let i=r.doc.resolve(n),a=va(e=>e.type.name===`table`)(i),o=a?{node:a.node,from:a.start}:void 0,s=e===`row`;if(o){let e=U.get(o.node);if(t>=0&&t<(s?e.height:e.width)){let n=e.positionAt(s?t:e.height-1,s?e.width-1:t,o.node),i=r.doc.resolve(o.from+n),a=s?W.rowSelection:W.colSelection,c=e.positionAt(s?t:0,s?0:t,o.node),l=r.doc.resolve(o.from+c);return fa(r.setSelection(a(i,l)))}}return r}}var ng=tg(`row`),rg=tg(`col`);function ig(e,t,{map:n,tableStart:r,table:i},a){let o=Array(a).fill(0).reduce((e,t,n)=>e+i.child(n).nodeSize,r),s=Array(n.width).fill(0).map((t,r)=>{let a=i.nodeAt(n.map[r]);return Qh.type(e).createAndFill({alignment:a?.attrs.alignment})});return t.insert(o,Zh.type(e).create(null,s)),t}function ag(e){let t=bm(e.$from);if(!t)return;let n=U.get(t.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map(e=>{let n=t.node.nodeAt(e),r=e+t.start;return{pos:r,start:r+1,node:n}})}function og(e){let t=ag(e.selection);if(t&&t[0]){let n=e.doc.resolve(t[0].pos),r=t[t.length-1];if(r){let t=e.doc.resolve(r.pos);return fa(e.setSelection(new W(t,n)))}}return e}var sg=z(`GoToPrevTableCell`,()=>()=>Wm(-1));G(sg,{displayName:`Command<goToPrevTableCellCommand>`,group:`Table`});var cg=z(`GoToNextTableCell`,()=>()=>Wm(1));G(cg,{displayName:`Command<goToNextTableCellCommand>`,group:`Table`});var lg=z(`ExitTable`,e=>()=>(t,n)=>{if(!Qp(t))return!1;let{$head:r}=t.selection,i=ga(r,Yh.type(e));if(!i)return!1;let{to:a}=i,o=t.tr.replaceWith(a,a,gf.type(e).createAndFill());return o.setSelection(k.near(o.doc.resolve(a),1)).scrollIntoView(),n?.(o),!0});G(lg,{displayName:`Command<breakTableCommand>`,group:`Table`});var ug=z(`InsertTable`,e=>({row:t,col:n}={})=>(r,i)=>{let{selection:a,tr:o}=r,{from:s}=a,c=eg(e,t,n),l=o.replaceSelectionWith(c),u=k.findFrom(l.doc.resolve(s),1,!0);return u&&l.setSelection(u),i?.(l),!0});G(ug,{displayName:`Command<insertTableCommand>`,group:`Table`});var dg=z(`MoveRow`,()=>({from:e,to:t,pos:n}={})=>qm({from:e??0,to:t??0,pos:n}));G(dg,{displayName:`Command<moveRowCommand>`,group:`Table`});var fg=z(`MoveCol`,()=>({from:e,to:t,pos:n}={})=>Jm({from:e??0,to:t??0,pos:n}));G(fg,{displayName:`Command<moveColCommand>`,group:`Table`});var pg=z(`SelectRow`,()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(ng(e.index,e.pos)(r))});G(pg,{displayName:`Command<selectRowCommand>`,group:`Table`});var mg=z(`SelectCol`,()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(rg(e.index,e.pos)(r))});G(mg,{displayName:`Command<selectColCommand>`,group:`Table`});var hg=z(`SelectTable`,()=>()=>(e,t)=>{let{tr:n}=e;return!!t?.(og(n))});G(hg,{displayName:`Command<selectTableCommand>`,group:`Table`});var gg=z(`DeleteSelectedCells`,()=>()=>(e,t)=>{let{selection:n}=e;if(!(n instanceof W))return!1;let r=n.isRowSelection(),i=n.isColSelection();return r&&i?Gm(e,t):i?Im(e,t):Rm(e,t)});G(gg,{displayName:`Command<deleteSelectedCellsCommand>`,group:`Table`});var _g=z(`AddColBefore`,()=>()=>Nm);G(_g,{displayName:`Command<addColBeforeCommand>`,group:`Table`});var vg=z(`AddColAfter`,()=>()=>Pm);G(vg,{displayName:`Command<addColAfterCommand>`,group:`Table`});var yg=z(`AddRowBefore`,e=>()=>(t,n)=>{if(!Qp(t))return!1;if(n){let r=jm(t);n(ig(e,t.tr,r,r.top))}return!0});G(yg,{displayName:`Command<addRowBeforeCommand>`,group:`Table`});var bg=z(`AddRowAfter`,e=>()=>(t,n)=>{if(!Qp(t))return!1;if(n){let r=jm(t);n(ig(e,t.tr,r,r.bottom))}return!0});G(bg,{displayName:`Command<addRowAfterCommand>`,group:`Table`});var xg=z(`SetAlign`,()=>(e=`left`)=>zm(`alignment`,e));G(xg,{displayName:`Command<setAlignCommand>`,group:`Table`});var Sg=vd(e=>new qi(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(t,n,r,i)=>{let a=t.doc.resolve(r);if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),Yh.type(e)))return null;let o=eg(e,Math.max(Number(n.groups?.row??0),2),Number(n.groups?.col)),s=t.tr.replaceRangeWith(r,i,o);return s.setSelection(A.create(s.doc,r+3)).scrollIntoView()}));G(Sg,{displayName:`InputRule<insertTableInputRule>`,group:`Table`});var Cg=yd(e=>({run:(t,n,r)=>{if(r)return t;function i(t){let n=t.childCount,r=t.lastChild?.childCount??0;if(n===0||r===0)return gf.type(e).create();let i=t.firstChild;if(!(r>0&&i&&i.childCount===0))return t;if(n>=3){let r=t.child(1),a=[];for(let t=0;t<r.childCount;t++){let n=r.child(t);a.push($h.type(e).create(n.attrs,n.content,n.marks))}let o=i.type.create(i.attrs,a),s=[];for(let e=2;e<n;e++)s.push(t.child(e));return t.type.create(t.attrs,[o,...s])}let a=Array(r).fill(0).map(()=>$h.type(e).createAndFill()),o=new O(E.from(a),0,0),s=i.replace(0,0,o);return t.replace(0,i.nodeSize,new O(E.from(s),0,0))}function a(t){let n=Zh.type(e),r=[],a=[],o=!1;function s(){if(a.length===0)return;let t=Xh.type(e).createAndFill(),n=Yh.type(e).create(null,[t,...a]);r.push(i(n)),a=[]}return t.forEach(e=>{e.type===n?(o=!0,a.push(e)):(s(),r.push(e))}),s(),o?E.from(r):t}function o(t){let n=a(t),r=n!==t,s=[];return n.forEach(t=>{if(t.type===Yh.type(e)){let e=i(t);e!==t&&(r=!0),s.push(e)}else if(t.childCount>0){let e=o(t.content);e===t.content?s.push(t):(r=!0,s.push(t.copy(e)))}else s.push(t)}),r?E.from(s):t}function s(t){let n=[],r=[];t.forEach(e=>r.push(e));for(let t=0;t<r.length;t++){let i=r[t],a=r[t+1];i.type===gf.type(e)&&i.content.size===0&&a&&a.type===Yh.type(e)||n.push(i)}return n.length<r.length?E.from(n):t}let c=o(t.content);return c=s(c),new O(E.from(c),t.openStart,t.openEnd)}}));G(Cg,{displayName:`PasteRule<table>`,group:`Table`});var wg=Dd(`tableKeymap`,{NextCell:{priority:100,shortcuts:[`Mod-]`,`Tab`],command:e=>{let t=e.get(R);return()=>t.call(cg.key)}},PrevCell:{shortcuts:[`Mod-[`,`Shift-Tab`],command:e=>{let t=e.get(R);return()=>t.call(sg.key)}},ExitTable:{shortcuts:[`Mod-Enter`,`Enter`],command:e=>{let t=e.get(R);return()=>t.call(lg.key)}}});G(wg.ctx,{displayName:`KeymapCtx<table>`,group:`Table`}),G(wg.shortcuts,{displayName:`Keymap<table>`,group:`Table`});var Tg=`footnote_definition`,Eg=`footnoteDefinition`,Dg=B(`footnote_definition`,()=>({group:`block`,content:`block+`,defining:!0,attrs:{label:{default:``,validate:`string`}},parseDOM:[{tag:`dl[data-type="${Tg}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{label:e.dataset.label}},contentElement:`dd`}],toDOM:e=>{let t=e.attrs.label;return[`dl`,{"data-label":t,"data-type":Tg},[`dt`,t],[`dd`,0]]},parseMarkdown:{match:({type:e})=>e===Eg,runner:(e,t,n)=>{e.openNode(n,{label:t.label}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===Tg,runner:(e,t)=>{e.openNode(Eg,void 0,{label:t.attrs.label,identifier:t.attrs.label}).next(t.content).closeNode()}}}));G(Dg.ctx,{displayName:`NodeSchemaCtx<footnodeDef>`,group:`footnote`}),G(Dg.node,{displayName:`NodeSchema<footnodeDef>`,group:`footnote`});var Og=`footnote_reference`,kg=B(`footnote_reference`,()=>({group:`inline`,inline:!0,atom:!0,attrs:{label:{default:``,validate:`string`}},parseDOM:[{tag:`sup[data-type="${Og}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{label:e.dataset.label}}}],toDOM:e=>{let t=e.attrs.label;return[`sup`,{"data-label":t,"data-type":Og},t]},parseMarkdown:{match:({type:e})=>e===`footnoteReference`,runner:(e,t,n)=>{e.addNode(n,{label:t.label})}},toMarkdown:{match:e=>e.type.name===Og,runner:(e,t)=>{e.addNode(`footnoteReference`,void 0,void 0,{label:t.attrs.label,identifier:t.attrs.label})}}}));G(kg.ctx,{displayName:`NodeSchemaCtx<footnodeRef>`,group:`footnote`}),G(kg.node,{displayName:`NodeSchema<footnodeRef>`,group:`footnote`});var Ag=cp.extendSchema(e=>t=>{let n=e(t);return{...n,attrs:{...n.attrs,checked:{default:null,validate:`boolean|null`}},parseDOM:[{tag:`li[data-item-type="task"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread,checked:e.dataset.checked?e.dataset.checked===`true`:null}}},...n?.parseDOM||[]],toDOM:e=>n.toDOM&&e.attrs.checked==null?n.toDOM(e):[`li`,{"data-item-type":`task`,"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread,"data-checked":e.attrs.checked},0],parseMarkdown:{match:({type:e})=>e===`listItem`,runner:(e,t,r)=>{if(t.checked==null){n.parseMarkdown.runner(e,t,r);return}let i=t.label==null?`•`:`${t.label}.`,a=t.checked==null?null:!!t.checked,o=t.label==null?`bullet`:`ordered`,s=t.spread==null?`true`:`${t.spread}`;e.openNode(r,{label:i,listType:o,spread:s,checked:a}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`list_item`,runner:(e,t)=>{if(t.attrs.checked==null){n.toMarkdown.runner(e,t);return}let r=t.attrs.label,i=t.attrs.listType,a=t.attrs.spread===`true`,o=t.attrs.checked;e.openNode(`listItem`,void 0,{label:r,listType:i,spread:a,checked:o}),e.next(t.content),e.closeNode()}}}});G(Ag.node,{displayName:`NodeSchema<taskListItem>`,group:`ListItem`}),G(Ag.ctx,{displayName:`NodeSchemaCtx<taskListItem>`,group:`ListItem`});var jg=vd(()=>new qi(/^\[(?<checked>\s|x)\]\s$/,(e,t,n,r)=>{let i=e.doc.resolve(n),a=0,o=i.node(a);for(;o&&o.type.name!==`list_item`;)a--,o=i.node(a);if(!o||o.attrs.checked!=null)return null;let s=t.groups?.checked===`x`,c=i.before(a),l=e.tr;return l.deleteRange(n,r).setNodeMarkup(c,void 0,{...o.attrs,checked:s}),l}));G(jg,{displayName:`InputRule<wrapInTaskListInputRule>`,group:`ListItem`});var Mg=[qh,wg].flat(),Ng=[Sg,jg],Pg=[Kh],Fg=[Cg],Ig=Sd(()=>Hh);G(Ig,{displayName:`Prose<autoInsertSpanPlugin>`,group:`Prose`}),G(Sd(()=>gh({})),{displayName:`Prose<columnResizingPlugin>`,group:`Prose`});var Lg=Sd(()=>Ah({allowTableNodeSelection:!0}));G(Lg,{displayName:`Prose<tableEditingPlugin>`,group:`Prose`});var Rg=Ad(`remarkGFM`,()=>x);G(Rg.plugin,{displayName:`Remark<remarkGFMPlugin>`,group:`Remark`}),G(Rg.options,{displayName:`RemarkConfig<remarkGFMPlugin>`,group:`Remark`});var zg=new N(`MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN`);function Bg(e,t){let n=0;return t.forEach((t,r,i)=>{t===e&&(n=i)}),n}var Vg=Sd(()=>new M({key:zg,appendTransaction:(e,t,n)=>{let r;return t.doc!==n.doc&&n.doc.descendants((e,t)=>{if(r||=n.tr,e.type.name!==`table_cell`)return;let i=n.doc.resolve(t),a=i.node(i.depth),o=i.node(i.depth-1).firstChild;if(!o)return;let s=Bg(e,a),c=o.maybeChild(s);if(!c)return;let l=c.attrs.alignment;l!==e.attrs.alignment&&r.setNodeMarkup(t,void 0,{...e.attrs,alignment:l})}),r}}));G(Vg,{displayName:`Prose<keepTableAlignPlugin>`,group:`Prose`});var Hg=[Vg,Ig,Rg,Lg].flat(),Ug=[Ag,Yh,Xh,Zh,$h,Qh,Dg,kg,Uh,Wh].flat(),Wg=[cg,sg,lg,ug,dg,fg,pg,mg,hg,gg,yg,bg,_g,vg,xg,Gh];[Ug,Ng,Fg,Pg,Mg,Wg,Hg].flat();function Gg(e){if(!e)return!1;if(Array.isArray(e))return e.length>1?!1:Gg(e[0]);let t=e.content;return t?Gg(t):e.type===`text`}function Kg(e,t){return Object.assign(e,{meta:{package:`@milkdown/plugin-clipboard`,...t}}),e}function qg(e,t){let n=ma(t);if(n)return e.dispatch(e.state.tr.replaceSelectionWith(n,!0)),!0;try{return e.dispatch(e.state.tr.replaceSelection(t)),!0}catch{return!1}}var Jg=Sd(e=>{let t=e.get(xu);return e.update(od,e=>({...e,editable:e.editable??(()=>!0),transformPastedHTML:(t,n)=>{let r=e.transformPastedHTML;return r&&(t=r(t,n)),t.includes(`docs-internal-guid`)&&(t=t.replace(/<b[^>]*id="docs-internal-guid[^"]*"[^>]*>([\s\S]*)<\/b>/,`$1`),t=t.replace(/<div[^>]*>(<table[\s\S]*?<\/table>)<\/div>/g,`$1`)),t}})),new M({key:new N(`MILKDOWN_CLIPBOARD`),props:{handlePaste:(n,r,i)=>{let a=e.get(zu),o=n.props.editable?.(n.state),{clipboardData:s}=r;if(!o||!s||n.state.selection.$from.node().type.spec.code)return!1;let c=s.getData(`text/plain`),l=s.getData(`vscode-editor-data`);if(l){let e=JSON.parse(l)?.mode;if(c&&e){let{tr:r}=n.state,i=_a(`code_block`,t);return r.replaceSelectionWith(i.create({language:e})).setSelection(A.near(r.doc.resolve(Math.max(0,r.selection.from-2)))).insertText(c.replace(/\r\n?/g,`
|
|
33
|
+
`):e.addNode(`break`)}}}));H(Wf.node,{displayName:`NodeSchema<hardbreak>`,group:`Hardbreak`}),H(Wf.ctx,{displayName:`NodeSchemaCtx<hardbreak>`,group:`Hardbreak`});var Gf=z(`InsertHardbreak`,e=>()=>(t,n)=>{let{selection:r,tr:i}=t;if(!(r instanceof A))return!1;if(r.empty){let e=r.$from.node();if(e.childCount>0&&e.lastChild?.type.name===`hardbreak`)return n?.(i.replaceRangeWith(r.to-1,r.to,t.schema.node(`paragraph`)).setSelection(k.near(i.doc.resolve(r.to))).scrollIntoView()),!0}return n?.(i.setMeta(`hardbreak`,!0).replaceSelectionWith(Wf.type(e).create()).scrollIntoView()),!0});H(Gf,{displayName:`Command<insertHardbreakCommand>`,group:`Hardbreak`});var Kf=Dd(`hardbreakKeymap`,{InsertHardbreak:{shortcuts:`Shift-Enter`,command:e=>{let t=e.get(R);return()=>t.call(Gf.key)}}});H(Kf.ctx,{displayName:`KeymapCtx<hardbreak>`,group:`Hardbreak`}),H(Kf.shortcuts,{displayName:`Keymap<hardbreak>`,group:`Hardbreak`});var qf=Od(`hr`);H(qf,{displayName:`Attr<hr>`,group:`Hr`});var Jf=B(`hr`,e=>({group:`block`,parseDOM:[{tag:`hr`}],toDOM:t=>[`hr`,e.get(qf.key)(t)],parseMarkdown:{match:({type:e})=>e===`thematicBreak`,runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>e.type.name===`hr`,runner:e=>{e.addNode(`thematicBreak`)}}}));H(Jf.node,{displayName:`NodeSchema<hr>`,group:`Hr`}),H(Jf.ctx,{displayName:`NodeSchemaCtx<hr>`,group:`Hr`});var Yf=vd(e=>new qi(/^(?:---|___\s|\*\*\*\s)$/,(t,n,r,i)=>{let{tr:a}=t;return n[0]&&a.replaceWith(r-1,i,Jf.type(e).create()),a}));H(Yf,{displayName:`InputRule<insertHrInputRule>`,group:`Hr`});var Xf=z(`InsertHr`,e=>()=>(t,n)=>{if(!n)return!0;let r=gf.node.type(e).create(),{tr:i,selection:a}=t,{from:o}=a,s=Jf.type(e).create();if(!s)return!0;let c=i.replaceSelectionWith(s).insert(o,r),l=k.findFrom(c.doc.resolve(o),1,!0);return l&&n(c.setSelection(l).scrollIntoView()),!0});H(Xf,{displayName:`Command<insertHrCommand>`,group:`Hr`});var Zf=Od(`bulletList`);H(Zf,{displayName:`Attr<bulletList>`,group:`BulletList`});var Qf=B(`bullet_list`,e=>({content:`listItem+`,group:`block`,attrs:{spread:{default:!1,validate:`boolean`}},parseDOM:[{tag:`ul`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{spread:e.dataset.spread===`true`}}}],toDOM:t=>[`ul`,{...e.get(Zf.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e===`list`&&!t,runner:(e,t,n)=>{let r=t.spread==null?`false`:`${t.spread}`;e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`bullet_list`,runner:(e,t)=>{e.openNode(`list`,void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));H(Qf.node,{displayName:`NodeSchema<bulletList>`,group:`BulletList`}),H(Qf.ctx,{displayName:`NodeSchemaCtx<bulletList>`,group:`BulletList`});var $f=vd(e=>Xi(/^\s*([-+*])\s$/,Qf.type(e)));H($f,{displayName:`InputRule<wrapInBulletListInputRule>`,group:`BulletList`});var ep=z(`WrapInBulletList`,e=>()=>Ii(Qf.type(e)));H(ep,{displayName:`Command<wrapInBulletListCommand>`,group:`BulletList`});var tp=Dd(`bulletListKeymap`,{WrapInBulletList:{shortcuts:`Mod-Alt-8`,command:e=>{let t=e.get(R);return()=>t.call(ep.key)}}});H(tp.ctx,{displayName:`KeymapCtx<bulletListKeymap>`,group:`BulletList`}),H(tp.shortcuts,{displayName:`Keymap<bulletListKeymap>`,group:`BulletList`});var np=Od(`orderedList`);H(np,{displayName:`Attr<orderedList>`,group:`OrderedList`});var rp=B(`ordered_list`,e=>({content:`listItem+`,group:`block`,attrs:{order:{default:1,validate:`number`},spread:{default:!1,validate:`boolean`}},parseDOM:[{tag:`ol`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{spread:e.dataset.spread,order:e.hasAttribute(`start`)?Number(e.getAttribute(`start`)):1}}}],toDOM:t=>[`ol`,{...e.get(np.key)(t),...t.attrs.order===1?{}:{start:t.attrs.order},"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e===`list`&&!!t,runner:(e,t,n)=>{let r=t.spread==null?`true`:`${t.spread}`;e.openNode(n,{spread:r,order:t.start??1}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===`ordered_list`,runner:(e,t)=>{e.openNode(`list`,void 0,{ordered:!0,start:t.attrs.order??1,spread:t.attrs.spread===`true`}),e.next(t.content),e.closeNode()}}}));H(rp.node,{displayName:`NodeSchema<orderedList>`,group:`OrderedList`}),H(rp.ctx,{displayName:`NodeSchemaCtx<orderedList>`,group:`OrderedList`});var ip=vd(e=>Xi(/^\s*(\d+)\.\s$/,rp.type(e),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));H(ip,{displayName:`InputRule<wrapInOrderedListInputRule>`,group:`OrderedList`});var ap=z(`WrapInOrderedList`,e=>()=>Ii(rp.type(e)));H(ap,{displayName:`Command<wrapInOrderedListCommand>`,group:`OrderedList`});var op=Dd(`orderedListKeymap`,{WrapInOrderedList:{shortcuts:`Mod-Alt-7`,command:e=>{let t=e.get(R);return()=>t.call(ap.key)}}});H(op.ctx,{displayName:`KeymapCtx<orderedList>`,group:`OrderedList`}),H(op.shortcuts,{displayName:`Keymap<orderedList>`,group:`OrderedList`});var sp=Od(`listItem`);H(sp,{displayName:`Attr<listItem>`,group:`ListItem`});var cp=B(`list_item`,e=>({group:`listItem`,content:`paragraph block*`,attrs:{label:{default:`•`,validate:`string`},listType:{default:`bullet`,validate:`string`},spread:{default:!0,validate:`boolean`}},defining:!0,parseDOM:[{tag:`li`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread===`true`}}}],toDOM:t=>[`li`,{...e.get(sp.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e})=>e===`listItem`,runner:(e,t,n)=>{let r=t.label==null?`•`:`${t.label}.`,i=t.label==null?`bullet`:`ordered`,a=t.spread==null?`true`:`${t.spread}`;e.openNode(n,{label:r,listType:i,spread:a}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`list_item`,runner:(e,t)=>{e.openNode(`listItem`,void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));H(cp.node,{displayName:`NodeSchema<listItem>`,group:`ListItem`}),H(cp.ctx,{displayName:`NodeSchemaCtx<listItem>`,group:`ListItem`});var lp=z(`SinkListItem`,e=>()=>Bd(cp.type(e)));H(lp,{displayName:`Command<sinkListItemCommand>`,group:`ListItem`});var up=z(`LiftListItem`,e=>()=>Ld(cp.type(e)));H(up,{displayName:`Command<liftListItemCommand>`,group:`ListItem`});var dp=z(`SplitListItem`,e=>()=>Id(cp.type(e)));H(dp,{displayName:`Command<splitListItemCommand>`,group:`ListItem`});function fp(e){return(t,n,r)=>{let{selection:i}=t;if(!(i instanceof A))return!1;let{empty:a,$from:o}=i;return!a||o.parentOffset!==0||o.node(-1).type!==cp.type(e)?!1:pi(t,n,r)}}var pp=z(`LiftFirstListItem`,e=>()=>fp(e));H(pp,{displayName:`Command<liftFirstListItemCommand>`,group:`ListItem`});var mp=Dd(`listItemKeymap`,{NextListItem:{shortcuts:`Enter`,command:e=>{let t=e.get(R);return()=>t.call(dp.key)}},SinkListItem:{shortcuts:[`Tab`,`Mod-]`],command:e=>{let t=e.get(R);return()=>t.call(lp.key)}},LiftListItem:{shortcuts:[`Shift-Tab`,`Mod-[`],command:e=>{let t=e.get(R);return()=>t.call(up.key)}},LiftFirstListItem:{shortcuts:[`Backspace`,`Delete`],command:e=>{let t=e.get(R);return()=>t.call(pp.key)}}});H(mp.ctx,{displayName:`KeymapCtx<listItem>`,group:`ListItem`}),H(mp.shortcuts,{displayName:`Keymap<listItem>`,group:`ListItem`});var hp=xd(`text`,()=>({group:`inline`,parseMarkdown:{match:({type:e})=>e===`text`,runner:(e,t)=>{e.addText(t.value)}},toMarkdown:{match:e=>e.type.name===`text`,runner:(e,t)=>{e.addNode(`text`,void 0,t.text)}}}));H(hp,{displayName:`NodeSchema<text>`,group:`Text`});var gp=Od(`html`);H(gp,{displayName:`Attr<html>`,group:`Html`});var _p=B(`html`,e=>({atom:!0,group:`inline`,inline:!0,attrs:{value:{default:``,validate:`string`}},toDOM:t=>{let n=document.createElement(`span`),r={...e.get(gp.key)(t),"data-value":t.attrs.value,"data-type":`html`};return n.textContent=t.attrs.value,[`span`,r,t.attrs.value]},parseDOM:[{tag:`span[data-type="html"]`,getAttrs:e=>({value:e.dataset.value??``})}],parseMarkdown:{match:({type:e})=>e===`html`,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name===`html`,runner:(e,t)=>{e.addNode(`html`,void 0,t.attrs.value)}}}));H(_p.node,{displayName:`NodeSchema<html>`,group:`Html`}),H(_p.ctx,{displayName:`NodeSchemaCtx<html>`,group:`Html`});var vp=[ff,hf,gf,Sf,Cf,wf,Uf,Wf,kf,Af,Pf,Ff,qf,Jf,zf,Bf,Zf,Qf,np,rp,sp,cp,Gd,Kd,Zd,Qd,nf,rf,cf,lf,gp,_p,hp].flat(),yp=[jf,$f,ip,If,Yf,Tf].flat(),bp=[Jd,Yd,of,ef],xp=[vf,Mf,Ef,Df,Lf,Gf,Xf,Vf,Hf,ap,ep,lp,dp,up,pp,qd,af,$d,uf,df,z(`IsMarkSelected`,()=>e=>t=>{if(!e)return!1;let{doc:n,selection:r}=t;return n.rangeHasMark(r.from,r.to,e)}),z(`IsNoteSelected`,()=>e=>t=>e?ba(t,e).hasNode:!1),z(`ClearTextInCurrentBlock`,()=>()=>(e,t)=>{let n=e.tr,{$from:r,$to:i}=n.selection,{pos:a}=r,{pos:o}=i,s=a-r.node().content.size;return s<0?!1:(n=n.deleteRange(s,o),t?.(n),!0)}),z(`SetBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr,{from:o,to:s}=a.selection;try{a.setBlockType(o,s,r,i)}catch{return!1}return n?.(a),!0}),z(`WrapInBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr;try{let{$from:e,$to:t}=a.selection,n=e.blockRange(t),o=n&&or(n,r,i);if(!o)return!1;a=a.wrap(n,o)}catch{return!1}return n?.(a),!0}),z(`AddBlockType`,()=>e=>(t,n)=>{let{nodeType:r,attrs:i=null}=e??{};if(!r)return!1;let a=t.tr;try{let e=r instanceof Pt?r:r.createAndFill(i);if(!e)return!1;a.replaceSelectionWith(e)}catch{return!1}return n?.(a),!0}),z(`SelectTextNearPos`,()=>e=>(t,n)=>{let{pos:r}=e??{};if(r==null)return!1;let i=(e,t,n)=>Math.min(Math.max(e,t),n),a=t.tr;try{let e=t.doc.resolve(i(r,0,t.doc.content.size));a.setSelection(A.near(e))}catch{return!1}return n?.(a.scrollIntoView()),!0})],Sp=[Nf,Rf,Kf,Of,mp,op,tp,yf,Xd,sf,tf].flat(),Cp=Ad(`remarkAddOrderInList`,()=>()=>e=>{ne(e,`list`,e=>{if(e.ordered){let t=e.start??1;e.children.forEach((e,n)=>{e.label=n+t})}})});H(Cp.plugin,{displayName:`Remark<remarkAddOrderInListPlugin>`,group:`Remark`}),H(Cp.options,{displayName:`RemarkConfig<remarkAddOrderInListPlugin>`,group:`Remark`});var wp=Ad(`remarkLineBreak`,()=>()=>e=>{let t=/[\t ]*(?:\r?\n|\r)/g;ne(e,`text`,(e,n,r)=>{if(!e.value||typeof e.value!=`string`)return;let i=[],a=0;t.lastIndex=0;let o=t.exec(e.value);for(;o;){let n=o.index;a!==n&&i.push({type:`text`,value:e.value.slice(a,n)}),i.push({type:`break`,data:{isInline:!0}}),a=n+o[0].length,o=t.exec(e.value)}if(i.length>0&&r&&typeof n==`number`)return a<e.value.length&&i.push({type:`text`,value:e.value.slice(a)}),r.children.splice(n,1,...i),n+i.length})});H(wp.plugin,{displayName:`Remark<remarkLineBreak>`,group:`Remark`}),H(wp.options,{displayName:`RemarkConfig<remarkLineBreak>`,group:`Remark`});var Tp=Ad(`remarkInlineLink`,()=>Ud);H(Tp.plugin,{displayName:`Remark<remarkInlineLinkPlugin>`,group:`Remark`}),H(Tp.options,{displayName:`RemarkConfig<remarkInlineLinkPlugin>`,group:`Remark`});var Ep=e=>!!e.children,Dp=e=>e.type===`html`;function Op(e,t){return n(e,0,null)[0];function n(e,r,i){if(Ep(e)){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i){let a=n(i,r,e);if(a)for(let e=0,n=a.length;e<n;e++){let n=a[e];n&&t.push(n)}}}e.children=t}return t(e,r,i)}}var kp=[`root`,`blockquote`,`listItem`],Ap=Ad(`remarkHTMLTransformer`,()=>()=>e=>{Op(e,(e,t,n)=>(Dp(e)&&n&&kp.includes(n.type)&&(e.children=[{...e}],delete e.value,e.type=`paragraph`),[e]))});H(Ap.plugin,{displayName:`Remark<remarkHtmlTransformer>`,group:`Remark`}),H(Ap.options,{displayName:`RemarkConfig<remarkHtmlTransformer>`,group:`Remark`});var jp=Ad(`remarkMarker`,()=>()=>(e,t)=>{let n=e=>t.value.charAt(e.position.start.offset);ne(e,e=>[`strong`,`emphasis`].includes(e.type),e=>{e.marker=n(e)})});H(jp.plugin,{displayName:`Remark<remarkMarker>`,group:`Remark`}),H(jp.options,{displayName:`RemarkConfig<remarkMarker>`,group:`Remark`});var Mp=Sd(()=>{let e=!1,t=new M({key:new N(`MILKDOWN_INLINE_NODES_CURSOR`),state:{init(){return!1},apply(e){if(!e.selection.empty)return!1;let t=e.selection.$from,n=t.nodeBefore,r=t.nodeAfter;return!!(n&&r&&n.isInline&&!n.isText&&r.isInline&&!r.isText)}},props:{handleDOMEvents:{compositionend:(n,r)=>e?(e=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){let e=n.state.selection.from;r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||``,e))}}),!0):!1,compositionstart:n=>(t.getState(n.state)&&(e=!0),!1),beforeinput:(n,r)=>{if(t.getState(n.state)&&r instanceof InputEvent&&r.data&&!e){let e=n.state.selection.from;return r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||``,e)),!0}return!1}},decorations(e){if(t.getState(e)){let t=e.selection.$from.pos,n=document.createElement(`span`),r=pl.widget(t,n,{side:-1}),i=document.createElement(`span`),a=pl.widget(t,i);return setTimeout(()=>{n.contentEditable=`true`,i.contentEditable=`true`}),I.create(e.doc,[r,a])}return I.empty}}});return t});H(Mp,{displayName:`Prose<inlineNodesCursorPlugin>`,group:`Prose`});var Np=Sd(e=>new M({key:new N(`MILKDOWN_HARDBREAK_MARKS`),appendTransaction:(t,n,r)=>{if(!t.length)return;let[i]=t;if(!i)return;let[a]=i.steps;if(i.getMeta(`hardbreak`)){if(!(a instanceof Zn))return;let{from:t}=a;return r.tr.setNodeMarkup(t,Wf.type(e),void 0,[])}if(a instanceof qn){let t=r.tr,{from:n,to:i}=a;return r.doc.nodesBetween(n,i,(n,r)=>{n.type===Wf.type(e)&&(t=t.setNodeMarkup(r,Wf.type(e),void 0,[]))}),t}}}));H(Np,{displayName:`Prose<hardbreakClearMarkPlugin>`,group:`Prose`});var Pp=Td([`table`,`code_block`],`hardbreakFilterNodes`);H(Pp,{displayName:`Ctx<hardbreakFilterNodes>`,group:`Prose`});var Fp=Sd(e=>{let t=e.get(Pp.key);return new M({key:new N(`MILKDOWN_HARDBREAK_FILTER`),filterTransaction:(e,n)=>{let r=e.getMeta(`hardbreak`),[i]=e.steps;if(r&&i){let{from:e}=i,r=n.doc.resolve(e),a=r.depth,o=!0;for(;a>0;)t.includes(r.node(a).type.name)&&(o=!1),a--;return o}return!0}})});H(Fp,{displayName:`Prose<hardbreakFilterPlugin>`,group:`Prose`});var Ip=Sd(e=>{let t=new N(`MILKDOWN_HEADING_ID`),n=n=>{if(n.composing)return;let r=e.get(Sf.key),i=n.state.tr.setMeta(`addToHistory`,!1),a=!1,o={};n.state.doc.descendants((n,s)=>{if(n.type===wf.type(e)){if(n.textContent.trim().length===0)return;let e=n.attrs,c=r(n);o[c]?(o[c]+=1,c+=`-#${o[c]}`):o[c]=1,e.id!==c&&(a=!0,i.setMeta(t,!0).setNodeMarkup(s,void 0,{...e,id:c}))}}),a&&n.dispatch(i)};return new M({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})});H(Ip,{displayName:`Prose<syncHeadingIdPlugin>`,group:`Prose`});var Lp=Sd(e=>new M({key:new N(`MILKDOWN_KEEP_LIST_ORDER`),appendTransaction:(t,n,r)=>{if(!r.selection||t.some(e=>e.getMeta(`addToHistory`)===!1||!e.isGeneric))return null;let i=rp.type(e),a=Qf.type(e),o=cp.type(e),s=(e,t,n=1)=>{let r=!1,i=`${t+n}.`;return e.label!==i&&(e.label=i,r=!0),r},c=r.tr,l=!1;return r.doc.descendants((e,t,n,r)=>{if(e.type===a){let n=e.maybeChild(0);n?.type===o&&n.attrs.listType===`ordered`&&(l=!0,c.setNodeMarkup(t,i,{spread:`true`}),e.descendants((e,t,n,r)=>{if(e.type===o){let n={...e.attrs};s(n,r)&&(c=c.setNodeMarkup(t,void 0,n))}return!1}))}else if(e.type===o&&n?.type===i){let i={...e.attrs},a=!1;i.listType!==`ordered`&&(i.listType=`ordered`,a=!0),n?.maybeChild(0)&&(a=s(i,r,n?.attrs.order??1)),a&&(c=c.setNodeMarkup(t,void 0,i),l=!0)}}),l?c.setMeta(`addToHistory`,!1):null}}));H(Lp,{displayName:`Prose<syncListOrderPlugin>`,group:`Prose`});var Rp=[vp,yp,bp,xp,Sp,[Np,Pp,Fp,Mp,Cp,Tp,wp,Ap,jp,mf,Ip,Lp].flat()].flat(),zp,Bp;if(typeof WeakMap<`u`){let e=new WeakMap;zp=t=>e.get(t),Bp=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;zp=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},Bp=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var U=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,!(i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o)&&t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return zp(e)||Bp(e,Vp(e))}};function Vp(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=Hp(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new U(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&Up(s,o,e),s}function Hp(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function Up(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r!=null&&(!c.colwidth||c.colwidth[n]!=r)&&((s||=Wp(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function Wp(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function Gp(e,t){if(typeof e==`string`)return{};let n=e.getAttribute(`data-colwidth`),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(`,`).map(e=>Number(e)):null,i=Number(e.getAttribute(`colspan`)||1),a={colspan:i,rowspan:Number(e.getAttribute(`rowspan`)||1),colwidth:r&&r.length==i?r:null};for(let n in t){let r=t[n].getFromDOM,i=r&&r(e);i!=null&&(a[n]=i)}return a}function Kp(e,t){let n={};e.attrs.colspan!=1&&(n.colspan=e.attrs.colspan),e.attrs.rowspan!=1&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n[`data-colwidth`]=e.attrs.colwidth.join(`,`));for(let r in t){let i=t[r].setDOMAttr;i&&i(e.attrs[r],n)}return n}function qp(e){if(e!==null){if(!Array.isArray(e))throw TypeError(`colwidth must be null or an array`);for(let t of e)if(typeof t!=`number`)throw TypeError(`colwidth must be null or an array of numbers`)}}function Jp(e){let t=e.cellAttributes||{},n={colspan:{default:1,validate:`number`},rowspan:{default:1,validate:`number`},colwidth:{default:null,validate:qp}};for(let e in t)n[e]={default:t[e].default,validate:t[e].validate};return{table:{content:`table_row+`,tableRole:`table`,isolating:!0,group:e.tableGroup,parseDOM:[{tag:`table`}],toDOM(){return[`table`,[`tbody`,0]]}},table_row:{content:`(table_cell | table_header)*`,tableRole:`row`,parseDOM:[{tag:`tr`}],toDOM(){return[`tr`,0]}},table_cell:{content:e.cellContent,attrs:n,tableRole:`cell`,isolating:!0,parseDOM:[{tag:`td`,getAttrs:e=>Gp(e,t)}],toDOM(e){return[`td`,Kp(e,t),0]}},table_header:{content:e.cellContent,attrs:n,tableRole:`header_cell`,isolating:!0,parseDOM:[{tag:`th`,getAttrs:e=>Gp(e,t)}],toDOM(e){return[`th`,Kp(e,t),0]}}}}function Yp(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var Xp=new N(`selectingCells`);function Zp(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function Qp(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function $p(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=Zp(t.$head)||em(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function em(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function tm(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function nm(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function rm(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function im(e,t,n){let r=e.node(-1),i=U.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function am(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function om(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function sm(e,t,n){let r=Yp(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var W=class e extends k{constructor(e,t=e){let n=e.node(-1),r=U.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new Wr(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(tm(r)&&tm(i)&&rm(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return A.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=U.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=am(e,0,l)),u>0&&(e=am(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(E.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new O(E.from(o),1,1)}replace(e,t=O.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?O.empty:t)}let i=k.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new O(E.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=U.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=U.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=U.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=U.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new cm(this.$anchorCell.pos,this.$headCell.pos)}};W.prototype.visible=!1,k.jsonID(`cell`,W);var cm=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&rm(t,n)?new W(t,n):k.near(n,1)}};function lm(e){if(!(e.selection instanceof W))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(pl.node(n,n+e.nodeSize,{class:`selectedCell`}))}),I.create(e.doc,t)}function um({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function dm({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function fm(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof j&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=W.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=W.rowSelection(e,e)}else if(!n){let e=U.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=W.create(i,t+1,n)}}else r instanceof A&&um(r)?a=A.create(i,r.from):r instanceof A&&dm(r)&&(a=A.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var pm=new N(`fix-tables`);function mm(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue outer}r(a,n),s<i&&e.child(s).sameMarkup(a)?mm(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function hm(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=gm(e,t,r,n))};return t?t.doc!=e.doc&&mm(t.doc,e.doc,0,r):e.doc.descendants(r),n}function gm(e,t,n,r){let i=U.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e<i.height;e++)a.push(0);for(let e=0;e<i.problems.length;e++){let o=i.problems[e];if(o.type==`collision`){let e=t.nodeAt(o.pos);if(!e)continue;let i=e.attrs;for(let e=0;e<i.rowspan;e++)a[o.row+e]+=o.n;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,am(i,i.colspan-o.n,o.n))}else if(o.type==`missing`)a[o.row]+=o.n;else if(o.type==`overlong_rowspan`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-o.n})}else if(o.type==`colwidth mismatch`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,colwidth:o.colwidth})}else if(o.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let o,s;for(let e=0;e<a.length;e++)a[e]&&(o??=e,s=e);for(let c=0,l=n+1;c<i.height;c++){let n=t.child(c),i=l+n.nodeSize,u=a[c];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<u;n++){let n=Yp(e.schema)[t].createAndFill();n&&a.push(n)}let d=(c==0||o==c-1)&&s==c?l+1:i-1;r.insert(r.mapping.map(d),a)}l=i}return r.setMeta(pm,{fixTables:!0})}function _m(e){let t=U.get(e),n=[],r=t.height,i=t.width;for(let a=0;a<r;a++){let r=[];for(let n=0;n<i;n++){let o=a*i+n,s=t.map[o];if(a>0){let e=o-i;if(s===t.map[e]){r.push(null);continue}}if(n>0){let e=o-1;if(s===t.map[e]){r.push(null);continue}}r.push(e.nodeAt(s))}n.push(r)}return n}function vm(e,t){let n=[],r=U.get(e),i=r.height,a=r.width;for(let o=0;o<i;o++){let i=e.child(o),s=[];for(let n=0;n<a;n++){let i=t[o][n];if(!i)continue;let a=r.map[o*r.width+n],c=e.nodeAt(a);if(!c)continue;let l=c.type.createChecked(i.attrs,i.content,i.marks);s.push(l)}let c=i.type.createChecked(i.attrs,s,i.marks);n.push(c)}return e.type.createChecked(e.attrs,n,e.marks)}function ym(e,t,n,r){let i=t[0]>n[0]?-1:1,a=e.splice(t[0],t.length),o=+(a.length%2==0),s;return s=r===-1&&i===1?n[0]-1:r===1&&i===-1?n[n.length-1]-o+1:i===-1?n[0]:n[n.length-1]-o,e.splice(s,0,...a),e}function bm(e){return xm(e=>e.type.spec.tableRole===`table`,e)}function xm(e,t){for(let n=t.depth;n>=0;--n){let r=t.node(n);if(e(r))return{node:r,pos:n===0?0:t.before(n),start:t.start(n),depth:n}}return null}function Sm(e,t){let n=bm(t.$from);if(!n)return;let r=U.get(n.node);if(!(e<0||e>r.width-1))return r.cellsInRect({left:e,right:e+1,top:0,bottom:r.height}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function Cm(e,t){let n=bm(t.$from);if(!n)return;let r=U.get(n.node);if(!(e<0||e>r.height-1))return r.cellsInRect({left:0,right:r.width,top:e,bottom:e+1}).map(e=>{let t=n.node.nodeAt(e),r=e+n.start;return{pos:r,start:r+1,node:t,depth:n.depth+2}})}function wm(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=Sm(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=Sm(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.colspan+n-1;e.node.attrs.colspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=Sm(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=Sm(r,e.selection),s=Cm(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=Sm(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function Tm(e,t,n=t){let r=t,i=n;for(let n=t;n>=0;n--){let t=Cm(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;t>=r&&(r=n),t>i&&(i=t)})}for(let n=t;n<=i;n++){let t=Cm(n,e.selection);t&&t.forEach(e=>{let t=e.node.attrs.rowspan+n-1;e.node.attrs.rowspan>1&&t>i&&(i=t)})}let a=[];for(let t=r;t<=i;t++){let n=Cm(t,e.selection);n&&n.length>0&&a.push(t)}r=a[0],i=a[a.length-1];let o=Cm(r,e.selection),s=Sm(0,e.selection);if(!o||!s)return;let c=e.doc.resolve(o[o.length-1].pos),l;for(let t=i;t>=r;t--){let n=Cm(t,e.selection);if(n&&n.length>0){for(let e=s.length-1;e>=0;e--)if(s[e].pos===n[0].pos){l=n[0];break}if(l)break}}if(l)return{$anchor:c,$head:e.doc.resolve(l.pos),indexes:a}}function Em(e){return e[0].map((t,n)=>e.map(e=>e[n]))}function Dm(e){let{tr:t,originIndex:n,targetIndex:r,select:i,pos:a}=e,o=bm(t.doc.resolve(a));if(!o)return!1;let s=wm(t,n)?.indexes,c=wm(t,r)?.indexes;if(!s||!c||s.includes(r))return!1;let l=Om(o.node,s,c,0);if(t.replaceWith(o.pos,o.pos+o.node.nodeSize,l),!i)return!0;let u=U.get(l),d=o.start,f=r,p=u.positionAt(u.height-1,f,l),m=t.doc.resolve(d+p),h=u.positionAt(0,f,l),g=t.doc.resolve(d+h);return t.setSelection(W.colSelection(m,g)),!0}function Om(e,t,n,r){let i=Em(_m(e));return i=ym(i,t,n,r),i=Em(i),vm(e,i)}function km(e){let{tr:t,originIndex:n,targetIndex:r,select:i,pos:a}=e,o=bm(t.doc.resolve(a));if(!o)return!1;let s=Tm(t,n)?.indexes,c=Tm(t,r)?.indexes;if(!s||!c||s.includes(r))return!1;let l=Am(o.node,s,c,0);if(t.replaceWith(o.pos,o.pos+o.node.nodeSize,l),!i)return!0;let u=U.get(l),d=o.start,f=r,p=u.positionAt(f,u.width-1,l),m=t.doc.resolve(d+p),h=u.positionAt(f,0,l),g=t.doc.resolve(d+h);return t.setSelection(W.rowSelection(m,g)),!0}function Am(e,t,n,r){let i=_m(e);return i=ym(i,t,n,r),vm(e,i)}function jm(e){let t=e.selection,n=$p(e),r=n.node(-1),i=n.start(-1),a=U.get(r);return{...t instanceof W?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function Mm(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;sm(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,om(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?Yp(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function Nm(e,t){if(!Qp(e))return!1;if(t){let n=jm(e);t(Mm(e.tr,n,n.left))}return!0}function Pm(e,t){if(!Qp(e))return!1;if(t){let n=jm(e);t(Mm(e.tr,n,n.right))}return!0}function Fm(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,am(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function Im(e,t){if(!Qp(e))return!1;if(t){let n=jm(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;Fm(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=U.get(e)}t(r)}return!0}function Lm(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function Rm(e,t){if(!Qp(e))return!1;if(t){let n=jm(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;Lm(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=U.get(n.table)}t(r)}return!0}function zm(e,t){return function(n,r){if(!Qp(n))return!1;let i=$p(n);if(i.nodeAfter.attrs[e]===t)return!1;if(r){let a=n.tr;n.selection instanceof W?n.selection.forEachCell((n,r)=>{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function Bm(e){return function(t,n){if(!Qp(t))return!1;if(n){let r=Yp(t.schema),i=jm(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function Vm(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function Hm(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?Bm(e):function(t,n){if(!Qp(t))return!1;if(n){let r=Yp(t.schema),i=jm(t),a=t.tr,o=Vm(`row`,i,r),s=Vm(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}Hm(`row`,{useDeprecatedLogic:!0}),Hm(`column`,{useDeprecatedLogic:!0}),Hm(`cell`,{useDeprecatedLogic:!0});function Um(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function Wm(e){return function(t,n){if(!Qp(t))return!1;let r=Um($p(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(A.between(e,nm(e))).scrollIntoView())}return!0}}function Gm(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Km(e,t){let n=e.selection;if(!(n instanceof W))return!1;if(t){let r=e.tr,i=Yp(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new O(i,0,0))}),r.docChanged&&t(r)}return!0}function qm(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return km({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function Jm(e){return(t,n)=>{let{from:r,to:i,select:a=!0,pos:o=t.selection.from}=e,s=t.tr;return Dm({tr:s,originIndex:r,targetIndex:i,select:a,pos:o})?(n?.(s),!0):!1}}function Ym(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e<t.childCount;e++){let i=t.child(e).content,a=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(a||c)&&(i=Zm(Yp(o).row,new O(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?Zm(Yp(o).row,new O(t,n,r)).content:t);else return null;return Xm(o,s)}function Xm(e,t){let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let t=r.childCount-1;t>=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+a}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(E.empty),n[i]<r){let a=Yp(e).cell.createAndFill(),o=[];for(let e=n[i];e<r;e++)o.push(a);t[i]=t[i].append(E.from(o))}return{height:t.length,width:r,rows:t}}function Zm(e,t){let n=e.createAndFill();return new Hr(n).replace(0,n.content.size,t).doc}function Qm({width:e,height:t,rows:n},r,i){if(e!=r){let t=[],i=[];for(let e=0;e<n.length;e++){let a=n[e],o=[];for(let n=t[e]||0,i=0;n<r;i++){let s=a.child(i%a.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(am(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}i.push(E.from(o))}n=i,e=r}if(t!=i){let e=[];for(let r=0,a=0;r<i;r++,a++){let o=[],s=n[a%t];for(let e=0;e<s.childCount;e++){let t=s.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(E.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function $m(e,t,n,r,i,a,o){let s=e.doc.type.schema,c=Yp(s),l,u;if(i>t.width)for(let a=0,s=0;a<t.height;a++){let d=n.child(a);s+=d.nodeSize;let f=[],p;p=d.lastChild==null||d.lastChild.type==c.cell?l||=c.cell.createAndFill():u||=c.header_cell.createAndFill();for(let e=t.width;e<i;e++)f.push(p);e.insert(e.mapping.slice(o).map(s-1+r),f)}if(a>t.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){let i=e>=t.width?!1:n.nodeAt(t.map[r+e]).type==c.header_cell;s.push(i?u||=c.header_cell.createAndFill():l||=c.cell.createAndFill())}let d=c.row.create(null,E.from(s)),f=[];for(let e=t.height;e<a;e++)f.push(d);e.insert(e.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(l||u)}function eh(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function th(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,am(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(am(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function nh(e,t,n,r,i){let a=n?e.doc.nodeAt(n-1):e.doc;if(!a)throw Error(`No table found`);let o=U.get(a),{top:s,left:c}=r,l=c+i.width,u=s+i.height,d=e.tr,f=0;function p(){if(a=n?d.doc.nodeAt(n-1):d.doc,!a)throw Error(`No table found`);o=U.get(a),f=d.mapping.maps.length}$m(d,o,a,n,l,u,f)&&p(),eh(d,o,a,n,c,l,s,f)&&p(),eh(d,o,a,n,c,l,u,f)&&p(),th(d,o,a,n,s,u,c,f)&&p(),th(d,o,a,n,s,u,l,f)&&p();for(let e=s;e<u;e++){let t=o.positionAt(e,c,a),r=o.positionAt(e,l,a);d.replace(d.mapping.slice(f).map(t+n),d.mapping.slice(f).map(r+n),new O(i.rows[e-s],0,0))}p(),d.setSelection(new W(d.doc.resolve(n+o.positionAt(s,c,a)),d.doc.resolve(n+o.positionAt(u-1,l-1,a)))),t(d)}var rh=Da({ArrowLeft:ah(`horiz`,-1),ArrowRight:ah(`horiz`,1),ArrowUp:ah(`vert`,-1),ArrowDown:ah(`vert`,1),"Shift-ArrowLeft":oh(`horiz`,-1),"Shift-ArrowRight":oh(`horiz`,1),"Shift-ArrowUp":oh(`vert`,-1),"Shift-ArrowDown":oh(`vert`,1),Backspace:Km,"Mod-Backspace":Km,Delete:Km,"Mod-Delete":Km});function ih(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function ah(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof W)return ih(n,r,k.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=uh(i,e,t);if(o==null)return!1;if(e==`horiz`)return ih(n,r,k.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=im(i,e,t),s;return s=a?k.near(a,1):t<0?k.near(n.doc.resolve(i.before(-1)),-1):k.near(n.doc.resolve(i.after(-1)),1),ih(n,r,s)}}}function oh(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof W)o=a;else{let r=uh(i,e,t);if(r==null)return!1;o=new W(n.doc.resolve(r))}let s=im(o.$headCell,e,t);return s?ih(n,r,new W(o.$anchorCell,s)):!1}}function sh(e,t){let n=e.state.doc,r=Zp(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new W(r))),!0):!1}function ch(e,t,n){if(!Qp(e.state))return!1;let r=Ym(n),i=e.state.selection;if(i instanceof W){r||={width:1,height:1,rows:[E.from(Zm(Yp(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=U.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=Qm(r,o.right-o.left,o.bottom-o.top),nh(e.state,e.dispatch,a,o,r),!0}else if(r){let t=$p(e.state),n=t.start(-1);return nh(e.state,e.dispatch,n,U.get(t.node(-1)).findCell(t.pos-n),r),!0}else return!1}function lh(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=dh(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof W)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=Zp(e.state.selection.$anchor))!=null&&fh(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=fh(e,n),i=Xp.getState(e.state)==null;if(!r||!rm(t,r))if(i)r=t;else return;let a=new W(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(Xp,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),Xp.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Xp,-1))}function o(r){let o=r,s=Xp.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(dh(e,o.target)!=n&&(c=fh(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function uh(e,t,n){if(!(e.state.selection instanceof A))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function dh(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function fh(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Zp(e.state.doc.resolve(r))||Zp(e.state.doc.resolve(i))}var ph=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),mh(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type?(this.node=e,mh(e,this.colgroup,this.table,this.defaultCellMinWidth),!0):!1}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function mh(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;e<l.childCount;e++){let{colspan:u,colwidth:d}=l.child(e).attrs;for(let e=0;e<u;e++,n++){let l=i==n?a:d&&d[e],u=l?l+`px`:``;if(o+=l||r,l||(s=!1),c)c.style.width!=u&&(c.style.width=u),c=c.nextSibling;else{let e=document.createElement(`col`);e.style.width=u,t.appendChild(e)}}}for(;c;){var u;let e=c.nextSibling;(u=c.parentNode)==null||u.removeChild(c),c=e}s?(n.style.width=o+`px`,n.style.minWidth=``):(n.style.width=``,n.style.minWidth=o+`px`)}}var hh=new N(`tableColumnResizing`);function gh({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:r=ph,lastColumnResizable:i=!0}={}){let a=new M({key:hh,state:{init(e,t){var i;let o=(i=a.spec)==null||(i=i.props)==null?void 0:i.nodeViews,s=Yp(t.schema).table.name;return r&&o&&(o[s]=(e,t)=>new r(e,n,t)),new _h(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=hh.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{vh(t,n,e,i)},mouseleave:e=>{yh(e)},mousedown:(e,r)=>{bh(e,r,t,n)}},decorations:e=>{let t=hh.getState(e);if(t&&t.activeHandle>-1)return kh(e,t.activeHandle)},nodeViews:{}}});return a}var _h=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(hh);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return tm(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function vh(e,t,n,r){if(!e.editable)return;let i=hh.getState(e.state);if(i&&!i.dragging){let a=Sh(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=Ch(e,t,`left`,n):i-t.clientX<=n&&(o=Ch(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=U.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}Th(e,o)}}}function yh(e){if(!e.editable)return;let t=hh.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Th(e,-1)}function bh(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=hh.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=xh(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(hh,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=hh.getState(e.state);r?.dragging&&(Eh(e,r.activeHandle,wh(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(hh,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=hh.getState(e.state);if(i&&i.dragging){let a=wh(i.dragging,t,n);Dh(e,i.activeHandle,a,r)}}return Dh(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function xh(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;e<n;e++)r[e]&&(o-=r[e],s--);return o/s}function Sh(e){for(;e&&e.nodeName!=`TD`&&e.nodeName!=`TH`;)e=e.classList&&e.classList.contains(`ProseMirror`)?null:e.parentNode;return e}function Ch(e,t,n,r){let i=n==`right`?-r:r,a=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!a)return-1;let{pos:o}=a,s=Zp(e.state.doc.resolve(o));if(!s)return-1;if(n==`right`)return s.pos;let c=U.get(s.node(-1)),l=s.start(-1),u=c.map.indexOf(s.pos-l);return u%c.width==0?-1:l+c.map[u-1]}function wh(e,t,n){let r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function Th(e,t){e.dispatch(e.state.tr.setMeta(hh,{setHandle:t}))}function Eh(e,t,n){let r=e.state.doc.resolve(t),i=r.node(-1),a=U.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,c=e.state.tr;for(let e=0;e<a.height;e++){let t=e*a.width+s;if(e&&a.map[t]==a.map[t-a.width])continue;let r=a.map[t],l=i.nodeAt(r).attrs,u=l.colspan==1?0:s-a.colCount(r);if(l.colwidth&&l.colwidth[u]==n)continue;let d=l.colwidth?l.colwidth.slice():Oh(l.colspan);d[u]=n,c.setNodeMarkup(o+r,null,{...l,colwidth:d})}c.docChanged&&e.dispatch(c)}function Dh(e,t,n,r){let i=e.state.doc.resolve(t),a=i.node(-1),o=i.start(-1),s=U.get(a).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,c=e.domAtPos(i.start(-1)).node;for(;c&&c.nodeName!=`TABLE`;)c=c.parentNode;c&&mh(a,c.firstChild,c,r,s,n)}function Oh(e){return Array(e).fill(0)}function kh(e,t){let n=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return I.empty;let a=U.get(i),o=r.start(-1),s=a.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<a.height;t++){let r=s+t*a.width;if((s==a.width-1||a.map[r]!=a.map[r+1])&&(t==0||a.map[r]!=a.map[r-a.width])){let t=a.map[r],s=o+t+i.nodeAt(t).nodeSize-1,c=document.createElement(`div`);c.className=`column-resize-handle`,hh.getState(e)?.dragging&&n.push(pl.node(o+t,o+t+i.nodeAt(t).nodeSize,{class:`column-resize-dragging`})),n.push(pl.widget(s,c))}}return I.create(e.doc,n)}function Ah({allowTableNodeSelection:e=!1}={}){return new M({key:Xp,state:{init(){return null},apply(e,t){let n=e.getMeta(Xp);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:lm,handleDOMEvents:{mousedown:lh},createSelectionBetween(e){return Xp.getState(e.state)==null?null:e.state.selection},handleTripleClick:sh,handleKeyDown:rh,handlePaste:ch},appendTransaction(t,n,r){return fm(r,hm(r,n),e)}})}var jh=typeof navigator<`u`?navigator:null,Mh=jh&&jh.userAgent||``,Nh=/Edge\/(\d+)/.exec(Mh),Ph=/MSIE \d/.exec(Mh),Fh=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Mh),Ih=!(Ph||Fh||Nh)&&!!jh&&/Apple Computer/.test(jh.vendor),Lh=new N(`safari-ime-span`),Rh=!1,zh={key:Lh,props:{decorations:Bh,handleDOMEvents:{compositionstart:()=>{Rh=!0},compositionend:()=>{Rh=!1}}}};function Bh(e){let{$from:t,$to:n,to:r}=e.selection;if(Rh&&t.sameParent(n)){let t=pl.widget(r,Vh,{ignoreSelection:!0,key:`safari-ime-span`});return I.create(e.doc,[t])}}function Vh(e){let t=e.dom.ownerDocument.createElement(`span`);return t.className=`ProseMirror-safari-ime-span`,t}var Hh=new M(Ih?zh:{key:Lh});function G(e,t){return Object.assign(e,{meta:{package:`@milkdown/preset-gfm`,...t}}),e}var Uh=kd(`strike_through`);G(Uh,{displayName:`Attr<strikethrough>`,group:`Strikethrough`});var Wh=Ed(`strike_through`,e=>({parseDOM:[{tag:`del`},{style:`text-decoration`,getAttrs:e=>e===`line-through`}],toDOM:t=>[`del`,e.get(Uh.key)(t)],parseMarkdown:{match:e=>e.type===`delete`,runner:(e,t,n)=>{e.openMark(n),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name===`strike_through`,runner:(e,t)=>{e.withMark(t,`delete`)}}}));G(Wh.mark,{displayName:`MarkSchema<strikethrough>`,group:`Strikethrough`}),G(Wh.ctx,{displayName:`MarkSchemaCtx<strikethrough>`,group:`Strikethrough`});var Gh=z(`ToggleStrikeThrough`,e=>()=>Bi(Wh.type(e)));G(Gh,{displayName:`Command<ToggleStrikethrough>`,group:`Strikethrough`});var Kh=vd(e=>da(/(?<![\w:/])(~{1,2})(.+?)\1(?!\w|\/)/,Wh.type(e)));G(Kh,{displayName:`InputRule<strikethrough>`,group:`Strikethrough`});var qh=Dd(`strikeThroughKeymap`,{ToggleStrikethrough:{shortcuts:`Mod-Alt-x`,command:e=>{let t=e.get(R);return()=>t.call(Gh.key)}}});G(qh.ctx,{displayName:`KeymapCtx<strikethrough>`,group:`Strikethrough`}),G(qh.shortcuts,{displayName:`Keymap<strikethrough>`,group:`Strikethrough`});var Jh=Jp({tableGroup:`block`,cellContent:`paragraph`,cellAttributes:{alignment:{default:`left`,getFromDOM:e=>e.style.textAlign||`left`,setDOMAttr:(e,t)=>{t.style=`text-align: ${e||`left`}`}}}}),Yh=B(`table`,()=>({...Jh.table,content:`table_header_row table_row+`,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`table`,runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,t)=>({...e,align:r,isHeader:t===0}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table`,runner:(e,t)=>{let n=t.content.firstChild?.content;if(!n)return;let r=[];n.forEach(e=>{r.push(e.attrs.alignment)}),e.openNode(`table`,void 0,{align:r}),e.next(t.content),e.closeNode()}}}));G(Yh.node,{displayName:`NodeSchema<table>`,group:`Table`}),G(Yh.ctx,{displayName:`NodeSchemaCtx<table>`,group:`Table`});var Xh=B(`table_header_row`,()=>({...Jh.table_row,disableDropCursor:!0,content:`(table_header)*`,parseDOM:[{tag:`tr[data-is-header]`},{tag:`tr`,getAttrs:e=>e instanceof HTMLElement&&e.querySelector(`th`)?{}:!1}],toDOM(){return[`tr`,{"data-is-header":!0},0]},parseMarkdown:{match:e=>!!(e.type===`tableRow`&&e.isHeader),runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,n)=>({...e,align:r[n],isHeader:t.isHeader}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_header_row`,runner:(e,t)=>{t.content.size!==0&&(e.openNode(`tableRow`,void 0,{isHeader:!0}),e.next(t.content),e.closeNode())}}}));G(Xh.node,{displayName:`NodeSchema<tableHeaderRow>`,group:`Table`}),G(Xh.ctx,{displayName:`NodeSchemaCtx<tableHeaderRow>`,group:`Table`});var Zh=B(`table_row`,()=>({...Jh.table_row,disableDropCursor:!0,content:`(table_cell)*`,parseMarkdown:{match:e=>e.type===`tableRow`,runner:(e,t,n)=>{let r=t.align,i=t.children.map((e,t)=>({...e,align:r[t]}));e.openNode(n),e.next(i),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_row`,runner:(e,t)=>{t.content.size!==0&&(e.openNode(`tableRow`),e.next(t.content),e.closeNode())}}}));G(Zh.node,{displayName:`NodeSchema<tableRow>`,group:`Table`}),G(Zh.ctx,{displayName:`NodeSchemaCtx<tableRow>`,group:`Table`});var Qh=B(`table_cell`,()=>({...Jh.table_cell,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`tableCell`&&!e.isHeader,runner:(e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}).openNode(e.schema.nodes.paragraph).next(t.children).closeNode().closeNode()}},toMarkdown:{match:e=>e.type.name===`table_cell`,runner:(e,t)=>{e.openNode(`tableCell`).next(t.content).closeNode()}}}));G(Qh.node,{displayName:`NodeSchema<tableCell>`,group:`Table`}),G(Qh.ctx,{displayName:`NodeSchemaCtx<tableCell>`,group:`Table`});var $h=B(`table_header`,()=>({...Jh.table_header,disableDropCursor:!0,parseMarkdown:{match:e=>e.type===`tableCell`&&!!e.isHeader,runner:(e,t,n)=>{let r=t.align;e.openNode(n,{alignment:r}),e.openNode(e.schema.nodes.paragraph),e.next(t.children),e.closeNode(),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`table_header`,runner:(e,t)=>{e.openNode(`tableCell`),e.next(t.content),e.closeNode()}}}));G($h.node,{displayName:`NodeSchema<tableHeader>`,group:`Table`}),G($h.ctx,{displayName:`NodeSchemaCtx<tableHeader>`,group:`Table`});function eg(e,t=3,n=3){let r=Array(n).fill(0).map(()=>Qh.type(e).createAndFill()),i=Array(n).fill(0).map(()=>$h.type(e).createAndFill()),a=Array(t).fill(0).map((t,n)=>n===0?Xh.type(e).create(null,i):Zh.type(e).create(null,r));return Yh.type(e).create(null,a)}function tg(e){return(t,n)=>r=>{n??=r.selection.from;let i=r.doc.resolve(n),a=va(e=>e.type.name===`table`)(i),o=a?{node:a.node,from:a.start}:void 0,s=e===`row`;if(o){let e=U.get(o.node);if(t>=0&&t<(s?e.height:e.width)){let n=e.positionAt(s?t:e.height-1,s?e.width-1:t,o.node),i=r.doc.resolve(o.from+n),a=s?W.rowSelection:W.colSelection,c=e.positionAt(s?t:0,s?0:t,o.node),l=r.doc.resolve(o.from+c);return fa(r.setSelection(a(i,l)))}}return r}}var ng=tg(`row`),rg=tg(`col`);function ig(e,t,{map:n,tableStart:r,table:i},a){let o=Array(a).fill(0).reduce((e,t,n)=>e+i.child(n).nodeSize,r),s=Array(n.width).fill(0).map((t,r)=>{let a=i.nodeAt(n.map[r]);return Qh.type(e).createAndFill({alignment:a?.attrs.alignment})});return t.insert(o,Zh.type(e).create(null,s)),t}function ag(e){let t=bm(e.$from);if(!t)return;let n=U.get(t.node);return n.cellsInRect({left:0,right:n.width,top:0,bottom:n.height}).map(e=>{let n=t.node.nodeAt(e),r=e+t.start;return{pos:r,start:r+1,node:n}})}function og(e){let t=ag(e.selection);if(t&&t[0]){let n=e.doc.resolve(t[0].pos),r=t[t.length-1];if(r){let t=e.doc.resolve(r.pos);return fa(e.setSelection(new W(t,n)))}}return e}var sg=z(`GoToPrevTableCell`,()=>()=>Wm(-1));G(sg,{displayName:`Command<goToPrevTableCellCommand>`,group:`Table`});var cg=z(`GoToNextTableCell`,()=>()=>Wm(1));G(cg,{displayName:`Command<goToNextTableCellCommand>`,group:`Table`});var lg=z(`ExitTable`,e=>()=>(t,n)=>{if(!Qp(t))return!1;let{$head:r}=t.selection,i=ga(r,Yh.type(e));if(!i)return!1;let{to:a}=i,o=t.tr.replaceWith(a,a,gf.type(e).createAndFill());return o.setSelection(k.near(o.doc.resolve(a),1)).scrollIntoView(),n?.(o),!0});G(lg,{displayName:`Command<breakTableCommand>`,group:`Table`});var ug=z(`InsertTable`,e=>({row:t,col:n}={})=>(r,i)=>{let{selection:a,tr:o}=r,{from:s}=a,c=eg(e,t,n),l=o.replaceSelectionWith(c),u=k.findFrom(l.doc.resolve(s),1,!0);return u&&l.setSelection(u),i?.(l),!0});G(ug,{displayName:`Command<insertTableCommand>`,group:`Table`});var dg=z(`MoveRow`,()=>({from:e,to:t,pos:n}={})=>qm({from:e??0,to:t??0,pos:n}));G(dg,{displayName:`Command<moveRowCommand>`,group:`Table`});var fg=z(`MoveCol`,()=>({from:e,to:t,pos:n}={})=>Jm({from:e??0,to:t??0,pos:n}));G(fg,{displayName:`Command<moveColCommand>`,group:`Table`});var pg=z(`SelectRow`,()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(ng(e.index,e.pos)(r))});G(pg,{displayName:`Command<selectRowCommand>`,group:`Table`});var mg=z(`SelectCol`,()=>(e={index:0})=>(t,n)=>{let{tr:r}=t;return!!n?.(rg(e.index,e.pos)(r))});G(mg,{displayName:`Command<selectColCommand>`,group:`Table`});var hg=z(`SelectTable`,()=>()=>(e,t)=>{let{tr:n}=e;return!!t?.(og(n))});G(hg,{displayName:`Command<selectTableCommand>`,group:`Table`});var gg=z(`DeleteSelectedCells`,()=>()=>(e,t)=>{let{selection:n}=e;if(!(n instanceof W))return!1;let r=n.isRowSelection(),i=n.isColSelection();return r&&i?Gm(e,t):i?Im(e,t):Rm(e,t)});G(gg,{displayName:`Command<deleteSelectedCellsCommand>`,group:`Table`});var _g=z(`AddColBefore`,()=>()=>Nm);G(_g,{displayName:`Command<addColBeforeCommand>`,group:`Table`});var vg=z(`AddColAfter`,()=>()=>Pm);G(vg,{displayName:`Command<addColAfterCommand>`,group:`Table`});var yg=z(`AddRowBefore`,e=>()=>(t,n)=>{if(!Qp(t))return!1;if(n){let r=jm(t);n(ig(e,t.tr,r,r.top))}return!0});G(yg,{displayName:`Command<addRowBeforeCommand>`,group:`Table`});var bg=z(`AddRowAfter`,e=>()=>(t,n)=>{if(!Qp(t))return!1;if(n){let r=jm(t);n(ig(e,t.tr,r,r.bottom))}return!0});G(bg,{displayName:`Command<addRowAfterCommand>`,group:`Table`});var xg=z(`SetAlign`,()=>(e=`left`)=>zm(`alignment`,e));G(xg,{displayName:`Command<setAlignCommand>`,group:`Table`});var Sg=vd(e=>new qi(/^\|(?<col>\d+)[xX](?<row>\d+)\|\s$/,(t,n,r,i)=>{let a=t.doc.resolve(r);if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),Yh.type(e)))return null;let o=eg(e,Math.max(Number(n.groups?.row??0),2),Number(n.groups?.col)),s=t.tr.replaceRangeWith(r,i,o);return s.setSelection(A.create(s.doc,r+3)).scrollIntoView()}));G(Sg,{displayName:`InputRule<insertTableInputRule>`,group:`Table`});var Cg=yd(e=>({run:(t,n,r)=>{if(r)return t;function i(t){let n=t.childCount,r=t.lastChild?.childCount??0;if(n===0||r===0)return gf.type(e).create();let i=t.firstChild;if(!(r>0&&i&&i.childCount===0))return t;if(n>=3){let r=t.child(1),a=[];for(let t=0;t<r.childCount;t++){let n=r.child(t);a.push($h.type(e).create(n.attrs,n.content,n.marks))}let o=i.type.create(i.attrs,a),s=[];for(let e=2;e<n;e++)s.push(t.child(e));return t.type.create(t.attrs,[o,...s])}let a=Array(r).fill(0).map(()=>$h.type(e).createAndFill()),o=new O(E.from(a),0,0),s=i.replace(0,0,o);return t.replace(0,i.nodeSize,new O(E.from(s),0,0))}function a(t){let n=Zh.type(e),r=[],a=[],o=!1;function s(){if(a.length===0)return;let t=Xh.type(e).createAndFill(),n=Yh.type(e).create(null,[t,...a]);r.push(i(n)),a=[]}return t.forEach(e=>{e.type===n?(o=!0,a.push(e)):(s(),r.push(e))}),s(),o?E.from(r):t}function o(t){let n=a(t),r=n!==t,s=[];return n.forEach(t=>{if(t.type===Yh.type(e)){let e=i(t);e!==t&&(r=!0),s.push(e)}else if(t.childCount>0){let e=o(t.content);e===t.content?s.push(t):(r=!0,s.push(t.copy(e)))}else s.push(t)}),r?E.from(s):t}function s(t){let n=[],r=[];t.forEach(e=>r.push(e));for(let t=0;t<r.length;t++){let i=r[t],a=r[t+1];i.type===gf.type(e)&&i.content.size===0&&a&&a.type===Yh.type(e)||n.push(i)}return n.length<r.length?E.from(n):t}let c=o(t.content);return c=s(c),new O(E.from(c),t.openStart,t.openEnd)}}));G(Cg,{displayName:`PasteRule<table>`,group:`Table`});var wg=Dd(`tableKeymap`,{NextCell:{priority:100,shortcuts:[`Mod-]`,`Tab`],command:e=>{let t=e.get(R);return()=>t.call(cg.key)}},PrevCell:{shortcuts:[`Mod-[`,`Shift-Tab`],command:e=>{let t=e.get(R);return()=>t.call(sg.key)}},ExitTable:{shortcuts:[`Mod-Enter`,`Enter`],command:e=>{let t=e.get(R);return()=>t.call(lg.key)}}});G(wg.ctx,{displayName:`KeymapCtx<table>`,group:`Table`}),G(wg.shortcuts,{displayName:`Keymap<table>`,group:`Table`});var Tg=`footnote_definition`,Eg=`footnoteDefinition`,Dg=B(`footnote_definition`,()=>({group:`block`,content:`block+`,defining:!0,attrs:{label:{default:``,validate:`string`}},parseDOM:[{tag:`dl[data-type="${Tg}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{label:e.dataset.label}},contentElement:`dd`}],toDOM:e=>{let t=e.attrs.label;return[`dl`,{"data-label":t,"data-type":Tg},[`dt`,t],[`dd`,0]]},parseMarkdown:{match:({type:e})=>e===Eg,runner:(e,t,n)=>{e.openNode(n,{label:t.label}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name===Tg,runner:(e,t)=>{e.openNode(Eg,void 0,{label:t.attrs.label,identifier:t.attrs.label}).next(t.content).closeNode()}}}));G(Dg.ctx,{displayName:`NodeSchemaCtx<footnodeDef>`,group:`footnote`}),G(Dg.node,{displayName:`NodeSchema<footnodeDef>`,group:`footnote`});var Og=`footnote_reference`,kg=B(`footnote_reference`,()=>({group:`inline`,inline:!0,atom:!0,attrs:{label:{default:``,validate:`string`}},parseDOM:[{tag:`sup[data-type="${Og}"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{label:e.dataset.label}}}],toDOM:e=>{let t=e.attrs.label;return[`sup`,{"data-label":t,"data-type":Og},t]},parseMarkdown:{match:({type:e})=>e===`footnoteReference`,runner:(e,t,n)=>{e.addNode(n,{label:t.label})}},toMarkdown:{match:e=>e.type.name===Og,runner:(e,t)=>{e.addNode(`footnoteReference`,void 0,void 0,{label:t.attrs.label,identifier:t.attrs.label})}}}));G(kg.ctx,{displayName:`NodeSchemaCtx<footnodeRef>`,group:`footnote`}),G(kg.node,{displayName:`NodeSchema<footnodeRef>`,group:`footnote`});var Ag=cp.extendSchema(e=>t=>{let n=e(t);return{...n,attrs:{...n.attrs,checked:{default:null,validate:`boolean|null`}},parseDOM:[{tag:`li[data-item-type="task"]`,getAttrs:e=>{if(!(e instanceof HTMLElement))throw Xe(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread,checked:e.dataset.checked?e.dataset.checked===`true`:null}}},...n?.parseDOM||[]],toDOM:e=>n.toDOM&&e.attrs.checked==null?n.toDOM(e):[`li`,{"data-item-type":`task`,"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread,"data-checked":e.attrs.checked},0],parseMarkdown:{match:({type:e})=>e===`listItem`,runner:(e,t,r)=>{if(t.checked==null){n.parseMarkdown.runner(e,t,r);return}let i=t.label==null?`•`:`${t.label}.`,a=t.checked==null?null:!!t.checked,o=t.label==null?`bullet`:`ordered`,s=t.spread==null?`true`:`${t.spread}`;e.openNode(r,{label:i,listType:o,spread:s,checked:a}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name===`list_item`,runner:(e,t)=>{if(t.attrs.checked==null){n.toMarkdown.runner(e,t);return}let r=t.attrs.label,i=t.attrs.listType,a=t.attrs.spread===`true`,o=t.attrs.checked;e.openNode(`listItem`,void 0,{label:r,listType:i,spread:a,checked:o}),e.next(t.content),e.closeNode()}}}});G(Ag.node,{displayName:`NodeSchema<taskListItem>`,group:`ListItem`}),G(Ag.ctx,{displayName:`NodeSchemaCtx<taskListItem>`,group:`ListItem`});var jg=vd(()=>new qi(/^\[(?<checked>\s|x)\]\s$/,(e,t,n,r)=>{let i=e.doc.resolve(n),a=0,o=i.node(a);for(;o&&o.type.name!==`list_item`;)a--,o=i.node(a);if(!o||o.attrs.checked!=null)return null;let s=t.groups?.checked===`x`,c=i.before(a),l=e.tr;return l.deleteRange(n,r).setNodeMarkup(c,void 0,{...o.attrs,checked:s}),l}));G(jg,{displayName:`InputRule<wrapInTaskListInputRule>`,group:`ListItem`});var Mg=[qh,wg].flat(),Ng=[Sg,jg],Pg=[Kh],Fg=[Cg],Ig=Sd(()=>Hh);G(Ig,{displayName:`Prose<autoInsertSpanPlugin>`,group:`Prose`}),G(Sd(()=>gh({})),{displayName:`Prose<columnResizingPlugin>`,group:`Prose`});var Lg=Sd(()=>Ah({allowTableNodeSelection:!0}));G(Lg,{displayName:`Prose<tableEditingPlugin>`,group:`Prose`});var Rg=Ad(`remarkGFM`,()=>y);G(Rg.plugin,{displayName:`Remark<remarkGFMPlugin>`,group:`Remark`}),G(Rg.options,{displayName:`RemarkConfig<remarkGFMPlugin>`,group:`Remark`});var zg=new N(`MILKDOWN_KEEP_TABLE_ALIGN_PLUGIN`);function Bg(e,t){let n=0;return t.forEach((t,r,i)=>{t===e&&(n=i)}),n}var Vg=Sd(()=>new M({key:zg,appendTransaction:(e,t,n)=>{let r;return t.doc!==n.doc&&n.doc.descendants((e,t)=>{if(r||=n.tr,e.type.name!==`table_cell`)return;let i=n.doc.resolve(t),a=i.node(i.depth),o=i.node(i.depth-1).firstChild;if(!o)return;let s=Bg(e,a),c=o.maybeChild(s);if(!c)return;let l=c.attrs.alignment;l!==e.attrs.alignment&&r.setNodeMarkup(t,void 0,{...e.attrs,alignment:l})}),r}}));G(Vg,{displayName:`Prose<keepTableAlignPlugin>`,group:`Prose`});var Hg=[Vg,Ig,Rg,Lg].flat(),Ug=[Ag,Yh,Xh,Zh,$h,Qh,Dg,kg,Uh,Wh].flat(),Wg=[cg,sg,lg,ug,dg,fg,pg,mg,hg,gg,yg,bg,_g,vg,xg,Gh];[Ug,Ng,Fg,Pg,Mg,Wg,Hg].flat();function Gg(e){if(!e)return!1;if(Array.isArray(e))return e.length>1?!1:Gg(e[0]);let t=e.content;return t?Gg(t):e.type===`text`}function Kg(e,t){return Object.assign(e,{meta:{package:`@milkdown/plugin-clipboard`,...t}}),e}function qg(e,t){let n=ma(t);if(n)return e.dispatch(e.state.tr.replaceSelectionWith(n,!0)),!0;try{return e.dispatch(e.state.tr.replaceSelection(t)),!0}catch{return!1}}var Jg=Sd(e=>{let t=e.get(xu);return e.update(od,e=>({...e,editable:e.editable??(()=>!0),transformPastedHTML:(t,n)=>{let r=e.transformPastedHTML;return r&&(t=r(t,n)),t.includes(`docs-internal-guid`)&&(t=t.replace(/<b[^>]*id="docs-internal-guid[^"]*"[^>]*>([\s\S]*)<\/b>/,`$1`),t=t.replace(/<div[^>]*>(<table[\s\S]*?<\/table>)<\/div>/g,`$1`)),t}})),new M({key:new N(`MILKDOWN_CLIPBOARD`),props:{handlePaste:(n,r,i)=>{let a=e.get(zu),o=n.props.editable?.(n.state),{clipboardData:s}=r;if(!o||!s||n.state.selection.$from.node().type.spec.code)return!1;let c=s.getData(`text/plain`),l=s.getData(`vscode-editor-data`);if(l){let e=JSON.parse(l)?.mode;if(c&&e){let{tr:r}=n.state,i=_a(`code_block`,t);return r.replaceSelectionWith(i.create({language:e})).setSelection(A.near(r.doc.resolve(Math.max(0,r.selection.from-2)))).insertText(c.replace(/\r\n?/g,`
|
|
34
34
|
`)),n.dispatch(r),!0}}let u=s.getData(`text/html`);if(u.length===0&&c.length===0)return!1;if(u.length>0&&i)return qg(n,i);let d=un.fromSchema(t),f;if(u.length===0){let e=a(c);if(!e||typeof e==`string`)return!1;f=wn.fromSchema(t).serializeFragment(e.content)}else{let e=document.createElement(`template`);e.innerHTML=u,f=e.content.cloneNode(!0),e.remove()}return qg(n,d.parseSlice(f))},clipboardTextSerializer:n=>{let r=e.get(Gu);if(Gg(n.content.toJSON()))return n.content.textBetween(0,n.content.size,`
|
|
35
35
|
|
|
36
36
|
`);let i=t.topNodeType.createAndFill(void 0,n.content);return i?r(i):``}}})});Kg(Jg,{displayName:`Prose<clipboard>`});var Yg=200,K=function(){};K.prototype.append=function(e){return e.length?(e=K.from(e),!this.length&&e||e.length<Yg&&this.leafAppend(e)||this.length<Yg&&e.leafPrepend(this)||this.appendInner(e)):this},K.prototype.prepend=function(e){return e.length?K.from(e).append(this):this},K.prototype.appendInner=function(e){return new Zg(this,e)},K.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?K.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},K.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},K.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},K.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},K.from=function(e){return e instanceof K?e:e&&e.length?new Xg(e):K.empty};var Xg=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Yg)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Yg)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(K);K.empty=new Xg([]);var Zg=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(K),Qg=500,$g=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new t_(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new t_(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new t_(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>r_&&(s=e_(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new Hn;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new t_(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new t_(i,o,l))}else r.push(new t_(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new t_(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>Qg&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new t_(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(K.from(i.reverse()),a)}};$g.empty=new $g(K.empty,0);function e_(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var t_=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},n_=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},r_=20;function i_(e,t,n,r){let i=n.getMeta(f_),a;if(i)return i.historyState;n.getMeta(p_)&&(e=new n_(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(f_))return o.getMeta(f_).redo?new n_(e.done.addTransform(n,void 0,r,d_(t)),e.undone,o_(n.mapping.maps),e.prevTime,e.prevComposition):new n_(e.done,e.undone.addTransform(n,void 0,r,d_(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!a_(n,e.prevRanges)),s=o?s_(e.prevRanges,n.mapping):o_(n.mapping.maps);return new n_(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,d_(t)),$g.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new n_(e.done.rebased(n,a),e.undone.rebased(n,a),s_(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new n_(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),s_(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function a_(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function o_(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function s_(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function c_(e,t,n){let r=d_(t),i=f_.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new n_(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(f_,{redo:n,historyState:c})}var l_=!1,u_=null;function d_(e){let t=e.plugins;if(u_!=t){l_=!1,u_=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){l_=!0;break}}return l_}var f_=new N(`history`),p_=new N(`closeHistory`);function m_(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new M({key:f_,state:{init(){return new n_($g.empty,$g.empty,null,0,-1)},apply(t,n,r){return i_(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?g_:n==`historyRedo`?__:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function h_(e,t){return(n,r)=>{let i=f_.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=c_(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var g_=h_(!1,!0),__=h_(!0,!0);function v_(e,t){return Object.assign(e,{meta:{package:`@milkdown/plugin-history`,...t}}),e}var y_=z(`Undo`,()=>()=>g_);v_(y_,{displayName:`Command<undo>`});var b_=z(`Redo`,()=>()=>__);v_(b_,{displayName:`Command<redo>`});var x_=Td({},`historyProviderConfig`);v_(x_,{displayName:`Ctx<historyProviderConfig>`});var S_=Sd(e=>m_(e.get(x_.key)));v_(S_,{displayName:`Ctx<historyProviderPlugin>`});var C_=Dd(`historyKeymap`,{Undo:{shortcuts:`Mod-z`,command:e=>{let t=e.get(R);return()=>t.call(y_.key)}},Redo:{shortcuts:[`Mod-y`,`Shift-Mod-z`],command:e=>{let t=e.get(R);return()=>t.call(b_.key)}}});v_(C_.ctx,{displayName:`KeymapCtx<history>`}),v_(C_.shortcuts,{displayName:`Keymap<history>`});var w_=[x_,S_,C_,y_,b_].flat(),T_=class{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.selectionUpdatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=e=>(this.beforeMountedListeners.push(e),this),this.mounted=e=>(this.mountedListeners.push(e),this),this.updated=e=>(this.updatedListeners.push(e),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners,selectionUpdated:this.selectionUpdatedListeners}}markdownUpdated(e){return this.markdownUpdatedListeners.push(e),this}blur(e){return this.blurListeners.push(e),this}focus(e){return this.focusListeners.push(e),this}destroy(e){return this.destroyListeners.push(e),this}selectionUpdated(e){return this.selectionUpdatedListeners.push(e),this}},E_=w(new T_,`listener`),D_=new N(`MILKDOWN_LISTENER`),O_=e=>(e.inject(E_,new T_),async()=>{await e.wait(_u);let{listeners:t}=e.get(E_);t.beforeMount.forEach(t=>t(e)),await e.wait(Hu);let n=e.get(Gu),r=null,i=null,a=null,o=null,s=ce(()=>{if(!o)return;let{doc:a}=o;if(t.updated.length>0&&r&&!r.eq(a)&&t.updated.forEach(t=>{t(e,a,r)}),t.markdownUpdated.length>0&&r&&!r.eq(a)){let r=n(a);t.markdownUpdated.forEach(t=>{t(e,r,i)}),i=r}r=a,o=null},200),c=new M({key:D_,view:()=>({destroy:()=>{t.destroy.forEach(t=>t(e))}}),props:{handleDOMEvents:{focus:()=>(t.focus.forEach(t=>t(e)),!1),blur:()=>(t.blur.forEach(t=>t(e)),!1)}},state:{init:(e,t)=>{r=t.doc,i=n(t.doc)},apply:n=>{let r=n.selection;(!a&&r||a&&!r.eq(a))&&(t.selectionUpdated.forEach(t=>{t(e,r,a)}),a=r),!(!(n.docChanged||n.storedMarksSet)||n.getMeta(`addToHistory`)===!1)&&(o=n,s())}}});e.update(lu,e=>e.concat(c)),await e.wait(id),t.mounted.forEach(t=>t(e))});O_.meta={package:`@milkdown/plugin-listener`,displayName:`Listener`};var q=e(n(),1);function k_(e){e?.querySelector(`.ProseMirror`)?.focus()}function A_(e){let t=document.createElement(`div`);return t.innerHTML=e,t.textContent??``}function j_(e){return e instanceof HTMLElement&&!!e.closest(`textarea.notes-code-raw`)}function M_(e){return e.trim().toLowerCase().replace(/[^a-z0-9_+-]/g,``)}function N_(e){e&&e.querySelectorAll(`img[src]`).forEach(e=>{let t=e.dataset.notesOriginalSrc||e.getAttribute(`src`)||``;if(!t)return;let n=v(t);n&&(e.dataset.notesOriginalSrc=t,e.getAttribute(`src`)!==n&&e.setAttribute(`src`,n))})}var P_=new Set([`code_block`,`math_block`]),F_=new Set([`math_inline`]);function I_(e,t,n){let r=e.nodeDOM(t);return r instanceof HTMLElement?(r.dispatchEvent(new CustomEvent(`notes-enter-editing`,{bubbles:!1,detail:{caretPosition:n}})),!0):!1}function L_(e,t){if(!(e.selection instanceof A))return null;let{$cursor:n}=e.selection;if(!n||t===`prev`&&n.parentOffset!==0||t===`next`&&n.parentOffset!==n.parent.content.size)return null;let r=n.depth;if(r<1)return null;let i=r-1,a=n.index(i),o=n.node(i);if(t===`prev`){if(a===0)return null;let e=o.child(a-1);return P_.has(e.type.name)?{node:e,pos:n.before(r)-e.nodeSize}:null}if(a>=o.childCount-1)return null;let s=o.child(a+1);return P_.has(s.type.name)?{node:s,pos:n.after(r)}:null}var R_=[Sd(()=>Ea({Backspace:(e,t,n)=>{if(!(e.selection instanceof A))return!1;let{$cursor:r}=e.selection;if(!r||r.parentOffset!==0)return!1;if(r.parent.type.name===`heading`){let n=e.schema.nodes.paragraph;if(!n||!t)return!0;let i=r.depth,a=r.before(i),o=e.tr.setNodeMarkup(a,n);return o.setSelection(A.near(o.doc.resolve(a+1))),t(o.scrollIntoView()),!0}let i=r.depth;if(i<1)return!1;let a=i-1,o=r.index(a);if(o===0)return!1;let s=r.node(a).child(o-1);if(!P_.has(s.type.name))return!1;if(!n)return!0;let c=r.before(i)-s.nodeSize,l=n.nodeDOM(c);return l instanceof HTMLElement&&l.dispatchEvent(new CustomEvent(`notes-enter-editing`,{bubbles:!1})),!0},Enter:(e,t)=>{if(!(e.selection instanceof j))return!1;let n=e.selection.node;if(!P_.has(n.type.name))return!1;if(!t)return!0;let r=e.selection.from+n.nodeSize,i=e.schema.nodes.paragraph?.create();if(!i)return!1;let a=e.tr.insert(r,i);return a.setSelection(A.create(a.doc,r+1)),t(a.scrollIntoView()),!0},ArrowDown:(e,t,n)=>{if(!n||!n.endOfTextblock(`down`))return!1;let r=L_(e,`next`);return r?I_(n,r.pos,`start`):!1},ArrowUp:(e,t,n)=>{if(!n||!n.endOfTextblock(`up`))return!1;let r=L_(e,`prev`);return r?I_(n,r.pos,`end`):!1},ArrowRight:(e,t,n)=>{if(!n||!(e.selection instanceof A))return!1;let{$cursor:r}=e.selection;if(!r)return!1;let i=r.nodeAfter;if(i&&F_.has(i.type.name))return I_(n,r.pos,`start`);if(r.parentOffset!==r.parent.content.size)return!1;let a=L_(e,`next`);return a?I_(n,a.pos,`start`):!1},ArrowLeft:(e,t,n)=>{if(!n||!(e.selection instanceof A))return!1;let{$cursor:r}=e.selection;if(!r)return!1;let i=r.nodeBefore;if(i&&F_.has(i.type.name))return I_(n,r.pos-i.nodeSize,`end`);if(r.parentOffset!==0)return!1;let a=L_(e,`prev`);return a?I_(n,a.pos,`end`):!1}}))].flat(),z_=[{label:`Heading 1`,icon:`H1`,run:e=>V(Ef.key,1)(e)},{label:`Heading 2`,icon:`H2`,run:e=>V(Ef.key,2)(e)},{label:`Heading 3`,icon:`H3`,run:e=>V(Ef.key,3)(e)},{label:`Bullet List`,icon:`•`,run:e=>V(ep.key)(e)},{label:`Ordered List`,icon:`1.`,run:e=>V(ap.key)(e)},{label:`Blockquote`,icon:`❝`,run:e=>V(Mf.key)(e)},{label:`Code Block`,icon:`<>`,run:e=>V(Lf.key)(e)},{label:`Table`,icon:`⊞`,run:e=>V(ug.key,{row:3,col:3})(e)},{label:`Divider`,icon:`—`,run:e=>V(Xf.key)(e)},{label:`Math Block`,icon:`∑`,run:e=>{let t=e.get(L),n=e.get(xu).nodes.math_block?.create({value:``});n&&t.dispatch(t.state.tr.replaceSelectionWith(n,!1).scrollIntoView())}}],B_=null,V_=0;function H_(){B_&&=(B_.remove(),null)}function U_(e){let{state:t}=e,{$from:n}=t.selection;if(n.parent.type.name===`code_block`||n.marks().some(e=>e.type.name===`code_inline`))return null;let r=n.parent.textBetween(0,n.parentOffset).match(/\/(\S*)$/);if(!r)return null;let i=n.parentOffset-r[0].length;return{from:n.start()+i,to:n.pos,filter:r[1]}}function W_(e){if(!e)return z_;let t=e.toLowerCase();return z_.filter(e=>e.label.toLowerCase().includes(t))}function G_(e,t,n){if(e.innerHTML=``,t.length===0){let t=document.createElement(`div`);t.className=`notes-slash-menu-empty`,t.textContent=`No matches`,e.appendChild(t);return}for(let r=0;r<t.length;r++){let i=t[r],a=document.createElement(`button`);a.type=`button`,a.className=`notes-slash-menu-item${r===V_?` notes-slash-menu-item--active`:``}`,a.setAttribute(`role`,`option`);let o=document.createElement(`span`);o.className=`notes-slash-menu-icon`,o.textContent=i.icon;let s=document.createElement(`span`);s.textContent=i.label,a.appendChild(o),a.appendChild(s),a.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation(),n(i)}),e.appendChild(a)}}function K_(){B_&&B_.querySelectorAll(`.notes-slash-menu-item`).forEach((e,t)=>e.classList.toggle(`notes-slash-menu-item--active`,t===V_))}function q_(e,t,n){H_();let r=W_(n.filter),i=document.createElement(`div`);i.className=`notes-slash-menu`,i.setAttribute(`role`,`listbox`),V_=0;function a(r){let{state:i}=e;e.dispatch(i.tr.deleteRange(n.from,n.to)),r.run(t),H_(),e.focus()}G_(i,r,a);let o=e.coordsAtPos(n.from);i.style.left=`${o.left}px`,i.style.top=`${o.bottom+4}px`,document.body.appendChild(i),B_=i;let s=i.getBoundingClientRect();s.right>window.innerWidth&&(i.style.left=`${window.innerWidth-s.width-8}px`),s.bottom>window.innerHeight&&(i.style.top=`${o.top-s.height-4}px`)}var J_=[Sd(e=>new M({key:new N(`notes-slash-menu`),props:{handleKeyDown:(t,n)=>{if(!B_)return!1;let r=U_(t);if(!r)return H_(),!1;let i=W_(r.filter);return i.length===0?!1:n.key===`ArrowDown`?(n.preventDefault(),V_=(V_+1)%i.length,K_(),!0):n.key===`ArrowUp`?(n.preventDefault(),V_=(V_-1+i.length)%i.length,K_(),!0):n.key===`Enter`?(n.preventDefault(),t.dispatch(t.state.tr.deleteRange(r.from,r.to)),i[V_].run(e),H_(),t.focus(),!0):n.key===`Escape`?(n.preventDefault(),H_(),!0):!1}},view:()=>({update:t=>{let n=U_(t);if(!n){H_();return}q_(t,e,n)},destroy:()=>H_()})}))].flat(),Y_=[{label:`Insert Row Above`,run:e=>V(yg.key)(e)},{label:`Insert Row Below`,run:e=>V(bg.key)(e)},{label:`Insert Column Left`,run:e=>V(_g.key)(e)},{label:`Insert Column Right`,run:e=>V(vg.key)(e)},{label:``,separator:!0,run:()=>{}},{label:`Delete Selected Cells`,run:e=>V(gg.key)(e)},{label:`Select Entire Table`,run:e=>V(hg.key)(e)}];function X_(e,t){let n=e.state.doc.resolve(t);for(let e=n.depth;e>0;e--)if(n.node(e).type.name===`table`)return!0;return!1}var Z_=null;function Q_(){Z_&&=(Z_.remove(),null)}function $_(e,t){Q_();let n=document.createElement(`div`);n.className=`notes-table-context-menu`,n.setAttribute(`role`,`menu`);for(let e of Y_){if(e.separator){let e=document.createElement(`div`);e.className=`notes-table-context-menu-separator`,n.appendChild(e);continue}let r=document.createElement(`button`);r.type=`button`,r.className=`notes-table-context-menu-item`,r.setAttribute(`role`,`menuitem`),r.textContent=e.label,r.addEventListener(`mousedown`,n=>{n.preventDefault(),n.stopPropagation(),e.run(t),Q_()}),n.appendChild(r)}n.style.left=`${e.clientX}px`,n.style.top=`${e.clientY}px`,document.body.appendChild(n),Z_=n;let r=n.getBoundingClientRect();r.right>window.innerWidth&&(n.style.left=`${e.clientX-r.width}px`),r.bottom>window.innerHeight&&(n.style.top=`${e.clientY-r.height}px`);function i(e){e instanceof KeyboardEvent&&e.key!==`Escape`||(Q_(),document.removeEventListener(`mousedown`,i),document.removeEventListener(`keydown`,i))}setTimeout(()=>{document.addEventListener(`mousedown`,i),document.addEventListener(`keydown`,i)},0)}var ev=[Sd(e=>new M({key:new N(`notes-table-context-menu`),props:{handleDOMEvents:{contextmenu:(t,n)=>{let r=t.posAtCoords({left:n.clientX,top:n.clientY});if(!r||!X_(t,r.pos))return!1;n.preventDefault();let i=t.state.doc.resolve(r.pos),a=A.near(i);return t.dispatch(t.state.tr.setSelection(a)),$_(n,e),!0}}}}))].flat(),tv=`notes-code-source-updated`;function nv(e){return e.textContent}function rv(e){return String(e.attrs.language??``)}function iv(e){return`\`\`\`${rv(e)}\n${nv(e)}\n\`\`\``}function av(e){let t=e.replace(/\r\n?/g,`
|
|
@@ -41,7 +41,7 @@ import{r as e}from"./rolldown-runtime-XQCOJYun.js";import{A as t}from"./vendor-r
|
|
|
41
41
|
`,t-1)+1,i=n.indexOf(`
|
|
42
42
|
`,t),a=i===-1?n.length:i,o=n.slice(r,a);return/^```[^\n`]*$/.test(o)&&r===0?`above`:`below`}function fv(){return(e,t,n)=>{let r=e,a=document.createElement(`div`),o=document.createElement(`div`),s=document.createElement(`div`),c=document.createElement(`pre`),l=document.createElement(`code`),u=document.createElement(`textarea`),d=document.createElement(`div`),f=document.createElement(`button`);a.className=`notes-code-source-node`;let m=document.createElement(`button`);o.className=`notes-code-rendered`,s.className=`notes-code-source-header`,m.className=`notes-code-copy-btn`,m.type=`button`,m.setAttribute(`aria-label`,`Copy code`),d.className=`notes-code-raw-controls`,f.className=`notes-code-done-btn`,f.type=`button`,f.textContent=`Done`,f.setAttribute(`aria-label`,`Done editing code block`),u.className=`notes-code-raw`,u.setAttribute(`aria-label`,`Edit fenced code source`),a.contentEditable=`false`,a.tabIndex=0,c.append(l),s.append(m),o.append(s,c),d.append(f),a.append(o,d,u);function h(){return rv(r)||`copy`}function g(){let e=rv(r),t=nv(r);a.dataset.language=e,c.dataset.language=e,m.textContent=h();let n=p(t,e);l.className=`hljs language-${n.language}`,l.dataset.highlighted=n.highlighted?`yes`:`no`,l.innerHTML=n.html,a.dataset.editing!==`true`&&(u.value=iv(r))}function _(e,i={}){if(!(a.dataset.editing===`true`&&e)&&!(!e&&a.dataset.editing!==`true`)){if(!e&&i.commit!==!1){let e=u.value;a.dataset.editing=`false`,u.blur(),lv(t,n,e);return}a.dataset.editing=e?`true`:`false`,e?(u.value=iv(r),u.focus(),u.select()):u.blur()}}function v(e){a.dataset.editing===`true`&&(a.contains(e.target)||setTimeout(()=>{a.dataset.editing===`true`&&_(!1,{commit:!1})},0))}function y(e=`below`){let r=u.value;_(!1,{commit:!1}),uv(t,n,r,e),t.focus()}function b(e){if(!(e instanceof HTMLElement))return;let t=e.querySelector(`textarea.notes-code-raw`);t instanceof HTMLTextAreaElement&&(e.dataset.editing=`true`,t.focus(),t.select())}function x(e){if(u.contains(e.target)||m.contains(e.target)||a.dataset.editing===`true`)return;e.preventDefault(),e.stopPropagation();let t=e instanceof PointerEvent||e instanceof MouseEvent?{x:e.clientX,y:e.clientY}:null;setTimeout(()=>{if(a.isConnected){_(!0);return}b(t?document.elementFromPoint(t.x,t.y)?.closest(`.notes-code-source-node`)??null:null)},0)}return a.addEventListener(`pointerdown`,x,{capture:!0}),a.addEventListener(`mousedown`,x,{capture:!0}),a.addEventListener(`click`,x),a.addEventListener(`keydown`,e=>{e.target===a&&a.dataset.editing!==`true`&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),_(!0))}),u.addEventListener(`keydown`,e=>{if(e.key===`Escape`){e.preventDefault(),_(!1,{commit:!1}),t.focus();return}if(e.key===`Enter`&&ov(u.value)&&sv(u)){e.preventDefault(),y(dv(u));return}if(e.key===`ArrowUp`&&ov(u.value)&&!u.value.slice(0,u.selectionStart).includes(`
|
|
43
43
|
`)){e.preventDefault(),y(`above`);return}if(e.key===`ArrowDown`&&ov(u.value)&&!u.value.slice(u.selectionEnd).includes(`
|
|
44
|
-
`)){e.preventDefault(),y(`below`);return}if(e.key===`ArrowLeft`&&ov(u.value)&&u.selectionStart===0&&u.selectionEnd===0){e.preventDefault(),y(`above`);return}if(e.key===`ArrowRight`&&ov(u.value)&&u.selectionStart===u.value.length&&u.selectionEnd===u.value.length){e.preventDefault(),y(`below`);return}e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),_(!1,{commit:!1}),t.focus())}),u.addEventListener(`input`,()=>{lv(t,n,u.value)}),u.addEventListener(`blur`,()=>{setTimeout(()=>{a.dataset.editing===`true`&&document.activeElement!==u&&_(!1,{commit:!1})},0)}),u.addEventListener(`mousedown`,e=>e.stopPropagation()),u.addEventListener(`click`,e=>e.stopPropagation()),document.addEventListener(`pointerdown`,v,!0),f.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),y(`below`)}),f.addEventListener(`mousedown`,e=>e.stopPropagation()),m.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),i(nv(r)).then(e=>{if(!e.ok)throw Error(e.error??`Copy failed`);m.textContent=`Copied!`,setTimeout(()=>{m.textContent=h()},1500)}).catch(e=>{console.error(`[notes:wysiwyg-code-copy]`,e)})}),m.addEventListener(`mousedown`,e=>e.stopPropagation()),a.addEventListener(`notes-enter-editing`,e=>{_(!0);let t=e.detail?.caretPosition===`start`?0:u.value.length;u.setSelectionRange(t,t)}),g(),{dom:a,update:e=>e.type===r.type?(r=e,g(),!0):!1,selectNode:()=>{a.dataset.selected=`true`},deselectNode:()=>{a.dataset.selected=`false`,a.dataset.editing===`true`&&_(!1,{commit:!1})},stopEvent:e=>e.target===u||u.contains(e.target)||e.target===f||f.contains(e.target)||e.type===`pointerdown`||e.type===`mousedown`||e.type===`click`,ignoreMutation:e=>e.target===a||e.target===u||u.contains(e.target)||d.contains(e.target)||o.contains(e.target),destroy:()=>{document.removeEventListener(`pointerdown`,v,!0)}}}}var pv=[wd(Ff.node,()=>fv())].flat(),mv=[Ug,Ng.filter(e=>e!==jg),Pg,Fg,Mg,Wg,Hg].flat(),hv=1,gv=6,_v=`notes-heading-source-updated`;function vv(e){let t=Number(e.attrs.level);return Number.isFinite(t)?Math.min(gv,Math.max(hv,Math.trunc(t))):hv}function yv(e){return`#`.repeat(e)}function bv(e){let t=e.trim();return t===``?0:/^#{1,6}$/.test(t)?t.length:null}function xv(e,t){return A.near(e.state.doc.resolve(Math.min(t,e.state.doc.content.size)),1)}function Sv(e,t,n,r){let i=t();if(i===void 0)return;let a=e.state.doc.nodeAt(i);if(!a||a.type.name!==`heading`)return;let o=e.state.schema.nodes.paragraph,s=r===0&&o?e.state.tr.setNodeMarkup(i,o):e.state.tr.setNodeMarkup(i,void 0,{...n.attrs,level:r});r===0?s.setSelection(xv(e,i+1)):s.setSelection(e.state.selection.map(s.doc,s.mapping)),e.dispatch(s.scrollIntoView()),e.dom.dispatchEvent(new CustomEvent(_v,{bubbles:!0}))}function Cv(){return(e,t,n)=>{let r=e,i=document.createElement(`div`),a=document.createElement(`input`),o=document.createElement(`span`);i.className=`notes-heading-source-node`,a.className=`notes-heading-source-marker`,a.type=`text`,a.inputMode=`text`,a.autocomplete=`off`,a.spellcheck=!1,a.setAttribute(`aria-label`,`Edit heading marker`),o.className=`notes-heading-source-content`,i.append(a,o);function s(){let e=vv(r);i.dataset.level=String(e),i.setAttribute(`role`,`heading`),i.setAttribute(`aria-level`,String(e)),i.setAttribute(`aria-label`,r.textContent),document.activeElement!==a&&(a.value=yv(e)),a.size=Math.max(1,a.value.length)}function c(){let e=bv(a.value);if(e===null){a.value=yv(vv(r)),s();return}Sv(t,n,r,e),t.focus()}function l(e){a.contains(e.target)&&(e.preventDefault(),e.stopPropagation(),a.focus(),a.select(),window.setTimeout(()=>{a.focus(),a.select()},0))}function u(){i.dataset.editing=`true`,a.select()}function d(){a.size=Math.max(1,a.value.length);let e=bv(a.value);e===null||e===0||e===vv(r)||Sv(t,n,r,e)}function f(){i.dataset.editing=`false`,c()}function p(e){e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),a.blur()),e.key===`Escape`&&(e.preventDefault(),a.value=yv(vv(r)),i.dataset.editing=`false`,a.blur(),t.focus())}return i.addEventListener(`pointerdown`,l,{capture:!0}),i.addEventListener(`mousedown`,l,{capture:!0}),i.addEventListener(`click`,l,{capture:!0}),a.addEventListener(`focus`,u),a.addEventListener(`input`,d),a.addEventListener(`blur`,f),a.addEventListener(`keydown`,p),s(),{dom:i,contentDOM:o,update(e){return e.type.name===`heading`?(r=e,s(),!0):!1},selectNode(){i.dataset.selected=`true`},deselectNode(){delete i.dataset.selected},stopEvent(e){return a.contains(e.target)||e.type===`pointerdown`||e.type===`mousedown`||e.type===`click`},ignoreMutation(e){return e.target===i||a.contains(e.target)},destroy(){i.removeEventListener(`pointerdown`,l,{capture:!0}),i.removeEventListener(`mousedown`,l,{capture:!0}),i.removeEventListener(`click`,l,{capture:!0}),a.removeEventListener(`focus`,u),a.removeEventListener(`input`,d),a.removeEventListener(`blur`,f),a.removeEventListener(`keydown`,p)}}}}var wv=[wd(wf.node,()=>Cv())].flat(),Tv=`math_inline`,Ev=`math_block`,Dv=`notes-math-source-updated`,Ov=Td({},`notesKatexOptions`),kv=Ad(`notesRemarkMath`,()=>
|
|
44
|
+
`)){e.preventDefault(),y(`below`);return}if(e.key===`ArrowLeft`&&ov(u.value)&&u.selectionStart===0&&u.selectionEnd===0){e.preventDefault(),y(`above`);return}if(e.key===`ArrowRight`&&ov(u.value)&&u.selectionStart===u.value.length&&u.selectionEnd===u.value.length){e.preventDefault(),y(`below`);return}e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),_(!1,{commit:!1}),t.focus())}),u.addEventListener(`input`,()=>{lv(t,n,u.value)}),u.addEventListener(`blur`,()=>{setTimeout(()=>{a.dataset.editing===`true`&&document.activeElement!==u&&_(!1,{commit:!1})},0)}),u.addEventListener(`mousedown`,e=>e.stopPropagation()),u.addEventListener(`click`,e=>e.stopPropagation()),document.addEventListener(`pointerdown`,v,!0),f.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),y(`below`)}),f.addEventListener(`mousedown`,e=>e.stopPropagation()),m.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),i(nv(r)).then(e=>{if(!e.ok)throw Error(e.error??`Copy failed`);m.textContent=`Copied!`,setTimeout(()=>{m.textContent=h()},1500)}).catch(e=>{console.error(`[notes:wysiwyg-code-copy]`,e)})}),m.addEventListener(`mousedown`,e=>e.stopPropagation()),a.addEventListener(`notes-enter-editing`,e=>{_(!0);let t=e.detail?.caretPosition===`start`?0:u.value.length;u.setSelectionRange(t,t)}),g(),{dom:a,update:e=>e.type===r.type?(r=e,g(),!0):!1,selectNode:()=>{a.dataset.selected=`true`},deselectNode:()=>{a.dataset.selected=`false`,a.dataset.editing===`true`&&_(!1,{commit:!1})},stopEvent:e=>e.target===u||u.contains(e.target)||e.target===f||f.contains(e.target)||e.type===`pointerdown`||e.type===`mousedown`||e.type===`click`,ignoreMutation:e=>e.target===a||e.target===u||u.contains(e.target)||d.contains(e.target)||o.contains(e.target),destroy:()=>{document.removeEventListener(`pointerdown`,v,!0)}}}}var pv=[wd(Ff.node,()=>fv())].flat(),mv=[Ug,Ng.filter(e=>e!==jg),Pg,Fg,Mg,Wg,Hg].flat(),hv=1,gv=6,_v=`notes-heading-source-updated`;function vv(e){let t=Number(e.attrs.level);return Number.isFinite(t)?Math.min(gv,Math.max(hv,Math.trunc(t))):hv}function yv(e){return`#`.repeat(e)}function bv(e){let t=e.trim();return t===``?0:/^#{1,6}$/.test(t)?t.length:null}function xv(e,t){return A.near(e.state.doc.resolve(Math.min(t,e.state.doc.content.size)),1)}function Sv(e,t,n,r){let i=t();if(i===void 0)return;let a=e.state.doc.nodeAt(i);if(!a||a.type.name!==`heading`)return;let o=e.state.schema.nodes.paragraph,s=r===0&&o?e.state.tr.setNodeMarkup(i,o):e.state.tr.setNodeMarkup(i,void 0,{...n.attrs,level:r});r===0?s.setSelection(xv(e,i+1)):s.setSelection(e.state.selection.map(s.doc,s.mapping)),e.dispatch(s.scrollIntoView()),e.dom.dispatchEvent(new CustomEvent(_v,{bubbles:!0}))}function Cv(){return(e,t,n)=>{let r=e,i=document.createElement(`div`),a=document.createElement(`input`),o=document.createElement(`span`);i.className=`notes-heading-source-node`,a.className=`notes-heading-source-marker`,a.type=`text`,a.inputMode=`text`,a.autocomplete=`off`,a.spellcheck=!1,a.setAttribute(`aria-label`,`Edit heading marker`),o.className=`notes-heading-source-content`,i.append(a,o);function s(){let e=vv(r);i.dataset.level=String(e),i.setAttribute(`role`,`heading`),i.setAttribute(`aria-level`,String(e)),i.setAttribute(`aria-label`,r.textContent),document.activeElement!==a&&(a.value=yv(e)),a.size=Math.max(1,a.value.length)}function c(){let e=bv(a.value);if(e===null){a.value=yv(vv(r)),s();return}Sv(t,n,r,e),t.focus()}function l(e){a.contains(e.target)&&(e.preventDefault(),e.stopPropagation(),a.focus(),a.select(),window.setTimeout(()=>{a.focus(),a.select()},0))}function u(){i.dataset.editing=`true`,a.select()}function d(){a.size=Math.max(1,a.value.length);let e=bv(a.value);e===null||e===0||e===vv(r)||Sv(t,n,r,e)}function f(){i.dataset.editing=`false`,c()}function p(e){e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),a.blur()),e.key===`Escape`&&(e.preventDefault(),a.value=yv(vv(r)),i.dataset.editing=`false`,a.blur(),t.focus())}return i.addEventListener(`pointerdown`,l,{capture:!0}),i.addEventListener(`mousedown`,l,{capture:!0}),i.addEventListener(`click`,l,{capture:!0}),a.addEventListener(`focus`,u),a.addEventListener(`input`,d),a.addEventListener(`blur`,f),a.addEventListener(`keydown`,p),s(),{dom:i,contentDOM:o,update(e){return e.type.name===`heading`?(r=e,s(),!0):!1},selectNode(){i.dataset.selected=`true`},deselectNode(){delete i.dataset.selected},stopEvent(e){return a.contains(e.target)||e.type===`pointerdown`||e.type===`mousedown`||e.type===`click`},ignoreMutation(e){return e.target===i||a.contains(e.target)},destroy(){i.removeEventListener(`pointerdown`,l,{capture:!0}),i.removeEventListener(`mousedown`,l,{capture:!0}),i.removeEventListener(`click`,l,{capture:!0}),a.removeEventListener(`focus`,u),a.removeEventListener(`input`,d),a.removeEventListener(`blur`,f),a.removeEventListener(`keydown`,p)}}}}var wv=[wd(wf.node,()=>Cv())].flat(),Tv=`math_inline`,Ev=`math_block`,Dv=`notes-math-source-updated`,Ov=Td({},`notesKatexOptions`),kv=Ad(`notesRemarkMath`,()=>x);function Av(e,n,r){e.textContent=``;try{t.render(n,e,r)}catch{e.textContent=n}}function jv(e,t,n){let r=t();if(r===void 0)return;let i=e.state.doc.nodeAt(r);i&&(e.dispatch(e.state.tr.setNodeMarkup(r,void 0,{...i.attrs,value:n}).scrollIntoView()),Mv(e))}function Mv(e){e.dom.dispatchEvent(new CustomEvent(Dv,{bubbles:!0}))}function Nv(e){return`$${e}$`}function Pv(e){return`$$\n${e}\n$$`}function Fv(e){let t=e.trim();return t.startsWith(`$$`)&&t.endsWith(`$$`)&&t.length>=4?t.slice(2,-2).trim():t.startsWith(`$`)&&t.endsWith(`$`)&&t.length>=2?t.slice(1,-1).trim():e}function Iv(e){let t=e.trim();return t.startsWith(`$$`)&&t.endsWith(`$$`)&&t.length>=4?t.slice(2,-2).trim():e}function Lv(e,t){let n=e.trim();return t?n.startsWith(`$$`)&&n.endsWith(`$$`)&&n.length>=4:n.startsWith(`$`)&&n.endsWith(`$`)&&n.length>=2}function Rv(e){return e.selectionStart===e.value.length&&e.selectionEnd===e.value.length}function zv(e,t){let n=e.selectionStart??0,r=e.selectionEnd??0,i=e.value;if(n!==r)return n===0&&r===i.length;if(n===0||n===i.length)return!0;if(!t)return!1;let a=i.lastIndexOf(`
|
|
45
45
|
`,n-1)+1,o=i.indexOf(`
|
|
46
46
|
`,n),s=o===-1?i.length:o,c=i.slice(a,s);return/^\$\$$/.test(c)}function Bv(e,t,n,r,i){let a=t();if(a===void 0)return;let o=e.state.doc.nodeAt(a);if(!o)return;let s=e.state.tr.setNodeMarkup(a,void 0,{...o.attrs,value:r});if(i===`above`&&n){let t=s.doc.resolve(a),n=t.index()-1;if(n>=0&&t.parent.child(n).isTextblock){s.setSelection(A.create(s.doc,a-1)),e.dispatch(s.scrollIntoView()),Mv(e);return}let r=e.state.schema.nodes.paragraph?.create();if(!r)return;s.insert(a,r),s.setSelection(A.create(s.doc,a+1)),e.dispatch(s.scrollIntoView()),Mv(e);return}let c=s.mapping.map(a+o.nodeSize);if(n){let t=s.doc.resolve(a),n=t.index()+1,r=!1;if(n<t.parent.childCount){let e=t.parent.child(n);e.isTextblock&&e.content.size===0&&(s.setSelection(A.create(s.doc,c+1)),r=!0)}if(!r){let t=e.state.schema.nodes.paragraph?.create();if(!t)return;s.insert(c,t),s.setSelection(A.create(s.doc,c+1))}}else i===`above`?s.setSelection(A.near(s.doc.resolve(a),-1)):s.setSelection(A.near(s.doc.resolve(c),1));e.dispatch(s.scrollIntoView()),Mv(e)}function Vv(e,t){let n=e.selectionStart??0,r=e.value;if(n===0)return`above`;if(n===r.length||!t)return`below`;let i=r.lastIndexOf(`
|
|
47
47
|
`,n-1)+1,a=r.indexOf(`
|
|
@@ -49,7 +49,7 @@ import{r as e}from"./rolldown-runtime-XQCOJYun.js";import{A as t}from"./vendor-r
|
|
|
49
49
|
`)){r.preventDefault(),d(`above`);return}if(r.key===`ArrowDown`&&Lv(s.value,e.block)&&!s.value.slice(s.selectionEnd??s.value.length).includes(`
|
|
50
50
|
`)){r.preventDefault(),d(`below`);return}if(r.key===`ArrowLeft`&&Lv(s.value,e.block)&&(s.selectionStart??0)===0&&(s.selectionEnd??0)===0){r.preventDefault(),d(`above`);return}if(r.key===`ArrowRight`&&Lv(s.value,e.block)&&(s.selectionStart??0)===s.value.length&&(s.selectionEnd??0)===s.value.length){r.preventDefault(),d(`below`);return}!e.block&&r.key===`Enter`&&(r.preventDefault(),u(!1),n.focus()),e.block&&r.key===`Enter`&&(r.metaKey||r.ctrlKey)&&(r.preventDefault(),u(!1),n.focus())}),s.addEventListener(`mousedown`,e=>e.stopPropagation()),s.addEventListener(`click`,e=>e.stopPropagation()),a.addEventListener(`notes-enter-editing`,e=>{u(!0);let t=e.detail?.caretPosition===`start`?0:s.value.length;s.setSelectionRange(t,t)}),f(),{dom:a,update:e=>e.type===i.type?(i=e,f(),!0):!1,selectNode:()=>{a.dataset.selected=`true`},deselectNode:()=>{a.dataset.selected=`false`},stopEvent:e=>e.target===s||s.contains(e.target)||e.type===`pointerdown`||e.type===`mousedown`||e.type===`click`,ignoreMutation:e=>e.target===a||e.target===s||s.contains(e.target)||o.contains(e.target)}}}var Uv=B(Tv,e=>({group:`inline`,inline:!0,atom:!0,attrs:{value:{default:``,validate:`string`}},parseDOM:[{tag:`span[data-type="${Tv}"]`,getAttrs:e=>({value:e instanceof HTMLElement?e.dataset.value??``:``})}],toDOM:t=>{let n=t.attrs.value,r=document.createElement(`span`);return r.dataset.type=Tv,r.dataset.value=n,Av(r,n,e.get(Ov.key)),r},parseMarkdown:{match:e=>e.type===`inlineMath`,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name===Tv,runner:(e,t)=>{e.addNode(`inlineMath`,void 0,t.attrs.value)}}})),Wv=B(Ev,e=>({content:`text*`,group:`block`,marks:``,defining:!0,atom:!0,isolating:!0,attrs:{value:{default:``,validate:`string`}},parseDOM:[{tag:`div[data-type="${Ev}"]`,preserveWhitespace:`full`,getAttrs:e=>({value:e instanceof HTMLElement?e.dataset.value??``:``})}],toDOM:t=>{let n=t.attrs.value,r=document.createElement(`div`);return r.dataset.type=Ev,r.dataset.value=n,Av(r,n,e.get(Ov.key)),r},parseMarkdown:{match:e=>e.type===`math`,runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name===Ev,runner:(e,t)=>{e.addNode(`math`,void 0,t.attrs.value)}}})),Gv=wd(Uv.node,e=>Hv({block:!1,render:(t,n)=>Av(t,n,e.get(Ov.key))})),Kv=wd(Wv.node,e=>Hv({block:!0,render:(t,n)=>Av(t,n,e.get(Ov.key))})),qv=vd(e=>new qi(/(?:\$)([^$]+)(?:\$)$/,(t,n,r,i)=>{let a=n[1]?.trim();return a?t.tr.replaceWith(r,i,Uv.type(e).create({value:a})):null})),Jv=[kv,Ov,Uv,Wv,Gv,Kv,vd(e=>new qi(/^\$\$\s$/,(t,n,r,i)=>{let a=t.doc.resolve(r);return a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),Wv.type(e))?t.tr.delete(r,i).setBlockType(r,r,Wv.type(e)):null})),qv].flat(),Yv=/^([ \t]*[-*+][ \t]+)\\?\[([ xX])\\?\]([ \t]*)/gm,Xv=/^([ \t]*[-*+][ \t]+)\[([ xX])\]([ \t]*)/gm,Zv=/^([ \t]*)\[\^([^\]\n]+)\]:/gm,Qv=/^([ \t]*)\\\[\^([^\]\n]+)\]:/gm,$v=/(^|[^\]\\])\[\^([^\]\n]+)\]/g,ey=/(^|[^\\])\\\[\^([^\]\n]+)\]/g;function ty(e){return e.replace(Xv,`$1\\[$2\\]$3`).replace(Zv,`$1\\[^$2]:`).replace($v,`$1\\[^$2]`)}function ny(e){return e.replace(Yv,`$1[$2]$3`).replace(Qv,`$1[^$2]:`).replace(ey,`$1[^$2]`)}var ry={active:!1,from:0,to:0,query:``,selected:0,suggestions:[]},iy=new N(`NOTES_WYSIWYG_WIKILINK_COMPLETION`);function ay(e){e.dispatch(e.state.tr.setMeta(iy,{refresh:!0}))}function oy(e,t){return t.length===0?0:Math.max(0,Math.min(e,t.length-1))}function sy(e,t,n){if(!e.selection.empty)return ry;let{$from:r}=e.selection,i=r.start(),a=r.end(),o=C(e.doc.textBetween(i,a,`
|
|
51
51
|
`,`
|
|
52
|
-
`),r.pos-i);if(!o)return ry;let s=ae(t.notes,o.query),c=n?.active&&n.query===o.query?oy(n.selected,s):0;return{active:!0,from:i+o.from,to:i+o.to,query:o.query,selected:c,suggestions:s}}function cy(e,t,n){e.dispatch(e.state.tr.insertText(se(n),t.from,t.to).setMeta(iy,{close:!0}).scrollIntoView()),e.focus()}function ly(e,t){let n=document.createElement(`span`);n.className=`notes-wikilink-completion-anchor`;let r=document.createElement(`div`);return r.className=`notes-wikilink-completion`,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-label`,`Wiki link suggestions`),e.suggestions.forEach((n,i)=>{let a=document.createElement(`button`);a.type=`button`,a.className=`notes-wikilink-completion-item`,a.setAttribute(`role`,`option`),a.setAttribute(`aria-selected`,i===e.selected?`true`:`false`),a.addEventListener(`mousedown`,e=>{e.preventDefault()}),a.addEventListener(`click`,r=>{r.preventDefault(),cy(t,e,n)});let o=document.createElement(`span`);o.className=`notes-wikilink-completion-title`,o.textContent=n.title||n.path;let s=document.createElement(`span`);s.className=`notes-wikilink-completion-path`,s.textContent=n.path;let c=document.createElement(`span`);c.className=`notes-wikilink-completion-meta`,c.textContent=n.matchKind,a.append(o,s,c),r.append(a)}),n.append(r),n}function uy(e,t,n){if(t.suggestions.length===0)return;let r=(t.selected+n+t.suggestions.length)%t.suggestions.length;e.dispatch(e.state.tr.setMeta(iy,{move:r-t.selected}))}function dy(e){return[Sd(()=>new M({key:iy,state:{init:(t,n)=>sy(n,e),apply:(t,n,r,i)=>{let a=t.getMeta(iy);if(a?.close)return ry;if(!t.docChanged&&!t.selectionSet&&!a?.refresh&&a?.move==null)return n;let o=sy(i,e,n);return o.active&&a?.move!=null&&o.suggestions.length>0?{...o,selected:(n.selected+a.move+o.suggestions.length)%o.suggestions.length}:o}},props:{decorations(e){let t=this.getState(e);return!t?.active||t.suggestions.length===0?I.empty:I.create(e.doc,[pl.widget(t.to,e=>ly(t,e),{key:`notes-wikilink-completion-${t.from}-${t.to}-${t.query}-${t.selected}`,side:1,stopEvent:e=>e.type===`mousedown`||e.type===`click`})])},handleKeyDown(e,t){let n=iy.getState(e.state);if(!n?.active||n.suggestions.length===0)return!1;if(t.key===`ArrowDown`)return t.preventDefault(),uy(e,n,1),!0;if(t.key===`ArrowUp`)return t.preventDefault(),uy(e,n,-1),!0;if(t.key===`Escape`)return t.preventDefault(),e.dispatch(e.state.tr.setMeta(iy,{close:!0})),!0;if(t.key===`Enter`){t.preventDefault();let r=n.suggestions[n.selected];return r&&cy(e,n,r),!0}return!1}}}))]}var fy=new N(`NOTES_WYSIWYG_WIKILINKS`);function py(e){e.dispatch(e.state.tr.setMeta(fy,{refresh:!0}))}function my(e){return e.marks.some(e=>e.type.name===`inlineCode`||e.type.name===`link`)}function hy(e,t,n,r){return n===r?n>e&&n<t:n<t&&r>e}function gy(e,t,n,r,i){return i?!hy(e,t,n,r):!0}function _y(e,t,n){let r=e.status===`resolved`&&!!e.resolvedPath,i=document.createElement(r?`button`:`span`);return i.className=r?`notes-wikilink notes-wikilink-live`:`notes-wikilink notes-wikilink-live is-broken`,i.textContent=f(e,t),i.dataset.notesWikiRaw=t,i.title=e.resolvedPath??b(e),r&&e.resolvedPath&&(i.dataset.notesWikiPath=e.resolvedPath,i instanceof HTMLButtonElement&&(i.type=`button`),i.addEventListener(`click`,t=>{t.preventDefault(),t.stopPropagation(),n.onNavigate(e.resolvedPath)})),i}function vy(e,t,n){let r=[],{from:i,to:a}=e.selection;return e.doc.descendants((e,o)=>{if(e.type.name===`code_block`)return!1;if(!e.isText||my(e))return!0;let s=e.text??``;S.lastIndex=0;let c;for(;(c=S.exec(s))!==null;){let e=c[0],s=o+c.index,l=
|
|
52
|
+
`),r.pos-i);if(!o)return ry;let s=ae(t.notes,o.query),c=n?.active&&n.query===o.query?oy(n.selected,s):0;return{active:!0,from:i+o.from,to:i+o.to,query:o.query,selected:c,suggestions:s}}function cy(e,t,n){e.dispatch(e.state.tr.insertText(se(n),t.from,t.to).setMeta(iy,{close:!0}).scrollIntoView()),e.focus()}function ly(e,t){let n=document.createElement(`span`);n.className=`notes-wikilink-completion-anchor`;let r=document.createElement(`div`);return r.className=`notes-wikilink-completion`,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-label`,`Wiki link suggestions`),e.suggestions.forEach((n,i)=>{let a=document.createElement(`button`);a.type=`button`,a.className=`notes-wikilink-completion-item`,a.setAttribute(`role`,`option`),a.setAttribute(`aria-selected`,i===e.selected?`true`:`false`),a.addEventListener(`mousedown`,e=>{e.preventDefault()}),a.addEventListener(`click`,r=>{r.preventDefault(),cy(t,e,n)});let o=document.createElement(`span`);o.className=`notes-wikilink-completion-title`,o.textContent=n.title||n.path;let s=document.createElement(`span`);s.className=`notes-wikilink-completion-path`,s.textContent=n.path;let c=document.createElement(`span`);c.className=`notes-wikilink-completion-meta`,c.textContent=n.matchKind,a.append(o,s,c),r.append(a)}),n.append(r),n}function uy(e,t,n){if(t.suggestions.length===0)return;let r=(t.selected+n+t.suggestions.length)%t.suggestions.length;e.dispatch(e.state.tr.setMeta(iy,{move:r-t.selected}))}function dy(e){return[Sd(()=>new M({key:iy,state:{init:(t,n)=>sy(n,e),apply:(t,n,r,i)=>{let a=t.getMeta(iy);if(a?.close)return ry;if(!t.docChanged&&!t.selectionSet&&!a?.refresh&&a?.move==null)return n;let o=sy(i,e,n);return o.active&&a?.move!=null&&o.suggestions.length>0?{...o,selected:(n.selected+a.move+o.suggestions.length)%o.suggestions.length}:o}},props:{decorations(e){let t=this.getState(e);return!t?.active||t.suggestions.length===0?I.empty:I.create(e.doc,[pl.widget(t.to,e=>ly(t,e),{key:`notes-wikilink-completion-${t.from}-${t.to}-${t.query}-${t.selected}`,side:1,stopEvent:e=>e.type===`mousedown`||e.type===`click`})])},handleKeyDown(e,t){let n=iy.getState(e.state);if(!n?.active||n.suggestions.length===0)return!1;if(t.key===`ArrowDown`)return t.preventDefault(),uy(e,n,1),!0;if(t.key===`ArrowUp`)return t.preventDefault(),uy(e,n,-1),!0;if(t.key===`Escape`)return t.preventDefault(),e.dispatch(e.state.tr.setMeta(iy,{close:!0})),!0;if(t.key===`Enter`){t.preventDefault();let r=n.suggestions[n.selected];return r&&cy(e,n,r),!0}return!1}}}))]}var fy=new N(`NOTES_WYSIWYG_WIKILINKS`);function py(e){e.dispatch(e.state.tr.setMeta(fy,{refresh:!0}))}function my(e){return e.marks.some(e=>e.type.name===`inlineCode`||e.type.name===`link`)}function hy(e,t,n,r){return n===r?n>e&&n<t:n<t&&r>e}function gy(e,t,n,r,i){return i?!hy(e,t,n,r):!0}function _y(e,t,n){let r=e.status===`resolved`&&!!e.resolvedPath,i=document.createElement(r?`button`:`span`);return i.className=r?`notes-wikilink notes-wikilink-live`:`notes-wikilink notes-wikilink-live is-broken`,i.textContent=f(e,t),i.dataset.notesWikiRaw=t,i.title=e.resolvedPath??b(e),r&&e.resolvedPath&&(i.dataset.notesWikiPath=e.resolvedPath,i instanceof HTMLButtonElement&&(i.type=`button`),i.addEventListener(`click`,t=>{t.preventDefault(),t.stopPropagation(),n.onNavigate(e.resolvedPath)})),i}function vy(e,t,n){let r=[],{from:i,to:a}=e.selection;return e.doc.descendants((e,o)=>{if(e.type.name===`code_block`)return!1;if(!e.isText||my(e))return!0;let s=e.text??``;S.lastIndex=0;let c;for(;(c=S.exec(s))!==null;){let e=c[0],s=o+c.index,l=g(e,t.outgoing,t.notes,s);if(!l)continue;let u=s+e.length,d=gy(s,u,i,a,n);r.push(pl.inline(s,u,{class:`notes-wikilink-source`,"data-notes-wiki-raw":e,"data-notes-wiki-hidden":d?`true`:`false`},{inclusiveStart:!1,inclusiveEnd:!1})),d&&r.push(pl.widget(s,_y(l,e,t),{key:`notes-wikilink-${s}-${u}-${e}`,side:-1,stopEvent:e=>e.type===`click`||e.type===`mousedown`}))}return!0}),I.create(e.doc,r)}function yy(e){return[Sd(()=>new M({key:fy,state:{init:(t,n)=>({decorations:vy(n,e,!1),focused:!1}),apply:(t,n,r,i)=>{let a=t.getMeta(fy),o=typeof a?.focused==`boolean`?a.focused:n.focused;return!t.docChanged&&!t.selectionSet&&!a?.refresh&&a?.focused==null?{focused:o,decorations:n.decorations.map(t.mapping,t.doc)}:{focused:o,decorations:vy(i,e,o)}}},props:{decorations(e){return this.getState(e)?.decorations??I.empty},handleDOMEvents:{focus(e){return e.dispatch(e.state.tr.setMeta(fy,{focused:!0,refresh:!0})),!1},blur(e){return e.dispatch(e.state.tr.setMeta(fy,{focused:!1,refresh:!0})),!1}}}}))]}var by=Symbol.for(`yaml.alias`),xy=Symbol.for(`yaml.document`),Sy=Symbol.for(`yaml.map`),Cy=Symbol.for(`yaml.pair`),wy=Symbol.for(`yaml.scalar`),Ty=Symbol.for(`yaml.seq`),Ey=Symbol.for(`yaml.node.type`),Dy=e=>!!e&&typeof e==`object`&&e[Ey]===by,Oy=e=>!!e&&typeof e==`object`&&e[Ey]===xy,ky=e=>!!e&&typeof e==`object`&&e[Ey]===Sy,J=e=>!!e&&typeof e==`object`&&e[Ey]===Cy,Y=e=>!!e&&typeof e==`object`&&e[Ey]===wy,Ay=e=>!!e&&typeof e==`object`&&e[Ey]===Ty;function X(e){if(e&&typeof e==`object`)switch(e[Ey]){case Sy:case Ty:return!0}return!1}function Z(e){if(e&&typeof e==`object`)switch(e[Ey]){case by:case Sy:case wy:case Ty:return!0}return!1}var jy=e=>(Y(e)||X(e))&&!!e.anchor,My=Symbol(`break visit`),Ny=Symbol(`skip children`),Py=Symbol(`remove node`);function Fy(e,t){let n=zy(t);Oy(e)?Iy(null,e.contents,n,Object.freeze([e]))===Py&&(e.contents=null):Iy(null,e,n,Object.freeze([]))}Fy.BREAK=My,Fy.SKIP=Ny,Fy.REMOVE=Py;function Iy(e,t,n,r){let i=By(e,t,n,r);if(Z(i)||J(i))return Vy(e,r,i),Iy(e,i,n,r);if(typeof i!=`symbol`){if(X(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=Iy(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===My)return My;else i===Py&&(t.items.splice(e,1),--e)}}else if(J(t)){r=Object.freeze(r.concat(t));let e=Iy(`key`,t.key,n,r);if(e===My)return My;e===Py&&(t.key=null);let i=Iy(`value`,t.value,n,r);if(i===My)return My;i===Py&&(t.value=null)}}return i}async function Ly(e,t){let n=zy(t);Oy(e)?await Ry(null,e.contents,n,Object.freeze([e]))===Py&&(e.contents=null):await Ry(null,e,n,Object.freeze([]))}Ly.BREAK=My,Ly.SKIP=Ny,Ly.REMOVE=Py;async function Ry(e,t,n,r){let i=await By(e,t,n,r);if(Z(i)||J(i))return Vy(e,r,i),Ry(e,i,n,r);if(typeof i!=`symbol`){if(X(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await Ry(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===My)return My;else i===Py&&(t.items.splice(e,1),--e)}}else if(J(t)){r=Object.freeze(r.concat(t));let e=await Ry(`key`,t.key,n,r);if(e===My)return My;e===Py&&(t.key=null);let i=await Ry(`value`,t.value,n,r);if(i===My)return My;i===Py&&(t.value=null)}}return i}function zy(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function By(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(ky(t))return n.Map?.(e,t,r);if(Ay(t))return n.Seq?.(e,t,r);if(J(t))return n.Pair?.(e,t,r);if(Y(t))return n.Scalar?.(e,t,r);if(Dy(t))return n.Alias?.(e,t,r)}function Vy(e,t,n){let r=t[t.length-1];if(X(r))r.items[e]=n;else if(J(r))e===`key`?r.key=n:r.value=n;else if(Oy(r))r.contents=n;else{let e=Dy(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var Hy={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},Uy=e=>e.replace(/[!,[\]{}]/g,e=>Hy[e]),Wy=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+Uy(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&Z(e.contents)){let t={};Fy(e.contents,(e,n)=>{Z(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)i===`!!`&&a===`tag:yaml.org,2002:`||(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
|
|
53
53
|
`)}};Wy.defaultYaml={explicit:!1,version:`1.2`},Wy.defaultTags={"!!":`tag:yaml.org,2002:`};function Gy(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function Ky(e){let t=new Set;return Fy(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function qy(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function Jy(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=Ky(e);let a=qy(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(Y(t.node)||X(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function Yy(e,t,n,r){if(r&&typeof r==`object`)if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=Yy(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=Yy(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=Yy(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=Yy(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}return e.call(t,n,r)}function Xy(e,t,n){if(Array.isArray(e))return e.map((e,t)=>Xy(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!jy(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var Zy=class{constructor(e){Object.defineProperty(this,Ey,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Oy(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=Xy(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?Yy(i,{"":o},``,o):o}},Qy=class extends Zy{constructor(e){super(by),this.source=e,Object.defineProperty(this,`tag`,{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],Fy(e,{Node:(e,t)=>{(Dy(t)||jy(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}return r}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r,t);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(Xy(a,null,t),n.get(a)),o?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=$y(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(Gy(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function $y(e,t,n){if(Dy(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(X(t)){let r=0;for(let i of t.items){let t=$y(e,i,n);t>r&&(r=t)}return r}else if(J(t)){let r=$y(e,t.key,n),i=$y(e,t.value,n);return Math.max(r,i)}return 1}var eb=e=>!e||typeof e!=`function`&&typeof e!=`object`,Q=class extends Zy{constructor(e){super(wy),this.value=e}toJSON(e,t){return t?.keep?this.value:Xy(this.value,e,t)}toString(){return String(this.value)}};Q.BLOCK_FOLDED=`BLOCK_FOLDED`,Q.BLOCK_LITERAL=`BLOCK_LITERAL`,Q.PLAIN=`PLAIN`,Q.QUOTE_DOUBLE=`QUOTE_DOUBLE`,Q.QUOTE_SINGLE=`QUOTE_SINGLE`;var tb=`tag:yaml.org,2002:`;function nb(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function rb(e,t,n){if(Oy(e)&&(e=e.contents),Z(e))return e;if(J(e)){let t=n.schema[Sy].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??=i(e),new Qy(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=tb+t.slice(2));let l=nb(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new Q(e);return c&&(c.node=t),t}l=e instanceof Map?o[Sy]:Symbol.iterator in Object(e)?o[Ty]:o[Sy]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new Q(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function ib(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return rb(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var ab=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,ob=class extends Zy{constructor(e,t){super(e),Object.defineProperty(this,`schema`,{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>Z(t)||J(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(ab(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(X(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,ib(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(X(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&Y(i)?i.value:i:X(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!J(t))return!1;let n=t.value;return n==null||e&&Y(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return X(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(X(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,ib(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},sb=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function cb(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var lb=(e,t,n)=>e.endsWith(`
|
|
54
54
|
`)?cb(n,t):n.includes(`
|
|
55
55
|
`)?`
|