reactjs-tiptap-editor 1.0.10 → 1.0.12
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/lib/{ActionMenuButton-CKTxYtl7.js → ActionMenuButton-BKqin6Kz.js} +17 -13
- package/lib/ActionMenuButton-CPPHERbq.cjs +1 -0
- package/lib/Attachment.cjs +2 -2
- package/lib/Attachment.js +24 -21
- package/lib/Blockquote.cjs +2 -2
- package/lib/Blockquote.js +7 -5
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +11 -9
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +14 -12
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +3 -3
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +11 -9
- package/lib/CodeBlock.cjs +22 -22
- package/lib/CodeBlock.js +102 -100
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +10 -8
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +20 -18
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +7 -5
- package/lib/{Drawer-Cfx115up.js → Drawer-DUPsBE0H.js} +10 -9
- package/lib/Drawer-fplzqNI6.cjs +1 -0
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +3 -3
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +11 -9
- package/lib/{Excalidraw-CO93Tsmb.js → Excalidraw-BEzpvRLx.js} +20 -19
- package/lib/Excalidraw-qjnQspLq.cjs +1 -0
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +2 -2
- package/lib/ExportPdf.cjs +2 -2
- package/lib/ExportPdf.js +7 -5
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +7 -5
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +9 -8
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +13 -12
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +25 -24
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +9 -7
- package/lib/History.cjs +1 -1
- package/lib/History.js +18 -15
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +7 -5
- package/lib/Icon-CiR8RqdQ.cjs +1 -0
- package/lib/Icon-ONE1AwKo.js +12 -0
- package/lib/{Iframe-DwhclppJ.js → Iframe-CBTnv2mk.js} +41 -39
- package/lib/Iframe-DsUNJ2n2.cjs +1 -0
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +2 -2
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +25 -23
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +53 -51
- package/lib/ImportWord.cjs +31 -31
- package/lib/ImportWord.js +8 -6
- package/lib/{Indent-BOsymiZ7.js → Indent-B00o0P0M.js} +26 -24
- package/lib/Indent-CaGP0qTp.cjs +1 -0
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +12 -10
- package/lib/Katex-XsfpKgJU.cjs +4 -0
- package/lib/{Katex-BYK-b9X2.js → Katex-x370CSXZ.js} +12 -10
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +2 -2
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +10 -8
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-DgrLUMsJ.js → LinkEditBlock-C_ipl3EA.js} +23 -21
- package/lib/{LinkEditBlock-4-iRXH7m.cjs → LinkEditBlock-xt88G5fb.cjs} +2 -2
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +3 -3
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.js +18 -17
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +25 -22
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +10 -8
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +43 -41
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +6 -6
- package/lib/SlashCommandNodeView-BT5ystah.cjs +1 -0
- package/lib/{SlashCommandNodeView-BpNNU7Sm.js → SlashCommandNodeView-DX6axvLs.js} +75 -66
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +7 -5
- package/lib/Table-DSRSwtXx.cjs +9 -0
- package/lib/{Table-CT9R9Sdq.js → Table-DidusYID.js} +10 -8
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +15 -13
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +20 -17
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +20 -17
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +7 -5
- package/lib/Twitter-CBuVBQM1.cjs +1 -0
- package/lib/{Twitter-mowilxRd.js → Twitter-D58T0Zt3.js} +51 -49
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +13 -11
- package/lib/bubble.cjs +4 -4
- package/lib/bubble.js +403 -407
- package/lib/{button-CBO-WDXK.js → button-9_8t7ca7.js} +4 -3
- package/lib/button-Cs9TroWr.cjs +1 -0
- package/lib/{checkbox-DUcLSGZD.cjs → checkbox-BQRKTXXr.cjs} +1 -1
- package/lib/{checkbox-D1h32VWM.js → checkbox-DnkkV6qo.js} +1 -1
- package/lib/{index-BBNITgNi.cjs → clsx-CXbNJWDD.cjs} +13 -13
- package/lib/{index-sVScpCFG.js → clsx-DmuN0U_8.js} +228 -228
- package/lib/{dialog-DY868Uji.cjs → dialog-BS3zm-T9.cjs} +1 -1
- package/lib/{dialog-DSvgtlDI.js → dialog-DhayAPvV.js} +1 -1
- package/lib/{dropdown-menu-BripAeGB.cjs → dropdown-menu-CxwWX0yj.cjs} +1 -1
- package/lib/{dropdown-menu-B88Qn2KR.js → dropdown-menu-DQqKeZcx.js} +1 -1
- package/lib/events.constant-Dq21NPdV.cjs +1 -0
- package/lib/events.constant-do95b767.js +21 -0
- package/lib/{index-CApXPpjF.cjs → index-BCzvbrf5.cjs} +1 -1
- package/lib/{index-0OnGZkVF.js → index-BDX1uE62.js} +78 -312
- package/lib/index-CBFmXCcU.cjs +1 -0
- package/lib/{index-DmPwbBqm.js → index-CKmT9KAQ.js} +1 -1
- package/lib/index-CVFzP1Dc.cjs +1 -0
- package/lib/index-CX4pNJlH.cjs +1 -0
- package/lib/index-CjhjjJsN.cjs +1 -0
- package/lib/index-Cs6cp0Y6.cjs +1 -0
- package/lib/{index-9A6-kVBM.js → index-D1jd7elj.js} +1 -1
- package/lib/{index-BIqaogQg.js → index-D9JOHlso.js} +449 -1216
- package/lib/{index-DRHrDScg.js → index-DdEmgiAA.js} +1 -1
- package/lib/{index-DKt5wfAc.js → index-DvvwJvau.js} +23 -23
- package/lib/index-EAK64CCA.js +425 -0
- package/lib/{index--nUS7Y66.cjs → index-neeeY2o7.cjs} +3 -3
- package/lib/index.cjs +9 -2
- package/lib/index.js +142 -26
- package/lib/{input-BeD5GdMv.cjs → input-BJ7ihMq-.cjs} +1 -1
- package/lib/{input-Bx4uo4gO.js → input-YoheBL2D.js} +1 -1
- package/lib/{isNumber-Bv1Qhmw8.cjs → isNumber-BTYSVlKo.cjs} +1 -1
- package/lib/{isNumber-DF0fU3ob.js → isNumber-DmQXlKp3.js} +1 -1
- package/lib/label-C8PLcjFI.js +19 -0
- package/lib/label-Y7_hvqf2.cjs +1 -0
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.js +6 -7
- package/lib/locales/index.d.ts +3 -4316
- package/lib/{popover-Csk538NC.cjs → popover-BiSrlM4j.cjs} +1 -1
- package/lib/{popover-BVX8otO9.js → popover-CWmTzHSy.js} +1 -1
- package/lib/react-BEoMZB61.cjs +1 -0
- package/lib/react-c9FSfB30.js +27 -0
- package/lib/separator-C-DKMYmg.js +329 -0
- package/lib/separator-CJ_adziN.cjs +1 -0
- package/lib/store/EditorEditableReactive.d.ts +1 -0
- package/lib/store/ThemeColorReactive.d.ts +1 -0
- package/lib/store/commandList.d.ts +1 -1
- package/lib/store/store.d.ts +6 -7
- package/lib/store-BKMaw1AW.cjs +1 -0
- package/lib/store-DG7cMfET.js +10 -0
- package/lib/style.css +1 -1
- package/lib/{tabs-DOasUMDU.cjs → tabs-DpHSMyF_.cjs} +1 -1
- package/lib/{tabs-BKpr0QQB.js → tabs-DxlKKM-N.js} +1 -1
- package/lib/{textarea-Ba9OOzba.js → textarea-D7m-apUh.js} +1 -1
- package/lib/{textarea-D9egO4qC.cjs → textarea-DU9RMi6u.cjs} +1 -1
- package/lib/theme/theme.d.ts +5 -0
- package/lib/theme.cjs +1 -1
- package/lib/theme.js +37 -8
- package/lib/{throttle-DsowOft0.js → throttle-BRtichEP.js} +1 -1
- package/lib/throttle-gTTvqDTW.cjs +1 -0
- package/lib/toggle-BYvLnjCL.cjs +1 -0
- package/lib/toggle-Bxwwb_Kp.js +99 -0
- package/lib/tooltip-BTy5CRrN.js +24 -0
- package/lib/tooltip-COvf4_R-.cjs +1 -0
- package/lib/{updatePosition-Bbd8ETMv.js → updatePosition-CUukgu-Q.js} +2 -2
- package/lib/updatePosition-Cjuj2E26.cjs +1 -0
- package/lib/{useButtonProps-C_bqxmHi.js → useButtonProps-CfYtuEnd.js} +48 -36
- package/lib/useButtonProps-CydzndG1.cjs +1 -0
- package/lib/utils/customEvents/events.constant.d.ts +0 -5
- package/package.json +3 -3
- package/lib/ActionMenuButton-BPdRqzDX.cjs +0 -1
- package/lib/Drawer-hHj4Opkg.cjs +0 -1
- package/lib/Excalidraw-8pWJ17Ye.cjs +0 -1
- package/lib/Icon-D7GJZzoa.js +0 -10
- package/lib/Icon-gtc3g-VK.cjs +0 -1
- package/lib/Iframe-BmXO2c65.cjs +0 -1
- package/lib/Indent-DPkMWfcv.cjs +0 -1
- package/lib/Katex-B1XbT8-X.cjs +0 -4
- package/lib/SlashCommandNodeView-CQvMTXys.cjs +0 -1
- package/lib/Table-LnWGm2m8.cjs +0 -9
- package/lib/Twitter-Bo4JkBTL.cjs +0 -1
- package/lib/button-wt49IYwP.cjs +0 -1
- package/lib/events.constant-DQYeJpu5.cjs +0 -1
- package/lib/events.constant-wrlJ_7JZ.js +0 -26
- package/lib/index-BZ6DfR2r.cjs +0 -1
- package/lib/index-BvIJKpX1.cjs +0 -8
- package/lib/index-Cv9Z6dyV.cjs +0 -1
- package/lib/index-FSRjMsxW.cjs +0 -1
- package/lib/label--161UPH6.cjs +0 -1
- package/lib/label-uKG7RzFU.js +0 -18
- package/lib/separator-DLRVddHS.cjs +0 -1
- package/lib/separator-DtrEdjAF.js +0 -241
- package/lib/store/ProviderUniqueId.d.ts +0 -6
- package/lib/store-B8IkVz1J.cjs +0 -1
- package/lib/store-CsIFDUKR.js +0 -10
- package/lib/throttle-BM3Bmbf_.cjs +0 -1
- package/lib/updatePosition-M2IyqkI1.cjs +0 -1
- package/lib/useButtonProps-DEtmDVPr.cjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const T=require("react"),an=require("react-dom"),J=require("react/jsx-runtime"),M=require("@tiptap/pm/state"),_=require("@tiptap/pm/model");require("@tiptap/pm/view");
|
|
1
|
+
"use strict";const T=require("react"),an=require("react-dom"),J=require("react/jsx-runtime"),M=require("@tiptap/pm/state"),_=require("@tiptap/pm/model");require("@tiptap/pm/view");var xe={exports:{}},Fe={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* use-sync-external-store-shim.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var At;function
|
|
9
|
+
*/var At;function Sr(){if(At)return Fe;At=1;var n=T;function e(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var t=typeof Object.is=="function"?Object.is:e,r=n.useState,i=n.useEffect,s=n.useLayoutEffect,o=n.useDebugValue;function l(f,h){var d=h(),m=r({inst:{value:d,getSnapshot:h}}),p=m[0].inst,g=m[1];return s(function(){p.value=d,p.getSnapshot=h,a(p)&&g({inst:p})},[f,d,h]),i(function(){return a(p)&&g({inst:p}),f(function(){a(p)&&g({inst:p})})},[f]),o(d),d}function a(f){var h=f.getSnapshot;f=f.value;try{var d=h();return!t(f,d)}catch{return!0}}function c(f,h){return h()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:l;return Fe.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:u,Fe}var qe={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* use-sync-external-store-shim.development.js
|
|
12
12
|
*
|
|
@@ -14,28 +14,28 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Nt;function kr(){return Nt||(Nt=1,process.env.NODE_ENV!=="production"&&(function(){function n(d,m){return d===m&&(d!==0||1/d===1/m)||d!==d&&m!==m}function e(d,m){u||i.startTransition===void 0||(u=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var p=m();if(!f){var g=m();s(p,g)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),f=!0)}g=o({inst:{value:p,getSnapshot:m}});var y=g[0].inst,S=g[1];return a(function(){y.value=p,y.getSnapshot=m,t(y)&&S({inst:y})},[d,p,m]),l(function(){return t(y)&&S({inst:y}),d(function(){t(y)&&S({inst:y})})},[d]),c(p),p}function t(d){var m=d.getSnapshot;d=d.value;try{var p=m();return!s(d,p)}catch{return!0}}function r(d,m){return m()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var i=T,s=typeof Object.is=="function"?Object.is:n,o=i.useState,l=i.useEffect,a=i.useLayoutEffect,c=i.useDebugValue,u=!1,f=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:e;qe.useSyncExternalStore=i.useSyncExternalStore!==void 0?i.useSyncExternalStore:h,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),qe}var Ot;function lt(){return Ot||(Ot=1,process.env.NODE_ENV==="production"?xe.exports=xr():xe.exports=kr()),xe.exports}var un=lt();function fn(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=fn(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function dn(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=dn(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class v{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new v(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new v(r,i)}cutByIndex(e,t){return e==t?v.empty:e==0&&t==this.content.length?this:new v(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new v(i,s)}addToStart(e){return new v([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new v(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return fn(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return dn(this,e,t,r)}findIndex(e){if(e==0)return ke(0,e);if(e==this.size)return ke(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?ke(t+1,s):ke(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return v.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new v(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return v.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new v(t||e,r)}static from(e){if(!e)return v.empty;if(e instanceof v)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new v([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}v.empty=new v([],0);const je={index:0,offset:0};function ke(n,e){return je.index=n,je.offset=e,je}function Qe(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Qe(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Qe(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let L=class et{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Qe(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return et.none;if(e instanceof et)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};L.none=[];class br extends Error{}class w{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=pn(this.content,e+this.openStart,t);return r&&new w(r,this.openStart,this.openEnd)}removeBetween(e,t){return new w(hn(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return w.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new w(v.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new w(e,r,i)}}w.empty=new w(v.empty,0,0);function hn(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(hn(s.content,e-i-1,t-i-1)))}function pn(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),o=n.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=pn(o.content,e-s-1,t,o);return l&&n.replaceChild(i,o.copy(l))}class tt{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}function Er(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Mr(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function Cr(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let s=n[i];s.validate&&s.validate(e[i])}}function Rr(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Ar(n,r,e[r]);return t}function Tr(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class Ar{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Tr(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class at{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Rr(e,i.attrs),this.excluded=null;let s=Er(this.attrs);this.instance=s?new L(this,s):null}create(e=null){return!e&&this.instance?this.instance:new L(this,Mr(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new at(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Cr(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}function Nr(n){return n.tag!=null}function Or(n){return n.style!=null}class Ie{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(Nr(i))this.tags.push(i);else if(Or(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new zt(this,t,!1);return r.addAll(e,L.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new zt(this,t,!0);return r.addAll(e,L.none,t.from,t.to),w.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(Pr(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Pt(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Pt(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ie(e,Ie.schemaRules(e)))}}const mn={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Ir={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},gn={ol:!0,ul:!0},pe=1,nt=2,he=4;function It(n,e,t){return e!=null?(e?pe:0)|(e==="full"?nt:0):n&&n.whitespace=="pre"?pe|nt:t&~he}class be{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=L.none,this.match=s||(o&he?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(v.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&pe)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=v.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(v.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!mn.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class zt{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=It(null,t.preserveWhitespace,0)|(r?he:0);i?s=new be(i.type,i.attrs,L.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new be(null,null,L.none,!0,null,o):s=new be(e.schema.topNodeType,null,L.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&nt?"full":this.localPreserveWS||(i.options&pe)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
|
|
18
|
-
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;
|
|
19
|
-
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=L.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):$t(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=It(e,s,o.options);o.options&he&&o.content.length==0&&(l|=he);let a=L.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):$t(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new be(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=pe)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function zr(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&gn.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Pr(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Pt(n){let e={};for(let t in n)e[t]=n[t];return e}function $t(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&o(u))return!0}};if(o(i.contentMatch))return!0}}class ct{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=We(t).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,t);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=Ae(We(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Ae(We(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return Ae(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ct(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Dt(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Dt(e.marks)}}function Dt(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function We(n){return n.document||window.document}const Bt=new WeakMap;function $r(n){let e=Bt.get(n);return e===void 0&&Bt.set(n,e=Dr(n)),e}function Dr(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function Ae(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=$r(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let h=f.indexOf(" ");h>0?a.setAttributeNS(f.slice(0,h),f.slice(h+1),c[f]):f=="style"&&a.style?a.style.cssText=c[f]:a.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let h=e[f];if(h===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:d,contentDOM:m}=Ae(n,h,t,r);if(a.appendChild(d),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:a,contentDOM:l}}const yn=65535,vn=Math.pow(2,16);function Br(n,e){return n+e*vn}function _t(n){return n&yn}function _r(n){return(n-(n&yn))/vn}const wn=1,Sn=2,Ne=4,xn=8;class rt{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&xn)>0}get deletedBefore(){return(this.delInfo&(wn|Ne))>0}get deletedAfter(){return(this.delInfo&(Sn|Ne))>0}get deletedAcross(){return(this.delInfo&Ne)>0}}class B{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&B.empty)return B.empty}recover(e){let t=0,r=_t(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+_r(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+o],f=a+c;if(e<=f){let h=c?e==a?-1:e==f?1:t:t,d=a+i+(h<0?0:u);if(r)return d;let m=e==(t<0?a:f)?null:Br(l/3,e-a),p=e==a?Sn:e==f?wn:Ne;return(t<0?e!=a:e!=f)&&(p|=xn),new rt(d,p,m)}i+=u-c}return r?e+i:new rt(e+i,0,null)}touches(e,t){let r=0,i=_t(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],u=this.ranges[i+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new B(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?B.empty:new B(e<0?[0,-e,0]:[0,0,e])}}B.empty=new B([]);class me{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new me(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new me;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new rt(e,i,null)}}const Ve=Object.create(null);class ${getMap(){return B.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ve[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Ve)throw new RangeError("Duplicate use of step JSON ID "+e);return Ve[e]=t,t.prototype.jsonID=e,t}}class N{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new N(e,null)}static fail(e){return new N(null,e)}static fromReplace(e,t,r,i){try{return N.ok(e.replace(t,r,i))}catch(s){if(s instanceof br)return N.fail(s.message);throw s}}}function ut(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(ut(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return v.fromArray(r)}class X extends ${constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new w(ut(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return N.fromReplace(e,this.from,this.to,s)}invert(){return new q(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new X(t.pos,r.pos,this.mark)}merge(e){return e instanceof X&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new X(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new X(t.from,t.to,e.markFromJSON(t.mark))}}$.jsonID("addMark",X);class q extends ${constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new w(ut(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return N.fromReplace(e,this.from,this.to,r)}invert(){return new X(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new q(t.pos,r.pos,this.mark)}merge(e){return e instanceof q&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new q(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new q(t.from,t.to,e.markFromJSON(t.mark))}}$.jsonID("removeMark",q);class Y extends ${constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return N.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return N.fromReplace(e,this.pos,this.pos+1,new w(v.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new Y(this.pos,t.marks[i]);return new Y(this.pos,this.mark)}}return new te(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Y(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Y(t.pos,e.markFromJSON(t.mark))}}$.jsonID("addNodeMark",Y);class te extends ${constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return N.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return N.fromReplace(e,this.pos,this.pos+1,new w(v.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Y(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new te(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new te(t.pos,e.markFromJSON(t.mark))}}$.jsonID("removeNodeMark",te);class I extends ${constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&it(e,this.from,this.to)?N.fail("Structure replace would overwrite content"):N.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new B([this.from,this.to-this.from,this.slice.size])}invert(e){return new I(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new I(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof I)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?w.empty:new w(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new I(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?w.empty:new w(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new I(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new I(t.from,t.to,w.fromJSON(e,t.slice),!!t.structure)}}$.jsonID("replace",I);class z extends ${constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(it(e,this.from,this.gapFrom)||it(e,this.gapTo,this.to)))return N.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return N.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?N.fromReplace(e,this.from,this.to,r):N.fail("Content does not fit in gap")}getMap(){return new B([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new z(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new z(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new z(t.from,t.to,t.gapFrom,t.gapTo,w.fromJSON(e,t.slice),t.insert,!!t.structure)}}$.jsonID("replaceAround",z);function it(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Lr(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let h=Math.max(c,e),d=Math.min(c+a.nodeSize,t),m=r.addToSet(f);for(let p=0;p<f.length;p++)f[p].isInSet(m)||(o&&o.to==h&&o.mark.eq(f[p])?o.to=d:i.push(o=new q(h,d,f[p])));l&&l.to==h?l.to=d:s.push(l=new X(h,d,r))}}),i.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function Fr(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof at){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let u=0;u<a.length;u++){let f=a[u],h;for(let d=0;d<i.length;d++){let m=i[d];m.step==s-1&&f.eq(i[d].style)&&(h=m)}h?(h.to=c,h.step=s):i.push({style:f,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>n.step(new q(o.from,o.to,o.style)))}function ft(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)o.push(new I(l,u,w.empty));else{r=f;for(let h=0;h<c.marks.length;h++)t.allowsMarkType(c.marks[h].type)||n.step(new q(l,u,c.marks[h]));if(i&&c.isText&&t.whitespace!="pre"){let h,d=/\r?\n|\r/g,m;for(;h=d.exec(c.text);)m||(m=new w(v.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new I(l+h.index,l+h.index+h[0].length,m))}}l=u}if(!r.validEnd){let a=r.fillBefore(v.empty,!0);n.replace(l,l,new w(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function qr(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ce(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-s;if(r<n.depth&&o.canReplace(l,a,t))return r;if(r==0||o.type.spec.isolating||!qr(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function jr(n,e,t){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,c=l,u=v.empty,f=0;for(let m=s,p=!1;m>t;m--)p||r.index(m)>0?(p=!0,u=v.from(r.node(m).copy(u)),f++):a--;let h=v.empty,d=0;for(let m=s,p=!1;m>t;m--)p||i.after(m+1)<i.end(m)?(p=!0,h=v.from(i.node(m).copy(h)),d++):c++;n.step(new z(a,c,o,l,new w(u.append(h),f,d),u.size-f,!0))}function dt(n,e,t=null,r=n){let i=Wr(n,e),s=i&&Vr(r,e);return s?i.map(Lt).concat({type:e,attrs:t}).concat(s.map(Lt)):null}function Lt(n){return{type:n,attrs:null}}function Wr(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function Vr(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function Jr(n,e,t){let r=v.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=v.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new z(i,s,i,s,new w(r,0,0),t.length,!0))}function Hr(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&Ur(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let d=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);d&&!m?c=!1:!d&&m&&(c=!0)}c===!1&&bn(n,o,l,s),ft(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),f=u.map(l,1),h=u.map(l+o.nodeSize,1);return n.step(new z(f,h,f+1,h-1,new w(v.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&kn(n,o,l,s),!1}})}function kn(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function bn(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
|
|
20
|
-
`))}})}function Ur(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function Kr(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new z(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new w(v.from(o),0,0),1,!0))}function U(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>s;c--,u--){let f=i.node(c),h=i.index(c);if(f.type.spec.isolating)return!1;let d=f.content.cutByIndex(h,f.childCount),m=r&&r[u+1];m&&(d=d.replaceChild(0,m.type.create(m.attrs)));let p=r&&r[u]||f;if(!f.canReplace(h+1,f.childCount)||!p.type.validContent(d))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function Gr(n,e,t=1,r){let i=n.doc.resolve(e),s=v.empty,o=v.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=v.from(i.node(l).copy(s));let u=r&&r[c];o=v.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}n.step(new I(e,e,new w(s.append(o),t,t),!0))}function Z(n,e){let t=n.resolve(e),r=t.index();return En(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Xr(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function En(n,e){return!!(n&&e&&!n.isLeaf&&Xr(n,e))}function Pe(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):t>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&En(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function Yr(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",f=!!o.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);bn(n,u.node(),u.before(),l)}o.inlineContent&&ft(n,e+t-1,o,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new I(c,a.map(e+t,-1),w.empty,!0)),r===!0){let u=n.doc.resolve(c);kn(n,u.node(),u.before(),n.steps.length)}return n}function Zr(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function Qr(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(a,a,i);else{let f=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function $e(n,e,t=e,r=w.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return Mn(i,s,r)?new I(e,t,r):new ei(i,s,r).fit()}function Mn(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class ei{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=v.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=v.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new w(s,o,l);return e>-1?new z(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new I(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Je(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(t==1&&(o?c.matchType(o.type)||(f=c.fillBefore(v.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:f};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Je(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new w(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Je(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new w(fe(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new w(fe(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let p=0;p<s.length;p++)this.openFrontierNode(s[p]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:f,type:h}=this.frontier[t];if(i){for(let p=0;p<i.childCount;p++)u.push(i.child(p));f=f.matchFragment(i)}let d=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let p=l.child(c),g=f.matchType(p.type);if(!g)break;c++,(c>1||a==0||p.content.size)&&(f=g,u.push(Cn(p.mark(h.allowedMarks(p.marks)),c==1?a:0,c==l.childCount?d:-1)))}let m=c==l.childCount;m||(d=-1),this.placed=de(this.placed,t,v.from(u)),this.frontier[t].match=f,m&&d<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let p=0,g=l;p<d;p++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=m?e==0?w.empty:new w(fe(o.content,e-1,1),e-1,d<0?o.openEnd:e-1):new w(fe(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!He(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=He(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=He(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=de(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=de(this.placed,this.depth,v.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(v.empty,!0);t.childCount&&(this.placed=de(this.placed,this.frontier.length,t))}}function fe(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(fe(n.firstChild.content,e-1,t)))}function de(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(de(n.lastChild.content,e-1,t)))}function Je(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Cn(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Cn(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(v.empty,!0)))),n.copy(r)}function He(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!ti(t,s.content,o)?l:null}function ti(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function ni(n){return n.spec.defining||n.spec.definingForContent}function ri(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(Mn(i,s,r))return n.step(new I(e,t,r));let o=Tn(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let h=i.depth,d=i.pos-1;h>0;h--,d--){let m=i.node(h).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;o.indexOf(h)>-1?l=h:i.before(h)==d&&o.splice(1,0,-h)}let a=o.indexOf(l),c=[],u=r.openStart;for(let h=r.content,d=0;;d++){let m=h.firstChild;if(c.push(m),d==r.openStart)break;h=m.content}for(let h=u-1;h>=0;h--){let d=c[h],m=ni(d.type);if(m&&!d.sameMarkup(i.node(Math.abs(l)-1)))u=h;else if(m||!d.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let d=(h+u+1)%(r.openStart+1),m=c[d];if(m)for(let p=0;p<o.length;p++){let g=o[(p+a)%o.length],y=!0;g<0&&(y=!1,g=-g);let S=i.node(g-1),k=i.index(g-1);if(S.canReplaceWith(k,k,m.type,m.marks))return n.replace(i.before(g),y?s.after(g):t,new w(Rn(r.content,0,r.openStart,d),d,r.openEnd))}}let f=n.steps.length;for(let h=o.length-1;h>=0&&(n.replace(e,t,r),!(n.steps.length>f));h--){let d=o[h];d<0||(e=i.before(d),t=s.after(d))}}function Rn(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Rn(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(v.empty,!0))}return n}function ii(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Zr(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new w(v.from(r),0,0))}function si(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=Tn(r,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function Tn(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class ie extends ${constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return N.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return N.fromReplace(e,this.pos,this.pos+1,new w(v.from(i),0,t.isLeaf?0:1))}getMap(){return B.empty}invert(e){return new ie(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ie(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ie(t.pos,t.attr,t.value)}}$.jsonID("attr",ie);class ge extends ${constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return N.ok(r)}getMap(){return B.empty}invert(e){return new ge(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ge(t.attr,t.value)}}$.jsonID("docAttr",ge);let se=class extends Error{};se=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};se.prototype=Object.create(Error.prototype);se.prototype.constructor=se;se.prototype.name="TransformError";class An{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new me}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new se(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=w.empty){let i=$e(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new w(v.from(r),0,0))}delete(e,t){return this.replace(e,t,w.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return ri(this,e,t,r),this}replaceRangeWith(e,t,r){return ii(this,e,t,r),this}deleteRange(e,t){return si(this,e,t),this}lift(e,t){return jr(this,e,t),this}join(e,t=1){return Yr(this,e,t),this}wrap(e,t){return Jr(this,e,t),this}setBlockType(e,t=e,r,i=null){return Hr(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return Kr(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new ie(e,t,r)),this}setDocAttribute(e,t){return this.step(new ge(e,t)),this}addNodeMark(e,t){return this.step(new Y(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof L)t.isInSet(r.marks)&&this.step(new te(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new te(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,r){return Gr(this,e,t,r),this}addMark(e,t,r){return Lr(this,e,t,r),this}removeMark(e,t,r){return Fr(this,e,t,r),this}clearIncompatible(e,t,r){return ft(this,e,t,r),this}}const Ue=Object.create(null);class A{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Nn(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=w.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?w.empty:t),l==0&&jt(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),jt(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new D(e):re(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?re(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):re(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new F(e.node(0))}static atStart(e){return re(e,e,0,0,1)||new F(e)}static atEnd(e){return re(e,e,e.content.size,e.childCount,-1)||new F(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ue[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Ue)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ue[e]=t,t.prototype.jsonID=e,t}getBookmark(){return D.between(this.$anchor,this.$head).getBookmark()}}A.prototype.visible=!0;class Nn{constructor(e,t){this.$from=e,this.$to=t}}let Ft=!1;function qt(n){!Ft&&!n.parent.inlineContent&&(Ft=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class D extends A{constructor(e,t=e){qt(e),qt(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return A.near(r);let i=e.resolve(t.map(this.anchor));return new D(i.parent.inlineContent?i:r,r)}replace(e,t=w.empty){if(super.replace(e,t),t==w.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof D&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new De(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new D(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=A.findFrom(t,r,!0)||A.findFrom(t,-r,!0);if(s)t=s.$head;else return A.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(A.findFrom(e,-r,!0)||A.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new D(e,t)}}A.jsonID("text",D);class De{constructor(e,t){this.anchor=e,this.head=t}map(e){return new De(e.map(this.anchor),e.map(this.head))}resolve(e){return D.between(e.resolve(this.anchor),e.resolve(this.head))}}class R extends A{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?A.near(s):new R(s)}content(){return new w(v.from(this.node),0,0)}eq(e){return e instanceof R&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ht(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new R(e.resolve(t.anchor))}static create(e,t){return new R(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}R.prototype.visible=!1;A.jsonID("node",R);class ht{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new De(r,r):new ht(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&R.isSelectable(r)?new R(t):A.near(t)}}class F extends A{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=w.empty){if(t==w.empty){e.delete(0,e.doc.content.size);let r=A.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new F(e)}map(e){return new F(e)}eq(e){return e instanceof F}getBookmark(){return oi}}A.jsonID("all",F);const oi={map(){return this},resolve(n){return new F(n)}};function re(n,e,t,r,i,s=!1){if(e.inlineContent)return D.create(n,t);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&R.isSelectable(l))return R.create(n,t-(i<0?l.nodeSize:0))}else{let a=re(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function jt(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof I||i instanceof z))return;let s=n.mapping.maps[r],o;s.forEach((l,a,c,u)=>{o==null&&(o=u)}),n.setSelection(A.near(n.doc.resolve(o),t))}function Wt(n,e){return!e||!n?n:n.bind(e)}class Ee{constructor(e,t,r){this.name=e,this.init=Wt(t.init,r),this.apply=Wt(t.apply,r)}}new Ee("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ee("selection",{init(n,e){return n.selection||A.atStart(e.doc)},apply(n){return n.selection}}),new Ee("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Ee("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}});function On(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=On(i,e,{})),t[r]=i}return t}class li{constructor(e){this.spec=e,this.props={},e.props&&On(e.props,this,this.props),this.key=e.key?e.key.key:In("plugin")}getState(e){return e[this.key]}}const Ke=Object.create(null);function In(n){return n in Ke?n+"$"+ ++Ke[n]:(Ke[n]=0,n+"$")}class ai{constructor(e="key"){this.key=In(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Be=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function zn(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Pn=(n,e,t)=>{let r=zn(n,t);if(!r)return!1;let i=pt(r);if(!i){let o=r.blockRange(),l=o&&ce(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Wn(n,i,e,-1))return!0;if(r.parent.content.size==0&&(oe(s,"end")||R.isSelectable(s)))for(let o=r.depth;;o--){let l=$e(n.doc,r.before(o),r.after(o),w.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(oe(s,"end")?A.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):R.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},ci=(n,e,t)=>{let r=zn(n,t);if(!r)return!1;let i=pt(r);return i?$n(n,i,e):!1},ui=(n,e,t)=>{let r=Bn(n,t);if(!r)return!1;let i=mt(r);return i?$n(n,i,e):!1};function $n(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=$e(n.doc,s,a,w.empty);if(!c||c.from!=s||c instanceof I&&c.slice.size>=a-s)return!1;if(t){let u=n.tr.step(c);u.setSelection(D.create(u.doc,s)),t(u.scrollIntoView())}return!0}function oe(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Dn=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=pt(r)}let o=s&&s.nodeBefore;return!o||!R.isSelectable(o)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function pt(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Bn(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const _n=(n,e,t)=>{let r=Bn(n,t);if(!r)return!1;let i=mt(r);if(!i)return!1;let s=i.nodeAfter;if(Wn(n,i,e,1))return!0;if(r.parent.content.size==0&&(oe(s,"start")||R.isSelectable(s))){let o=$e(n.doc,r.before(),r.after(),w.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(oe(s,"start")?A.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):R.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},Ln=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=mt(r)}let o=s&&s.nodeAfter;return!o||!R.isSelectable(o)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,s.pos)).scrollIntoView()),!0)};function mt(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const fi=(n,e)=>{let t=n.selection,r=t instanceof R,i;if(r){if(t.node.isTextblock||!Z(n.doc,t.from))return!1;i=t.from}else if(i=Pe(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(R.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},di=(n,e)=>{let t=n.selection,r;if(t instanceof R){if(t.node.isTextblock||!Z(n.doc,t.to))return!1;r=t.to}else if(r=Pe(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},hi=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&ce(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},Fn=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
21
|
-
`).scrollIntoView()),!0)};function gt(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const pi=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=gt(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(A.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},qn=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof F||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=gt(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(D.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},jn=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(U(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&ce(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function mi(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof R&&e.selection.node.isBlock)return!r.parentOffset||!U(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let d=r.depth;;d--)if(r.node(d).isBlock){a=r.end(d)==r.pos+(r.depth-d),c=r.start(d)==r.pos-(r.depth-d),l=gt(r.node(d-1).contentMatchAt(r.indexAfter(d-1))),s.unshift(a&&l?{type:l}:null),o=d;break}else{if(d==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof D||e.selection instanceof F)&&u.deleteSelection();let f=u.mapping.map(r.pos),h=U(u.doc,f,s.length,s);if(h||(s[0]=l?{type:l}:null,h=U(u.doc,f,s.length,s)),!h)return!1;if(u.split(f,s.length,s),!a&&c&&r.node(o).type!=l){let d=u.mapping.map(r.before(o)),m=u.doc.resolve(d);l&&r.node(o-1).canReplaceWith(m.index(),m.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return t&&t(u.scrollIntoView()),!0}}const gi=mi(),yi=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(R.create(n.doc,i))),!0)};function vi(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Z(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Wn(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&vi(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let d=e.pos+s.nodeSize,m=v.empty;for(let y=o.length-1;y>=0;y--)m=v.from(o[y].create(null,m));m=v.from(i.copy(m));let p=n.tr.step(new z(e.pos-1,d,e.pos,d,new w(m,1,0),o.length,!0)),g=p.doc.resolve(d+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Z(p.doc,g.pos)&&p.join(g.pos),t(p.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:A.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),h=f&&ce(f);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(f,h).scrollIntoView()),!0;if(c&&oe(s,"start",!0)&&oe(i,"end")){let d=i,m=[];for(;m.push(d),!d.isTextblock;)d=d.lastChild;let p=s,g=1;for(;!p.isTextblock;p=p.firstChild)g++;if(d.canReplace(d.childCount,d.childCount,p.content)){if(t){let y=v.empty;for(let k=m.length-1;k>=0;k--)y=v.from(m[k].copy(y));let S=n.tr.step(new z(e.pos-m.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new w(y,m.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function Vn(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(D.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const wi=Vn(-1),Si=Vn(1);function xi(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&dt(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Vt(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),f=u.index();i=u.parent.canReplaceWith(f,f+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function yt(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}yt(Be,Pn,Dn);yt(Be,_n,Ln);yt(Fn,qn,jn,gi);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function ki(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s);if(!o)return!1;let l=r?t.tr:null;return bi(l,o,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function bi(n,e,t,r=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);s=new tt(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new tt(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=dt(s,t,r,e);return l?(n&&Ei(n,e,l,i,t),!0):!1}function Ei(n,e,t,r,i){let s=v.empty;for(let u=t.length-1;u>=0;u--)s=v.from(t[u].type.create(t[u].attrs,s));n.step(new z(e.start-(r?2:0),e.end,e.start,e.end,new w(s,0,0),t.length,!0));let o=0;for(let u=0;u<t.length;u++)t[u].type==i&&(o=u+1);let l=t.length-o,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,f=e.endIndex,h=!0;u<f;u++,h=!1)!h&&U(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Mi(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Ci(e,t,n,s):Ri(e,t,s):!0:!1}}function Ci(n,e,t,r){let i=n.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new z(s-1,o,s,o,new w(v.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new tt(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=ce(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return Z(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function Ri(n,e,t){let r=n.tr,i=t.parent;for(let d=t.end,m=t.endIndex-1,p=t.startIndex;m>p;m--)d-=i.child(m).nodeSize,r.delete(d-1,d+1);let s=r.doc.resolve(t.start),o=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?v.empty:v.from(i))))return!1;let f=s.pos,h=f+o.nodeSize;return r.step(new z(f-(l?1:0),h+(a?1:0),f+1,h-1,new w((l?v.empty:v.from(i.copy(v.empty))).append(a?v.empty:v.from(i.copy(v.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Ti(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=v.from(c?n.create():null),f=new w(v.from(n.create(null,v.from(l.type.create(null,u)))),c?3:1,0),h=s.start,d=s.end;t(e.tr.step(new z(h-(c?3:1),d,h,d,f,1,!0)).scrollIntoView())}return!0}}var Ai=Object.defineProperty,vt=(n,e)=>{for(var t in e)Ai(n,t,{get:e[t],enumerable:!0})};function Jn(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,s=t.storedMarks,t}}}var Ni=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:i}=t,s=this.buildProps(i);return Object.fromEntries(Object.entries(n).map(([o,l])=>[o,(...c)=>{const u=l(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:r,state:i}=this,{view:s}=r,o=[],l=!!n,a=n||i.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),o.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(t).map(([f,h])=>[f,(...m)=>{const p=this.buildProps(a,e),g=h(...m)(p);return o.push(g),u}])),run:c};return u}createCan(n){const{rawCommands:e,state:t}=this,r=!1,i=n||t.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(n,e=!0){const{rawCommands:t,editor:r,state:i}=this,{view:s}=r,o={tr:n,editor:r,view:s,state:Jn({state:i,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},Hn={};vt(Hn,{blur:()=>Oi,clearContent:()=>Ii,clearNodes:()=>zi,command:()=>Pi,createParagraphNear:()=>$i,cut:()=>Di,deleteCurrentNode:()=>Bi,deleteNode:()=>_i,deleteRange:()=>Li,deleteSelection:()=>Fi,enter:()=>qi,exitCode:()=>ji,extendMarkRange:()=>Vi,first:()=>Ji,focus:()=>Ui,forEach:()=>Ki,insertContent:()=>Gi,insertContentAt:()=>Zi,joinBackward:()=>ts,joinDown:()=>es,joinForward:()=>ns,joinItemBackward:()=>rs,joinItemForward:()=>is,joinTextblockBackward:()=>ss,joinTextblockForward:()=>ls,joinUp:()=>Qi,keyboardShortcut:()=>cs,lift:()=>us,liftEmptyBlock:()=>fs,liftListItem:()=>ds,newlineInCode:()=>hs,resetAttributes:()=>ps,scrollIntoView:()=>ms,selectAll:()=>gs,selectNodeBackward:()=>ys,selectNodeForward:()=>vs,selectParentNode:()=>ws,selectTextblockEnd:()=>Ss,selectTextblockStart:()=>xs,setContent:()=>bs,setMark:()=>qs,setMeta:()=>js,setNode:()=>Ws,setNodeSelection:()=>Vs,setTextDirection:()=>Js,setTextSelection:()=>Hs,sinkListItem:()=>Us,splitBlock:()=>Ks,splitListItem:()=>Gs,toggleList:()=>Xs,toggleMark:()=>Ys,toggleNode:()=>Zs,toggleWrap:()=>Qs,undoInputRule:()=>eo,unsetAllMarks:()=>to,unsetMark:()=>no,unsetTextDirection:()=>ro,updateAttributes:()=>io,wrapIn:()=>so,wrapInList:()=>oo});var Oi=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())==null||t.removeAllRanges())}),!0),Ii=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),zi=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:s,$to:o})=>{n.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,f=c.resolve(u.map(a)),h=c.resolve(u.map(a+l.nodeSize)),d=f.blockRange(h);if(!d)return;const m=ce(d);if(l.type.isTextblock){const{defaultType:p}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(d.start,p)}(m||m===0)&&e.lift(d,m)})}),!0},Pi=n=>e=>n(e),$i=()=>({state:n,dispatch:e})=>qn(n,e),Di=(n,e)=>({editor:t,tr:r})=>{const{state:i}=t,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new M.TextSelection(r.doc.resolve(Math.max(o-1,0)))),!0},Bi=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const i=n.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const l=i.before(s),a=i.after(s);n.delete(l,a).scrollIntoView()}return!0}return!1};function P(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var _i=n=>({tr:e,state:t,dispatch:r})=>{const i=P(n,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},Li=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},Fi=()=>({state:n,dispatch:e})=>Be(n,e),qi=()=>({commands:n})=>n.keyboardShortcut("Enter"),ji=()=>({state:n,dispatch:e})=>pi(n,e);function Wi(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function ze(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:Wi(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function Un(n,e,t={}){return n.find(r=>r.type===e&&ze(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function Jt(n,e,t={}){return!!Un(n,e,t)}function wt(n,e,t){var r;if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(u=>u.type===e)||(t=t||((r=i.node.marks[0])==null?void 0:r.attrs),!Un([...i.node.marks],e,t)))return;let o=i.index,l=n.start()+i.offset,a=o+1,c=l+i.node.nodeSize;for(;o>0&&Jt([...n.parent.child(o-1).marks],e,t);)o-=1,l-=n.parent.child(o).nodeSize;for(;a<n.parent.childCount&&Jt([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Q(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var Vi=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const s=Q(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:u}=l;if(i){const f=wt(a,s,e);if(f&&f.from<=c&&f.to>=u){const h=M.TextSelection.create(o,f.from,f.to);t.setSelection(h)}}return!0},Ji=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function St(n){return n instanceof M.TextSelection}function H(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Hi(n,e=null){if(!e)return null;const t=M.Selection.atStart(n),r=M.Selection.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const i=t.from,s=r.to;return e==="all"?M.TextSelection.create(n,H(0,i,s),H(n.content.size,i,s)):M.TextSelection.create(n,H(e,i,s),H(e,i,s))}function Kn(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function _e(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Ui=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(_e()||Kn())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!St(t.state.selection))return o(),!0;const l=Hi(i.doc,n)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Ki=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),Gi=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),Gn=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&Gn(r)}return n};function Me(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Gn(t)}function ye(n,e,t){if(n instanceof _.Node||n instanceof _.Fragment)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return _.Fragment.fromArray(n.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),ye("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const a=new _.Schema({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?_.DOMParser.fromSchema(a).parseSlice(Me(n),t.parseOptions):_.DOMParser.fromSchema(a).parse(Me(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=_.DOMParser.fromSchema(e);return t.slice?s.parseSlice(Me(n),t.parseOptions).content:s.parse(Me(n),t.parseOptions)}return ye("",e,t)}function Xi(n,e,t){const r=n.steps.length-1;if(r<e)return;const i=n.steps[r];if(!(i instanceof I||i instanceof z))return;const s=n.mapping.maps[r];let o=0;s.forEach((l,a,c,u)=>{o===0&&(o=u)}),n.setSelection(M.Selection.near(n.doc.resolve(o),t))}var Yi=n=>!("type"in n),Zi=(n,e,t)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{ye(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=ye(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:u,to:f}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},h=!0,d=!0;if((Yi(l)?l:[l]).forEach(g=>{g.check(),h=h?g.isText&&g.marks.length===0:!1,d=d?g.isBlock:!1}),u===f&&d){const{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,f+=1)}let p;if(h){if(Array.isArray(e))p=e.map(g=>g.text||"").join("");else if(e instanceof _.Fragment){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),p=g}else typeof e=="object"&&e&&e.text?p=e.text:p=e;r.insertText(p,u,f)}else{p=l;const g=r.doc.resolve(u),y=g.node(),S=g.parentOffset===0,k=y.isText||y.isTextblock,x=y.content.size>0;S&&k&&x&&(u=Math.max(0,u-1)),r.replaceWith(u,f,p)}t.updateSelection&&Xi(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:p}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:p})}return!0},Qi=()=>({state:n,dispatch:e})=>fi(n,e),es=()=>({state:n,dispatch:e})=>di(n,e),ts=()=>({state:n,dispatch:e})=>Pn(n,e),ns=()=>({state:n,dispatch:e})=>_n(n,e),rs=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Pe(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},is=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Pe(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},ss=()=>({state:n,dispatch:e})=>ci(n,e),ls=()=>({state:n,dispatch:e})=>ui(n,e);function Xn(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function as(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))_e()||Xn()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var cs=n=>({editor:e,view:t,tr:r,dispatch:i})=>{const s=as(n).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function le(n,e,t={}){const{from:r,to:i,empty:s}=n.selection,o=e?P(e,n.schema):null,l=[];n.doc.nodesBetween(r,i,(f,h)=>{if(f.isText)return;const d=Math.max(r,h),m=Math.min(i,h+f.nodeSize);l.push({node:f,from:d,to:m})});const a=i-r,c=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>ze(f.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((f,h)=>f+h.to-h.from,0)>=a}var us=(n,e={})=>({state:t,dispatch:r})=>{const i=P(n,t.schema);return le(t,i,e)?hi(t,r):!1},fs=()=>({state:n,dispatch:e})=>jn(n,e),ds=n=>({state:e,dispatch:t})=>{const r=P(n,e.schema);return Mi(r)(e,t)},hs=()=>({state:n,dispatch:e})=>Fn(n,e);function Le(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Ht(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}var ps=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const l=Le(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(s=P(n,r.schema)),l==="mark"&&(o=Q(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,f)=>{s&&s===u.type&&(a=!0,i&&t.setNodeMarkup(f,void 0,Ht(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(h=>{o===h.type&&(a=!0,i&&t.addMark(f,f+u.nodeSize,o.create(Ht(h.attrs,e))))})})}),a},ms=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),gs=()=>({tr:n,dispatch:e})=>{if(e){const t=new M.AllSelection(n.doc);n.setSelection(t)}return!0},ys=()=>({state:n,dispatch:e})=>Dn(n,e),vs=()=>({state:n,dispatch:e})=>Ln(n,e),ws=()=>({state:n,dispatch:e})=>yi(n,e),Ss=()=>({state:n,dispatch:e})=>Si(n,e),xs=()=>({state:n,dispatch:e})=>wi(n,e);function ks(n,e,t={},r={}){return ye(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var bs=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:a}=s;if(r.preserveWhitespace!=="full"){const c=ks(n,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}return o&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},n,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function Yn(n,e){const t=Q(e,n.schema),{from:r,to:i,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function Zn(n,e){const t=new An(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}function Es(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Ms(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&r.push({node:i,pos:s})}),r}function Qn(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function ve(n){return e=>Qn(e.$from,n)}function ae(n,e,t){return n.config[e]===void 0&&n.parent?ae(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?ae(n.parent,e,t):null}):n.config[e]}function Cs(n){return typeof n=="function"}function j(n,e=void 0,...t){return Cs(n)?e?n.bind(e)(...t):n(...t):n}function er(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function tr(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const l=s?String(s).split(" "):[],a=r[i]?r[i].split(" "):[],c=l.filter(u=>!a.includes(u));r[i]=[...a,...c].join(" ")}else if(i==="style"){const l=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[i]?r[i].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{const[f,h]=u.split(":").map(d=>d.trim());c.set(f,h)}),l.forEach(u=>{const[f,h]=u.split(":").map(d=>d.trim());c.set(f,h)}),r[i]=Array.from(c.entries()).map(([u,f])=>`${u}: ${f}`).join("; ")}else r[i]=s}),r},{})}function Rs(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>tr(t,r),{})}function nr(n,e,t){const{from:r,to:i}=e,{blockSeparator:s=`
|
|
17
|
+
*/var Nt;function xr(){return Nt||(Nt=1,process.env.NODE_ENV!=="production"&&(function(){function n(d,m){return d===m&&(d!==0||1/d===1/m)||d!==d&&m!==m}function e(d,m){u||i.startTransition===void 0||(u=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var p=m();if(!f){var g=m();s(p,g)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),f=!0)}g=o({inst:{value:p,getSnapshot:m}});var y=g[0].inst,S=g[1];return a(function(){y.value=p,y.getSnapshot=m,t(y)&&S({inst:y})},[d,p,m]),l(function(){return t(y)&&S({inst:y}),d(function(){t(y)&&S({inst:y})})},[d]),c(p),p}function t(d){var m=d.getSnapshot;d=d.value;try{var p=m();return!s(d,p)}catch{return!0}}function r(d,m){return m()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var i=T,s=typeof Object.is=="function"?Object.is:n,o=i.useState,l=i.useEffect,a=i.useLayoutEffect,c=i.useDebugValue,u=!1,f=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:e;qe.useSyncExternalStore=i.useSyncExternalStore!==void 0?i.useSyncExternalStore:h,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),qe}var Ot;function lt(){return Ot||(Ot=1,process.env.NODE_ENV==="production"?xe.exports=Sr():xe.exports=xr()),xe.exports}var cn=lt();function un(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=un(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function fn(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=fn(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class v{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new v(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new v(r,i)}cutByIndex(e,t){return e==t?v.empty:e==0&&t==this.content.length?this:new v(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new v(i,s)}addToStart(e){return new v([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new v(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return un(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return fn(this,e,t,r)}findIndex(e){if(e==0)return ke(0,e);if(e==this.size)return ke(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?ke(t+1,s):ke(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return v.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new v(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return v.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new v(t||e,r)}static from(e){if(!e)return v.empty;if(e instanceof v)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new v([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}v.empty=new v([],0);const je={index:0,offset:0};function ke(n,e){return je.index=n,je.offset=e,je}function Qe(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Qe(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Qe(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let L=class et{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Qe(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return et.none;if(e instanceof et)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};L.none=[];class kr extends Error{}class w{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=hn(this.content,e+this.openStart,t);return r&&new w(r,this.openStart,this.openEnd)}removeBetween(e,t){return new w(dn(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return w.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new w(v.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new w(e,r,i)}}w.empty=new w(v.empty,0,0);function dn(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(dn(s.content,e-i-1,t-i-1)))}function hn(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),o=n.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=hn(o.content,e-s-1,t,o);return l&&n.replaceChild(i,o.copy(l))}class tt{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}function br(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Er(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function Mr(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let s=n[i];s.validate&&s.validate(e[i])}}function Cr(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Tr(n,r,e[r]);return t}function Rr(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class Tr{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Rr(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class at{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Cr(e,i.attrs),this.excluded=null;let s=br(this.attrs);this.instance=s?new L(this,s):null}create(e=null){return!e&&this.instance?this.instance:new L(this,Er(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new at(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Mr(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}function Ar(n){return n.tag!=null}function Nr(n){return n.style!=null}class Ie{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(Ar(i))this.tags.push(i);else if(Nr(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new zt(this,t,!1);return r.addAll(e,L.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new zt(this,t,!0);return r.addAll(e,L.none,t.from,t.to),w.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(zr(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Pt(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Pt(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ie(e,Ie.schemaRules(e)))}}const pn={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Or={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},mn={ol:!0,ul:!0},pe=1,nt=2,he=4;function It(n,e,t){return e!=null?(e?pe:0)|(e==="full"?nt:0):n&&n.whitespace=="pre"?pe|nt:t&~he}class be{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=L.none,this.match=s||(o&he?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(v.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&pe)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=v.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(v.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!pn.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class zt{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=It(null,t.preserveWhitespace,0)|(r?he:0);i?s=new be(i.type,i.attrs,L.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new be(null,null,L.none,!0,null,o):s=new be(e.schema.topNodeType,null,L.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&nt?"full":this.localPreserveWS||(i.options&pe)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
|
|
18
|
+
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;mn.hasOwnProperty(o)&&this.parser.normalizeLists&&Ir(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Or.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(pn.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let f=a&&a.skip?t:this.readStyles(e,t);f&&this.addAll(e,f),c&&this.sync(s),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
19
|
+
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=L.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):$t(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=It(e,s,o.options);o.options&he&&o.content.length==0&&(l|=he);let a=L.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):$t(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new be(e,t,a,i,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=pe)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function Ir(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&mn.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function zr(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Pt(n){let e={};for(let t in n)e[t]=n[t];return e}function $t(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&o(u))return!0}};if(o(i.contentMatch))return!0}}class ct{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=We(t).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,t);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=Ae(We(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Ae(We(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return Ae(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ct(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Dt(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Dt(e.marks)}}function Dt(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function We(n){return n.document||window.document}const Bt=new WeakMap;function Pr(n){let e=Bt.get(n);return e===void 0&&Bt.set(n,e=$r(n)),e}function $r(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function Ae(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Pr(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let h=f.indexOf(" ");h>0?a.setAttributeNS(f.slice(0,h),f.slice(h+1),c[f]):f=="style"&&a.style?a.style.cssText=c[f]:a.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let h=e[f];if(h===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:d,contentDOM:m}=Ae(n,h,t,r);if(a.appendChild(d),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:a,contentDOM:l}}const gn=65535,yn=Math.pow(2,16);function Dr(n,e){return n+e*yn}function _t(n){return n&gn}function Br(n){return(n-(n&gn))/yn}const vn=1,wn=2,Ne=4,Sn=8;class rt{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Sn)>0}get deletedBefore(){return(this.delInfo&(vn|Ne))>0}get deletedAfter(){return(this.delInfo&(wn|Ne))>0}get deletedAcross(){return(this.delInfo&Ne)>0}}class B{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&B.empty)return B.empty}recover(e){let t=0,r=_t(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+Br(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+o],f=a+c;if(e<=f){let h=c?e==a?-1:e==f?1:t:t,d=a+i+(h<0?0:u);if(r)return d;let m=e==(t<0?a:f)?null:Dr(l/3,e-a),p=e==a?wn:e==f?vn:Ne;return(t<0?e!=a:e!=f)&&(p|=Sn),new rt(d,p,m)}i+=u-c}return r?e+i:new rt(e+i,0,null)}touches(e,t){let r=0,i=_t(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],u=this.ranges[i+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new B(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?B.empty:new B(e<0?[0,-e,0]:[0,0,e])}}B.empty=new B([]);class me{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new me(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new me;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new rt(e,i,null)}}const Ve=Object.create(null);class ${getMap(){return B.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ve[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Ve)throw new RangeError("Duplicate use of step JSON ID "+e);return Ve[e]=t,t.prototype.jsonID=e,t}}class N{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new N(e,null)}static fail(e){return new N(null,e)}static fromReplace(e,t,r,i){try{return N.ok(e.replace(t,r,i))}catch(s){if(s instanceof kr)return N.fail(s.message);throw s}}}function ut(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(ut(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return v.fromArray(r)}class X extends ${constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new w(ut(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return N.fromReplace(e,this.from,this.to,s)}invert(){return new q(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new X(t.pos,r.pos,this.mark)}merge(e){return e instanceof X&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new X(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new X(t.from,t.to,e.markFromJSON(t.mark))}}$.jsonID("addMark",X);class q extends ${constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new w(ut(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return N.fromReplace(e,this.from,this.to,r)}invert(){return new X(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new q(t.pos,r.pos,this.mark)}merge(e){return e instanceof q&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new q(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new q(t.from,t.to,e.markFromJSON(t.mark))}}$.jsonID("removeMark",q);class Y extends ${constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return N.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return N.fromReplace(e,this.pos,this.pos+1,new w(v.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new Y(this.pos,t.marks[i]);return new Y(this.pos,this.mark)}}return new te(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Y(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Y(t.pos,e.markFromJSON(t.mark))}}$.jsonID("addNodeMark",Y);class te extends ${constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return N.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return N.fromReplace(e,this.pos,this.pos+1,new w(v.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Y(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new te(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new te(t.pos,e.markFromJSON(t.mark))}}$.jsonID("removeNodeMark",te);class I extends ${constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&it(e,this.from,this.to)?N.fail("Structure replace would overwrite content"):N.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new B([this.from,this.to-this.from,this.slice.size])}invert(e){return new I(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new I(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof I)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?w.empty:new w(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new I(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?w.empty:new w(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new I(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new I(t.from,t.to,w.fromJSON(e,t.slice),!!t.structure)}}$.jsonID("replace",I);class z extends ${constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(it(e,this.from,this.gapFrom)||it(e,this.gapTo,this.to)))return N.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return N.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?N.fromReplace(e,this.from,this.to,r):N.fail("Content does not fit in gap")}getMap(){return new B([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new z(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new z(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new z(t.from,t.to,t.gapFrom,t.gapTo,w.fromJSON(e,t.slice),t.insert,!!t.structure)}}$.jsonID("replaceAround",z);function it(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function _r(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let h=Math.max(c,e),d=Math.min(c+a.nodeSize,t),m=r.addToSet(f);for(let p=0;p<f.length;p++)f[p].isInSet(m)||(o&&o.to==h&&o.mark.eq(f[p])?o.to=d:i.push(o=new q(h,d,f[p])));l&&l.to==h?l.to=d:s.push(l=new X(h,d,r))}}),i.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function Lr(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof at){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let u=0;u<a.length;u++){let f=a[u],h;for(let d=0;d<i.length;d++){let m=i[d];m.step==s-1&&f.eq(i[d].style)&&(h=m)}h?(h.to=c,h.step=s):i.push({style:f,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>n.step(new q(o.from,o.to,o.style)))}function ft(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)o.push(new I(l,u,w.empty));else{r=f;for(let h=0;h<c.marks.length;h++)t.allowsMarkType(c.marks[h].type)||n.step(new q(l,u,c.marks[h]));if(i&&c.isText&&t.whitespace!="pre"){let h,d=/\r?\n|\r/g,m;for(;h=d.exec(c.text);)m||(m=new w(v.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new I(l+h.index,l+h.index+h[0].length,m))}}l=u}if(!r.validEnd){let a=r.fillBefore(v.empty,!0);n.replace(l,l,new w(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function Fr(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ce(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-s;if(r<n.depth&&o.canReplace(l,a,t))return r;if(r==0||o.type.spec.isolating||!Fr(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function qr(n,e,t){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,c=l,u=v.empty,f=0;for(let m=s,p=!1;m>t;m--)p||r.index(m)>0?(p=!0,u=v.from(r.node(m).copy(u)),f++):a--;let h=v.empty,d=0;for(let m=s,p=!1;m>t;m--)p||i.after(m+1)<i.end(m)?(p=!0,h=v.from(i.node(m).copy(h)),d++):c++;n.step(new z(a,c,o,l,new w(u.append(h),f,d),u.size-f,!0))}function dt(n,e,t=null,r=n){let i=jr(n,e),s=i&&Wr(r,e);return s?i.map(Lt).concat({type:e,attrs:t}).concat(s.map(Lt)):null}function Lt(n){return{type:n,attrs:null}}function jr(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function Wr(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function Vr(n,e,t){let r=v.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=v.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new z(i,s,i,s,new w(r,0,0),t.length,!0))}function Jr(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&Hr(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let d=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);d&&!m?c=!1:!d&&m&&(c=!0)}c===!1&&kn(n,o,l,s),ft(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),f=u.map(l,1),h=u.map(l+o.nodeSize,1);return n.step(new z(f,h,f+1,h-1,new w(v.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&xn(n,o,l,s),!1}})}function xn(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function kn(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
|
|
20
|
+
`))}})}function Hr(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function Ur(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new z(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new w(v.from(o),0,0),1,!0))}function U(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>s;c--,u--){let f=i.node(c),h=i.index(c);if(f.type.spec.isolating)return!1;let d=f.content.cutByIndex(h,f.childCount),m=r&&r[u+1];m&&(d=d.replaceChild(0,m.type.create(m.attrs)));let p=r&&r[u]||f;if(!f.canReplace(h+1,f.childCount)||!p.type.validContent(d))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function Kr(n,e,t=1,r){let i=n.doc.resolve(e),s=v.empty,o=v.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=v.from(i.node(l).copy(s));let u=r&&r[c];o=v.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}n.step(new I(e,e,new w(s.append(o),t,t),!0))}function Z(n,e){let t=n.resolve(e),r=t.index();return bn(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Gr(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function bn(n,e){return!!(n&&e&&!n.isLeaf&&Gr(n,e))}function Pe(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):t>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&bn(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function Xr(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",f=!!o.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);kn(n,u.node(),u.before(),l)}o.inlineContent&&ft(n,e+t-1,o,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new I(c,a.map(e+t,-1),w.empty,!0)),r===!0){let u=n.doc.resolve(c);xn(n,u.node(),u.before(),n.steps.length)}return n}function Yr(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function Zr(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(a,a,i);else{let f=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function $e(n,e,t=e,r=w.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return En(i,s,r)?new I(e,t,r):new Qr(i,s,r).fit()}function En(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Qr{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=v.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=v.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new w(s,o,l);return e>-1?new z(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new I(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Je(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(t==1&&(o?c.matchType(o.type)||(f=c.fillBefore(v.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:f};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Je(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new w(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Je(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new w(fe(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new w(fe(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let p=0;p<s.length;p++)this.openFrontierNode(s[p]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:f,type:h}=this.frontier[t];if(i){for(let p=0;p<i.childCount;p++)u.push(i.child(p));f=f.matchFragment(i)}let d=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let p=l.child(c),g=f.matchType(p.type);if(!g)break;c++,(c>1||a==0||p.content.size)&&(f=g,u.push(Mn(p.mark(h.allowedMarks(p.marks)),c==1?a:0,c==l.childCount?d:-1)))}let m=c==l.childCount;m||(d=-1),this.placed=de(this.placed,t,v.from(u)),this.frontier[t].match=f,m&&d<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let p=0,g=l;p<d;p++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=m?e==0?w.empty:new w(fe(o.content,e-1,1),e-1,d<0?o.openEnd:e-1):new w(fe(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!He(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=He(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=He(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=de(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=de(this.placed,this.depth,v.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(v.empty,!0);t.childCount&&(this.placed=de(this.placed,this.frontier.length,t))}}function fe(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(fe(n.firstChild.content,e-1,t)))}function de(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(de(n.lastChild.content,e-1,t)))}function Je(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Mn(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Mn(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(v.empty,!0)))),n.copy(r)}function He(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!ei(t,s.content,o)?l:null}function ei(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function ti(n){return n.spec.defining||n.spec.definingForContent}function ni(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(En(i,s,r))return n.step(new I(e,t,r));let o=Rn(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let h=i.depth,d=i.pos-1;h>0;h--,d--){let m=i.node(h).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;o.indexOf(h)>-1?l=h:i.before(h)==d&&o.splice(1,0,-h)}let a=o.indexOf(l),c=[],u=r.openStart;for(let h=r.content,d=0;;d++){let m=h.firstChild;if(c.push(m),d==r.openStart)break;h=m.content}for(let h=u-1;h>=0;h--){let d=c[h],m=ti(d.type);if(m&&!d.sameMarkup(i.node(Math.abs(l)-1)))u=h;else if(m||!d.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let d=(h+u+1)%(r.openStart+1),m=c[d];if(m)for(let p=0;p<o.length;p++){let g=o[(p+a)%o.length],y=!0;g<0&&(y=!1,g=-g);let S=i.node(g-1),k=i.index(g-1);if(S.canReplaceWith(k,k,m.type,m.marks))return n.replace(i.before(g),y?s.after(g):t,new w(Cn(r.content,0,r.openStart,d),d,r.openEnd))}}let f=n.steps.length;for(let h=o.length-1;h>=0&&(n.replace(e,t,r),!(n.steps.length>f));h--){let d=o[h];d<0||(e=i.before(d),t=s.after(d))}}function Cn(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Cn(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(v.empty,!0))}return n}function ri(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Yr(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new w(v.from(r),0,0))}function ii(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=Rn(r,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function Rn(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class ie extends ${constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return N.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return N.fromReplace(e,this.pos,this.pos+1,new w(v.from(i),0,t.isLeaf?0:1))}getMap(){return B.empty}invert(e){return new ie(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ie(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ie(t.pos,t.attr,t.value)}}$.jsonID("attr",ie);class ge extends ${constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return N.ok(r)}getMap(){return B.empty}invert(e){return new ge(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ge(t.attr,t.value)}}$.jsonID("docAttr",ge);let se=class extends Error{};se=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};se.prototype=Object.create(Error.prototype);se.prototype.constructor=se;se.prototype.name="TransformError";class Tn{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new me}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new se(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=w.empty){let i=$e(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new w(v.from(r),0,0))}delete(e,t){return this.replace(e,t,w.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return ni(this,e,t,r),this}replaceRangeWith(e,t,r){return ri(this,e,t,r),this}deleteRange(e,t){return ii(this,e,t),this}lift(e,t){return qr(this,e,t),this}join(e,t=1){return Xr(this,e,t),this}wrap(e,t){return Vr(this,e,t),this}setBlockType(e,t=e,r,i=null){return Jr(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return Ur(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new ie(e,t,r)),this}setDocAttribute(e,t){return this.step(new ge(e,t)),this}addNodeMark(e,t){return this.step(new Y(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof L)t.isInSet(r.marks)&&this.step(new te(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new te(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,r){return Kr(this,e,t,r),this}addMark(e,t,r){return _r(this,e,t,r),this}removeMark(e,t,r){return Lr(this,e,t,r),this}clearIncompatible(e,t,r){return ft(this,e,t,r),this}}const Ue=Object.create(null);class A{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new An(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=w.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?w.empty:t),l==0&&jt(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),jt(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new D(e):re(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?re(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):re(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new F(e.node(0))}static atStart(e){return re(e,e,0,0,1)||new F(e)}static atEnd(e){return re(e,e,e.content.size,e.childCount,-1)||new F(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ue[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Ue)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ue[e]=t,t.prototype.jsonID=e,t}getBookmark(){return D.between(this.$anchor,this.$head).getBookmark()}}A.prototype.visible=!0;class An{constructor(e,t){this.$from=e,this.$to=t}}let Ft=!1;function qt(n){!Ft&&!n.parent.inlineContent&&(Ft=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class D extends A{constructor(e,t=e){qt(e),qt(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return A.near(r);let i=e.resolve(t.map(this.anchor));return new D(i.parent.inlineContent?i:r,r)}replace(e,t=w.empty){if(super.replace(e,t),t==w.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof D&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new De(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new D(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=A.findFrom(t,r,!0)||A.findFrom(t,-r,!0);if(s)t=s.$head;else return A.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(A.findFrom(e,-r,!0)||A.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new D(e,t)}}A.jsonID("text",D);class De{constructor(e,t){this.anchor=e,this.head=t}map(e){return new De(e.map(this.anchor),e.map(this.head))}resolve(e){return D.between(e.resolve(this.anchor),e.resolve(this.head))}}class R extends A{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?A.near(s):new R(s)}content(){return new w(v.from(this.node),0,0)}eq(e){return e instanceof R&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ht(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new R(e.resolve(t.anchor))}static create(e,t){return new R(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}R.prototype.visible=!1;A.jsonID("node",R);class ht{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new De(r,r):new ht(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&R.isSelectable(r)?new R(t):A.near(t)}}class F extends A{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=w.empty){if(t==w.empty){e.delete(0,e.doc.content.size);let r=A.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new F(e)}map(e){return new F(e)}eq(e){return e instanceof F}getBookmark(){return si}}A.jsonID("all",F);const si={map(){return this},resolve(n){return new F(n)}};function re(n,e,t,r,i,s=!1){if(e.inlineContent)return D.create(n,t);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&R.isSelectable(l))return R.create(n,t-(i<0?l.nodeSize:0))}else{let a=re(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function jt(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof I||i instanceof z))return;let s=n.mapping.maps[r],o;s.forEach((l,a,c,u)=>{o==null&&(o=u)}),n.setSelection(A.near(n.doc.resolve(o),t))}function Wt(n,e){return!e||!n?n:n.bind(e)}class Ee{constructor(e,t,r){this.name=e,this.init=Wt(t.init,r),this.apply=Wt(t.apply,r)}}new Ee("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ee("selection",{init(n,e){return n.selection||A.atStart(e.doc)},apply(n){return n.selection}}),new Ee("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Ee("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}});function Nn(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Nn(i,e,{})),t[r]=i}return t}class oi{constructor(e){this.spec=e,this.props={},e.props&&Nn(e.props,this,this.props),this.key=e.key?e.key.key:On("plugin")}getState(e){return e[this.key]}}const Ke=Object.create(null);function On(n){return n in Ke?n+"$"+ ++Ke[n]:(Ke[n]=0,n+"$")}class li{constructor(e="key"){this.key=On(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Be=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function In(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const zn=(n,e,t)=>{let r=In(n,t);if(!r)return!1;let i=pt(r);if(!i){let o=r.blockRange(),l=o&&ce(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(jn(n,i,e,-1))return!0;if(r.parent.content.size==0&&(oe(s,"end")||R.isSelectable(s)))for(let o=r.depth;;o--){let l=$e(n.doc,r.before(o),r.after(o),w.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(oe(s,"end")?A.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):R.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},ai=(n,e,t)=>{let r=In(n,t);if(!r)return!1;let i=pt(r);return i?Pn(n,i,e):!1},ci=(n,e,t)=>{let r=Dn(n,t);if(!r)return!1;let i=mt(r);return i?Pn(n,i,e):!1};function Pn(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=$e(n.doc,s,a,w.empty);if(!c||c.from!=s||c instanceof I&&c.slice.size>=a-s)return!1;if(t){let u=n.tr.step(c);u.setSelection(D.create(u.doc,s)),t(u.scrollIntoView())}return!0}function oe(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const $n=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=pt(r)}let o=s&&s.nodeBefore;return!o||!R.isSelectable(o)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function pt(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Dn(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Bn=(n,e,t)=>{let r=Dn(n,t);if(!r)return!1;let i=mt(r);if(!i)return!1;let s=i.nodeAfter;if(jn(n,i,e,1))return!0;if(r.parent.content.size==0&&(oe(s,"start")||R.isSelectable(s))){let o=$e(n.doc,r.before(),r.after(),w.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(oe(s,"start")?A.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):R.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},_n=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=mt(r)}let o=s&&s.nodeAfter;return!o||!R.isSelectable(o)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,s.pos)).scrollIntoView()),!0)};function mt(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const ui=(n,e)=>{let t=n.selection,r=t instanceof R,i;if(r){if(t.node.isTextblock||!Z(n.doc,t.from))return!1;i=t.from}else if(i=Pe(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(R.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},fi=(n,e)=>{let t=n.selection,r;if(t instanceof R){if(t.node.isTextblock||!Z(n.doc,t.to))return!1;r=t.to}else if(r=Pe(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},di=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&ce(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},Ln=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
21
|
+
`).scrollIntoView()),!0)};function gt(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const hi=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=gt(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(A.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Fn=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof F||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=gt(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(D.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},qn=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(U(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&ce(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function pi(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof R&&e.selection.node.isBlock)return!r.parentOffset||!U(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let d=r.depth;;d--)if(r.node(d).isBlock){a=r.end(d)==r.pos+(r.depth-d),c=r.start(d)==r.pos-(r.depth-d),l=gt(r.node(d-1).contentMatchAt(r.indexAfter(d-1))),s.unshift(a&&l?{type:l}:null),o=d;break}else{if(d==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof D||e.selection instanceof F)&&u.deleteSelection();let f=u.mapping.map(r.pos),h=U(u.doc,f,s.length,s);if(h||(s[0]=l?{type:l}:null,h=U(u.doc,f,s.length,s)),!h)return!1;if(u.split(f,s.length,s),!a&&c&&r.node(o).type!=l){let d=u.mapping.map(r.before(o)),m=u.doc.resolve(d);l&&r.node(o-1).canReplaceWith(m.index(),m.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return t&&t(u.scrollIntoView()),!0}}const mi=pi(),gi=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(R.create(n.doc,i))),!0)};function yi(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Z(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function jn(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&yi(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let d=e.pos+s.nodeSize,m=v.empty;for(let y=o.length-1;y>=0;y--)m=v.from(o[y].create(null,m));m=v.from(i.copy(m));let p=n.tr.step(new z(e.pos-1,d,e.pos,d,new w(m,1,0),o.length,!0)),g=p.doc.resolve(d+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Z(p.doc,g.pos)&&p.join(g.pos),t(p.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:A.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),h=f&&ce(f);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(f,h).scrollIntoView()),!0;if(c&&oe(s,"start",!0)&&oe(i,"end")){let d=i,m=[];for(;m.push(d),!d.isTextblock;)d=d.lastChild;let p=s,g=1;for(;!p.isTextblock;p=p.firstChild)g++;if(d.canReplace(d.childCount,d.childCount,p.content)){if(t){let y=v.empty;for(let k=m.length-1;k>=0;k--)y=v.from(m[k].copy(y));let S=n.tr.step(new z(e.pos-m.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new w(y,m.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function Wn(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(D.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const vi=Wn(-1),wi=Wn(1);function Si(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&dt(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Vt(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),f=u.index();i=u.parent.canReplaceWith(f,f+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function yt(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}yt(Be,zn,$n);yt(Be,Bn,_n);yt(Ln,Fn,qn,mi);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function xi(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s);if(!o)return!1;let l=r?t.tr:null;return ki(l,o,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function ki(n,e,t,r=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);s=new tt(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new tt(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=dt(s,t,r,e);return l?(n&&bi(n,e,l,i,t),!0):!1}function bi(n,e,t,r,i){let s=v.empty;for(let u=t.length-1;u>=0;u--)s=v.from(t[u].type.create(t[u].attrs,s));n.step(new z(e.start-(r?2:0),e.end,e.start,e.end,new w(s,0,0),t.length,!0));let o=0;for(let u=0;u<t.length;u++)t[u].type==i&&(o=u+1);let l=t.length-o,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,f=e.endIndex,h=!0;u<f;u++,h=!1)!h&&U(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Ei(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Mi(e,t,n,s):Ci(e,t,s):!0:!1}}function Mi(n,e,t,r){let i=n.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new z(s-1,o,s,o,new w(v.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new tt(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=ce(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return Z(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function Ci(n,e,t){let r=n.tr,i=t.parent;for(let d=t.end,m=t.endIndex-1,p=t.startIndex;m>p;m--)d-=i.child(m).nodeSize,r.delete(d-1,d+1);let s=r.doc.resolve(t.start),o=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?v.empty:v.from(i))))return!1;let f=s.pos,h=f+o.nodeSize;return r.step(new z(f-(l?1:0),h+(a?1:0),f+1,h-1,new w((l?v.empty:v.from(i.copy(v.empty))).append(a?v.empty:v.from(i.copy(v.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Ri(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=v.from(c?n.create():null),f=new w(v.from(n.create(null,v.from(l.type.create(null,u)))),c?3:1,0),h=s.start,d=s.end;t(e.tr.step(new z(h-(c?3:1),d,h,d,f,1,!0)).scrollIntoView())}return!0}}var Ti=Object.defineProperty,vt=(n,e)=>{for(var t in e)Ti(n,t,{get:e[t],enumerable:!0})};function Vn(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,s=t.storedMarks,t}}}var Ai=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:i}=t,s=this.buildProps(i);return Object.fromEntries(Object.entries(n).map(([o,l])=>[o,(...c)=>{const u=l(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:r,state:i}=this,{view:s}=r,o=[],l=!!n,a=n||i.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),o.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(t).map(([f,h])=>[f,(...m)=>{const p=this.buildProps(a,e),g=h(...m)(p);return o.push(g),u}])),run:c};return u}createCan(n){const{rawCommands:e,state:t}=this,r=!1,i=n||t.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(n,e=!0){const{rawCommands:t,editor:r,state:i}=this,{view:s}=r,o={tr:n,editor:r,view:s,state:Vn({state:i,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},Jn={};vt(Jn,{blur:()=>Ni,clearContent:()=>Oi,clearNodes:()=>Ii,command:()=>zi,createParagraphNear:()=>Pi,cut:()=>$i,deleteCurrentNode:()=>Di,deleteNode:()=>Bi,deleteRange:()=>_i,deleteSelection:()=>Li,enter:()=>Fi,exitCode:()=>qi,extendMarkRange:()=>Wi,first:()=>Vi,focus:()=>Hi,forEach:()=>Ui,insertContent:()=>Ki,insertContentAt:()=>Yi,joinBackward:()=>es,joinDown:()=>Qi,joinForward:()=>ts,joinItemBackward:()=>ns,joinItemForward:()=>rs,joinTextblockBackward:()=>is,joinTextblockForward:()=>ss,joinUp:()=>Zi,keyboardShortcut:()=>as,lift:()=>cs,liftEmptyBlock:()=>us,liftListItem:()=>fs,newlineInCode:()=>ds,resetAttributes:()=>hs,scrollIntoView:()=>ps,selectAll:()=>ms,selectNodeBackward:()=>gs,selectNodeForward:()=>ys,selectParentNode:()=>vs,selectTextblockEnd:()=>ws,selectTextblockStart:()=>Ss,setContent:()=>ks,setMark:()=>Fs,setMeta:()=>qs,setNode:()=>js,setNodeSelection:()=>Ws,setTextDirection:()=>Vs,setTextSelection:()=>Js,sinkListItem:()=>Hs,splitBlock:()=>Us,splitListItem:()=>Ks,toggleList:()=>Gs,toggleMark:()=>Xs,toggleNode:()=>Ys,toggleWrap:()=>Zs,undoInputRule:()=>Qs,unsetAllMarks:()=>eo,unsetMark:()=>to,unsetTextDirection:()=>no,updateAttributes:()=>ro,wrapIn:()=>io,wrapInList:()=>so});var Ni=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())==null||t.removeAllRanges())}),!0),Oi=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),Ii=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:s,$to:o})=>{n.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,f=c.resolve(u.map(a)),h=c.resolve(u.map(a+l.nodeSize)),d=f.blockRange(h);if(!d)return;const m=ce(d);if(l.type.isTextblock){const{defaultType:p}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(d.start,p)}(m||m===0)&&e.lift(d,m)})}),!0},zi=n=>e=>n(e),Pi=()=>({state:n,dispatch:e})=>Fn(n,e),$i=(n,e)=>({editor:t,tr:r})=>{const{state:i}=t,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new M.TextSelection(r.doc.resolve(Math.max(o-1,0)))),!0},Di=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const i=n.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const l=i.before(s),a=i.after(s);n.delete(l,a).scrollIntoView()}return!0}return!1};function P(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var Bi=n=>({tr:e,state:t,dispatch:r})=>{const i=P(n,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},_i=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},Li=()=>({state:n,dispatch:e})=>Be(n,e),Fi=()=>({commands:n})=>n.keyboardShortcut("Enter"),qi=()=>({state:n,dispatch:e})=>hi(n,e);function ji(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function ze(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:ji(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function Hn(n,e,t={}){return n.find(r=>r.type===e&&ze(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function Jt(n,e,t={}){return!!Hn(n,e,t)}function wt(n,e,t){var r;if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(u=>u.type===e)||(t=t||((r=i.node.marks[0])==null?void 0:r.attrs),!Hn([...i.node.marks],e,t)))return;let o=i.index,l=n.start()+i.offset,a=o+1,c=l+i.node.nodeSize;for(;o>0&&Jt([...n.parent.child(o-1).marks],e,t);)o-=1,l-=n.parent.child(o).nodeSize;for(;a<n.parent.childCount&&Jt([...n.parent.child(a).marks],e,t);)c+=n.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Q(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var Wi=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const s=Q(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:u}=l;if(i){const f=wt(a,s,e);if(f&&f.from<=c&&f.to>=u){const h=M.TextSelection.create(o,f.from,f.to);t.setSelection(h)}}return!0},Vi=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function St(n){return n instanceof M.TextSelection}function H(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Ji(n,e=null){if(!e)return null;const t=M.Selection.atStart(n),r=M.Selection.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const i=t.from,s=r.to;return e==="all"?M.TextSelection.create(n,H(0,i,s),H(n.content.size,i,s)):M.TextSelection.create(n,H(e,i,s),H(e,i,s))}function Un(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function _e(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Hi=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(_e()||Un())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!St(t.state.selection))return o(),!0;const l=Ji(i.doc,n)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Ui=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),Ki=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),Kn=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&Kn(r)}return n};function Me(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Kn(t)}function ye(n,e,t){if(n instanceof _.Node||n instanceof _.Fragment)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return _.Fragment.fromArray(n.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),ye("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const a=new _.Schema({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?_.DOMParser.fromSchema(a).parseSlice(Me(n),t.parseOptions):_.DOMParser.fromSchema(a).parse(Me(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=_.DOMParser.fromSchema(e);return t.slice?s.parseSlice(Me(n),t.parseOptions).content:s.parse(Me(n),t.parseOptions)}return ye("",e,t)}function Gi(n,e,t){const r=n.steps.length-1;if(r<e)return;const i=n.steps[r];if(!(i instanceof I||i instanceof z))return;const s=n.mapping.maps[r];let o=0;s.forEach((l,a,c,u)=>{o===0&&(o=u)}),n.setSelection(M.Selection.near(n.doc.resolve(o),t))}var Xi=n=>!("type"in n),Yi=(n,e,t)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{ye(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=ye(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:u,to:f}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},h=!0,d=!0;if((Xi(l)?l:[l]).forEach(g=>{g.check(),h=h?g.isText&&g.marks.length===0:!1,d=d?g.isBlock:!1}),u===f&&d){const{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,f+=1)}let p;if(h){if(Array.isArray(e))p=e.map(g=>g.text||"").join("");else if(e instanceof _.Fragment){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),p=g}else typeof e=="object"&&e&&e.text?p=e.text:p=e;r.insertText(p,u,f)}else{p=l;const g=r.doc.resolve(u),y=g.node(),S=g.parentOffset===0,k=y.isText||y.isTextblock,x=y.content.size>0;S&&k&&x&&(u=Math.max(0,u-1)),r.replaceWith(u,f,p)}t.updateSelection&&Gi(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:p}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:p})}return!0},Zi=()=>({state:n,dispatch:e})=>ui(n,e),Qi=()=>({state:n,dispatch:e})=>fi(n,e),es=()=>({state:n,dispatch:e})=>zn(n,e),ts=()=>({state:n,dispatch:e})=>Bn(n,e),ns=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Pe(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},rs=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Pe(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},is=()=>({state:n,dispatch:e})=>ai(n,e),ss=()=>({state:n,dispatch:e})=>ci(n,e);function Gn(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function ls(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,i,s,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))_e()||Gn()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var as=n=>({editor:e,view:t,tr:r,dispatch:i})=>{const s=ls(n).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function le(n,e,t={}){const{from:r,to:i,empty:s}=n.selection,o=e?P(e,n.schema):null,l=[];n.doc.nodesBetween(r,i,(f,h)=>{if(f.isText)return;const d=Math.max(r,h),m=Math.min(i,h+f.nodeSize);l.push({node:f,from:d,to:m})});const a=i-r,c=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>ze(f.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((f,h)=>f+h.to-h.from,0)>=a}var cs=(n,e={})=>({state:t,dispatch:r})=>{const i=P(n,t.schema);return le(t,i,e)?di(t,r):!1},us=()=>({state:n,dispatch:e})=>qn(n,e),fs=n=>({state:e,dispatch:t})=>{const r=P(n,e.schema);return Ei(r)(e,t)},ds=()=>({state:n,dispatch:e})=>Ln(n,e);function Le(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Ht(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}var hs=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const l=Le(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(s=P(n,r.schema)),l==="mark"&&(o=Q(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,f)=>{s&&s===u.type&&(a=!0,i&&t.setNodeMarkup(f,void 0,Ht(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(h=>{o===h.type&&(a=!0,i&&t.addMark(f,f+u.nodeSize,o.create(Ht(h.attrs,e))))})})}),a},ps=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),ms=()=>({tr:n,dispatch:e})=>{if(e){const t=new M.AllSelection(n.doc);n.setSelection(t)}return!0},gs=()=>({state:n,dispatch:e})=>$n(n,e),ys=()=>({state:n,dispatch:e})=>_n(n,e),vs=()=>({state:n,dispatch:e})=>gi(n,e),ws=()=>({state:n,dispatch:e})=>wi(n,e),Ss=()=>({state:n,dispatch:e})=>vi(n,e);function xs(n,e,t={},r={}){return ye(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var ks=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:a}=s;if(r.preserveWhitespace!=="full"){const c=xs(n,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}return o&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},n,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function Xn(n,e){const t=Q(e,n.schema),{from:r,to:i,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function Yn(n,e){const t=new Tn(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}function bs(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Es(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&r.push({node:i,pos:s})}),r}function Zn(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function ve(n){return e=>Zn(e.$from,n)}function ae(n,e,t){return n.config[e]===void 0&&n.parent?ae(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?ae(n.parent,e,t):null}):n.config[e]}function Ms(n){return typeof n=="function"}function j(n,e=void 0,...t){return Ms(n)?e?n.bind(e)(...t):n(...t):n}function Qn(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function er(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const l=s?String(s).split(" "):[],a=r[i]?r[i].split(" "):[],c=l.filter(u=>!a.includes(u));r[i]=[...a,...c].join(" ")}else if(i==="style"){const l=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[i]?r[i].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{const[f,h]=u.split(":").map(d=>d.trim());c.set(f,h)}),l.forEach(u=>{const[f,h]=u.split(":").map(d=>d.trim());c.set(f,h)}),r[i]=Array.from(c.entries()).map(([u,f])=>`${u}: ${f}`).join("; ")}else r[i]=s}),r},{})}function Cs(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>er(t,r),{})}function tr(n,e,t){const{from:r,to:i}=e,{blockSeparator:s=`
|
|
22
22
|
|
|
23
|
-
`,textSerializers:o={}}=t||{};let l="";return n.nodesBetween(r,i,(a,c,u,f)=>{var h;a.isBlock&&c>r&&(l+=s);const d=o==null?void 0:o[a.type.name];if(d)return u&&(l+=d({node:a,pos:c,parent:u,index:f,range:e})),!1;a.isText&&(l+=(h=a==null?void 0:a.text)==null?void 0:h.slice(Math.max(r,c)-c,i-c))}),l}function Ts(n,e){const t={from:0,to:n.content.size};return nr(n,t,e)}function rr(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function As(n,e){const t=P(e,n.schema),{from:r,to:i}=n.selection,s=[];n.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function Ns(n,e){const t=Le(typeof e=="string"?e:e.name,n.schema);return t==="node"?As(n,e):t==="mark"?Yn(n,e):{}}function Os(n,e=JSON.stringify){const t={};return n.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function Is(n){const e=Os(n);return e.length===1?e:e.filter((t,r)=>!e.filter((s,o)=>o!==r).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function ir(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=t[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),u=e.slice(s).map(a),f=e.invert().map(c,-1),h=e.invert().map(u);r.push({oldRange:{from:f,to:h},newRange:{from:c,to:u}})})}),Is(r)}function xt(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const s=t.resolve(n),o=wt(s,i.type);o&&r.push({mark:i,...o})}):t.nodesBetween(n,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var zs=(n,e,t,r=20)=>{const i=n.doc.resolve(t);let s=r,o=null;for(;s>0&&o===null;){const l=i.node(s);(l==null?void 0:l.type.name)===e?o=l:s-=1}return[o,s]};function Oe(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const i=n.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}function st(n,e,t={}){const{empty:r,ranges:i}=n.selection,s=e?Q(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(f=>s?s.name===f.type.name:!0).find(f=>ze(f.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:h})=>{const d=f.pos,m=h.pos;n.doc.nodesBetween(d,m,(p,g)=>{if(!p.isText&&!p.marks.length)return;const y=Math.max(d,g),S=Math.min(m,g+p.nodeSize),k=S-y;o+=k,l.push(...p.marks.map(x=>({mark:x,from:y,to:S})))})}),o===0)return!1;const a=l.filter(f=>s?s.name===f.mark.type.name:!0).filter(f=>ze(f.mark.attrs,t,{strict:!1})).reduce((f,h)=>f+h.to-h.from,0),c=l.filter(f=>s?f.mark.type!==s&&f.mark.type.excludes(s):!0).reduce((f,h)=>f+h.to-h.from,0);return(a>0?a+c:a)>=o}function Ps(n,e,t={}){if(!e)return le(n,null,t)||st(n,null,t);const r=Le(e,n.schema);return r==="node"?le(n,e,t):r==="mark"?st(n,e,t):!1}var $s=(n,e)=>{const{$from:t,$to:r,$anchor:i}=n.selection;if(e){const s=ve(l=>l.type.name===e)(n.selection);if(!s)return!1;const o=n.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},Ds=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function ot(n,e){const{nodeExtensions:t}=er(e),r=t.find(o=>o.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=j(ae(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function kt(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(s=>{i!==!1&&(kt(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function Bs(n){return n instanceof M.NodeSelection}var sr=class or{constructor(e){this.position=e}static fromJSON(e){return new or(e.position)}toJSON(){return{position:this.position}}};function _s(n,e){const t=e.mapping.mapResult(n.position);return{position:new sr(t.pos),mapResult:t}}function Ls(n,e,t){const i=n.state.doc.content.size,s=H(e,0,i),o=H(t,0,i),l=n.coordsAtPos(s),a=n.coordsAtPos(o,-1),c=Math.min(l.top,a.top),u=Math.max(l.bottom,a.bottom),f=Math.min(l.left,a.left),h=Math.max(l.right,a.right),d=h-f,m=u-c,y={top:c,bottom:u,left:f,right:h,width:d,height:m,x:f,y:c};return{...y,toJSON:()=>y}}function Fs(n,e,t){var r;const{selection:i}=e;let s=null;if(St(i)&&(s=i.$cursor),s){const l=(r=n.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.type.excludes(t)))}const{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,f,h)=>{if(c)return!1;if(u.isInline){const d=!h||h.type.allowsMarkType(t),m=!!t.isInSet(u.marks)||!u.marks.some(p=>p.type.excludes(t));c=d&&m}return!c}),c})}var qs=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Q(n,r.schema);if(i)if(o){const c=Yn(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,f=c.$to.pos;r.doc.nodesBetween(u,f,(h,d)=>{const m=Math.max(d,u),p=Math.min(d+h.nodeSize,f);h.marks.find(y=>y.type===a)?h.marks.forEach(y=>{a===y.type&&t.addMark(m,p,a.create({...y.attrs,...e}))}):t.addMark(m,p,a.create(e))})});return Fs(r,t,a)},js=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Ws=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const s=P(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>Vt(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Vt(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Vs=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=H(n,0,r.content.size),s=M.NodeSelection.create(r,i);e.setSelection(s)}return!0},Js=(n,e)=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),i&&t.doc.nodesBetween(o,l,(a,c)=>{a.isText||t.setNodeMarkup(c,void 0,{...a.attrs,dir:n})}),!0},Hs=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,o=M.TextSelection.atStart(r).from,l=M.TextSelection.atEnd(r).to,a=H(i,o,l),c=H(s,o,l),u=M.TextSelection.create(r,a,c);e.setSelection(u)}return!0},Us=n=>({state:e,dispatch:t})=>{const r=P(n,e.schema);return Ti(r)(e,t)};function Ut(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(i=>e==null?void 0:e.includes(i.type.name));n.tr.ensureMarks(r)}}var Ks=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,u=Oe(c,l.node().type.name,l.node().attrs);if(s instanceof M.NodeSelection&&s.node.isBlock)return!l.parentOffset||!U(o,l.pos)?!1:(r&&(n&&Ut(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=a.parentOffset===a.parent.content.size,h=l.depth===0?void 0:Es(l.node(-1).contentMatchAt(l.indexAfter(-1)));let d=f&&h?[{type:h,attrs:u}]:void 0,m=U(e.doc,e.mapping.map(l.pos),1,d);if(!d&&!m&&U(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)&&(m=!0,d=h?[{type:h,attrs:u}]:void 0),r){if(m&&(s instanceof M.TextSelection&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,d),h&&!f&&!l.parentOffset&&l.parent.type!==h)){const p=e.mapping.map(l.before()),g=e.doc.resolve(p);l.node(-1).canReplaceWith(g.index(),g.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}n&&Ut(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return m},Gs=(n,e={})=>({tr:t,state:r,dispatch:i,editor:s})=>{var o;const l=P(n,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const f=a.node(-1);if(f.type!==l)return!1;const h=s.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let y=_.Fragment.empty;const S=a.index(-1)?1:a.index(-2)?2:3;for(let O=a.depth-S;O>=a.depth-3;O-=1)y=_.Fragment.from(a.node(O).copy(y));const k=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,x={...Oe(h,a.node().type.name,a.node().attrs),...e},E=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(x))||void 0;y=y.append(_.Fragment.from(l.createAndFill(null,E)||void 0));const b=a.before(a.depth-(S-1));t.replace(b,a.after(-k),new _.Slice(y,4-S,0));let C=-1;t.doc.nodesBetween(b,t.doc.content.size,(O,K)=>{if(C>-1)return!1;O.isTextblock&&O.content.size===0&&(C=K+1)}),C>-1&&t.setSelection(M.TextSelection.near(t.doc.resolve(C))),t.scrollIntoView()}return!0}const d=c.pos===a.end()?f.contentMatchAt(0).defaultType:null,m={...Oe(h,f.type.name,f.attrs),...e},p={...Oe(h,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const g=d?[{type:l,attrs:m},{type:d,attrs:p}]:[{type:l,attrs:m}];if(!U(t.doc,a.pos,2))return!1;if(i){const{selection:y,storedMarks:S}=r,{splittableMarks:k}=s.extensionManager,x=S||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!x||!i)return!0;const E=x.filter(b=>k.includes(b.type.name));t.ensureMarks(E)}return!0},Ge=(n,e)=>{const t=ve(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Z(n.doc,t.pos)&&n.join(t.pos),!0},Xe=(n,e)=>{const t=ve(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Z(n.doc,r)&&n.join(r),!0},Xs=(n,e,t,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:f,splittableMarks:h}=i.extensionManager,d=P(n,o.schema),m=P(e,o.schema),{selection:p,storedMarks:g}=o,{$from:y,$to:S}=p,k=y.blockRange(S),x=g||p.$to.parentOffset&&p.$from.marks();if(!k)return!1;const E=ve(b=>ot(b.type.name,f))(p);if(k.depth>=1&&E&&k.depth-E.depth<=1){if(E.node.type===d)return c.liftListItem(m);if(ot(E.node.type.name,f)&&d.validContent(E.node.content)&&l)return a().command(()=>(s.setNodeMarkup(E.pos,d),!0)).command(()=>Ge(s,d)).command(()=>Xe(s,d)).run()}return!t||!x||!l?a().command(()=>u().wrapInList(d,r)?!0:c.clearNodes()).wrapInList(d,r).command(()=>Ge(s,d)).command(()=>Xe(s,d)).run():a().command(()=>{const b=u().wrapInList(d,r),C=x.filter(O=>h.includes(O.type.name));return s.ensureMarks(C),b?!0:c.clearNodes()}).wrapInList(d,r).command(()=>Ge(s,d)).command(()=>Xe(s,d)).run()},Ys=(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Q(n,r.schema);return st(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},Zs=(n,e,t={})=>({state:r,commands:i})=>{const s=P(n,r.schema),o=P(e,r.schema),l=le(r,s,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...t})},Qs=(n,e={})=>({state:t,commands:r})=>{const i=P(n,t.schema);return le(t,i,e)?r.lift(i):r.wrapIn(i,e)},eo=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const i=t[r];let s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){const o=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){const a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},to=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},no=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Q(n,r.schema),{$from:c,empty:u,ranges:f}=l;if(!i)return!0;if(u&&o){let{from:h,to:d}=l;const m=(s=c.marks().find(g=>g.type===a))==null?void 0:s.attrs,p=wt(c,a,m);p&&(h=p.from,d=p.to),t.removeMark(h,d,a)}else f.forEach(h=>{t.removeMark(h.$from.pos,h.$to.pos,a)});return t.removeStoredMark(a),!0},ro=n=>({tr:e,state:t,dispatch:r})=>{const{selection:i}=t;let s,o;return typeof n=="number"?(s=n,o=n):n&&"from"in n&&"to"in n?(s=n.from,o=n.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},io=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const l=Le(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(s=P(n,r.schema)),l==="mark"&&(o=Q(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{const u=c.$from.pos,f=c.$to.pos;let h,d,m,p;t.selection.empty?r.doc.nodesBetween(u,f,(g,y)=>{s&&s===g.type&&(a=!0,m=Math.max(y,u),p=Math.min(y+g.nodeSize,f),h=y,d=g)}):r.doc.nodesBetween(u,f,(g,y)=>{y<u&&s&&s===g.type&&(a=!0,m=Math.max(y,u),p=Math.min(y+g.nodeSize,f),h=y,d=g),y>=u&&y<=f&&(s&&s===g.type&&(a=!0,i&&t.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(S=>{if(o===S.type&&(a=!0,i)){const k=Math.max(y,u),x=Math.min(y+g.nodeSize,f);t.addMark(k,x,o.create({...S.attrs,...e}))}}))}),d&&(h!==void 0&&i&&t.setNodeMarkup(h,void 0,{...d.attrs,...e}),o&&d.marks.length&&d.marks.forEach(g=>{o===g.type&&i&&t.addMark(m,p,o.create({...g.attrs,...e}))}))}),a},so=(n,e={})=>({state:t,dispatch:r})=>{const i=P(n,t.schema);return xi(i,e)(t,r)},oo=(n,e={})=>({state:t,dispatch:r})=>{const i=P(n,t.schema);return ki(i,e)(t,r)},we=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}};function lo(n){return Object.prototype.toString.call(n).slice(8,-1)}function Ce(n){return lo(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function lr(n,e){const t={...n};return Ce(n)&&Ce(e)&&Object.keys(e).forEach(r=>{Ce(e[r])&&Ce(n[r])?t[r]=lr(n[r],e[r]):t[r]=e[r]}),t}var bt=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...j(ae(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...j(ae(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>lr(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},ao=class ar extends bt{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new ar(t)}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function co(n){return typeof n=="number"}var Et=class{constructor(n){this.find=n.find,this.handler=n.handler}},uo={};vt(uo,{ClipboardTextSerializer:()=>fo,Commands:()=>ho,Delete:()=>po,Drop:()=>mo,Editable:()=>go,FocusEvents:()=>yo,Keymap:()=>vo,Paste:()=>wo,Tabindex:()=>So,TextDirection:()=>xo,focusEventsPluginKey:()=>ur});var W=class cr extends bt{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new cr(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},fo=W.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(u=>u.$from.pos)),l=Math.max(...s.map(u=>u.$to.pos)),a=rr(t);return nr(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),ho=W.create({name:"commands",addCommands(){return{...Hn}}}),po=W.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,i;const s=()=>{var o,l,a,c;if((c=(a=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,n))!=null?c:n.getMeta("y-sync$"))return;const u=Zn(n.before,[n,...e]);ir(u).forEach(d=>{u.mapping.mapResult(d.oldRange.from).deletedAfter&&u.mapping.mapResult(d.oldRange.to).deletedBefore&&u.before.nodesBetween(d.oldRange.from,d.oldRange.to,(m,p)=>{const g=p+m.nodeSize-2,y=d.oldRange.from<=p&&g<=d.oldRange.to;this.editor.emit("delete",{type:"node",node:m,from:p,to:g,newFrom:u.mapping.map(p),newTo:u.mapping.map(g),deletedRange:d.oldRange,newRange:d.newRange,partial:!y,editor:this.editor,transaction:n,combinedTransform:u})})});const h=u.mapping;u.steps.forEach((d,m)=>{var p,g;if(d instanceof q){const y=h.slice(m).map(d.from,-1),S=h.slice(m).map(d.to),k=h.invert().map(y,-1),x=h.invert().map(S),E=(p=u.doc.nodeAt(y-1))==null?void 0:p.marks.some(C=>C.eq(d.mark)),b=(g=u.doc.nodeAt(S))==null?void 0:g.marks.some(C=>C.eq(d.mark));this.editor.emit("delete",{type:"mark",mark:d.mark,from:d.from,to:d.to,deletedRange:{from:k,to:x},newRange:{from:y,to:S},partial:!!(b||E),editor:this.editor,transaction:n,combinedTransform:u})}})};(i=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),mo=W.create({name:"drop",addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),go=W.create({name:"editable",addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("editable"),props:{editable:()=>this.editor.options.editable}})]}}),ur=new M.PluginKey("focusEvents"),yo=W.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new M.Plugin({key:ur,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),vo=W.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:f}=a,{pos:h,parent:d}=f,m=f.parent.isTextblock&&h>0?l.doc.resolve(h-1):f,p=m.parent.type.spec.isolating,g=f.pos-f.parentOffset,y=p&&m.parent.childCount===1?g===f.pos:M.Selection.atStart(c).from===h;return!u||!d.type.isTextblock||d.textContent.length||!y||y&&f.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return _e()||Xn()?s:i},addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(p=>p.getMeta("composition")))return;const r=n.some(p=>p.docChanged)&&!e.doc.eq(t.doc),i=n.some(p=>p.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:o,to:l}=e.selection,a=M.Selection.atStart(e.doc).from,c=M.Selection.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!kt(t.doc))return;const h=t.tr,d=Jn({state:t,transaction:h}),{commands:m}=new Ni({editor:this.editor,state:d});if(m.clearNodes(),!!h.steps.length)return h}})]}}),wo=W.create({name:"paste",addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),So=W.create({name:"tabindex",addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),xo=W.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=er(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}});function ko(n){return new we({find:n.find,handler:({state:e,range:t,match:r})=>{const i=j(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),u=c+o.length;if(xt(t.from,t.to,e.doc).filter(d=>d.mark.type.excluded.find(p=>p===n.type&&p!==d.mark.type)).filter(d=>d.to>c).length)return null;u<t.to&&s.delete(u,t.to),c>t.from&&s.delete(t.from+a,c);const h=t.from+a+o.length;s.addMark(t.from+a,h,n.type.create(i||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}function bo(n){return new we({find:n.find,handler:({state:e,range:t,match:r})=>{const i=j(n.getAttributes,void 0,r)||{},{tr:s}=e,o=t.from;let l=t.to;const a=n.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>l?u=l:l=u+r[1].length;const f=r[0][r[0].length-1];s.insertText(f,o+r[0].length-1),s.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?o:o-1;s.insert(c,n.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:n.undoable})}function Eo(n){return new we({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=j(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)},undoable:n.undoable})}function Mo(n){return new we({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=j(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&dt(a,n.type,s);if(!c)return null;if(o.wrap(a,c),n.keepMarks&&n.editor){const{selection:f,storedMarks:h}=e,{splittableMarks:d}=n.editor.extensionManager,m=h||f.$to.parentOffset&&f.$from.marks();if(m){const p=m.filter(g=>d.includes(g.type.name));o.ensureMarks(p)}}if(n.keepAttributes){const f=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,s).run()}const u=o.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Z(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(t.from-1)},undoable:n.undoable})}var Co=n=>"touches"in n,Ro=class{constructor(n){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.touches[0];if(!a)return;const c=a.clientX-this.startX,u=a.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,t,r,i,s,o;this.node=n.node,this.editor=n.editor,this.element=n.element,this.contentElement=n.contentElement,this.getPos=n.getPos,this.onResize=n.onResize,this.onCommit=n.onCommit,this.onUpdate=n.onUpdate,(e=n.options)!=null&&e.min&&(this.minSize={...this.minSize,...n.options.min}),(t=n.options)!=null&&t.max&&(this.maxSize=n.options.max),(r=n==null?void 0:n.options)!=null&&r.directions&&(this.directions=n.options.directions),(i=n.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=n.options.preserveAspectRatio),(s=n.options)!=null&&s.className&&(this.classNames={container:n.options.className.container||"",wrapper:n.options.className.wrapper||"",handle:n.options.className.handle||"",resizing:n.options.className.resizing||""}),(o=n.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=n.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){return this.contentElement}handleEditorUpdate(){const n=this.editor.isEditable;n!==this.lastEditableState&&(this.lastEditableState=n,n?n&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(n,e,t){return n.type!==this.node.type?!1:(this.node=n,this.onUpdate?this.onUpdate(n,e,t):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const n=document.createElement("div");return n.dataset.resizeContainer="",n.dataset.node=this.node.type.name,n.style.display="flex",this.classNames.container&&(n.className=this.classNames.container),n.appendChild(this.wrapper),n}createWrapper(){const n=document.createElement("div");return n.style.position="relative",n.style.display="block",n.dataset.resizeWrapper="",this.classNames.wrapper&&(n.className=this.classNames.wrapper),n.appendChild(this.element),n}createHandle(n){const e=document.createElement("div");return e.dataset.resizeHandle=n,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(n,e){const t=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),s=e.includes("right");t&&(n.style.top="0"),r&&(n.style.bottom="0"),i&&(n.style.left="0"),s&&(n.style.right="0"),(e==="top"||e==="bottom")&&(n.style.left="0",n.style.right="0"),(e==="left"||e==="right")&&(n.style.top="0",n.style.bottom="0")}attachHandles(){this.directions.forEach(n=>{let e;this.createCustomHandle?e=this.createCustomHandle(n):e=this.createHandle(n),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${n}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(n)),this.createCustomHandle||this.positionHandle(e,n),e.addEventListener("mousedown",t=>this.handleResizeStart(t,n)),e.addEventListener("touchstart",t=>this.handleResizeStart(t,n)),this.handleMap.set(n,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(n=>n.remove()),this.handleMap.clear()}applyInitialSize(){const n=this.node.attrs.width,e=this.node.attrs.height;n?(this.element.style.width=`${n}px`,this.initialWidth=n):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(n,e){n.preventDefault(),n.stopPropagation(),this.isResizing=!0,this.activeHandle=e,Co(n)?(this.startX=n.touches[0].clientX,this.startY=n.touches[0].clientY):(this.startX=n.clientX,this.startY=n.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(n,e){if(!this.activeHandle)return;const t=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,n,e),s=this.applyConstraints(r,i,t);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(n,e,t){let r=this.startWidth,i=this.startHeight;const s=n.includes("right"),o=n.includes("left"),l=n.includes("bottom"),a=n.includes("top");return s?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+t:a&&(i=this.startHeight-t),(n==="right"||n==="left")&&(r=this.startWidth+(s?e:-e)),(n==="top"||n==="bottom")&&(i=this.startHeight+(l?t:-t)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,n):{width:r,height:i}}applyConstraints(n,e,t){var r,i,s,o;if(!t){let c=Math.max(this.minSize.width,n),u=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(c=Math.min(this.maxSize.width,c)),(i=this.maxSize)!=null&&i.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let l=n,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(n,e,t){const r=t==="left"||t==="right",i=t==="top"||t==="bottom";return r?{width:n,height:n/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:n,height:n/this.aspectRatio}}};function To(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof M.NodeSelection){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}function Ao(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var No={};vt(No,{createAtomBlockMarkdownSpec:()=>Oo,createBlockMarkdownSpec:()=>Io,createInlineMarkdownSpec:()=>fr,parseAttributes:()=>Mt,parseIndentedBlocks:()=>dr,renderNestedMarkdownContent:()=>hr,serializeAttributes:()=>Ct});function Mt(n){if(!(n!=null&&n.trim()))return{};const e={},t=[],r=n.replace(/["']([^"']*)["']/g,c=>(t.push(c),`__QUOTED_${t.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const c=i.map(u=>u.trim().slice(1));e.class=c.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,c,u])=>{var f;const h=parseInt(((f=u.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),d=t[h];d&&(e[c]=d.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Ct(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function Oo(n){const{nodeName:e,name:t,parseAttributes:r=Mt,serializeAttributes:i=Ct,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=n,a=t||e,c=u=>{if(!l)return u;const f={};return l.forEach(h=>{h in u&&(f[h]=u[h])}),f};return{parseMarkdown:(u,f)=>{const h={...s,...u.attributes};return f.createNode(e,h,[])},markdownTokenizer:{name:e,level:"block",start(u){var f;const h=new RegExp(`^:::${a}(?:\\s|$)`,"m"),d=(f=u.match(h))==null?void 0:f.index;return d!==void 0?d:-1},tokenize(u,f,h){const d=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),m=u.match(d);if(!m)return;const p=m[1]||"",g=r(p);if(!o.find(S=>!(S in g)))return{type:e,raw:m[0],attributes:g}}},renderMarkdown:u=>{const f=c(u.attrs||{}),h=i(f),d=h?` {${h}}`:"";return`:::${a}${d} :::`}}}function Io(n){const{nodeName:e,name:t,getContent:r,parseAttributes:i=Mt,serializeAttributes:s=Ct,defaultAttributes:o={},content:l="block",allowedAttributes:a}=n,c=t||e,u=f=>{if(!a)return f;const h={};return a.forEach(d=>{d in f&&(h[d]=f[d])}),h};return{parseMarkdown:(f,h)=>{let d;if(r){const p=r(f);d=typeof p=="string"?[{type:"text",text:p}]:p}else l==="block"?d=h.parseChildren(f.tokens||[]):d=h.parseInline(f.tokens||[]);const m={...o,...f.attributes};return h.createNode(e,m,d)},markdownTokenizer:{name:e,level:"block",start(f){var h;const d=new RegExp(`^:::${c}`,"m"),m=(h=f.match(d))==null?void 0:h.index;return m!==void 0?m:-1},tokenize(f,h,d){var m;const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=f.match(p);if(!g)return;const[y,S=""]=g,k=i(S);let x=1;const E=y.length;let b="";const C=/^:::([\w-]*)(\s.*)?/gm,O=f.slice(E);for(C.lastIndex=0;;){const K=C.exec(O);if(K===null)break;const Se=K.index,vr=K[1];if(!((m=K[2])!=null&&m.endsWith(":::"))){if(vr)x+=1;else if(x-=1,x===0){const Tt=O.slice(0,Se);b=Tt.trim();const wr=f.slice(0,E+Se+K[0].length);let G=[];if(b)if(l==="block")for(G=d.blockTokens(Tt),G.forEach(V=>{V.text&&(!V.tokens||V.tokens.length===0)&&(V.tokens=d.inlineTokens(V.text))});G.length>0;){const V=G[G.length-1];if(V.type==="paragraph"&&(!V.text||V.text.trim()===""))G.pop();else break}else G=d.inlineTokens(b);return{type:e,raw:wr,attributes:k,content:b,tokens:G}}}}}},renderMarkdown:(f,h)=>{const d=u(f.attrs||{}),m=s(d),p=m?` {${m}}`:"",g=h.renderChildren(f.content||[],`
|
|
23
|
+
`,textSerializers:o={}}=t||{};let l="";return n.nodesBetween(r,i,(a,c,u,f)=>{var h;a.isBlock&&c>r&&(l+=s);const d=o==null?void 0:o[a.type.name];if(d)return u&&(l+=d({node:a,pos:c,parent:u,index:f,range:e})),!1;a.isText&&(l+=(h=a==null?void 0:a.text)==null?void 0:h.slice(Math.max(r,c)-c,i-c))}),l}function Rs(n,e){const t={from:0,to:n.content.size};return tr(n,t,e)}function nr(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Ts(n,e){const t=P(e,n.schema),{from:r,to:i}=n.selection,s=[];n.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function As(n,e){const t=Le(typeof e=="string"?e:e.name,n.schema);return t==="node"?Ts(n,e):t==="mark"?Xn(n,e):{}}function Ns(n,e=JSON.stringify){const t={};return n.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function Os(n){const e=Ns(n);return e.length===1?e:e.filter((t,r)=>!e.filter((s,o)=>o!==r).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function rr(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=t[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),u=e.slice(s).map(a),f=e.invert().map(c,-1),h=e.invert().map(u);r.push({oldRange:{from:f,to:h},newRange:{from:c,to:u}})})}),Os(r)}function xt(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const s=t.resolve(n),o=wt(s,i.type);o&&r.push({mark:i,...o})}):t.nodesBetween(n,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var Is=(n,e,t,r=20)=>{const i=n.doc.resolve(t);let s=r,o=null;for(;s>0&&o===null;){const l=i.node(s);(l==null?void 0:l.type.name)===e?o=l:s-=1}return[o,s]};function Oe(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const i=n.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}function st(n,e,t={}){const{empty:r,ranges:i}=n.selection,s=e?Q(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(f=>s?s.name===f.type.name:!0).find(f=>ze(f.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:h})=>{const d=f.pos,m=h.pos;n.doc.nodesBetween(d,m,(p,g)=>{if(!p.isText&&!p.marks.length)return;const y=Math.max(d,g),S=Math.min(m,g+p.nodeSize),k=S-y;o+=k,l.push(...p.marks.map(x=>({mark:x,from:y,to:S})))})}),o===0)return!1;const a=l.filter(f=>s?s.name===f.mark.type.name:!0).filter(f=>ze(f.mark.attrs,t,{strict:!1})).reduce((f,h)=>f+h.to-h.from,0),c=l.filter(f=>s?f.mark.type!==s&&f.mark.type.excludes(s):!0).reduce((f,h)=>f+h.to-h.from,0);return(a>0?a+c:a)>=o}function zs(n,e,t={}){if(!e)return le(n,null,t)||st(n,null,t);const r=Le(e,n.schema);return r==="node"?le(n,e,t):r==="mark"?st(n,e,t):!1}var Ps=(n,e)=>{const{$from:t,$to:r,$anchor:i}=n.selection;if(e){const s=ve(l=>l.type.name===e)(n.selection);if(!s)return!1;const o=n.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},$s=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function ot(n,e){const{nodeExtensions:t}=Qn(e),r=t.find(o=>o.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=j(ae(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function kt(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(s=>{i!==!1&&(kt(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function Ds(n){return n instanceof M.NodeSelection}var ir=class sr{constructor(e){this.position=e}static fromJSON(e){return new sr(e.position)}toJSON(){return{position:this.position}}};function Bs(n,e){const t=e.mapping.mapResult(n.position);return{position:new ir(t.pos),mapResult:t}}function _s(n,e,t){const i=n.state.doc.content.size,s=H(e,0,i),o=H(t,0,i),l=n.coordsAtPos(s),a=n.coordsAtPos(o,-1),c=Math.min(l.top,a.top),u=Math.max(l.bottom,a.bottom),f=Math.min(l.left,a.left),h=Math.max(l.right,a.right),d=h-f,m=u-c,y={top:c,bottom:u,left:f,right:h,width:d,height:m,x:f,y:c};return{...y,toJSON:()=>y}}function Ls(n,e,t){var r;const{selection:i}=e;let s=null;if(St(i)&&(s=i.$cursor),s){const l=(r=n.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.type.excludes(t)))}const{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,f,h)=>{if(c)return!1;if(u.isInline){const d=!h||h.type.allowsMarkType(t),m=!!t.isInSet(u.marks)||!u.marks.some(p=>p.type.excludes(t));c=d&&m}return!c}),c})}var Fs=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Q(n,r.schema);if(i)if(o){const c=Xn(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,f=c.$to.pos;r.doc.nodesBetween(u,f,(h,d)=>{const m=Math.max(d,u),p=Math.min(d+h.nodeSize,f);h.marks.find(y=>y.type===a)?h.marks.forEach(y=>{a===y.type&&t.addMark(m,p,a.create({...y.attrs,...e}))}):t.addMark(m,p,a.create(e))})});return Ls(r,t,a)},qs=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),js=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const s=P(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>Vt(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Vt(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Ws=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=H(n,0,r.content.size),s=M.NodeSelection.create(r,i);e.setSelection(s)}return!0},Vs=(n,e)=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),i&&t.doc.nodesBetween(o,l,(a,c)=>{a.isText||t.setNodeMarkup(c,void 0,{...a.attrs,dir:n})}),!0},Js=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,o=M.TextSelection.atStart(r).from,l=M.TextSelection.atEnd(r).to,a=H(i,o,l),c=H(s,o,l),u=M.TextSelection.create(r,a,c);e.setSelection(u)}return!0},Hs=n=>({state:e,dispatch:t})=>{const r=P(n,e.schema);return Ri(r)(e,t)};function Ut(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(i=>e==null?void 0:e.includes(i.type.name));n.tr.ensureMarks(r)}}var Us=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,u=Oe(c,l.node().type.name,l.node().attrs);if(s instanceof M.NodeSelection&&s.node.isBlock)return!l.parentOffset||!U(o,l.pos)?!1:(r&&(n&&Ut(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=a.parentOffset===a.parent.content.size,h=l.depth===0?void 0:bs(l.node(-1).contentMatchAt(l.indexAfter(-1)));let d=f&&h?[{type:h,attrs:u}]:void 0,m=U(e.doc,e.mapping.map(l.pos),1,d);if(!d&&!m&&U(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)&&(m=!0,d=h?[{type:h,attrs:u}]:void 0),r){if(m&&(s instanceof M.TextSelection&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,d),h&&!f&&!l.parentOffset&&l.parent.type!==h)){const p=e.mapping.map(l.before()),g=e.doc.resolve(p);l.node(-1).canReplaceWith(g.index(),g.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}n&&Ut(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return m},Ks=(n,e={})=>({tr:t,state:r,dispatch:i,editor:s})=>{var o;const l=P(n,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const f=a.node(-1);if(f.type!==l)return!1;const h=s.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let y=_.Fragment.empty;const S=a.index(-1)?1:a.index(-2)?2:3;for(let O=a.depth-S;O>=a.depth-3;O-=1)y=_.Fragment.from(a.node(O).copy(y));const k=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,x={...Oe(h,a.node().type.name,a.node().attrs),...e},E=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(x))||void 0;y=y.append(_.Fragment.from(l.createAndFill(null,E)||void 0));const b=a.before(a.depth-(S-1));t.replace(b,a.after(-k),new _.Slice(y,4-S,0));let C=-1;t.doc.nodesBetween(b,t.doc.content.size,(O,K)=>{if(C>-1)return!1;O.isTextblock&&O.content.size===0&&(C=K+1)}),C>-1&&t.setSelection(M.TextSelection.near(t.doc.resolve(C))),t.scrollIntoView()}return!0}const d=c.pos===a.end()?f.contentMatchAt(0).defaultType:null,m={...Oe(h,f.type.name,f.attrs),...e},p={...Oe(h,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const g=d?[{type:l,attrs:m},{type:d,attrs:p}]:[{type:l,attrs:m}];if(!U(t.doc,a.pos,2))return!1;if(i){const{selection:y,storedMarks:S}=r,{splittableMarks:k}=s.extensionManager,x=S||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!x||!i)return!0;const E=x.filter(b=>k.includes(b.type.name));t.ensureMarks(E)}return!0},Ge=(n,e)=>{const t=ve(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Z(n.doc,t.pos)&&n.join(t.pos),!0},Xe=(n,e)=>{const t=ve(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Z(n.doc,r)&&n.join(r),!0},Gs=(n,e,t,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:f,splittableMarks:h}=i.extensionManager,d=P(n,o.schema),m=P(e,o.schema),{selection:p,storedMarks:g}=o,{$from:y,$to:S}=p,k=y.blockRange(S),x=g||p.$to.parentOffset&&p.$from.marks();if(!k)return!1;const E=ve(b=>ot(b.type.name,f))(p);if(k.depth>=1&&E&&k.depth-E.depth<=1){if(E.node.type===d)return c.liftListItem(m);if(ot(E.node.type.name,f)&&d.validContent(E.node.content)&&l)return a().command(()=>(s.setNodeMarkup(E.pos,d),!0)).command(()=>Ge(s,d)).command(()=>Xe(s,d)).run()}return!t||!x||!l?a().command(()=>u().wrapInList(d,r)?!0:c.clearNodes()).wrapInList(d,r).command(()=>Ge(s,d)).command(()=>Xe(s,d)).run():a().command(()=>{const b=u().wrapInList(d,r),C=x.filter(O=>h.includes(O.type.name));return s.ensureMarks(C),b?!0:c.clearNodes()}).wrapInList(d,r).command(()=>Ge(s,d)).command(()=>Xe(s,d)).run()},Xs=(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Q(n,r.schema);return st(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},Ys=(n,e,t={})=>({state:r,commands:i})=>{const s=P(n,r.schema),o=P(e,r.schema),l=le(r,s,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...t})},Zs=(n,e={})=>({state:t,commands:r})=>{const i=P(n,t.schema);return le(t,i,e)?r.lift(i):r.wrapIn(i,e)},Qs=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const i=t[r];let s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){const o=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){const a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},eo=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},to=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Q(n,r.schema),{$from:c,empty:u,ranges:f}=l;if(!i)return!0;if(u&&o){let{from:h,to:d}=l;const m=(s=c.marks().find(g=>g.type===a))==null?void 0:s.attrs,p=wt(c,a,m);p&&(h=p.from,d=p.to),t.removeMark(h,d,a)}else f.forEach(h=>{t.removeMark(h.$from.pos,h.$to.pos,a)});return t.removeStoredMark(a),!0},no=n=>({tr:e,state:t,dispatch:r})=>{const{selection:i}=t;let s,o;return typeof n=="number"?(s=n,o=n):n&&"from"in n&&"to"in n?(s=n.from,o=n.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},ro=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const l=Le(typeof n=="string"?n:n.name,r.schema);if(!l)return!1;l==="node"&&(s=P(n,r.schema)),l==="mark"&&(o=Q(n,r.schema));let a=!1;return t.selection.ranges.forEach(c=>{const u=c.$from.pos,f=c.$to.pos;let h,d,m,p;t.selection.empty?r.doc.nodesBetween(u,f,(g,y)=>{s&&s===g.type&&(a=!0,m=Math.max(y,u),p=Math.min(y+g.nodeSize,f),h=y,d=g)}):r.doc.nodesBetween(u,f,(g,y)=>{y<u&&s&&s===g.type&&(a=!0,m=Math.max(y,u),p=Math.min(y+g.nodeSize,f),h=y,d=g),y>=u&&y<=f&&(s&&s===g.type&&(a=!0,i&&t.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(S=>{if(o===S.type&&(a=!0,i)){const k=Math.max(y,u),x=Math.min(y+g.nodeSize,f);t.addMark(k,x,o.create({...S.attrs,...e}))}}))}),d&&(h!==void 0&&i&&t.setNodeMarkup(h,void 0,{...d.attrs,...e}),o&&d.marks.length&&d.marks.forEach(g=>{o===g.type&&i&&t.addMark(m,p,o.create({...g.attrs,...e}))}))}),a},io=(n,e={})=>({state:t,dispatch:r})=>{const i=P(n,t.schema);return Si(i,e)(t,r)},so=(n,e={})=>({state:t,dispatch:r})=>{const i=P(n,t.schema);return xi(i,e)(t,r)},we=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}};function oo(n){return Object.prototype.toString.call(n).slice(8,-1)}function Ce(n){return oo(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function or(n,e){const t={...n};return Ce(n)&&Ce(e)&&Object.keys(e).forEach(r=>{Ce(e[r])&&Ce(n[r])?t[r]=or(n[r],e[r]):t[r]=e[r]}),t}var bt=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...j(ae(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...j(ae(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>or(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},lo=class lr extends bt{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new lr(t)}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function ao(n){return typeof n=="number"}var Et=class{constructor(n){this.find=n.find,this.handler=n.handler}},co={};vt(co,{ClipboardTextSerializer:()=>uo,Commands:()=>fo,Delete:()=>ho,Drop:()=>po,Editable:()=>mo,FocusEvents:()=>go,Keymap:()=>yo,Paste:()=>vo,Tabindex:()=>wo,TextDirection:()=>So,focusEventsPluginKey:()=>cr});var W=class ar extends bt{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new ar(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},uo=W.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(u=>u.$from.pos)),l=Math.max(...s.map(u=>u.$to.pos)),a=nr(t);return tr(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),fo=W.create({name:"commands",addCommands(){return{...Jn}}}),ho=W.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,i;const s=()=>{var o,l,a,c;if((c=(a=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,n))!=null?c:n.getMeta("y-sync$"))return;const u=Yn(n.before,[n,...e]);rr(u).forEach(d=>{u.mapping.mapResult(d.oldRange.from).deletedAfter&&u.mapping.mapResult(d.oldRange.to).deletedBefore&&u.before.nodesBetween(d.oldRange.from,d.oldRange.to,(m,p)=>{const g=p+m.nodeSize-2,y=d.oldRange.from<=p&&g<=d.oldRange.to;this.editor.emit("delete",{type:"node",node:m,from:p,to:g,newFrom:u.mapping.map(p),newTo:u.mapping.map(g),deletedRange:d.oldRange,newRange:d.newRange,partial:!y,editor:this.editor,transaction:n,combinedTransform:u})})});const h=u.mapping;u.steps.forEach((d,m)=>{var p,g;if(d instanceof q){const y=h.slice(m).map(d.from,-1),S=h.slice(m).map(d.to),k=h.invert().map(y,-1),x=h.invert().map(S),E=(p=u.doc.nodeAt(y-1))==null?void 0:p.marks.some(C=>C.eq(d.mark)),b=(g=u.doc.nodeAt(S))==null?void 0:g.marks.some(C=>C.eq(d.mark));this.editor.emit("delete",{type:"mark",mark:d.mark,from:d.from,to:d.to,deletedRange:{from:k,to:x},newRange:{from:y,to:S},partial:!!(b||E),editor:this.editor,transaction:n,combinedTransform:u})}})};(i=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),po=W.create({name:"drop",addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),mo=W.create({name:"editable",addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("editable"),props:{editable:()=>this.editor.options.editable}})]}}),cr=new M.PluginKey("focusEvents"),go=W.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new M.Plugin({key:cr,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),yo=W.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:f}=a,{pos:h,parent:d}=f,m=f.parent.isTextblock&&h>0?l.doc.resolve(h-1):f,p=m.parent.type.spec.isolating,g=f.pos-f.parentOffset,y=p&&m.parent.childCount===1?g===f.pos:M.Selection.atStart(c).from===h;return!u||!d.type.isTextblock||d.textContent.length||!y||y&&f.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return _e()||Gn()?s:i},addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(p=>p.getMeta("composition")))return;const r=n.some(p=>p.docChanged)&&!e.doc.eq(t.doc),i=n.some(p=>p.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:o,to:l}=e.selection,a=M.Selection.atStart(e.doc).from,c=M.Selection.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!kt(t.doc))return;const h=t.tr,d=Vn({state:t,transaction:h}),{commands:m}=new Ai({editor:this.editor,state:d});if(m.clearNodes(),!!h.steps.length)return h}})]}}),vo=W.create({name:"paste",addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),wo=W.create({name:"tabindex",addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),So=W.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=Qn(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new M.Plugin({key:new M.PluginKey("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}});function xo(n){return new we({find:n.find,handler:({state:e,range:t,match:r})=>{const i=j(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),u=c+o.length;if(xt(t.from,t.to,e.doc).filter(d=>d.mark.type.excluded.find(p=>p===n.type&&p!==d.mark.type)).filter(d=>d.to>c).length)return null;u<t.to&&s.delete(u,t.to),c>t.from&&s.delete(t.from+a,c);const h=t.from+a+o.length;s.addMark(t.from+a,h,n.type.create(i||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}function ko(n){return new we({find:n.find,handler:({state:e,range:t,match:r})=>{const i=j(n.getAttributes,void 0,r)||{},{tr:s}=e,o=t.from;let l=t.to;const a=n.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>l?u=l:l=u+r[1].length;const f=r[0][r[0].length-1];s.insertText(f,o+r[0].length-1),s.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?o:o-1;s.insert(c,n.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:n.undoable})}function bo(n){return new we({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=j(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)},undoable:n.undoable})}function Eo(n){return new we({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=j(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&dt(a,n.type,s);if(!c)return null;if(o.wrap(a,c),n.keepMarks&&n.editor){const{selection:f,storedMarks:h}=e,{splittableMarks:d}=n.editor.extensionManager,m=h||f.$to.parentOffset&&f.$from.marks();if(m){const p=m.filter(g=>d.includes(g.type.name));o.ensureMarks(p)}}if(n.keepAttributes){const f=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,s).run()}const u=o.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Z(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(t.from-1)},undoable:n.undoable})}var Mo=n=>"touches"in n,Co=class{constructor(n){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.touches[0];if(!a)return;const c=a.clientX-this.startX,u=a.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,t,r,i,s,o;this.node=n.node,this.editor=n.editor,this.element=n.element,this.contentElement=n.contentElement,this.getPos=n.getPos,this.onResize=n.onResize,this.onCommit=n.onCommit,this.onUpdate=n.onUpdate,(e=n.options)!=null&&e.min&&(this.minSize={...this.minSize,...n.options.min}),(t=n.options)!=null&&t.max&&(this.maxSize=n.options.max),(r=n==null?void 0:n.options)!=null&&r.directions&&(this.directions=n.options.directions),(i=n.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=n.options.preserveAspectRatio),(s=n.options)!=null&&s.className&&(this.classNames={container:n.options.className.container||"",wrapper:n.options.className.wrapper||"",handle:n.options.className.handle||"",resizing:n.options.className.resizing||""}),(o=n.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=n.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){return this.contentElement}handleEditorUpdate(){const n=this.editor.isEditable;n!==this.lastEditableState&&(this.lastEditableState=n,n?n&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(n,e,t){return n.type!==this.node.type?!1:(this.node=n,this.onUpdate?this.onUpdate(n,e,t):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const n=document.createElement("div");return n.dataset.resizeContainer="",n.dataset.node=this.node.type.name,n.style.display="flex",this.classNames.container&&(n.className=this.classNames.container),n.appendChild(this.wrapper),n}createWrapper(){const n=document.createElement("div");return n.style.position="relative",n.style.display="block",n.dataset.resizeWrapper="",this.classNames.wrapper&&(n.className=this.classNames.wrapper),n.appendChild(this.element),n}createHandle(n){const e=document.createElement("div");return e.dataset.resizeHandle=n,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(n,e){const t=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),s=e.includes("right");t&&(n.style.top="0"),r&&(n.style.bottom="0"),i&&(n.style.left="0"),s&&(n.style.right="0"),(e==="top"||e==="bottom")&&(n.style.left="0",n.style.right="0"),(e==="left"||e==="right")&&(n.style.top="0",n.style.bottom="0")}attachHandles(){this.directions.forEach(n=>{let e;this.createCustomHandle?e=this.createCustomHandle(n):e=this.createHandle(n),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${n}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(n)),this.createCustomHandle||this.positionHandle(e,n),e.addEventListener("mousedown",t=>this.handleResizeStart(t,n)),e.addEventListener("touchstart",t=>this.handleResizeStart(t,n)),this.handleMap.set(n,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(n=>n.remove()),this.handleMap.clear()}applyInitialSize(){const n=this.node.attrs.width,e=this.node.attrs.height;n?(this.element.style.width=`${n}px`,this.initialWidth=n):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(n,e){n.preventDefault(),n.stopPropagation(),this.isResizing=!0,this.activeHandle=e,Mo(n)?(this.startX=n.touches[0].clientX,this.startY=n.touches[0].clientY):(this.startX=n.clientX,this.startY=n.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(n,e){if(!this.activeHandle)return;const t=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,n,e),s=this.applyConstraints(r,i,t);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(n,e,t){let r=this.startWidth,i=this.startHeight;const s=n.includes("right"),o=n.includes("left"),l=n.includes("bottom"),a=n.includes("top");return s?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+t:a&&(i=this.startHeight-t),(n==="right"||n==="left")&&(r=this.startWidth+(s?e:-e)),(n==="top"||n==="bottom")&&(i=this.startHeight+(l?t:-t)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,n):{width:r,height:i}}applyConstraints(n,e,t){var r,i,s,o;if(!t){let c=Math.max(this.minSize.width,n),u=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(c=Math.min(this.maxSize.width,c)),(i=this.maxSize)!=null&&i.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let l=n,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(n,e,t){const r=t==="left"||t==="right",i=t==="top"||t==="bottom";return r?{width:n,height:n/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:n,height:n/this.aspectRatio}}};function Ro(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof M.NodeSelection){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}function To(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Ao={};vt(Ao,{createAtomBlockMarkdownSpec:()=>No,createBlockMarkdownSpec:()=>Oo,createInlineMarkdownSpec:()=>ur,parseAttributes:()=>Mt,parseIndentedBlocks:()=>fr,renderNestedMarkdownContent:()=>dr,serializeAttributes:()=>Ct});function Mt(n){if(!(n!=null&&n.trim()))return{};const e={},t=[],r=n.replace(/["']([^"']*)["']/g,c=>(t.push(c),`__QUOTED_${t.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const c=i.map(u=>u.trim().slice(1));e.class=c.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,c,u])=>{var f;const h=parseInt(((f=u.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),d=t[h];d&&(e[c]=d.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Ct(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function No(n){const{nodeName:e,name:t,parseAttributes:r=Mt,serializeAttributes:i=Ct,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=n,a=t||e,c=u=>{if(!l)return u;const f={};return l.forEach(h=>{h in u&&(f[h]=u[h])}),f};return{parseMarkdown:(u,f)=>{const h={...s,...u.attributes};return f.createNode(e,h,[])},markdownTokenizer:{name:e,level:"block",start(u){var f;const h=new RegExp(`^:::${a}(?:\\s|$)`,"m"),d=(f=u.match(h))==null?void 0:f.index;return d!==void 0?d:-1},tokenize(u,f,h){const d=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),m=u.match(d);if(!m)return;const p=m[1]||"",g=r(p);if(!o.find(S=>!(S in g)))return{type:e,raw:m[0],attributes:g}}},renderMarkdown:u=>{const f=c(u.attrs||{}),h=i(f),d=h?` {${h}}`:"";return`:::${a}${d} :::`}}}function Oo(n){const{nodeName:e,name:t,getContent:r,parseAttributes:i=Mt,serializeAttributes:s=Ct,defaultAttributes:o={},content:l="block",allowedAttributes:a}=n,c=t||e,u=f=>{if(!a)return f;const h={};return a.forEach(d=>{d in f&&(h[d]=f[d])}),h};return{parseMarkdown:(f,h)=>{let d;if(r){const p=r(f);d=typeof p=="string"?[{type:"text",text:p}]:p}else l==="block"?d=h.parseChildren(f.tokens||[]):d=h.parseInline(f.tokens||[]);const m={...o,...f.attributes};return h.createNode(e,m,d)},markdownTokenizer:{name:e,level:"block",start(f){var h;const d=new RegExp(`^:::${c}`,"m"),m=(h=f.match(d))==null?void 0:h.index;return m!==void 0?m:-1},tokenize(f,h,d){var m;const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=f.match(p);if(!g)return;const[y,S=""]=g,k=i(S);let x=1;const E=y.length;let b="";const C=/^:::([\w-]*)(\s.*)?/gm,O=f.slice(E);for(C.lastIndex=0;;){const K=C.exec(O);if(K===null)break;const Se=K.index,vr=K[1];if(!((m=K[2])!=null&&m.endsWith(":::"))){if(vr)x+=1;else if(x-=1,x===0){const Tt=O.slice(0,Se);b=Tt.trim();const wr=f.slice(0,E+Se+K[0].length);let G=[];if(b)if(l==="block")for(G=d.blockTokens(Tt),G.forEach(V=>{V.text&&(!V.tokens||V.tokens.length===0)&&(V.tokens=d.inlineTokens(V.text))});G.length>0;){const V=G[G.length-1];if(V.type==="paragraph"&&(!V.text||V.text.trim()===""))G.pop();else break}else G=d.inlineTokens(b);return{type:e,raw:wr,attributes:k,content:b,tokens:G}}}}}},renderMarkdown:(f,h)=>{const d=u(f.attrs||{}),m=s(d),p=m?` {${m}}`:"",g=h.renderChildren(f.content||[],`
|
|
24
24
|
|
|
25
25
|
`);return`:::${c}${p}
|
|
26
26
|
|
|
27
27
|
${g}
|
|
28
28
|
|
|
29
|
-
:::`}}}function
|
|
29
|
+
:::`}}}function Io(n){if(!n.trim())return{};const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,i,s,o]=r;e[i]=s||o,r=t.exec(n)}return e}function zo(n){return Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(" ")}function ur(n){const{nodeName:e,name:t,getContent:r,parseAttributes:i=Io,serializeAttributes:s=zo,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:a}=n,c=t||e,u=h=>{if(!a)return h;const d={};return a.forEach(m=>{const p=typeof m=="string"?m:m.name,g=typeof m=="string"?void 0:m.skipIfDefault;if(p in h){const y=h[p];if(g!==void 0&&y===g)return;d[p]=y}}),d},f=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(h,d)=>{const m={...o,...h.attributes};if(l)return d.createNode(e,m);const p=r?r(h):h.content||"";return p?d.createNode(e,m,[d.createTextNode(p)]):d.createNode(e,m,[])},markdownTokenizer:{name:e,level:"inline",start(h){const d=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),m=h.match(d),p=m==null?void 0:m.index;return p!==void 0?p:-1},tokenize(h,d,m){const p=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),g=h.match(p);if(!g)return;let y="",S="";if(l){const[,x]=g;S=x}else{const[,x,E]=g;S=x,y=E||""}const k=i(S.trim());return{type:e,raw:g[0],content:y.trim(),attributes:k}}},renderMarkdown:h=>{let d="";r?d=r(h):h.content&&h.content.length>0&&(d=h.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const m=u(h.attrs||{}),p=s(m),g=p?` ${p}`:"";return l?`[${c}${g}]`:`[${c}${g}]${d}[/${c}]`}}}function fr(n,e,t){var r,i,s,o;const l=n.split(`
|
|
30
30
|
`),a=[];let c="",u=0;const f=e.baseIndentSize||2;for(;u<l.length;){const h=l[u],d=h.match(e.itemPattern);if(!d){if(a.length>0)break;if(h.trim()===""){u+=1,c=`${c}${h}
|
|
31
31
|
`;continue}else return}const m=e.extractItemData(d),{indentLevel:p,mainContent:g}=m;c=`${c}${h}
|
|
32
32
|
`;const y=[g];for(u+=1;u<l.length;){const E=l[u];if(E.trim()===""){const C=l.slice(u+1).findIndex(Se=>Se.trim()!=="");if(C===-1)break;if((((i=(r=l[u+1+C].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>p){y.push(E),c=`${c}${E}
|
|
33
33
|
`,u+=1;continue}else break}if((((o=(s=E.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>p)y.push(E),c=`${c}${E}
|
|
34
34
|
`,u+=1;else break}let S;const k=y.slice(1);if(k.length>0){const E=k.map(b=>b.slice(p+f)).join(`
|
|
35
|
-
`);E.trim()&&(e.customNestedParser?S=e.customNestedParser(E):S=t.blockTokens(E))}const x=e.createToken(m,S);a.push(x)}if(a.length!==0)return{items:a,raw:c}}function
|
|
35
|
+
`);E.trim()&&(e.customNestedParser?S=e.customNestedParser(E):S=t.blockTokens(E))}const x=e.createToken(m,S);a.push(x)}if(a.length!==0)return{items:a,raw:c}}function dr(n,e,t,r){if(!n||!Array.isArray(n.content))return"";const i=typeof t=="function"?t(r):t,[s,...o]=n.content,l=e.renderChildren([s]),a=[`${i}${l}`];return o&&o.length>0&&o.forEach(c=>{const u=e.renderChildren([c]);if(u){const f=u.split(`
|
|
36
36
|
`).map(h=>h?e.indent(h):"").join(`
|
|
37
37
|
`);a.push(f)}}),a.join(`
|
|
38
|
-
`)}var $o=class pr extends bt{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new pr(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Do=class{constructor(n,e,t){this.isDragging=!1,this.component=n,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(n){var e,t,r,i,s,o,l;const{view:a}=this.editor,c=n.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(c)||!u)return;let f=0,h=0;if(this.dom!==u){const S=this.dom.getBoundingClientRect(),k=u.getBoundingClientRect(),x=(i=n.offsetX)!=null?i:(r=n.nativeEvent)==null?void 0:r.offsetX,E=(o=n.offsetY)!=null?o:(s=n.nativeEvent)==null?void 0:s.offsetY;f=k.x-S.x+x,h=k.y-S.y+E}const d=this.dom.cloneNode(!0);try{const S=this.dom.getBoundingClientRect();d.style.width=`${Math.round(S.width)}px`,d.style.height=`${Math.round(S.height)}px`,d.style.boxSizing="border-box",d.style.pointerEvents="none"}catch{}let m=null;try{m=document.createElement("div"),m.style.position="absolute",m.style.top="-9999px",m.style.left="-9999px",m.style.pointerEvents="none",m.appendChild(d),document.body.appendChild(m),(l=n.dataTransfer)==null||l.setDragImage(d,f,h)}finally{m&&setTimeout(()=>{try{m==null||m.remove()}catch{}},0)}const p=this.getPos();if(typeof p!="number")return;const g=M.NodeSelection.create(a.state.doc,p),y=a.state.tr.setSelection(g);a.dispatch(y)}stopEvent(n){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:n});const t=n.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const i=n.type.startsWith("drag"),s=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!s&&!i)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=M.NodeSelection.isSelectable(this.node),f=n.type==="copy",h=n.type==="paste",d=n.type==="cut",m=n.type==="mousedown";if(!c&&u&&i&&n.target===this.dom&&n.preventDefault(),c&&i&&!a&&n.target===this.dom)return n.preventDefault(),!1;if(c&&l&&!a&&m){const p=t.closest("[data-drag-handle]");p&&(this.dom===p||this.dom.contains(p))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||s||f||h||d||m&&u)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):this.node.isLeaf||this.node.isAtom?!0:n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(_e()||Kn())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}updateAttributes(n){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...n}),!0)})}deleteNode(){const n=this.getPos();if(typeof n!="number")return;const e=n+this.node.nodeSize;this.editor.commands.deleteRange({from:n,to:e})}};function Bo(n){return new Et({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=j(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),f=t.from+a.indexOf(l),h=f+l.length;if(xt(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(g=>g===n.type&&g!==m.mark.type)).filter(m=>m.to>f).length)return null;h<t.to&&o.delete(h,t.to),f>t.from&&o.delete(t.from+u,f),c=t.from+u+l.length,o.addMark(t.from+u,c,n.type.create(s||{})),o.removeStoredMark(n.type)}}})}function _o(n){return new Et({find:n.find,handler({match:e,chain:t,range:r,pasteEvent:i}){const s=j(n.getAttributes,void 0,e,i),o=j(n.getContent,void 0,s);if(s===!1||s===null)return null;const l={type:n.type.name,attrs:s};o&&(l.content=o),e.input&&t().deleteRange(r).insertContentAt(r.from,l)}})}var Lo=Object.getOwnPropertyNames,Fo=Object.getOwnPropertySymbols,qo=Object.prototype.hasOwnProperty;function Kt(n,e){return function(r,i,s){return n(r,i,s)&&e(r,i,s)}}function Re(n){return function(t,r,i){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,i);var s=i.cache,o=s.get(t),l=s.get(r);if(o&&l)return o===r&&l===t;s.set(t,r),s.set(r,t);var a=n(t,r,i);return s.delete(t),s.delete(r),a}}function jo(n){return n!=null?n[Symbol.toStringTag]:void 0}function Gt(n){return Lo(n).concat(Fo(n))}var Wo=Object.hasOwn||(function(n,e){return qo.call(n,e)});function ne(n,e){return n===e||!n&&!e&&n!==n&&e!==e}var Vo="__v",Jo="__o",Ho="_owner",Xt=Object.getOwnPropertyDescriptor,Yt=Object.keys;function Uo(n,e,t){var r=n.length;if(e.length!==r)return!1;for(;r-- >0;)if(!t.equals(n[r],e[r],r,r,n,e,t))return!1;return!0}function Ko(n,e){return ne(n.getTime(),e.getTime())}function Go(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function Xo(n,e){return n===e}function Zt(n,e,t){var r=n.size;if(r!==e.size)return!1;if(!r)return!0;for(var i=new Array(r),s=n.entries(),o,l,a=0;(o=s.next())&&!o.done;){for(var c=e.entries(),u=!1,f=0;(l=c.next())&&!l.done;){if(i[f]){f++;continue}var h=o.value,d=l.value;if(t.equals(h[0],d[0],a,f,n,e,t)&&t.equals(h[1],d[1],h[0],d[0],n,e,t)){u=i[f]=!0;break}f++}if(!u)return!1;a++}return!0}var Yo=ne;function Zo(n,e,t){var r=Yt(n),i=r.length;if(Yt(e).length!==i)return!1;for(;i-- >0;)if(!mr(n,e,t,r[i]))return!1;return!0}function ue(n,e,t){var r=Gt(n),i=r.length;if(Gt(e).length!==i)return!1;for(var s,o,l;i-- >0;)if(s=r[i],!mr(n,e,t,s)||(o=Xt(n,s),l=Xt(e,s),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function Qo(n,e){return ne(n.valueOf(),e.valueOf())}function el(n,e){return n.source===e.source&&n.flags===e.flags}function Qt(n,e,t){var r=n.size;if(r!==e.size)return!1;if(!r)return!0;for(var i=new Array(r),s=n.values(),o,l;(o=s.next())&&!o.done;){for(var a=e.values(),c=!1,u=0;(l=a.next())&&!l.done;){if(!i[u]&&t.equals(o.value,l.value,o.value,l.value,n,e,t)){c=i[u]=!0;break}u++}if(!c)return!1}return!0}function tl(n,e){var t=n.length;if(e.length!==t)return!1;for(;t-- >0;)if(n[t]!==e[t])return!1;return!0}function nl(n,e){return n.hostname===e.hostname&&n.pathname===e.pathname&&n.protocol===e.protocol&&n.port===e.port&&n.hash===e.hash&&n.username===e.username&&n.password===e.password}function mr(n,e,t,r){return(r===Ho||r===Jo||r===Vo)&&(n.$$typeof||e.$$typeof)?!0:Wo(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}var rl="[object Arguments]",il="[object Boolean]",sl="[object Date]",ol="[object Error]",ll="[object Map]",al="[object Number]",cl="[object Object]",ul="[object RegExp]",fl="[object Set]",dl="[object String]",hl="[object URL]",pl=Array.isArray,en=typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView:null,tn=Object.assign,ml=Object.prototype.toString.call.bind(Object.prototype.toString);function gl(n){var e=n.areArraysEqual,t=n.areDatesEqual,r=n.areErrorsEqual,i=n.areFunctionsEqual,s=n.areMapsEqual,o=n.areNumbersEqual,l=n.areObjectsEqual,a=n.arePrimitiveWrappersEqual,c=n.areRegExpsEqual,u=n.areSetsEqual,f=n.areTypedArraysEqual,h=n.areUrlsEqual,d=n.unknownTagComparators;return function(p,g,y){if(p===g)return!0;if(p==null||g==null)return!1;var S=typeof p;if(S!==typeof g)return!1;if(S!=="object")return S==="number"?o(p,g,y):S==="function"?i(p,g,y):!1;var k=p.constructor;if(k!==g.constructor)return!1;if(k===Object)return l(p,g,y);if(pl(p))return e(p,g,y);if(en!=null&&en(p))return f(p,g,y);if(k===Date)return t(p,g,y);if(k===RegExp)return c(p,g,y);if(k===Map)return s(p,g,y);if(k===Set)return u(p,g,y);var x=ml(p);if(x===sl)return t(p,g,y);if(x===ul)return c(p,g,y);if(x===ll)return s(p,g,y);if(x===fl)return u(p,g,y);if(x===cl)return typeof p.then!="function"&&typeof g.then!="function"&&l(p,g,y);if(x===hl)return h(p,g,y);if(x===ol)return r(p,g,y);if(x===rl)return l(p,g,y);if(x===il||x===al||x===dl)return a(p,g,y);if(d){var E=d[x];if(!E){var b=jo(p);b&&(E=d[b])}if(E)return E(p,g,y)}return!1}}function yl(n){var e=n.circular,t=n.createCustomConfig,r=n.strict,i={areArraysEqual:r?ue:Uo,areDatesEqual:Ko,areErrorsEqual:Go,areFunctionsEqual:Xo,areMapsEqual:r?Kt(Zt,ue):Zt,areNumbersEqual:Yo,areObjectsEqual:r?ue:Zo,arePrimitiveWrappersEqual:Qo,areRegExpsEqual:el,areSetsEqual:r?Kt(Qt,ue):Qt,areTypedArraysEqual:r?ue:tl,areUrlsEqual:nl,unknownTagComparators:void 0};if(t&&(i=tn({},i,t(i))),e){var s=Re(i.areArraysEqual),o=Re(i.areMapsEqual),l=Re(i.areObjectsEqual),a=Re(i.areSetsEqual);i=tn({},i,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:l,areSetsEqual:a})}return i}function vl(n){return function(e,t,r,i,s,o,l){return n(e,t,l)}}function wl(n){var e=n.circular,t=n.comparator,r=n.createState,i=n.equals,s=n.strict;if(r)return function(a,c){var u=r(),f=u.cache,h=f===void 0?e?new WeakMap:void 0:f,d=u.meta;return t(a,c,{cache:h,equals:i,meta:d,strict:s})};if(e)return function(a,c){return t(a,c,{cache:new WeakMap,equals:i,meta:void 0,strict:s})};var o={cache:void 0,equals:i,meta:void 0,strict:s};return function(a,c){return t(a,c,o)}}var Sl=ee();ee({strict:!0});ee({circular:!0});ee({circular:!0,strict:!0});ee({createInternalComparator:function(){return ne}});ee({strict:!0,createInternalComparator:function(){return ne}});ee({circular:!0,createInternalComparator:function(){return ne}});ee({circular:!0,createInternalComparator:function(){return ne},strict:!0});function ee(n){n===void 0&&(n={});var e=n.circular,t=e===void 0?!1:e,r=n.createInternalComparator,i=n.createState,s=n.strict,o=s===void 0?!1:s,l=yl(n),a=gl(l),c=r?r(a):vl(a);return wl({circular:t,comparator:a,createState:i,equals:c,strict:o})}var Te={exports:{}},Ye={};/**
|
|
38
|
+
`)}var Po=class hr extends bt{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new hr(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},$o=class{constructor(n,e,t){this.isDragging=!1,this.component=n,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(n){var e,t,r,i,s,o,l;const{view:a}=this.editor,c=n.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(c)||!u)return;let f=0,h=0;if(this.dom!==u){const S=this.dom.getBoundingClientRect(),k=u.getBoundingClientRect(),x=(i=n.offsetX)!=null?i:(r=n.nativeEvent)==null?void 0:r.offsetX,E=(o=n.offsetY)!=null?o:(s=n.nativeEvent)==null?void 0:s.offsetY;f=k.x-S.x+x,h=k.y-S.y+E}const d=this.dom.cloneNode(!0);try{const S=this.dom.getBoundingClientRect();d.style.width=`${Math.round(S.width)}px`,d.style.height=`${Math.round(S.height)}px`,d.style.boxSizing="border-box",d.style.pointerEvents="none"}catch{}let m=null;try{m=document.createElement("div"),m.style.position="absolute",m.style.top="-9999px",m.style.left="-9999px",m.style.pointerEvents="none",m.appendChild(d),document.body.appendChild(m),(l=n.dataTransfer)==null||l.setDragImage(d,f,h)}finally{m&&setTimeout(()=>{try{m==null||m.remove()}catch{}},0)}const p=this.getPos();if(typeof p!="number")return;const g=M.NodeSelection.create(a.state.doc,p),y=a.state.tr.setSelection(g);a.dispatch(y)}stopEvent(n){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:n});const t=n.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const i=n.type.startsWith("drag"),s=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!s&&!i)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=M.NodeSelection.isSelectable(this.node),f=n.type==="copy",h=n.type==="paste",d=n.type==="cut",m=n.type==="mousedown";if(!c&&u&&i&&n.target===this.dom&&n.preventDefault(),c&&i&&!a&&n.target===this.dom)return n.preventDefault(),!1;if(c&&l&&!a&&m){const p=t.closest("[data-drag-handle]");p&&(this.dom===p||this.dom.contains(p))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||s||f||h||d||m&&u)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):this.node.isLeaf||this.node.isAtom?!0:n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(_e()||Un())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(t=>t.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}updateAttributes(n){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...n}),!0)})}deleteNode(){const n=this.getPos();if(typeof n!="number")return;const e=n+this.node.nodeSize;this.editor.commands.deleteRange({from:n,to:e})}};function Do(n){return new Et({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=j(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),f=t.from+a.indexOf(l),h=f+l.length;if(xt(t.from,t.to,e.doc).filter(m=>m.mark.type.excluded.find(g=>g===n.type&&g!==m.mark.type)).filter(m=>m.to>f).length)return null;h<t.to&&o.delete(h,t.to),f>t.from&&o.delete(t.from+u,f),c=t.from+u+l.length,o.addMark(t.from+u,c,n.type.create(s||{})),o.removeStoredMark(n.type)}}})}function Bo(n){return new Et({find:n.find,handler({match:e,chain:t,range:r,pasteEvent:i}){const s=j(n.getAttributes,void 0,e,i),o=j(n.getContent,void 0,s);if(s===!1||s===null)return null;const l={type:n.type.name,attrs:s};o&&(l.content=o),e.input&&t().deleteRange(r).insertContentAt(r.from,l)}})}var _o=Object.getOwnPropertyNames,Lo=Object.getOwnPropertySymbols,Fo=Object.prototype.hasOwnProperty;function Kt(n,e){return function(r,i,s){return n(r,i,s)&&e(r,i,s)}}function Re(n){return function(t,r,i){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,i);var s=i.cache,o=s.get(t),l=s.get(r);if(o&&l)return o===r&&l===t;s.set(t,r),s.set(r,t);var a=n(t,r,i);return s.delete(t),s.delete(r),a}}function qo(n){return n!=null?n[Symbol.toStringTag]:void 0}function Gt(n){return _o(n).concat(Lo(n))}var jo=Object.hasOwn||(function(n,e){return Fo.call(n,e)});function ne(n,e){return n===e||!n&&!e&&n!==n&&e!==e}var Wo="__v",Vo="__o",Jo="_owner",Xt=Object.getOwnPropertyDescriptor,Yt=Object.keys;function Ho(n,e,t){var r=n.length;if(e.length!==r)return!1;for(;r-- >0;)if(!t.equals(n[r],e[r],r,r,n,e,t))return!1;return!0}function Uo(n,e){return ne(n.getTime(),e.getTime())}function Ko(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function Go(n,e){return n===e}function Zt(n,e,t){var r=n.size;if(r!==e.size)return!1;if(!r)return!0;for(var i=new Array(r),s=n.entries(),o,l,a=0;(o=s.next())&&!o.done;){for(var c=e.entries(),u=!1,f=0;(l=c.next())&&!l.done;){if(i[f]){f++;continue}var h=o.value,d=l.value;if(t.equals(h[0],d[0],a,f,n,e,t)&&t.equals(h[1],d[1],h[0],d[0],n,e,t)){u=i[f]=!0;break}f++}if(!u)return!1;a++}return!0}var Xo=ne;function Yo(n,e,t){var r=Yt(n),i=r.length;if(Yt(e).length!==i)return!1;for(;i-- >0;)if(!pr(n,e,t,r[i]))return!1;return!0}function ue(n,e,t){var r=Gt(n),i=r.length;if(Gt(e).length!==i)return!1;for(var s,o,l;i-- >0;)if(s=r[i],!pr(n,e,t,s)||(o=Xt(n,s),l=Xt(e,s),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function Zo(n,e){return ne(n.valueOf(),e.valueOf())}function Qo(n,e){return n.source===e.source&&n.flags===e.flags}function Qt(n,e,t){var r=n.size;if(r!==e.size)return!1;if(!r)return!0;for(var i=new Array(r),s=n.values(),o,l;(o=s.next())&&!o.done;){for(var a=e.values(),c=!1,u=0;(l=a.next())&&!l.done;){if(!i[u]&&t.equals(o.value,l.value,o.value,l.value,n,e,t)){c=i[u]=!0;break}u++}if(!c)return!1}return!0}function el(n,e){var t=n.length;if(e.length!==t)return!1;for(;t-- >0;)if(n[t]!==e[t])return!1;return!0}function tl(n,e){return n.hostname===e.hostname&&n.pathname===e.pathname&&n.protocol===e.protocol&&n.port===e.port&&n.hash===e.hash&&n.username===e.username&&n.password===e.password}function pr(n,e,t,r){return(r===Jo||r===Vo||r===Wo)&&(n.$$typeof||e.$$typeof)?!0:jo(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}var nl="[object Arguments]",rl="[object Boolean]",il="[object Date]",sl="[object Error]",ol="[object Map]",ll="[object Number]",al="[object Object]",cl="[object RegExp]",ul="[object Set]",fl="[object String]",dl="[object URL]",hl=Array.isArray,en=typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView:null,tn=Object.assign,pl=Object.prototype.toString.call.bind(Object.prototype.toString);function ml(n){var e=n.areArraysEqual,t=n.areDatesEqual,r=n.areErrorsEqual,i=n.areFunctionsEqual,s=n.areMapsEqual,o=n.areNumbersEqual,l=n.areObjectsEqual,a=n.arePrimitiveWrappersEqual,c=n.areRegExpsEqual,u=n.areSetsEqual,f=n.areTypedArraysEqual,h=n.areUrlsEqual,d=n.unknownTagComparators;return function(p,g,y){if(p===g)return!0;if(p==null||g==null)return!1;var S=typeof p;if(S!==typeof g)return!1;if(S!=="object")return S==="number"?o(p,g,y):S==="function"?i(p,g,y):!1;var k=p.constructor;if(k!==g.constructor)return!1;if(k===Object)return l(p,g,y);if(hl(p))return e(p,g,y);if(en!=null&&en(p))return f(p,g,y);if(k===Date)return t(p,g,y);if(k===RegExp)return c(p,g,y);if(k===Map)return s(p,g,y);if(k===Set)return u(p,g,y);var x=pl(p);if(x===il)return t(p,g,y);if(x===cl)return c(p,g,y);if(x===ol)return s(p,g,y);if(x===ul)return u(p,g,y);if(x===al)return typeof p.then!="function"&&typeof g.then!="function"&&l(p,g,y);if(x===dl)return h(p,g,y);if(x===sl)return r(p,g,y);if(x===nl)return l(p,g,y);if(x===rl||x===ll||x===fl)return a(p,g,y);if(d){var E=d[x];if(!E){var b=qo(p);b&&(E=d[b])}if(E)return E(p,g,y)}return!1}}function gl(n){var e=n.circular,t=n.createCustomConfig,r=n.strict,i={areArraysEqual:r?ue:Ho,areDatesEqual:Uo,areErrorsEqual:Ko,areFunctionsEqual:Go,areMapsEqual:r?Kt(Zt,ue):Zt,areNumbersEqual:Xo,areObjectsEqual:r?ue:Yo,arePrimitiveWrappersEqual:Zo,areRegExpsEqual:Qo,areSetsEqual:r?Kt(Qt,ue):Qt,areTypedArraysEqual:r?ue:el,areUrlsEqual:tl,unknownTagComparators:void 0};if(t&&(i=tn({},i,t(i))),e){var s=Re(i.areArraysEqual),o=Re(i.areMapsEqual),l=Re(i.areObjectsEqual),a=Re(i.areSetsEqual);i=tn({},i,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:l,areSetsEqual:a})}return i}function yl(n){return function(e,t,r,i,s,o,l){return n(e,t,l)}}function vl(n){var e=n.circular,t=n.comparator,r=n.createState,i=n.equals,s=n.strict;if(r)return function(a,c){var u=r(),f=u.cache,h=f===void 0?e?new WeakMap:void 0:f,d=u.meta;return t(a,c,{cache:h,equals:i,meta:d,strict:s})};if(e)return function(a,c){return t(a,c,{cache:new WeakMap,equals:i,meta:void 0,strict:s})};var o={cache:void 0,equals:i,meta:void 0,strict:s};return function(a,c){return t(a,c,o)}}var wl=ee();ee({strict:!0});ee({circular:!0});ee({circular:!0,strict:!0});ee({createInternalComparator:function(){return ne}});ee({strict:!0,createInternalComparator:function(){return ne}});ee({circular:!0,createInternalComparator:function(){return ne}});ee({circular:!0,createInternalComparator:function(){return ne},strict:!0});function ee(n){n===void 0&&(n={});var e=n.circular,t=e===void 0?!1:e,r=n.createInternalComparator,i=n.createState,s=n.strict,o=s===void 0?!1:s,l=gl(n),a=ml(l),c=r?r(a):yl(a);return vl({circular:t,comparator:a,createState:i,equals:c,strict:o})}var Te={exports:{}},Ye={};/**
|
|
39
39
|
* @license React
|
|
40
40
|
* use-sync-external-store-shim/with-selector.production.js
|
|
41
41
|
*
|
|
@@ -43,7 +43,7 @@ ${g}
|
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the MIT license found in the
|
|
45
45
|
* LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/var nn;function
|
|
46
|
+
*/var nn;function Sl(){if(nn)return Ye;nn=1;var n=T,e=lt();function t(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:t,i=e.useSyncExternalStore,s=n.useRef,o=n.useEffect,l=n.useMemo,a=n.useDebugValue;return Ye.useSyncExternalStoreWithSelector=function(c,u,f,h,d){var m=s(null);if(m.current===null){var p={hasValue:!1,value:null};m.current=p}else p=m.current;m=l(function(){function y(b){if(!S){if(S=!0,k=b,b=h(b),d!==void 0&&p.hasValue){var C=p.value;if(d(C,b))return x=C}return x=b}if(C=x,r(k,b))return C;var O=h(b);return d!==void 0&&d(C,O)?(k=b,C):(k=b,x=O)}var S=!1,k,x,E=f===void 0?null:f;return[function(){return y(u())},E===null?void 0:function(){return y(E())}]},[u,f,h,d]);var g=i(c,m[0],m[1]);return o(function(){p.hasValue=!0,p.value=g},[g]),a(g),g},Ye}var Ze={};/**
|
|
47
47
|
* @license React
|
|
48
48
|
* use-sync-external-store-shim/with-selector.development.js
|
|
49
49
|
*
|
|
@@ -51,4 +51,4 @@ ${g}
|
|
|
51
51
|
*
|
|
52
52
|
* This source code is licensed under the MIT license found in the
|
|
53
53
|
* LICENSE file in the root directory of this source tree.
|
|
54
|
-
*/var rn;function kl(){return rn||(rn=1,process.env.NODE_ENV!=="production"&&(function(){function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=T,t=lt(),r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,s=e.useRef,o=e.useEffect,l=e.useMemo,a=e.useDebugValue;Ze.useSyncExternalStoreWithSelector=function(c,u,f,h,d){var m=s(null);if(m.current===null){var p={hasValue:!1,value:null};m.current=p}else p=m.current;m=l(function(){function y(b){if(!S){if(S=!0,k=b,b=h(b),d!==void 0&&p.hasValue){var C=p.value;if(d(C,b))return x=C}return x=b}if(C=x,r(k,b))return C;var O=h(b);return d!==void 0&&d(C,O)?(k=b,C):(k=b,x=O)}var S=!1,k,x,E=f===void 0?null:f;return[function(){return y(u())},E===null?void 0:function(){return y(E())}]},[u,f,h,d]);var g=i(c,m[0],m[1]);return o(function(){p.hasValue=!0,p.value=g},[g]),a(g),g},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Ze}var sn;function bl(){return sn||(sn=1,process.env.NODE_ENV==="production"?Te.exports=xl():Te.exports=kl()),Te.exports}var El=bl(),Ml=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},Cl=({contentComponent:n})=>{const e=un.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return J.jsx(J.Fragment,{children:Object.values(e)})};function Rl(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:an.createPortal(r.reactElement,r.element,t)},n.forEach(i=>i())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(i=>i())}}}var Tl=class extends T.Component{constructor(n){var e;super(n),this.editorContentRef=T.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=n.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const e=this.props.editor;if(e&&!e.isDestroyed&&((n=e.view.dom)!=null&&n.parentNode)){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=Rl(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((n=e.view.dom)!=null&&n.parentNode))return;const t=document.createElement("div");t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return J.jsxs(J.Fragment,{children:[J.jsx("div",{ref:Ml(e,this.editorContentRef),...t}),(n==null?void 0:n.contentComponent)&&J.jsx(Cl,{contentComponent:n.contentComponent})]})}},Al=T.forwardRef((n,e)=>{const t=T.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return T.createElement(Tl,{key:t,innerRef:e,...n})});T.memo(Al);var Nl=typeof window<"u"?T.useLayoutEffect:T.useEffect,Ol=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function Il(n){var e;const[t]=T.useState(()=>new Ol(n.editor)),r=El.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:Sl);return Nl(()=>t.watch(n.editor),[n.editor,t]),T.useDebugValue(r),r}process.env.NODE_ENV;var Rt=T.createContext({editor:null});Rt.Consumer;var zl=()=>T.useContext(Rt),gr=T.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Pl=()=>T.useContext(gr),$l=T.forwardRef((n,e)=>{const{onDragStart:t}=Pl(),r=n.as||"div";return J.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function on(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function ln(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function Dl(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function Bl(n){if(on(n)||ln(n))return!0;if(Dl(n)){const e=n.type;if(e)return on(e)||ln(e)}return!1}function _l(){try{if(T.version)return parseInt(T.version.split(".")[0],10)>=19}catch{}return!1}var yr=class{constructor(n,{editor:e,props:t={},as:r="div",className:i=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=n,this.editor=e,this.props=t,this.element=document.createElement(r),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?an.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var n;const e=this.component,t=this.props,r=this.editor,i=_l(),s=Bl(e),o={...t};o.ref&&!(i||s)&&delete o.ref,!o.ref&&(i||s)&&(o.ref=l=>{this.ref=l}),this.reactElement=J.jsx(e,{...o}),(n=r==null?void 0:r.contentComponent)==null||n.setRenderer(this.id,this)}updateProps(n={}){this.props={...this.props,...n},this.render()}destroy(){var n;const e=this.editor;(n=e==null?void 0:e.contentComponent)==null||n.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(n){Object.keys(n).forEach(e=>{this.element.setAttribute(e,n[e])})}};T.createContext({markViewContentRef:()=>{}});var Ll=class extends Do{constructor(n,e,t){if(super(n,e,t),this.selectionRafId=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}mount(){const n={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:T.createRef()};if(!this.component.displayName){const a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement&&(a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper"),a.appendChild(this.contentDOMElement))}},i=this.component,s=T.memo(a=>J.jsx(gr.Provider,{value:r,children:T.createElement(i,a)}));s.displayName="ReactNodeView";let o=this.node.isInline?"span":"div";this.options.as&&(o=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new yr(s,{editor:this.editor,props:n,as:o,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var n;if(this.renderer.element.firstElementChild&&!((n=this.renderer.element.firstElementChild)!=null&&n.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:n,to:e}=this.editor.state.selection,t=this.getPos();if(typeof t=="number")if(n<=t&&e>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(n,e,t){const r=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(n.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,s=this.decorations,o=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:i,oldDecorations:s,newNode:n,newDecorations:e,oldInnerDecorations:o,innerDecorations:t,updateProps:()=>r({node:n,decorations:e,innerDecorations:t})})}return n===this.node&&this.decorations===e&&this.innerDecorations===t||(this.node=n,this.decorations=e,this.innerDecorations=t,r({node:n,decorations:e,innerDecorations:t})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let n={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,t=Rs(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function Fl(n,e){return t=>t.editor.contentComponent?new Ll(n,t,e):{}}exports.AllSelection=F;exports.DOMParser=Ie;exports.DOMSerializer=ct;exports.EditorContext=Rt;exports.Extension=W;exports.Fragment=v;exports.InputRule=we;exports.MappablePosition=sr;exports.Mapping=me;exports.Mark=ao;exports.Node3=$o;exports.NodeSelection=R;exports.NodeViewWrapper=$l;exports.PasteRule=Et;exports.Plugin=li;exports.PluginKey=ai;exports.ReactNodeViewRenderer=Fl;exports.ReactRenderer=yr;exports.ResizableNodeView=Ro;exports.Selection=A;exports.SelectionRange=Nn;exports.Slice=w;exports.TextSelection=D;exports.Transform=An;exports.callOrReturn=j;exports.canInsertNode=To;exports.clsx=Sr;exports.combineTransactionSteps=Zn;exports.createInlineMarkdownSpec=fr;exports.deleteSelection=Be;exports.dropPoint=Qr;exports.escapeForRegEx=Ao;exports.findChildrenInRange=Ms;exports.findParentNode=ve;exports.findParentNodeClosestToPos=Qn;exports.getAttributes=Ns;exports.getChangedRanges=ir;exports.getExtensionField=ae;exports.getMarksBetween=xt;exports.getNodeAtPosition=zs;exports.getNodeType=P;exports.getText=Ts;exports.getTextSerializersFromSchema=rr;exports.getUpdatedPosition=_s;exports.isActive=Ps;exports.isAtEndOfNode=$s;exports.isAtStartOfNode=Ds;exports.isList=ot;exports.isNodeActive=le;exports.isNodeEmpty=kt;exports.isNodeSelection=Bs;exports.isNumber=co;exports.isTextSelection=St;exports.markInputRule=ko;exports.markPasteRule=Bo;exports.mergeAttributes=tr;exports.nodeInputRule=bo;exports.nodePasteRule=_o;exports.parseIndentedBlocks=dr;exports.posToDOMRect=Ls;exports.renderNestedMarkdownContent=hr;exports.shimExports=un;exports.textblockTypeInputRule=Eo;exports.useCurrentEditor=zl;exports.useEditorState=Il;exports.wrappingInputRule=Mo;
|
|
54
|
+
*/var rn;function xl(){return rn||(rn=1,process.env.NODE_ENV!=="production"&&(function(){function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=T,t=lt(),r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,s=e.useRef,o=e.useEffect,l=e.useMemo,a=e.useDebugValue;Ze.useSyncExternalStoreWithSelector=function(c,u,f,h,d){var m=s(null);if(m.current===null){var p={hasValue:!1,value:null};m.current=p}else p=m.current;m=l(function(){function y(b){if(!S){if(S=!0,k=b,b=h(b),d!==void 0&&p.hasValue){var C=p.value;if(d(C,b))return x=C}return x=b}if(C=x,r(k,b))return C;var O=h(b);return d!==void 0&&d(C,O)?(k=b,C):(k=b,x=O)}var S=!1,k,x,E=f===void 0?null:f;return[function(){return y(u())},E===null?void 0:function(){return y(E())}]},[u,f,h,d]);var g=i(c,m[0],m[1]);return o(function(){p.hasValue=!0,p.value=g},[g]),a(g),g},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Ze}var sn;function kl(){return sn||(sn=1,process.env.NODE_ENV==="production"?Te.exports=Sl():Te.exports=xl()),Te.exports}var bl=kl(),El=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},Ml=({contentComponent:n})=>{const e=cn.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return J.jsx(J.Fragment,{children:Object.values(e)})};function Cl(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:an.createPortal(r.reactElement,r.element,t)},n.forEach(i=>i())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(i=>i())}}}var Rl=class extends T.Component{constructor(n){var e;super(n),this.editorContentRef=T.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=n.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const e=this.props.editor;if(e&&!e.isDestroyed&&((n=e.view.dom)!=null&&n.parentNode)){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=Cl(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((n=e.view.dom)!=null&&n.parentNode))return;const t=document.createElement("div");t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return J.jsxs(J.Fragment,{children:[J.jsx("div",{ref:El(e,this.editorContentRef),...t}),(n==null?void 0:n.contentComponent)&&J.jsx(Ml,{contentComponent:n.contentComponent})]})}},Tl=T.forwardRef((n,e)=>{const t=T.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return T.createElement(Rl,{key:t,innerRef:e,...n})});T.memo(Tl);var Al=typeof window<"u"?T.useLayoutEffect:T.useEffect,Nl=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function Ol(n){var e;const[t]=T.useState(()=>new Nl(n.editor)),r=bl.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:wl);return Al(()=>t.watch(n.editor),[n.editor,t]),T.useDebugValue(r),r}process.env.NODE_ENV;var Rt=T.createContext({editor:null});Rt.Consumer;var Il=()=>T.useContext(Rt),mr=T.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),zl=()=>T.useContext(mr),Pl=T.forwardRef((n,e)=>{const{onDragStart:t}=zl(),r=n.as||"div";return J.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function on(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function ln(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function $l(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function Dl(n){if(on(n)||ln(n))return!0;if($l(n)){const e=n.type;if(e)return on(e)||ln(e)}return!1}function Bl(){try{if(T.version)return parseInt(T.version.split(".")[0],10)>=19}catch{}return!1}var gr=class{constructor(n,{editor:e,props:t={},as:r="div",className:i=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=n,this.editor=e,this.props=t,this.element=document.createElement(r),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?an.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var n;const e=this.component,t=this.props,r=this.editor,i=Bl(),s=Dl(e),o={...t};o.ref&&!(i||s)&&delete o.ref,!o.ref&&(i||s)&&(o.ref=l=>{this.ref=l}),this.reactElement=J.jsx(e,{...o}),(n=r==null?void 0:r.contentComponent)==null||n.setRenderer(this.id,this)}updateProps(n={}){this.props={...this.props,...n},this.render()}destroy(){var n;const e=this.editor;(n=e==null?void 0:e.contentComponent)==null||n.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(n){Object.keys(n).forEach(e=>{this.element.setAttribute(e,n[e])})}};T.createContext({markViewContentRef:()=>{}});var _l=class extends $o{constructor(n,e,t){if(super(n,e,t),this.selectionRafId=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}mount(){const n={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:T.createRef()};if(!this.component.displayName){const a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement&&(a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper"),a.appendChild(this.contentDOMElement))}},i=this.component,s=T.memo(a=>J.jsx(mr.Provider,{value:r,children:T.createElement(i,a)}));s.displayName="ReactNodeView";let o=this.node.isInline?"span":"div";this.options.as&&(o=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new gr(s,{editor:this.editor,props:n,as:o,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var n;if(this.renderer.element.firstElementChild&&!((n=this.renderer.element.firstElementChild)!=null&&n.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:n,to:e}=this.editor.state.selection,t=this.getPos();if(typeof t=="number")if(n<=t&&e>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(n,e,t){const r=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(n.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,s=this.decorations,o=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:i,oldDecorations:s,newNode:n,newDecorations:e,oldInnerDecorations:o,innerDecorations:t,updateProps:()=>r({node:n,decorations:e,innerDecorations:t})})}return n===this.node&&this.decorations===e&&this.innerDecorations===t||(this.node=n,this.decorations=e,this.innerDecorations=t,r({node:n,decorations:e,innerDecorations:t})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let n={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,t=Cs(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function Ll(n,e){return t=>t.editor.contentComponent?new _l(n,t,e):{}}function yr(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=yr(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function Fl(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=yr(n))&&(r&&(r+=" "),r+=e);return r}exports.AllSelection=F;exports.DOMParser=Ie;exports.DOMSerializer=ct;exports.EditorContext=Rt;exports.Extension=W;exports.Fragment=v;exports.InputRule=we;exports.MappablePosition=ir;exports.Mapping=me;exports.Mark=lo;exports.Node3=Po;exports.NodeSelection=R;exports.NodeViewWrapper=Pl;exports.PasteRule=Et;exports.Plugin=oi;exports.PluginKey=li;exports.ReactNodeViewRenderer=Ll;exports.ReactRenderer=gr;exports.ResizableNodeView=Co;exports.Selection=A;exports.SelectionRange=An;exports.Slice=w;exports.TextSelection=D;exports.Transform=Tn;exports.callOrReturn=j;exports.canInsertNode=Ro;exports.clsx=Fl;exports.combineTransactionSteps=Yn;exports.createInlineMarkdownSpec=ur;exports.deleteSelection=Be;exports.dropPoint=Zr;exports.escapeForRegEx=To;exports.findChildrenInRange=Es;exports.findParentNode=ve;exports.findParentNodeClosestToPos=Zn;exports.getAttributes=As;exports.getChangedRanges=rr;exports.getExtensionField=ae;exports.getMarksBetween=xt;exports.getNodeAtPosition=Is;exports.getNodeType=P;exports.getText=Rs;exports.getTextSerializersFromSchema=nr;exports.getUpdatedPosition=Bs;exports.isActive=zs;exports.isAtEndOfNode=Ps;exports.isAtStartOfNode=$s;exports.isList=ot;exports.isNodeActive=le;exports.isNodeEmpty=kt;exports.isNodeSelection=Ds;exports.isNumber=ao;exports.isTextSelection=St;exports.markInputRule=xo;exports.markPasteRule=Do;exports.mergeAttributes=er;exports.nodeInputRule=ko;exports.nodePasteRule=Bo;exports.parseIndentedBlocks=fr;exports.posToDOMRect=_s;exports.renderNestedMarkdownContent=dr;exports.shimExports=cn;exports.textblockTypeInputRule=bo;exports.useCurrentEditor=Il;exports.useEditorState=Ol;exports.wrappingInputRule=Eo;
|