react-tiptap-base-editor 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/assets/index-DgxxYiuK.css +1 -0
  2. package/dist/assets/index-iWUyV8z0.js +248 -0
  3. package/dist/components/tiptap-icons/video-icon.d.ts +3 -0
  4. package/dist/components/tiptap-icons/video-icon.d.ts.map +1 -0
  5. package/dist/components/tiptap-node/video-embed-node/index.d.ts +2 -0
  6. package/dist/components/tiptap-node/video-embed-node/index.d.ts.map +1 -0
  7. package/dist/components/tiptap-node/video-embed-node/video-embed-component.d.ts +4 -0
  8. package/dist/components/tiptap-node/video-embed-node/video-embed-component.d.ts.map +1 -0
  9. package/dist/components/tiptap-node/video-embed-node/video-embed-extension.d.ts +22 -0
  10. package/dist/components/tiptap-node/video-embed-node/video-embed-extension.d.ts.map +1 -0
  11. package/dist/components/tiptap-templates/simple/simple-editor.d.ts +1 -0
  12. package/dist/components/tiptap-templates/simple/simple-editor.d.ts.map +1 -1
  13. package/dist/components/tiptap-ui/video-embed-button/index.d.ts +3 -0
  14. package/dist/components/tiptap-ui/video-embed-button/index.d.ts.map +1 -0
  15. package/dist/components/tiptap-ui/video-embed-button/use-video-embed.d.ts +16 -0
  16. package/dist/components/tiptap-ui/video-embed-button/use-video-embed.d.ts.map +1 -0
  17. package/dist/components/tiptap-ui/video-embed-button/video-embed-button.d.ts +8 -0
  18. package/dist/components/tiptap-ui/video-embed-button/video-embed-button.d.ts.map +1 -0
  19. package/dist/components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.d.ts +1 -1
  20. package/dist/components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.d.ts.map +1 -1
  21. package/dist/components/tiptap-ui-primitive/popover/popover.d.ts.map +1 -1
  22. package/dist/components/tiptap-ui-primitive/tooltip/tooltip.d.ts.map +1 -1
  23. package/dist/contexts/rtbe-portal-context.d.ts +7 -0
  24. package/dist/contexts/rtbe-portal-context.d.ts.map +1 -0
  25. package/dist/index.cjs +50 -50
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.ts +3 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.html +14 -0
  30. package/dist/index.js +5316 -4850
  31. package/dist/index.js.map +1 -1
  32. package/dist/lib/rtbe-scope.d.ts +3 -0
  33. package/dist/lib/rtbe-scope.d.ts.map +1 -0
  34. package/dist/styles/index.css +1 -1
  35. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),D=require("react"),Ui=require("react-dom");function Mf(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const y=Mf(D),va=Mf(Ui);var po=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Tf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mo={exports:{}},ks={};/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),L=require("react"),Ui=require("react-dom");function Pf(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const y=Pf(L),va=Pf(Ui);var mo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function jf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var go={exports:{}},ks={};/**
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 nu;function B0(){if(nu)return ks;nu=1;var t=D;function e(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,o=t.useEffect,i=t.useLayoutEffect,s=t.useDebugValue;function l(d,h){var f=h(),p=r({inst:{value:f,getSnapshot:h}}),m=p[0].inst,v=p[1];return i(function(){m.value=f,m.getSnapshot=h,a(m)&&v({inst:m})},[d,f,h]),o(function(){return a(m)&&v({inst:m}),d(function(){a(m)&&v({inst:m})})},[d]),s(f),f}function a(d){var h=d.getSnapshot;d=d.value;try{var f=h();return!n(d,f)}catch{return!0}}function c(d,h){return h()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:l;return ks.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,ks}var Es={};/**
9
+ */var uu;function K0(){if(uu)return ks;uu=1;var t=L;function e(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,o=t.useEffect,i=t.useLayoutEffect,s=t.useDebugValue;function l(d,h){var f=h(),p=r({inst:{value:f,getSnapshot:h}}),m=p[0].inst,v=p[1];return i(function(){m.value=f,m.getSnapshot=h,a(m)&&v({inst:m})},[d,f,h]),o(function(){return a(m)&&v({inst:m}),d(function(){a(m)&&v({inst:m})})},[d]),s(f),f}function a(d){var h=d.getSnapshot;d=d.value;try{var f=h();return!n(d,f)}catch{return!0}}function c(d,h){return h()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:l;return ks.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,ks}var Es={};/**
10
10
  * @license React
11
11
  * use-sync-external-store-shim.development.js
12
12
  *
@@ -14,19 +14,19 @@
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 ru;function _0(){return ru||(ru=1,process.env.NODE_ENV!=="production"&&(function(){function t(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}function e(f,p){u||o.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 m=p();if(!d){var v=p();i(m,v)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}v=s({inst:{value:m,getSnapshot:p}});var b=v[0].inst,C=v[1];return a(function(){b.value=m,b.getSnapshot=p,n(b)&&C({inst:b})},[f,m,p]),l(function(){return n(b)&&C({inst:b}),f(function(){n(b)&&C({inst:b})})},[f]),c(m),m}function n(f){var p=f.getSnapshot;f=f.value;try{var m=p();return!i(f,m)}catch{return!0}}function r(f,p){return p()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=D,i=typeof Object.is=="function"?Object.is:t,s=o.useState,l=o.useEffect,a=o.useLayoutEffect,c=o.useDebugValue,u=!1,d=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:e;Es.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:h,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Es}var ou;function ba(){return ou||(ou=1,process.env.NODE_ENV==="production"?mo.exports=B0():mo.exports=_0()),mo.exports}var Af=ba();function Se(t){this.content=t}Se.prototype={constructor:Se,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,o=r.find(t),i=r.content.slice();return o==-1?i.push(n||t,e):(i[o+1]=e,n&&(i[o]=n)),new Se(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Se(n)},addToStart:function(t,e){return new Se([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Se(n)},addBefore:function(t,e,n){var r=this.remove(e),o=r.content.slice(),i=r.find(t);return o.splice(i==-1?o.length:i,0,e,n),new Se(o)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Se.from(t),t.size?new Se(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Se.from(t),t.size?new Se(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Se.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Se.from=function(t){if(t instanceof Se)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Se(e)};function Rf(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o==i){n+=o.nodeSize;continue}if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)n++;return n}if(o.content.size||i.content.size){let s=Rf(o.content,i.content,n+1);if(s!=null)return s}n+=o.nodeSize}}function Of(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:n,b:r};let s=t.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let c=0,u=Math.min(s.text.length,l.text.length);for(;c<u&&s.text[s.text.length-c-1]==l.text[l.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(s.content.size||l.content.size){let c=Of(s.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}class A{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,o=0,i){for(let s=0,l=0;l<n;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let i="",s=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new A(o,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],o=0;if(n>e)for(let i=0,s=0;s<n;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),o+=l.nodeSize),s=a}return new A(r,o)}cutByIndex(e,n){return e==n?A.empty:e==0&&n==this.content.length?this:new A(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new A(o,i)}addToStart(e){return new A([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new A(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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 n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let o=this.content[n];e(o,r,n),r+=o.nodeSize}}findDiffStart(e,n=0){return Rf(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Of(this,e,n,r)}findIndex(e){if(e==0)return go(0,e);if(e==this.size)return go(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=this.child(n),i=r+o.nodeSize;if(i>=e)return i==e?go(n+1,i):go(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return A.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new A(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return A.empty;let n,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(n||(n=e.slice(0,o)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new A(n||e,r)}static from(e){if(!e)return A.empty;if(e instanceof A)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new A([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}A.empty=new A([],0);const Ms={index:0,offset:0};function go(t,e){return Ms.index=t,Ms.offset=e,Ms}function qo(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!qo(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!qo(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let re=class wl{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&qo(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let o=r.create(n.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return wl.none;if(e instanceof wl)return[e];let n=e.slice();return n.sort((r,o)=>r.type.rank-o.type.rank),n}};re.none=[];class Go extends Error{}class P{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=If(this.content,e+this.openStart,n);return r&&new P(r,this.openStart,this.openEnd)}removeBetween(e,n){return new P(Nf(this.content,e+this.openStart,n+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,n){if(!n)return P.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new P(A.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)o++;return new P(e,r,o)}}P.empty=new P(A.empty,0,0);function Nf(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(o==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Nf(i.content,e-o-1,n-o-1)))}function If(t,e,n,r){let{index:o,offset:i}=t.findIndex(e),s=t.maybeChild(o);if(i==e||s.isText)return r&&!r.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=If(s.content,e-i-1,n,s);return l&&t.replaceChild(o,s.copy(l))}function H0(t,e,n){if(n.openStart>t.depth)throw new Go("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Go("Inconsistent open depths");return Lf(t,e,n,0)}function Lf(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r<t.depth-n.openStart){let s=Lf(t,e,n,r+1);return i.copy(i.content.replaceChild(o,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,l=s.content;return Sn(s,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=F0(n,t);return Sn(i,Pf(t,s,l,e,r))}else return Sn(i,Jo(t,e,r))}function Df(t,e){if(!e.type.compatibleContent(t.type))throw new Go("Cannot join "+e.type.name+" onto "+t.type.name)}function Sl(t,e,n){let r=t.node(n);return Df(r,e.node(n)),r}function wn(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Er(t,e,n,r){let o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(wn(t.nodeAfter,r),i++));for(let l=i;l<s;l++)wn(o.child(l),r);e&&e.depth==n&&e.textOffset&&wn(e.nodeBefore,r)}function Sn(t,e){return t.type.checkContent(e),t.copy(e)}function Pf(t,e,n,r,o){let i=t.depth>o&&Sl(t,e,o+1),s=r.depth>o&&Sl(n,r,o+1),l=[];return Er(null,t,o,l),i&&s&&e.index(o)==n.index(o)?(Df(i,s),wn(Sn(i,Pf(t,e,n,r,o+1)),l)):(i&&wn(Sn(i,Jo(t,e,o+1)),l),Er(e,n,o,l),s&&wn(Sn(s,Jo(n,r,o+1)),l)),Er(r,null,o,l),new A(l)}function Jo(t,e,n){let r=[];if(Er(null,t,n,r),t.depth>n){let o=Sl(t,e,n+1);wn(Sn(o,Jo(t,e,n+1)),r)}return Er(e,null,n,r),new A(r)}function F0(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(A.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}class jr{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return re.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),o=e.maybeChild(n);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Zo(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],o=0,i=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new jr(n,r,i)}static resolveCached(e,n){let r=iu.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==n)return s}else iu.set(e,r=new $0);let o=r.elts[r.i]=jr.resolve(e,n);return r.i=(r.i+1)%V0,o}}class $0{constructor(){this.elts=[],this.i=0}}const V0=12,iu=new WeakMap;class Zo{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const z0=Object.create(null);let Xt=class kl{constructor(e,n,r,o=re.none){this.type=e,this.attrs=n,this.marks=o,this.content=r||A.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,o=0){this.content.nodesBetween(e,n,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,o){return this.content.textBetween(e,n,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&qo(this.attrs,n||e.defaultAttrs||z0)&&re.sameSet(this.marks,r||re.none)}copy(e=null){return e==this.content?this:new kl(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new kl(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return P.empty;let o=this.resolve(e),i=this.resolve(n),s=r?0:o.sharedDepth(n),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new P(c,o.depth-s,i.depth-s)}replace(e,n,r){return H0(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:o}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(o==e||n.isText)return n;e-=o+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}}resolve(e){return jr.resolveCached(this,e)}resolveNoCache(e){return jr.resolve(this,e)}rangeHasMark(e,n,r){let o=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),jf(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=A.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=re.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!re.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let o=A.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,o,r);return i.type.checkAttrs(i.attrs),i}};Xt.prototype.text=void 0;class Yo extends Xt{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):jf(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Yo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Yo(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function jf(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Tn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new U0(e,n);if(r.next==null)return Tn.empty;let o=Bf(r);r.next&&r.err("Unexpected trailing text");let i=Y0(Z0(o));return X0(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let o=this;for(let i=n;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!n||a.validEnd))return A.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(d)==-1){o.push(d);let h=i(d,l.concat(u));if(h)return h}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&n(r.next[o].next)}return n(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
18
- `)}}Tn.empty=new Tn(!0);class U0{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Bf(t){let e=[];do e.push(W0(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function W0(t){let e=[];do e.push(K0(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function K0(t){let e=J0(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=q0(t,e);else break;return e}function su(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function q0(t,e){let n=su(t),r=n;return t.eat(",")&&(t.next!="}"?r=su(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function G0(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let i in n){let s=n[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&t.err("No node type or group '"+e+"' found"),o}function J0(t){if(t.eat("(")){let e=Bf(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=G0(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Z0(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=n())}else if(s.type=="star"){let a=n();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=n();o(i(s.expr,a),u),a=u}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=n();r(a,u),o(i(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function _f(t,e){return e-t}function lu(t,e){let n=[];return r(e),n.sort(_f);function r(o){let i=t[o];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&n.indexOf(a)==-1&&r(a)}}}function Y0(t){let e=Object.create(null);return n(lu(t,0));function n(r){let o=[];r.forEach(s=>{t[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);lu(t,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new Tn(r.indexOf(t.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(_f);i.next.push({type:o[s][0],next:e[l.join(",")]||n(l)})}return i}}function X0(t,e){for(let n=0,r=[t];n<r.length;n++){let o=r[n],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Hf(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Ff(t,e){let n=Object.create(null);for(let r in t){let o=e&&e[r];if(o===void 0){let i=t[r];if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=o}return n}function $f(t,e,n,r){for(let o in e)if(!(o in t))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let o in t){let i=t[o];i.validate&&i.validate(e[o])}}function Vf(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new e2(t,r,e[r]);return n}let au=class zf{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Vf(e,r.attrs),this.defaultAttrs=Hf(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Tn.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ff(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Xt(this,this.computeAttrs(e),A.from(n),re.setFrom(r))}createChecked(e=null,n,r){return n=A.from(n),this.checkContent(n),new Xt(this,this.computeAttrs(e),n,re.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=A.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let o=this.contentMatch.matchFragment(n),i=o&&o.fillBefore(A.empty,!0);return i?new Xt(this,e,n.append(i),re.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){$f(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:re.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,s)=>r[i]=new zf(i,n,s));let o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Q0(t,e,n){let r=n.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class e2{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Q0(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Wi{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=Vf(e,o.attrs),this.excluded=null;let i=Hf(this.attrs);this.instance=i?new re(this,i):null}create(e=null){return!e&&this.instance?this.instance:new re(this,Ff(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new Wi(i,o++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){$f(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Uf{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=Se.from(e.nodes),n.marks=Se.from(e.marks||{}),this.nodes=au.compile(this.spec.nodes,this),this.marks=Wi.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=Tn.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?cu(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:cu(this,s.split(" "))}this.nodeFromJSON=o=>Xt.fromJSON(this,o),this.markFromJSON=o=>re.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof au){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,o)}text(e,n){let r=this.nodes.text;return new Yo(r,r.defaultAttrs,e,re.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function cu(t,e){let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(let l in t.marks){let a=t.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function t2(t){return t.tag!=null}function n2(t){return t.style!=null}class Qt{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(o=>{if(t2(o))this.tags.push(o);else if(n2(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new du(this,n,!1);return r.addAll(e,re.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new du(this,n,!0);return r.addAll(e,re.none,n.from,n.to),P.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(i2(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,n,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<n.length;s++){let l=n[s];if((l.priority==null?50:l.priority)<i)break}n.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=fu(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=fu(s)),s.node||s.ignore||s.mark||(s.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Qt(e,Qt.schemaRules(e)))}}const Wf={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},r2={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Kf={ol:!0,ul:!0},Br=1,El=2,Mr=4;function uu(t,e,n){return e!=null?(e?Br:0)|(e==="full"?El:0):t&&t.whitespace=="pre"?Br|El:n&~Mr}class yo{constructor(e,n,r,o,i,s){this.type=e,this.attrs=n,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=re.none,this.match=i||(s&Mr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(A.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Br)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let n=A.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(A.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Wf.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class du{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=n.topNode,i,s=uu(null,n.preserveWhitespace,0)|(r?Mr:0);o?i=new yo(o.type,o.attrs,re.none,!0,n.topMatch||o.type.contentMatch,s):r?i=new yo(null,null,re.none,!0,null,s):i=new yo(e.schema.topNodeType,null,re.none,!0,null,s),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,o=this.top,i=o.options&El?"full":this.localPreserveWS||(o.options&Br)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
19
- `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(s.text(l[a]),n,!/\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=o.content[o.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(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Kf.hasOwnProperty(s)&&this.parser.normalizeLists&&o2(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:r2.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);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(Wf.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
20
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(i,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,o){let i,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,n);this.findAtPoint(e,i)}findPlace(e,n,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)n=this.enterInner(o[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let o=this.findPlace(e,n,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=re.none;for(let l of o.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):hu(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,n,r,o){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,o)),i}enterInner(e,n,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=uu(e,i,s.options);s.options&Mr&&s.content.length==0&&(l|=Mr);let a=re.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):hu(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new yo(e,n,a,o,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].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 n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Br)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&n.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function o2(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Kf.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function i2(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function fu(t){let e={};for(let n in t)e[n]=t[n];return e}function hu(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&s(u))return!0}};if(s(o.contentMatch))return!0}}class Ln{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Ts(n).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,n);u&&(i.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:o}=Bo(Ts(n),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,o)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&Bo(Ts(r),o(e,n),null,e.attrs)}static renderSpec(e,n,r=null,o){return Bo(e,n,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ln(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=pu(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return pu(e.marks)}}function pu(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Ts(t){return t.document||window.document}const mu=new WeakMap;function s2(t){let e=mu.get(t);return e===void 0&&mu.set(t,e=l2(t)),e}function l2(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)n(r[o]);else for(let o in r)n(r[o])}return n(t),e}function Bo(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=s2(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=o.indexOf(" ");s>0&&(n=o.slice(0,s),o=o.slice(s+1));let l,a=n?t.createElementNS(n,o):t.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let h=d.indexOf(" ");h>0?a.setAttributeNS(d.slice(0,h),d.slice(h+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let h=e[d];if(h===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=Bo(t,h,n,r);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const qf=65535,Gf=Math.pow(2,16);function a2(t,e){return t+e*Gf}function gu(t){return t&qf}function c2(t){return(t-(t&qf))/Gf}const Jf=1,Zf=2,_o=4,Yf=8;class Ml{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Yf)>0}get deletedBefore(){return(this.delInfo&(Jf|_o))>0}get deletedAfter(){return(this.delInfo&(Zf|_o))>0}get deletedAcross(){return(this.delInfo&_o)>0}}class Ve{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ve.empty)return Ve.empty}recover(e){let n=0,r=gu(e);if(!this.inverted)for(let o=0;o<r;o++)n+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+n+c2(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+s],d=a+c;if(e<=d){let h=c?e==a?-1:e==d?1:n:n,f=a+o+(h<0?0:u);if(r)return f;let p=e==(n<0?a:d)?null:a2(l/3,e-a),m=e==a?Zf:e==d?Jf:_o;return(n<0?e!=a:e!=d)&&(m|=Yf),new Ml(f,m,p)}o+=u-c}return r?e+o:new Ml(e+o,0,null)}touches(e,n){let r=0,o=gu(n),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+n],u=this.ranges[o+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new Ve(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ve.empty:new Ve(e<0?[0,-e,0]:[0,0,e])}}Ve.empty=new Ve([]);class _r{constructor(e,n,r=0,o=e?e.length:0){this.mirror=n,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new _r(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let o=e.getMirror(n);this.appendMap(e._maps[n],o!=null&&o<n?r+o:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let o=e.getMirror(n);this.appendMap(e._maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let e=new _r;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],l=s.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new Ml(e,o,null)}}const As=Object.create(null);class Ne{getMap(){return Ve.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=As[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in As)throw new RangeError("Duplicate use of step JSON ID "+e);return As[e]=n,n.prototype.jsonID=e,n}}class pe{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new pe(e,null)}static fail(e){return new pe(null,e)}static fromReplace(e,n,r,o){try{return pe.ok(e.replace(n,r,o))}catch(i){if(i instanceof Go)return pe.fail(i.message);throw i}}}function Ca(t,e,n){let r=[];for(let o=0;o<t.childCount;o++){let i=t.child(o);i.content.size&&(i=i.copy(Ca(i.content,e,i))),i.isInline&&(i=e(i,n,o)),r.push(i)}return A.fromArray(r)}class Jt extends Ne{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new P(Ca(n.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),n.openStart,n.openEnd);return pe.fromReplace(e,this.from,this.to,i)}invert(){return new rt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Jt(n.pos,r.pos,this.mark)}merge(e){return e instanceof Jt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Jt(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Jt(n.from,n.to,e.markFromJSON(n.mark))}}Ne.jsonID("addMark",Jt);class rt extends Ne{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new P(Ca(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return pe.fromReplace(e,this.from,this.to,r)}invert(){return new Jt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new rt(n.pos,r.pos,this.mark)}merge(e){return e instanceof rt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rt(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new rt(n.from,n.to,e.markFromJSON(n.mark))}}Ne.jsonID("removeMark",rt);class Zt extends Ne{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return pe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return pe.fromReplace(e,this.pos,this.pos+1,new P(A.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;o<n.marks.length;o++)if(!n.marks[o].isInSet(r))return new Zt(this.pos,n.marks[o]);return new Zt(this.pos,this.mark)}}return new An(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Zt(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Zt(n.pos,e.markFromJSON(n.mark))}}Ne.jsonID("addNodeMark",Zt);class An extends Ne{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return pe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return pe.fromReplace(e,this.pos,this.pos+1,new P(A.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Zt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new An(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new An(n.pos,e.markFromJSON(n.mark))}}Ne.jsonID("removeNodeMark",An);class ve extends Ne{constructor(e,n,r,o=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=o}apply(e){return this.structure&&Tl(e,this.from,this.to)?pe.fail("Structure replace would overwrite content"):pe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ve([this.from,this.to-this.from,this.slice.size])}invert(e){return new ve(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new ve(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ve)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?P.empty:new P(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ve(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?P.empty:new P(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ve(e.from,this.to,n,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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ve(n.from,n.to,P.fromJSON(e,n.slice),!!n.structure)}}Ne.jsonID("replace",ve);class be extends Ne{constructor(e,n,r,o,i,s,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Tl(e,this.from,this.gapFrom)||Tl(e,this.gapTo,this.to)))return pe.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return pe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?pe.fromReplace(e,this.from,this.to,r):pe.fail("Content does not fit in gap")}getMap(){return new Ve([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new be(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||o<n.pos||i>r.pos?null:new be(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new be(n.from,n.to,n.gapFrom,n.gapTo,P.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ne.jsonID("replaceAround",be);function Tl(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function u2(t,e,n,r){let o=[],i=[],s,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let h=Math.max(c,e),f=Math.min(c+a.nodeSize,n),p=r.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(s&&s.to==h&&s.mark.eq(d[m])?s.to=f:o.push(s=new rt(h,f,d[m])));l&&l.to==h?l.to=f:i.push(l=new Jt(h,f,r))}}),o.forEach(a=>t.step(a)),i.forEach(a=>t.step(a))}function d2(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof Wi){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],h;for(let f=0;f<o.length;f++){let p=o[f];p.step==i-1&&d.eq(o[f].style)&&(h=p)}h?(h.to=c,h.step=i):o.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>t.step(new rt(s.from,s.to,s.style)))}function xa(t,e,n,r=n.contentMatch,o=!0){let i=t.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)s.push(new ve(l,u,P.empty));else{r=d;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new rt(l,u,c.marks[h]));if(o&&c.isText&&n.whitespace!="pre"){let h,f=/\r?\n|\r/g,p;for(;h=f.exec(c.text);)p||(p=new P(A.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new ve(l+h.index,l+h.index+h[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(A.empty,!0);t.replace(l,l,new P(a,0,0))}for(let a=s.length-1;a>=0;a--)t.step(s[a])}function f2(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function ur(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let o=t.$from.node(r),i=t.$from.index(r),s=t.$to.indexAfter(r);if(r<t.depth&&o.canReplace(i,s,n))return r;if(r==0||o.type.spec.isolating||!f2(o,i,s))break}return null}function h2(t,e,n){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,u=A.empty,d=0;for(let p=i,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=A.from(r.node(p).copy(u)),d++):a--;let h=A.empty,f=0;for(let p=i,m=!1;p>n;p--)m||o.after(p+1)<o.end(p)?(m=!0,h=A.from(o.node(p).copy(h)),f++):c++;t.step(new be(a,c,s,l,new P(u.append(h),d,f),u.size-d,!0))}function wa(t,e,n=null,r=t){let o=p2(t,e),i=o&&m2(r,e);return i?o.map(yu).concat({type:e,attrs:n}).concat(i.map(yu)):null}function yu(t){return{type:t,attrs:null}}function p2(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(r,o,s)?i:null}function m2(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:s}function g2(t,e,n){let r=A.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let l=n[s].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=A.from(n[s].type.create(n[s].attrs,r))}let o=e.start,i=e.end;t.step(new be(o,i,o,i,new P(r,0,0),n.length,!0))}function y2(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&v2(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&Qf(t,s,l,i),xa(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let u=t.mapping.slice(i),d=u.map(l,1),h=u.map(l+s.nodeSize,1);return t.step(new be(d,h,d+1,h-1,new P(A.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Xf(t,s,l,i),!1}})}function Xf(t,e,n,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=t.mapping.slice(r).map(n+1+i+s.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Qf(t,e,n,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+i);t.replaceWith(s,s+1,e.type.schema.text(`
21
- `))}})}function v2(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function b2(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new be(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new P(A.from(s),0,0),1,!0))}function Rt(t,e,n=1,r){let o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=n-2;c>i;c--,u--){let d=o.node(c),h=o.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(h,d.childCount),p=r&&r[u+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(h+1,d.childCount)||!m.type.validContent(f))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function C2(t,e,n=1,r){let o=t.doc.resolve(e),i=A.empty,s=A.empty;for(let l=o.depth,a=o.depth-n,c=n-1;l>a;l--,c--){i=A.from(o.node(l).copy(i));let u=r&&r[c];s=A.from(u?u.type.create(u.attrs,s):o.node(l).copy(s))}t.step(new ve(e,e,new P(i.append(s),n,n),!0))}function dn(t,e){let n=t.resolve(e),r=n.index();return eh(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function x2(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),s=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function eh(t,e){return!!(t&&e&&!t.isLeaf&&x2(t,e))}function Ki(t,e,n=-1){let r=t.resolve(e);for(let o=r.depth;;o--){let i,s,l=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&eh(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=n<0?r.before(o):r.after(o)}}function w2(t,e,n){let r=null,{linebreakReplacement:o}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(o&&s.inlineContent){let u=s.whitespace=="pre",d=!!s.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);Qf(t,u.node(),u.before(),l)}s.inlineContent&&xa(t,e+n-1,s,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new ve(c,a.map(e+n,-1),P.empty,!0)),r===!0){let u=t.doc.resolve(c);Xf(t,u.node(),u.before(),t.steps.length)}return t}function S2(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,n))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function th(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let o=n.content;for(let i=0;i<n.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),u=!1;if(i==1)u=c.canReplace(a,a,o);else{let d=c.contentMatchAt(a).findWrapping(o.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function qi(t,e,n=e,r=P.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return nh(o,i,r)?new ve(e,n,r):new k2(o,i,r).fit()}function nh(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class k2{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=A.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=A.from(e.node(o).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(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new P(i,s,l);return e>-1?new be(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new ve(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=Rs(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(s?c.matchType(s.type)||(d=c.fillBefore(A.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Rs(e,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new P(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Rs(e,n);if(o.childCount<=1&&n>0){let i=e.size-n<=n+o.size;this.unplaced=new P(br(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new P(br(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:d,type:h}=this.frontier[n];if(o){for(let m=0;m<o.childCount;m++)u.push(o.child(m));d=d.matchFragment(o)}let f=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),v=d.matchType(m.type);if(!v)break;c++,(c>1||a==0||m.content.size)&&(d=v,u.push(rh(m.mark(h.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=Cr(this.placed,n,A.from(u)),this.frontier[n].match=d,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,v=l;m<f;m++){let b=v.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),v=b.content}this.unplaced=p?e==0?P.empty:new P(br(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new P(br(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Os(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=Os(e,n,o,r,i);if(s){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Os(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Cr(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Cr(this.placed,this.depth,A.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(A.empty,!0);n.childCount&&(this.placed=Cr(this.placed,this.frontier.length,n))}}function br(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(br(t.firstChild.content,e-1,n)))}function Cr(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Cr(t.lastChild.content,e-1,n)))}function Rs(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function rh(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,rh(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(A.empty,!0)))),t.copy(r)}function Os(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!E2(n,i.content,s)?l:null}function E2(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function M2(t){return t.spec.defining||t.spec.definingForContent}function T2(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let o=t.doc.resolve(e),i=t.doc.resolve(n);if(nh(o,i,r))return t.step(new ve(e,n,r));let s=ih(o,t.doc.resolve(n));s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let h=o.depth,f=o.pos-1;h>0;h--,f--){let p=o.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(h)>-1?l=h:o.before(h)==f&&s.splice(1,0,-h)}let a=s.indexOf(l),c=[],u=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==r.openStart)break;h=p.content}for(let h=u-1;h>=0;h--){let f=c[h],p=M2(f.type);if(p&&!f.sameMarkup(o.node(Math.abs(l)-1)))u=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+u+1)%(r.openStart+1),p=c[f];if(p)for(let m=0;m<s.length;m++){let v=s[(m+a)%s.length],b=!0;v<0&&(b=!1,v=-v);let C=o.node(v-1),x=o.index(v-1);if(C.canReplaceWith(x,x,p.type,p.marks))return t.replace(o.before(v),b?i.after(v):n,new P(oh(r.content,0,r.openStart,f),f,r.openEnd))}}let d=t.steps.length;for(let h=s.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>d));h--){let f=s[h];f<0||(e=o.before(f),n=i.after(f))}}function oh(t,e,n,r,o){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(oh(i.content,e+1,n,r,i)))}if(e>r){let i=o.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(A.empty,!0))}return t}function A2(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=S2(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new P(A.from(r),0,0))}function R2(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n),i=ih(r,o);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function ih(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let i=t.start(o);if(i<t.pos-(t.depth-o)||e.end(o)>e.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&n.push(o)}return n}class Yn extends Ne{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return pe.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return pe.fromReplace(e,this.pos,this.pos+1,new P(A.from(o),0,n.isLeaf?0:1))}getMap(){return Ve.empty}invert(e){return new Yn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Yn(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Yn(n.pos,n.attr,n.value)}}Ne.jsonID("attr",Yn);class Hr extends Ne{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return pe.ok(r)}getMap(){return Ve.empty}invert(e){return new Hr(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Hr(n.attr,n.value)}}Ne.jsonID("docAttr",Hr);let nr=class extends Error{};nr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};nr.prototype=Object.create(Error.prototype);nr.prototype.constructor=nr;nr.prototype.name="TransformError";class sh{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new _r}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new nr(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=P.empty){let o=qi(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new P(A.from(r),0,0))}delete(e,n){return this.replace(e,n,P.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return T2(this,e,n,r),this}replaceRangeWith(e,n,r){return A2(this,e,n,r),this}deleteRange(e,n){return R2(this,e,n),this}lift(e,n){return h2(this,e,n),this}join(e,n=1){return w2(this,e,n),this}wrap(e,n){return g2(this,e,n),this}setBlockType(e,n=e,r,o=null){return y2(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return b2(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new Yn(e,n,r)),this}setDocAttribute(e,n){return this.step(new Hr(e,n)),this}addNodeMark(e,n){return this.step(new Zt(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof re)n.isInSet(r.marks)&&this.step(new An(e,n));else{let o=r.marks,i,s=[];for(;i=n.isInSet(o);)s.push(new An(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return C2(this,e,n,r),this}addMark(e,n,r){return u2(this,e,n,r),this}removeMark(e,n,r){return d2(this,e,n,r),this}clearIncompatible(e,n,r){return xa(this,e,n,r),this}}const Ns=Object.create(null);let q=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new O2(e.min(n),e.max(n))]}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 n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=P.empty){let r=n.content.lastChild,o=null;for(let l=0;l<n.openEnd;l++)o=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?P.empty:n),l==0&&Cu(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:l}=o[i],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),Cu(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let o=e.parent.inlineContent?new z(e):Wn(e.node(0),e.parent,e.pos,e.index(),n,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=n<0?Wn(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Wn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new ze(e.node(0))}static atStart(e){return Wn(e,e,0,0,1)||new ze(e)}static atEnd(e){return Wn(e,e,e.content.size,e.childCount,-1)||new ze(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ns[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Ns)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ns[e]=n,n.prototype.jsonID=e,n}getBookmark(){return z.between(this.$anchor,this.$head).getBookmark()}};q.prototype.visible=!0;class O2{constructor(e,n){this.$from=e,this.$to=n}}let vu=!1;function bu(t){!vu&&!t.parent.inlineContent&&(vu=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class z extends q{constructor(e,n=e){bu(e),bu(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return q.near(r);let o=e.resolve(n.map(this.anchor));return new z(o.parent.inlineContent?o:r,r)}replace(e,n=P.empty){if(super.replace(e,n),n==P.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof z&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Gi(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new z(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let i=q.findFrom(n,r,!0)||q.findFrom(n,-r,!0);if(i)n=i.$head;else return q.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(q.findFrom(e,-r,!0)||q.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=o<0&&(e=n))),new z(e,n)}}q.jsonID("text",z);class Gi{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Gi(e.map(this.anchor),e.map(this.head))}resolve(e){return z.between(e.resolve(this.anchor),e.resolve(this.head))}}class B extends q{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:o}=n.mapResult(this.anchor),i=e.resolve(o);return r?q.near(i):new B(i)}content(){return new P(A.from(this.node),0,0)}eq(e){return e instanceof B&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Sa(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new B(e.resolve(n.anchor))}static create(e,n){return new B(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}B.prototype.visible=!1;q.jsonID("node",B);class Sa{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Gi(r,r):new Sa(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&B.isSelectable(r)?new B(n):q.near(n)}}class ze extends q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=P.empty){if(n==P.empty){e.delete(0,e.doc.content.size);let r=q.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new ze(e)}map(e){return new ze(e)}eq(e){return e instanceof ze}getBookmark(){return N2}}q.jsonID("all",ze);const N2={map(){return this},resolve(t){return new ze(t)}};function Wn(t,e,n,r,o,i=!1){if(e.inlineContent)return z.create(t,n);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&B.isSelectable(l))return B.create(t,n-(o<0?l.nodeSize:0))}else{let a=Wn(t,l,n+o,o<0?l.childCount:0,o,i);if(a)return a}n+=l.nodeSize*o}return null}function Cu(t,e,n){let r=t.steps.length-1;if(r<e)return;let o=t.steps[r];if(!(o instanceof ve||o instanceof be))return;let i=t.mapping.maps[r],s;i.forEach((l,a,c,u)=>{s==null&&(s=u)}),t.setSelection(q.near(t.doc.resolve(s),n))}const xu=1,vo=2,wu=4;class I2 extends sh{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|xu)&~vo,this.storedMarks=null,this}get selectionSet(){return(this.updated&xu)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=vo,this}ensureMarks(e){return re.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&vo)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~vo,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||re.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(q.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=wu,this}get scrolledIntoView(){return(this.updated&wu)>0}}function Su(t,e){return!e||!t?t:t.bind(e)}class xr{constructor(e,n,r){this.name=e,this.init=Su(n.init,r),this.apply=Su(n.apply,r)}}const L2=[new xr("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new xr("selection",{init(t,e){return t.selection||q.atStart(e.doc)},apply(t){return t.selection}}),new xr("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new xr("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Is{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=L2.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new xr(r.key,r.spec.state,r))})}}class Jn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=o?o[s].n:0,c=o?o[s].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let d=0;d<this.config.plugins.length;d++)o.push(d<s?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),i=!0}o&&(o[s]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Jn(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new I2(this)}static create(e){let n=new Is(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Jn(n);for(let o=0;o<n.fields.length;o++)r[n.fields[o].name]=n.fields[o].init(e,r);return r}reconfigure(e){let n=new Is(this.schema,e.plugins),r=n.fields,o=new Jn(n);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[i].init(e,o)}return o}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,this[o.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Is(e.schema,e.plugins),i=new Jn(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=Xt.fromJSON(e.schema,n.doc);else if(s.name=="selection")i.selection=q.fromJSON(i.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[s.name]=c.fromJSON.call(a,e,n[l],i);return}}i[s.name]=s.init(e,i)}}),i}}function lh(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=lh(o,e,{})),n[r]=o}return n}class ae{constructor(e){this.spec=e,this.props={},e.props&&lh(e.props,this,this.props),this.key=e.key?e.key.key:ah("plugin")}getState(e){return e[this.key]}}const Ls=Object.create(null);function ah(t){return t in Ls?t+"$"+ ++Ls[t]:(Ls[t]=0,t+"$")}class ge{constructor(e="key"){this.key=ah(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ka=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function ch(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const uh=(t,e,n)=>{let r=ch(t,n);if(!r)return!1;let o=Ea(r);if(!o){let s=r.blockRange(),l=s&&ur(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(bh(t,o,e,-1))return!0;if(r.parent.content.size==0&&(rr(i,"end")||B.isSelectable(i)))for(let s=r.depth;;s--){let l=qi(t.doc,r.before(s),r.after(s),P.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(rr(i,"end")?q.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):B.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},D2=(t,e,n)=>{let r=ch(t,n);if(!r)return!1;let o=Ea(r);return o?dh(t,o,e):!1},P2=(t,e,n)=>{let r=hh(t,n);if(!r)return!1;let o=Ma(r);return o?dh(t,o,e):!1};function dh(t,e,n){let r=e.nodeBefore,o=r,i=e.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let u=o.lastChild;if(!u)return!1;o=u}let s=e.nodeAfter,l=s,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=qi(t.doc,i,a,P.empty);if(!c||c.from!=i||c instanceof ve&&c.slice.size>=a-i)return!1;if(n){let u=t.tr.step(c);u.setSelection(z.create(u.doc,i)),n(u.scrollIntoView())}return!0}function rr(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const fh=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=Ea(r)}let s=i&&i.nodeBefore;return!s||!B.isSelectable(s)?!1:(e&&e(t.tr.setSelection(B.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function Ea(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function hh(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const ph=(t,e,n)=>{let r=hh(t,n);if(!r)return!1;let o=Ma(r);if(!o)return!1;let i=o.nodeAfter;if(bh(t,o,e,1))return!0;if(r.parent.content.size==0&&(rr(i,"start")||B.isSelectable(i))){let s=qi(t.doc,r.before(),r.after(),P.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=t.tr.step(s);l.setSelection(rr(i,"start")?q.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):B.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},mh=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=Ma(r)}let s=i&&i.nodeAfter;return!s||!B.isSelectable(s)?!1:(e&&e(t.tr.setSelection(B.create(t.doc,i.pos)).scrollIntoView()),!0)};function Ma(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const j2=(t,e)=>{let n=t.selection,r=n instanceof B,o;if(r){if(n.node.isTextblock||!dn(t.doc,n.from))return!1;o=n.from}else if(o=Ki(t.doc,n.from,-1),o==null)return!1;if(e){let i=t.tr.join(o);r&&i.setSelection(B.create(i.doc,o-t.doc.resolve(o).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},B2=(t,e)=>{let n=t.selection,r;if(n instanceof B){if(n.node.isTextblock||!dn(t.doc,n.to))return!1;r=n.to}else if(r=Ki(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},_2=(t,e)=>{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),i=o&&ur(o);return i==null?!1:(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)},gh=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
22
- `).scrollIntoView()),!0)};function Ta(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const H2=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=Ta(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(q.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},yh=(t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof ze||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Ta(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=t.tr.insert(s,i.createAndFill());l.setSelection(z.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},vh=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Rt(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&ur(r);return o==null?!1:(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)};function F2(t){return(e,n)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof B&&e.selection.node.isBlock)return!r.parentOffset||!Rt(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],s,l,a=!1,c=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){a=r.end(f)==r.pos+(r.depth-f),c=r.start(f)==r.pos-(r.depth-f),l=Ta(r.node(f-1).contentMatchAt(r.indexAfter(f-1))),i.unshift(a&&l?{type:l}:null),s=f;break}else{if(f==1)return!1;i.unshift(null)}let u=e.tr;(e.selection instanceof z||e.selection instanceof ze)&&u.deleteSelection();let d=u.mapping.map(r.pos),h=Rt(u.doc,d,i.length,i);if(h||(i[0]=l?{type:l}:null,h=Rt(u.doc,d,i.length,i)),!h)return!1;if(u.split(d,i.length,i),!a&&c&&r.node(s).type!=l){let f=u.mapping.map(r.before(s)),p=u.doc.resolve(f);l&&r.node(s-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(s)),l)}return n&&n(u.scrollIntoView()),!0}}const $2=F2(),V2=(t,e)=>{let{$from:n,to:r}=t.selection,o,i=n.sharedDepth(r);return i==0?!1:(o=n.before(i),e&&e(t.tr.setSelection(B.create(t.doc,o))),!0)};function z2(t,e,n){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||dn(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function bh(t,e,n,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&z2(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(n){let f=e.pos+i.nodeSize,p=A.empty;for(let b=s.length-1;b>=0;b--)p=A.from(s[b].create(null,p));p=A.from(o.copy(p));let m=t.tr.step(new be(e.pos-1,f,e.pos,f,new P(p,1,0),s.length,!0)),v=m.doc.resolve(f+2*s.length);v.nodeAfter&&v.nodeAfter.type==o.type&&dn(m.doc,v.pos)&&m.join(v.pos),n(m.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:q.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),h=d&&ur(d);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(d,h).scrollIntoView()),!0;if(c&&rr(i,"start",!0)&&rr(o,"end")){let f=o,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let m=i,v=1;for(;!m.isTextblock;m=m.firstChild)v++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(n){let b=A.empty;for(let x=p.length-1;x>=0;x--)b=A.from(p[x].copy(b));let C=t.tr.step(new be(e.pos-p.length,e.pos+i.nodeSize,e.pos+v,e.pos+i.nodeSize-v,new P(b,p.length,0),0,!0));n(C.scrollIntoView())}return!0}}return!1}function Ch(t){return function(e,n){let r=e.selection,o=t<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(n&&n(e.tr.setSelection(z.create(e.doc,t<0?o.start(i):o.end(i)))),!0):!1}}const U2=Ch(-1),W2=Ch(1);function K2(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&wa(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function ku(t,e=null){return function(n,r){let o=!1;for(let i=0;i<n.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)o=!0;else{let u=n.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,t)}})}if(!o)return!1;if(r){let i=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[s];i.setBlockType(l,a,t,e)}r(i.scrollIntoView())}return!0}}function Aa(...t){return function(e,n,r){for(let o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}Aa(ka,uh,fh);Aa(ka,ph,mh);Aa(gh,yh,vh,$2);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function q2(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i);if(!s)return!1;let l=r?n.tr:null;return G2(l,s,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function G2(t,e,n,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new Zo(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Zo(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=wa(i,n,r,e);return l?(t&&J2(t,e,l,o,n),!0):!1}function J2(t,e,n,r,o){let i=A.empty;for(let u=n.length-1;u>=0;u--)i=A.from(n[u].type.create(n[u].attrs,i));t.step(new be(e.start-(r?2:0),e.end,e.start,e.end,new P(i,0,0),n.length,!0));let s=0;for(let u=0;u<n.length;u++)n[u].type==o&&(s=u+1);let l=n.length-s,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,h=!0;u<d;u++,h=!1)!h&&Rt(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function Z2(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,s=>s.childCount>0&&s.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?Y2(e,n,t,i):X2(e,n,i):!0:!1}}function Y2(t,e,n,r){let o=t.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new be(i-1,s,i,s,new P(A.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Zo(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));const l=ur(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(i,-1)-1);return dn(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),e(o.scrollIntoView()),!0}function X2(t,e,n){let r=t.tr,o=n.parent;for(let f=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)f-=o.child(p).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==o.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?A.empty:A.from(o))))return!1;let d=i.pos,h=d+s.nodeSize;return r.step(new be(d-(l?1:0),h+(a?1:0),d+1,h-1,new P((l?A.empty:A.from(o.copy(A.empty))).append(a?A.empty:A.from(o.copy(A.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Q2(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=A.from(c?t.create():null),d=new P(A.from(t.create(null,A.from(l.type.create(null,u)))),c?3:1,0),h=i.start,f=i.end;n(e.tr.step(new be(h-(c?3:1),f,h,f,d,1,!0)).scrollIntoView())}return!0}}const ke=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},or=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Al=null;const Et=function(t,e,n){let r=Al||(Al=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},ey=function(){Al=null},Rn=function(t,e,n,r){return n&&(Eu(t,e,n,r,-1)||Eu(t,e,n,r,1))},ty=/^(img|br|input|textarea|hr)$/i;function Eu(t,e,n,r,o){for(var i;;){if(t==n&&e==r)return!0;if(e==(o<0?0:Ye(t))){let s=t.parentNode;if(!s||s.nodeType!=1||to(t)||ty.test(t.nodeName)||t.contentEditable=="false")return!1;e=ke(t)+(o<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(o<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else t=s,e=o<0?Ye(t):0}else return!1}}function Ye(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ny(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Ye(t)}else if(t.parentNode&&!to(t))e=ke(t),t=t.parentNode;else return null}}function ry(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!to(t))e=ke(t)+1,t=t.parentNode;else return null}}function oy(t,e,n){for(let r=e==0,o=e==Ye(t);r||o;){if(t==n)return!0;let i=ke(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,o=o&&i==Ye(t)}}function to(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Ji=function(t){return t.focusNode&&Rn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function gn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function iy(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function sy(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Ye(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Ye(r.startContainer),r.startOffset)}}}const ht=typeof navigator<"u"?navigator:null,Mu=typeof document<"u"?document:null,fn=ht&&ht.userAgent||"",Rl=/Edge\/(\d+)/.exec(fn),xh=/MSIE \d/.exec(fn),Ol=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(fn),He=!!(xh||Ol||Rl),en=xh?document.documentMode:Ol?+Ol[1]:Rl?+Rl[1]:0,Xe=!He&&/gecko\/(\d+)/i.test(fn);Xe&&+(/Firefox\/(\d+)/.exec(fn)||[0,0])[1];const Nl=!He&&/Chrome\/(\d+)/.exec(fn),Re=!!Nl,wh=Nl?+Nl[1]:0,Le=!He&&!!ht&&/Apple Computer/.test(ht.vendor),ir=Le&&(/Mobile\/\w+/.test(fn)||!!ht&&ht.maxTouchPoints>2),Ze=ir||(ht?/Mac/.test(ht.platform):!1),ly=ht?/Win/.test(ht.platform):!1,Mt=/Android \d/.test(fn),no=!!Mu&&"webkitFontSmoothing"in Mu.documentElement.style,ay=no?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function cy(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function xt(t,e){return typeof t=="number"?t:t[e]}function uy(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Tu(t,e,n){let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=or(s);continue}let l=s,a=l==i.body,c=a?cy(i):uy(l),u=0,d=0;if(e.top<c.top+xt(r,"top")?d=-(c.top-e.top+xt(o,"top")):e.bottom>c.bottom-xt(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+xt(o,"top")-c.top:e.bottom-c.bottom+xt(o,"bottom")),e.left<c.left+xt(r,"left")?u=-(c.left-e.left+xt(o,"left")):e.right>c.right-xt(r,"right")&&(u=e.right-c.right+xt(o,"right")),u||d)if(a)i.defaultView.scrollBy(u,d);else{let f=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let m=l.scrollLeft-f,v=l.scrollTop-p;e={left:e.left-m,top:e.top-v,right:e.right-m,bottom:e.bottom-v}}let h=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(h))break;s=h=="absolute"?s.offsetParent:or(s)}}function dy(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=t.root.elementFromPoint(i,s);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Sh(t.dom)}}function Sh(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=or(r));return e}function fy({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;kh(n,r==0?0:r-e)}function kh(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:o,left:i}=t[n];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let Fn=null;function hy(t){if(t.setActive)return t.setActive();if(Fn)return t.focus(Fn);let e=Sh(t);t.focus(Fn==null?{get preventScroll(){return Fn={preventScroll:!0},!0}}:void 0),Fn||(Fn=!1,kh(e,0))}function Eh(t,e){let n,r=2e8,o,i=0,s=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let h;if(u.nodeType==1)h=u.getClientRects();else if(u.nodeType==3)h=Et(u).getClientRects();else continue;for(let f=0;f<h.length;f++){let p=h[f];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){n=u,r=m,o=m&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&m&&(i=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=d+1)}}return!n&&a&&(n=a,o=c,r=0),n&&n.nodeType==3?py(n,o):!n||r&&n.nodeType==1?{node:t,offset:i}:Eh(n,o)}function py(t,e){let n=t.nodeValue.length,r=document.createRange();for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let i=Ft(r,1);if(i.top!=i.bottom&&Ra(e,i))return{node:t,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function Ra(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function my(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function gy(t,e,n){let{node:r,offset:o}=Eh(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,o,i)}function yy(t,e,n,r){let o=-1;for(let i=e,s=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n,-1)}function Mh(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let s=t.childNodes[i];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Ra(e,c))return Mh(s,e,c)}}if((i=(i+1)%r)==o)break}return t}function vy(t,e){let n=t.dom.ownerDocument,r,o=0,i=sy(n,e.left,e.top);i&&({node:r,offset:o}=i);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=t.dom.getBoundingClientRect();if(!Ra(e,c)||(s=Mh(t.dom,e,c),!s))return null}if(Le)for(let c=s;r&&c;c=or(c))c.draggable&&(r=void 0);if(s=my(s,e),r){if(Xe&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&o++}let c;no&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=yy(t,r,o,e))}l==null&&(l=gy(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Au(t){return t.top<t.bottom||t.left<t.right}function Ft(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Au(r))return r}return Array.prototype.find.call(n,Au)||t.getBoundingClientRect()}const by=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Th(t,e,n){let{node:r,offset:o,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=no||Xe;if(r.nodeType==3)if(s&&(by.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let a=Ft(Et(r,o,o),n);if(Xe&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=Ft(Et(r,o-1,o-1),-1);if(c.top==a.top){let u=Ft(Et(r,o,o+1),-1);if(u.top!=a.top)return gr(u,u.left<c.left)}}return a}else{let a=o,c=o,u=n<0?1:-1;return n<0&&!o?(c++,u=-1):n>=0&&o==r.nodeValue.length?(a--,u=1):n<0?a--:c++,gr(Ft(Et(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==Ye(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return Ds(a.getBoundingClientRect(),!1)}if(i==null&&o<Ye(r)){let a=r.childNodes[o];if(a.nodeType==1)return Ds(a.getBoundingClientRect(),!0)}return Ds(r.getBoundingClientRect(),n>=0)}if(i==null&&o&&(n<0||o==Ye(r))){let a=r.childNodes[o-1],c=a.nodeType==3?Et(a,Ye(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return gr(Ft(c,1),!1)}if(i==null&&o<Ye(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Et(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return gr(Ft(c,-1),!0)}return gr(Ft(r.nodeType==3?Et(r):r,-n),n>=0)}function gr(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Ds(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Ah(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}function Cy(t,e,n){let r=e.selection,o=n=="up"?r.$from:r.$to;return Ah(t,e,()=>{let{node:i}=t.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=Th(t,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Et(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const xy=/[\u0590-\u08ac]/;function wy(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=t.domSelection();return l?!xy.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:Ah(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),v=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return h!=null&&(l.caretBidiLevel=h),v}):r.pos==r.start()||r.pos==r.end()}let Ru=null,Ou=null,Nu=!1;function Sy(t,e,n){return Ru==e&&Ou==n?Nu:(Ru=e,Ou=n,Nu=n=="up"||n=="down"?Cy(t,e,n):wy(t,e,n))}const Qe=0,Iu=1,vn=2,pt=3;class ro{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=Qe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let o=this.children[n];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=n>ke(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>e||s instanceof Oh){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Rh&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?ke(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?ke(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&e<=c){let u=s+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=s;for(let d=l;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){o=ke(h.dom)+1;break}e-=h.size}o==-1&&(o=0)}if(o>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=ke(d.dom);break}n+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,o=!1){let i=Math.min(e,n),s=Math.max(e,n);for(let f=0,p=0;f<this.children.length;f++){let m=this.children[f],v=p+m.size;if(i>p&&s<v)return m.setSelection(e-p-m.border,n-p-m.border,r,o);p=v}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((Xe||Le)&&e==n){let{node:f,offset:p}=l;if(f.nodeType==3){if(d=!!(p&&f.nodeValue[p-1]==`
23
- `),d&&p==f.nodeValue.length)for(let m=f,v;m;m=m.parentNode){if(v=m.nextSibling){v.nodeName=="BR"&&(l=a={node:v.parentNode,offset:ke(v)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=f.childNodes[p-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Xe&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let f=u.focusNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(o=!0)}if(!(o||d&&Le)&&Rn(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Rn(a.node,a.offset,u.focusNode,u.focusOffset))return;let h=!1;if((c.extend||e==n)&&!(d&&Xe)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),h=!0}catch{}}if(!h){if(e>n){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,o=0;o<this.children.length;o++){let i=this.children[o],s=r+i.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let l=r+i.border,a=s-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?vn:Iu,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=pt:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?vn:pt}r=s}this.dirty=vn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?vn:Iu;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Rh extends ro{constructor(e,n,r,o){let i,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Qe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class ky extends ro{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class On extends ro{constructor(e,n,r,o,i){super(e,[],r,o),this.mark=n,this.spec=i}static create(e,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=Ln.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new On(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&pt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=pt&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Qe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Qe}}slice(e,n,r){let o=On.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=Ll(i,n,s,r)),e>0&&(i=Ll(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class tn extends ro{constructor(e,n,r,o,i,s,l,a,c){super(e,[],i,s),this.node=n,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,n,r,o,i,s){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Ln.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let h=u;return u=Lh(u,r,n),c?a=new Ey(e,n,r,o,u,d||null,h,c,i,s+1):n.isText?new Zi(e,n,r,o,u,h,i):new tn(e,n,r,o,u,d||null,h,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>A.empty)}return e}matchesNode(e,n,r){return this.dirty==Qe&&e.eq(this.node)&&Xo(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,o=n,i=e.composing?this.localCompositionInfo(e,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Ty(this,s&&s.node,e);Oy(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?re.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,o)},(c,u,d,h)=>{a.syncToMarks(c.marks,r,e);let f;a.findNodeMatch(c,u,d,h)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(f=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,u,d,f,e)||a.updateNextNode(c,u,d,e,h,o)||a.addNode(c,u,d,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==vn)&&(s&&this.protectLocalComposition(e,s),Nh(this.contentDOM,this.children,e),ir&&Ny(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof z)||r<n||o>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=Iy(this.node.content,s,r-n,o-n);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new ky(this,i,n,o);e.input.compositionNodes.push(s),this.children=Ll(this.children,r,r+o.length,e,s)}update(e,n,r,o){return this.dirty==pt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,o),!0)}updateInner(e,n,r,o){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Qe}updateOuterDeco(e){if(Xo(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Ih(this.dom,this.nodeDOM,Il(this.outerDeco,this.node,n),Il(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Lu(t,e,n,r,o){Lh(r,e,t);let i=new tn(void 0,t,e,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class Zi extends tn{constructor(e,n,r,o,i,s,l){super(e,n,r,o,i,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,o){return this.dirty==pt||this.dirty!=Qe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Qe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Qe,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let o=this.node.cut(e,n),i=document.createTextNode(o.text);return new Zi(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=pt)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Oh extends ro{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Qe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Ey extends tn{constructor(e,n,r,o,i,s,l,a,c,u){super(e,n,r,o,i,s,l,c,u),this.spec=a}update(e,n,r,o){if(this.dirty==pt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Nh(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==t){for(;l!=r;)r=Du(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(l,r);if(s instanceof On){let a=r?r.previousSibling:t.lastChild;Nh(s.contentDOM,s.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Du(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}const Tr=function(t){t&&(this.nodeName=t)};Tr.prototype=Object.create(null);const bn=[new Tr];function Il(t,e,n){if(t.length==0)return bn;let r=n?bn[0]:new Tr,o=[r];for(let i=0;i<t.length;i++){let s=t[i].type.attrs;if(s){s.nodeName&&o.push(r=new Tr(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&o.length==1&&o.push(r=new Tr(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function Ih(t,e,n,r){if(n==bn&&r==bn)return e;let o=e;for(let i=0;i<r.length;i++){let s=r[i],l=n[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=t&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=bn[0]),o=a}My(o,l||bn[0],s)}return o}function My(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&t.classList.add(o[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)t.style.removeProperty(o[1])}n.style&&(t.style.cssText+=n.style)}}function Lh(t,e,n){return Ih(t,t,bn,Il(e,n,t.nodeType!=1))}function Xo(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Du(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Ty{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Ay(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let o=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;o<s&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=Qe,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=On.create(this.top,e[i],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,o,i){let s=this.top.children[o];return s.dirty==pt&&s.dom==s.contentDOM&&(s.dirty=vn),s.update(e,n,r,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=n}}updateNextNode(e,n,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof tn){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,h=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=pt&&Xo(n,a.outerDeco));if(!h&&a.update(e,n,r,o))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!h&&(d=this.recreateWrapper(a,e,n,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=vn,d.updateChildren(o,s+1),d.dirty=Qe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,o,i,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Xo(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=tn.create(this.top,n,r,o,i,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,o,i){let s=tn.create(this.top,e,n,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Rh(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof On;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Zi)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Le||Re)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new Oh(this.top,[],r,null);n!=this.top?n.children.push(o):n.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Ay(t,e){let n=e,r=n.children.length,o=t.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof On)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function Ry(t,e){return t.type.side-e.type.side}function Oy(t,e,n,r){let o=e.locals(t),i=0;if(o.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,o,e.forChild(i,u),c),i+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d;for(;s<o.length&&o[s].to==i;){let v=o[s++];v.widget&&(u?(d||(d=[u])).push(v):u=v)}if(u)if(d){d.sort(Ry);for(let v=0;v<d.length;v++)n(d[v],c,!!a)}else n(u,c,!!a);let h,f;if(a)f=-1,h=a,a=null;else if(c<t.childCount)f=c,h=t.child(c++);else break;for(let v=0;v<l.length;v++)l[v].to<=i&&l.splice(v--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let p=i+h.nodeSize;if(h.isText){let v=p;s<o.length&&o[s].from<v&&(v=o[s].from);for(let b=0;b<l.length;b++)l[b].to<v&&(v=l[b].to);v<p&&(a=h.cut(v-i),h=h.cut(0,v-i),p=v,f=-1)}else for(;s<o.length&&o[s].to<p;)s++;let m=h.isInline&&!h.isLeaf?l.filter(v=>!v.inline):l.slice();r(h,m,e.forChild(i,h),f),i=p}}function Ny(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function Iy(t,e,n,r){for(let o=0,i=0;o<t.childCount&&i<=r;){let s=t.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<t.childCount;){let c=t.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Ll(t,e,n,r,o){let i=[];for(let s=0,l=0;s<t.length;s++){let a=t[s],c=l,u=l+=a.size;c>=n||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),o&&(i.push(o),o=void 0),u>n&&i.push(a.slice(n-c,a.size,r)))}return i}function Oa(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),i=o&&o.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Ji(n)){for(a=s;o&&!o.node;)o=o.parent;let d=o.node;if(o&&d.isAtom&&B.isSelectable(d)&&o.parent&&!(d.isInline&&oy(n.focusNode,n.focusOffset,o.dom))){let h=o.posBefore;c=new B(s==h?l:r.resolve(h))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=s,h=s;for(let f=0;f<n.rangeCount;f++){let p=n.getRangeAt(f);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),h=Math.max(h,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,s]=h==t.state.selection.anchor?[h,d]:[d,h],l=r.resolve(s)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;c=Na(t,u,l,d)}return c}function Dh(t){return t.editable?t.hasFocus():jh(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ot(t,e=!1){let n=t.state.selection;if(Ph(t,n),!!Dh(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Re){let r=t.domSelectionRange(),o=t.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Rn(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Dy(t);else{let{anchor:r,head:o}=n,i,s;Pu&&!(n instanceof z)&&(n.$from.parent.inlineContent||(i=ju(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=ju(t,n.to))),t.docView.setSelection(r,o,t,e),Pu&&(i&&Bu(i),s&&Bu(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ly(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Pu=Le||Re&&wh<63;function ju(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(Le&&o&&o.contentEditable=="false")return Ps(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return Ps(o);if(i)return Ps(i)}}function Ps(t){return t.contentEditable="true",Le&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Bu(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Ly(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Dh(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Dy(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ke(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&He&&en<=11&&(n.disabled=!0,n.disabled=!1)}function Ph(t,e){if(e instanceof B){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(_u(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else _u(t)}function _u(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Na(t,e,n,r){return t.someProp("createSelectionBetween",o=>o(t,e,n))||z.between(e,n,r)}function Hu(t){return t.editable&&!t.hasFocus()?!1:jh(t)}function jh(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Py(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Rn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Dl(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return i&&q.findFrom(i,e)}function Vt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Fu(t,e,n){let r=t.state.selection;if(r instanceof z)if(n.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return Vt(t,new z(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let o=Dl(t.state,e);return o&&o instanceof B?Vt(t,o):!1}else if(!(Ze&&n.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?B.isSelectable(i)?Vt(t,new B(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):no?Vt(t,new z(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof B&&r.node.isInline)return Vt(t,new z(e>0?r.$to:r.$from));{let o=Dl(t.state,e);return o?Vt(t,o):!1}}}function Qo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ar(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function $n(t,e){return e<0?jy(t):By(t)}function jy(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(Xe&&n.nodeType==1&&r<Qo(n)&&Ar(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Ar(l,-1))o=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Bh(n))break;{let l=n.previousSibling;for(;l&&Ar(l,-1);)o=n.parentNode,i=ke(l),l=l.previousSibling;if(l)n=l,r=Qo(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Pl(t,n,r):o&&Pl(t,o,i)}function By(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=Qo(n),i,s;for(;;)if(r<o){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Ar(l,1))i=n,s=++r;else break}else{if(Bh(n))break;{let l=n.nextSibling;for(;l&&Ar(l,1);)i=l.parentNode,s=ke(l)+1,l=l.nextSibling;if(l)n=l,r=0,o=Qo(n);else{if(n=n.parentNode,n==t.dom)break;r=o=0}}}i&&Pl(t,i,s)}function Bh(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function _y(t,e){for(;t&&e==t.childNodes.length&&!to(t);)e=ke(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function Hy(t,e){for(;t&&!e&&!to(t);)e=ke(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Pl(t,e,n){if(e.nodeType!=3){let i,s;(s=_y(e,n))?(e=s,n=0):(i=Hy(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Ji(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:o}=t;setTimeout(()=>{t.state==o&&Ot(t)},50)}function $u(t,e){let n=t.state.doc.resolve(e);if(!(Re||ly)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Vu(t,e,n){let r=t.state.selection;if(r instanceof z&&!r.empty||n.indexOf("s")>-1||Ze&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Dl(t.state,e);if(s&&s instanceof B)return Vt(t,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof ze?q.near(s,e):q.findFrom(s,e);return l?Vt(t,l):!1}return!1}function zu(t,e){if(!(t.state.selection instanceof z))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let s=t.state.tr;return e<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),t.dispatch(s),!0}return!1}function Uu(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Fy(t){if(!Le||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Uu(t,r,"true"),setTimeout(()=>Uu(t,r,"false"),20)}return!1}function $y(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Vy(t,e){let n=e.keyCode,r=$y(e);if(n==8||Ze&&n==72&&r=="c")return zu(t,-1)||$n(t,-1);if(n==46&&!e.shiftKey||Ze&&n==68&&r=="c")return zu(t,1)||$n(t,1);if(n==13||n==27)return!0;if(n==37||Ze&&n==66&&r=="c"){let o=n==37?$u(t,t.state.selection.from)=="ltr"?-1:1:-1;return Fu(t,o,r)||$n(t,o)}else if(n==39||Ze&&n==70&&r=="c"){let o=n==39?$u(t,t.state.selection.from)=="ltr"?1:-1:1;return Fu(t,o,r)||$n(t,o)}else{if(n==38||Ze&&n==80&&r=="c")return Vu(t,-1,r)||$n(t,-1);if(n==40||Ze&&n==78&&r=="c")return Fy(t)||Vu(t,1,r)||$n(t,1);if(r==(Ze?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Ia(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let s=t.someProp("clipboardSerializer")||Ln.fromSchema(t.state.schema),l=zh(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=Vh[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let p=l.createElement(u[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,`
24
-
25
- `);return{dom:a,text:h,slice:e}}function _h(t,e,n,r,o){let i=o.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",h=>{e=h(e,i||r,t)}),i)return l=new P(A.from(t.state.schema.text(e.replace(/\r\n?/g,`
26
- `))),0,0),t.someProp("transformPasted",h=>{l=h(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",h=>h(e,o,r,t));if(d)l=d;else{let h=o.marks(),{schema:f}=t.state,p=Ln.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let v=s.appendChild(document.createElement("p"));m&&v.appendChild(p.serializeNode(f.text(m,h)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),s=Ky(n),no&&qy(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let h=s.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;s=h}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Qt.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!zy.test(h.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Gy(Wu(l,+u[1],+u[2]),u[4]);else if(l=P.maxOpen(Uy(l.content,o),!0),l.openStart||l.openEnd){let d=0,h=0;for(let f=l.content.firstChild;d<l.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=l.content.lastChild;h<l.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);l=Wu(l,d,h)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}const zy=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Uy(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.index(n)),i,s=[];if(t.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&Fh(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=$h(s[s.length-1],i.length));let u=Hh(l,a);s.push(u),o=o.matchType(u.type),i=a}}),s)return A.from(s)}return t}function Hh(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,A.from(t));return t}function Fh(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o]==e[o]){let i=Fh(t,e,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==t.length-1?n.type:t[o+1]))return r.copy(r.content.append(A.from(Hh(n,t,o+1))))}}function $h(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,$h(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(A.empty,!0);return t.copy(n.append(r))}function jl(t,e,n,r,o,i){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(i=0),o<r-1&&(l=jl(l,e,n,r,o+1,i)),o>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(A.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function Wu(t,e,n){return e<t.openStart&&(t=new P(jl(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new P(jl(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Vh={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Ku=null;function zh(){return Ku||(Ku=document.implementation.createHTMLDocument("title"))}let js=null;function Wy(t){let e=window.trustedTypes;return e?(js||(js=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),js.createHTML(t)):t}function Ky(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=zh().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),o;if((o=r&&Vh[r[1].toLowerCase()])&&(t=o.map(i=>"<"+i+">").join("")+t+o.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=Wy(t),o)for(let i=0;i<o.length;i++)n=n.querySelector(o[i])||n;return n}function qy(t){let e=t.querySelectorAll(Re?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Gy(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:o,openStart:i,openEnd:s}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=A.from(a.create(r[l+1],o)),i++,s++}return new P(o,i,s)}const De={},Pe={},Jy={touchstart:!0,touchmove:!0};class Zy{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Yy(t){for(let e in De){let n=De[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Qy(t,r)&&!La(t,r)&&(t.editable||!(r.type in Pe))&&n(t,r)},Jy[e]?{passive:!0}:void 0)}Le&&t.dom.addEventListener("input",()=>null),Bl(t)}function Yt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Xy(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Bl(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>La(t,r))})}function La(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Qy(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function ev(t,e){!La(t,e)&&De[e.type]&&(t.editable||!(e.type in Pe))&&De[e.type](t,e)}Pe.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Wh(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Mt&&Re&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ir&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",o=>o(t,gn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Vy(t,n)?n.preventDefault():Yt(t,"key")};Pe.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Pe.keypress=(t,e)=>{let n=e;if(Wh(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ze&&n.metaKey)return;if(t.someProp("handleKeyPress",o=>o(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof z)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,o,i))&&t.dispatch(i()),n.preventDefault()}};function Yi(t){return{left:t.clientX,top:t.clientY}}function tv(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Da(t,e,n,r,o){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(t.someProp(e,l=>s>i.depth?l(t,n,i.nodeAfter,i.before(s),o,!0):l(t,n,i.node(s),i.before(s),o,!1)))return!0;return!1}function Xn(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function nv(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&B.isSelectable(r)?(Xn(t,new B(n)),!0):!1}function rv(t,e){if(e==-1)return!1;let n=t.state.selection,r,o;n instanceof B&&(r=n.node);let i=t.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(B.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?o=i.before(n.$from.depth):o=i.before(s);break}}return o!=null?(Xn(t,B.create(t.state.doc,o)),!0):!1}function ov(t,e,n,r,o){return Da(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(o?rv(t,n):nv(t,n))}function iv(t,e,n,r){return Da(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",o=>o(t,e,r))}function sv(t,e,n,r){return Da(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",o=>o(t,e,r))||lv(t,n,r)}function lv(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Xn(t,z.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)Xn(t,z.create(r,l+1,l+1+s.content.size));else if(B.isSelectable(s))Xn(t,B.create(r,l));else continue;return!0}}function Pa(t){return ei(t)}const Uh=Ze?"metaKey":"ctrlKey";De.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Pa(t),o=Date.now(),i="singleClick";o-t.input.lastClick.time<500&&tv(n,t.input.lastClick)&&!n[Uh]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button};let s=t.posAtCoords(Yi(n));s&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new av(t,s,n,!!r)):(i=="doubleClick"?iv:sv)(t,s.pos,s.inside,n)?n.preventDefault():Yt(t,"pointer"))};class av{constructor(e,n,r,o){this.view=e,this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Uh],this.allowDefault=r.shiftKey;let i,s;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,s=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof B&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Xe&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Yt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Ot(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Yi(e))),this.updateAllowDefault(e),this.allowDefault||!n?Yt(this.view,"pointer"):ov(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Le&&this.mightDrag&&!this.mightDrag.node.isAtom||Re&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Xn(this.view,q.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Yt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Yt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}De.touchstart=t=>{t.input.lastTouch=Date.now(),Pa(t),Yt(t,"pointer")};De.touchmove=t=>{t.input.lastTouch=Date.now(),Yt(t,"pointer")};De.contextmenu=t=>Pa(t);function Wh(t,e){return t.composing?!0:Le&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const cv=Mt?5e3:-1;Pe.compositionstart=Pe.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof z&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),ei(t,!0),t.markCursor=null;else if(ei(t,!e.selection.empty),Xe&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&o.nodeType==1&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(s.nodeType==3){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}t.input.composing=!0}Kh(t,cv)};Pe.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Kh(t,20))};function Kh(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>ei(t),e))}function qh(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=dv());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function uv(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=ny(e.focusNode,e.focusOffset),r=ry(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let o=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function dv(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function ei(t,e=!1){if(!(Mt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),qh(t),e||t.docView&&t.docView.dirty){let n=Oa(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function fv(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Fr=He&&en<15||ir&&ay<604;De.copy=Pe.cut=(t,e)=>{let n=e,r=t.state.selection,o=n.type=="cut";if(r.empty)return;let i=Fr?null:n.clipboardData,s=r.content(),{dom:l,text:a}=Ia(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):fv(t,l),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function hv(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function pv(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?$r(t,r.value,null,o,e):$r(t,r.textContent,r.innerHTML,o,e)},50)}function $r(t,e,n,r,o){let i=_h(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,o,i||P.empty)))return!0;if(!i)return!1;let s=hv(i),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Gh(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Pe.paste=(t,e)=>{let n=e;if(t.composing&&!Mt)return;let r=Fr?null:n.clipboardData,o=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&$r(t,Gh(r),r.getData("text/html"),o,n)?n.preventDefault():pv(t,n)};class Jh{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const mv=Ze?"altKey":"ctrlKey";function Zh(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[mv]}De.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=t.state.selection,i=o.empty?null:t.posAtCoords(Yi(n)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof B?o.to-1:o.to))){if(r&&r.mightDrag)s=B.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(s=B.create(t.state.doc,d.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:u}=Ia(t,l);(!n.dataTransfer.files.length||!Re||wh>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Fr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Fr||n.dataTransfer.setData("text/plain",c),t.dragging=new Jh(u,Zh(t,n),s)};De.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Pe.dragover=Pe.dragenter=(t,e)=>e.preventDefault();Pe.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let o=t.posAtCoords(Yi(n));if(!o)return;let i=t.state.doc.resolve(o.pos),s=r&&r.slice;s?t.someProp("transformPasted",p=>{s=p(s,t,!1)}):s=_h(t,Gh(n.dataTransfer),Fr?null:n.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&Zh(t,n));if(t.someProp("handleDrop",p=>p(t,n,s||P.empty,l))){n.preventDefault();return}if(!s)return;n.preventDefault();let a=s?th(t.state.doc,i.pos,s):i.pos;a==null&&(a=i.pos);let c=t.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,h=c.doc;if(d?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(h))return;let f=c.doc.resolve(u);if(d&&B.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new B(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,v,b,C)=>p=C),c.setSelection(Na(t,f,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};De.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Ot(t)},20))};De.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};De.beforeinput=(t,e)=>{if(Re&&Mt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,gn(8,"Backspace")))))return;let{$cursor:o}=t.state.selection;o&&o.pos>0&&t.dispatch(t.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let t in Pe)De[t]=Pe[t];function Vr(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class ti{constructor(e,n){this.toDOM=e,this.spec=n||kn,this.side=this.spec.side||0}map(e,n,r,o){let{pos:i,deleted:s}=e.mapResult(n.from+o,this.side<0?-1:1);return s?null:new Ie(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ti&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Vr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class nn{constructor(e,n){this.attrs=e,this.spec=n||kn}map(e,n,r,o){let i=e.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new Ie(i,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof nn&&Vr(this.attrs,e.attrs)&&Vr(this.spec,e.spec)}static is(e){return e.type instanceof nn}destroy(){}}class ja{constructor(e,n){this.attrs=e,this.spec=n||kn}map(e,n,r,o){let i=e.mapResult(n.from+o,1);if(i.deleted)return null;let s=e.mapResult(n.to+o,-1);return s.deleted||s.pos<=i.pos?null:new Ie(i.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:o}=e.content.findIndex(n.from),i;return o==n.from&&!(i=e.child(r)).isText&&o+i.nodeSize==n.to}eq(e){return this==e||e instanceof ja&&Vr(this.attrs,e.attrs)&&Vr(this.spec,e.spec)}destroy(){}}class Ie{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ie(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Ie(e,e,new ti(n,r))}static inline(e,n,r,o){return new Ie(e,n,new nn(r,o))}static node(e,n,r,o){return new Ie(e,n,new ja(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof nn}get widget(){return this.type instanceof ti}}const Kn=[],kn={};class ue{constructor(e,n){this.local=e.length?e:Kn,this.children=n.length?n:Kn}static create(e,n){return n.length?ni(n,e,0,kn):Ae}find(e,n,r){let o=[];return this.findInner(e??0,n??1e9,o,0,r),o}findInner(e,n,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,o+l,i)}}map(e,n,r){return this==Ae||e.maps.length==0?this:this.mapInner(e,n,0,0,r||kn)}mapInner(e,n,r,o,i){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(n,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?gv(this.children,s||[],e,n,r,o,i):s?new ue(s.sort(En),Kn):Ae}add(e,n){return n.length?this==Ae?ue.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let o,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Xh(n,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,u,c+1):o.splice(i,0,a,a+l.nodeSize,ni(u,l,c+1,kn)),i+=3}});let s=Yh(i?Qh(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new ue(s.length?this.local.concat(s).sort(En):this.local,o||this.children)}remove(e){return e.length==0||this==Ae?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+n,a=r[i+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=Ae?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<o.length;l++)o[l].eq(s,n)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new ue(o,r):Ae}forChild(e,n){if(this==Ae)return this;if(n.isLeaf)return ue.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,s=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>i&&a.type instanceof nn){let c=Math.max(i,a.from)-i,u=Math.min(s,a.to)-i;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new ue(o.sort(En),Kn);return r?new Wt([l,r]):l}return r||Ae}eq(e){if(this==e)return!0;if(!(e instanceof ue)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Ba(this.localsInner(e))}localsInner(e){if(this==Ae)return Kn;if(e.inlineContent||!this.local.some(nn.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof nn||n.push(this.local[r]);return n}forEachSet(e){e(this)}}ue.empty=new ue([],[]);ue.removeOverlap=Ba;const Ae=ue.empty;class Wt{constructor(e){this.members=e}map(e,n){const r=this.members.map(o=>o.map(e,n,kn));return Wt.from(r)}forChild(e,n){if(n.isLeaf)return ue.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,n);i!=Ae&&(i instanceof Wt?r=r.concat(i.members):r.push(i))}return Wt.from(r)}eq(e){if(!(e instanceof Wt)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let s=0;s<i.length;s++)n.push(i[s])}}return n?Ba(r?n:n.sort(En)):Kn}static from(e){switch(e.length){case 0:return Ae;case 1:return e[0];default:return new Wt(e.every(n=>n instanceof ue)?e:e.reduce((n,r)=>n.concat(r instanceof ue?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function gv(t,e,n,r,o,i,s){let l=t.slice();for(let c=0,u=i;c<n.maps.length;c++){let d=0;n.maps[c].forEach((h,f,p,m)=>{let v=m-p-(f-h);for(let b=0;b<l.length;b+=3){let C=l[b+1];if(C<0||h>C+u-d)continue;let x=l[b]+u-d;f>=x?l[b+1]=h<=x?-2:-1:h>=u&&v&&(l[b]+=v,l[b+1]+=v)}d+=v}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+i),d=u-o;if(d<0||d>=r.content.size){a=!0;continue}let h=n.map(t[c+1]+i,-1),f=h-o,{index:p,offset:m}=r.content.findIndex(d),v=r.maybeChild(p);if(v&&m==d&&m+v.nodeSize==f){let b=l[c+2].mapInner(n,v,u+1,t[c]+i+1,s);b!=Ae?(l[c]=d,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=yv(l,t,e,n,o,i,s),u=ni(c,r,0,s);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,h=0;d<u.children.length;d+=3){let f=u.children[d];for(;h<l.length&&l[h]<f;)h+=3;l.splice(h,0,u.children[d],u.children[d+1],u.children[d+2])}}return new ue(e.sort(En),l)}function Yh(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let o=t[r];n.push(new Ie(o.from+e,o.to+e,o.type))}return n}function yv(t,e,n,r,o,i,s){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,o,c);d?n.push(d):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function Xh(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,o=null;for(let i=0,s;i<t.length;i++)(s=t[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),t[i]=null);return o}function Qh(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function ni(t,e,n,r){let o=[],i=!1;e.forEach((l,a)=>{let c=Xh(t,l,a+n);if(c){i=!0;let u=ni(c,l,n+a+1,r);u!=Ae&&o.push(a,a+l.nodeSize,u)}});let s=Yh(i?Qh(t):t,-n).sort(En);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||o.length?new ue(s,o):Ae}function En(t,e){return t.from-e.from||t.to-e.to}function Ba(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let o=n+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),qu(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),qu(e,o,r.copy(i.from,r.to)));break}}}return e}function qu(t,e,n){for(;e<t.length&&En(n,t[e])>0;)e++;t.splice(e,0,n)}function Bs(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Ae&&e.push(r)}),t.cursorWrapper&&e.push(ue.create(t.state.doc,[t.cursorWrapper.deco])),Wt.from(e)}const vv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},bv=He&&en<=11;class Cv{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class xv{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Cv,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);He&&en<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),bv&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,vv)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Hu(this.view)){if(this.suppressingSelectionUpdates)return Ot(this.view);if(He&&en<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Rn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=or(i))n.add(i);for(let i=e.anchorNode;i;i=or(i))if(n.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Hu(e)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(l=!0))}if(Xe&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,h]=u;d.parentNode&&d.parentNode.parentNode==h.parentNode?h.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let h of u){let f=h.parentNode;f&&f.nodeName=="LI"&&(!d||kv(e,d)!=f)&&h.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ji(r)&&(c=Oa(e))&&c.eq(q.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ot(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,s),wv(e)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ot(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,i=e.nextSibling;if(He&&en<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:h}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(o=d),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h)}let s=o&&o.parentNode==e.target?ke(o)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=i&&i.parentNode==e.target?ke(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Gu=new WeakMap,Ju=!1;function wv(t){if(!Gu.has(t)&&(Gu.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Xe,Ju)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Ju=!0}}function Zu(t,e){let n=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Rn(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function Sv(t,e){if(e.getComposedRanges){let o=e.getComposedRanges(t.root)[0];if(o)return Zu(t,o)}let n;function r(o){o.preventDefault(),o.stopImmediatePropagation(),n=o.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Zu(t,n):null}function kv(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Ev(t,e,n){let{node:r,fromOffset:o,toOffset:i,from:s,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,u=a.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],Ji(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Re&&t.input.lastKeyCode===8)for(let v=i;v>o;v--){let b=r.childNodes[v-1],C=b.pmViewDesc;if(b.nodeName=="BR"&&!C){i=v;break}if(!C||C.size)break}let d=t.state.doc,h=t.someProp("domParser")||Qt.fromSchema(t.state.schema),f=d.resolve(s),p=null,m=h.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:o,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Mv,context:f});if(c&&c[0].pos!=null){let v=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=v),p={anchor:v+s,head:b+s}}return{doc:m,sel:p,from:s,to:l}}function Mv(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Le&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Le&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Tv=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Av(t,e,n,r,o){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let S=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,M=Oa(t,S);if(M&&!t.state.selection.eq(M)){if(Re&&Mt&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",j=>j(t,gn(13,"Enter"))))return;let I=t.state.tr.setSelection(M);S=="pointer"?I.setMeta("pointer",!0):S=="key"&&I.scrollIntoView(),i&&I.setMeta("composition",i),t.dispatch(I)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=Ev(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),h,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,f="end"):(h=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let p=Nv(d.content,c.doc.content,c.from,h,f);if(p&&t.input.domChangeCount++,(ir&&t.input.lastIOSEnter>Date.now()-225||Mt)&&o.some(S=>S.nodeType==1&&!Tv.test(S.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",S=>S(t,gn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof z&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let S=Yu(t,t.state.doc,c.sel);if(S&&!S.eq(t.state.selection)){let M=t.state.tr.setSelection(S);i&&M.setMeta("composition",i),t.dispatch(M)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof z&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),He&&en<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),v=c.doc.resolveNoCache(p.endB-c.from),b=u.resolve(p.start),C=m.sameParent(v)&&m.parent.inlineContent&&b.end()>=p.endA;if((ir&&t.input.lastIOSEnter>Date.now()-225&&(!C||o.some(S=>S.nodeName=="DIV"||S.nodeName=="P"))||!C&&m.pos<c.doc.content.size&&(!m.sameParent(v)||!m.parent.inlineContent)&&m.pos<v.pos&&!/\S/.test(c.doc.textBetween(m.pos,v.pos,"","")))&&t.someProp("handleKeyDown",S=>S(t,gn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&Ov(u,p.start,p.endA,m,v)&&t.someProp("handleKeyDown",S=>S(t,gn(8,"Backspace")))){Mt&&Re&&t.domObserver.suppressSelectionUpdates();return}Re&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Mt&&!C&&m.start()!=v.start()&&v.parentOffset==0&&m.depth==v.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,v=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(S){return S(t,gn(13,"Enter"))})},20));let x=p.start,w=p.endA,E=S=>{let M=S||t.state.tr.replace(x,w,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let I=Yu(t,M.doc,c.sel);I&&!(Re&&t.composing&&I.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(I.head==x||I.head==M.mapping.map(w)-1)||He&&I.empty&&I.head==x)&&M.setSelection(I)}return i&&M.setMeta("composition",i),M.scrollIntoView()},k;if(C)if(m.pos==v.pos){He&&en<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ot(t),20));let S=E(t.state.tr.delete(x,w)),M=u.resolve(p.start).marksAcross(u.resolve(p.endA));M&&S.ensureMarks(M),t.dispatch(S)}else if(p.endA==p.endB&&(k=Rv(m.parent.content.cut(m.parentOffset,v.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let S=E(t.state.tr);k.type=="add"?S.addMark(x,w,k.mark):S.removeMark(x,w,k.mark),t.dispatch(S)}else if(m.parent.child(m.index()).isText&&m.index()==v.index()-(v.textOffset?0:1)){let S=m.parent.textBetween(m.parentOffset,v.parentOffset),M=()=>E(t.state.tr.insertText(S,x,w));t.someProp("handleTextInput",I=>I(t,x,w,S,M))||t.dispatch(M())}else t.dispatch(E());else t.dispatch(E())}function Yu(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Na(t,e.resolve(n.anchor),e.resolve(n.head))}function Rv(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,o=n,i=r,s,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(A.from(c).eq(t))return{mark:l,type:s}}function Ov(t,e,n,r,o){if(n-e<=o.pos-r.pos||_s(r,!0,!1)<o.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=t.resolve(_s(i,!0,!0));return!s.parent.isTextblock||s.pos>n||_s(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function _s(t,e,n){let r=t.depth,o=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function Nv(t,e,n,r,o){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:s,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(o=="end"){let a=Math.max(0,i-Math.min(s,l));r-=s+a-i}if(s<i&&t.size<e.size){let a=r<=i&&r>=s?i-r:0;i-=a,i&&i<e.size&&Xu(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-s),s=i}else if(l<i){let a=r<=i&&r>=l?i-r:0;i-=a,i&&i<t.size&&Xu(t.textBetween(i-1,i+1))&&(i+=a?1:-1),s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}function Xu(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class ep{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Zy,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(rd),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=td(this),ed(this),this.nodeViews=nd(this),this.docView=Lu(this.state.doc,Qu(this),Bs(this),this.dom,this),this.domObserver=new xv(this,(r,o,i,s)=>Av(this,r,o,i,s)),this.domObserver.start(),Yy(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Bl(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(rd),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(qh(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=nd(this);Lv(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Bl(this),this.editable=td(this),ed(this);let a=Bs(this),c=Qu(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(o.selection))&&(s=!0);let h=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&dy(this);if(s){this.domObserver.stop();let f=d&&(He||Re)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Iv(o.selection,e.selection);if(d){let p=Re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=uv(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Lu(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Py(this))?Ot(this,f):(Ph(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():h&&fy(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof B){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Tu(this,n.getBoundingClientRect(),e)}else Tu(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,o=-1;if(this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new Jh(e.slice,e.move,o<0?void 0:B.create(this.state.doc,o))}someProp(e,n){let r=this._props&&this._props[e],o;if(r!=null&&(o=n?n(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=n?n(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(o=n?n(l):l))return o}}hasFocus(){if(He){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&hy(this.dom),Ot(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return vy(this,e)}coordsAtPos(e,n=1){return Th(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let o=this.docView.posFromDOM(e,n,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,n){return Sy(this,n||this.state,e)}pasteHTML(e,n){return $r(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return $r(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ia(this,e)}destroy(){this.docView&&(Xy(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Bs(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ey())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ev(this,e)}domSelectionRange(){let e=this.domSelection();return e?Le&&this.root.nodeType===11&&iy(this.dom.ownerDocument)==this.dom&&Sv(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}ep.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Qu(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Ie.node(0,t.state.doc.content.size,e)]}function ed(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Ie.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function td(t){return!t.someProp("editable",e=>e(t.state)===!1)}function Iv(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function nd(t){let e=Object.create(null);function n(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function Lv(t,e){let n=0,r=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let o in e)r++;return n!=r}function rd(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var sn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},ri={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Dv=typeof navigator<"u"&&/Mac/.test(navigator.platform),Pv=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ee=0;Ee<10;Ee++)sn[48+Ee]=sn[96+Ee]=String(Ee);for(var Ee=1;Ee<=24;Ee++)sn[Ee+111]="F"+Ee;for(var Ee=65;Ee<=90;Ee++)sn[Ee]=String.fromCharCode(Ee+32),ri[Ee]=String.fromCharCode(Ee);for(var Hs in sn)ri.hasOwnProperty(Hs)||(ri[Hs]=sn[Hs]);function jv(t){var e=Dv&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Pv&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ri:sn)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const Bv=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),_v=typeof navigator<"u"&&/Win/.test(navigator.platform);function Hv(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,o,i,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Bv?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),o&&(n="Ctrl-"+n),s&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function Fv(t){let e=Object.create(null);for(let n in t)e[Hv(n)]=t[n];return e}function Fs(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function $v(t){return new ae({props:{handleKeyDown:tp(t)}})}function tp(t){let e=Fv(t);return function(n,r){let o=jv(r),i,s=e[Fs(o,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[Fs(o,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(_v&&r.ctrlKey&&r.altKey)&&(i=sn[r.keyCode])&&i!=o){let l=e[Fs(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Vv=Object.defineProperty,_a=(t,e)=>{for(var n in e)Vv(t,n,{get:e[n],enumerable:!0})};function Xi(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:o}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}var Qi=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:o}=n,i=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(([s,l])=>[s,(...c)=>{const u=l(...c)(i);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(o),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s=[],l=!!t,a=t||o.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),s.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(n).map(([d,h])=>[d,(...p)=>{const m=this.buildProps(a,e),v=h(...p)(m);return s.push(v),u}])),run:c};return u}createCan(t){const{rawCommands:e,state:n}=this,r=!1,o=t||n.tr,i=this.buildProps(o,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(o,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s={tr:t,editor:r,view:i,state:Xi({state:o,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(s)]))}};return s}},np={};_a(np,{blur:()=>zv,clearContent:()=>Uv,clearNodes:()=>Wv,command:()=>Kv,createParagraphNear:()=>qv,cut:()=>Gv,deleteCurrentNode:()=>Jv,deleteNode:()=>Zv,deleteRange:()=>Yv,deleteSelection:()=>Xv,enter:()=>Qv,exitCode:()=>eb,extendMarkRange:()=>tb,first:()=>nb,focus:()=>ob,forEach:()=>ib,insertContent:()=>sb,insertContentAt:()=>cb,joinBackward:()=>fb,joinDown:()=>db,joinForward:()=>hb,joinItemBackward:()=>pb,joinItemForward:()=>mb,joinTextblockBackward:()=>gb,joinTextblockForward:()=>yb,joinUp:()=>ub,keyboardShortcut:()=>bb,lift:()=>Cb,liftEmptyBlock:()=>xb,liftListItem:()=>wb,newlineInCode:()=>Sb,resetAttributes:()=>kb,scrollIntoView:()=>Eb,selectAll:()=>Mb,selectNodeBackward:()=>Tb,selectNodeForward:()=>Ab,selectParentNode:()=>Rb,selectTextblockEnd:()=>Ob,selectTextblockStart:()=>Nb,setContent:()=>Ib,setMark:()=>Qb,setMeta:()=>eC,setNode:()=>tC,setNodeSelection:()=>nC,setTextDirection:()=>rC,setTextSelection:()=>oC,sinkListItem:()=>iC,splitBlock:()=>sC,splitListItem:()=>lC,toggleList:()=>aC,toggleMark:()=>cC,toggleNode:()=>uC,toggleWrap:()=>dC,undoInputRule:()=>fC,unsetAllMarks:()=>hC,unsetMark:()=>pC,unsetTextDirection:()=>mC,updateAttributes:()=>gC,wrapIn:()=>yC,wrapInList:()=>vC});var zv=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),Uv=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),Wv=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:o}=r;return n&&o.forEach(({$from:i,$to:s})=>{t.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),h=c.resolve(u.map(a+l.nodeSize)),f=d.blockRange(h);if(!f)return;const p=ur(f);if(l.type.isTextblock){const{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(f.start,m)}(p||p===0)&&e.lift(f,p)})}),!0},Kv=t=>e=>t(e),qv=()=>({state:t,dispatch:e})=>yh(t,e),Gv=(t,e)=>({editor:n,tr:r})=>{const{state:o}=n,i=o.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new z(r.doc.resolve(Math.max(s-1,0)))),!0},Jv=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const o=t.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(e){const l=o.before(i),a=o.after(i);t.delete(l,a).scrollIntoView()}return!0}return!1};function me(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var Zv=t=>({tr:e,state:n,dispatch:r})=>{const o=me(t,n.schema),i=e.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){const a=i.before(s),c=i.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},Yv=t=>({tr:e,dispatch:n})=>{const{from:r,to:o}=t;return n&&e.delete(r,o),!0},Xv=()=>({state:t,dispatch:e})=>ka(t,e),Qv=()=>({commands:t})=>t.keyboardShortcut("Enter"),eb=()=>({state:t,dispatch:e})=>H2(t,e);function Ha(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function oi(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(o=>n.strict?e[o]===t[o]:Ha(e[o])?e[o].test(t[o]):e[o]===t[o]):!0}function rp(t,e,n={}){return t.find(r=>r.type===e&&oi(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function od(t,e,n={}){return!!rp(t,e,n)}function Fa(t,e,n){var r;if(!t||!e)return;let o=t.parent.childAfter(t.parentOffset);if((!o.node||!o.node.marks.some(u=>u.type===e))&&(o=t.parent.childBefore(t.parentOffset)),!o.node||!o.node.marks.some(u=>u.type===e)||(n=n||((r=o.node.marks[0])==null?void 0:r.attrs),!rp([...o.node.marks],e,n)))return;let s=o.index,l=t.start()+o.offset,a=s+1,c=l+o.node.nodeSize;for(;s>0&&od([...t.parent.child(s-1).marks],e,n);)s-=1,l-=t.parent.child(s).nodeSize;for(;a<t.parent.childCount&&od([...t.parent.child(a).marks],e,n);)c+=t.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function jt(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var tb=(t,e={})=>({tr:n,state:r,dispatch:o})=>{const i=jt(t,r.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:u}=l;if(o){const d=Fa(a,i,e);if(d&&d.from<=c&&d.to>=u){const h=z.create(s,d.from,d.to);n.setSelection(h)}}return!0},nb=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function op(t){return t instanceof z}function Cn(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function ip(t,e=null){if(!e)return null;const n=q.atStart(t),r=q.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const o=n.from,i=r.to;return e==="all"?z.create(t,Cn(0,o,i),Cn(t.content.size,o,i)):z.create(t,Cn(e,o,i),Cn(e,o,i))}function _l(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function zr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function rb(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var ob=(t=null,e={})=>({editor:n,view:r,tr:o,dispatch:i})=>{e={scrollIntoView:!0,...e};const s=()=>{(zr()||_l())&&r.dom.focus(),rb()&&!zr()&&!_l()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!op(n.state.selection))return s(),!0;const l=ip(o.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},ib=(t,e)=>n=>t.every((r,o)=>e(r,{...n,index:o})),sb=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),sp=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&sp(r)}return t};function bo(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return sp(n)}function Ur(t,e,n){if(t instanceof Xt||t instanceof A)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,o=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return A.fromArray(t.map(l=>e.nodeFromJSON(l)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),Ur("",e,n)}if(o){if(n.errorOnInvalidContent){let s=!1,l="";const a=new Uf({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=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Qt.fromSchema(a).parseSlice(bo(t),n.parseOptions):Qt.fromSchema(a).parse(bo(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=Qt.fromSchema(e);return n.slice?i.parseSlice(bo(t),n.parseOptions).content:i.parse(bo(t),n.parseOptions)}return Ur("",e,n)}function lb(t,e,n){const r=t.steps.length-1;if(r<e)return;const o=t.steps[r];if(!(o instanceof ve||o instanceof be))return;const i=t.mapping.maps[r];let s=0;i.forEach((l,a,c,u)=>{s===0&&(s=u)}),t.setSelection(q.near(t.doc.resolve(s),n))}var ab=t=>!("type"in t),cb=(t,e,n)=>({tr:r,dispatch:o,editor:i})=>{var s;if(o){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=v=>{i.emit("contentError",{editor:i,error:v,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Ur(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(v){a(v)}try{l=Ur(e,i.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:i.options.enableContentCheck})}catch(v){return a(v),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,f=!0;if((ab(l)?l:[l]).forEach(v=>{v.check(),h=h?v.isText&&v.marks.length===0:!1,f=f?v.isBlock:!1}),u===d&&f){const{parent:v}=r.doc.resolve(u);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(u-=1,d+=1)}let m;if(h){if(Array.isArray(e))m=e.map(v=>v.text||"").join("");else if(e instanceof A){let v="";e.forEach(b=>{b.text&&(v+=b.text)}),m=v}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,u,d)}else{m=l;const v=r.doc.resolve(u),b=v.node(),C=v.parentOffset===0,x=b.isText||b.isTextblock,w=b.content.size>0;C&&x&&w&&(u=Math.max(0,u-1)),r.replaceWith(u,d,m)}n.updateSelection&&lb(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0},ub=()=>({state:t,dispatch:e})=>j2(t,e),db=()=>({state:t,dispatch:e})=>B2(t,e),fb=()=>({state:t,dispatch:e})=>uh(t,e),hb=()=>({state:t,dispatch:e})=>ph(t,e),pb=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ki(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},mb=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ki(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},gb=()=>({state:t,dispatch:e})=>D2(t,e),yb=()=>({state:t,dispatch:e})=>P2(t,e);function lp(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function vb(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,o,i,s;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))zr()||lp()?s=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),o&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var bb=t=>({editor:e,view:n,tr:r,dispatch:o})=>{const i=vb(t).split(/-(?!$)/),s=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{const u=c.map(r.mapping);u&&o&&r.maybeStep(u)}),!0};function ln(t,e,n={}){const{from:r,to:o,empty:i}=t.selection,s=e?me(e,t.schema):null,l=[];t.doc.nodesBetween(r,o,(d,h)=>{if(d.isText)return;const f=Math.max(r,h),p=Math.min(o,h+d.nodeSize);l.push({node:d,from:f,to:p})});const a=o-r,c=l.filter(d=>s?s.name===d.node.type.name:!0).filter(d=>oi(d.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((d,h)=>d+h.to-h.from,0)>=a}var Cb=(t,e={})=>({state:n,dispatch:r})=>{const o=me(t,n.schema);return ln(n,o,e)?_2(n,r):!1},xb=()=>({state:t,dispatch:e})=>vh(t,e),wb=t=>({state:e,dispatch:n})=>{const r=me(t,e.schema);return Z2(r)(e,n)},Sb=()=>({state:t,dispatch:e})=>gh(t,e);function es(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function id(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,o)=>(n.includes(o)||(r[o]=t[o]),r),{})}var kb=(t,e)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null;const l=es(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=me(t,r.schema)),l==="mark"&&(s=jt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{i&&i===u.type&&(a=!0,o&&n.setNodeMarkup(d,void 0,id(u.attrs,e))),s&&u.marks.length&&u.marks.forEach(h=>{s===h.type&&(a=!0,o&&n.addMark(d,d+u.nodeSize,s.create(id(h.attrs,e))))})})}),a},Eb=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Mb=()=>({tr:t,dispatch:e})=>{if(e){const n=new ze(t.doc);t.setSelection(n)}return!0},Tb=()=>({state:t,dispatch:e})=>fh(t,e),Ab=()=>({state:t,dispatch:e})=>mh(t,e),Rb=()=>({state:t,dispatch:e})=>V2(t,e),Ob=()=>({state:t,dispatch:e})=>W2(t,e),Nb=()=>({state:t,dispatch:e})=>U2(t,e);function Hl(t,e,n={},r={}){return Ur(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var Ib=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{const{doc:a}=i;if(r.preserveWhitespace!=="full"){const c=Hl(t,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});return s&&i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return s&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function ap(t,e){const n=jt(e,t.schema),{from:r,to:o,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});const l=s.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function $a(t,e){const n=new sh(t);return e.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function Lb(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Db(t,e){const n=[];return t.descendants((r,o)=>{e(r)&&n.push({node:r,pos:o})}),n}function cp(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(o,i)=>{n(o)&&r.push({node:o,pos:i})}),r}function Pb(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function ts(t){return e=>Pb(e.$from,t)}function $(t,e,n){return t.config[e]===void 0&&t.parent?$(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?$(t.parent,e,n):null}):t.config[e]}function Va(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=$(e,"addExtensions",n);return r?[e,...Va(r())]:e}).flat(10)}function za(t,e){const n=Ln.fromSchema(e).serializeFragment(t),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}function up(t){return typeof t=="function"}function Q(t,e=void 0,...n){return up(t)?e?t.bind(e)(...n):t(...n):t}function jb(t={}){return Object.keys(t).length===0&&t.constructor===Object}function sr(t){const e=t.filter(o=>o.type==="extension"),n=t.filter(o=>o.type==="node"),r=t.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function dp(t){const e=[],{nodeExtensions:n,markExtensions:r}=sr(t),o=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},s=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...s,...l];return t.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage,extensions:o},d=$(c,"addGlobalAttributes",u);if(!d)return;d().forEach(f=>{let p;Array.isArray(f.types)?p=f.types:f.types==="*"?p=a:f.types==="nodes"?p=s:f.types==="marks"?p=l:p=[],p.forEach(m=>{Object.entries(f.attributes).forEach(([v,b])=>{e.push({type:m,name:v,attribute:{...i,...b}})})})})}),o.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage},d=$(c,"addAttributes",u);if(!d)return;const h=d();Object.entries(h).forEach(([f,p])=>{const m={...i,...p};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:c.name,name:f,attribute:m})})}),e}function Bb(t){const e=[];let n="",r=!1,o=!1,i=0;const s=t.length;for(let l=0;l<s;l+=1){const a=t[l];if(a==="'"&&!o){r=!r,n+=a;continue}if(a==='"'&&!r){o=!o,n+=a;continue}if(!r&&!o){if(a==="("){i+=1,n+=a;continue}if(a===")"&&i>0){i-=1,n+=a;continue}if(a===";"&&i===0){e.push(n),n="";continue}}n+=a}return n&&e.push(n),e}function sd(t){const e=[],n=Bb(t||""),r=n.length;for(let o=0;o<r;o+=1){const i=n[o],s=i.indexOf(":");if(s===-1)continue;const l=i.slice(0,s).trim(),a=i.slice(s+1).trim();l&&a&&e.push([l,a])}return e}function oe(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([o,i])=>{if(!r[o]){r[o]=i;return}if(o==="class"){const l=i?String(i).split(" "):[],a=r[o]?r[o].split(" "):[],c=l.filter(u=>!a.includes(u));r[o]=[...a,...c].join(" ")}else if(o==="style"){const l=new Map([...sd(r[o]),...sd(i)]);r[o]=Array.from(l.entries()).map(([a,c])=>`${a}: ${c}`).join("; ")}else r[o]=i}),r},{})}function Wr(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>oe(n,r),{})}function _b(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function ld(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const o=e.reduce((i,s)=>{const l=s.attribute.parseHTML?s.attribute.parseHTML(n):_b(n.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function ad(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&jb(n)?!1:n!=null))}function cd(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function Hb(t,e){var n;const r=dp(t),{nodeExtensions:o,markExtensions:i}=sr(t),s=(n=o.find(c=>$(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(o.map(c=>{const u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((b,C)=>{const x=$(C,"extendNodeSchema",d);return{...b,...x?x(c):{}}},{}),f=ad({...h,content:Q($(c,"content",d)),marks:Q($(c,"marks",d)),group:Q($(c,"group",d)),inline:Q($(c,"inline",d)),atom:Q($(c,"atom",d)),selectable:Q($(c,"selectable",d)),draggable:Q($(c,"draggable",d)),code:Q($(c,"code",d)),whitespace:Q($(c,"whitespace",d)),linebreakReplacement:Q($(c,"linebreakReplacement",d)),defining:Q($(c,"defining",d)),isolating:Q($(c,"isolating",d)),attrs:Object.fromEntries(u.map(cd))}),p=Q($(c,"parseHTML",d));p&&(f.parseDOM=p.map(b=>ld(b,u)));const m=$(c,"renderHTML",d);m&&(f.toDOM=b=>m({node:b,HTMLAttributes:Wr(b,u)}));const v=$(c,"renderText",d);return v&&(f.toText=v),[c.name,f]})),a=Object.fromEntries(i.map(c=>{const u=r.filter(v=>v.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((v,b)=>{const C=$(b,"extendMarkSchema",d);return{...v,...C?C(c):{}}},{}),f=ad({...h,inclusive:Q($(c,"inclusive",d)),excludes:Q($(c,"excludes",d)),group:Q($(c,"group",d)),spanning:Q($(c,"spanning",d)),code:Q($(c,"code",d)),attrs:Object.fromEntries(u.map(cd))}),p=Q($(c,"parseHTML",d));p&&(f.parseDOM=p.map(v=>ld(v,u)));const m=$(c,"renderHTML",d);return m&&(f.toDOM=v=>m({mark:v,HTMLAttributes:Wr(v,u)})),[c.name,f]}));return new Uf({topNode:s,nodes:l,marks:a})}function Fb(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Rr(t){return t.sort((n,r)=>{const o=$(n,"priority")||100,i=$(r,"priority")||100;return o>i?-1:o<i?1:0})}function fp(t){const e=Rr(Va(t)),n=Fb(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function hp(t,e,n){const{from:r,to:o}=e,{blockSeparator:i=`
27
-
28
- `,textSerializers:s={}}=n||{};let l="";return t.nodesBetween(r,o,(a,c,u,d)=>{var h;a.isBlock&&c>r&&(l+=i);const f=s?.[a.type.name];if(f)return u&&(l+=f({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(h=a?.text)==null?void 0:h.slice(Math.max(r,c)-c,o-c))}),l}function $b(t,e){const n={from:0,to:t.content.size};return hp(t,n,e)}function pp(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function Vb(t,e){const n=me(e,t.schema),{from:r,to:o}=t.selection,i=[];t.doc.nodesBetween(r,o,l=>{i.push(l)});const s=i.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function mp(t,e){const n=es(typeof e=="string"?e:e.name,t.schema);return n==="node"?Vb(t,e):n==="mark"?ap(t,e):{}}function zb(t,e=JSON.stringify){const n={};return t.filter(r=>{const o=e(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function Ub(t){const e=zb(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,s)=>s!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Ua(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((o,i)=>{const s=[];if(o.ranges.length)o.forEach((l,a)=>{s.push({from:l,to:a})});else{const{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{const c=e.slice(i).map(l,-1),u=e.slice(i).map(a),d=e.invert().map(c,-1),h=e.invert().map(u);r.push({oldRange:{from:d,to:h},newRange:{from:c,to:u}})})}),Ub(r)}function Wa(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(o=>{const i=n.resolve(t),s=Fa(i,o.type);s&&r.push({mark:o,...s})}):n.nodesBetween(t,e,(o,i)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var Wb=(t,e,n,r=20)=>{const o=t.doc.resolve(n);let i=r,s=null;for(;i>0&&s===null;){const l=o.node(i);l?.type.name===e?s=l:i-=1}return[s,i]};function yr(t,e){return e.nodes[t]||e.marks[t]||null}function Ho(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const o=t.find(i=>i.type===e&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var Kb=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(o,i,s,l)=>{var a,c;const u=((c=(a=o.type.spec).toText)==null?void 0:c.call(a,{node:o,pos:i,parent:s,index:l}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?u:u.slice(0,Math.max(0,r-i))}),n};function Fl(t,e,n={}){const{empty:r,ranges:o}=t.selection,i=e?jt(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>i?i.name===d.type.name:!0).find(d=>oi(d.attrs,n,{strict:!1}));let s=0;const l=[];if(o.forEach(({$from:d,$to:h})=>{const f=d.pos,p=h.pos;t.doc.nodesBetween(f,p,(m,v)=>{if(i&&m.inlineContent&&!m.type.allowsMarkType(i))return!1;if(!m.isText&&!m.marks.length)return;const b=Math.max(f,v),C=Math.min(p,v+m.nodeSize),x=C-b;s+=x,l.push(...m.marks.map(w=>({mark:w,from:b,to:C})))})}),s===0)return!1;const a=l.filter(d=>i?i.name===d.mark.type.name:!0).filter(d=>oi(d.mark.attrs,n,{strict:!1})).reduce((d,h)=>d+h.to-h.from,0),c=l.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):!0).reduce((d,h)=>d+h.to-h.from,0);return(a>0?a+c:a)>=s}function qb(t,e,n={}){if(!e)return ln(t,null,n)||Fl(t,null,n);const r=es(e,t.schema);return r==="node"?ln(t,e,n):r==="mark"?Fl(t,e,n):!1}var Gb=(t,e)=>{const{$from:n,$to:r,$anchor:o}=t.selection;if(e){const i=ts(l=>l.type.name===e)(t.selection);if(!i)return!1;const s=t.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},Jb=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function ud(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function dd(t,e){const{nodeExtensions:n}=sr(e),r=n.find(s=>s.name===t);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},i=Q($(r,"group",o));return typeof i!="string"?!1:i.split(" ").includes("list")}function ns(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let o=!0;return t.content.forEach(i=>{o!==!1&&(ns(i,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}function gp(t){return t instanceof B}var yp=class vp{constructor(e){this.position=e}static fromJSON(e){return new vp(e.position)}toJSON(){return{position:this.position}}};function Zb(t,e){const n=e.mapping.mapResult(t.position);return{position:new yp(n.pos),mapResult:n}}function Yb(t){return new yp(t)}function Xb(t,e,n){var r;const{selection:o}=e;let i=null;if(op(o)&&(i=o.$cursor),i){const l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}const{ranges:s}=o;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,h)=>{if(c)return!1;if(u.isInline){const f=!h||h.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(n));c=f&&p}return!c}),c})}var Qb=(t,e={})=>({tr:n,state:r,dispatch:o})=>{const{selection:i}=n,{empty:s,ranges:l}=i,a=jt(t,r.schema);if(o)if(s){const c=ap(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(h,f)=>{const p=Math.max(f,u),m=Math.min(f+h.nodeSize,d);h.marks.find(b=>b.type===a)?h.marks.forEach(b=>{a===b.type&&n.addMark(p,m,a.create({...b.attrs,...e}))}):n.addMark(p,m,a.create(e))})});return Xb(r,n,a)},eC=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),tC=(t,e={})=>({state:n,dispatch:r,chain:o})=>{const i=me(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>ku(i,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>ku(i,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},nC=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,o=Cn(t,0,r.content.size),i=B.create(r,o);e.setSelection(i)}return!0},rC=(t,e)=>({tr:n,state:r,dispatch:o})=>{const{selection:i}=r;let s,l;return typeof e=="number"?(s=e,l=e):e&&"from"in e&&"to"in e?(s=e.from,l=e.to):(s=i.from,l=i.to),o&&n.doc.nodesBetween(s,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},oC=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:o,to:i}=typeof t=="number"?{from:t,to:t}:t,s=z.atStart(r).from,l=z.atEnd(r).to,a=Cn(o,s,l),c=Cn(i,s,l),u=z.create(r,a,c);e.setSelection(u)}return!0},iC=t=>({state:e,dispatch:n})=>{const r=me(t,e.schema);return Q2(r)(e,n)};function fd(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(o=>e?.includes(o.type.name));t.tr.ensureMarks(r)}}var sC=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:o})=>{const{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=o.extensionManager.attributes,u=Ho(c,l.node().type.name,l.node().attrs);if(i instanceof B&&i.node.isBlock)return!l.parentOffset||!Rt(s,l.pos)?!1:(r&&(t&&fd(n,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,h=l.depth===0?void 0:Lb(l.node(-1).contentMatchAt(l.indexAfter(-1)));let f=d&&h?[{type:h,attrs:u}]:void 0,p=Rt(e.doc,e.mapping.map(l.pos),1,f);if(!f&&!p&&Rt(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)&&(p=!0,f=h?[{type:h,attrs:u}]:void 0),r){if(p&&(i instanceof z&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,f),h&&!d&&!l.parentOffset&&l.parent.type!==h)){const m=e.mapping.map(l.before()),v=e.doc.resolve(m);l.node(-1).canReplaceWith(v.index(),v.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}t&&fd(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return p},lC=(t,e={})=>({tr:n,state:r,dispatch:o,editor:i})=>{var s;const l=me(t,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 d=a.node(-1);if(d.type!==l)return!1;const h=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(o){let b=A.empty;const C=a.index(-1)?1:a.index(-2)?2:3;for(let M=a.depth-C;M>=a.depth-3;M-=1)b=A.from(a.node(M).copy(b));const x=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,w={...Ho(h,a.node().type.name,a.node().attrs),...e},E=((s=l.contentMatch.defaultType)==null?void 0:s.createAndFill(w))||void 0;b=b.append(A.from(l.createAndFill(null,E)||void 0));const k=a.before(a.depth-(C-1));n.replace(k,a.after(-x),new P(b,4-C,0));let S=-1;n.doc.nodesBetween(k,n.doc.content.size,(M,I)=>{if(S>-1)return!1;M.isTextblock&&M.content.size===0&&(S=I+1)}),S>-1&&n.setSelection(z.near(n.doc.resolve(S))),n.scrollIntoView()}return!0}const f=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...Ho(h,d.type.name,d.attrs),...e},m={...Ho(h,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const v=f?[{type:l,attrs:p},{type:f,attrs:m}]:[{type:l,attrs:p}];if(!Rt(n.doc,a.pos,2))return!1;if(o){const{selection:b,storedMarks:C}=r,{splittableMarks:x}=i.extensionManager,w=C||b.$to.parentOffset&&b.$from.marks();if(n.split(a.pos,2,v).scrollIntoView(),!w||!o)return!0;const E=w.filter(k=>x.includes(k.type.name));n.ensureMarks(E)}return!0},$s=(t,e)=>{const n=ts(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const o=t.doc.nodeAt(r);return n.node.type===o?.type&&dn(t.doc,n.pos)&&t.join(n.pos),!0},Vs=(t,e)=>{const n=ts(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const o=t.doc.nodeAt(r);return n.node.type===o?.type&&dn(t.doc,r)&&t.join(r),!0},aC=(t,e,n,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:h}=o.extensionManager,f=me(t,s.schema),p=me(e,s.schema),{selection:m,storedMarks:v}=s,{$from:b,$to:C}=m,x=b.blockRange(C),w=v||m.$to.parentOffset&&m.$from.marks();if(!x)return!1;const E=ts(k=>dd(k.type.name,d))(m);if(x.depth>=1&&E&&x.depth-E.depth<=1){if(E.node.type===f)return c.liftListItem(p);if(dd(E.node.type.name,d)&&f.validContent(E.node.content)&&l)return a().command(()=>(i.setNodeMarkup(E.pos,f),!0)).command(()=>$s(i,f)).command(()=>Vs(i,f)).run()}return!n||!w||!l?a().command(()=>u().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>$s(i,f)).command(()=>Vs(i,f)).run():a().command(()=>{const k=u().wrapInList(f,r),S=w.filter(M=>h.includes(M.type.name));return i.ensureMarks(S),k?!0:c.clearNodes()}).wrapInList(f,r).command(()=>$s(i,f)).command(()=>Vs(i,f)).run()},cC=(t,e={},n={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:i=!1}=n,s=jt(t,r.schema);return Fl(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},uC=(t,e,n={})=>({state:r,commands:o})=>{const i=me(t,r.schema),s=me(e,r.schema),l=ln(r,i,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...n})},dC=(t,e={})=>({state:n,commands:r})=>{const o=me(t,n.schema);return ln(n,o,e)?r.lift(o):r.wrapIn(o,e)},fC=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const o=n[r];let i;if(o.spec.isInputRules&&(i=o.getState(t))){if(e){const s=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},hC=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:o}=n;return r||e&&o.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},pC=(t,e={})=>({tr:n,state:r,dispatch:o})=>{var i;const{extendEmptyMarkRange:s=!1}=e,{selection:l}=n,a=jt(t,r.schema),{$from:c,empty:u,ranges:d}=l;if(!o)return!0;if(u&&s){let{from:h,to:f}=l;const p=(i=c.marks().find(v=>v.type===a))==null?void 0:i.attrs,m=Fa(c,a,p);m&&(h=m.from,f=m.to),n.removeMark(h,f,a)}else d.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,a)});return n.removeStoredMark(a),!0},mC=t=>({tr:e,state:n,dispatch:r})=>{const{selection:o}=n;let i,s;return typeof t=="number"?(i=t,s=t):t&&"from"in t&&"to"in t?(i=t.from,s=t.to):(i=o.from,s=o.to),r&&e.doc.nodesBetween(i,s,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},gC=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null;const l=es(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=me(t,r.schema)),l==="mark"&&(s=jt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let h,f,p,m;n.selection.empty?r.doc.nodesBetween(u,d,(v,b)=>{i&&i===v.type&&(a=!0,p=Math.max(b,u),m=Math.min(b+v.nodeSize,d),h=b,f=v)}):r.doc.nodesBetween(u,d,(v,b)=>{b<u&&i&&i===v.type&&(a=!0,p=Math.max(b,u),m=Math.min(b+v.nodeSize,d),h=b,f=v),b>=u&&b<=d&&(i&&i===v.type&&(a=!0,o&&n.setNodeMarkup(b,void 0,{...v.attrs,...e})),s&&v.marks.length&&v.marks.forEach(C=>{if(s===C.type&&(a=!0,o)){const x=Math.max(b,u),w=Math.min(b+v.nodeSize,d);n.addMark(x,w,s.create({...C.attrs,...e}))}}))}),f&&(h!==void 0&&o&&n.setNodeMarkup(h,void 0,{...f.attrs,...e}),s&&f.marks.length&&f.marks.forEach(v=>{s===v.type&&o&&n.addMark(p,m,s.create({...v.attrs,...e}))}))}),a},yC=(t,e={})=>({state:n,dispatch:r})=>{const o=me(t,n.schema);return K2(o,e)(n,r)},vC=(t,e={})=>({state:n,dispatch:r})=>{const o=me(t,n.schema);return q2(o,e)(n,r)},bC=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},oo=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},CC=(t,e)=>{if(Ha(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Co(t){var e;const{editor:n,from:r,to:o,text:i,rules:s,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(h=>h.type.spec.code))return!1;let u=!1;const d=Kb(c)+i;return s.forEach(h=>{if(u)return;const f=CC(d,h.find);if(!f)return;const p=a.state.tr,m=Xi({state:a.state,transaction:p}),v={from:r-(f[0].length-i.length),to:o},{commands:b,chain:C,can:x}=new Qi({editor:n,state:m});h.handler({state:m,range:v,match:f,commands:b,chain:C,can:x})===null||!p.steps.length||(h.undoable&&p.setMeta(l,{transform:p,from:r,to:o,text:i}),a.dispatch(p),u=!0)}),u}function xC(t){const{editor:e,rules:n}=t,r=new ae({state:{init(){return null},apply(o,i,s){const l=o.getMeta(r);if(l)return l;const a=o.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=za(A.from(u),s.schema);const{from:d}=a,h=d+u.length;Co({editor:e,from:d,to:h,text:u,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return Co({editor:e,from:i,to:s,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{const{$cursor:i}=o.state.selection;i&&Co({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;const{$cursor:s}=o.state.selection;return s?Co({editor:e,from:s.pos,to:s.pos,text:`
29
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function wC(t){return Object.prototype.toString.call(t).slice(8,-1)}function xo(t){return wC(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function bp(t,e){const n={...t};return xo(t)&&xo(e)&&Object.keys(e).forEach(r=>{xo(e[r])&&xo(t[r])?n[r]=bp(t[r],e[r]):n[r]=e[r]}),n}var Ka=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Q($(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Q($(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>bp(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},it=class Cp extends Ka{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Cp(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){const s=o.marks();if(!!!s.find(c=>c?.type.name===n.name))return!1;const a=s.find(c=>c?.type.name===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function SC(t){return typeof t=="number"}var kC=class{constructor(t){this.find=t.find,this.handler=t.handler}},EC=(t,e,n)=>{if(Ha(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(o=>{const i=[o.text];return i.index=o.index,i.input=t,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function MC(t){const{editor:e,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=t,{commands:a,chain:c,can:u}=new Qi({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,o,(f,p)=>{var m,v,b,C,x;if((v=(m=f.type)==null?void 0:m.spec)!=null&&v.code||!(f.isText||f.isTextblock||f.isInline))return;const w=(x=(C=(b=f.content)==null?void 0:b.size)!=null?C:f.nodeSize)!=null?x:0,E=Math.max(r,p),k=Math.min(o,p+w);if(E>=k)return;const S=f.isText?f.text||"":f.textBetween(E-p,k-p,void 0,"");EC(S,i.find,s).forEach(I=>{if(I.index===void 0)return;const j=E+I.index+1,_=j+I[0].length,U={from:n.tr.mapping.map(j),to:n.tr.mapping.map(_)},F=i.handler({state:n,range:U,match:I,commands:a,chain:c,can:u,pasteEvent:s,dropEvent:l});d.push(F)})}),d.every(f=>f!==null)}var wo=null,TC=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function AC(t){const{editor:e,rules:n}=t;let r=null,o=!1,i=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:u,from:d,to:h,rule:f,pasteEvt:p})=>{const m=u.tr,v=Xi({state:u,transaction:m});if(!(!MC({editor:e,state:v,from:Math.max(d-1,0),to:h.b-1,rule:f,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return n.map(u=>new ae({view(d){const h=p=>{var m;r=(m=d.dom.parentElement)!=null&&m.contains(p.target)?d.dom.parentElement:null,r&&(wo=e)},f=()=>{wo&&(wo=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(d,h)=>{if(i=r===d.dom.parentElement,l=h,!i){const f=wo;f?.isEditable&&setTimeout(()=>{const p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,h)=>{var f;const p=(f=h.clipboardData)==null?void 0:f.getData("text/html");return s=h,o=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(d,h,f)=>{const p=d[0],m=p.getMeta("uiEvent")==="paste"&&!o,v=p.getMeta("uiEvent")==="drop"&&!i,b=p.getMeta("applyPasteRules"),C=!!b;if(!m&&!v&&!C)return;if(C){let{text:E}=b;typeof E=="string"?E=E:E=za(A.from(E),f.schema);const{from:k}=b,S=k+E.length,M=TC(E);return a({rule:u,state:f,from:k,to:{b:S},pasteEvt:M})}const x=h.doc.content.findDiffStart(f.doc.content),w=h.doc.content.findDiffEnd(f.doc.content);if(!(!SC(x)||!w||x===w.b))return a({rule:u,state:f,from:x,to:w,pasteEvt:s})}}))}var rs=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=fp(t),this.schema=Hb(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:yr(e.name,this.schema)},r=$(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Rr([...this.extensions].reverse()).flatMap(r=>{const o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:yr(r.name,this.schema)},i=[],s=$(r,"addKeyboardShortcuts",o);let l={};if(r.type==="mark"&&$(r,"exitable",o)&&(l.ArrowRight=()=>it.handleExit({editor:t,mark:r})),s){const h=Object.fromEntries(Object.entries(s()).map(([f,p])=>[f,()=>p({editor:t})]));l={...l,...h}}const a=$v(l);i.push(a);const c=$(r,"addInputRules",o);if(ud(r,t.options.enableInputRules)&&c){const h=c();if(h&&h.length){const f=xC({editor:t,rules:h}),p=Array.isArray(f)?f:[f];i.push(...p)}}const u=$(r,"addPasteRules",o);if(ud(r,t.options.enablePasteRules)&&u){const h=u();if(h&&h.length){const f=AC({editor:t,rules:h});i.push(...f)}}const d=$(r,"addProseMirrorPlugins",o);if(d){const h=d();i.push(...h)}return i})}get attributes(){return dp(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=sr(this.extensions);return Object.fromEntries(e.filter(n=>!!$(n,"addNodeView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:me(n.name,this.schema)},i=$(n,"addNodeView",o);if(!i)return[];const s=i();if(!s)return[];const l=(a,c,u,d,h)=>{const f=Wr(a,r);return s({node:a,view:c,getPos:u,decorations:d,innerDecorations:h,editor:t,extension:n,HTMLAttributes:f})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return Rr([...this.extensions].reverse()).reduceRight((r,o)=>{const i={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:e,type:yr(o.name,this.schema)},s=$(o,"dispatchTransaction",i);return s?l=>{s.call(i,{transaction:l,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return Rr([...this.extensions]).reduce((r,o)=>{const i={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:e,type:yr(o.name,this.schema)},s=$(o,"transformPastedHTML",i);return s?(l,a)=>{const c=r(l,a);return s.call(i,c)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=sr(this.extensions);return Object.fromEntries(e.filter(n=>!!$(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:jt(n.name,this.schema)},i=$(n,"addMarkView",o);if(!i)return[];const s=(l,a,c)=>{const u=Wr(l,r);return i()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{VC(l,t,d)}})};return[n.name,s]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:yr(e.name,this.schema)};e.type==="mark"&&((n=Q($(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const o=$(e,"onBeforeCreate",r),i=$(e,"onCreate",r),s=$(e,"onUpdate",r),l=$(e,"onSelectionUpdate",r),a=$(e,"onTransaction",r),c=$(e,"onFocus",r),u=$(e,"onBlur",r),d=$(e,"onDestroy",r);o&&this.editor.on("beforeCreate",o),i&&this.editor.on("create",i),s&&this.editor.on("update",s),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}};rs.resolve=fp;rs.sort=Rr;rs.flatten=Va;var RC={};_a(RC,{ClipboardTextSerializer:()=>wp,Commands:()=>Sp,Delete:()=>kp,Drop:()=>Ep,Editable:()=>Mp,FocusEvents:()=>Ap,Keymap:()=>Rp,Paste:()=>Op,Tabindex:()=>Np,TextDirection:()=>Ip,focusEventsPluginKey:()=>Tp});var Z=class xp extends Ka{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new xp(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},wp=Z.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ae({key:new ge("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:o}=e,{ranges:i}=o,s=Math.min(...i.map(u=>u.$from.pos)),l=Math.max(...i.map(u=>u.$to.pos)),a=pp(n);return hp(r,{from:s,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Sp=Z.create({name:"commands",addCommands(){return{...np}}}),kp=Z.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,o;const i=()=>{var s,l,a,c;if((c=(a=(l=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,t))!=null?c:t.getMeta("y-sync$"))return;const u=$a(t.before,[t,...e]);Ua(u).forEach(f=>{u.mapping.mapResult(f.oldRange.from).deletedAfter&&u.mapping.mapResult(f.oldRange.to).deletedBefore&&u.before.nodesBetween(f.oldRange.from,f.oldRange.to,(p,m)=>{const v=m+p.nodeSize-2,b=f.oldRange.from<=m&&v<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:v,newFrom:u.mapping.map(m),newTo:u.mapping.map(v),deletedRange:f.oldRange,newRange:f.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:u})})});const h=u.mapping;u.steps.forEach((f,p)=>{var m,v;if(f instanceof rt){const b=h.slice(p).map(f.from,-1),C=h.slice(p).map(f.to),x=h.invert().map(b,-1),w=h.invert().map(C),E=(m=u.doc.nodeAt(b-1))==null?void 0:m.marks.some(S=>S.eq(f.mark)),k=(v=u.doc.nodeAt(C))==null?void 0:v.marks.some(S=>S.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:x,to:w},newRange:{from:b,to:C},partial:!!(k||E),editor:this.editor,transaction:t,combinedTransform:u})}})};(o=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||o?setTimeout(i,0):i()}}),Ep=Z.create({name:"drop",addProseMirrorPlugins(){return[new ae({key:new ge("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Mp=Z.create({name:"editable",addProseMirrorPlugins(){return[new ae({key:new ge("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Tp=new ge("focusEvents"),Ap=Z.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ae({key:Tp,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Rp=Z.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:h,parent:f}=d,p=d.parent.isTextblock&&h>0?l.doc.resolve(h-1):d,m=p.parent.type.spec.isolating,v=d.pos-d.parentOffset,b=m&&p.parent.childCount===1?v===d.pos:q.atStart(c).from===h;return!u||!f.type.isTextblock||f.textContent.length||!b||b&&d.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"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 zr()||lp()?i:o},addProseMirrorPlugins(){return[new ae({key:new ge("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(m=>m.getMeta("composition")))return;const r=t.some(m=>m.docChanged)&&!e.doc.eq(n.doc),o=t.some(m=>m.getMeta("preventClearDocument"));if(!r||o)return;const{empty:i,from:s,to:l}=e.selection,a=q.atStart(e.doc).from,c=q.atEnd(e.doc).to;if(i||!(s===a&&l===c)||!ns(n.doc))return;const h=n.tr,f=Xi({state:n,transaction:h}),{commands:p}=new Qi({editor:this.editor,state:f});if(p.clearNodes(),!!h.steps.length)return h}})]}}),Op=Z.create({name:"paste",addProseMirrorPlugins(){return[new ae({key:new ge("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Np=Z.create({name:"tabindex",addProseMirrorPlugins(){return[new ae({key:new ge("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Ip=Z.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=sr(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new ae({key:new ge("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),OC=class wr{constructor(e,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=o}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new wr(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new wr(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new wr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const o=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,s=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(l);if(!o&&!s&&a.depth<=this.depth)return;const c=new wr(a,this.editor,o,o||s?n:null);o&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(n).length>0){const i=o.node.attrs,s=Object.keys(n);for(let l=0;l<s.length;l+=1){const a=s[l];if(i[a]!==n[a])break}}else r=o;o=o.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;const i=Object.keys(n);return this.children.forEach(s=>{r&&o.length>0||(s.node.type.name===e&&i.every(a=>n[a]===s.node.attrs[a])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(e,n,r))))}),o}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},NC=`.ProseMirror {
17
+ */var du;function q0(){return du||(du=1,process.env.NODE_ENV!=="production"&&(function(){function t(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}function e(f,p){u||o.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 m=p();if(!d){var v=p();i(m,v)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}v=s({inst:{value:m,getSnapshot:p}});var b=v[0].inst,C=v[1];return a(function(){b.value=m,b.getSnapshot=p,n(b)&&C({inst:b})},[f,m,p]),l(function(){return n(b)&&C({inst:b}),f(function(){n(b)&&C({inst:b})})},[f]),c(m),m}function n(f){var p=f.getSnapshot;f=f.value;try{var m=p();return!i(f,m)}catch{return!0}}function r(f,p){return p()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=L,i=typeof Object.is=="function"?Object.is:t,s=o.useState,l=o.useEffect,a=o.useLayoutEffect,c=o.useDebugValue,u=!1,d=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:e;Es.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:h,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Es}var fu;function ba(){return fu||(fu=1,process.env.NODE_ENV==="production"?go.exports=K0():go.exports=q0()),go.exports}var Bf=ba();function Se(t){this.content=t}Se.prototype={constructor:Se,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,o=r.find(t),i=r.content.slice();return o==-1?i.push(n||t,e):(i[o+1]=e,n&&(i[o]=n)),new Se(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Se(n)},addToStart:function(t,e){return new Se([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Se(n)},addBefore:function(t,e,n){var r=this.remove(e),o=r.content.slice(),i=r.find(t);return o.splice(i==-1?o.length:i,0,e,n),new Se(o)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Se.from(t),t.size?new Se(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Se.from(t),t.size?new Se(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Se.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Se.from=function(t){if(t instanceof Se)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Se(e)};function _f(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o==i){n+=o.nodeSize;continue}if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)n++;return n}if(o.content.size||i.content.size){let s=_f(o.content,i.content,n+1);if(s!=null)return s}n+=o.nodeSize}}function Hf(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:n,b:r};let s=t.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let c=0,u=Math.min(s.text.length,l.text.length);for(;c<u&&s.text[s.text.length-c-1]==l.text[l.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(s.content.size||l.content.size){let c=Hf(s.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}class A{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,o=0,i){for(let s=0,l=0;l<n;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let i="",s=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new A(o,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],o=0;if(n>e)for(let i=0,s=0;s<n;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),o+=l.nodeSize),s=a}return new A(r,o)}cutByIndex(e,n){return e==n?A.empty:e==0&&n==this.content.length?this:new A(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new A(o,i)}addToStart(e){return new A([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new A(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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 n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let o=this.content[n];e(o,r,n),r+=o.nodeSize}}findDiffStart(e,n=0){return _f(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Hf(this,e,n,r)}findIndex(e){if(e==0)return yo(0,e);if(e==this.size)return yo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=this.child(n),i=r+o.nodeSize;if(i>=e)return i==e?yo(n+1,i):yo(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return A.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new A(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return A.empty;let n,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(n||(n=e.slice(0,o)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new A(n||e,r)}static from(e){if(!e)return A.empty;if(e instanceof A)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new A([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}A.empty=new A([],0);const Ms={index:0,offset:0};function yo(t,e){return Ms.index=t,Ms.offset=e,Ms}function Go(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Go(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Go(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let oe=class wl{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Go(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let o=r.create(n.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return wl.none;if(e instanceof wl)return[e];let n=e.slice();return n.sort((r,o)=>r.type.rank-o.type.rank),n}};oe.none=[];class Jo extends Error{}class j{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=$f(this.content,e+this.openStart,n);return r&&new j(r,this.openStart,this.openEnd)}removeBetween(e,n){return new j(Ff(this.content,e+this.openStart,n+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,n){if(!n)return j.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new j(A.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)o++;return new j(e,r,o)}}j.empty=new j(A.empty,0,0);function Ff(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(o==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Ff(i.content,e-o-1,n-o-1)))}function $f(t,e,n,r){let{index:o,offset:i}=t.findIndex(e),s=t.maybeChild(o);if(i==e||s.isText)return r&&!r.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=$f(s.content,e-i-1,n,s);return l&&t.replaceChild(o,s.copy(l))}function G0(t,e,n){if(n.openStart>t.depth)throw new Jo("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Jo("Inconsistent open depths");return Vf(t,e,n,0)}function Vf(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r<t.depth-n.openStart){let s=Vf(t,e,n,r+1);return i.copy(i.content.replaceChild(o,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,l=s.content;return Sn(s,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=J0(n,t);return Sn(i,Uf(t,s,l,e,r))}else return Sn(i,Zo(t,e,r))}function zf(t,e){if(!e.type.compatibleContent(t.type))throw new Jo("Cannot join "+e.type.name+" onto "+t.type.name)}function Sl(t,e,n){let r=t.node(n);return zf(r,e.node(n)),r}function wn(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Mr(t,e,n,r){let o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(wn(t.nodeAfter,r),i++));for(let l=i;l<s;l++)wn(o.child(l),r);e&&e.depth==n&&e.textOffset&&wn(e.nodeBefore,r)}function Sn(t,e){return t.type.checkContent(e),t.copy(e)}function Uf(t,e,n,r,o){let i=t.depth>o&&Sl(t,e,o+1),s=r.depth>o&&Sl(n,r,o+1),l=[];return Mr(null,t,o,l),i&&s&&e.index(o)==n.index(o)?(zf(i,s),wn(Sn(i,Uf(t,e,n,r,o+1)),l)):(i&&wn(Sn(i,Zo(t,e,o+1)),l),Mr(e,n,o,l),s&&wn(Sn(s,Zo(n,r,o+1)),l)),Mr(r,null,o,l),new A(l)}function Zo(t,e,n){let r=[];if(Mr(null,t,n,r),t.depth>n){let o=Sl(t,e,n+1);wn(Sn(o,Zo(t,e,n+1)),r)}return Mr(e,null,n,r),new A(r)}function J0(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(A.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}class Br{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return oe.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),o=e.maybeChild(n);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Yo(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],o=0,i=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new Br(n,r,i)}static resolveCached(e,n){let r=hu.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==n)return s}else hu.set(e,r=new Z0);let o=r.elts[r.i]=Br.resolve(e,n);return r.i=(r.i+1)%Y0,o}}class Z0{constructor(){this.elts=[],this.i=0}}const Y0=12,hu=new WeakMap;class Yo{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const X0=Object.create(null);let Xt=class kl{constructor(e,n,r,o=oe.none){this.type=e,this.attrs=n,this.marks=o,this.content=r||A.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,o=0){this.content.nodesBetween(e,n,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,o){return this.content.textBetween(e,n,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&Go(this.attrs,n||e.defaultAttrs||X0)&&oe.sameSet(this.marks,r||oe.none)}copy(e=null){return e==this.content?this:new kl(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new kl(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return j.empty;let o=this.resolve(e),i=this.resolve(n),s=r?0:o.sharedDepth(n),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new j(c,o.depth-s,i.depth-s)}replace(e,n,r){return G0(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:o}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(o==e||n.isText)return n;e-=o+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}}resolve(e){return Br.resolveCached(this,e)}resolveNoCache(e){return Br.resolve(this,e)}rangeHasMark(e,n,r){let o=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Wf(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=A.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=oe.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!oe.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let o=A.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,o,r);return i.type.checkAttrs(i.attrs),i}};Xt.prototype.text=void 0;class Xo extends Xt{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Wf(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Xo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Xo(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Wf(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Tn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Q0(e,n);if(r.next==null)return Tn.empty;let o=Kf(r);r.next&&r.err("Unexpected trailing text");let i=s2(i2(o));return l2(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let o=this;for(let i=n;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!n||a.validEnd))return A.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(d)==-1){o.push(d);let h=i(d,l.concat(u));if(h)return h}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&n(r.next[o].next)}return n(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
18
+ `)}}Tn.empty=new Tn(!0);class Q0{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Kf(t){let e=[];do e.push(e2(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function e2(t){let e=[];do e.push(t2(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function t2(t){let e=o2(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=n2(t,e);else break;return e}function pu(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function n2(t,e){let n=pu(t),r=n;return t.eat(",")&&(t.next!="}"?r=pu(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function r2(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let i in n){let s=n[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&t.err("No node type or group '"+e+"' found"),o}function o2(t){if(t.eat("(")){let e=Kf(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=r2(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function i2(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=n())}else if(s.type=="star"){let a=n();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=n();o(i(s.expr,a),u),a=u}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=n();r(a,u),o(i(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function qf(t,e){return e-t}function mu(t,e){let n=[];return r(e),n.sort(qf);function r(o){let i=t[o];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&n.indexOf(a)==-1&&r(a)}}}function s2(t){let e=Object.create(null);return n(mu(t,0));function n(r){let o=[];r.forEach(s=>{t[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);mu(t,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new Tn(r.indexOf(t.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(qf);i.next.push({type:o[s][0],next:e[l.join(",")]||n(l)})}return i}}function l2(t,e){for(let n=0,r=[t];n<r.length;n++){let o=r[n],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Gf(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Jf(t,e){let n=Object.create(null);for(let r in t){let o=e&&e[r];if(o===void 0){let i=t[r];if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=o}return n}function Zf(t,e,n,r){for(let o in e)if(!(o in t))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let o in t){let i=t[o];i.validate&&i.validate(e[o])}}function Yf(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new c2(t,r,e[r]);return n}let gu=class Xf{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Yf(e,r.attrs),this.defaultAttrs=Gf(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Tn.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Jf(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Xt(this,this.computeAttrs(e),A.from(n),oe.setFrom(r))}createChecked(e=null,n,r){return n=A.from(n),this.checkContent(n),new Xt(this,this.computeAttrs(e),n,oe.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=A.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let o=this.contentMatch.matchFragment(n),i=o&&o.fillBefore(A.empty,!0);return i?new Xt(this,e,n.append(i),oe.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Zf(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:oe.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,s)=>r[i]=new Xf(i,n,s));let o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function a2(t,e,n){let r=n.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class c2{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?a2(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Wi{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=Yf(e,o.attrs),this.excluded=null;let i=Gf(this.attrs);this.instance=i?new oe(this,i):null}create(e=null){return!e&&this.instance?this.instance:new oe(this,Jf(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new Wi(i,o++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Zf(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Qf{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=Se.from(e.nodes),n.marks=Se.from(e.marks||{}),this.nodes=gu.compile(this.spec.nodes,this),this.marks=Wi.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=Tn.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?yu(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:yu(this,s.split(" "))}this.nodeFromJSON=o=>Xt.fromJSON(this,o),this.markFromJSON=o=>oe.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof gu){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,o)}text(e,n){let r=this.nodes.text;return new Xo(r,r.defaultAttrs,e,oe.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function yu(t,e){let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(let l in t.marks){let a=t.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function u2(t){return t.tag!=null}function d2(t){return t.style!=null}class Qt{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(o=>{if(u2(o))this.tags.push(o);else if(d2(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new bu(this,n,!1);return r.addAll(e,oe.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new bu(this,n,!0);return r.addAll(e,oe.none,n.from,n.to),j.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(p2(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,n,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<n.length;s++){let l=n[s];if((l.priority==null?50:l.priority)<i)break}n.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Cu(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Cu(s)),s.node||s.ignore||s.mark||(s.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Qt(e,Qt.schemaRules(e)))}}const eh={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},f2={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},th={ol:!0,ul:!0},_r=1,El=2,Tr=4;function vu(t,e,n){return e!=null?(e?_r:0)|(e==="full"?El:0):t&&t.whitespace=="pre"?_r|El:n&~Tr}class vo{constructor(e,n,r,o,i,s){this.type=e,this.attrs=n,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=oe.none,this.match=i||(s&Tr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(A.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&_r)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let n=A.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(A.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!eh.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class bu{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=n.topNode,i,s=vu(null,n.preserveWhitespace,0)|(r?Tr:0);o?i=new vo(o.type,o.attrs,oe.none,!0,n.topMatch||o.type.contentMatch,s):r?i=new vo(null,null,oe.none,!0,null,s):i=new vo(e.schema.topNodeType,null,oe.none,!0,null,s),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,o=this.top,i=o.options&El?"full":this.localPreserveWS||(o.options&_r)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
19
+ `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(s.text(l[a]),n,!/\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=o.content[o.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(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;th.hasOwnProperty(s)&&this.parser.normalizeLists&&h2(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:f2.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);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(eh.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
20
+ `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(i,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,o){let i,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,n);this.findAtPoint(e,i)}findPlace(e,n,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)n=this.enterInner(o[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let o=this.findPlace(e,n,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=oe.none;for(let l of o.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):xu(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,n,r,o){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,o)),i}enterInner(e,n,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=vu(e,i,s.options);s.options&Tr&&s.content.length==0&&(l|=Tr);let a=oe.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):xu(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new vo(e,n,a,o,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].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 n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=_r)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&n.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function h2(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&th.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function p2(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Cu(t){let e={};for(let n in t)e[n]=t[n];return e}function xu(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&s(u))return!0}};if(s(o.contentMatch))return!0}}class Ln{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Ts(n).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,n);u&&(i.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:o}=_o(Ts(n),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,o)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&_o(Ts(r),o(e,n),null,e.attrs)}static renderSpec(e,n,r=null,o){return _o(e,n,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ln(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=wu(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return wu(e.marks)}}function wu(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Ts(t){return t.document||window.document}const Su=new WeakMap;function m2(t){let e=Su.get(t);return e===void 0&&Su.set(t,e=g2(t)),e}function g2(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)n(r[o]);else for(let o in r)n(r[o])}return n(t),e}function _o(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=m2(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=o.indexOf(" ");s>0&&(n=o.slice(0,s),o=o.slice(s+1));let l,a=n?t.createElementNS(n,o):t.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let h=d.indexOf(" ");h>0?a.setAttributeNS(d.slice(0,h),d.slice(h+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let h=e[d];if(h===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=_o(t,h,n,r);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const nh=65535,rh=Math.pow(2,16);function y2(t,e){return t+e*rh}function ku(t){return t&nh}function v2(t){return(t-(t&nh))/rh}const oh=1,ih=2,Ho=4,sh=8;class Ml{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&sh)>0}get deletedBefore(){return(this.delInfo&(oh|Ho))>0}get deletedAfter(){return(this.delInfo&(ih|Ho))>0}get deletedAcross(){return(this.delInfo&Ho)>0}}class Ve{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ve.empty)return Ve.empty}recover(e){let n=0,r=ku(e);if(!this.inverted)for(let o=0;o<r;o++)n+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+n+v2(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+s],d=a+c;if(e<=d){let h=c?e==a?-1:e==d?1:n:n,f=a+o+(h<0?0:u);if(r)return f;let p=e==(n<0?a:d)?null:y2(l/3,e-a),m=e==a?ih:e==d?oh:Ho;return(n<0?e!=a:e!=d)&&(m|=sh),new Ml(f,m,p)}o+=u-c}return r?e+o:new Ml(e+o,0,null)}touches(e,n){let r=0,o=ku(n),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+n],u=this.ranges[o+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new Ve(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ve.empty:new Ve(e<0?[0,-e,0]:[0,0,e])}}Ve.empty=new Ve([]);class Hr{constructor(e,n,r=0,o=e?e.length:0){this.mirror=n,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Hr(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let o=e.getMirror(n);this.appendMap(e._maps[n],o!=null&&o<n?r+o:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let o=e.getMirror(n);this.appendMap(e._maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let e=new Hr;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],l=s.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new Ml(e,o,null)}}const As=Object.create(null);class Ne{getMap(){return Ve.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=As[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in As)throw new RangeError("Duplicate use of step JSON ID "+e);return As[e]=n,n.prototype.jsonID=e,n}}class pe{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new pe(e,null)}static fail(e){return new pe(null,e)}static fromReplace(e,n,r,o){try{return pe.ok(e.replace(n,r,o))}catch(i){if(i instanceof Jo)return pe.fail(i.message);throw i}}}function Ca(t,e,n){let r=[];for(let o=0;o<t.childCount;o++){let i=t.child(o);i.content.size&&(i=i.copy(Ca(i.content,e,i))),i.isInline&&(i=e(i,n,o)),r.push(i)}return A.fromArray(r)}class Jt extends Ne{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new j(Ca(n.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),n.openStart,n.openEnd);return pe.fromReplace(e,this.from,this.to,i)}invert(){return new rt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Jt(n.pos,r.pos,this.mark)}merge(e){return e instanceof Jt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Jt(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Jt(n.from,n.to,e.markFromJSON(n.mark))}}Ne.jsonID("addMark",Jt);class rt extends Ne{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new j(Ca(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return pe.fromReplace(e,this.from,this.to,r)}invert(){return new Jt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new rt(n.pos,r.pos,this.mark)}merge(e){return e instanceof rt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rt(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new rt(n.from,n.to,e.markFromJSON(n.mark))}}Ne.jsonID("removeMark",rt);class Zt extends Ne{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return pe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return pe.fromReplace(e,this.pos,this.pos+1,new j(A.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;o<n.marks.length;o++)if(!n.marks[o].isInSet(r))return new Zt(this.pos,n.marks[o]);return new Zt(this.pos,this.mark)}}return new An(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Zt(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Zt(n.pos,e.markFromJSON(n.mark))}}Ne.jsonID("addNodeMark",Zt);class An extends Ne{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return pe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return pe.fromReplace(e,this.pos,this.pos+1,new j(A.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Zt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new An(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new An(n.pos,e.markFromJSON(n.mark))}}Ne.jsonID("removeNodeMark",An);class ve extends Ne{constructor(e,n,r,o=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=o}apply(e){return this.structure&&Tl(e,this.from,this.to)?pe.fail("Structure replace would overwrite content"):pe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ve([this.from,this.to-this.from,this.slice.size])}invert(e){return new ve(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new ve(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ve)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?j.empty:new j(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ve(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?j.empty:new j(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ve(e.from,this.to,n,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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ve(n.from,n.to,j.fromJSON(e,n.slice),!!n.structure)}}Ne.jsonID("replace",ve);class be extends Ne{constructor(e,n,r,o,i,s,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Tl(e,this.from,this.gapFrom)||Tl(e,this.gapTo,this.to)))return pe.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return pe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?pe.fromReplace(e,this.from,this.to,r):pe.fail("Content does not fit in gap")}getMap(){return new Ve([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new be(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||o<n.pos||i>r.pos?null:new be(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new be(n.from,n.to,n.gapFrom,n.gapTo,j.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ne.jsonID("replaceAround",be);function Tl(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function b2(t,e,n,r){let o=[],i=[],s,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let h=Math.max(c,e),f=Math.min(c+a.nodeSize,n),p=r.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(s&&s.to==h&&s.mark.eq(d[m])?s.to=f:o.push(s=new rt(h,f,d[m])));l&&l.to==h?l.to=f:i.push(l=new Jt(h,f,r))}}),o.forEach(a=>t.step(a)),i.forEach(a=>t.step(a))}function C2(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof Wi){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],h;for(let f=0;f<o.length;f++){let p=o[f];p.step==i-1&&d.eq(o[f].style)&&(h=p)}h?(h.to=c,h.step=i):o.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>t.step(new rt(s.from,s.to,s.style)))}function xa(t,e,n,r=n.contentMatch,o=!0){let i=t.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)s.push(new ve(l,u,j.empty));else{r=d;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new rt(l,u,c.marks[h]));if(o&&c.isText&&n.whitespace!="pre"){let h,f=/\r?\n|\r/g,p;for(;h=f.exec(c.text);)p||(p=new j(A.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new ve(l+h.index,l+h.index+h[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(A.empty,!0);t.replace(l,l,new j(a,0,0))}for(let a=s.length-1;a>=0;a--)t.step(s[a])}function x2(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function dr(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let o=t.$from.node(r),i=t.$from.index(r),s=t.$to.indexAfter(r);if(r<t.depth&&o.canReplace(i,s,n))return r;if(r==0||o.type.spec.isolating||!x2(o,i,s))break}return null}function w2(t,e,n){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,u=A.empty,d=0;for(let p=i,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=A.from(r.node(p).copy(u)),d++):a--;let h=A.empty,f=0;for(let p=i,m=!1;p>n;p--)m||o.after(p+1)<o.end(p)?(m=!0,h=A.from(o.node(p).copy(h)),f++):c++;t.step(new be(a,c,s,l,new j(u.append(h),d,f),u.size-d,!0))}function wa(t,e,n=null,r=t){let o=S2(t,e),i=o&&k2(r,e);return i?o.map(Eu).concat({type:e,attrs:n}).concat(i.map(Eu)):null}function Eu(t){return{type:t,attrs:null}}function S2(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(r,o,s)?i:null}function k2(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:s}function E2(t,e,n){let r=A.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let l=n[s].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=A.from(n[s].type.create(n[s].attrs,r))}let o=e.start,i=e.end;t.step(new be(o,i,o,i,new j(r,0,0),n.length,!0))}function M2(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&T2(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&ah(t,s,l,i),xa(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let u=t.mapping.slice(i),d=u.map(l,1),h=u.map(l+s.nodeSize,1);return t.step(new be(d,h,d+1,h-1,new j(A.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&lh(t,s,l,i),!1}})}function lh(t,e,n,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=t.mapping.slice(r).map(n+1+i+s.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function ah(t,e,n,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+i);t.replaceWith(s,s+1,e.type.schema.text(`
21
+ `))}})}function T2(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function A2(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new be(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new j(A.from(s),0,0),1,!0))}function Rt(t,e,n=1,r){let o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=n-2;c>i;c--,u--){let d=o.node(c),h=o.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(h,d.childCount),p=r&&r[u+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(h+1,d.childCount)||!m.type.validContent(f))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function R2(t,e,n=1,r){let o=t.doc.resolve(e),i=A.empty,s=A.empty;for(let l=o.depth,a=o.depth-n,c=n-1;l>a;l--,c--){i=A.from(o.node(l).copy(i));let u=r&&r[c];s=A.from(u?u.type.create(u.attrs,s):o.node(l).copy(s))}t.step(new ve(e,e,new j(i.append(s),n,n),!0))}function dn(t,e){let n=t.resolve(e),r=n.index();return ch(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function O2(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),s=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function ch(t,e){return!!(t&&e&&!t.isLeaf&&O2(t,e))}function Ki(t,e,n=-1){let r=t.resolve(e);for(let o=r.depth;;o--){let i,s,l=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&ch(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=n<0?r.before(o):r.after(o)}}function N2(t,e,n){let r=null,{linebreakReplacement:o}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(o&&s.inlineContent){let u=s.whitespace=="pre",d=!!s.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);ah(t,u.node(),u.before(),l)}s.inlineContent&&xa(t,e+n-1,s,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new ve(c,a.map(e+n,-1),j.empty,!0)),r===!0){let u=t.doc.resolve(c);lh(t,u.node(),u.before(),t.steps.length)}return t}function I2(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,n))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function uh(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let o=n.content;for(let i=0;i<n.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),u=!1;if(i==1)u=c.canReplace(a,a,o);else{let d=c.contentMatchAt(a).findWrapping(o.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function qi(t,e,n=e,r=j.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return dh(o,i,r)?new ve(e,n,r):new L2(o,i,r).fit()}function dh(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class L2{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=A.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=A.from(e.node(o).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(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new j(i,s,l);return e>-1?new be(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new ve(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=Rs(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(s?c.matchType(s.type)||(d=c.fillBefore(A.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Rs(e,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new j(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Rs(e,n);if(o.childCount<=1&&n>0){let i=e.size-n<=n+o.size;this.unplaced=new j(Cr(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new j(Cr(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:d,type:h}=this.frontier[n];if(o){for(let m=0;m<o.childCount;m++)u.push(o.child(m));d=d.matchFragment(o)}let f=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),v=d.matchType(m.type);if(!v)break;c++,(c>1||a==0||m.content.size)&&(d=v,u.push(fh(m.mark(h.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=xr(this.placed,n,A.from(u)),this.frontier[n].match=d,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,v=l;m<f;m++){let b=v.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),v=b.content}this.unplaced=p?e==0?j.empty:new j(Cr(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new j(Cr(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Os(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=Os(e,n,o,r,i);if(s){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Os(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=xr(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=xr(this.placed,this.depth,A.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(A.empty,!0);n.childCount&&(this.placed=xr(this.placed,this.frontier.length,n))}}function Cr(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Cr(t.firstChild.content,e-1,n)))}function xr(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(xr(t.lastChild.content,e-1,n)))}function Rs(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function fh(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,fh(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(A.empty,!0)))),t.copy(r)}function Os(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!D2(n,i.content,s)?l:null}function D2(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function P2(t){return t.spec.defining||t.spec.definingForContent}function j2(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let o=t.doc.resolve(e),i=t.doc.resolve(n);if(dh(o,i,r))return t.step(new ve(e,n,r));let s=ph(o,t.doc.resolve(n));s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let h=o.depth,f=o.pos-1;h>0;h--,f--){let p=o.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(h)>-1?l=h:o.before(h)==f&&s.splice(1,0,-h)}let a=s.indexOf(l),c=[],u=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==r.openStart)break;h=p.content}for(let h=u-1;h>=0;h--){let f=c[h],p=P2(f.type);if(p&&!f.sameMarkup(o.node(Math.abs(l)-1)))u=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+u+1)%(r.openStart+1),p=c[f];if(p)for(let m=0;m<s.length;m++){let v=s[(m+a)%s.length],b=!0;v<0&&(b=!1,v=-v);let C=o.node(v-1),x=o.index(v-1);if(C.canReplaceWith(x,x,p.type,p.marks))return t.replace(o.before(v),b?i.after(v):n,new j(hh(r.content,0,r.openStart,f),f,r.openEnd))}}let d=t.steps.length;for(let h=s.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>d));h--){let f=s[h];f<0||(e=o.before(f),n=i.after(f))}}function hh(t,e,n,r,o){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(hh(i.content,e+1,n,r,i)))}if(e>r){let i=o.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(A.empty,!0))}return t}function B2(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=I2(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new j(A.from(r),0,0))}function _2(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n),i=ph(r,o);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function ph(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let i=t.start(o);if(i<t.pos-(t.depth-o)||e.end(o)>e.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&n.push(o)}return n}class Xn extends Ne{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return pe.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return pe.fromReplace(e,this.pos,this.pos+1,new j(A.from(o),0,n.isLeaf?0:1))}getMap(){return Ve.empty}invert(e){return new Xn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Xn(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Xn(n.pos,n.attr,n.value)}}Ne.jsonID("attr",Xn);class Fr extends Ne{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return pe.ok(r)}getMap(){return Ve.empty}invert(e){return new Fr(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Fr(n.attr,n.value)}}Ne.jsonID("docAttr",Fr);let rr=class extends Error{};rr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};rr.prototype=Object.create(Error.prototype);rr.prototype.constructor=rr;rr.prototype.name="TransformError";class mh{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Hr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new rr(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=j.empty){let o=qi(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new j(A.from(r),0,0))}delete(e,n){return this.replace(e,n,j.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return j2(this,e,n,r),this}replaceRangeWith(e,n,r){return B2(this,e,n,r),this}deleteRange(e,n){return _2(this,e,n),this}lift(e,n){return w2(this,e,n),this}join(e,n=1){return N2(this,e,n),this}wrap(e,n){return E2(this,e,n),this}setBlockType(e,n=e,r,o=null){return M2(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return A2(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new Xn(e,n,r)),this}setDocAttribute(e,n){return this.step(new Fr(e,n)),this}addNodeMark(e,n){return this.step(new Zt(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof oe)n.isInSet(r.marks)&&this.step(new An(e,n));else{let o=r.marks,i,s=[];for(;i=n.isInSet(o);)s.push(new An(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return R2(this,e,n,r),this}addMark(e,n,r){return b2(this,e,n,r),this}removeMark(e,n,r){return C2(this,e,n,r),this}clearIncompatible(e,n,r){return xa(this,e,n,r),this}}const Ns=Object.create(null);let q=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new H2(e.min(n),e.max(n))]}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 n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=j.empty){let r=n.content.lastChild,o=null;for(let l=0;l<n.openEnd;l++)o=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?j.empty:n),l==0&&Au(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:l}=o[i],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),Au(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let o=e.parent.inlineContent?new z(e):Kn(e.node(0),e.parent,e.pos,e.index(),n,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=n<0?Kn(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Kn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new ze(e.node(0))}static atStart(e){return Kn(e,e,0,0,1)||new ze(e)}static atEnd(e){return Kn(e,e,e.content.size,e.childCount,-1)||new ze(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ns[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Ns)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ns[e]=n,n.prototype.jsonID=e,n}getBookmark(){return z.between(this.$anchor,this.$head).getBookmark()}};q.prototype.visible=!0;class H2{constructor(e,n){this.$from=e,this.$to=n}}let Mu=!1;function Tu(t){!Mu&&!t.parent.inlineContent&&(Mu=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class z extends q{constructor(e,n=e){Tu(e),Tu(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return q.near(r);let o=e.resolve(n.map(this.anchor));return new z(o.parent.inlineContent?o:r,r)}replace(e,n=j.empty){if(super.replace(e,n),n==j.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof z&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Gi(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new z(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let i=q.findFrom(n,r,!0)||q.findFrom(n,-r,!0);if(i)n=i.$head;else return q.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(q.findFrom(e,-r,!0)||q.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=o<0&&(e=n))),new z(e,n)}}q.jsonID("text",z);class Gi{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Gi(e.map(this.anchor),e.map(this.head))}resolve(e){return z.between(e.resolve(this.anchor),e.resolve(this.head))}}class B extends q{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:o}=n.mapResult(this.anchor),i=e.resolve(o);return r?q.near(i):new B(i)}content(){return new j(A.from(this.node),0,0)}eq(e){return e instanceof B&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Sa(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new B(e.resolve(n.anchor))}static create(e,n){return new B(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}B.prototype.visible=!1;q.jsonID("node",B);class Sa{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Gi(r,r):new Sa(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&B.isSelectable(r)?new B(n):q.near(n)}}class ze extends q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=j.empty){if(n==j.empty){e.delete(0,e.doc.content.size);let r=q.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new ze(e)}map(e){return new ze(e)}eq(e){return e instanceof ze}getBookmark(){return F2}}q.jsonID("all",ze);const F2={map(){return this},resolve(t){return new ze(t)}};function Kn(t,e,n,r,o,i=!1){if(e.inlineContent)return z.create(t,n);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&B.isSelectable(l))return B.create(t,n-(o<0?l.nodeSize:0))}else{let a=Kn(t,l,n+o,o<0?l.childCount:0,o,i);if(a)return a}n+=l.nodeSize*o}return null}function Au(t,e,n){let r=t.steps.length-1;if(r<e)return;let o=t.steps[r];if(!(o instanceof ve||o instanceof be))return;let i=t.mapping.maps[r],s;i.forEach((l,a,c,u)=>{s==null&&(s=u)}),t.setSelection(q.near(t.doc.resolve(s),n))}const Ru=1,bo=2,Ou=4;class $2 extends mh{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Ru)&~bo,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ru)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=bo,this}ensureMarks(e){return oe.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&bo)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~bo,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||oe.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(q.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ou,this}get scrolledIntoView(){return(this.updated&Ou)>0}}function Nu(t,e){return!e||!t?t:t.bind(e)}class wr{constructor(e,n,r){this.name=e,this.init=Nu(n.init,r),this.apply=Nu(n.apply,r)}}const V2=[new wr("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new wr("selection",{init(t,e){return t.selection||q.atStart(e.doc)},apply(t){return t.selection}}),new wr("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new wr("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Is{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=V2.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new wr(r.key,r.spec.state,r))})}}class Zn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=o?o[s].n:0,c=o?o[s].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let d=0;d<this.config.plugins.length;d++)o.push(d<s?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),i=!0}o&&(o[s]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Zn(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new $2(this)}static create(e){let n=new Is(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Zn(n);for(let o=0;o<n.fields.length;o++)r[n.fields[o].name]=n.fields[o].init(e,r);return r}reconfigure(e){let n=new Is(this.schema,e.plugins),r=n.fields,o=new Zn(n);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[i].init(e,o)}return o}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,this[o.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Is(e.schema,e.plugins),i=new Zn(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=Xt.fromJSON(e.schema,n.doc);else if(s.name=="selection")i.selection=q.fromJSON(i.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[s.name]=c.fromJSON.call(a,e,n[l],i);return}}i[s.name]=s.init(e,i)}}),i}}function gh(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=gh(o,e,{})),n[r]=o}return n}class ae{constructor(e){this.spec=e,this.props={},e.props&&gh(e.props,this,this.props),this.key=e.key?e.key.key:yh("plugin")}getState(e){return e[this.key]}}const Ls=Object.create(null);function yh(t){return t in Ls?t+"$"+ ++Ls[t]:(Ls[t]=0,t+"$")}class ge{constructor(e="key"){this.key=yh(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ka=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function vh(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const bh=(t,e,n)=>{let r=vh(t,n);if(!r)return!1;let o=Ea(r);if(!o){let s=r.blockRange(),l=s&&dr(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Ah(t,o,e,-1))return!0;if(r.parent.content.size==0&&(or(i,"end")||B.isSelectable(i)))for(let s=r.depth;;s--){let l=qi(t.doc,r.before(s),r.after(s),j.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(or(i,"end")?q.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):B.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},z2=(t,e,n)=>{let r=vh(t,n);if(!r)return!1;let o=Ea(r);return o?Ch(t,o,e):!1},U2=(t,e,n)=>{let r=wh(t,n);if(!r)return!1;let o=Ma(r);return o?Ch(t,o,e):!1};function Ch(t,e,n){let r=e.nodeBefore,o=r,i=e.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let u=o.lastChild;if(!u)return!1;o=u}let s=e.nodeAfter,l=s,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=qi(t.doc,i,a,j.empty);if(!c||c.from!=i||c instanceof ve&&c.slice.size>=a-i)return!1;if(n){let u=t.tr.step(c);u.setSelection(z.create(u.doc,i)),n(u.scrollIntoView())}return!0}function or(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const xh=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=Ea(r)}let s=i&&i.nodeBefore;return!s||!B.isSelectable(s)?!1:(e&&e(t.tr.setSelection(B.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function Ea(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function wh(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Sh=(t,e,n)=>{let r=wh(t,n);if(!r)return!1;let o=Ma(r);if(!o)return!1;let i=o.nodeAfter;if(Ah(t,o,e,1))return!0;if(r.parent.content.size==0&&(or(i,"start")||B.isSelectable(i))){let s=qi(t.doc,r.before(),r.after(),j.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=t.tr.step(s);l.setSelection(or(i,"start")?q.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):B.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},kh=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=Ma(r)}let s=i&&i.nodeAfter;return!s||!B.isSelectable(s)?!1:(e&&e(t.tr.setSelection(B.create(t.doc,i.pos)).scrollIntoView()),!0)};function Ma(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const W2=(t,e)=>{let n=t.selection,r=n instanceof B,o;if(r){if(n.node.isTextblock||!dn(t.doc,n.from))return!1;o=n.from}else if(o=Ki(t.doc,n.from,-1),o==null)return!1;if(e){let i=t.tr.join(o);r&&i.setSelection(B.create(i.doc,o-t.doc.resolve(o).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},K2=(t,e)=>{let n=t.selection,r;if(n instanceof B){if(n.node.isTextblock||!dn(t.doc,n.to))return!1;r=n.to}else if(r=Ki(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},q2=(t,e)=>{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),i=o&&dr(o);return i==null?!1:(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)},Eh=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
22
+ `).scrollIntoView()),!0)};function Ta(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const G2=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=Ta(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(q.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Mh=(t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof ze||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Ta(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=t.tr.insert(s,i.createAndFill());l.setSelection(z.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Th=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Rt(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&dr(r);return o==null?!1:(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)};function J2(t){return(e,n)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof B&&e.selection.node.isBlock)return!r.parentOffset||!Rt(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],s,l,a=!1,c=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){a=r.end(f)==r.pos+(r.depth-f),c=r.start(f)==r.pos-(r.depth-f),l=Ta(r.node(f-1).contentMatchAt(r.indexAfter(f-1))),i.unshift(a&&l?{type:l}:null),s=f;break}else{if(f==1)return!1;i.unshift(null)}let u=e.tr;(e.selection instanceof z||e.selection instanceof ze)&&u.deleteSelection();let d=u.mapping.map(r.pos),h=Rt(u.doc,d,i.length,i);if(h||(i[0]=l?{type:l}:null,h=Rt(u.doc,d,i.length,i)),!h)return!1;if(u.split(d,i.length,i),!a&&c&&r.node(s).type!=l){let f=u.mapping.map(r.before(s)),p=u.doc.resolve(f);l&&r.node(s-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(s)),l)}return n&&n(u.scrollIntoView()),!0}}const Z2=J2(),Y2=(t,e)=>{let{$from:n,to:r}=t.selection,o,i=n.sharedDepth(r);return i==0?!1:(o=n.before(i),e&&e(t.tr.setSelection(B.create(t.doc,o))),!0)};function X2(t,e,n){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||dn(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Ah(t,e,n,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&X2(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(n){let f=e.pos+i.nodeSize,p=A.empty;for(let b=s.length-1;b>=0;b--)p=A.from(s[b].create(null,p));p=A.from(o.copy(p));let m=t.tr.step(new be(e.pos-1,f,e.pos,f,new j(p,1,0),s.length,!0)),v=m.doc.resolve(f+2*s.length);v.nodeAfter&&v.nodeAfter.type==o.type&&dn(m.doc,v.pos)&&m.join(v.pos),n(m.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:q.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),h=d&&dr(d);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(d,h).scrollIntoView()),!0;if(c&&or(i,"start",!0)&&or(o,"end")){let f=o,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let m=i,v=1;for(;!m.isTextblock;m=m.firstChild)v++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(n){let b=A.empty;for(let x=p.length-1;x>=0;x--)b=A.from(p[x].copy(b));let C=t.tr.step(new be(e.pos-p.length,e.pos+i.nodeSize,e.pos+v,e.pos+i.nodeSize-v,new j(b,p.length,0),0,!0));n(C.scrollIntoView())}return!0}}return!1}function Rh(t){return function(e,n){let r=e.selection,o=t<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(n&&n(e.tr.setSelection(z.create(e.doc,t<0?o.start(i):o.end(i)))),!0):!1}}const Q2=Rh(-1),ey=Rh(1);function ty(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&wa(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Iu(t,e=null){return function(n,r){let o=!1;for(let i=0;i<n.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)o=!0;else{let u=n.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,t)}})}if(!o)return!1;if(r){let i=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[s];i.setBlockType(l,a,t,e)}r(i.scrollIntoView())}return!0}}function Aa(...t){return function(e,n,r){for(let o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}Aa(ka,bh,xh);Aa(ka,Sh,kh);Aa(Eh,Mh,Th,Z2);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function ny(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i);if(!s)return!1;let l=r?n.tr:null;return ry(l,s,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function ry(t,e,n,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new Yo(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Yo(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=wa(i,n,r,e);return l?(t&&oy(t,e,l,o,n),!0):!1}function oy(t,e,n,r,o){let i=A.empty;for(let u=n.length-1;u>=0;u--)i=A.from(n[u].type.create(n[u].attrs,i));t.step(new be(e.start-(r?2:0),e.end,e.start,e.end,new j(i,0,0),n.length,!0));let s=0;for(let u=0;u<n.length;u++)n[u].type==o&&(s=u+1);let l=n.length-s,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,h=!0;u<d;u++,h=!1)!h&&Rt(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function iy(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,s=>s.childCount>0&&s.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?sy(e,n,t,i):ly(e,n,i):!0:!1}}function sy(t,e,n,r){let o=t.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new be(i-1,s,i,s,new j(A.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Yo(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));const l=dr(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(i,-1)-1);return dn(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),e(o.scrollIntoView()),!0}function ly(t,e,n){let r=t.tr,o=n.parent;for(let f=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)f-=o.child(p).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==o.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?A.empty:A.from(o))))return!1;let d=i.pos,h=d+s.nodeSize;return r.step(new be(d-(l?1:0),h+(a?1:0),d+1,h-1,new j((l?A.empty:A.from(o.copy(A.empty))).append(a?A.empty:A.from(o.copy(A.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function ay(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=A.from(c?t.create():null),d=new j(A.from(t.create(null,A.from(l.type.create(null,u)))),c?3:1,0),h=i.start,f=i.end;n(e.tr.step(new be(h-(c?3:1),f,h,f,d,1,!0)).scrollIntoView())}return!0}}const ke=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},ir=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Al=null;const Mt=function(t,e,n){let r=Al||(Al=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},cy=function(){Al=null},Rn=function(t,e,n,r){return n&&(Lu(t,e,n,r,-1)||Lu(t,e,n,r,1))},uy=/^(img|br|input|textarea|hr)$/i;function Lu(t,e,n,r,o){for(var i;;){if(t==n&&e==r)return!0;if(e==(o<0?0:Ye(t))){let s=t.parentNode;if(!s||s.nodeType!=1||ro(t)||uy.test(t.nodeName)||t.contentEditable=="false")return!1;e=ke(t)+(o<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(o<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else t=s,e=o<0?Ye(t):0}else return!1}}function Ye(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function dy(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Ye(t)}else if(t.parentNode&&!ro(t))e=ke(t),t=t.parentNode;else return null}}function fy(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!ro(t))e=ke(t)+1,t=t.parentNode;else return null}}function hy(t,e,n){for(let r=e==0,o=e==Ye(t);r||o;){if(t==n)return!0;let i=ke(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,o=o&&i==Ye(t)}}function ro(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Ji=function(t){return t.focusNode&&Rn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function gn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function py(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function my(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Ye(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Ye(r.startContainer),r.startOffset)}}}const pt=typeof navigator<"u"?navigator:null,Du=typeof document<"u"?document:null,fn=pt&&pt.userAgent||"",Rl=/Edge\/(\d+)/.exec(fn),Oh=/MSIE \d/.exec(fn),Ol=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(fn),He=!!(Oh||Ol||Rl),en=Oh?document.documentMode:Ol?+Ol[1]:Rl?+Rl[1]:0,Xe=!He&&/gecko\/(\d+)/i.test(fn);Xe&&+(/Firefox\/(\d+)/.exec(fn)||[0,0])[1];const Nl=!He&&/Chrome\/(\d+)/.exec(fn),Re=!!Nl,Nh=Nl?+Nl[1]:0,De=!He&&!!pt&&/Apple Computer/.test(pt.vendor),sr=De&&(/Mobile\/\w+/.test(fn)||!!pt&&pt.maxTouchPoints>2),Ze=sr||(pt?/Mac/.test(pt.platform):!1),gy=pt?/Win/.test(pt.platform):!1,Tt=/Android \d/.test(fn),oo=!!Du&&"webkitFontSmoothing"in Du.documentElement.style,yy=oo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function vy(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function wt(t,e){return typeof t=="number"?t:t[e]}function by(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Pu(t,e,n){let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=ir(s);continue}let l=s,a=l==i.body,c=a?vy(i):by(l),u=0,d=0;if(e.top<c.top+wt(r,"top")?d=-(c.top-e.top+wt(o,"top")):e.bottom>c.bottom-wt(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+wt(o,"top")-c.top:e.bottom-c.bottom+wt(o,"bottom")),e.left<c.left+wt(r,"left")?u=-(c.left-e.left+wt(o,"left")):e.right>c.right-wt(r,"right")&&(u=e.right-c.right+wt(o,"right")),u||d)if(a)i.defaultView.scrollBy(u,d);else{let f=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let m=l.scrollLeft-f,v=l.scrollTop-p;e={left:e.left-m,top:e.top-v,right:e.right-m,bottom:e.bottom-v}}let h=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(h))break;s=h=="absolute"?s.offsetParent:ir(s)}}function Cy(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=t.root.elementFromPoint(i,s);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Ih(t.dom)}}function Ih(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=ir(r));return e}function xy({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Lh(n,r==0?0:r-e)}function Lh(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:o,left:i}=t[n];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let $n=null;function wy(t){if(t.setActive)return t.setActive();if($n)return t.focus($n);let e=Ih(t);t.focus($n==null?{get preventScroll(){return $n={preventScroll:!0},!0}}:void 0),$n||($n=!1,Lh(e,0))}function Dh(t,e){let n,r=2e8,o,i=0,s=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let h;if(u.nodeType==1)h=u.getClientRects();else if(u.nodeType==3)h=Mt(u).getClientRects();else continue;for(let f=0;f<h.length;f++){let p=h[f];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){n=u,r=m,o=m&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&m&&(i=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=d+1)}}return!n&&a&&(n=a,o=c,r=0),n&&n.nodeType==3?Sy(n,o):!n||r&&n.nodeType==1?{node:t,offset:i}:Dh(n,o)}function Sy(t,e){let n=t.nodeValue.length,r=document.createRange();for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let i=Ft(r,1);if(i.top!=i.bottom&&Ra(e,i))return{node:t,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function Ra(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function ky(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Ey(t,e,n){let{node:r,offset:o}=Dh(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,o,i)}function My(t,e,n,r){let o=-1;for(let i=e,s=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n,-1)}function Ph(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let s=t.childNodes[i];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Ra(e,c))return Ph(s,e,c)}}if((i=(i+1)%r)==o)break}return t}function Ty(t,e){let n=t.dom.ownerDocument,r,o=0,i=my(n,e.left,e.top);i&&({node:r,offset:o}=i);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=t.dom.getBoundingClientRect();if(!Ra(e,c)||(s=Ph(t.dom,e,c),!s))return null}if(De)for(let c=s;r&&c;c=ir(c))c.draggable&&(r=void 0);if(s=ky(s,e),r){if(Xe&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&o++}let c;oo&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=My(t,r,o,e))}l==null&&(l=Ey(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function ju(t){return t.top<t.bottom||t.left<t.right}function Ft(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(ju(r))return r}return Array.prototype.find.call(n,ju)||t.getBoundingClientRect()}const Ay=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function jh(t,e,n){let{node:r,offset:o,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=oo||Xe;if(r.nodeType==3)if(s&&(Ay.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let a=Ft(Mt(r,o,o),n);if(Xe&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=Ft(Mt(r,o-1,o-1),-1);if(c.top==a.top){let u=Ft(Mt(r,o,o+1),-1);if(u.top!=a.top)return yr(u,u.left<c.left)}}return a}else{let a=o,c=o,u=n<0?1:-1;return n<0&&!o?(c++,u=-1):n>=0&&o==r.nodeValue.length?(a--,u=1):n<0?a--:c++,yr(Ft(Mt(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==Ye(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return Ds(a.getBoundingClientRect(),!1)}if(i==null&&o<Ye(r)){let a=r.childNodes[o];if(a.nodeType==1)return Ds(a.getBoundingClientRect(),!0)}return Ds(r.getBoundingClientRect(),n>=0)}if(i==null&&o&&(n<0||o==Ye(r))){let a=r.childNodes[o-1],c=a.nodeType==3?Mt(a,Ye(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return yr(Ft(c,1),!1)}if(i==null&&o<Ye(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Mt(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return yr(Ft(c,-1),!0)}return yr(Ft(r.nodeType==3?Mt(r):r,-n),n>=0)}function yr(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Ds(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Bh(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}function Ry(t,e,n){let r=e.selection,o=n=="up"?r.$from:r.$to;return Bh(t,e,()=>{let{node:i}=t.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=jh(t,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Mt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const Oy=/[\u0590-\u08ac]/;function Ny(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=t.domSelection();return l?!Oy.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:Bh(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),v=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return h!=null&&(l.caretBidiLevel=h),v}):r.pos==r.start()||r.pos==r.end()}let Bu=null,_u=null,Hu=!1;function Iy(t,e,n){return Bu==e&&_u==n?Hu:(Bu=e,_u=n,Hu=n=="up"||n=="down"?Ry(t,e,n):Ny(t,e,n))}const Qe=0,Fu=1,vn=2,mt=3;class io{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=Qe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let o=this.children[n];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=n>ke(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>e||s instanceof Hh){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof _h&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?ke(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?ke(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&e<=c){let u=s+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=s;for(let d=l;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){o=ke(h.dom)+1;break}e-=h.size}o==-1&&(o=0)}if(o>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=ke(d.dom);break}n+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,o=!1){let i=Math.min(e,n),s=Math.max(e,n);for(let f=0,p=0;f<this.children.length;f++){let m=this.children[f],v=p+m.size;if(i>p&&s<v)return m.setSelection(e-p-m.border,n-p-m.border,r,o);p=v}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((Xe||De)&&e==n){let{node:f,offset:p}=l;if(f.nodeType==3){if(d=!!(p&&f.nodeValue[p-1]==`
23
+ `),d&&p==f.nodeValue.length)for(let m=f,v;m;m=m.parentNode){if(v=m.nextSibling){v.nodeName=="BR"&&(l=a={node:v.parentNode,offset:ke(v)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=f.childNodes[p-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Xe&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let f=u.focusNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(o=!0)}if(!(o||d&&De)&&Rn(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Rn(a.node,a.offset,u.focusNode,u.focusOffset))return;let h=!1;if((c.extend||e==n)&&!(d&&Xe)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),h=!0}catch{}}if(!h){if(e>n){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,o=0;o<this.children.length;o++){let i=this.children[o],s=r+i.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let l=r+i.border,a=s-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?vn:Fu,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=mt:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?vn:mt}r=s}this.dirty=vn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?vn:Fu;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class _h extends io{constructor(e,n,r,o){let i,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Qe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Ly extends io{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class On extends io{constructor(e,n,r,o,i){super(e,[],r,o),this.mark=n,this.spec=i}static create(e,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=Ln.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new On(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&mt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=mt&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Qe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Qe}}slice(e,n,r){let o=On.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=Ll(i,n,s,r)),e>0&&(i=Ll(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class tn extends io{constructor(e,n,r,o,i,s,l,a,c){super(e,[],i,s),this.node=n,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,n,r,o,i,s){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Ln.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let h=u;return u=Vh(u,r,n),c?a=new Dy(e,n,r,o,u,d||null,h,c,i,s+1):n.isText?new Zi(e,n,r,o,u,h,i):new tn(e,n,r,o,u,d||null,h,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>A.empty)}return e}matchesNode(e,n,r){return this.dirty==Qe&&e.eq(this.node)&&Qo(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,o=n,i=e.composing?this.localCompositionInfo(e,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new jy(this,s&&s.node,e);Hy(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?oe.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,o)},(c,u,d,h)=>{a.syncToMarks(c.marks,r,e);let f;a.findNodeMatch(c,u,d,h)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(f=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,u,d,f,e)||a.updateNextNode(c,u,d,e,h,o)||a.addNode(c,u,d,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==vn)&&(s&&this.protectLocalComposition(e,s),Fh(this.contentDOM,this.children,e),sr&&Fy(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof z)||r<n||o>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=$y(this.node.content,s,r-n,o-n);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new Ly(this,i,n,o);e.input.compositionNodes.push(s),this.children=Ll(this.children,r,r+o.length,e,s)}update(e,n,r,o){return this.dirty==mt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,o),!0)}updateInner(e,n,r,o){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Qe}updateOuterDeco(e){if(Qo(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=$h(this.dom,this.nodeDOM,Il(this.outerDeco,this.node,n),Il(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function $u(t,e,n,r,o){Vh(r,e,t);let i=new tn(void 0,t,e,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class Zi extends tn{constructor(e,n,r,o,i,s,l){super(e,n,r,o,i,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,o){return this.dirty==mt||this.dirty!=Qe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Qe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Qe,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let o=this.node.cut(e,n),i=document.createTextNode(o.text);return new Zi(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=mt)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Hh extends io{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Qe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Dy extends tn{constructor(e,n,r,o,i,s,l,a,c,u){super(e,n,r,o,i,s,l,c,u),this.spec=a}update(e,n,r,o){if(this.dirty==mt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Fh(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==t){for(;l!=r;)r=Vu(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(l,r);if(s instanceof On){let a=r?r.previousSibling:t.lastChild;Fh(s.contentDOM,s.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Vu(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}const Ar=function(t){t&&(this.nodeName=t)};Ar.prototype=Object.create(null);const bn=[new Ar];function Il(t,e,n){if(t.length==0)return bn;let r=n?bn[0]:new Ar,o=[r];for(let i=0;i<t.length;i++){let s=t[i].type.attrs;if(s){s.nodeName&&o.push(r=new Ar(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&o.length==1&&o.push(r=new Ar(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function $h(t,e,n,r){if(n==bn&&r==bn)return e;let o=e;for(let i=0;i<r.length;i++){let s=r[i],l=n[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=t&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=bn[0]),o=a}Py(o,l||bn[0],s)}return o}function Py(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&t.classList.add(o[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)t.style.removeProperty(o[1])}n.style&&(t.style.cssText+=n.style)}}function Vh(t,e,n){return $h(t,t,bn,Il(e,n,t.nodeType!=1))}function Qo(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Vu(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class jy{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=By(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let o=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;o<s&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=Qe,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=On.create(this.top,e[i],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,o,i){let s=this.top.children[o];return s.dirty==mt&&s.dom==s.contentDOM&&(s.dirty=vn),s.update(e,n,r,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=n}}updateNextNode(e,n,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof tn){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,h=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=mt&&Qo(n,a.outerDeco));if(!h&&a.update(e,n,r,o))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!h&&(d=this.recreateWrapper(a,e,n,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=vn,d.updateChildren(o,s+1),d.dirty=Qe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,o,i,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Qo(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=tn.create(this.top,n,r,o,i,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,o,i){let s=tn.create(this.top,e,n,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new _h(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof On;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Zi)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((De||Re)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new Hh(this.top,[],r,null);n!=this.top?n.children.push(o):n.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function By(t,e){let n=e,r=n.children.length,o=t.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof On)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function _y(t,e){return t.type.side-e.type.side}function Hy(t,e,n,r){let o=e.locals(t),i=0;if(o.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,o,e.forChild(i,u),c),i+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d;for(;s<o.length&&o[s].to==i;){let v=o[s++];v.widget&&(u?(d||(d=[u])).push(v):u=v)}if(u)if(d){d.sort(_y);for(let v=0;v<d.length;v++)n(d[v],c,!!a)}else n(u,c,!!a);let h,f;if(a)f=-1,h=a,a=null;else if(c<t.childCount)f=c,h=t.child(c++);else break;for(let v=0;v<l.length;v++)l[v].to<=i&&l.splice(v--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let p=i+h.nodeSize;if(h.isText){let v=p;s<o.length&&o[s].from<v&&(v=o[s].from);for(let b=0;b<l.length;b++)l[b].to<v&&(v=l[b].to);v<p&&(a=h.cut(v-i),h=h.cut(0,v-i),p=v,f=-1)}else for(;s<o.length&&o[s].to<p;)s++;let m=h.isInline&&!h.isLeaf?l.filter(v=>!v.inline):l.slice();r(h,m,e.forChild(i,h),f),i=p}}function Fy(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function $y(t,e,n,r){for(let o=0,i=0;o<t.childCount&&i<=r;){let s=t.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<t.childCount;){let c=t.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Ll(t,e,n,r,o){let i=[];for(let s=0,l=0;s<t.length;s++){let a=t[s],c=l,u=l+=a.size;c>=n||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),o&&(i.push(o),o=void 0),u>n&&i.push(a.slice(n-c,a.size,r)))}return i}function Oa(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),i=o&&o.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Ji(n)){for(a=s;o&&!o.node;)o=o.parent;let d=o.node;if(o&&d.isAtom&&B.isSelectable(d)&&o.parent&&!(d.isInline&&hy(n.focusNode,n.focusOffset,o.dom))){let h=o.posBefore;c=new B(s==h?l:r.resolve(h))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=s,h=s;for(let f=0;f<n.rangeCount;f++){let p=n.getRangeAt(f);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),h=Math.max(h,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,s]=h==t.state.selection.anchor?[h,d]:[d,h],l=r.resolve(s)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;c=Na(t,u,l,d)}return c}function zh(t){return t.editable?t.hasFocus():Wh(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ot(t,e=!1){let n=t.state.selection;if(Uh(t,n),!!zh(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Re){let r=t.domSelectionRange(),o=t.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Rn(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)zy(t);else{let{anchor:r,head:o}=n,i,s;zu&&!(n instanceof z)&&(n.$from.parent.inlineContent||(i=Uu(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=Uu(t,n.to))),t.docView.setSelection(r,o,t,e),zu&&(i&&Wu(i),s&&Wu(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Vy(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const zu=De||Re&&Nh<63;function Uu(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(De&&o&&o.contentEditable=="false")return Ps(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return Ps(o);if(i)return Ps(i)}}function Ps(t){return t.contentEditable="true",De&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Wu(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Vy(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!zh(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function zy(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ke(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&He&&en<=11&&(n.disabled=!0,n.disabled=!1)}function Uh(t,e){if(e instanceof B){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Ku(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Ku(t)}function Ku(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Na(t,e,n,r){return t.someProp("createSelectionBetween",o=>o(t,e,n))||z.between(e,n,r)}function qu(t){return t.editable&&!t.hasFocus()?!1:Wh(t)}function Wh(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Uy(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Rn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Dl(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return i&&q.findFrom(i,e)}function Vt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Gu(t,e,n){let r=t.state.selection;if(r instanceof z)if(n.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return Vt(t,new z(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let o=Dl(t.state,e);return o&&o instanceof B?Vt(t,o):!1}else if(!(Ze&&n.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?B.isSelectable(i)?Vt(t,new B(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):oo?Vt(t,new z(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof B&&r.node.isInline)return Vt(t,new z(e>0?r.$to:r.$from));{let o=Dl(t.state,e);return o?Vt(t,o):!1}}}function ei(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Rr(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Vn(t,e){return e<0?Wy(t):Ky(t)}function Wy(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(Xe&&n.nodeType==1&&r<ei(n)&&Rr(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Rr(l,-1))o=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Kh(n))break;{let l=n.previousSibling;for(;l&&Rr(l,-1);)o=n.parentNode,i=ke(l),l=l.previousSibling;if(l)n=l,r=ei(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Pl(t,n,r):o&&Pl(t,o,i)}function Ky(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=ei(n),i,s;for(;;)if(r<o){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Rr(l,1))i=n,s=++r;else break}else{if(Kh(n))break;{let l=n.nextSibling;for(;l&&Rr(l,1);)i=l.parentNode,s=ke(l)+1,l=l.nextSibling;if(l)n=l,r=0,o=ei(n);else{if(n=n.parentNode,n==t.dom)break;r=o=0}}}i&&Pl(t,i,s)}function Kh(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function qy(t,e){for(;t&&e==t.childNodes.length&&!ro(t);)e=ke(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function Gy(t,e){for(;t&&!e&&!ro(t);)e=ke(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Pl(t,e,n){if(e.nodeType!=3){let i,s;(s=qy(e,n))?(e=s,n=0):(i=Gy(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Ji(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:o}=t;setTimeout(()=>{t.state==o&&Ot(t)},50)}function Ju(t,e){let n=t.state.doc.resolve(e);if(!(Re||gy)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Zu(t,e,n){let r=t.state.selection;if(r instanceof z&&!r.empty||n.indexOf("s")>-1||Ze&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Dl(t.state,e);if(s&&s instanceof B)return Vt(t,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof ze?q.near(s,e):q.findFrom(s,e);return l?Vt(t,l):!1}return!1}function Yu(t,e){if(!(t.state.selection instanceof z))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let s=t.state.tr;return e<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),t.dispatch(s),!0}return!1}function Xu(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Jy(t){if(!De||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Xu(t,r,"true"),setTimeout(()=>Xu(t,r,"false"),20)}return!1}function Zy(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Yy(t,e){let n=e.keyCode,r=Zy(e);if(n==8||Ze&&n==72&&r=="c")return Yu(t,-1)||Vn(t,-1);if(n==46&&!e.shiftKey||Ze&&n==68&&r=="c")return Yu(t,1)||Vn(t,1);if(n==13||n==27)return!0;if(n==37||Ze&&n==66&&r=="c"){let o=n==37?Ju(t,t.state.selection.from)=="ltr"?-1:1:-1;return Gu(t,o,r)||Vn(t,o)}else if(n==39||Ze&&n==70&&r=="c"){let o=n==39?Ju(t,t.state.selection.from)=="ltr"?1:-1:1;return Gu(t,o,r)||Vn(t,o)}else{if(n==38||Ze&&n==80&&r=="c")return Zu(t,-1,r)||Vn(t,-1);if(n==40||Ze&&n==78&&r=="c")return Jy(t)||Zu(t,1,r)||Vn(t,1);if(r==(Ze?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Ia(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let s=t.someProp("clipboardSerializer")||Ln.fromSchema(t.state.schema),l=Xh(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=Yh[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let p=l.createElement(u[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,`
24
+
25
+ `);return{dom:a,text:h,slice:e}}function qh(t,e,n,r,o){let i=o.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",h=>{e=h(e,i||r,t)}),i)return l=new j(A.from(t.state.schema.text(e.replace(/\r\n?/g,`
26
+ `))),0,0),t.someProp("transformPasted",h=>{l=h(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",h=>h(e,o,r,t));if(d)l=d;else{let h=o.marks(),{schema:f}=t.state,p=Ln.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let v=s.appendChild(document.createElement("p"));m&&v.appendChild(p.serializeNode(f.text(m,h)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),s=tv(n),oo&&nv(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let h=s.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;s=h}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Qt.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!Xy.test(h.parentNode.nodeName)?{ignore:!0}:null}})),u)l=rv(Qu(l,+u[1],+u[2]),u[4]);else if(l=j.maxOpen(Qy(l.content,o),!0),l.openStart||l.openEnd){let d=0,h=0;for(let f=l.content.firstChild;d<l.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=l.content.lastChild;h<l.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);l=Qu(l,d,h)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}const Xy=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Qy(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.index(n)),i,s=[];if(t.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&Jh(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Zh(s[s.length-1],i.length));let u=Gh(l,a);s.push(u),o=o.matchType(u.type),i=a}}),s)return A.from(s)}return t}function Gh(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,A.from(t));return t}function Jh(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o]==e[o]){let i=Jh(t,e,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==t.length-1?n.type:t[o+1]))return r.copy(r.content.append(A.from(Gh(n,t,o+1))))}}function Zh(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Zh(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(A.empty,!0);return t.copy(n.append(r))}function jl(t,e,n,r,o,i){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(i=0),o<r-1&&(l=jl(l,e,n,r,o+1,i)),o>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(A.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function Qu(t,e,n){return e<t.openStart&&(t=new j(jl(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new j(jl(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Yh={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ed=null;function Xh(){return ed||(ed=document.implementation.createHTMLDocument("title"))}let js=null;function ev(t){let e=window.trustedTypes;return e?(js||(js=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),js.createHTML(t)):t}function tv(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Xh().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),o;if((o=r&&Yh[r[1].toLowerCase()])&&(t=o.map(i=>"<"+i+">").join("")+t+o.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=ev(t),o)for(let i=0;i<o.length;i++)n=n.querySelector(o[i])||n;return n}function nv(t){let e=t.querySelectorAll(Re?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function rv(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:o,openStart:i,openEnd:s}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=A.from(a.create(r[l+1],o)),i++,s++}return new j(o,i,s)}const Pe={},je={},ov={touchstart:!0,touchmove:!0};class iv{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function sv(t){for(let e in Pe){let n=Pe[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{av(t,r)&&!La(t,r)&&(t.editable||!(r.type in je))&&n(t,r)},ov[e]?{passive:!0}:void 0)}De&&t.dom.addEventListener("input",()=>null),Bl(t)}function Yt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function lv(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Bl(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>La(t,r))})}function La(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function av(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function cv(t,e){!La(t,e)&&Pe[e.type]&&(t.editable||!(e.type in je))&&Pe[e.type](t,e)}je.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!ep(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Tt&&Re&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),sr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",o=>o(t,gn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Yy(t,n)?n.preventDefault():Yt(t,"key")};je.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};je.keypress=(t,e)=>{let n=e;if(ep(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ze&&n.metaKey)return;if(t.someProp("handleKeyPress",o=>o(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof z)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,o,i))&&t.dispatch(i()),n.preventDefault()}};function Yi(t){return{left:t.clientX,top:t.clientY}}function uv(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Da(t,e,n,r,o){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(t.someProp(e,l=>s>i.depth?l(t,n,i.nodeAfter,i.before(s),o,!0):l(t,n,i.node(s),i.before(s),o,!1)))return!0;return!1}function Qn(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function dv(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&B.isSelectable(r)?(Qn(t,new B(n)),!0):!1}function fv(t,e){if(e==-1)return!1;let n=t.state.selection,r,o;n instanceof B&&(r=n.node);let i=t.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(B.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?o=i.before(n.$from.depth):o=i.before(s);break}}return o!=null?(Qn(t,B.create(t.state.doc,o)),!0):!1}function hv(t,e,n,r,o){return Da(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(o?fv(t,n):dv(t,n))}function pv(t,e,n,r){return Da(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",o=>o(t,e,r))}function mv(t,e,n,r){return Da(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",o=>o(t,e,r))||gv(t,n,r)}function gv(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Qn(t,z.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)Qn(t,z.create(r,l+1,l+1+s.content.size));else if(B.isSelectable(s))Qn(t,B.create(r,l));else continue;return!0}}function Pa(t){return ti(t)}const Qh=Ze?"metaKey":"ctrlKey";Pe.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Pa(t),o=Date.now(),i="singleClick";o-t.input.lastClick.time<500&&uv(n,t.input.lastClick)&&!n[Qh]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button};let s=t.posAtCoords(Yi(n));s&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new yv(t,s,n,!!r)):(i=="doubleClick"?pv:mv)(t,s.pos,s.inside,n)?n.preventDefault():Yt(t,"pointer"))};class yv{constructor(e,n,r,o){this.view=e,this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Qh],this.allowDefault=r.shiftKey;let i,s;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,s=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof B&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Xe&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Yt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Ot(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Yi(e))),this.updateAllowDefault(e),this.allowDefault||!n?Yt(this.view,"pointer"):hv(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||De&&this.mightDrag&&!this.mightDrag.node.isAtom||Re&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Qn(this.view,q.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Yt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Yt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Pe.touchstart=t=>{t.input.lastTouch=Date.now(),Pa(t),Yt(t,"pointer")};Pe.touchmove=t=>{t.input.lastTouch=Date.now(),Yt(t,"pointer")};Pe.contextmenu=t=>Pa(t);function ep(t,e){return t.composing?!0:De&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const vv=Tt?5e3:-1;je.compositionstart=je.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof z&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),ti(t,!0),t.markCursor=null;else if(ti(t,!e.selection.empty),Xe&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&o.nodeType==1&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(s.nodeType==3){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}t.input.composing=!0}tp(t,vv)};je.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,tp(t,20))};function tp(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>ti(t),e))}function np(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Cv());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function bv(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=dy(e.focusNode,e.focusOffset),r=fy(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let o=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function Cv(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function ti(t,e=!1){if(!(Tt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),np(t),e||t.docView&&t.docView.dirty){let n=Oa(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function xv(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const $r=He&&en<15||sr&&yy<604;Pe.copy=je.cut=(t,e)=>{let n=e,r=t.state.selection,o=n.type=="cut";if(r.empty)return;let i=$r?null:n.clipboardData,s=r.content(),{dom:l,text:a}=Ia(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):xv(t,l),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function wv(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Sv(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Vr(t,r.value,null,o,e):Vr(t,r.textContent,r.innerHTML,o,e)},50)}function Vr(t,e,n,r,o){let i=qh(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,o,i||j.empty)))return!0;if(!i)return!1;let s=wv(i),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function rp(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}je.paste=(t,e)=>{let n=e;if(t.composing&&!Tt)return;let r=$r?null:n.clipboardData,o=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Vr(t,rp(r),r.getData("text/html"),o,n)?n.preventDefault():Sv(t,n)};class op{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const kv=Ze?"altKey":"ctrlKey";function ip(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[kv]}Pe.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=t.state.selection,i=o.empty?null:t.posAtCoords(Yi(n)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof B?o.to-1:o.to))){if(r&&r.mightDrag)s=B.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(s=B.create(t.state.doc,d.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:u}=Ia(t,l);(!n.dataTransfer.files.length||!Re||Nh>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData($r?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",$r||n.dataTransfer.setData("text/plain",c),t.dragging=new op(u,ip(t,n),s)};Pe.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};je.dragover=je.dragenter=(t,e)=>e.preventDefault();je.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let o=t.posAtCoords(Yi(n));if(!o)return;let i=t.state.doc.resolve(o.pos),s=r&&r.slice;s?t.someProp("transformPasted",p=>{s=p(s,t,!1)}):s=qh(t,rp(n.dataTransfer),$r?null:n.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&ip(t,n));if(t.someProp("handleDrop",p=>p(t,n,s||j.empty,l))){n.preventDefault();return}if(!s)return;n.preventDefault();let a=s?uh(t.state.doc,i.pos,s):i.pos;a==null&&(a=i.pos);let c=t.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,h=c.doc;if(d?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(h))return;let f=c.doc.resolve(u);if(d&&B.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new B(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,v,b,C)=>p=C),c.setSelection(Na(t,f,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};Pe.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Ot(t)},20))};Pe.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Pe.beforeinput=(t,e)=>{if(Re&&Tt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,gn(8,"Backspace")))))return;let{$cursor:o}=t.state.selection;o&&o.pos>0&&t.dispatch(t.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let t in je)Pe[t]=je[t];function zr(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class ni{constructor(e,n){this.toDOM=e,this.spec=n||kn,this.side=this.spec.side||0}map(e,n,r,o){let{pos:i,deleted:s}=e.mapResult(n.from+o,this.side<0?-1:1);return s?null:new Le(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ni&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&zr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class nn{constructor(e,n){this.attrs=e,this.spec=n||kn}map(e,n,r,o){let i=e.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new Le(i,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof nn&&zr(this.attrs,e.attrs)&&zr(this.spec,e.spec)}static is(e){return e.type instanceof nn}destroy(){}}class ja{constructor(e,n){this.attrs=e,this.spec=n||kn}map(e,n,r,o){let i=e.mapResult(n.from+o,1);if(i.deleted)return null;let s=e.mapResult(n.to+o,-1);return s.deleted||s.pos<=i.pos?null:new Le(i.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:o}=e.content.findIndex(n.from),i;return o==n.from&&!(i=e.child(r)).isText&&o+i.nodeSize==n.to}eq(e){return this==e||e instanceof ja&&zr(this.attrs,e.attrs)&&zr(this.spec,e.spec)}destroy(){}}class Le{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Le(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Le(e,e,new ni(n,r))}static inline(e,n,r,o){return new Le(e,n,new nn(r,o))}static node(e,n,r,o){return new Le(e,n,new ja(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof nn}get widget(){return this.type instanceof ni}}const qn=[],kn={};class ue{constructor(e,n){this.local=e.length?e:qn,this.children=n.length?n:qn}static create(e,n){return n.length?ri(n,e,0,kn):Ae}find(e,n,r){let o=[];return this.findInner(e??0,n??1e9,o,0,r),o}findInner(e,n,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,o+l,i)}}map(e,n,r){return this==Ae||e.maps.length==0?this:this.mapInner(e,n,0,0,r||kn)}mapInner(e,n,r,o,i){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(n,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?Ev(this.children,s||[],e,n,r,o,i):s?new ue(s.sort(En),qn):Ae}add(e,n){return n.length?this==Ae?ue.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let o,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=lp(n,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,u,c+1):o.splice(i,0,a,a+l.nodeSize,ri(u,l,c+1,kn)),i+=3}});let s=sp(i?ap(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new ue(s.length?this.local.concat(s).sort(En):this.local,o||this.children)}remove(e){return e.length==0||this==Ae?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+n,a=r[i+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=Ae?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<o.length;l++)o[l].eq(s,n)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new ue(o,r):Ae}forChild(e,n){if(this==Ae)return this;if(n.isLeaf)return ue.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,s=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>i&&a.type instanceof nn){let c=Math.max(i,a.from)-i,u=Math.min(s,a.to)-i;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new ue(o.sort(En),qn);return r?new Wt([l,r]):l}return r||Ae}eq(e){if(this==e)return!0;if(!(e instanceof ue)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Ba(this.localsInner(e))}localsInner(e){if(this==Ae)return qn;if(e.inlineContent||!this.local.some(nn.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof nn||n.push(this.local[r]);return n}forEachSet(e){e(this)}}ue.empty=new ue([],[]);ue.removeOverlap=Ba;const Ae=ue.empty;class Wt{constructor(e){this.members=e}map(e,n){const r=this.members.map(o=>o.map(e,n,kn));return Wt.from(r)}forChild(e,n){if(n.isLeaf)return ue.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,n);i!=Ae&&(i instanceof Wt?r=r.concat(i.members):r.push(i))}return Wt.from(r)}eq(e){if(!(e instanceof Wt)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let s=0;s<i.length;s++)n.push(i[s])}}return n?Ba(r?n:n.sort(En)):qn}static from(e){switch(e.length){case 0:return Ae;case 1:return e[0];default:return new Wt(e.every(n=>n instanceof ue)?e:e.reduce((n,r)=>n.concat(r instanceof ue?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Ev(t,e,n,r,o,i,s){let l=t.slice();for(let c=0,u=i;c<n.maps.length;c++){let d=0;n.maps[c].forEach((h,f,p,m)=>{let v=m-p-(f-h);for(let b=0;b<l.length;b+=3){let C=l[b+1];if(C<0||h>C+u-d)continue;let x=l[b]+u-d;f>=x?l[b+1]=h<=x?-2:-1:h>=u&&v&&(l[b]+=v,l[b+1]+=v)}d+=v}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+i),d=u-o;if(d<0||d>=r.content.size){a=!0;continue}let h=n.map(t[c+1]+i,-1),f=h-o,{index:p,offset:m}=r.content.findIndex(d),v=r.maybeChild(p);if(v&&m==d&&m+v.nodeSize==f){let b=l[c+2].mapInner(n,v,u+1,t[c]+i+1,s);b!=Ae?(l[c]=d,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Mv(l,t,e,n,o,i,s),u=ri(c,r,0,s);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,h=0;d<u.children.length;d+=3){let f=u.children[d];for(;h<l.length&&l[h]<f;)h+=3;l.splice(h,0,u.children[d],u.children[d+1],u.children[d+2])}}return new ue(e.sort(En),l)}function sp(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let o=t[r];n.push(new Le(o.from+e,o.to+e,o.type))}return n}function Mv(t,e,n,r,o,i,s){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,o,c);d?n.push(d):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function lp(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,o=null;for(let i=0,s;i<t.length;i++)(s=t[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),t[i]=null);return o}function ap(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function ri(t,e,n,r){let o=[],i=!1;e.forEach((l,a)=>{let c=lp(t,l,a+n);if(c){i=!0;let u=ri(c,l,n+a+1,r);u!=Ae&&o.push(a,a+l.nodeSize,u)}});let s=sp(i?ap(t):t,-n).sort(En);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||o.length?new ue(s,o):Ae}function En(t,e){return t.from-e.from||t.to-e.to}function Ba(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let o=n+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),td(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),td(e,o,r.copy(i.from,r.to)));break}}}return e}function td(t,e,n){for(;e<t.length&&En(n,t[e])>0;)e++;t.splice(e,0,n)}function Bs(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Ae&&e.push(r)}),t.cursorWrapper&&e.push(ue.create(t.state.doc,[t.cursorWrapper.deco])),Wt.from(e)}const Tv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Av=He&&en<=11;class Rv{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Ov{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Rv,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);He&&en<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),Av&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Tv)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(qu(this.view)){if(this.suppressingSelectionUpdates)return Ot(this.view);if(He&&en<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Rn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=ir(i))n.add(i);for(let i=e.anchorNode;i;i=ir(i))if(n.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&qu(e)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(l=!0))}if(Xe&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,h]=u;d.parentNode&&d.parentNode.parentNode==h.parentNode?h.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let h of u){let f=h.parentNode;f&&f.nodeName=="LI"&&(!d||Lv(e,d)!=f)&&h.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ji(r)&&(c=Oa(e))&&c.eq(q.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ot(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,s),Nv(e)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ot(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,i=e.nextSibling;if(He&&en<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:h}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(o=d),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h)}let s=o&&o.parentNode==e.target?ke(o)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=i&&i.parentNode==e.target?ke(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let nd=new WeakMap,rd=!1;function Nv(t){if(!nd.has(t)&&(nd.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Xe,rd)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),rd=!0}}function od(t,e){let n=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Rn(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function Iv(t,e){if(e.getComposedRanges){let o=e.getComposedRanges(t.root)[0];if(o)return od(t,o)}let n;function r(o){o.preventDefault(),o.stopImmediatePropagation(),n=o.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?od(t,n):null}function Lv(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Dv(t,e,n){let{node:r,fromOffset:o,toOffset:i,from:s,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,u=a.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],Ji(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Re&&t.input.lastKeyCode===8)for(let v=i;v>o;v--){let b=r.childNodes[v-1],C=b.pmViewDesc;if(b.nodeName=="BR"&&!C){i=v;break}if(!C||C.size)break}let d=t.state.doc,h=t.someProp("domParser")||Qt.fromSchema(t.state.schema),f=d.resolve(s),p=null,m=h.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:o,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Pv,context:f});if(c&&c[0].pos!=null){let v=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=v),p={anchor:v+s,head:b+s}}return{doc:m,sel:p,from:s,to:l}}function Pv(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(De&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||De&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const jv=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Bv(t,e,n,r,o){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let k=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,M=Oa(t,k);if(M&&!t.state.selection.eq(M)){if(Re&&Tt&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",P=>P(t,gn(13,"Enter"))))return;let I=t.state.tr.setSelection(M);k=="pointer"?I.setMeta("pointer",!0):k=="key"&&I.scrollIntoView(),i&&I.setMeta("composition",i),t.dispatch(I)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=Dv(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),h,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,f="end"):(h=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let p=Fv(d.content,c.doc.content,c.from,h,f);if(p&&t.input.domChangeCount++,(sr&&t.input.lastIOSEnter>Date.now()-225||Tt)&&o.some(k=>k.nodeType==1&&!jv.test(k.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",k=>k(t,gn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof z&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let k=id(t,t.state.doc,c.sel);if(k&&!k.eq(t.state.selection)){let M=t.state.tr.setSelection(k);i&&M.setMeta("composition",i),t.dispatch(M)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof z&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),He&&en<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),v=c.doc.resolveNoCache(p.endB-c.from),b=u.resolve(p.start),C=m.sameParent(v)&&m.parent.inlineContent&&b.end()>=p.endA;if((sr&&t.input.lastIOSEnter>Date.now()-225&&(!C||o.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!C&&m.pos<c.doc.content.size&&(!m.sameParent(v)||!m.parent.inlineContent)&&m.pos<v.pos&&!/\S/.test(c.doc.textBetween(m.pos,v.pos,"","")))&&t.someProp("handleKeyDown",k=>k(t,gn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&Hv(u,p.start,p.endA,m,v)&&t.someProp("handleKeyDown",k=>k(t,gn(8,"Backspace")))){Tt&&Re&&t.domObserver.suppressSelectionUpdates();return}Re&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Tt&&!C&&m.start()!=v.start()&&v.parentOffset==0&&m.depth==v.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,v=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(k){return k(t,gn(13,"Enter"))})},20));let x=p.start,w=p.endA,E=k=>{let M=k||t.state.tr.replace(x,w,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let I=id(t,M.doc,c.sel);I&&!(Re&&t.composing&&I.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(I.head==x||I.head==M.mapping.map(w)-1)||He&&I.empty&&I.head==x)&&M.setSelection(I)}return i&&M.setMeta("composition",i),M.scrollIntoView()},S;if(C)if(m.pos==v.pos){He&&en<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ot(t),20));let k=E(t.state.tr.delete(x,w)),M=u.resolve(p.start).marksAcross(u.resolve(p.endA));M&&k.ensureMarks(M),t.dispatch(k)}else if(p.endA==p.endB&&(S=_v(m.parent.content.cut(m.parentOffset,v.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let k=E(t.state.tr);S.type=="add"?k.addMark(x,w,S.mark):k.removeMark(x,w,S.mark),t.dispatch(k)}else if(m.parent.child(m.index()).isText&&m.index()==v.index()-(v.textOffset?0:1)){let k=m.parent.textBetween(m.parentOffset,v.parentOffset),M=()=>E(t.state.tr.insertText(k,x,w));t.someProp("handleTextInput",I=>I(t,x,w,k,M))||t.dispatch(M())}else t.dispatch(E());else t.dispatch(E())}function id(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Na(t,e.resolve(n.anchor),e.resolve(n.head))}function _v(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,o=n,i=r,s,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(A.from(c).eq(t))return{mark:l,type:s}}function Hv(t,e,n,r,o){if(n-e<=o.pos-r.pos||_s(r,!0,!1)<o.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=t.resolve(_s(i,!0,!0));return!s.parent.isTextblock||s.pos>n||_s(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function _s(t,e,n){let r=t.depth,o=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function Fv(t,e,n,r,o){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:s,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(o=="end"){let a=Math.max(0,i-Math.min(s,l));r-=s+a-i}if(s<i&&t.size<e.size){let a=r<=i&&r>=s?i-r:0;i-=a,i&&i<e.size&&sd(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-s),s=i}else if(l<i){let a=r<=i&&r>=l?i-r:0;i-=a,i&&i<t.size&&sd(t.textBetween(i-1,i+1))&&(i+=a?1:-1),s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}function sd(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class cp{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new iv,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(dd),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=cd(this),ad(this),this.nodeViews=ud(this),this.docView=$u(this.state.doc,ld(this),Bs(this),this.dom,this),this.domObserver=new Ov(this,(r,o,i,s)=>Bv(this,r,o,i,s)),this.domObserver.start(),sv(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Bl(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(dd),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(np(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=ud(this);Vv(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Bl(this),this.editable=cd(this),ad(this);let a=Bs(this),c=ld(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(o.selection))&&(s=!0);let h=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Cy(this);if(s){this.domObserver.stop();let f=d&&(He||Re)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&$v(o.selection,e.selection);if(d){let p=Re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=bv(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=$u(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Uy(this))?Ot(this,f):(Uh(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():h&&xy(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof B){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Pu(this,n.getBoundingClientRect(),e)}else Pu(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,o=-1;if(this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new op(e.slice,e.move,o<0?void 0:B.create(this.state.doc,o))}someProp(e,n){let r=this._props&&this._props[e],o;if(r!=null&&(o=n?n(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=n?n(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(o=n?n(l):l))return o}}hasFocus(){if(He){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&wy(this.dom),Ot(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Ty(this,e)}coordsAtPos(e,n=1){return jh(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let o=this.docView.posFromDOM(e,n,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,n){return Iy(this,n||this.state,e)}pasteHTML(e,n){return Vr(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Vr(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ia(this,e)}destroy(){this.docView&&(lv(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Bs(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,cy())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return cv(this,e)}domSelectionRange(){let e=this.domSelection();return e?De&&this.root.nodeType===11&&py(this.dom.ownerDocument)==this.dom&&Iv(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}cp.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function ld(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Le.node(0,t.state.doc.content.size,e)]}function ad(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Le.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function cd(t){return!t.someProp("editable",e=>e(t.state)===!1)}function $v(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function ud(t){let e=Object.create(null);function n(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function Vv(t,e){let n=0,r=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let o in e)r++;return n!=r}function dd(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var sn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},oi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},zv=typeof navigator<"u"&&/Mac/.test(navigator.platform),Uv=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ee=0;Ee<10;Ee++)sn[48+Ee]=sn[96+Ee]=String(Ee);for(var Ee=1;Ee<=24;Ee++)sn[Ee+111]="F"+Ee;for(var Ee=65;Ee<=90;Ee++)sn[Ee]=String.fromCharCode(Ee+32),oi[Ee]=String.fromCharCode(Ee);for(var Hs in sn)oi.hasOwnProperty(Hs)||(oi[Hs]=sn[Hs]);function Wv(t){var e=zv&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Uv&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?oi:sn)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const Kv=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),qv=typeof navigator<"u"&&/Win/.test(navigator.platform);function Gv(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,o,i,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Kv?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),o&&(n="Ctrl-"+n),s&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function Jv(t){let e=Object.create(null);for(let n in t)e[Gv(n)]=t[n];return e}function Fs(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function Zv(t){return new ae({props:{handleKeyDown:up(t)}})}function up(t){let e=Jv(t);return function(n,r){let o=Wv(r),i,s=e[Fs(o,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[Fs(o,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(qv&&r.ctrlKey&&r.altKey)&&(i=sn[r.keyCode])&&i!=o){let l=e[Fs(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Yv=Object.defineProperty,_a=(t,e)=>{for(var n in e)Yv(t,n,{get:e[n],enumerable:!0})};function Xi(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:o}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}var Qi=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:o}=n,i=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(([s,l])=>[s,(...c)=>{const u=l(...c)(i);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(o),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s=[],l=!!t,a=t||o.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),s.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(n).map(([d,h])=>[d,(...p)=>{const m=this.buildProps(a,e),v=h(...p)(m);return s.push(v),u}])),run:c};return u}createCan(t){const{rawCommands:e,state:n}=this,r=!1,o=t||n.tr,i=this.buildProps(o,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(o,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s={tr:t,editor:r,view:i,state:Xi({state:o,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(s)]))}};return s}},dp={};_a(dp,{blur:()=>Xv,clearContent:()=>Qv,clearNodes:()=>eb,command:()=>tb,createParagraphNear:()=>nb,cut:()=>rb,deleteCurrentNode:()=>ob,deleteNode:()=>ib,deleteRange:()=>sb,deleteSelection:()=>lb,enter:()=>ab,exitCode:()=>cb,extendMarkRange:()=>ub,first:()=>db,focus:()=>hb,forEach:()=>pb,insertContent:()=>mb,insertContentAt:()=>vb,joinBackward:()=>xb,joinDown:()=>Cb,joinForward:()=>wb,joinItemBackward:()=>Sb,joinItemForward:()=>kb,joinTextblockBackward:()=>Eb,joinTextblockForward:()=>Mb,joinUp:()=>bb,keyboardShortcut:()=>Ab,lift:()=>Rb,liftEmptyBlock:()=>Ob,liftListItem:()=>Nb,newlineInCode:()=>Ib,resetAttributes:()=>Lb,scrollIntoView:()=>Db,selectAll:()=>Pb,selectNodeBackward:()=>jb,selectNodeForward:()=>Bb,selectParentNode:()=>_b,selectTextblockEnd:()=>Hb,selectTextblockStart:()=>Fb,setContent:()=>$b,setMark:()=>aC,setMeta:()=>cC,setNode:()=>uC,setNodeSelection:()=>dC,setTextDirection:()=>fC,setTextSelection:()=>hC,sinkListItem:()=>pC,splitBlock:()=>mC,splitListItem:()=>gC,toggleList:()=>yC,toggleMark:()=>vC,toggleNode:()=>bC,toggleWrap:()=>CC,undoInputRule:()=>xC,unsetAllMarks:()=>wC,unsetMark:()=>SC,unsetTextDirection:()=>kC,updateAttributes:()=>EC,wrapIn:()=>MC,wrapInList:()=>TC});var Xv=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),Qv=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),eb=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:o}=r;return n&&o.forEach(({$from:i,$to:s})=>{t.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),h=c.resolve(u.map(a+l.nodeSize)),f=d.blockRange(h);if(!f)return;const p=dr(f);if(l.type.isTextblock){const{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(f.start,m)}(p||p===0)&&e.lift(f,p)})}),!0},tb=t=>e=>t(e),nb=()=>({state:t,dispatch:e})=>Mh(t,e),rb=(t,e)=>({editor:n,tr:r})=>{const{state:o}=n,i=o.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new z(r.doc.resolve(Math.max(s-1,0)))),!0},ob=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const o=t.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(e){const l=o.before(i),a=o.after(i);t.delete(l,a).scrollIntoView()}return!0}return!1};function me(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var ib=t=>({tr:e,state:n,dispatch:r})=>{const o=me(t,n.schema),i=e.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){const a=i.before(s),c=i.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},sb=t=>({tr:e,dispatch:n})=>{const{from:r,to:o}=t;return n&&e.delete(r,o),!0},lb=()=>({state:t,dispatch:e})=>ka(t,e),ab=()=>({commands:t})=>t.keyboardShortcut("Enter"),cb=()=>({state:t,dispatch:e})=>G2(t,e);function Ha(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function ii(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(o=>n.strict?e[o]===t[o]:Ha(e[o])?e[o].test(t[o]):e[o]===t[o]):!0}function fp(t,e,n={}){return t.find(r=>r.type===e&&ii(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function fd(t,e,n={}){return!!fp(t,e,n)}function Fa(t,e,n){var r;if(!t||!e)return;let o=t.parent.childAfter(t.parentOffset);if((!o.node||!o.node.marks.some(u=>u.type===e))&&(o=t.parent.childBefore(t.parentOffset)),!o.node||!o.node.marks.some(u=>u.type===e)||(n=n||((r=o.node.marks[0])==null?void 0:r.attrs),!fp([...o.node.marks],e,n)))return;let s=o.index,l=t.start()+o.offset,a=s+1,c=l+o.node.nodeSize;for(;s>0&&fd([...t.parent.child(s-1).marks],e,n);)s-=1,l-=t.parent.child(s).nodeSize;for(;a<t.parent.childCount&&fd([...t.parent.child(a).marks],e,n);)c+=t.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function jt(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var ub=(t,e={})=>({tr:n,state:r,dispatch:o})=>{const i=jt(t,r.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:u}=l;if(o){const d=Fa(a,i,e);if(d&&d.from<=c&&d.to>=u){const h=z.create(s,d.from,d.to);n.setSelection(h)}}return!0},db=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function hp(t){return t instanceof z}function Cn(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function pp(t,e=null){if(!e)return null;const n=q.atStart(t),r=q.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const o=n.from,i=r.to;return e==="all"?z.create(t,Cn(0,o,i),Cn(t.content.size,o,i)):z.create(t,Cn(e,o,i),Cn(e,o,i))}function _l(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Ur(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function fb(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var hb=(t=null,e={})=>({editor:n,view:r,tr:o,dispatch:i})=>{e={scrollIntoView:!0,...e};const s=()=>{(Ur()||_l())&&r.dom.focus(),fb()&&!Ur()&&!_l()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!hp(n.state.selection))return s(),!0;const l=pp(o.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},pb=(t,e)=>n=>t.every((r,o)=>e(r,{...n,index:o})),mb=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),mp=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&mp(r)}return t};function Co(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return mp(n)}function Wr(t,e,n){if(t instanceof Xt||t instanceof A)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,o=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return A.fromArray(t.map(l=>e.nodeFromJSON(l)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),Wr("",e,n)}if(o){if(n.errorOnInvalidContent){let s=!1,l="";const a=new Qf({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=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Qt.fromSchema(a).parseSlice(Co(t),n.parseOptions):Qt.fromSchema(a).parse(Co(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=Qt.fromSchema(e);return n.slice?i.parseSlice(Co(t),n.parseOptions).content:i.parse(Co(t),n.parseOptions)}return Wr("",e,n)}function gb(t,e,n){const r=t.steps.length-1;if(r<e)return;const o=t.steps[r];if(!(o instanceof ve||o instanceof be))return;const i=t.mapping.maps[r];let s=0;i.forEach((l,a,c,u)=>{s===0&&(s=u)}),t.setSelection(q.near(t.doc.resolve(s),n))}var yb=t=>!("type"in t),vb=(t,e,n)=>({tr:r,dispatch:o,editor:i})=>{var s;if(o){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=v=>{i.emit("contentError",{editor:i,error:v,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Wr(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(v){a(v)}try{l=Wr(e,i.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:i.options.enableContentCheck})}catch(v){return a(v),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,f=!0;if((yb(l)?l:[l]).forEach(v=>{v.check(),h=h?v.isText&&v.marks.length===0:!1,f=f?v.isBlock:!1}),u===d&&f){const{parent:v}=r.doc.resolve(u);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(u-=1,d+=1)}let m;if(h){if(Array.isArray(e))m=e.map(v=>v.text||"").join("");else if(e instanceof A){let v="";e.forEach(b=>{b.text&&(v+=b.text)}),m=v}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,u,d)}else{m=l;const v=r.doc.resolve(u),b=v.node(),C=v.parentOffset===0,x=b.isText||b.isTextblock,w=b.content.size>0;C&&x&&w&&(u=Math.max(0,u-1)),r.replaceWith(u,d,m)}n.updateSelection&&gb(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0},bb=()=>({state:t,dispatch:e})=>W2(t,e),Cb=()=>({state:t,dispatch:e})=>K2(t,e),xb=()=>({state:t,dispatch:e})=>bh(t,e),wb=()=>({state:t,dispatch:e})=>Sh(t,e),Sb=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ki(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},kb=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ki(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Eb=()=>({state:t,dispatch:e})=>z2(t,e),Mb=()=>({state:t,dispatch:e})=>U2(t,e);function gp(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Tb(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,o,i,s;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Ur()||gp()?s=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),o&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var Ab=t=>({editor:e,view:n,tr:r,dispatch:o})=>{const i=Tb(t).split(/-(?!$)/),s=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{const u=c.map(r.mapping);u&&o&&r.maybeStep(u)}),!0};function ln(t,e,n={}){const{from:r,to:o,empty:i}=t.selection,s=e?me(e,t.schema):null,l=[];t.doc.nodesBetween(r,o,(d,h)=>{if(d.isText)return;const f=Math.max(r,h),p=Math.min(o,h+d.nodeSize);l.push({node:d,from:f,to:p})});const a=o-r,c=l.filter(d=>s?s.name===d.node.type.name:!0).filter(d=>ii(d.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((d,h)=>d+h.to-h.from,0)>=a}var Rb=(t,e={})=>({state:n,dispatch:r})=>{const o=me(t,n.schema);return ln(n,o,e)?q2(n,r):!1},Ob=()=>({state:t,dispatch:e})=>Th(t,e),Nb=t=>({state:e,dispatch:n})=>{const r=me(t,e.schema);return iy(r)(e,n)},Ib=()=>({state:t,dispatch:e})=>Eh(t,e);function es(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function hd(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,o)=>(n.includes(o)||(r[o]=t[o]),r),{})}var Lb=(t,e)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null;const l=es(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=me(t,r.schema)),l==="mark"&&(s=jt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{i&&i===u.type&&(a=!0,o&&n.setNodeMarkup(d,void 0,hd(u.attrs,e))),s&&u.marks.length&&u.marks.forEach(h=>{s===h.type&&(a=!0,o&&n.addMark(d,d+u.nodeSize,s.create(hd(h.attrs,e))))})})}),a},Db=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Pb=()=>({tr:t,dispatch:e})=>{if(e){const n=new ze(t.doc);t.setSelection(n)}return!0},jb=()=>({state:t,dispatch:e})=>xh(t,e),Bb=()=>({state:t,dispatch:e})=>kh(t,e),_b=()=>({state:t,dispatch:e})=>Y2(t,e),Hb=()=>({state:t,dispatch:e})=>ey(t,e),Fb=()=>({state:t,dispatch:e})=>Q2(t,e);function Hl(t,e,n={},r={}){return Wr(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var $b=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{const{doc:a}=i;if(r.preserveWhitespace!=="full"){const c=Hl(t,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});return s&&i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return s&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function yp(t,e){const n=jt(e,t.schema),{from:r,to:o,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});const l=s.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function $a(t,e){const n=new mh(t);return e.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function Vb(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function zb(t,e){const n=[];return t.descendants((r,o)=>{e(r)&&n.push({node:r,pos:o})}),n}function vp(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(o,i)=>{n(o)&&r.push({node:o,pos:i})}),r}function Ub(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function ts(t){return e=>Ub(e.$from,t)}function $(t,e,n){return t.config[e]===void 0&&t.parent?$(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?$(t.parent,e,n):null}):t.config[e]}function Va(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=$(e,"addExtensions",n);return r?[e,...Va(r())]:e}).flat(10)}function za(t,e){const n=Ln.fromSchema(e).serializeFragment(t),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}function bp(t){return typeof t=="function"}function ee(t,e=void 0,...n){return bp(t)?e?t.bind(e)(...n):t(...n):t}function Wb(t={}){return Object.keys(t).length===0&&t.constructor===Object}function lr(t){const e=t.filter(o=>o.type==="extension"),n=t.filter(o=>o.type==="node"),r=t.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Cp(t){const e=[],{nodeExtensions:n,markExtensions:r}=lr(t),o=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},s=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...s,...l];return t.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage,extensions:o},d=$(c,"addGlobalAttributes",u);if(!d)return;d().forEach(f=>{let p;Array.isArray(f.types)?p=f.types:f.types==="*"?p=a:f.types==="nodes"?p=s:f.types==="marks"?p=l:p=[],p.forEach(m=>{Object.entries(f.attributes).forEach(([v,b])=>{e.push({type:m,name:v,attribute:{...i,...b}})})})})}),o.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage},d=$(c,"addAttributes",u);if(!d)return;const h=d();Object.entries(h).forEach(([f,p])=>{const m={...i,...p};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:c.name,name:f,attribute:m})})}),e}function Kb(t){const e=[];let n="",r=!1,o=!1,i=0;const s=t.length;for(let l=0;l<s;l+=1){const a=t[l];if(a==="'"&&!o){r=!r,n+=a;continue}if(a==='"'&&!r){o=!o,n+=a;continue}if(!r&&!o){if(a==="("){i+=1,n+=a;continue}if(a===")"&&i>0){i-=1,n+=a;continue}if(a===";"&&i===0){e.push(n),n="";continue}}n+=a}return n&&e.push(n),e}function pd(t){const e=[],n=Kb(t||""),r=n.length;for(let o=0;o<r;o+=1){const i=n[o],s=i.indexOf(":");if(s===-1)continue;const l=i.slice(0,s).trim(),a=i.slice(s+1).trim();l&&a&&e.push([l,a])}return e}function te(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([o,i])=>{if(!r[o]){r[o]=i;return}if(o==="class"){const l=i?String(i).split(" "):[],a=r[o]?r[o].split(" "):[],c=l.filter(u=>!a.includes(u));r[o]=[...a,...c].join(" ")}else if(o==="style"){const l=new Map([...pd(r[o]),...pd(i)]);r[o]=Array.from(l.entries()).map(([a,c])=>`${a}: ${c}`).join("; ")}else r[o]=i}),r},{})}function Kr(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>te(n,r),{})}function qb(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function md(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const o=e.reduce((i,s)=>{const l=s.attribute.parseHTML?s.attribute.parseHTML(n):qb(n.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function gd(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Wb(n)?!1:n!=null))}function yd(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function Gb(t,e){var n;const r=Cp(t),{nodeExtensions:o,markExtensions:i}=lr(t),s=(n=o.find(c=>$(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(o.map(c=>{const u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((b,C)=>{const x=$(C,"extendNodeSchema",d);return{...b,...x?x(c):{}}},{}),f=gd({...h,content:ee($(c,"content",d)),marks:ee($(c,"marks",d)),group:ee($(c,"group",d)),inline:ee($(c,"inline",d)),atom:ee($(c,"atom",d)),selectable:ee($(c,"selectable",d)),draggable:ee($(c,"draggable",d)),code:ee($(c,"code",d)),whitespace:ee($(c,"whitespace",d)),linebreakReplacement:ee($(c,"linebreakReplacement",d)),defining:ee($(c,"defining",d)),isolating:ee($(c,"isolating",d)),attrs:Object.fromEntries(u.map(yd))}),p=ee($(c,"parseHTML",d));p&&(f.parseDOM=p.map(b=>md(b,u)));const m=$(c,"renderHTML",d);m&&(f.toDOM=b=>m({node:b,HTMLAttributes:Kr(b,u)}));const v=$(c,"renderText",d);return v&&(f.toText=v),[c.name,f]})),a=Object.fromEntries(i.map(c=>{const u=r.filter(v=>v.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((v,b)=>{const C=$(b,"extendMarkSchema",d);return{...v,...C?C(c):{}}},{}),f=gd({...h,inclusive:ee($(c,"inclusive",d)),excludes:ee($(c,"excludes",d)),group:ee($(c,"group",d)),spanning:ee($(c,"spanning",d)),code:ee($(c,"code",d)),attrs:Object.fromEntries(u.map(yd))}),p=ee($(c,"parseHTML",d));p&&(f.parseDOM=p.map(v=>md(v,u)));const m=$(c,"renderHTML",d);return m&&(f.toDOM=v=>m({mark:v,HTMLAttributes:Kr(v,u)})),[c.name,f]}));return new Qf({topNode:s,nodes:l,marks:a})}function Jb(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Or(t){return t.sort((n,r)=>{const o=$(n,"priority")||100,i=$(r,"priority")||100;return o>i?-1:o<i?1:0})}function xp(t){const e=Or(Va(t)),n=Jb(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function wp(t,e,n){const{from:r,to:o}=e,{blockSeparator:i=`
27
+
28
+ `,textSerializers:s={}}=n||{};let l="";return t.nodesBetween(r,o,(a,c,u,d)=>{var h;a.isBlock&&c>r&&(l+=i);const f=s?.[a.type.name];if(f)return u&&(l+=f({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(h=a?.text)==null?void 0:h.slice(Math.max(r,c)-c,o-c))}),l}function Zb(t,e){const n={from:0,to:t.content.size};return wp(t,n,e)}function Sp(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function Yb(t,e){const n=me(e,t.schema),{from:r,to:o}=t.selection,i=[];t.doc.nodesBetween(r,o,l=>{i.push(l)});const s=i.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function kp(t,e){const n=es(typeof e=="string"?e:e.name,t.schema);return n==="node"?Yb(t,e):n==="mark"?yp(t,e):{}}function Xb(t,e=JSON.stringify){const n={};return t.filter(r=>{const o=e(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function Qb(t){const e=Xb(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,s)=>s!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Ua(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((o,i)=>{const s=[];if(o.ranges.length)o.forEach((l,a)=>{s.push({from:l,to:a})});else{const{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{const c=e.slice(i).map(l,-1),u=e.slice(i).map(a),d=e.invert().map(c,-1),h=e.invert().map(u);r.push({oldRange:{from:d,to:h},newRange:{from:c,to:u}})})}),Qb(r)}function Wa(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(o=>{const i=n.resolve(t),s=Fa(i,o.type);s&&r.push({mark:o,...s})}):n.nodesBetween(t,e,(o,i)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var eC=(t,e,n,r=20)=>{const o=t.doc.resolve(n);let i=r,s=null;for(;i>0&&s===null;){const l=o.node(i);l?.type.name===e?s=l:i-=1}return[s,i]};function vr(t,e){return e.nodes[t]||e.marks[t]||null}function Fo(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const o=t.find(i=>i.type===e&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var tC=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(o,i,s,l)=>{var a,c;const u=((c=(a=o.type.spec).toText)==null?void 0:c.call(a,{node:o,pos:i,parent:s,index:l}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?u:u.slice(0,Math.max(0,r-i))}),n};function Fl(t,e,n={}){const{empty:r,ranges:o}=t.selection,i=e?jt(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>i?i.name===d.type.name:!0).find(d=>ii(d.attrs,n,{strict:!1}));let s=0;const l=[];if(o.forEach(({$from:d,$to:h})=>{const f=d.pos,p=h.pos;t.doc.nodesBetween(f,p,(m,v)=>{if(i&&m.inlineContent&&!m.type.allowsMarkType(i))return!1;if(!m.isText&&!m.marks.length)return;const b=Math.max(f,v),C=Math.min(p,v+m.nodeSize),x=C-b;s+=x,l.push(...m.marks.map(w=>({mark:w,from:b,to:C})))})}),s===0)return!1;const a=l.filter(d=>i?i.name===d.mark.type.name:!0).filter(d=>ii(d.mark.attrs,n,{strict:!1})).reduce((d,h)=>d+h.to-h.from,0),c=l.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):!0).reduce((d,h)=>d+h.to-h.from,0);return(a>0?a+c:a)>=s}function nC(t,e,n={}){if(!e)return ln(t,null,n)||Fl(t,null,n);const r=es(e,t.schema);return r==="node"?ln(t,e,n):r==="mark"?Fl(t,e,n):!1}var rC=(t,e)=>{const{$from:n,$to:r,$anchor:o}=t.selection;if(e){const i=ts(l=>l.type.name===e)(t.selection);if(!i)return!1;const s=t.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},oC=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function vd(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function bd(t,e){const{nodeExtensions:n}=lr(e),r=n.find(s=>s.name===t);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},i=ee($(r,"group",o));return typeof i!="string"?!1:i.split(" ").includes("list")}function ns(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let o=!0;return t.content.forEach(i=>{o!==!1&&(ns(i,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}function Ep(t){return t instanceof B}var Mp=class Tp{constructor(e){this.position=e}static fromJSON(e){return new Tp(e.position)}toJSON(){return{position:this.position}}};function iC(t,e){const n=e.mapping.mapResult(t.position);return{position:new Mp(n.pos),mapResult:n}}function sC(t){return new Mp(t)}function lC(t,e,n){var r;const{selection:o}=e;let i=null;if(hp(o)&&(i=o.$cursor),i){const l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}const{ranges:s}=o;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,h)=>{if(c)return!1;if(u.isInline){const f=!h||h.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(n));c=f&&p}return!c}),c})}var aC=(t,e={})=>({tr:n,state:r,dispatch:o})=>{const{selection:i}=n,{empty:s,ranges:l}=i,a=jt(t,r.schema);if(o)if(s){const c=yp(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(h,f)=>{const p=Math.max(f,u),m=Math.min(f+h.nodeSize,d);h.marks.find(b=>b.type===a)?h.marks.forEach(b=>{a===b.type&&n.addMark(p,m,a.create({...b.attrs,...e}))}):n.addMark(p,m,a.create(e))})});return lC(r,n,a)},cC=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),uC=(t,e={})=>({state:n,dispatch:r,chain:o})=>{const i=me(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>Iu(i,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Iu(i,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},dC=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,o=Cn(t,0,r.content.size),i=B.create(r,o);e.setSelection(i)}return!0},fC=(t,e)=>({tr:n,state:r,dispatch:o})=>{const{selection:i}=r;let s,l;return typeof e=="number"?(s=e,l=e):e&&"from"in e&&"to"in e?(s=e.from,l=e.to):(s=i.from,l=i.to),o&&n.doc.nodesBetween(s,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},hC=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:o,to:i}=typeof t=="number"?{from:t,to:t}:t,s=z.atStart(r).from,l=z.atEnd(r).to,a=Cn(o,s,l),c=Cn(i,s,l),u=z.create(r,a,c);e.setSelection(u)}return!0},pC=t=>({state:e,dispatch:n})=>{const r=me(t,e.schema);return ay(r)(e,n)};function Cd(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(o=>e?.includes(o.type.name));t.tr.ensureMarks(r)}}var mC=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:o})=>{const{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=o.extensionManager.attributes,u=Fo(c,l.node().type.name,l.node().attrs);if(i instanceof B&&i.node.isBlock)return!l.parentOffset||!Rt(s,l.pos)?!1:(r&&(t&&Cd(n,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,h=l.depth===0?void 0:Vb(l.node(-1).contentMatchAt(l.indexAfter(-1)));let f=d&&h?[{type:h,attrs:u}]:void 0,p=Rt(e.doc,e.mapping.map(l.pos),1,f);if(!f&&!p&&Rt(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)&&(p=!0,f=h?[{type:h,attrs:u}]:void 0),r){if(p&&(i instanceof z&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,f),h&&!d&&!l.parentOffset&&l.parent.type!==h)){const m=e.mapping.map(l.before()),v=e.doc.resolve(m);l.node(-1).canReplaceWith(v.index(),v.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}t&&Cd(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return p},gC=(t,e={})=>({tr:n,state:r,dispatch:o,editor:i})=>{var s;const l=me(t,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 d=a.node(-1);if(d.type!==l)return!1;const h=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(o){let b=A.empty;const C=a.index(-1)?1:a.index(-2)?2:3;for(let M=a.depth-C;M>=a.depth-3;M-=1)b=A.from(a.node(M).copy(b));const x=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,w={...Fo(h,a.node().type.name,a.node().attrs),...e},E=((s=l.contentMatch.defaultType)==null?void 0:s.createAndFill(w))||void 0;b=b.append(A.from(l.createAndFill(null,E)||void 0));const S=a.before(a.depth-(C-1));n.replace(S,a.after(-x),new j(b,4-C,0));let k=-1;n.doc.nodesBetween(S,n.doc.content.size,(M,I)=>{if(k>-1)return!1;M.isTextblock&&M.content.size===0&&(k=I+1)}),k>-1&&n.setSelection(z.near(n.doc.resolve(k))),n.scrollIntoView()}return!0}const f=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...Fo(h,d.type.name,d.attrs),...e},m={...Fo(h,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const v=f?[{type:l,attrs:p},{type:f,attrs:m}]:[{type:l,attrs:p}];if(!Rt(n.doc,a.pos,2))return!1;if(o){const{selection:b,storedMarks:C}=r,{splittableMarks:x}=i.extensionManager,w=C||b.$to.parentOffset&&b.$from.marks();if(n.split(a.pos,2,v).scrollIntoView(),!w||!o)return!0;const E=w.filter(S=>x.includes(S.type.name));n.ensureMarks(E)}return!0},$s=(t,e)=>{const n=ts(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const o=t.doc.nodeAt(r);return n.node.type===o?.type&&dn(t.doc,n.pos)&&t.join(n.pos),!0},Vs=(t,e)=>{const n=ts(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const o=t.doc.nodeAt(r);return n.node.type===o?.type&&dn(t.doc,r)&&t.join(r),!0},yC=(t,e,n,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:h}=o.extensionManager,f=me(t,s.schema),p=me(e,s.schema),{selection:m,storedMarks:v}=s,{$from:b,$to:C}=m,x=b.blockRange(C),w=v||m.$to.parentOffset&&m.$from.marks();if(!x)return!1;const E=ts(S=>bd(S.type.name,d))(m);if(x.depth>=1&&E&&x.depth-E.depth<=1){if(E.node.type===f)return c.liftListItem(p);if(bd(E.node.type.name,d)&&f.validContent(E.node.content)&&l)return a().command(()=>(i.setNodeMarkup(E.pos,f),!0)).command(()=>$s(i,f)).command(()=>Vs(i,f)).run()}return!n||!w||!l?a().command(()=>u().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>$s(i,f)).command(()=>Vs(i,f)).run():a().command(()=>{const S=u().wrapInList(f,r),k=w.filter(M=>h.includes(M.type.name));return i.ensureMarks(k),S?!0:c.clearNodes()}).wrapInList(f,r).command(()=>$s(i,f)).command(()=>Vs(i,f)).run()},vC=(t,e={},n={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:i=!1}=n,s=jt(t,r.schema);return Fl(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},bC=(t,e,n={})=>({state:r,commands:o})=>{const i=me(t,r.schema),s=me(e,r.schema),l=ln(r,i,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...n})},CC=(t,e={})=>({state:n,commands:r})=>{const o=me(t,n.schema);return ln(n,o,e)?r.lift(o):r.wrapIn(o,e)},xC=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const o=n[r];let i;if(o.spec.isInputRules&&(i=o.getState(t))){if(e){const s=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},wC=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:o}=n;return r||e&&o.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},SC=(t,e={})=>({tr:n,state:r,dispatch:o})=>{var i;const{extendEmptyMarkRange:s=!1}=e,{selection:l}=n,a=jt(t,r.schema),{$from:c,empty:u,ranges:d}=l;if(!o)return!0;if(u&&s){let{from:h,to:f}=l;const p=(i=c.marks().find(v=>v.type===a))==null?void 0:i.attrs,m=Fa(c,a,p);m&&(h=m.from,f=m.to),n.removeMark(h,f,a)}else d.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,a)});return n.removeStoredMark(a),!0},kC=t=>({tr:e,state:n,dispatch:r})=>{const{selection:o}=n;let i,s;return typeof t=="number"?(i=t,s=t):t&&"from"in t&&"to"in t?(i=t.from,s=t.to):(i=o.from,s=o.to),r&&e.doc.nodesBetween(i,s,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},EC=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null;const l=es(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=me(t,r.schema)),l==="mark"&&(s=jt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let h,f,p,m;n.selection.empty?r.doc.nodesBetween(u,d,(v,b)=>{i&&i===v.type&&(a=!0,p=Math.max(b,u),m=Math.min(b+v.nodeSize,d),h=b,f=v)}):r.doc.nodesBetween(u,d,(v,b)=>{b<u&&i&&i===v.type&&(a=!0,p=Math.max(b,u),m=Math.min(b+v.nodeSize,d),h=b,f=v),b>=u&&b<=d&&(i&&i===v.type&&(a=!0,o&&n.setNodeMarkup(b,void 0,{...v.attrs,...e})),s&&v.marks.length&&v.marks.forEach(C=>{if(s===C.type&&(a=!0,o)){const x=Math.max(b,u),w=Math.min(b+v.nodeSize,d);n.addMark(x,w,s.create({...C.attrs,...e}))}}))}),f&&(h!==void 0&&o&&n.setNodeMarkup(h,void 0,{...f.attrs,...e}),s&&f.marks.length&&f.marks.forEach(v=>{s===v.type&&o&&n.addMark(p,m,s.create({...v.attrs,...e}))}))}),a},MC=(t,e={})=>({state:n,dispatch:r})=>{const o=me(t,n.schema);return ty(o,e)(n,r)},TC=(t,e={})=>({state:n,dispatch:r})=>{const o=me(t,n.schema);return ny(o,e)(n,r)},AC=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},so=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},RC=(t,e)=>{if(Ha(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function xo(t){var e;const{editor:n,from:r,to:o,text:i,rules:s,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(h=>h.type.spec.code))return!1;let u=!1;const d=tC(c)+i;return s.forEach(h=>{if(u)return;const f=RC(d,h.find);if(!f)return;const p=a.state.tr,m=Xi({state:a.state,transaction:p}),v={from:r-(f[0].length-i.length),to:o},{commands:b,chain:C,can:x}=new Qi({editor:n,state:m});h.handler({state:m,range:v,match:f,commands:b,chain:C,can:x})===null||!p.steps.length||(h.undoable&&p.setMeta(l,{transform:p,from:r,to:o,text:i}),a.dispatch(p),u=!0)}),u}function OC(t){const{editor:e,rules:n}=t,r=new ae({state:{init(){return null},apply(o,i,s){const l=o.getMeta(r);if(l)return l;const a=o.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=za(A.from(u),s.schema);const{from:d}=a,h=d+u.length;xo({editor:e,from:d,to:h,text:u,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return xo({editor:e,from:i,to:s,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{const{$cursor:i}=o.state.selection;i&&xo({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;const{$cursor:s}=o.state.selection;return s?xo({editor:e,from:s.pos,to:s.pos,text:`
29
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function NC(t){return Object.prototype.toString.call(t).slice(8,-1)}function wo(t){return NC(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Ap(t,e){const n={...t};return wo(t)&&wo(e)&&Object.keys(e).forEach(r=>{wo(e[r])&&wo(t[r])?n[r]=Ap(t[r],e[r]):n[r]=e[r]}),n}var Ka=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...ee($(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...ee($(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Ap(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},it=class Rp extends Ka{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Rp(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){const s=o.marks();if(!!!s.find(c=>c?.type.name===n.name))return!1;const a=s.find(c=>c?.type.name===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function IC(t){return typeof t=="number"}var LC=class{constructor(t){this.find=t.find,this.handler=t.handler}},DC=(t,e,n)=>{if(Ha(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(o=>{const i=[o.text];return i.index=o.index,i.input=t,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function PC(t){const{editor:e,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=t,{commands:a,chain:c,can:u}=new Qi({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,o,(f,p)=>{var m,v,b,C,x;if((v=(m=f.type)==null?void 0:m.spec)!=null&&v.code||!(f.isText||f.isTextblock||f.isInline))return;const w=(x=(C=(b=f.content)==null?void 0:b.size)!=null?C:f.nodeSize)!=null?x:0,E=Math.max(r,p),S=Math.min(o,p+w);if(E>=S)return;const k=f.isText?f.text||"":f.textBetween(E-p,S-p,void 0,"");DC(k,i.find,s).forEach(I=>{if(I.index===void 0)return;const P=E+I.index+1,_=P+I[0].length,U={from:n.tr.mapping.map(P),to:n.tr.mapping.map(_)},F=i.handler({state:n,range:U,match:I,commands:a,chain:c,can:u,pasteEvent:s,dropEvent:l});d.push(F)})}),d.every(f=>f!==null)}var So=null,jC=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function BC(t){const{editor:e,rules:n}=t;let r=null,o=!1,i=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:u,from:d,to:h,rule:f,pasteEvt:p})=>{const m=u.tr,v=Xi({state:u,transaction:m});if(!(!PC({editor:e,state:v,from:Math.max(d-1,0),to:h.b-1,rule:f,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return n.map(u=>new ae({view(d){const h=p=>{var m;r=(m=d.dom.parentElement)!=null&&m.contains(p.target)?d.dom.parentElement:null,r&&(So=e)},f=()=>{So&&(So=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(d,h)=>{if(i=r===d.dom.parentElement,l=h,!i){const f=So;f?.isEditable&&setTimeout(()=>{const p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,h)=>{var f;const p=(f=h.clipboardData)==null?void 0:f.getData("text/html");return s=h,o=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(d,h,f)=>{const p=d[0],m=p.getMeta("uiEvent")==="paste"&&!o,v=p.getMeta("uiEvent")==="drop"&&!i,b=p.getMeta("applyPasteRules"),C=!!b;if(!m&&!v&&!C)return;if(C){let{text:E}=b;typeof E=="string"?E=E:E=za(A.from(E),f.schema);const{from:S}=b,k=S+E.length,M=jC(E);return a({rule:u,state:f,from:S,to:{b:k},pasteEvt:M})}const x=h.doc.content.findDiffStart(f.doc.content),w=h.doc.content.findDiffEnd(f.doc.content);if(!(!IC(x)||!w||x===w.b))return a({rule:u,state:f,from:x,to:w,pasteEvt:s})}}))}var rs=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=xp(t),this.schema=Gb(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:vr(e.name,this.schema)},r=$(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Or([...this.extensions].reverse()).flatMap(r=>{const o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:vr(r.name,this.schema)},i=[],s=$(r,"addKeyboardShortcuts",o);let l={};if(r.type==="mark"&&$(r,"exitable",o)&&(l.ArrowRight=()=>it.handleExit({editor:t,mark:r})),s){const h=Object.fromEntries(Object.entries(s()).map(([f,p])=>[f,()=>p({editor:t})]));l={...l,...h}}const a=Zv(l);i.push(a);const c=$(r,"addInputRules",o);if(vd(r,t.options.enableInputRules)&&c){const h=c();if(h&&h.length){const f=OC({editor:t,rules:h}),p=Array.isArray(f)?f:[f];i.push(...p)}}const u=$(r,"addPasteRules",o);if(vd(r,t.options.enablePasteRules)&&u){const h=u();if(h&&h.length){const f=BC({editor:t,rules:h});i.push(...f)}}const d=$(r,"addProseMirrorPlugins",o);if(d){const h=d();i.push(...h)}return i})}get attributes(){return Cp(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=lr(this.extensions);return Object.fromEntries(e.filter(n=>!!$(n,"addNodeView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:me(n.name,this.schema)},i=$(n,"addNodeView",o);if(!i)return[];const s=i();if(!s)return[];const l=(a,c,u,d,h)=>{const f=Kr(a,r);return s({node:a,view:c,getPos:u,decorations:d,innerDecorations:h,editor:t,extension:n,HTMLAttributes:f})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return Or([...this.extensions].reverse()).reduceRight((r,o)=>{const i={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:e,type:vr(o.name,this.schema)},s=$(o,"dispatchTransaction",i);return s?l=>{s.call(i,{transaction:l,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return Or([...this.extensions]).reduce((r,o)=>{const i={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:e,type:vr(o.name,this.schema)},s=$(o,"transformPastedHTML",i);return s?(l,a)=>{const c=r(l,a);return s.call(i,c)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=lr(this.extensions);return Object.fromEntries(e.filter(n=>!!$(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:jt(n.name,this.schema)},i=$(n,"addMarkView",o);if(!i)return[];const s=(l,a,c)=>{const u=Kr(l,r);return i()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{YC(l,t,d)}})};return[n.name,s]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:vr(e.name,this.schema)};e.type==="mark"&&((n=ee($(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const o=$(e,"onBeforeCreate",r),i=$(e,"onCreate",r),s=$(e,"onUpdate",r),l=$(e,"onSelectionUpdate",r),a=$(e,"onTransaction",r),c=$(e,"onFocus",r),u=$(e,"onBlur",r),d=$(e,"onDestroy",r);o&&this.editor.on("beforeCreate",o),i&&this.editor.on("create",i),s&&this.editor.on("update",s),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}};rs.resolve=xp;rs.sort=Or;rs.flatten=Va;var _C={};_a(_C,{ClipboardTextSerializer:()=>Np,Commands:()=>Ip,Delete:()=>Lp,Drop:()=>Dp,Editable:()=>Pp,FocusEvents:()=>Bp,Keymap:()=>_p,Paste:()=>Hp,Tabindex:()=>Fp,TextDirection:()=>$p,focusEventsPluginKey:()=>jp});var Z=class Op extends Ka{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Op(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Np=Z.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ae({key:new ge("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:o}=e,{ranges:i}=o,s=Math.min(...i.map(u=>u.$from.pos)),l=Math.max(...i.map(u=>u.$to.pos)),a=Sp(n);return wp(r,{from:s,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Ip=Z.create({name:"commands",addCommands(){return{...dp}}}),Lp=Z.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,o;const i=()=>{var s,l,a,c;if((c=(a=(l=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,t))!=null?c:t.getMeta("y-sync$"))return;const u=$a(t.before,[t,...e]);Ua(u).forEach(f=>{u.mapping.mapResult(f.oldRange.from).deletedAfter&&u.mapping.mapResult(f.oldRange.to).deletedBefore&&u.before.nodesBetween(f.oldRange.from,f.oldRange.to,(p,m)=>{const v=m+p.nodeSize-2,b=f.oldRange.from<=m&&v<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:v,newFrom:u.mapping.map(m),newTo:u.mapping.map(v),deletedRange:f.oldRange,newRange:f.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:u})})});const h=u.mapping;u.steps.forEach((f,p)=>{var m,v;if(f instanceof rt){const b=h.slice(p).map(f.from,-1),C=h.slice(p).map(f.to),x=h.invert().map(b,-1),w=h.invert().map(C),E=(m=u.doc.nodeAt(b-1))==null?void 0:m.marks.some(k=>k.eq(f.mark)),S=(v=u.doc.nodeAt(C))==null?void 0:v.marks.some(k=>k.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:x,to:w},newRange:{from:b,to:C},partial:!!(S||E),editor:this.editor,transaction:t,combinedTransform:u})}})};(o=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||o?setTimeout(i,0):i()}}),Dp=Z.create({name:"drop",addProseMirrorPlugins(){return[new ae({key:new ge("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Pp=Z.create({name:"editable",addProseMirrorPlugins(){return[new ae({key:new ge("editable"),props:{editable:()=>this.editor.options.editable}})]}}),jp=new ge("focusEvents"),Bp=Z.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ae({key:jp,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),_p=Z.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:h,parent:f}=d,p=d.parent.isTextblock&&h>0?l.doc.resolve(h-1):d,m=p.parent.type.spec.isolating,v=d.pos-d.parentOffset,b=m&&p.parent.childCount===1?v===d.pos:q.atStart(c).from===h;return!u||!f.type.isTextblock||f.textContent.length||!b||b&&d.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"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 Ur()||gp()?i:o},addProseMirrorPlugins(){return[new ae({key:new ge("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(m=>m.getMeta("composition")))return;const r=t.some(m=>m.docChanged)&&!e.doc.eq(n.doc),o=t.some(m=>m.getMeta("preventClearDocument"));if(!r||o)return;const{empty:i,from:s,to:l}=e.selection,a=q.atStart(e.doc).from,c=q.atEnd(e.doc).to;if(i||!(s===a&&l===c)||!ns(n.doc))return;const h=n.tr,f=Xi({state:n,transaction:h}),{commands:p}=new Qi({editor:this.editor,state:f});if(p.clearNodes(),!!h.steps.length)return h}})]}}),Hp=Z.create({name:"paste",addProseMirrorPlugins(){return[new ae({key:new ge("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Fp=Z.create({name:"tabindex",addProseMirrorPlugins(){return[new ae({key:new ge("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),$p=Z.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=lr(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new ae({key:new ge("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),HC=class Sr{constructor(e,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=o}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Sr(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Sr(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Sr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const o=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,s=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(l);if(!o&&!s&&a.depth<=this.depth)return;const c=new Sr(a,this.editor,o,o||s?n:null);o&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(n).length>0){const i=o.node.attrs,s=Object.keys(n);for(let l=0;l<s.length;l+=1){const a=s[l];if(i[a]!==n[a])break}}else r=o;o=o.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;const i=Object.keys(n);return this.children.forEach(s=>{r&&o.length>0||(s.node.type.name===e&&i.every(a=>n[a]===s.node.attrs[a])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(e,n,r))))}),o}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},FC=`.ProseMirror {
30
30
  position: relative;
31
31
  }
32
32
 
@@ -96,26 +96,26 @@ img.ProseMirror-separator {
96
96
 
97
97
  .ProseMirror-focused .ProseMirror-gapcursor {
98
98
  display: block;
99
- }`;function IC(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute("data-tiptap-style",""),o.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(o),o}var LC=class extends bC{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Zb,createMappablePosition:Yb},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:o,moved:i})=>this.options.onDrop(r,o,i)),this.on("paste",({event:r,slice:o})=>this.options.onPaste(r,o)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=ip(e,this.options.autofocus);this.editorState=Jn.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=IC(NC,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=up(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(o=>{const i=typeof o=="string"?`${o}$`:o.key;n=n.filter(s=>!s.key.startsWith(i))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[Mp,wp.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Sp,Ap,Rp,Np,Ep,Op,kp,Ip.configure({direction:this.options.textDirection})].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new rs(r,this)}createCommandManager(){this.commandManager=new Qi({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Hl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=Hl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),o=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,s=this.extensionManager.transformPastedHTML(i);this.editorView=new ep(t,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:o,transformPastedHTML:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();const a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),o=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const s=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=s?.getMeta("focus"),a=s?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),a&&this.emit("blur",{editor:this,event:a.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return mp(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return qb(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return za(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
99
+ }`;function $C(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute("data-tiptap-style",""),o.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(o),o}var VC=class extends AC{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:iC,createMappablePosition:sC},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:o,moved:i})=>this.options.onDrop(r,o,i)),this.on("paste",({event:r,slice:o})=>this.options.onPaste(r,o)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=pp(e,this.options.autofocus);this.editorState=Zn.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=$C(FC,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=bp(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(o=>{const i=typeof o=="string"?`${o}$`:o.key;n=n.filter(s=>!s.key.startsWith(i))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[Pp,Np.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Ip,Bp,_p,Fp,Dp,Hp,Lp,$p.configure({direction:this.options.textDirection})].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new rs(r,this)}createCommandManager(){this.commandManager=new Qi({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Hl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=Hl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),o=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,s=this.extensionManager.transformPastedHTML(i);this.editorView=new cp(t,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:o,transformPastedHTML:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();const a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),o=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const s=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=s?.getMeta("focus"),a=s?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),a&&this.emit("blur",{editor:this,event:a.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return kp(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return nC(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return za(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
100
100
 
101
- `,textSerializers:n={}}=t||{};return $b(this.state.doc,{blockSeparator:e,textSerializers:{...pp(this.schema),...n}})}get isEmpty(){return ns(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new OC(e,this)}get $doc(){return this.$pos(0)}};function Nn(t){return new oo({find:t.find,handler:({state:e,range:n,match:r})=>{const o=Q(t.getAttributes,void 0,r);if(o===!1||o===null)return null;const{tr:i}=e,s=r[r.length-1],l=r[0];if(s){const a=l.search(/\S/),c=n.from+l.indexOf(s),u=c+s.length;if(Wa(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(m=>m===t.type&&m!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&i.delete(u,n.to),c>n.from&&i.delete(n.from+a,c);const h=n.from+a+s.length;i.addMark(n.from+a,h,t.type.create(o||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function DC(t){return new oo({find:t.find,handler:({state:e,range:n,match:r})=>{const o=Q(t.getAttributes,void 0,r)||{},{tr:i}=e,s=n.from;let l=n.to;const a=t.type.create(o);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=s+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];i.insertText(d,s+r[0].length-1),i.replaceWith(u,l,a)}else if(r[0]){const c=t.type.isInline?s:s-1;i.insert(c,t.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function $l(t){return new oo({find:t.find,handler:({state:e,range:n,match:r})=>{const o=e.doc.resolve(n.from),i=Q(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function he(t){return new oo({find:t.find,handler:({state:e,range:n,match:r})=>{let o=t.replace,i=n.from;const s=n.to;if(r[1]){const l=r[0].lastIndexOf(r[1]);o+=r[0].slice(l+r[1].length),i+=l;const a=i-s;a>0&&(o=r[0].slice(l-a,l)+o,i=s)}e.tr.insertText(o,i,s)},undoable:t.undoable})}function lr(t){return new oo({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{const i=Q(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),a=s.doc.resolve(n.from).blockRange(),c=a&&wa(a,t.type,i);if(!c)return null;if(s.wrap(a,c),t.keepMarks&&t.editor){const{selection:d,storedMarks:h}=e,{splittableMarks:f}=t.editor.extensionManager,p=h||d.$to.parentOffset&&d.$from.marks();if(p){const m=p.filter(v=>f.includes(v.type.name));s.ensureMarks(m)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(d,i).run()}const u=s.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&dn(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&s.join(n.from-1)},undoable:t.undoable})}function PC(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof B){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let o=r.depth;for(;o>=0;){const i=r.index(o);if(r.node(o).contentMatchAt(i).matchType(e))return!0;o-=1}return!1}var jC={};_a(jC,{createAtomBlockMarkdownSpec:()=>BC,createBlockMarkdownSpec:()=>_C,createInlineMarkdownSpec:()=>$C,parseAttributes:()=>qa,parseIndentedBlocks:()=>Vl,renderNestedMarkdownContent:()=>Ja,serializeAttributes:()=>Ga});function qa(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),o=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(o){const c=o.map(u=>u.trim().slice(1));e.class=c.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const s=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(s)).forEach(([,c,u])=>{var d;const h=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),f=n[h];f&&(e[c]=f.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 Ga(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function BC(t){const{nodeName:e,name:n,parseAttributes:r=qa,serializeAttributes:o=Ga,defaultAttributes:i={},requiredAttributes:s=[],allowedAttributes:l}=t,a=n||e,c=u=>{if(!l)return u;const d={};return l.forEach(h=>{h in u&&(d[h]=u[h])}),d};return{parseMarkdown:(u,d)=>{const h={...i,...u.attributes};return d.createNode(e,h,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;const h=new RegExp(`^:::${a}(?:\\s|$)`,"m"),f=(d=u.match(h))==null?void 0:d.index;return f!==void 0?f:-1},tokenize(u,d,h){const f=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=u.match(f);if(!p)return;const m=p[1]||"",v=r(m);if(!s.find(C=>!(C in v)))return{type:e,raw:p[0],attributes:v}}},renderMarkdown:u=>{const d=c(u.attrs||{}),h=o(d),f=h?` {${h}}`:"";return`:::${a}${f} :::`}}}function _C(t){const{nodeName:e,name:n,getContent:r,parseAttributes:o=qa,serializeAttributes:i=Ga,defaultAttributes:s={},content:l="block",allowedAttributes:a}=t,c=n||e,u=d=>{if(!a)return d;const h={};return a.forEach(f=>{f in d&&(h[f]=d[f])}),h};return{parseMarkdown:(d,h)=>{let f;if(r){const m=r(d);f=typeof m=="string"?[{type:"text",text:m}]:m}else l==="block"?f=h.parseChildren(d.tokens||[]):f=h.parseInline(d.tokens||[]);const p={...s,...d.attributes};return h.createNode(e,p,f)},markdownTokenizer:{name:e,level:"block",start(d){var h;const f=new RegExp(`^:::${c}`,"m"),p=(h=d.match(f))==null?void 0:h.index;return p!==void 0?p:-1},tokenize(d,h,f){var p;const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=d.match(m);if(!v)return;const[b,C=""]=v,x=o(C);let w=1;const E=b.length;let k="";const S=/^:::([\w-]*)(\s.*)?/gm,M=d.slice(E);for(S.lastIndex=0;;){const I=S.exec(M);if(I===null)break;const j=I.index,_=I[1];if(!((p=I[2])!=null&&p.endsWith(":::"))){if(_)w+=1;else if(w-=1,w===0){const U=M.slice(0,j);k=U.trim();const F=d.slice(0,E+j+I[0].length);let O=[];if(k)if(l==="block")for(O=f.blockTokens(U),O.forEach(H=>{H.text&&(!H.tokens||H.tokens.length===0)&&(H.tokens=f.inlineTokens(H.text))});O.length>0;){const H=O[O.length-1];if(H.type==="paragraph"&&(!H.text||H.text.trim()===""))O.pop();else break}else O=f.inlineTokens(k);return{type:e,raw:F,attributes:x,content:k,tokens:O}}}}}},renderMarkdown:(d,h)=>{const f=u(d.attrs||{}),p=i(f),m=p?` {${p}}`:"",v=h.renderChildren(d.content||[],`
101
+ `,textSerializers:n={}}=t||{};return Zb(this.state.doc,{blockSeparator:e,textSerializers:{...Sp(this.schema),...n}})}get isEmpty(){return ns(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new HC(e,this)}get $doc(){return this.$pos(0)}};function Nn(t){return new so({find:t.find,handler:({state:e,range:n,match:r})=>{const o=ee(t.getAttributes,void 0,r);if(o===!1||o===null)return null;const{tr:i}=e,s=r[r.length-1],l=r[0];if(s){const a=l.search(/\S/),c=n.from+l.indexOf(s),u=c+s.length;if(Wa(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(m=>m===t.type&&m!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&i.delete(u,n.to),c>n.from&&i.delete(n.from+a,c);const h=n.from+a+s.length;i.addMark(n.from+a,h,t.type.create(o||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function zC(t){return new so({find:t.find,handler:({state:e,range:n,match:r})=>{const o=ee(t.getAttributes,void 0,r)||{},{tr:i}=e,s=n.from;let l=n.to;const a=t.type.create(o);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=s+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];i.insertText(d,s+r[0].length-1),i.replaceWith(u,l,a)}else if(r[0]){const c=t.type.isInline?s:s-1;i.insert(c,t.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function $l(t){return new so({find:t.find,handler:({state:e,range:n,match:r})=>{const o=e.doc.resolve(n.from),i=ee(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function he(t){return new so({find:t.find,handler:({state:e,range:n,match:r})=>{let o=t.replace,i=n.from;const s=n.to;if(r[1]){const l=r[0].lastIndexOf(r[1]);o+=r[0].slice(l+r[1].length),i+=l;const a=i-s;a>0&&(o=r[0].slice(l-a,l)+o,i=s)}e.tr.insertText(o,i,s)},undoable:t.undoable})}function ar(t){return new so({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{const i=ee(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),a=s.doc.resolve(n.from).blockRange(),c=a&&wa(a,t.type,i);if(!c)return null;if(s.wrap(a,c),t.keepMarks&&t.editor){const{selection:d,storedMarks:h}=e,{splittableMarks:f}=t.editor.extensionManager,p=h||d.$to.parentOffset&&d.$from.marks();if(p){const m=p.filter(v=>f.includes(v.type.name));s.ensureMarks(m)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(d,i).run()}const u=s.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&dn(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&s.join(n.from-1)},undoable:t.undoable})}function UC(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof B){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let o=r.depth;for(;o>=0;){const i=r.index(o);if(r.node(o).contentMatchAt(i).matchType(e))return!0;o-=1}return!1}var WC={};_a(WC,{createAtomBlockMarkdownSpec:()=>KC,createBlockMarkdownSpec:()=>qC,createInlineMarkdownSpec:()=>ZC,parseAttributes:()=>qa,parseIndentedBlocks:()=>Vl,renderNestedMarkdownContent:()=>Ja,serializeAttributes:()=>Ga});function qa(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),o=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(o){const c=o.map(u=>u.trim().slice(1));e.class=c.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const s=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(s)).forEach(([,c,u])=>{var d;const h=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),f=n[h];f&&(e[c]=f.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 Ga(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function KC(t){const{nodeName:e,name:n,parseAttributes:r=qa,serializeAttributes:o=Ga,defaultAttributes:i={},requiredAttributes:s=[],allowedAttributes:l}=t,a=n||e,c=u=>{if(!l)return u;const d={};return l.forEach(h=>{h in u&&(d[h]=u[h])}),d};return{parseMarkdown:(u,d)=>{const h={...i,...u.attributes};return d.createNode(e,h,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;const h=new RegExp(`^:::${a}(?:\\s|$)`,"m"),f=(d=u.match(h))==null?void 0:d.index;return f!==void 0?f:-1},tokenize(u,d,h){const f=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=u.match(f);if(!p)return;const m=p[1]||"",v=r(m);if(!s.find(C=>!(C in v)))return{type:e,raw:p[0],attributes:v}}},renderMarkdown:u=>{const d=c(u.attrs||{}),h=o(d),f=h?` {${h}}`:"";return`:::${a}${f} :::`}}}function qC(t){const{nodeName:e,name:n,getContent:r,parseAttributes:o=qa,serializeAttributes:i=Ga,defaultAttributes:s={},content:l="block",allowedAttributes:a}=t,c=n||e,u=d=>{if(!a)return d;const h={};return a.forEach(f=>{f in d&&(h[f]=d[f])}),h};return{parseMarkdown:(d,h)=>{let f;if(r){const m=r(d);f=typeof m=="string"?[{type:"text",text:m}]:m}else l==="block"?f=h.parseChildren(d.tokens||[]):f=h.parseInline(d.tokens||[]);const p={...s,...d.attributes};return h.createNode(e,p,f)},markdownTokenizer:{name:e,level:"block",start(d){var h;const f=new RegExp(`^:::${c}`,"m"),p=(h=d.match(f))==null?void 0:h.index;return p!==void 0?p:-1},tokenize(d,h,f){var p;const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=d.match(m);if(!v)return;const[b,C=""]=v,x=o(C);let w=1;const E=b.length;let S="";const k=/^:::([\w-]*)(\s.*)?/gm,M=d.slice(E);for(k.lastIndex=0;;){const I=k.exec(M);if(I===null)break;const P=I.index,_=I[1];if(!((p=I[2])!=null&&p.endsWith(":::"))){if(_)w+=1;else if(w-=1,w===0){const U=M.slice(0,P);S=U.trim();const F=d.slice(0,E+P+I[0].length);let O=[];if(S)if(l==="block")for(O=f.blockTokens(U),O.forEach(H=>{H.text&&(!H.tokens||H.tokens.length===0)&&(H.tokens=f.inlineTokens(H.text))});O.length>0;){const H=O[O.length-1];if(H.type==="paragraph"&&(!H.text||H.text.trim()===""))O.pop();else break}else O=f.inlineTokens(S);return{type:e,raw:F,attributes:x,content:S,tokens:O}}}}}},renderMarkdown:(d,h)=>{const f=u(d.attrs||{}),p=i(f),m=p?` {${p}}`:"",v=h.renderChildren(d.content||[],`
102
102
 
103
103
  `);return`:::${c}${m}
104
104
 
105
105
  ${v}
106
106
 
107
- :::`}}}function HC(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,o,i,s]=r;e[o]=i||s,r=n.exec(t)}return e}function FC(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function $C(t){const{nodeName:e,name:n,getContent:r,parseAttributes:o=HC,serializeAttributes:i=FC,defaultAttributes:s={},selfClosing:l=!1,allowedAttributes:a}=t,c=n||e,u=h=>{if(!a)return h;const f={};return a.forEach(p=>{const m=typeof p=="string"?p:p.name,v=typeof p=="string"?void 0:p.skipIfDefault;if(m in h){const b=h[m];if(v!==void 0&&b===v)return;f[m]=b}}),f},d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(h,f)=>{const p={...s,...h.attributes};if(l)return f.createNode(e,p);const m=r?r(h):h.content||"";return m?f.createNode(e,p,[f.createTextNode(m)]):f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(h){const f=l?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),p=h.match(f),m=p?.index;return m!==void 0?m:-1},tokenize(h,f,p){const m=l?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),v=h.match(m);if(!v)return;let b="",C="";if(l){const[,w]=v;C=w}else{const[,w,E]=v;C=w,b=E||""}const x=o(C.trim());return{type:e,raw:v[0],content:b.trim(),attributes:x}}},renderMarkdown:h=>{let f="";r?f=r(h):h.content&&h.content.length>0&&(f=h.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const p=u(h.attrs||{}),m=i(p),v=m?` ${m}`:"";return l?`[${c}${v}]`:`[${c}${v}]${f}[/${c}]`}}}function Vl(t,e,n){var r,o,i,s;const l=t.split(`
107
+ :::`}}}function GC(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,o,i,s]=r;e[o]=i||s,r=n.exec(t)}return e}function JC(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function ZC(t){const{nodeName:e,name:n,getContent:r,parseAttributes:o=GC,serializeAttributes:i=JC,defaultAttributes:s={},selfClosing:l=!1,allowedAttributes:a}=t,c=n||e,u=h=>{if(!a)return h;const f={};return a.forEach(p=>{const m=typeof p=="string"?p:p.name,v=typeof p=="string"?void 0:p.skipIfDefault;if(m in h){const b=h[m];if(v!==void 0&&b===v)return;f[m]=b}}),f},d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(h,f)=>{const p={...s,...h.attributes};if(l)return f.createNode(e,p);const m=r?r(h):h.content||"";return m?f.createNode(e,p,[f.createTextNode(m)]):f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(h){const f=l?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),p=h.match(f),m=p?.index;return m!==void 0?m:-1},tokenize(h,f,p){const m=l?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),v=h.match(m);if(!v)return;let b="",C="";if(l){const[,w]=v;C=w}else{const[,w,E]=v;C=w,b=E||""}const x=o(C.trim());return{type:e,raw:v[0],content:b.trim(),attributes:x}}},renderMarkdown:h=>{let f="";r?f=r(h):h.content&&h.content.length>0&&(f=h.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const p=u(h.attrs||{}),m=i(p),v=m?` ${m}`:"";return l?`[${c}${v}]`:`[${c}${v}]${f}[/${c}]`}}}function Vl(t,e,n){var r,o,i,s;const l=t.split(`
108
108
  `),a=[];let c="",u=0;const d=e.baseIndentSize||2;for(;u<l.length;){const h=l[u],f=h.match(e.itemPattern);if(!f){if(a.length>0)break;if(h.trim()===""){u+=1,c=`${c}${h}
109
109
  `;continue}else return}const p=e.extractItemData(f),{indentLevel:m,mainContent:v}=p;c=`${c}${h}
110
- `;const b=[v];for(u+=1;u<l.length;){const E=l[u];if(E.trim()===""){const S=l.slice(u+1).findIndex(j=>j.trim()!=="");if(S===-1)break;if((((o=(r=l[u+1+S].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:o.length)||0)>m){b.push(E),c=`${c}${E}
110
+ `;const b=[v];for(u+=1;u<l.length;){const E=l[u];if(E.trim()===""){const k=l.slice(u+1).findIndex(P=>P.trim()!=="");if(k===-1)break;if((((o=(r=l[u+1+k].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:o.length)||0)>m){b.push(E),c=`${c}${E}
111
111
  `,u+=1;continue}else break}if((((s=(i=E.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:s.length)||0)>m)b.push(E),c=`${c}${E}
112
- `,u+=1;else break}let C;const x=b.slice(1);if(x.length>0){const E=x.map(k=>k.slice(m+d)).join(`
112
+ `,u+=1;else break}let C;const x=b.slice(1);if(x.length>0){const E=x.map(S=>S.slice(m+d)).join(`
113
113
  `);E.trim()&&(e.customNestedParser?C=e.customNestedParser(E):C=n.blockTokens(E))}const w=e.createToken(p,C);a.push(w)}if(a.length!==0)return{items:a,raw:c}}function Ja(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const o=typeof n=="function"?n(r):n,[i,...s]=t.content,l=e.renderChildren([i]);let a=`${o}${l}`;return s&&s.length>0&&s.forEach((c,u)=>{var d,h;const f=(h=(d=e.renderChild)==null?void 0:d.call(e,c,u+1))!=null?h:e.renderChildren([c]);if(f!=null){const p=f.split(`
114
114
  `).map(m=>m?e.indent(m):e.indent("")).join(`
115
115
  `);a+=c.type==="paragraph"?`
116
116
 
117
117
  ${p}`:`
118
- ${p}`}}),a}function VC(t,e,n={}){const{state:r}=e,{doc:o,tr:i}=r,s=t;o.descendants((l,a)=>{const c=i.mapping.map(a),u=i.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(f=>{if(f!==s)return!1;d=f}),!d)return;let h=!1;if(Object.keys(n).forEach(f=>{n[f]!==d.attrs[f]&&(h=!0)}),h){const f=t.type.create({...t.attrs,...n});i.removeMark(c,u,t.type),i.addMark(c,u,f)}}),i.docChanged&&e.view.dispatch(i)}var je=class Lp extends Ka{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Lp(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},zC=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},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(t){var e,n,r,o,i,s,l;const{view:a}=this.editor,c=t.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!u)return;let d=0,h=0;if(this.dom!==u){const C=this.dom.getBoundingClientRect(),x=u.getBoundingClientRect(),w=(o=t.offsetX)!=null?o:(r=t.nativeEvent)==null?void 0:r.offsetX,E=(s=t.offsetY)!=null?s:(i=t.nativeEvent)==null?void 0:i.offsetY;d=x.x-C.x+w,h=x.y-C.y+E}const f=this.dom.cloneNode(!0);try{const C=this.dom.getBoundingClientRect();f.style.width=`${Math.round(C.width)}px`,f.style.height=`${Math.round(C.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(f),document.body.appendChild(p),(l=t.dataTransfer)==null||l.setDragImage(f,d,h)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}const m=this.getPos();if(typeof m!="number")return;const v=B.create(a.state.doc,m),b=a.state.tr.setSelection(v);a.dispatch(b)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const o=t.type.startsWith("drag"),i=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i&&!o)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=B.isSelectable(this.node),d=t.type==="copy",h=t.type==="paste",f=t.type==="cut",p=t.type==="mousedown";if(!c&&u&&o&&t.target===this.dom&&t.preventDefault(),c&&o&&!a&&t.target===this.dom)return t.preventDefault(),!1;if(c&&l&&!a&&p){const m=n.closest("[data-drag-handle]");m&&(this.dom===m||this.dom.contains(m))&&(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||i||d||h||f||p&&u)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(zr()||_l())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function an(t){return new kC({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{const i=Q(t.getAttributes,void 0,r,o);if(i===!1||i===null)return null;const{tr:s}=e,l=r[r.length-1],a=r[0];let c=n.to;if(l){const u=a.search(/\S/),d=n.from+a.indexOf(l),h=d+l.length;if(Wa(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===t.type&&v!==p.mark.type)).filter(p=>p.to>d).length)return null;h<n.to&&s.delete(h,n.to),d>n.from&&s.delete(n.from+u,d),c=n.from+u+l.length,s.addMark(n.from+u,c,t.type.create(i||{})),s.removeStoredMark(t.type)}}})}var zs,hd;function UC(){return hd||(hd=1,zs=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!t(e[o],n[o]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(o of e.entries())if(!n.has(o[0]))return!1;for(o of e.entries())if(!t(o[1],n.get(o[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(o of e.entries())if(!n.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(o=r;o--!==0;)if(e[o]!==n[o])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;o--!==0;){var s=i[o];if(!(s==="_owner"&&e.$$typeof)&&!t(e[s],n[s]))return!1}return!0}return e!==e&&n!==n}),zs}var WC=UC();const KC=Tf(WC);var So={exports:{}},Us={};/**
118
+ ${p}`}}),a}function YC(t,e,n={}){const{state:r}=e,{doc:o,tr:i}=r,s=t;o.descendants((l,a)=>{const c=i.mapping.map(a),u=i.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(f=>{if(f!==s)return!1;d=f}),!d)return;let h=!1;if(Object.keys(n).forEach(f=>{n[f]!==d.attrs[f]&&(h=!0)}),h){const f=t.type.create({...t.attrs,...n});i.removeMark(c,u,t.type),i.addMark(c,u,f)}}),i.docChanged&&e.view.dispatch(i)}var Ie=class Vp extends Ka{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Vp(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},XC=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},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(t){var e,n,r,o,i,s,l;const{view:a}=this.editor,c=t.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!u)return;let d=0,h=0;if(this.dom!==u){const C=this.dom.getBoundingClientRect(),x=u.getBoundingClientRect(),w=(o=t.offsetX)!=null?o:(r=t.nativeEvent)==null?void 0:r.offsetX,E=(s=t.offsetY)!=null?s:(i=t.nativeEvent)==null?void 0:i.offsetY;d=x.x-C.x+w,h=x.y-C.y+E}const f=this.dom.cloneNode(!0);try{const C=this.dom.getBoundingClientRect();f.style.width=`${Math.round(C.width)}px`,f.style.height=`${Math.round(C.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(f),document.body.appendChild(p),(l=t.dataTransfer)==null||l.setDragImage(f,d,h)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}const m=this.getPos();if(typeof m!="number")return;const v=B.create(a.state.doc,m),b=a.state.tr.setSelection(v);a.dispatch(b)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const o=t.type.startsWith("drag"),i=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i&&!o)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=B.isSelectable(this.node),d=t.type==="copy",h=t.type==="paste",f=t.type==="cut",p=t.type==="mousedown";if(!c&&u&&o&&t.target===this.dom&&t.preventDefault(),c&&o&&!a&&t.target===this.dom)return t.preventDefault(),!1;if(c&&l&&!a&&p){const m=n.closest("[data-drag-handle]");m&&(this.dom===m||this.dom.contains(m))&&(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||i||d||h||f||p&&u)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(Ur()||_l())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function an(t){return new LC({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{const i=ee(t.getAttributes,void 0,r,o);if(i===!1||i===null)return null;const{tr:s}=e,l=r[r.length-1],a=r[0];let c=n.to;if(l){const u=a.search(/\S/),d=n.from+a.indexOf(l),h=d+l.length;if(Wa(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===t.type&&v!==p.mark.type)).filter(p=>p.to>d).length)return null;h<n.to&&s.delete(h,n.to),d>n.from&&s.delete(n.from+u,d),c=n.from+u+l.length,s.addMark(n.from+u,c,t.type.create(i||{})),s.removeStoredMark(t.type)}}})}var zs,xd;function QC(){return xd||(xd=1,zs=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!t(e[o],n[o]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(o of e.entries())if(!n.has(o[0]))return!1;for(o of e.entries())if(!t(o[1],n.get(o[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(o of e.entries())if(!n.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(o=r;o--!==0;)if(e[o]!==n[o])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;o--!==0;){var s=i[o];if(!(s==="_owner"&&e.$$typeof)&&!t(e[s],n[s]))return!1}return!0}return e!==e&&n!==n}),zs}var ex=QC();const tx=jf(ex);var ko={exports:{}},Us={};/**
119
119
  * @license React
120
120
  * use-sync-external-store-shim/with-selector.production.js
121
121
  *
@@ -123,7 +123,7 @@ ${p}`}}),a}function VC(t,e,n={}){const{state:r}=e,{doc:o,tr:i}=r,s=t;o.descendan
123
123
  *
124
124
  * This source code is licensed under the MIT license found in the
125
125
  * LICENSE file in the root directory of this source tree.
126
- */var pd;function qC(){if(pd)return Us;pd=1;var t=D,e=ba();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,o=e.useSyncExternalStore,i=t.useRef,s=t.useEffect,l=t.useMemo,a=t.useDebugValue;return Us.useSyncExternalStoreWithSelector=function(c,u,d,h,f){var p=i(null);if(p.current===null){var m={hasValue:!1,value:null};p.current=m}else m=p.current;p=l(function(){function b(k){if(!C){if(C=!0,x=k,k=h(k),f!==void 0&&m.hasValue){var S=m.value;if(f(S,k))return w=S}return w=k}if(S=w,r(x,k))return S;var M=h(k);return f!==void 0&&f(S,M)?(x=k,S):(x=k,w=M)}var C=!1,x,w,E=d===void 0?null:d;return[function(){return b(u())},E===null?void 0:function(){return b(E())}]},[u,d,h,f]);var v=o(c,p[0],p[1]);return s(function(){m.hasValue=!0,m.value=v},[v]),a(v),v},Us}var Ws={};/**
126
+ */var wd;function nx(){if(wd)return Us;wd=1;var t=L,e=ba();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,o=e.useSyncExternalStore,i=t.useRef,s=t.useEffect,l=t.useMemo,a=t.useDebugValue;return Us.useSyncExternalStoreWithSelector=function(c,u,d,h,f){var p=i(null);if(p.current===null){var m={hasValue:!1,value:null};p.current=m}else m=p.current;p=l(function(){function b(S){if(!C){if(C=!0,x=S,S=h(S),f!==void 0&&m.hasValue){var k=m.value;if(f(k,S))return w=k}return w=S}if(k=w,r(x,S))return k;var M=h(S);return f!==void 0&&f(k,M)?(x=S,k):(x=S,w=M)}var C=!1,x,w,E=d===void 0?null:d;return[function(){return b(u())},E===null?void 0:function(){return b(E())}]},[u,d,h,f]);var v=o(c,p[0],p[1]);return s(function(){m.hasValue=!0,m.value=v},[v]),a(v),v},Us}var Ws={};/**
127
127
  * @license React
128
128
  * use-sync-external-store-shim/with-selector.development.js
129
129
  *
@@ -131,10 +131,10 @@ ${p}`}}),a}function VC(t,e,n={}){const{state:r}=e,{doc:o,tr:i}=r,s=t;o.descendan
131
131
  *
132
132
  * This source code is licensed under the MIT license found in the
133
133
  * LICENSE file in the root directory of this source tree.
134
- */var md;function GC(){return md||(md=1,process.env.NODE_ENV!=="production"&&(function(){function t(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=D,n=ba(),r=typeof Object.is=="function"?Object.is:t,o=n.useSyncExternalStore,i=e.useRef,s=e.useEffect,l=e.useMemo,a=e.useDebugValue;Ws.useSyncExternalStoreWithSelector=function(c,u,d,h,f){var p=i(null);if(p.current===null){var m={hasValue:!1,value:null};p.current=m}else m=p.current;p=l(function(){function b(k){if(!C){if(C=!0,x=k,k=h(k),f!==void 0&&m.hasValue){var S=m.value;if(f(S,k))return w=S}return w=k}if(S=w,r(x,k))return S;var M=h(k);return f!==void 0&&f(S,M)?(x=k,S):(x=k,w=M)}var C=!1,x,w,E=d===void 0?null:d;return[function(){return b(u())},E===null?void 0:function(){return b(E())}]},[u,d,h,f]);var v=o(c,p[0],p[1]);return s(function(){m.hasValue=!0,m.value=v},[v]),a(v),v},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Ws}var gd;function JC(){return gd||(gd=1,process.env.NODE_ENV==="production"?So.exports=qC():So.exports=GC()),So.exports}var ZC=JC(),YC=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},XC=({contentComponent:t})=>{const e=Af.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return g.jsx(g.Fragment,{children:Object.values(e)})};function QC(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:Ui.createPortal(r.reactElement,r.element,n)},t.forEach(o=>o())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(o=>o())}}}var ex=class extends D.Component{constructor(t){var e;super(t),this.editorContentRef=D.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(t.view.dom),t.setOptions({element:e}),t.contentComponent=QC(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;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(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return g.jsxs(g.Fragment,{children:[g.jsx("div",{ref:YC(e,this.editorContentRef),...n}),t?.contentComponent&&g.jsx(XC,{contentComponent:t.contentComponent})]})}},tx=D.forwardRef((t,e)=>{const n=D.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return D.createElement(ex,{key:n,innerRef:e,...t})}),nx=D.memo(tx),rx=typeof window<"u"?D.useLayoutEffect:D.useEffect,ox=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,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(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function Dp(t){var e;const[n]=D.useState(()=>new ox(t.editor)),r=ZC.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:KC);return rx(()=>n.watch(t.editor),[t.editor,n]),D.useDebugValue(r),r}var yd=process.env.NODE_ENV!=="production",zl=typeof window>"u",ix=zl||!!(typeof window<"u"&&window.next),sx=class Pp{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0){if(zl||ix){if(yd)throw new Error("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches.");return null}return this.createEditor()}if(this.options.current.immediatelyRender&&zl&&yd)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onBeforeCreate)==null?void 0:i.call(o,...r)},onBlur:(...r)=>{var o,i;return(i=(o=this.options.current).onBlur)==null?void 0:i.call(o,...r)},onCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onCreate)==null?void 0:i.call(o,...r)},onDestroy:(...r)=>{var o,i;return(i=(o=this.options.current).onDestroy)==null?void 0:i.call(o,...r)},onFocus:(...r)=>{var o,i;return(i=(o=this.options.current).onFocus)==null?void 0:i.call(o,...r)},onSelectionUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onSelectionUpdate)==null?void 0:i.call(o,...r)},onTransaction:(...r)=>{var o,i;return(i=(o=this.options.current).onTransaction)==null?void 0:i.call(o,...r)},onUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onUpdate)==null?void 0:i.call(o,...r)},onContentError:(...r)=>{var o,i;return(i=(o=this.options.current).onContentError)==null?void 0:i.call(o,...r)},onDrop:(...r)=>{var o,i;return(i=(o=this.options.current).onDrop)==null?void 0:i.call(o,...r)},onPaste:(...r)=>{var o,i;return(i=(o=this.options.current).onPaste)==null?void 0:i.call(o,...r)},onDelete:(...r)=>{var o,i;return(i=(o=this.options.current).onDelete)==null?void 0:i.call(o,...r)}};return new LC(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((o,i)=>{var s;return o===((s=n.extensions)==null?void 0:s[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Pp.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,o)=>r===e[o]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function lx(t={},e=[]){const n=D.useRef(t);n.current=t;const[r]=D.useState(()=>new sx(n)),o=Af.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return D.useDebugValue(o),D.useEffect(r.onRender(e)),Dp({editor:o,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),o}var Za=D.createContext({editor:null});Za.Consumer;var ax=()=>D.useContext(Za),jp=D.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),cx=()=>D.useContext(jp),Bp=D.forwardRef((t,e)=>{const{onDragStart:n}=cx(),r=t.as||"div";return g.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function vd(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function bd(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function ux(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function dx(t){if(vd(t)||bd(t))return!0;if(ux(t)){const e=t.type;if(e)return vd(e)||bd(e)}return!1}function fx(){try{if(D.version)return parseInt(D.version.split(".")[0],10)>=19}catch{}return!1}var hx=class{constructor(t,{editor:e,props:n={},as:r="div",className:o=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),o&&this.element.classList.add(...o.split(" ")),this.editor.isInitialized?Ui.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var t;const e=this.component,n=this.props,r=this.editor,o=fx(),i=dx(e),s={...n};s.ref&&!(o||i)&&delete s.ref,!s.ref&&(o||i)&&(s.ref=l=>{this.ref=l}),this.reactElement=g.jsx(e,{...s}),(t=r?.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.props={...this.props,...t},this.render()}destroy(){var t;const e=this.editor;(t=e?.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};D.createContext({markViewContentRef:()=>{}});var px=class extends zC{constructor(t,e,n){if(super(t,e,n),!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 t={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:D.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))}},o=this.component,i=D.memo(a=>g.jsx(jp.Provider,{value:r,children:D.createElement(o,a)}));i.displayName="ReactNodeView";let s=this.node.isInline?"span":"div";this.options.as&&(s=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new hx(i,{editor:this.editor,props:t,as:s,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.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(){const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(t,e,n){const r=o=>{this.renderer.updateProps(o),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const o=this.node,i=this.decorations,s=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:o,oldDecorations:i,newNode:t,newDecorations:e,oldInnerDecorations:s,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n})),!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}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=Wr(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function _p(t,e){return n=>n.editor.contentComponent?new px(t,n,e):{}}const xe=[];for(let t=0;t<256;++t)xe.push((t+256).toString(16).slice(1));function mx(t,e=0){return(xe[t[e+0]]+xe[t[e+1]]+xe[t[e+2]]+xe[t[e+3]]+"-"+xe[t[e+4]]+xe[t[e+5]]+"-"+xe[t[e+6]]+xe[t[e+7]]+"-"+xe[t[e+8]]+xe[t[e+9]]+"-"+xe[t[e+10]]+xe[t[e+11]]+xe[t[e+12]]+xe[t[e+13]]+xe[t[e+14]]+xe[t[e+15]]).toLowerCase()}let Ks;const gx=new Uint8Array(16);function yx(){if(!Ks){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ks=crypto.getRandomValues.bind(crypto)}return Ks(gx)}const vx=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Cd={randomUUID:vx};function bx(t,e,n){t=t||{};const r=t.random??t.rng?.()??yx();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,mx(r)}function Cx(t,e,n){return Cd.randomUUID&&!t?Cd.randomUUID():bx(t)}var ii=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},xx=/^\s*>\s$/,wx=je.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return ii("blockquote",{...oe(this.options.HTMLAttributes,t),children:ii("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=[];return t.content.forEach(o=>{const s=e.renderChildren(o).split(`
134
+ */var Sd;function rx(){return Sd||(Sd=1,process.env.NODE_ENV!=="production"&&(function(){function t(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=L,n=ba(),r=typeof Object.is=="function"?Object.is:t,o=n.useSyncExternalStore,i=e.useRef,s=e.useEffect,l=e.useMemo,a=e.useDebugValue;Ws.useSyncExternalStoreWithSelector=function(c,u,d,h,f){var p=i(null);if(p.current===null){var m={hasValue:!1,value:null};p.current=m}else m=p.current;p=l(function(){function b(S){if(!C){if(C=!0,x=S,S=h(S),f!==void 0&&m.hasValue){var k=m.value;if(f(k,S))return w=k}return w=S}if(k=w,r(x,S))return k;var M=h(S);return f!==void 0&&f(k,M)?(x=S,k):(x=S,w=M)}var C=!1,x,w,E=d===void 0?null:d;return[function(){return b(u())},E===null?void 0:function(){return b(E())}]},[u,d,h,f]);var v=o(c,p[0],p[1]);return s(function(){m.hasValue=!0,m.value=v},[v]),a(v),v},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Ws}var kd;function ox(){return kd||(kd=1,process.env.NODE_ENV==="production"?ko.exports=nx():ko.exports=rx()),ko.exports}var ix=ox(),sx=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},lx=({contentComponent:t})=>{const e=Bf.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return g.jsx(g.Fragment,{children:Object.values(e)})};function ax(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:Ui.createPortal(r.reactElement,r.element,n)},t.forEach(o=>o())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(o=>o())}}}var cx=class extends L.Component{constructor(t){var e;super(t),this.editorContentRef=L.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(t.view.dom),t.setOptions({element:e}),t.contentComponent=ax(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;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(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return g.jsxs(g.Fragment,{children:[g.jsx("div",{ref:sx(e,this.editorContentRef),...n}),t?.contentComponent&&g.jsx(lx,{contentComponent:t.contentComponent})]})}},ux=L.forwardRef((t,e)=>{const n=L.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return L.createElement(cx,{key:n,innerRef:e,...t})}),dx=L.memo(ux),fx=typeof window<"u"?L.useLayoutEffect:L.useEffect,hx=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,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(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function zp(t){var e;const[n]=L.useState(()=>new hx(t.editor)),r=ix.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:tx);return fx(()=>n.watch(t.editor),[t.editor,n]),L.useDebugValue(r),r}var Ed=process.env.NODE_ENV!=="production",zl=typeof window>"u",px=zl||!!(typeof window<"u"&&window.next),mx=class Up{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0){if(zl||px){if(Ed)throw new Error("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches.");return null}return this.createEditor()}if(this.options.current.immediatelyRender&&zl&&Ed)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onBeforeCreate)==null?void 0:i.call(o,...r)},onBlur:(...r)=>{var o,i;return(i=(o=this.options.current).onBlur)==null?void 0:i.call(o,...r)},onCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onCreate)==null?void 0:i.call(o,...r)},onDestroy:(...r)=>{var o,i;return(i=(o=this.options.current).onDestroy)==null?void 0:i.call(o,...r)},onFocus:(...r)=>{var o,i;return(i=(o=this.options.current).onFocus)==null?void 0:i.call(o,...r)},onSelectionUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onSelectionUpdate)==null?void 0:i.call(o,...r)},onTransaction:(...r)=>{var o,i;return(i=(o=this.options.current).onTransaction)==null?void 0:i.call(o,...r)},onUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onUpdate)==null?void 0:i.call(o,...r)},onContentError:(...r)=>{var o,i;return(i=(o=this.options.current).onContentError)==null?void 0:i.call(o,...r)},onDrop:(...r)=>{var o,i;return(i=(o=this.options.current).onDrop)==null?void 0:i.call(o,...r)},onPaste:(...r)=>{var o,i;return(i=(o=this.options.current).onPaste)==null?void 0:i.call(o,...r)},onDelete:(...r)=>{var o,i;return(i=(o=this.options.current).onDelete)==null?void 0:i.call(o,...r)}};return new VC(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((o,i)=>{var s;return o===((s=n.extensions)==null?void 0:s[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Up.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,o)=>r===e[o]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function gx(t={},e=[]){const n=L.useRef(t);n.current=t;const[r]=L.useState(()=>new mx(n)),o=Bf.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return L.useDebugValue(o),L.useEffect(r.onRender(e)),zp({editor:o,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),o}var Za=L.createContext({editor:null});Za.Consumer;var yx=()=>L.useContext(Za),Wp=L.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),vx=()=>L.useContext(Wp),Ya=L.forwardRef((t,e)=>{const{onDragStart:n}=vx(),r=t.as||"div";return g.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function Md(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function Td(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function bx(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function Cx(t){if(Md(t)||Td(t))return!0;if(bx(t)){const e=t.type;if(e)return Md(e)||Td(e)}return!1}function xx(){try{if(L.version)return parseInt(L.version.split(".")[0],10)>=19}catch{}return!1}var wx=class{constructor(t,{editor:e,props:n={},as:r="div",className:o=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),o&&this.element.classList.add(...o.split(" ")),this.editor.isInitialized?Ui.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var t;const e=this.component,n=this.props,r=this.editor,o=xx(),i=Cx(e),s={...n};s.ref&&!(o||i)&&delete s.ref,!s.ref&&(o||i)&&(s.ref=l=>{this.ref=l}),this.reactElement=g.jsx(e,{...s}),(t=r?.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.props={...this.props,...t},this.render()}destroy(){var t;const e=this.editor;(t=e?.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};L.createContext({markViewContentRef:()=>{}});var Sx=class extends XC{constructor(t,e,n){if(super(t,e,n),!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 t={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:L.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))}},o=this.component,i=L.memo(a=>g.jsx(Wp.Provider,{value:r,children:L.createElement(o,a)}));i.displayName="ReactNodeView";let s=this.node.isInline?"span":"div";this.options.as&&(s=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new wx(i,{editor:this.editor,props:t,as:s,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.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(){const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(t,e,n){const r=o=>{this.renderer.updateProps(o),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const o=this.node,i=this.decorations,s=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:o,oldDecorations:i,newNode:t,newDecorations:e,oldInnerDecorations:s,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n})),!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}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=Kr(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function Xa(t,e){return n=>n.editor.contentComponent?new Sx(t,n,e):{}}const xe=[];for(let t=0;t<256;++t)xe.push((t+256).toString(16).slice(1));function kx(t,e=0){return(xe[t[e+0]]+xe[t[e+1]]+xe[t[e+2]]+xe[t[e+3]]+"-"+xe[t[e+4]]+xe[t[e+5]]+"-"+xe[t[e+6]]+xe[t[e+7]]+"-"+xe[t[e+8]]+xe[t[e+9]]+"-"+xe[t[e+10]]+xe[t[e+11]]+xe[t[e+12]]+xe[t[e+13]]+xe[t[e+14]]+xe[t[e+15]]).toLowerCase()}let Ks;const Ex=new Uint8Array(16);function Mx(){if(!Ks){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ks=crypto.getRandomValues.bind(crypto)}return Ks(Ex)}const Tx=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ad={randomUUID:Tx};function Ax(t,e,n){t=t||{};const r=t.random??t.rng?.()??Mx();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,kx(r)}function Rx(t,e,n){return Ad.randomUUID&&!t?Ad.randomUUID():Ax(t)}var si=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},Ox=/^\s*>\s$/,Nx=Ie.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return si("blockquote",{...te(this.options.HTMLAttributes,t),children:si("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=[];return t.content.forEach(o=>{const s=e.renderChildren(o).split(`
135
135
  `).map(l=>`> ${l}`).join(`
136
136
  `);n.push(s)}),n.flatMap(o=>[o,"> "]).slice(0,-1).join(`
137
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[lr({find:xx,type:this.type})]}}),Sx=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,kx=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Ex=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Mx=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Tx=it.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return ii("strong",{...oe(this.options.HTMLAttributes,t),children:ii("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Nn({find:Sx,type:this.type}),Nn({find:Ex,type:this.type})]},addPasteRules(){return[an({find:kx,type:this.type}),an({find:Mx,type:this.type})]}}),Ax=/(^|[^`])`([^`]+)`(?!`)$/,Rx=/(^|[^`])`([^`]+)`(?!`)/g,Ox=it.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Nn({find:Ax,type:this.type})]},addPasteRules(){return[an({find:Rx,type:this.type})]}}),qs=4,Nx=/^```([a-z]+)?[\s\n]$/,Ix=/^~~~([a-z]+)?[\s\n]$/,Lx=je.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:qs,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",oe(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const o=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${o}`,e.renderChildren(t.content),"```"].join(`
137
+ `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[ar({find:Ox,type:this.type})]}}),Ix=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Lx=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Dx=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Px=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,jx=it.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return si("strong",{...te(this.options.HTMLAttributes,t),children:si("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Nn({find:Ix,type:this.type}),Nn({find:Dx,type:this.type})]},addPasteRules(){return[an({find:Lx,type:this.type}),an({find:Px,type:this.type})]}}),Bx=/(^|[^`])`([^`]+)`(?!`)$/,_x=/(^|[^`])`([^`]+)`(?!`)/g,Hx=it.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",te(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Nn({find:Bx,type:this.type})]},addPasteRules(){return[an({find:_x,type:this.type})]}}),qs=4,Fx=/^```([a-z]+)?[\s\n]$/,$x=/^~~~([a-z]+)?[\s\n]$/,Vx=Ie.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:qs,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",te(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const o=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${o}`,e.renderChildren(t.content),"```"].join(`
138
138
  `):r=`\`\`\`${o}
139
139
 
140
140
  \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:qs,{state:r}=t,{selection:o}=r,{$from:i,empty:s}=o;if(i.parent.type!==this.type)return!1;const l=" ".repeat(n);return s?t.commands.insertContent(l):t.commands.command(({tr:a})=>{const{from:c,to:u}=o,f=r.doc.textBetween(c,u,`
@@ -144,41 +144,41 @@ ${p}`}}),a}function VC(t,e,n={}){const{state:r}=e,{doc:o,tr:i}=r,s=t;o.descendan
144
144
  `);return a.replaceWith(c,u,r.schema.text(f)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:qs,{state:r}=t,{selection:o}=r,{$from:i,empty:s}=o;return i.parent.type!==this.type?!1:s?t.commands.command(({tr:l})=>{var a;const{pos:c}=i,u=i.start(),d=i.end(),f=r.doc.textBetween(u,d,`
145
145
  `,`
146
146
  `).split(`
147
- `);let p=0,m=0;const v=c-u;for(let k=0;k<f.length;k+=1){if(m+f[k].length>=v){p=k;break}m+=f[k].length+1}const C=((a=f[p].match(/^ */))==null?void 0:a[0])||"",x=Math.min(C.length,n);if(x===0)return!0;let w=u;for(let k=0;k<p;k+=1)w+=f[k].length+1;return l.delete(w,w+x),c-w<=x&&l.setSelection(z.create(l.doc,w)),!0}):t.commands.command(({tr:l})=>{const{from:a,to:c}=o,h=r.doc.textBetween(a,c,`
147
+ `);let p=0,m=0;const v=c-u;for(let S=0;S<f.length;S+=1){if(m+f[S].length>=v){p=S;break}m+=f[S].length+1}const C=((a=f[p].match(/^ */))==null?void 0:a[0])||"",x=Math.min(C.length,n);if(x===0)return!0;let w=u;for(let S=0;S<p;S+=1)w+=f[S].length+1;return l.delete(w,w+x),c-w<=x&&l.setSelection(z.create(l.doc,w)),!0}):t.commands.command(({tr:l})=>{const{from:a,to:c}=o,h=r.doc.textBetween(a,c,`
148
148
  `,`
149
149
  `).split(`
150
150
  `).map(f=>{var p;const m=((p=f.match(/^ */))==null?void 0:p[0])||"",v=Math.min(m.length,n);return f.slice(v)}).join(`
151
151
  `);return l.replaceWith(a,c,r.schema.text(h)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
152
152
 
153
- `);return!i||!s?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:o,empty:i}=n;if(!i||o.parent.type!==this.type||!(o.parentOffset===o.parent.nodeSize-2))return!1;const l=o.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(q.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[$l({find:Nx,type:this.type,getAttributes:t=>({language:t[1]})}),$l({find:Ix,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new ae({key:new ge("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,i=o?.mode;if(!n||!i)return!1;const{tr:s,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
154
- `));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(z.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),Dx=je.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
153
+ `);return!i||!s?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:o,empty:i}=n;if(!i||o.parent.type!==this.type||!(o.parentOffset===o.parent.nodeSize-2))return!1;const l=o.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(q.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[$l({find:Fx,type:this.type,getAttributes:t=>({language:t[1]})}),$l({find:$x,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new ae({key:new ge("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,i=o?.mode;if(!n||!i)return!1;const{tr:s,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
154
+ `));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(z.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),zx=Ie.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
155
155
 
156
- `):""}),Px=je.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",oe(this.options.HTMLAttributes,t)]},renderText(){return`
156
+ `):""}),Ux=Ie.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",te(this.options.HTMLAttributes,t)]},renderText(){return`
157
157
  `},renderMarkdown:(t,e)=>e.indent(`
158
- `),parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:o,storedMarks:i}=n;if(o.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=i||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&s){const d=a.filter(h=>l.includes(h.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),jx=je.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,oe(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,o="#".repeat(r);return t.content?`${o} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>$l({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),Hp=je.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",oe(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!PC(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,o=t();return gp(n)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({state:i,tr:s,dispatch:l})=>{if(l){const{$to:a}=s.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?s.setSelection(z.create(s.doc,a.pos+1)):a.nodeAfter.isBlock?s.setSelection(B.create(s.doc,a.pos)):s.setSelection(z.create(s.doc,a.pos));else{const u=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u?.create();d&&(s.insert(c,d),s.setSelection(z.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[DC({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Bx=Hp,_x=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Hx=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Fx=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,$x=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Vx=it.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",oe(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Nn({find:_x,type:this.type}),Nn({find:Fx,type:this.type})]},addPasteRules(){return[an({find:Hx,type:this.type}),an({find:$x,type:this.type})]}});const zx="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Ux="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Ul="numeric",Wl="ascii",Kl="alpha",Or="asciinumeric",Sr="alphanumeric",ql="domain",Fp="emoji",Wx="scheme",Kx="slashscheme",Gs="whitespace";function qx(t,e){return t in e||(e[t]=[]),e[t]}function xn(t,e,n){e[Ul]&&(e[Or]=!0,e[Sr]=!0),e[Wl]&&(e[Or]=!0,e[Kl]=!0),e[Or]&&(e[Sr]=!0),e[Kl]&&(e[Sr]=!0),e[Sr]&&(e[ql]=!0),e[Fp]&&(e[ql]=!0);for(const r in e){const o=qx(r,n);o.indexOf(t)<0&&o.push(t)}}function Gx(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function _e(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}_e.groups={};_e.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const o=e.jr[r][0],i=e.jr[r][1];if(i&&o.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let o=0;o<t.length;o++)this.tt(t[o],e,n,r)},tr(t,e,n,r){r=r||_e.groups;let o;return e&&e.j?o=e:(o=new _e(e),n&&r&&xn(e,n,r)),this.jr.push([t,o]),o},ts(t,e,n,r){let o=this;const i=t.length;if(!i)return o;for(let s=0;s<i-1;s++)o=o.tt(t[s]);return o.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||_e.groups;const o=this;if(e&&e.j)return o.j[t]=e,e;const i=e;let s,l=o.go(t);if(l?(s=new _e,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new _e,i){if(r)if(s.t&&typeof s.t=="string"){const a=Object.assign(Gx(s.t,r),n);xn(i,a,r)}else n&&xn(i,n,r);s.t=i}return o.j[t]=s,s}};const G=(t,e,n,r,o)=>t.ta(e,n,r,o),de=(t,e,n,r,o)=>t.tr(e,n,r,o),xd=(t,e,n,r,o)=>t.ts(e,n,r,o),N=(t,e,n,r,o)=>t.tt(e,n,r,o),kt="WORD",Gl="UWORD",$p="ASCIINUMERICAL",Vp="ALPHANUMERICAL",Kr="LOCALHOST",Jl="TLD",Zl="UTLD",Fo="SCHEME",qn="SLASH_SCHEME",Ya="NUM",Yl="WS",Xa="NL",Nr="OPENBRACE",Ir="CLOSEBRACE",si="OPENBRACKET",li="CLOSEBRACKET",ai="OPENPAREN",ci="CLOSEPAREN",ui="OPENANGLEBRACKET",di="CLOSEANGLEBRACKET",fi="FULLWIDTHLEFTPAREN",hi="FULLWIDTHRIGHTPAREN",pi="LEFTCORNERBRACKET",mi="RIGHTCORNERBRACKET",gi="LEFTWHITECORNERBRACKET",yi="RIGHTWHITECORNERBRACKET",vi="FULLWIDTHLESSTHAN",bi="FULLWIDTHGREATERTHAN",Ci="AMPERSAND",xi="APOSTROPHE",wi="ASTERISK",zt="AT",Si="BACKSLASH",ki="BACKTICK",Ei="CARET",Kt="COLON",Qa="COMMA",Mi="DOLLAR",st="DOT",Ti="EQUALS",ec="EXCLAMATION",Je="HYPHEN",Lr="PERCENT",Ai="PIPE",Ri="PLUS",Oi="POUND",Dr="QUERY",tc="QUOTE",zp="FULLWIDTHMIDDLEDOT",nc="SEMI",lt="SLASH",Pr="TILDE",Ni="UNDERSCORE",Up="EMOJI",Ii="SYM";var Wp=Object.freeze({__proto__:null,ALPHANUMERICAL:Vp,AMPERSAND:Ci,APOSTROPHE:xi,ASCIINUMERICAL:$p,ASTERISK:wi,AT:zt,BACKSLASH:Si,BACKTICK:ki,CARET:Ei,CLOSEANGLEBRACKET:di,CLOSEBRACE:Ir,CLOSEBRACKET:li,CLOSEPAREN:ci,COLON:Kt,COMMA:Qa,DOLLAR:Mi,DOT:st,EMOJI:Up,EQUALS:Ti,EXCLAMATION:ec,FULLWIDTHGREATERTHAN:bi,FULLWIDTHLEFTPAREN:fi,FULLWIDTHLESSTHAN:vi,FULLWIDTHMIDDLEDOT:zp,FULLWIDTHRIGHTPAREN:hi,HYPHEN:Je,LEFTCORNERBRACKET:pi,LEFTWHITECORNERBRACKET:gi,LOCALHOST:Kr,NL:Xa,NUM:Ya,OPENANGLEBRACKET:ui,OPENBRACE:Nr,OPENBRACKET:si,OPENPAREN:ai,PERCENT:Lr,PIPE:Ai,PLUS:Ri,POUND:Oi,QUERY:Dr,QUOTE:tc,RIGHTCORNERBRACKET:mi,RIGHTWHITECORNERBRACKET:yi,SCHEME:Fo,SEMI:nc,SLASH:lt,SLASH_SCHEME:qn,SYM:Ii,TILDE:Pr,TLD:Jl,UNDERSCORE:Ni,UTLD:Zl,UWORD:Gl,WORD:kt,WS:Yl});const wt=/[a-z]/,vr=new RegExp("\\p{L}","u"),Js=new RegExp("\\p{Emoji}","u"),St=/\d/,Zs=/\s/,wd="\r",Ys=`
159
- `,Jx="️",Zx="‍",Xs="";let ko=null,Eo=null;function Yx(t=[]){const e={};_e.groups=e;const n=new _e;ko==null&&(ko=Sd(zx)),Eo==null&&(Eo=Sd(Ux)),N(n,"'",xi),N(n,"{",Nr),N(n,"}",Ir),N(n,"[",si),N(n,"]",li),N(n,"(",ai),N(n,")",ci),N(n,"<",ui),N(n,">",di),N(n,"(",fi),N(n,")",hi),N(n,"「",pi),N(n,"」",mi),N(n,"『",gi),N(n,"』",yi),N(n,"<",vi),N(n,">",bi),N(n,"&",Ci),N(n,"*",wi),N(n,"@",zt),N(n,"`",ki),N(n,"^",Ei),N(n,":",Kt),N(n,",",Qa),N(n,"$",Mi),N(n,".",st),N(n,"=",Ti),N(n,"!",ec),N(n,"-",Je),N(n,"%",Lr),N(n,"|",Ai),N(n,"+",Ri),N(n,"#",Oi),N(n,"?",Dr),N(n,'"',tc),N(n,"/",lt),N(n,";",nc),N(n,"~",Pr),N(n,"_",Ni),N(n,"\\",Si),N(n,"・",zp);const r=de(n,St,Ya,{[Ul]:!0});de(r,St,r);const o=de(r,wt,$p,{[Or]:!0}),i=de(r,vr,Vp,{[Sr]:!0}),s=de(n,wt,kt,{[Wl]:!0});de(s,St,o),de(s,wt,s),de(o,St,o),de(o,wt,o);const l=de(n,vr,Gl,{[Kl]:!0});de(l,wt),de(l,St,i),de(l,vr,l),de(i,St,i),de(i,wt),de(i,vr,i);const a=N(n,Ys,Xa,{[Gs]:!0}),c=N(n,wd,Yl,{[Gs]:!0}),u=de(n,Zs,Yl,{[Gs]:!0});N(n,Xs,u),N(c,Ys,a),N(c,Xs,u),de(c,Zs,u),N(u,wd),N(u,Ys),de(u,Zs,u),N(u,Xs,u);const d=de(n,Js,Up,{[Fp]:!0});N(d,"#"),de(d,Js,d),N(d,Jx,d);const h=N(d,Zx);N(h,"#"),de(h,Js,d);const f=[[wt,s],[St,o]],p=[[wt,null],[vr,l],[St,i]];for(let m=0;m<ko.length;m++)_t(n,ko[m],Jl,kt,f);for(let m=0;m<Eo.length;m++)_t(n,Eo[m],Zl,Gl,p);xn(Jl,{tld:!0,ascii:!0},e),xn(Zl,{utld:!0,alpha:!0},e),_t(n,"file",Fo,kt,f),_t(n,"mailto",Fo,kt,f),_t(n,"http",qn,kt,f),_t(n,"https",qn,kt,f),_t(n,"ftp",qn,kt,f),_t(n,"ftps",qn,kt,f),xn(Fo,{scheme:!0,ascii:!0},e),xn(qn,{slashscheme:!0,ascii:!0},e),t=t.sort((m,v)=>m[0]>v[0]?1:-1);for(let m=0;m<t.length;m++){const v=t[m][0],C=t[m][1]?{[Wx]:!0}:{[Kx]:!0};v.indexOf("-")>=0?C[ql]=!0:wt.test(v)?St.test(v)?C[Or]=!0:C[Wl]=!0:C[Ul]=!0,xd(n,v,v,C)}return xd(n,"localhost",Kr,{ascii:!0}),n.jd=new _e(Ii),{start:n,tokens:Object.assign({groups:e},Wp)}}function Kp(t,e){const n=Xx(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,o=[];let i=0,s=0;for(;s<r;){let l=t,a=null,c=0,u=null,d=-1,h=-1;for(;s<r&&(a=l.go(n[s]));)l=a,l.accepts()?(d=0,h=0,u=l):d>=0&&(d+=n[s].length,h++),c+=n[s].length,i+=n[s].length,s++;i-=d,s-=h,c-=d,o.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return o}function Xx(t){const e=[],n=t.length;let r=0;for(;r<n;){let o=t.charCodeAt(r),i,s=o<55296||o>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function _t(t,e,n,r,o){let i;const s=e.length;for(let l=0;l<s-1;l++){const a=e[l];t.j[a]?i=t.j[a]:(i=new _e(r),i.jr=o.slice(),t.j[a]=i),t=i}return i=new _e(n),i.jr=o.slice(),t.j[e[s-1]]=i,i}function Sd(t){const e=[],n=[];let r=0,o="0123456789";for(;r<t.length;){let i=0;for(;o.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+i),10);s>0;s--)n.pop();r+=i}else n.push(t[r]),r++}return e}const qr={defaultProtocol:"http",events:null,format:kd,formatHref:kd,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function rc(t,e=null){let n=Object.assign({},qr);t&&(n=Object.assign(n,t instanceof rc?t.o:t));const r=n.ignoreTags,o=[];for(let i=0;i<r.length;i++)o.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=o}rc.prototype={o:qr,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let o=this.o[t];return o&&(typeof o=="object"?(o=n.t in o?o[n.t]:qr[t],typeof o=="function"&&r&&(o=o(e,n))):typeof o=="function"&&r&&(o=o(e,n.t,n)),o)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function kd(t){return t}function qp(t,e){this.t="token",this.v=t,this.tk=e}qp.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=qr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),o=t.get("tagName",n,e),i=this.toFormattedString(t),s={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:o,attributes:s,content:i,eventListeners:d}}};function is(t,e){class n extends qp{constructor(o,i){super(o,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const Ed=is("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Md=is("text"),Qx=is("nl"),Mo=is("url",{isLink:!0,toHref(t=qr.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Kr&&t[1].t===Kt}}),qe=t=>new _e(t);function ew({groups:t}){const e=t.domain.concat([Ci,wi,zt,Si,ki,Ei,Mi,Ti,Je,Ya,Lr,Ai,Ri,Oi,lt,Ii,Pr,Ni]),n=[xi,Kt,Qa,st,ec,Lr,Dr,tc,nc,ui,di,Nr,Ir,li,si,ai,ci,fi,hi,pi,mi,gi,yi,vi,bi],r=[Ci,xi,wi,Si,ki,Ei,Mi,Ti,Je,Nr,Ir,Lr,Ai,Ri,Oi,Dr,lt,Ii,Pr,Ni],o=qe(),i=N(o,Pr);G(i,r,i),G(i,t.domain,i);const s=qe(),l=qe(),a=qe();G(o,t.domain,s),G(o,t.scheme,l),G(o,t.slashscheme,a),G(s,r,i),G(s,t.domain,s);const c=N(s,zt);N(i,zt,c),N(l,zt,c),N(a,zt,c);const u=N(i,st);G(u,r,i),G(u,t.domain,i);const d=qe();G(c,t.domain,d),G(d,t.domain,d);const h=N(d,st);G(h,t.domain,d);const f=qe(Ed);G(h,t.tld,f),G(h,t.utld,f),N(c,Kr,f);const p=N(d,Je);N(p,Je,p),G(p,t.domain,d),G(f,t.domain,d),N(f,st,h),N(f,Je,p);const m=N(f,Kt);G(m,t.numeric,Ed);const v=N(s,Je),b=N(s,st);N(v,Je,v),G(v,t.domain,s),G(b,r,i),G(b,t.domain,s);const C=qe(Mo);G(b,t.tld,C),G(b,t.utld,C),G(C,t.domain,s),G(C,r,i),N(C,st,b),N(C,Je,v),N(C,zt,c);const x=N(C,Kt),w=qe(Mo);G(x,t.numeric,w);const E=qe(Mo),k=qe();G(E,e,E),G(E,n,k),G(k,e,E),G(k,n,k),N(C,lt,E),N(w,lt,E);const S=N(l,Kt),M=N(a,Kt),I=N(M,lt),j=N(I,lt);G(l,t.domain,s),N(l,st,b),N(l,Je,v),G(a,t.domain,s),N(a,st,b),N(a,Je,v),G(S,t.domain,E),N(S,lt,E),N(S,Dr,E),G(j,t.domain,E),G(j,e,E),N(j,lt,E);const _=[[Nr,Ir],[si,li],[ai,ci],[ui,di],[fi,hi],[pi,mi],[gi,yi],[vi,bi]];for(let U=0;U<_.length;U++){const[F,O]=_[U],H=N(E,F);N(k,F,H),N(H,O,E);const V=qe(Mo);G(H,e,V);const L=qe();G(H,n),G(V,e,V),G(V,n,L),G(L,e,V),G(L,n,L),N(V,O,E),N(L,O,E)}return N(o,Kr,C),N(o,Xa,Qx),{start:o,tokens:Wp}}function tw(t,e,n){let r=n.length,o=0,i=[],s=[];for(;o<r;){let l=t,a=null,c=null,u=0,d=null,h=-1;for(;o<r&&!(a=l.go(n[o].t));)s.push(n[o++]);for(;o<r&&(c=a||l.go(n[o].t));)a=null,l=c,l.accepts()?(h=0,d=l):h>=0&&h++,o++,u++;if(h<0)o-=u,o<r&&(s.push(n[o]),o++);else{s.length>0&&(i.push(Qs(Md,e,s)),s=[]),o-=h,u-=h;const f=d.t,p=n.slice(o-u,o);i.push(Qs(f,e,p))}}return s.length>0&&i.push(Qs(Md,e,s)),i}function Qs(t,e,n){const r=n[0].s,o=n[n.length-1].e,i=e.slice(r,o);return new t(i,n)}const nw=typeof console<"u"&&console&&console.warn||(()=>{}),rw="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",se={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function ow(){return _e.groups={},se.scanner=null,se.parser=null,se.tokenQueue=[],se.pluginQueue=[],se.customSchemes=[],se.initialized=!1,se}function Td(t,e=!1){if(se.initialized&&nw(`linkifyjs: already initialized - will not register custom scheme "${t}" ${rw}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
158
+ `),parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:o,storedMarks:i}=n;if(o.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=i||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&s){const d=a.filter(h=>l.includes(h.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Wx=Ie.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,te(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,o="#".repeat(r);return t.content?`${o} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>$l({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),Kp=Ie.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",te(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!UC(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,o=t();return Ep(n)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({state:i,tr:s,dispatch:l})=>{if(l){const{$to:a}=s.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?s.setSelection(z.create(s.doc,a.pos+1)):a.nodeAfter.isBlock?s.setSelection(B.create(s.doc,a.pos)):s.setSelection(z.create(s.doc,a.pos));else{const u=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u?.create();d&&(s.insert(c,d),s.setSelection(z.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[zC({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Kx=Kp,qx=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Gx=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Jx=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Zx=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Yx=it.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",te(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Nn({find:qx,type:this.type}),Nn({find:Jx,type:this.type})]},addPasteRules(){return[an({find:Gx,type:this.type}),an({find:Zx,type:this.type})]}});const Xx="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Qx="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Ul="numeric",Wl="ascii",Kl="alpha",Nr="asciinumeric",kr="alphanumeric",ql="domain",qp="emoji",ew="scheme",tw="slashscheme",Gs="whitespace";function nw(t,e){return t in e||(e[t]=[]),e[t]}function xn(t,e,n){e[Ul]&&(e[Nr]=!0,e[kr]=!0),e[Wl]&&(e[Nr]=!0,e[Kl]=!0),e[Nr]&&(e[kr]=!0),e[Kl]&&(e[kr]=!0),e[kr]&&(e[ql]=!0),e[qp]&&(e[ql]=!0);for(const r in e){const o=nw(r,n);o.indexOf(t)<0&&o.push(t)}}function rw(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function _e(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}_e.groups={};_e.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const o=e.jr[r][0],i=e.jr[r][1];if(i&&o.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let o=0;o<t.length;o++)this.tt(t[o],e,n,r)},tr(t,e,n,r){r=r||_e.groups;let o;return e&&e.j?o=e:(o=new _e(e),n&&r&&xn(e,n,r)),this.jr.push([t,o]),o},ts(t,e,n,r){let o=this;const i=t.length;if(!i)return o;for(let s=0;s<i-1;s++)o=o.tt(t[s]);return o.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||_e.groups;const o=this;if(e&&e.j)return o.j[t]=e,e;const i=e;let s,l=o.go(t);if(l?(s=new _e,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new _e,i){if(r)if(s.t&&typeof s.t=="string"){const a=Object.assign(rw(s.t,r),n);xn(i,a,r)}else n&&xn(i,n,r);s.t=i}return o.j[t]=s,s}};const G=(t,e,n,r,o)=>t.ta(e,n,r,o),de=(t,e,n,r,o)=>t.tr(e,n,r,o),Rd=(t,e,n,r,o)=>t.ts(e,n,r,o),N=(t,e,n,r,o)=>t.tt(e,n,r,o),Et="WORD",Gl="UWORD",Gp="ASCIINUMERICAL",Jp="ALPHANUMERICAL",qr="LOCALHOST",Jl="TLD",Zl="UTLD",$o="SCHEME",Gn="SLASH_SCHEME",Qa="NUM",Yl="WS",ec="NL",Ir="OPENBRACE",Lr="CLOSEBRACE",li="OPENBRACKET",ai="CLOSEBRACKET",ci="OPENPAREN",ui="CLOSEPAREN",di="OPENANGLEBRACKET",fi="CLOSEANGLEBRACKET",hi="FULLWIDTHLEFTPAREN",pi="FULLWIDTHRIGHTPAREN",mi="LEFTCORNERBRACKET",gi="RIGHTCORNERBRACKET",yi="LEFTWHITECORNERBRACKET",vi="RIGHTWHITECORNERBRACKET",bi="FULLWIDTHLESSTHAN",Ci="FULLWIDTHGREATERTHAN",xi="AMPERSAND",wi="APOSTROPHE",Si="ASTERISK",zt="AT",ki="BACKSLASH",Ei="BACKTICK",Mi="CARET",Kt="COLON",tc="COMMA",Ti="DOLLAR",st="DOT",Ai="EQUALS",nc="EXCLAMATION",Je="HYPHEN",Dr="PERCENT",Ri="PIPE",Oi="PLUS",Ni="POUND",Pr="QUERY",rc="QUOTE",Zp="FULLWIDTHMIDDLEDOT",oc="SEMI",lt="SLASH",jr="TILDE",Ii="UNDERSCORE",Yp="EMOJI",Li="SYM";var Xp=Object.freeze({__proto__:null,ALPHANUMERICAL:Jp,AMPERSAND:xi,APOSTROPHE:wi,ASCIINUMERICAL:Gp,ASTERISK:Si,AT:zt,BACKSLASH:ki,BACKTICK:Ei,CARET:Mi,CLOSEANGLEBRACKET:fi,CLOSEBRACE:Lr,CLOSEBRACKET:ai,CLOSEPAREN:ui,COLON:Kt,COMMA:tc,DOLLAR:Ti,DOT:st,EMOJI:Yp,EQUALS:Ai,EXCLAMATION:nc,FULLWIDTHGREATERTHAN:Ci,FULLWIDTHLEFTPAREN:hi,FULLWIDTHLESSTHAN:bi,FULLWIDTHMIDDLEDOT:Zp,FULLWIDTHRIGHTPAREN:pi,HYPHEN:Je,LEFTCORNERBRACKET:mi,LEFTWHITECORNERBRACKET:yi,LOCALHOST:qr,NL:ec,NUM:Qa,OPENANGLEBRACKET:di,OPENBRACE:Ir,OPENBRACKET:li,OPENPAREN:ci,PERCENT:Dr,PIPE:Ri,PLUS:Oi,POUND:Ni,QUERY:Pr,QUOTE:rc,RIGHTCORNERBRACKET:gi,RIGHTWHITECORNERBRACKET:vi,SCHEME:$o,SEMI:oc,SLASH:lt,SLASH_SCHEME:Gn,SYM:Li,TILDE:jr,TLD:Jl,UNDERSCORE:Ii,UTLD:Zl,UWORD:Gl,WORD:Et,WS:Yl});const St=/[a-z]/,br=new RegExp("\\p{L}","u"),Js=new RegExp("\\p{Emoji}","u"),kt=/\d/,Zs=/\s/,Od="\r",Ys=`
159
+ `,ow="️",iw="‍",Xs="";let Eo=null,Mo=null;function sw(t=[]){const e={};_e.groups=e;const n=new _e;Eo==null&&(Eo=Nd(Xx)),Mo==null&&(Mo=Nd(Qx)),N(n,"'",wi),N(n,"{",Ir),N(n,"}",Lr),N(n,"[",li),N(n,"]",ai),N(n,"(",ci),N(n,")",ui),N(n,"<",di),N(n,">",fi),N(n,"(",hi),N(n,")",pi),N(n,"「",mi),N(n,"」",gi),N(n,"『",yi),N(n,"』",vi),N(n,"<",bi),N(n,">",Ci),N(n,"&",xi),N(n,"*",Si),N(n,"@",zt),N(n,"`",Ei),N(n,"^",Mi),N(n,":",Kt),N(n,",",tc),N(n,"$",Ti),N(n,".",st),N(n,"=",Ai),N(n,"!",nc),N(n,"-",Je),N(n,"%",Dr),N(n,"|",Ri),N(n,"+",Oi),N(n,"#",Ni),N(n,"?",Pr),N(n,'"',rc),N(n,"/",lt),N(n,";",oc),N(n,"~",jr),N(n,"_",Ii),N(n,"\\",ki),N(n,"・",Zp);const r=de(n,kt,Qa,{[Ul]:!0});de(r,kt,r);const o=de(r,St,Gp,{[Nr]:!0}),i=de(r,br,Jp,{[kr]:!0}),s=de(n,St,Et,{[Wl]:!0});de(s,kt,o),de(s,St,s),de(o,kt,o),de(o,St,o);const l=de(n,br,Gl,{[Kl]:!0});de(l,St),de(l,kt,i),de(l,br,l),de(i,kt,i),de(i,St),de(i,br,i);const a=N(n,Ys,ec,{[Gs]:!0}),c=N(n,Od,Yl,{[Gs]:!0}),u=de(n,Zs,Yl,{[Gs]:!0});N(n,Xs,u),N(c,Ys,a),N(c,Xs,u),de(c,Zs,u),N(u,Od),N(u,Ys),de(u,Zs,u),N(u,Xs,u);const d=de(n,Js,Yp,{[qp]:!0});N(d,"#"),de(d,Js,d),N(d,ow,d);const h=N(d,iw);N(h,"#"),de(h,Js,d);const f=[[St,s],[kt,o]],p=[[St,null],[br,l],[kt,i]];for(let m=0;m<Eo.length;m++)_t(n,Eo[m],Jl,Et,f);for(let m=0;m<Mo.length;m++)_t(n,Mo[m],Zl,Gl,p);xn(Jl,{tld:!0,ascii:!0},e),xn(Zl,{utld:!0,alpha:!0},e),_t(n,"file",$o,Et,f),_t(n,"mailto",$o,Et,f),_t(n,"http",Gn,Et,f),_t(n,"https",Gn,Et,f),_t(n,"ftp",Gn,Et,f),_t(n,"ftps",Gn,Et,f),xn($o,{scheme:!0,ascii:!0},e),xn(Gn,{slashscheme:!0,ascii:!0},e),t=t.sort((m,v)=>m[0]>v[0]?1:-1);for(let m=0;m<t.length;m++){const v=t[m][0],C=t[m][1]?{[ew]:!0}:{[tw]:!0};v.indexOf("-")>=0?C[ql]=!0:St.test(v)?kt.test(v)?C[Nr]=!0:C[Wl]=!0:C[Ul]=!0,Rd(n,v,v,C)}return Rd(n,"localhost",qr,{ascii:!0}),n.jd=new _e(Li),{start:n,tokens:Object.assign({groups:e},Xp)}}function Qp(t,e){const n=lw(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,o=[];let i=0,s=0;for(;s<r;){let l=t,a=null,c=0,u=null,d=-1,h=-1;for(;s<r&&(a=l.go(n[s]));)l=a,l.accepts()?(d=0,h=0,u=l):d>=0&&(d+=n[s].length,h++),c+=n[s].length,i+=n[s].length,s++;i-=d,s-=h,c-=d,o.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return o}function lw(t){const e=[],n=t.length;let r=0;for(;r<n;){let o=t.charCodeAt(r),i,s=o<55296||o>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function _t(t,e,n,r,o){let i;const s=e.length;for(let l=0;l<s-1;l++){const a=e[l];t.j[a]?i=t.j[a]:(i=new _e(r),i.jr=o.slice(),t.j[a]=i),t=i}return i=new _e(n),i.jr=o.slice(),t.j[e[s-1]]=i,i}function Nd(t){const e=[],n=[];let r=0,o="0123456789";for(;r<t.length;){let i=0;for(;o.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+i),10);s>0;s--)n.pop();r+=i}else n.push(t[r]),r++}return e}const Gr={defaultProtocol:"http",events:null,format:Id,formatHref:Id,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ic(t,e=null){let n=Object.assign({},Gr);t&&(n=Object.assign(n,t instanceof ic?t.o:t));const r=n.ignoreTags,o=[];for(let i=0;i<r.length;i++)o.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=o}ic.prototype={o:Gr,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let o=this.o[t];return o&&(typeof o=="object"?(o=n.t in o?o[n.t]:Gr[t],typeof o=="function"&&r&&(o=o(e,n))):typeof o=="function"&&r&&(o=o(e,n.t,n)),o)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Id(t){return t}function em(t,e){this.t="token",this.v=t,this.tk=e}em.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Gr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),o=t.get("tagName",n,e),i=this.toFormattedString(t),s={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:o,attributes:s,content:i,eventListeners:d}}};function is(t,e){class n extends em{constructor(o,i){super(o,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const Ld=is("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Dd=is("text"),aw=is("nl"),To=is("url",{isLink:!0,toHref(t=Gr.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==qr&&t[1].t===Kt}}),qe=t=>new _e(t);function cw({groups:t}){const e=t.domain.concat([xi,Si,zt,ki,Ei,Mi,Ti,Ai,Je,Qa,Dr,Ri,Oi,Ni,lt,Li,jr,Ii]),n=[wi,Kt,tc,st,nc,Dr,Pr,rc,oc,di,fi,Ir,Lr,ai,li,ci,ui,hi,pi,mi,gi,yi,vi,bi,Ci],r=[xi,wi,Si,ki,Ei,Mi,Ti,Ai,Je,Ir,Lr,Dr,Ri,Oi,Ni,Pr,lt,Li,jr,Ii],o=qe(),i=N(o,jr);G(i,r,i),G(i,t.domain,i);const s=qe(),l=qe(),a=qe();G(o,t.domain,s),G(o,t.scheme,l),G(o,t.slashscheme,a),G(s,r,i),G(s,t.domain,s);const c=N(s,zt);N(i,zt,c),N(l,zt,c),N(a,zt,c);const u=N(i,st);G(u,r,i),G(u,t.domain,i);const d=qe();G(c,t.domain,d),G(d,t.domain,d);const h=N(d,st);G(h,t.domain,d);const f=qe(Ld);G(h,t.tld,f),G(h,t.utld,f),N(c,qr,f);const p=N(d,Je);N(p,Je,p),G(p,t.domain,d),G(f,t.domain,d),N(f,st,h),N(f,Je,p);const m=N(f,Kt);G(m,t.numeric,Ld);const v=N(s,Je),b=N(s,st);N(v,Je,v),G(v,t.domain,s),G(b,r,i),G(b,t.domain,s);const C=qe(To);G(b,t.tld,C),G(b,t.utld,C),G(C,t.domain,s),G(C,r,i),N(C,st,b),N(C,Je,v),N(C,zt,c);const x=N(C,Kt),w=qe(To);G(x,t.numeric,w);const E=qe(To),S=qe();G(E,e,E),G(E,n,S),G(S,e,E),G(S,n,S),N(C,lt,E),N(w,lt,E);const k=N(l,Kt),M=N(a,Kt),I=N(M,lt),P=N(I,lt);G(l,t.domain,s),N(l,st,b),N(l,Je,v),G(a,t.domain,s),N(a,st,b),N(a,Je,v),G(k,t.domain,E),N(k,lt,E),N(k,Pr,E),G(P,t.domain,E),G(P,e,E),N(P,lt,E);const _=[[Ir,Lr],[li,ai],[ci,ui],[di,fi],[hi,pi],[mi,gi],[yi,vi],[bi,Ci]];for(let U=0;U<_.length;U++){const[F,O]=_[U],H=N(E,F);N(S,F,H),N(H,O,E);const V=qe(To);G(H,e,V);const D=qe();G(H,n),G(V,e,V),G(V,n,D),G(D,e,V),G(D,n,D),N(V,O,E),N(D,O,E)}return N(o,qr,C),N(o,ec,aw),{start:o,tokens:Xp}}function uw(t,e,n){let r=n.length,o=0,i=[],s=[];for(;o<r;){let l=t,a=null,c=null,u=0,d=null,h=-1;for(;o<r&&!(a=l.go(n[o].t));)s.push(n[o++]);for(;o<r&&(c=a||l.go(n[o].t));)a=null,l=c,l.accepts()?(h=0,d=l):h>=0&&h++,o++,u++;if(h<0)o-=u,o<r&&(s.push(n[o]),o++);else{s.length>0&&(i.push(Qs(Dd,e,s)),s=[]),o-=h,u-=h;const f=d.t,p=n.slice(o-u,o);i.push(Qs(f,e,p))}}return s.length>0&&i.push(Qs(Dd,e,s)),i}function Qs(t,e,n){const r=n[0].s,o=n[n.length-1].e,i=e.slice(r,o);return new t(i,n)}const dw=typeof console<"u"&&console&&console.warn||(()=>{}),fw="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",le={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function hw(){return _e.groups={},le.scanner=null,le.parser=null,le.tokenQueue=[],le.pluginQueue=[],le.customSchemes=[],le.initialized=!1,le}function Pd(t,e=!1){if(le.initialized&&dw(`linkifyjs: already initialized - will not register custom scheme "${t}" ${fw}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
160
160
  1. Must only contain digits, lowercase ASCII letters or "-"
161
161
  2. Cannot start or end with "-"
162
- 3. "-" cannot repeat`);se.customSchemes.push([t,e])}function iw(){se.scanner=Yx(se.customSchemes);for(let t=0;t<se.tokenQueue.length;t++)se.tokenQueue[t][1]({scanner:se.scanner});se.parser=ew(se.scanner.tokens);for(let t=0;t<se.pluginQueue.length;t++)se.pluginQueue[t][1]({scanner:se.scanner,parser:se.parser});return se.initialized=!0,se}function oc(t){return se.initialized||iw(),tw(se.parser.start,t,Kp(se.scanner.start,t))}oc.scan=Kp;function Gp(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new rc(n),o=oc(t),i=[];for(let s=0;s<o.length;s++){const l=o[s];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var ic="[\0-   ᠎ -\u2029  ]",sw=new RegExp(ic),lw=new RegExp(`${ic}$`),aw=new RegExp(ic,"g");function cw(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function uw(t){return new ae({key:new ge("autolink"),appendTransaction:(e,n,r)=>{const o=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!o||i)return;const{tr:s}=r,l=$a(n.doc,[...e]);if(Ua(l).forEach(({newRange:c})=>{const u=cp(r.doc,c,f=>f.isTextblock);let d,h;if(u.length>1)d=u[0],h=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const f=r.doc.textBetween(c.from,c.to," "," ");if(!lw.test(f))return;d=u[0],h=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&h){const f=h.split(sw).filter(Boolean);if(f.length<=0)return!1;const p=f[f.length-1],m=d.pos+h.lastIndexOf(p);if(!p)return!1;const v=oc(p).map(b=>b.toObject(t.defaultProtocol));if(!cw(v))return!1;v.filter(b=>b.isLink).map(b=>({...b,from:m+b.start+1,to:m+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{Wa(b.from,b.to,r.doc).some(C=>C.mark.type===t.type)||s.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!s.steps.length)return s}})}function dw(t){return new ae({key:new ge("handleClickLink"),props:{handleClick:(e,n,r)=>{var o,i;if(r.button!==0||!e.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{let u=r.target;const d=[];for(;u.nodeName!=="DIV";)d.push(u),u=u.parentNode;s=d.find(h=>h.nodeName==="A")}if(!s)return!1;const l=mp(e.state,t.type.name),a=(o=s?.href)!=null?o:l.href,c=(i=s?.target)!=null?i:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),s&&a?(window.open(a,c),!0):!1}}})}function fw(t){return new ae({key:new ge("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:o}=t,{state:i}=e,{selection:s}=i,{empty:l}=s;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const c=Gp(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||o!==void 0&&!o(c.href)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function mn(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!t||t.replace(aw,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var hw=it.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Td(t);return}Td(t.scheme,t.optionalSlashes)})},onDestroy(){ow()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!mn(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!mn(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!mn(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",oe(this.options.HTMLAttributes,t),0]:["a",oe(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!mn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!mn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[an({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,o=Gp(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!mn(s,n),protocols:n,defaultProtocol:r}));o.length&&o.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(uw({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!mn(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(dw({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(fw({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),pw=Object.defineProperty,mw=(t,e)=>{for(var n in e)pw(t,n,{get:e[n],enumerable:!0})},gw="listItem",Ad="textStyle",Rd=/^\s*([-+*])\s$/,Jp=je.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
163
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(gw,this.editor.getAttributes(Ad)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=lr({find:Rd,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=lr({find:Rd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ad),editor:this.editor})),[t]}}),Zp=je.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(o=>o.type==="paragraph"))n=e.parseChildren(t.tokens);else{const o=t.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){const s=t.tokens.slice(1),l=e.parseChildren(s);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Ja(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),yw={};mw(yw,{findListItemPos:()=>io,getNextListDepth:()=>sc,handleBackspace:()=>Xl,handleDelete:()=>Ql,hasListBefore:()=>Yp,hasListItemAfter:()=>vw,hasListItemBefore:()=>Xp,listItemHasSubList:()=>Qp,nextListIsDeeper:()=>em,nextListIsHigher:()=>tm});var io=(t,e)=>{const{$from:n}=e.selection,r=me(t,e.schema);let o=null,i=n.depth,s=n.pos,l=null;for(;i>0&&l===null;)o=n.node(i),o.type===r?l=i:(i-=1,s-=1);return l===null?null:{$pos:e.doc.resolve(s),depth:l}},sc=(t,e)=>{const n=io(t,e);if(!n)return!1;const[,r]=Wb(e,t,n.$pos.pos+4);return r},Yp=(t,e,n)=>{const{$anchor:r}=t.selection,o=Math.max(0,r.pos-2),i=t.doc.resolve(o).node();return!(!i||!n.includes(i.type.name))},Xp=(t,e)=>{var n;const{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-2);return!(o.index()===0||((n=o.nodeBefore)==null?void 0:n.type.name)!==t)},Qp=(t,e,n)=>{if(!n)return!1;const r=me(t,e.schema);let o=!1;return n.descendants(i=>{i.type===r&&(o=!0)}),o},Xl=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ln(t.state,e)&&Yp(t.state,e,n)){const{$anchor:l}=t.state.selection,a=t.state.doc.resolve(l.before()-1),c=[];a.node().descendants((h,f)=>{h.type.name===e&&c.push({node:h,pos:f})});const u=c.at(-1);if(!u)return!1;const d=t.state.doc.resolve(a.start()+u.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},d.end()).joinForward().run()}if(!ln(t.state,e)||!Jb(t.state))return!1;const r=io(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=Qp(e,t.state,i);return Xp(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},em=(t,e)=>{const n=sc(t,e),r=io(t,e);return!r||!n?!1:n>r.depth},tm=(t,e)=>{const n=sc(t,e),r=io(t,e);return!r||!n?!1:n<r.depth},Ql=(t,e)=>{if(!ln(t.state,e)||!Gb(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:em(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():tm(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},vw=(t,e)=>{var n;const{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-r.parentOffset-2);return!(o.index()===o.parent.childCount-1||((n=o.nodeAfter)==null?void 0:n.type.name)!==t)},nm=Z.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Ql(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Ql(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Xl(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Xl(t,n,r)&&(e=!0)}),e}}}}),Od=/^(\s*)(\d+)\.\s+(.*)$/,bw=/^\s/;function Cw(t){const e=[];let n=0,r=0;for(;n<t.length;){const o=t[n],i=o.match(Od);if(!i)break;const[,s,l,a]=i,c=s.length;let u=a,d=n+1;const h=[o];for(;d<t.length;){const f=t[d];if(f.match(Od))break;if(f.trim()==="")h.push(f),u+=`
164
- `,d+=1;else if(f.match(bw))h.push(f),u+=`
162
+ 3. "-" cannot repeat`);le.customSchemes.push([t,e])}function pw(){le.scanner=sw(le.customSchemes);for(let t=0;t<le.tokenQueue.length;t++)le.tokenQueue[t][1]({scanner:le.scanner});le.parser=cw(le.scanner.tokens);for(let t=0;t<le.pluginQueue.length;t++)le.pluginQueue[t][1]({scanner:le.scanner,parser:le.parser});return le.initialized=!0,le}function sc(t){return le.initialized||pw(),uw(le.parser.start,t,Qp(le.scanner.start,t))}sc.scan=Qp;function tm(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new ic(n),o=sc(t),i=[];for(let s=0;s<o.length;s++){const l=o[s];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var lc="[\0-   ᠎ -\u2029  ]",mw=new RegExp(lc),gw=new RegExp(`${lc}$`),yw=new RegExp(lc,"g");function vw(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function bw(t){return new ae({key:new ge("autolink"),appendTransaction:(e,n,r)=>{const o=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!o||i)return;const{tr:s}=r,l=$a(n.doc,[...e]);if(Ua(l).forEach(({newRange:c})=>{const u=vp(r.doc,c,f=>f.isTextblock);let d,h;if(u.length>1)d=u[0],h=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const f=r.doc.textBetween(c.from,c.to," "," ");if(!gw.test(f))return;d=u[0],h=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&h){const f=h.split(mw).filter(Boolean);if(f.length<=0)return!1;const p=f[f.length-1],m=d.pos+h.lastIndexOf(p);if(!p)return!1;const v=sc(p).map(b=>b.toObject(t.defaultProtocol));if(!vw(v))return!1;v.filter(b=>b.isLink).map(b=>({...b,from:m+b.start+1,to:m+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{Wa(b.from,b.to,r.doc).some(C=>C.mark.type===t.type)||s.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!s.steps.length)return s}})}function Cw(t){return new ae({key:new ge("handleClickLink"),props:{handleClick:(e,n,r)=>{var o,i;if(r.button!==0||!e.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{let u=r.target;const d=[];for(;u.nodeName!=="DIV";)d.push(u),u=u.parentNode;s=d.find(h=>h.nodeName==="A")}if(!s)return!1;const l=kp(e.state,t.type.name),a=(o=s?.href)!=null?o:l.href,c=(i=s?.target)!=null?i:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),s&&a?(window.open(a,c),!0):!1}}})}function xw(t){return new ae({key:new ge("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:o}=t,{state:i}=e,{selection:s}=i,{empty:l}=s;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const c=tm(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||o!==void 0&&!o(c.href)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function mn(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!t||t.replace(yw,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var ww=it.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Pd(t);return}Pd(t.scheme,t.optionalSlashes)})},onDestroy(){hw()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!mn(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!mn(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!mn(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",te(this.options.HTMLAttributes,t),0]:["a",te(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!mn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!mn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[an({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,o=tm(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!mn(s,n),protocols:n,defaultProtocol:r}));o.length&&o.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(bw({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!mn(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(Cw({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(xw({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),Sw=Object.defineProperty,kw=(t,e)=>{for(var n in e)Sw(t,n,{get:e[n],enumerable:!0})},Ew="listItem",jd="textStyle",Bd=/^\s*([-+*])\s$/,nm=Ie.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",te(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
163
+ `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ew,this.editor.getAttributes(jd)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ar({find:Bd,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ar({find:Bd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(jd),editor:this.editor})),[t]}}),rm=Ie.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",te(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(o=>o.type==="paragraph"))n=e.parseChildren(t.tokens);else{const o=t.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){const s=t.tokens.slice(1),l=e.parseChildren(s);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Ja(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Mw={};kw(Mw,{findListItemPos:()=>lo,getNextListDepth:()=>ac,handleBackspace:()=>Xl,handleDelete:()=>Ql,hasListBefore:()=>om,hasListItemAfter:()=>Tw,hasListItemBefore:()=>im,listItemHasSubList:()=>sm,nextListIsDeeper:()=>lm,nextListIsHigher:()=>am});var lo=(t,e)=>{const{$from:n}=e.selection,r=me(t,e.schema);let o=null,i=n.depth,s=n.pos,l=null;for(;i>0&&l===null;)o=n.node(i),o.type===r?l=i:(i-=1,s-=1);return l===null?null:{$pos:e.doc.resolve(s),depth:l}},ac=(t,e)=>{const n=lo(t,e);if(!n)return!1;const[,r]=eC(e,t,n.$pos.pos+4);return r},om=(t,e,n)=>{const{$anchor:r}=t.selection,o=Math.max(0,r.pos-2),i=t.doc.resolve(o).node();return!(!i||!n.includes(i.type.name))},im=(t,e)=>{var n;const{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-2);return!(o.index()===0||((n=o.nodeBefore)==null?void 0:n.type.name)!==t)},sm=(t,e,n)=>{if(!n)return!1;const r=me(t,e.schema);let o=!1;return n.descendants(i=>{i.type===r&&(o=!0)}),o},Xl=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ln(t.state,e)&&om(t.state,e,n)){const{$anchor:l}=t.state.selection,a=t.state.doc.resolve(l.before()-1),c=[];a.node().descendants((h,f)=>{h.type.name===e&&c.push({node:h,pos:f})});const u=c.at(-1);if(!u)return!1;const d=t.state.doc.resolve(a.start()+u.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},d.end()).joinForward().run()}if(!ln(t.state,e)||!oC(t.state))return!1;const r=lo(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=sm(e,t.state,i);return im(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},lm=(t,e)=>{const n=ac(t,e),r=lo(t,e);return!r||!n?!1:n>r.depth},am=(t,e)=>{const n=ac(t,e),r=lo(t,e);return!r||!n?!1:n<r.depth},Ql=(t,e)=>{if(!ln(t.state,e)||!rC(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:lm(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():am(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},Tw=(t,e)=>{var n;const{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-r.parentOffset-2);return!(o.index()===o.parent.childCount-1||((n=o.nodeAfter)==null?void 0:n.type.name)!==t)},cm=Z.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Ql(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Ql(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Xl(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Xl(t,n,r)&&(e=!0)}),e}}}}),_d=/^(\s*)(\d+)\.\s+(.*)$/,Aw=/^\s/;function Rw(t){const e=[];let n=0,r=0;for(;n<t.length;){const o=t[n],i=o.match(_d);if(!i)break;const[,s,l,a]=i,c=s.length;let u=a,d=n+1;const h=[o];for(;d<t.length;){const f=t[d];if(f.match(_d))break;if(f.trim()==="")h.push(f),u+=`
164
+ `,d+=1;else if(f.match(Aw))h.push(f),u+=`
165
165
  ${f.slice(c+2)}`,d+=1;else break}e.push({indent:c,number:parseInt(l,10),content:u.trim(),raw:h.join(`
166
- `)}),r=d,n=d}return[e,r]}function rm(t,e,n){var r;const o=[];let i=0;for(;i<t.length;){const s=t[i];if(s.indent===e){const l=s.content.split(`
166
+ `)}),r=d,n=d}return[e,r]}function um(t,e,n){var r;const o=[];let i=0;for(;i<t.length;){const s=t[i];if(s.indent===e){const l=s.content.split(`
167
167
  `),a=((r=l[0])==null?void 0:r.trim())||"",c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});const u=l.slice(1).join(`
168
- `).trim();if(u){const f=n.blockTokens(u);c.push(...f)}let d=i+1;const h=[];for(;d<t.length&&t[d].indent>e;)h.push(t[d]),d+=1;if(h.length>0){const f=Math.min(...h.map(m=>m.indent)),p=rm(h,f,n);c.push({type:"list",ordered:!0,start:h[0].number,items:p,raw:h.map(m=>m.raw).join(`
169
- `)})}o.push({type:"list_item",raw:s.raw,tokens:c}),i=d}else i+=1}return o}function xw(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(o=>{if(o.type==="paragraph"||o.type==="list"||o.type==="blockquote"||o.type==="code")r.push(...e.parseChildren([o]));else if(o.type==="text"&&o.tokens){const i=e.parseChildren([o]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([o]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var ww="listItem",Nd="textStyle",Id=/^(\d+)\.\s$/,om=je.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",oe(this.options.HTMLAttributes,n),0]:["ol",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?xw(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
168
+ `).trim();if(u){const f=n.blockTokens(u);c.push(...f)}let d=i+1;const h=[];for(;d<t.length&&t[d].indent>e;)h.push(t[d]),d+=1;if(h.length>0){const f=Math.min(...h.map(m=>m.indent)),p=um(h,f,n);c.push({type:"list",ordered:!0,start:h[0].number,items:p,raw:h.map(m=>m.raw).join(`
169
+ `)})}o.push({type:"list_item",raw:s.raw,tokens:c}),i=d}else i+=1}return o}function Ow(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(o=>{if(o.type==="paragraph"||o.type==="list"||o.type==="blockquote"||o.type==="code")r.push(...e.parseChildren([o]));else if(o.type==="text"&&o.tokens){const i=e.parseChildren([o]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([o]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var Nw="listItem",Hd="textStyle",Fd=/^(\d+)\.\s$/,dm=Ie.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",te(this.options.HTMLAttributes,n),0]:["ol",te(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?Ow(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
170
170
  `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const o=t.split(`
171
- `),[i,s]=Cw(o);if(i.length===0)return;const l=rm(i,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:l,raw:o.slice(0,s).join(`
172
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ww,this.editor.getAttributes(Nd)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=lr({find:Id,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=lr({find:Id,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Nd)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Sw=/^\s*(\[([( |x])?\])\s$/,im=je.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",oe(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const o=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Ja(t,e,o)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=u=>{var d,h;l.ariaLabel=((h=(d=this.options.a11y)==null?void 0:d.checkboxLabel)==null?void 0:h.call(d,u,l.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};return c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:d}=u.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const f=n();if(typeof f!="number")return!1;const p=h.doc.nodeAt(f);return h.setNodeMarkup(f,void 0,{...p?.attrs,checked:d}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,d)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,d])=>{o.setAttribute(u,d)}),o.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,s),o.append(i,a),Object.entries(e).forEach(([u,d])=>{o.setAttribute(u,d)}),{dom:o,contentDOM:a,update:u=>u.type!==this.type?!1:(o.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u),!0)}}},addInputRules(){return[lr({find:Sw,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),sm=je.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",oe(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
173
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const s=Vl(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(i)},o=Vl(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,s)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:s}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Z.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Jp.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Zp.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(nm.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(om.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(im.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(sm.configure(this.options.taskList)),t}});var kw=je.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",oe(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Ew=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Mw=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Tw=it.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Nn({find:Ew,type:this.type})]},addPasteRules(){return[an({find:Mw,type:this.type})]}}),Aw=je.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Rw=it.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",oe(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const o=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!o)return;const i=o[2].trim();return{type:"underline",raw:o[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function Ow(t={}){return new ae({view(e){return new Nw(e,t)}})}class Nw{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(n){let d=e.nodeBefore,h=e.nodeAfter;if(d||h){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let p=f.getBoundingClientRect(),m=d?p.bottom:p.top;d&&h&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*l;r={left:p.left,right:p.right,top:m-v,bottom:m+v}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*s;r={left:d.left-h,right:d.left+h,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),h=d.width/a.offsetWidth,f=d.height/a.offsetHeight;c=d.left-a.scrollLeft*h,u=d.top-a.scrollTop*f}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,n,e):o;if(n&&!i){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=th(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class fe extends q{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return fe.valid(r)?new fe(r):q.near(r)}content(){return P.empty}eq(e){return e instanceof fe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new fe(e.resolve(n.pos))}getBookmark(){return new lc(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Iw(e)||!Lw(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&fe.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=n;let a=e.doc.resolve(o);if(fe.valid(a))return a}for(;;){let s=n>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!B.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=s,o+=n;let l=e.doc.resolve(o);if(fe.valid(l))return l}return null}}}fe.prototype.visible=!1;fe.findFrom=fe.findGapCursorFrom;q.jsonID("gapcursor",fe);class lc{constructor(e){this.pos=e}map(e){return new lc(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return fe.valid(n)?new fe(n):q.near(n)}}function lm(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Iw(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||lm(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Lw(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||lm(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Dw(){return new ae({props:{decorations:_w,createSelectionBetween(t,e,n){return e.pos==n.pos&&fe.valid(n)?new fe(n):null},handleClick:jw,handleKeyDown:Pw,handleDOMEvents:{beforeinput:Bw}}})}const Pw=tp({ArrowLeft:To("horiz",-1),ArrowRight:To("horiz",1),ArrowUp:To("vert",-1),ArrowDown:To("vert",1)});function To(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof z){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=fe.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new fe(c))),!0):!1}}function jw(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!fe.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&B.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new fe(r))),!0)}function Bw(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof fe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=A.empty;for(let s=r.length-1;s>=0;s--)o=A.from(r[s].createAndFill(null,o));let i=t.state.tr.replace(n.pos,n.pos,new P(o,0,0));return i.setSelection(z.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function _w(t){if(!(t.selection instanceof fe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ue.create(t.doc,[Ie.widget(t.selection.head,e,{key:"gapcursor"})])}var Li=200,Ce=function(){};Ce.prototype.append=function(e){return e.length?(e=Ce.from(e),!this.length&&e||e.length<Li&&this.leafAppend(e)||this.length<Li&&e.leafPrepend(this)||this.appendInner(e)):this};Ce.prototype.prepend=function(e){return e.length?Ce.from(e).append(this):this};Ce.prototype.appendInner=function(e){return new Hw(this,e)};Ce.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ce.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ce.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ce.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Ce.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},n,r),o};Ce.from=function(e){return e instanceof Ce?e:e&&e.length?new am(e):Ce.empty};var am=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Li)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Li)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Ce);Ce.empty=new am([]);var Hw=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Ce);const Fw=500;class nt{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;n&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,h)=>{if(!d.step){o||(o=this.remapping(r,h+1),i=o.maps.length),i--,u.push(d);return}if(o){u.push(new Ht(d.map));let f=d.step.map(o.slice(i)),p;f&&s.maybeStep(f).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new Ht(p,void 0,void 0,c.length+u.length))),i--,p&&o.appendMap(p,i)}else s.maybeStep(d.step);if(d.selection)return l=o?d.selection.map(o.slice(i)):d.selection,a=new nt(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,n,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),h=new Ht(e.mapping.maps[u],d,n),f;(f=a&&a.merge(h))&&(h=f,u?i.pop():l=l.slice(0,l.length-1)),i.push(h),n&&(s++,n=void 0),o||(a=h)}let c=s-r.depth;return c>Vw&&(l=$w(l,c),s-=c),new nt(l.append(i),s)}remapping(e,n){let r=new _r;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new nt(this.items.append(e.map(n=>new Ht(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-n),i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},o);let a=n;this.items.forEach(h=>{let f=i.getMirror(--a);if(f==null)return;s=Math.min(s,f);let p=i.maps[f];if(h.step){let m=e.steps[f].invert(e.docs[f]),v=h.selection&&h.selection.map(i.slice(a+1,f));v&&l++,r.push(new Ht(p,m,v))}else r.push(new Ht(p))},o);let c=[];for(let h=n;h<s;h++)c.push(new Ht(i.maps[h]));let u=this.items.slice(0,o).append(c).append(r),d=new nt(u,l);return d.emptyItemCount()>Fw&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=s.selection&&s.selection.map(n.slice(r));u&&i++;let d=new Ht(c.invert(),a,u),h,f=o.length-1;(h=o.length&&o[f].merge(d))?o[f]=h:o.push(d)}}else s.map&&r--},this.items.length,0),new nt(Ce.from(o.reverse()),i)}}nt.empty=new nt(Ce.empty,0);function $w(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}let Ht=class cm{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new cm(n.getMap().invert(),n,this.selection)}}};class Ut{constructor(e,n,r,o,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}}const Vw=20;function zw(t,e,n,r){let o=n.getMeta(Mn),i;if(o)return o.historyState;n.getMeta(Kw)&&(t=new Ut(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Mn))return s.getMeta(Mn).redo?new Ut(t.done.addTransform(n,void 0,r,$o(e)),t.undone,Ld(n.mapping.maps),t.prevTime,t.prevComposition):new Ut(t.done,t.undone.addTransform(n,void 0,r,$o(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!s&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!Uw(n,t.prevRanges)),c=s?el(t.prevRanges,n.mapping):Ld(n.mapping.maps);return new Ut(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,$o(e)),nt.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ut(t.done.rebased(n,i),t.undone.rebased(n,i),el(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ut(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),el(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Uw(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&o>=e[i]&&(n=!0)}),n}function Ld(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,i,s)=>e.push(i,s));return e}function el(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let o=e.map(t[r],1),i=e.map(t[r+1],-1);o<=i&&n.push(o,i)}return n}function Ww(t,e,n){let r=$o(e),o=Mn.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),o,r),a=new Ut(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(Mn,{redo:n,historyState:a})}let tl=!1,Dd=null;function $o(t){let e=t.plugins;if(Dd!=e){tl=!1,Dd=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){tl=!0;break}}return tl}const Mn=new ge("history"),Kw=new ge("closeHistory");function qw(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ae({key:Mn,state:{init(){return new Ut(nt.empty,nt.empty,null,0,-1)},apply(e,n,r){return zw(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,o=r=="historyUndo"?dm:r=="historyRedo"?fm:null;return o?(n.preventDefault(),o(e.state,e.dispatch)):!1}}}})}function um(t,e){return(n,r)=>{let o=Mn.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let i=Ww(o,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const dm=um(!1,!0),fm=um(!0,!0);Z.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new ae({key:new ge("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const o=this.options.limit;if(o==null||o===0){t=!0;return}const i=this.storage.characters({node:r.doc});if(i>o){const s=i-o,l=0,a=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const o=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=i-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var Gw=Z.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Ow(this.options)]}});Z.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ae({key:new ge("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,i=[];if(!n||!r)return ue.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(o>=c&&o<=c+a.nodeSize-1))return!1;s+=1});let l=0;return t.descendants((a,c)=>{if(a.isText||!(o>=c&&o<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(Ie.node(c,c+a.nodeSize,{class:this.options.className}))}),ue.create(t,i)}}})]}});var Jw=Z.create({name:"gapCursor",addProseMirrorPlugins(){return[Dw()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Q($(t,"allowGapCursor",n)))!=null?e:null}}});Z.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new ae({key:new ge("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants((s,l)=>{const a=r>=l&&r<=l+s.nodeSize,c=!s.isLeaf&&ns(s);if((a||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];i&&u.push(this.options.emptyEditorClass);const d=Ie.node(l,l+s.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:l,hasAnchor:a}):this.options.placeholder});o.push(d)}return this.options.includeChildren}),ue.create(t,o)}}})]}});var Zw=Z.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new ae({key:new ge("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||gp(n.selection)||t.view.dragging?null:ue.create(n.doc,[Ie.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Pd({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var Yw=Z.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ge(this.name),n=((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||this.options.node||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new ae({key:e,appendTransaction:(o,i,s)=>{const{doc:l,tr:a,schema:c}=s,u=e.getState(s),d=l.content.size,h=c.nodes[n];if(u)return a.insert(d,h.create())},state:{init:(o,i)=>{const s=i.tr.doc.lastChild;return!Pd({node:s,types:r})},apply:(o,i)=>{if(!o.docChanged)return i;const s=o.doc.lastChild;return!Pd({node:s,types:r})}}})]}}),Xw=Z.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>dm(t,e),redo:()=>({state:t,dispatch:e})=>fm(t,e)}},addProseMirrorPlugins(){return[qw(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Qw=Z.create({name:"starterKit",addExtensions(){var t,e,n,r;const o=[];return this.options.bold!==!1&&o.push(Tx.configure(this.options.bold)),this.options.blockquote!==!1&&o.push(wx.configure(this.options.blockquote)),this.options.bulletList!==!1&&o.push(Jp.configure(this.options.bulletList)),this.options.code!==!1&&o.push(Ox.configure(this.options.code)),this.options.codeBlock!==!1&&o.push(Lx.configure(this.options.codeBlock)),this.options.document!==!1&&o.push(Dx.configure(this.options.document)),this.options.dropcursor!==!1&&o.push(Gw.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&o.push(Jw.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&o.push(Px.configure(this.options.hardBreak)),this.options.heading!==!1&&o.push(jx.configure(this.options.heading)),this.options.undoRedo!==!1&&o.push(Xw.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&o.push(Hp.configure(this.options.horizontalRule)),this.options.italic!==!1&&o.push(Vx.configure(this.options.italic)),this.options.listItem!==!1&&o.push(Zp.configure(this.options.listItem)),this.options.listKeymap!==!1&&o.push(nm.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&o.push(hw.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&o.push(om.configure(this.options.orderedList)),this.options.paragraph!==!1&&o.push(kw.configure(this.options.paragraph)),this.options.strike!==!1&&o.push(Tw.configure(this.options.strike)),this.options.text!==!1&&o.push(Aw.configure(this.options.text)),this.options.underline!==!1&&o.push(Rw.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&o.push(Yw.configure((r=this.options)==null?void 0:r.trailingNode)),o}}),e7=Z.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),t7=t=>he({find:/--$/,replace:t??"—"}),n7=t=>he({find:/\.\.\.$/,replace:t??"…"}),r7=t=>he({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),o7=t=>he({find:/"$/,replace:t??"”"}),i7=t=>he({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),s7=t=>he({find:/'$/,replace:t??"’"}),l7=t=>he({find:/<-$/,replace:t??"←"}),a7=t=>he({find:/->$/,replace:t??"→"}),c7=t=>he({find:/\(c\)$/,replace:t??"©"}),u7=t=>he({find:/\(tm\)$/,replace:t??"™"}),d7=t=>he({find:/\(sm\)$/,replace:t??"℠"}),f7=t=>he({find:/\(r\)$/,replace:t??"®"}),h7=t=>he({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),p7=t=>he({find:/\+\/-$/,replace:t??"±"}),m7=t=>he({find:/!=$/,replace:t??"≠"}),g7=t=>he({find:/<<$/,replace:t??"«"}),y7=t=>he({find:/>>$/,replace:t??"»"}),v7=t=>he({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),b7=t=>he({find:/\^2$/,replace:t??"²"}),C7=t=>he({find:/\^3$/,replace:t??"³"}),x7=t=>he({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),w7=t=>he({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),S7=Z.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){const t=[];return this.options.emDash!==!1&&t.push(t7(this.options.emDash)),this.options.ellipsis!==!1&&t.push(n7(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(r7(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(o7(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(i7(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(s7(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(l7(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(a7(this.options.rightArrow)),this.options.copyright!==!1&&t.push(c7(this.options.copyright)),this.options.trademark!==!1&&t.push(u7(this.options.trademark)),this.options.servicemark!==!1&&t.push(d7(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(f7(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(h7(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(p7(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(m7(this.options.notEqual)),this.options.laquo!==!1&&t.push(g7(this.options.laquo)),this.options.raquo!==!1&&t.push(y7(this.options.raquo)),this.options.multiplication!==!1&&t.push(v7(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(b7(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(C7(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(x7(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(w7(this.options.threeQuarters)),t}}),k7=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,E7=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,M7=it.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",oe(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const o=/^(==)([^=]+)(==)/.exec(t);if(o){const i=o[2].trim(),s=n.inlineTokens(i);return{type:"highlight",raw:o[0],text:i,tokens:s}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Nn({find:k7,type:this.type})]},addPasteRules(){return[an({find:E7,type:this.type})]}}),T7=it.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",oe(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),A7=it.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",oe(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),we=[];for(var nl=0;nl<256;++nl)we.push((nl+256).toString(16).slice(1));function R7(t,e=0){return(we[t[e+0]]+we[t[e+1]]+we[t[e+2]]+we[t[e+3]]+"-"+we[t[e+4]]+we[t[e+5]]+"-"+we[t[e+6]]+we[t[e+7]]+"-"+we[t[e+8]]+we[t[e+9]]+"-"+we[t[e+10]]+we[t[e+11]]+we[t[e+12]]+we[t[e+13]]+we[t[e+14]]+we[t[e+15]]).toLowerCase()}var Ao,O7=new Uint8Array(16);function N7(){if(!Ao&&(Ao=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ao))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ao(O7)}var I7=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const jd={randomUUID:I7};function L7(t,e,n){if(jd.randomUUID&&!t)return jd.randomUUID();t=t||{};var r=t.random||(t.rng||N7)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,R7(r)}function D7(t,e=JSON.stringify){const n={};return t.filter(r=>{const o=e(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function P7(t){const e=t.filter((r,o)=>t.indexOf(r)!==o);return D7(e)}var j7=Z.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],generateID:()=>L7(),filterTransaction:null,updateDocument:!0}},addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:t=>t.getAttribute(`data-${this.options.attributeName}`),renderHTML:t=>t[this.options.attributeName]?{[`data-${this.options.attributeName}`]:t[this.options.attributeName]}:{}}}}]},onCreate(){var t;if(!this.options.updateDocument)return;const e=this.editor.extensionManager.extensions.find(l=>l.name==="collaboration"),n=this.editor.extensionManager.extensions.find(l=>l.name==="collaborationCaret"),o=[e,n].filter(Boolean).find(l=>{var a;return(a=l?.options)==null?void 0:a.provider}),i=(t=o?.options)==null?void 0:t.provider,s=()=>{const{view:l,state:a}=this.editor,{tr:c,doc:u}=a,{types:d,attributeName:h,generateID:f}=this.options;Db(u,m=>d.includes(m.type.name)&&m.attrs[h]===null).forEach(({node:m,pos:v})=>{c.setNodeMarkup(v,void 0,{...m.attrs,[h]:f({node:m,pos:v})})}),c.setMeta("addToHistory",!1),l.dispatch(c),i&&i.off("synced",s)};if(o){if(!i)return s();i.on("synced",s)}else return s()},addProseMirrorPlugins(){if(!this.options.updateDocument)return[];let t=null,e=!1;return[new ae({key:new ge("uniqueID"),appendTransaction:(n,r,o)=>{const i=n.some(m=>m.docChanged)&&!r.doc.eq(o.doc),s=this.options.filterTransaction&&n.some(m=>{var v,b;return!((b=(v=this.options).filterTransaction)!=null&&b.call(v,m))});if(n.find(m=>m.getMeta("y-sync$"))||!i||s)return;const{tr:a}=o,{types:c,attributeName:u,generateID:d}=this.options,h=$a(r.doc,n),{mapping:f}=h;if(Ua(h).forEach(({newRange:m})=>{const v=cp(o.doc,m,C=>c.includes(C.type.name)),b=v.map(({node:C})=>C.attrs[u]).filter(C=>C!==null);v.forEach(({node:C,pos:x},w)=>{var E;const k=(E=a.doc.nodeAt(x))==null?void 0:E.attrs[u];if(k===null){a.setNodeMarkup(x,void 0,{...C.attrs,[u]:d({node:C,pos:x})});return}const S=v[w+1];if(S&&C.content.size===0){if(a.setNodeMarkup(S.pos,void 0,{...S.node.attrs,[u]:k}),b[w+1]=k,S.node.attrs[u])return;const _=d({node:C,pos:x});return a.setNodeMarkup(x,void 0,{...C.attrs,[u]:_}),b[w]=_,a}const M=P7(b),{deleted:I}=f.invert().mapResult(x);I&&M.includes(k)&&a.setNodeMarkup(x,void 0,{...C.attrs,[u]:d({node:C,pos:x})})})}),!!a.steps.length)return a.setStoredMarks(o.tr.storedMarks),a},view(n){const r=o=>{var i;t=(i=n.dom.parentElement)!=null&&i.contains(o.target)?n.dom.parentElement:null};return window.addEventListener("dragstart",r),{destroy(){window.removeEventListener("dragstart",r)}}},props:{handleDOMEvents:{drop:(n,r)=>{var o,i;return(t!==n.dom.parentElement||((o=r.dataTransfer)==null?void 0:o.effectAllowed)==="copyMove"||((i=r.dataTransfer)==null?void 0:i.effectAllowed)==="copy")&&(t=null,e=!0),!1},paste:()=>(e=!0,!1)},transformPasted:n=>{if(!e)return n;const{types:r,attributeName:o}=this.options,i=s=>{const l=[];return s.forEach(a=>{if(a.isText){l.push(a);return}if(!r.includes(a.type.name)){l.push(a.copy(i(a.content)));return}const c=a.type.create({...a.attrs,[o]:null},i(a.content),a.marks);l.push(c)}),A.from(l)};return e=!1,new P(i(n.content),n.openStart,n.openEnd)}}})]}}),B7=j7,_7=20,hm=(t,e=0)=>{const n=[];return!t.children.length||e>_7||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...hm(r,e+1))}),n},H7=t=>{if(!t.children.length)return;const e=hm(t);e&&e.forEach(n=>{var r,o;const i=n.getAttribute("style"),s=(o=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:o.getAttribute("style");n.setAttribute("style",`${s};${i}`)})},pm=it.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&H7(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",oe(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),F7=Z.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const i=r[o].split(":");if(i.length>=2){const s=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(s==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),mm=Z.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const i=r[o].split(":");if(i.length>=2){const s=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(s==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),$7=Z.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),V7=Z.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),z7=Z.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});Z.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(F7.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(mm.configure(this.options.color)),this.options.fontFamily!==!1&&t.push($7.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(V7.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(z7.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(pm.configure(this.options.textStyle)),t}});function ss(){return typeof window<"u"}function dr(t){return ac(t)?(t.nodeName||"").toLowerCase():"#document"}function Fe(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function mt(t){var e;return(e=(ac(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function ac(t){return ss()?t instanceof Node||t instanceof Fe(t).Node:!1}function ie(t){return ss()?t instanceof Element||t instanceof Fe(t).Element:!1}function Ue(t){return ss()?t instanceof HTMLElement||t instanceof Fe(t).HTMLElement:!1}function ea(t){return!ss()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Fe(t).ShadowRoot}const U7=new Set(["inline","contents"]);function so(t){const{overflow:e,overflowX:n,overflowY:r,display:o}=tt(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!U7.has(o)}const W7=new Set(["table","td","th"]);function K7(t){return W7.has(dr(t))}const q7=[":popover-open",":modal"];function ls(t){return q7.some(e=>{try{return t.matches(e)}catch{return!1}})}const G7=["transform","translate","scale","rotate","perspective"],J7=["transform","translate","scale","rotate","perspective","filter"],Z7=["paint","layout","strict","content"];function cc(t){const e=as(),n=ie(t)?tt(t):t;return G7.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||J7.some(r=>(n.willChange||"").includes(r))||Z7.some(r=>(n.contain||"").includes(r))}function Y7(t){let e=It(t);for(;Ue(e)&&!Nt(e);){if(cc(e))return e;if(ls(e))return null;e=It(e)}return null}function as(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const X7=new Set(["html","body","#document"]);function Nt(t){return X7.has(dr(t))}function tt(t){return Fe(t).getComputedStyle(t)}function cs(t){return ie(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function It(t){if(dr(t)==="html")return t;const e=t.assignedSlot||t.parentNode||ea(t)&&t.host||mt(t);return ea(e)?e.host:e}function gm(t){const e=It(t);return Nt(e)?t.ownerDocument?t.ownerDocument.body:t.body:Ue(e)&&so(e)?e:gm(e)}function rn(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const o=gm(t),i=o===((r=t.ownerDocument)==null?void 0:r.body),s=Fe(o);if(i){const l=ta(s);return e.concat(s,s.visualViewport||[],so(o)?o:[],l&&n?rn(l):[])}return e.concat(o,rn(o,[],n))}function ta(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}const Q7=["top","right","bottom","left"],cn=Math.min,$e=Math.max,Di=Math.round,Ro=Math.floor,ft=t=>({x:t,y:t}),e4={left:"right",right:"left",bottom:"top",top:"bottom"},t4={start:"end",end:"start"};function na(t,e,n){return $e(t,cn(e,n))}function Lt(t,e){return typeof t=="function"?t(e):t}function Dt(t){return t.split("-")[0]}function fr(t){return t.split("-")[1]}function uc(t){return t==="x"?"y":"x"}function dc(t){return t==="y"?"height":"width"}const n4=new Set(["top","bottom"]);function ut(t){return n4.has(Dt(t))?"y":"x"}function fc(t){return uc(ut(t))}function r4(t,e,n){n===void 0&&(n=!1);const r=fr(t),o=fc(t),i=dc(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=Pi(s)),[s,Pi(s)]}function o4(t){const e=Pi(t);return[ra(t),e,ra(e)]}function ra(t){return t.replace(/start|end/g,e=>t4[e])}const Bd=["left","right"],_d=["right","left"],i4=["top","bottom"],s4=["bottom","top"];function l4(t,e,n){switch(t){case"top":case"bottom":return n?e?_d:Bd:e?Bd:_d;case"left":case"right":return e?i4:s4;default:return[]}}function a4(t,e,n,r){const o=fr(t);let i=l4(Dt(t),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),e&&(i=i.concat(i.map(ra)))),i}function Pi(t){return t.replace(/left|right|bottom|top/g,e=>e4[e])}function c4(t){return{top:0,right:0,bottom:0,left:0,...t}}function ym(t){return typeof t!="number"?c4(t):{top:t,right:t,bottom:t,left:t}}function ji(t){const{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}/*!
171
+ `),[i,s]=Rw(o);if(i.length===0)return;const l=um(i,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:l,raw:o.slice(0,s).join(`
172
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Nw,this.editor.getAttributes(Hd)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=ar({find:Fd,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ar({find:Fd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Hd)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Iw=/^\s*(\[([( |x])?\])\s$/,fm=Ie.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",te(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const o=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Ja(t,e,o)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=u=>{var d,h;l.ariaLabel=((h=(d=this.options.a11y)==null?void 0:d.checkboxLabel)==null?void 0:h.call(d,u,l.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};return c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:d}=u.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const f=n();if(typeof f!="number")return!1;const p=h.doc.nodeAt(f);return h.setNodeMarkup(f,void 0,{...p?.attrs,checked:d}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,d)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,d])=>{o.setAttribute(u,d)}),o.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,s),o.append(i,a),Object.entries(e).forEach(([u,d])=>{o.setAttribute(u,d)}),{dom:o,contentDOM:a,update:u=>u.type!==this.type?!1:(o.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u),!0)}}},addInputRules(){return[ar({find:Iw,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),hm=Ie.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",te(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
173
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const s=Vl(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(i)},o=Vl(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,s)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:s}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Z.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(nm.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(rm.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(cm.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(dm.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(fm.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(hm.configure(this.options.taskList)),t}});var Lw=Ie.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",te(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Dw=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Pw=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,jw=it.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",te(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Nn({find:Dw,type:this.type})]},addPasteRules(){return[an({find:Pw,type:this.type})]}}),Bw=Ie.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),_w=it.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",te(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const o=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!o)return;const i=o[2].trim();return{type:"underline",raw:o[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function Hw(t={}){return new ae({view(e){return new Fw(e,t)}})}class Fw{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(n){let d=e.nodeBefore,h=e.nodeAfter;if(d||h){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let p=f.getBoundingClientRect(),m=d?p.bottom:p.top;d&&h&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*l;r={left:p.left,right:p.right,top:m-v,bottom:m+v}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*s;r={left:d.left-h,right:d.left+h,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),h=d.width/a.offsetWidth,f=d.height/a.offsetHeight;c=d.left-a.scrollLeft*h,u=d.top-a.scrollTop*f}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,n,e):o;if(n&&!i){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=uh(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class fe extends q{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return fe.valid(r)?new fe(r):q.near(r)}content(){return j.empty}eq(e){return e instanceof fe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new fe(e.resolve(n.pos))}getBookmark(){return new cc(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!$w(e)||!Vw(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&fe.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=n;let a=e.doc.resolve(o);if(fe.valid(a))return a}for(;;){let s=n>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!B.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=s,o+=n;let l=e.doc.resolve(o);if(fe.valid(l))return l}return null}}}fe.prototype.visible=!1;fe.findFrom=fe.findGapCursorFrom;q.jsonID("gapcursor",fe);class cc{constructor(e){this.pos=e}map(e){return new cc(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return fe.valid(n)?new fe(n):q.near(n)}}function pm(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function $w(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||pm(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Vw(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||pm(o.type))return!0;if(o.inlineContent)return!1}}return!0}function zw(){return new ae({props:{decorations:qw,createSelectionBetween(t,e,n){return e.pos==n.pos&&fe.valid(n)?new fe(n):null},handleClick:Ww,handleKeyDown:Uw,handleDOMEvents:{beforeinput:Kw}}})}const Uw=up({ArrowLeft:Ao("horiz",-1),ArrowRight:Ao("horiz",1),ArrowUp:Ao("vert",-1),ArrowDown:Ao("vert",1)});function Ao(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof z){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=fe.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new fe(c))),!0):!1}}function Ww(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!fe.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&B.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new fe(r))),!0)}function Kw(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof fe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=A.empty;for(let s=r.length-1;s>=0;s--)o=A.from(r[s].createAndFill(null,o));let i=t.state.tr.replace(n.pos,n.pos,new j(o,0,0));return i.setSelection(z.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function qw(t){if(!(t.selection instanceof fe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ue.create(t.doc,[Le.widget(t.selection.head,e,{key:"gapcursor"})])}var Di=200,Ce=function(){};Ce.prototype.append=function(e){return e.length?(e=Ce.from(e),!this.length&&e||e.length<Di&&this.leafAppend(e)||this.length<Di&&e.leafPrepend(this)||this.appendInner(e)):this};Ce.prototype.prepend=function(e){return e.length?Ce.from(e).append(this):this};Ce.prototype.appendInner=function(e){return new Gw(this,e)};Ce.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ce.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ce.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ce.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Ce.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},n,r),o};Ce.from=function(e){return e instanceof Ce?e:e&&e.length?new mm(e):Ce.empty};var mm=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Di)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Di)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Ce);Ce.empty=new mm([]);var Gw=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Ce);const Jw=500;class nt{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;n&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,h)=>{if(!d.step){o||(o=this.remapping(r,h+1),i=o.maps.length),i--,u.push(d);return}if(o){u.push(new Ht(d.map));let f=d.step.map(o.slice(i)),p;f&&s.maybeStep(f).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new Ht(p,void 0,void 0,c.length+u.length))),i--,p&&o.appendMap(p,i)}else s.maybeStep(d.step);if(d.selection)return l=o?d.selection.map(o.slice(i)):d.selection,a=new nt(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,n,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),h=new Ht(e.mapping.maps[u],d,n),f;(f=a&&a.merge(h))&&(h=f,u?i.pop():l=l.slice(0,l.length-1)),i.push(h),n&&(s++,n=void 0),o||(a=h)}let c=s-r.depth;return c>Yw&&(l=Zw(l,c),s-=c),new nt(l.append(i),s)}remapping(e,n){let r=new Hr;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new nt(this.items.append(e.map(n=>new Ht(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-n),i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},o);let a=n;this.items.forEach(h=>{let f=i.getMirror(--a);if(f==null)return;s=Math.min(s,f);let p=i.maps[f];if(h.step){let m=e.steps[f].invert(e.docs[f]),v=h.selection&&h.selection.map(i.slice(a+1,f));v&&l++,r.push(new Ht(p,m,v))}else r.push(new Ht(p))},o);let c=[];for(let h=n;h<s;h++)c.push(new Ht(i.maps[h]));let u=this.items.slice(0,o).append(c).append(r),d=new nt(u,l);return d.emptyItemCount()>Jw&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=s.selection&&s.selection.map(n.slice(r));u&&i++;let d=new Ht(c.invert(),a,u),h,f=o.length-1;(h=o.length&&o[f].merge(d))?o[f]=h:o.push(d)}}else s.map&&r--},this.items.length,0),new nt(Ce.from(o.reverse()),i)}}nt.empty=new nt(Ce.empty,0);function Zw(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}let Ht=class gm{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new gm(n.getMap().invert(),n,this.selection)}}};class Ut{constructor(e,n,r,o,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}}const Yw=20;function Xw(t,e,n,r){let o=n.getMeta(Mn),i;if(o)return o.historyState;n.getMeta(t7)&&(t=new Ut(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Mn))return s.getMeta(Mn).redo?new Ut(t.done.addTransform(n,void 0,r,Vo(e)),t.undone,$d(n.mapping.maps),t.prevTime,t.prevComposition):new Ut(t.done,t.undone.addTransform(n,void 0,r,Vo(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!s&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!Qw(n,t.prevRanges)),c=s?el(t.prevRanges,n.mapping):$d(n.mapping.maps);return new Ut(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,Vo(e)),nt.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ut(t.done.rebased(n,i),t.undone.rebased(n,i),el(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ut(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),el(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Qw(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&o>=e[i]&&(n=!0)}),n}function $d(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,i,s)=>e.push(i,s));return e}function el(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let o=e.map(t[r],1),i=e.map(t[r+1],-1);o<=i&&n.push(o,i)}return n}function e7(t,e,n){let r=Vo(e),o=Mn.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),o,r),a=new Ut(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(Mn,{redo:n,historyState:a})}let tl=!1,Vd=null;function Vo(t){let e=t.plugins;if(Vd!=e){tl=!1,Vd=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){tl=!0;break}}return tl}const Mn=new ge("history"),t7=new ge("closeHistory");function n7(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ae({key:Mn,state:{init(){return new Ut(nt.empty,nt.empty,null,0,-1)},apply(e,n,r){return Xw(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,o=r=="historyUndo"?vm:r=="historyRedo"?bm:null;return o?(n.preventDefault(),o(e.state,e.dispatch)):!1}}}})}function ym(t,e){return(n,r)=>{let o=Mn.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let i=e7(o,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const vm=ym(!1,!0),bm=ym(!0,!0);Z.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new ae({key:new ge("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const o=this.options.limit;if(o==null||o===0){t=!0;return}const i=this.storage.characters({node:r.doc});if(i>o){const s=i-o,l=0,a=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const o=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=i-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var r7=Z.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Hw(this.options)]}});Z.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ae({key:new ge("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,i=[];if(!n||!r)return ue.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(o>=c&&o<=c+a.nodeSize-1))return!1;s+=1});let l=0;return t.descendants((a,c)=>{if(a.isText||!(o>=c&&o<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(Le.node(c,c+a.nodeSize,{class:this.options.className}))}),ue.create(t,i)}}})]}});var o7=Z.create({name:"gapCursor",addProseMirrorPlugins(){return[zw()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=ee($(t,"allowGapCursor",n)))!=null?e:null}}});Z.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new ae({key:new ge("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants((s,l)=>{const a=r>=l&&r<=l+s.nodeSize,c=!s.isLeaf&&ns(s);if((a||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];i&&u.push(this.options.emptyEditorClass);const d=Le.node(l,l+s.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:l,hasAnchor:a}):this.options.placeholder});o.push(d)}return this.options.includeChildren}),ue.create(t,o)}}})]}});var i7=Z.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new ae({key:new ge("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Ep(n.selection)||t.view.dragging?null:ue.create(n.doc,[Le.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function zd({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var s7=Z.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ge(this.name),n=((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||this.options.node||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new ae({key:e,appendTransaction:(o,i,s)=>{const{doc:l,tr:a,schema:c}=s,u=e.getState(s),d=l.content.size,h=c.nodes[n];if(u)return a.insert(d,h.create())},state:{init:(o,i)=>{const s=i.tr.doc.lastChild;return!zd({node:s,types:r})},apply:(o,i)=>{if(!o.docChanged)return i;const s=o.doc.lastChild;return!zd({node:s,types:r})}}})]}}),l7=Z.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>vm(t,e),redo:()=>({state:t,dispatch:e})=>bm(t,e)}},addProseMirrorPlugins(){return[n7(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),a7=Z.create({name:"starterKit",addExtensions(){var t,e,n,r;const o=[];return this.options.bold!==!1&&o.push(jx.configure(this.options.bold)),this.options.blockquote!==!1&&o.push(Nx.configure(this.options.blockquote)),this.options.bulletList!==!1&&o.push(nm.configure(this.options.bulletList)),this.options.code!==!1&&o.push(Hx.configure(this.options.code)),this.options.codeBlock!==!1&&o.push(Vx.configure(this.options.codeBlock)),this.options.document!==!1&&o.push(zx.configure(this.options.document)),this.options.dropcursor!==!1&&o.push(r7.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&o.push(o7.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&o.push(Ux.configure(this.options.hardBreak)),this.options.heading!==!1&&o.push(Wx.configure(this.options.heading)),this.options.undoRedo!==!1&&o.push(l7.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&o.push(Kp.configure(this.options.horizontalRule)),this.options.italic!==!1&&o.push(Yx.configure(this.options.italic)),this.options.listItem!==!1&&o.push(rm.configure(this.options.listItem)),this.options.listKeymap!==!1&&o.push(cm.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&o.push(ww.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&o.push(dm.configure(this.options.orderedList)),this.options.paragraph!==!1&&o.push(Lw.configure(this.options.paragraph)),this.options.strike!==!1&&o.push(jw.configure(this.options.strike)),this.options.text!==!1&&o.push(Bw.configure(this.options.text)),this.options.underline!==!1&&o.push(_w.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&o.push(s7.configure((r=this.options)==null?void 0:r.trailingNode)),o}}),c7=Z.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),u7=t=>he({find:/--$/,replace:t??"—"}),d7=t=>he({find:/\.\.\.$/,replace:t??"…"}),f7=t=>he({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),h7=t=>he({find:/"$/,replace:t??"”"}),p7=t=>he({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),m7=t=>he({find:/'$/,replace:t??"’"}),g7=t=>he({find:/<-$/,replace:t??"←"}),y7=t=>he({find:/->$/,replace:t??"→"}),v7=t=>he({find:/\(c\)$/,replace:t??"©"}),b7=t=>he({find:/\(tm\)$/,replace:t??"™"}),C7=t=>he({find:/\(sm\)$/,replace:t??"℠"}),x7=t=>he({find:/\(r\)$/,replace:t??"®"}),w7=t=>he({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),S7=t=>he({find:/\+\/-$/,replace:t??"±"}),k7=t=>he({find:/!=$/,replace:t??"≠"}),E7=t=>he({find:/<<$/,replace:t??"«"}),M7=t=>he({find:/>>$/,replace:t??"»"}),T7=t=>he({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),A7=t=>he({find:/\^2$/,replace:t??"²"}),R7=t=>he({find:/\^3$/,replace:t??"³"}),O7=t=>he({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),N7=t=>he({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),I7=Z.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){const t=[];return this.options.emDash!==!1&&t.push(u7(this.options.emDash)),this.options.ellipsis!==!1&&t.push(d7(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(f7(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(h7(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(p7(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(m7(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(g7(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(y7(this.options.rightArrow)),this.options.copyright!==!1&&t.push(v7(this.options.copyright)),this.options.trademark!==!1&&t.push(b7(this.options.trademark)),this.options.servicemark!==!1&&t.push(C7(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(x7(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(w7(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(S7(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(k7(this.options.notEqual)),this.options.laquo!==!1&&t.push(E7(this.options.laquo)),this.options.raquo!==!1&&t.push(M7(this.options.raquo)),this.options.multiplication!==!1&&t.push(T7(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(A7(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(R7(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(O7(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(N7(this.options.threeQuarters)),t}}),L7=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,D7=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,P7=it.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",te(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const o=/^(==)([^=]+)(==)/.exec(t);if(o){const i=o[2].trim(),s=n.inlineTokens(i);return{type:"highlight",raw:o[0],text:i,tokens:s}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Nn({find:L7,type:this.type})]},addPasteRules(){return[an({find:D7,type:this.type})]}}),j7=it.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",te(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),B7=it.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",te(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),we=[];for(var nl=0;nl<256;++nl)we.push((nl+256).toString(16).slice(1));function _7(t,e=0){return(we[t[e+0]]+we[t[e+1]]+we[t[e+2]]+we[t[e+3]]+"-"+we[t[e+4]]+we[t[e+5]]+"-"+we[t[e+6]]+we[t[e+7]]+"-"+we[t[e+8]]+we[t[e+9]]+"-"+we[t[e+10]]+we[t[e+11]]+we[t[e+12]]+we[t[e+13]]+we[t[e+14]]+we[t[e+15]]).toLowerCase()}var Ro,H7=new Uint8Array(16);function F7(){if(!Ro&&(Ro=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ro))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ro(H7)}var $7=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Ud={randomUUID:$7};function V7(t,e,n){if(Ud.randomUUID&&!t)return Ud.randomUUID();t=t||{};var r=t.random||(t.rng||F7)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,_7(r)}function z7(t,e=JSON.stringify){const n={};return t.filter(r=>{const o=e(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function U7(t){const e=t.filter((r,o)=>t.indexOf(r)!==o);return z7(e)}var W7=Z.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],generateID:()=>V7(),filterTransaction:null,updateDocument:!0}},addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:t=>t.getAttribute(`data-${this.options.attributeName}`),renderHTML:t=>t[this.options.attributeName]?{[`data-${this.options.attributeName}`]:t[this.options.attributeName]}:{}}}}]},onCreate(){var t;if(!this.options.updateDocument)return;const e=this.editor.extensionManager.extensions.find(l=>l.name==="collaboration"),n=this.editor.extensionManager.extensions.find(l=>l.name==="collaborationCaret"),o=[e,n].filter(Boolean).find(l=>{var a;return(a=l?.options)==null?void 0:a.provider}),i=(t=o?.options)==null?void 0:t.provider,s=()=>{const{view:l,state:a}=this.editor,{tr:c,doc:u}=a,{types:d,attributeName:h,generateID:f}=this.options;zb(u,m=>d.includes(m.type.name)&&m.attrs[h]===null).forEach(({node:m,pos:v})=>{c.setNodeMarkup(v,void 0,{...m.attrs,[h]:f({node:m,pos:v})})}),c.setMeta("addToHistory",!1),l.dispatch(c),i&&i.off("synced",s)};if(o){if(!i)return s();i.on("synced",s)}else return s()},addProseMirrorPlugins(){if(!this.options.updateDocument)return[];let t=null,e=!1;return[new ae({key:new ge("uniqueID"),appendTransaction:(n,r,o)=>{const i=n.some(m=>m.docChanged)&&!r.doc.eq(o.doc),s=this.options.filterTransaction&&n.some(m=>{var v,b;return!((b=(v=this.options).filterTransaction)!=null&&b.call(v,m))});if(n.find(m=>m.getMeta("y-sync$"))||!i||s)return;const{tr:a}=o,{types:c,attributeName:u,generateID:d}=this.options,h=$a(r.doc,n),{mapping:f}=h;if(Ua(h).forEach(({newRange:m})=>{const v=vp(o.doc,m,C=>c.includes(C.type.name)),b=v.map(({node:C})=>C.attrs[u]).filter(C=>C!==null);v.forEach(({node:C,pos:x},w)=>{var E;const S=(E=a.doc.nodeAt(x))==null?void 0:E.attrs[u];if(S===null){a.setNodeMarkup(x,void 0,{...C.attrs,[u]:d({node:C,pos:x})});return}const k=v[w+1];if(k&&C.content.size===0){if(a.setNodeMarkup(k.pos,void 0,{...k.node.attrs,[u]:S}),b[w+1]=S,k.node.attrs[u])return;const _=d({node:C,pos:x});return a.setNodeMarkup(x,void 0,{...C.attrs,[u]:_}),b[w]=_,a}const M=U7(b),{deleted:I}=f.invert().mapResult(x);I&&M.includes(S)&&a.setNodeMarkup(x,void 0,{...C.attrs,[u]:d({node:C,pos:x})})})}),!!a.steps.length)return a.setStoredMarks(o.tr.storedMarks),a},view(n){const r=o=>{var i;t=(i=n.dom.parentElement)!=null&&i.contains(o.target)?n.dom.parentElement:null};return window.addEventListener("dragstart",r),{destroy(){window.removeEventListener("dragstart",r)}}},props:{handleDOMEvents:{drop:(n,r)=>{var o,i;return(t!==n.dom.parentElement||((o=r.dataTransfer)==null?void 0:o.effectAllowed)==="copyMove"||((i=r.dataTransfer)==null?void 0:i.effectAllowed)==="copy")&&(t=null,e=!0),!1},paste:()=>(e=!0,!1)},transformPasted:n=>{if(!e)return n;const{types:r,attributeName:o}=this.options,i=s=>{const l=[];return s.forEach(a=>{if(a.isText){l.push(a);return}if(!r.includes(a.type.name)){l.push(a.copy(i(a.content)));return}const c=a.type.create({...a.attrs,[o]:null},i(a.content),a.marks);l.push(c)}),A.from(l)};return e=!1,new j(i(n.content),n.openStart,n.openEnd)}}})]}}),K7=W7,q7=20,Cm=(t,e=0)=>{const n=[];return!t.children.length||e>q7||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Cm(r,e+1))}),n},G7=t=>{if(!t.children.length)return;const e=Cm(t);e&&e.forEach(n=>{var r,o;const i=n.getAttribute("style"),s=(o=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:o.getAttribute("style");n.setAttribute("style",`${s};${i}`)})},xm=it.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&G7(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",te(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),J7=Z.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const i=r[o].split(":");if(i.length>=2){const s=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(s==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),wm=Z.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const i=r[o].split(":");if(i.length>=2){const s=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(s==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Z7=Z.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),Y7=Z.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),X7=Z.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});Z.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(J7.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(wm.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(Z7.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(Y7.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(X7.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(xm.configure(this.options.textStyle)),t}});function ss(){return typeof window<"u"}function fr(t){return uc(t)?(t.nodeName||"").toLowerCase():"#document"}function Fe(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function gt(t){var e;return(e=(uc(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function uc(t){return ss()?t instanceof Node||t instanceof Fe(t).Node:!1}function ie(t){return ss()?t instanceof Element||t instanceof Fe(t).Element:!1}function Ue(t){return ss()?t instanceof HTMLElement||t instanceof Fe(t).HTMLElement:!1}function ea(t){return!ss()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Fe(t).ShadowRoot}const Q7=new Set(["inline","contents"]);function ao(t){const{overflow:e,overflowX:n,overflowY:r,display:o}=tt(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!Q7.has(o)}const e4=new Set(["table","td","th"]);function t4(t){return e4.has(fr(t))}const n4=[":popover-open",":modal"];function ls(t){return n4.some(e=>{try{return t.matches(e)}catch{return!1}})}const r4=["transform","translate","scale","rotate","perspective"],o4=["transform","translate","scale","rotate","perspective","filter"],i4=["paint","layout","strict","content"];function dc(t){const e=as(),n=ie(t)?tt(t):t;return r4.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||o4.some(r=>(n.willChange||"").includes(r))||i4.some(r=>(n.contain||"").includes(r))}function s4(t){let e=It(t);for(;Ue(e)&&!Nt(e);){if(dc(e))return e;if(ls(e))return null;e=It(e)}return null}function as(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const l4=new Set(["html","body","#document"]);function Nt(t){return l4.has(fr(t))}function tt(t){return Fe(t).getComputedStyle(t)}function cs(t){return ie(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function It(t){if(fr(t)==="html")return t;const e=t.assignedSlot||t.parentNode||ea(t)&&t.host||gt(t);return ea(e)?e.host:e}function Sm(t){const e=It(t);return Nt(e)?t.ownerDocument?t.ownerDocument.body:t.body:Ue(e)&&ao(e)?e:Sm(e)}function rn(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const o=Sm(t),i=o===((r=t.ownerDocument)==null?void 0:r.body),s=Fe(o);if(i){const l=ta(s);return e.concat(s,s.visualViewport||[],ao(o)?o:[],l&&n?rn(l):[])}return e.concat(o,rn(o,[],n))}function ta(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}const a4=["top","right","bottom","left"],cn=Math.min,$e=Math.max,Pi=Math.round,Oo=Math.floor,ht=t=>({x:t,y:t}),c4={left:"right",right:"left",bottom:"top",top:"bottom"},u4={start:"end",end:"start"};function na(t,e,n){return $e(t,cn(e,n))}function Lt(t,e){return typeof t=="function"?t(e):t}function Dt(t){return t.split("-")[0]}function hr(t){return t.split("-")[1]}function fc(t){return t==="x"?"y":"x"}function hc(t){return t==="y"?"height":"width"}const d4=new Set(["top","bottom"]);function ut(t){return d4.has(Dt(t))?"y":"x"}function pc(t){return fc(ut(t))}function f4(t,e,n){n===void 0&&(n=!1);const r=hr(t),o=pc(t),i=hc(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=ji(s)),[s,ji(s)]}function h4(t){const e=ji(t);return[ra(t),e,ra(e)]}function ra(t){return t.replace(/start|end/g,e=>u4[e])}const Wd=["left","right"],Kd=["right","left"],p4=["top","bottom"],m4=["bottom","top"];function g4(t,e,n){switch(t){case"top":case"bottom":return n?e?Kd:Wd:e?Wd:Kd;case"left":case"right":return e?p4:m4;default:return[]}}function y4(t,e,n,r){const o=hr(t);let i=g4(Dt(t),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),e&&(i=i.concat(i.map(ra)))),i}function ji(t){return t.replace(/left|right|bottom|top/g,e=>c4[e])}function v4(t){return{top:0,right:0,bottom:0,left:0,...t}}function km(t){return typeof t!="number"?v4(t):{top:t,right:t,bottom:t,left:t}}function Bi(t){const{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}/*!
174
174
  * tabbable 6.3.0
175
175
  * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
176
- */var u4=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],oa=u4.join(","),vm=typeof Element>"u",Gr=vm?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Bi=!vm&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},Jr=function(e,n){var r;n===void 0&&(n=!0);var o=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),i=o===""||o==="true",s=i||n&&e&&Jr(e.parentNode);return s},d4=function(e){var n,r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return r===""||r==="true"},f4=function(e,n,r){if(Jr(e))return[];var o=Array.prototype.slice.apply(e.querySelectorAll(oa));return n&&Gr.call(e,oa)&&o.unshift(e),o=o.filter(r),o},ia=function(e,n,r){for(var o=[],i=Array.from(e);i.length;){var s=i.shift();if(!Jr(s,!1))if(s.tagName==="SLOT"){var l=s.assignedElements(),a=l.length?l:s.children,c=ia(a,!0,r);r.flatten?o.push.apply(o,c):o.push({scopeParent:s,candidates:c})}else{var u=Gr.call(s,oa);u&&r.filter(s)&&(n||!e.includes(s))&&o.push(s);var d=s.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(s),h=!Jr(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(s));if(d&&h){var f=ia(d===!0?s.children:d.children,!0,r);r.flatten?o.push.apply(o,f):o.push({scopeParent:s,candidates:f})}else i.unshift.apply(i,s.children)}}return o},bm=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Cm=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||d4(e))&&!bm(e)?0:e.tabIndex},h4=function(e,n){var r=Cm(e);return r<0&&n&&!bm(e)?0:r},p4=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},xm=function(e){return e.tagName==="INPUT"},m4=function(e){return xm(e)&&e.type==="hidden"},g4=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return n},y4=function(e,n){for(var r=0;r<e.length;r++)if(e[r].checked&&e[r].form===n)return e[r]},v4=function(e){if(!e.name)return!0;var n=e.form||Bi(e),r=function(l){return n.querySelectorAll('input[type="radio"][name="'+l+'"]')},o;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")o=r(window.CSS.escape(e.name));else try{o=r(e.name)}catch(s){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",s.message),!1}var i=y4(o,e.form);return!i||i===e},b4=function(e){return xm(e)&&e.type==="radio"},C4=function(e){return b4(e)&&!v4(e)},x4=function(e){var n,r=e&&Bi(e),o=(n=r)===null||n===void 0?void 0:n.host,i=!1;if(r&&r!==e){var s,l,a;for(i=!!((s=o)!==null&&s!==void 0&&(l=s.ownerDocument)!==null&&l!==void 0&&l.contains(o)||e!=null&&(a=e.ownerDocument)!==null&&a!==void 0&&a.contains(e));!i&&o;){var c,u,d;r=Bi(o),o=(c=r)===null||c===void 0?void 0:c.host,i=!!((u=o)!==null&&u!==void 0&&(d=u.ownerDocument)!==null&&d!==void 0&&d.contains(o))}}return i},Hd=function(e){var n=e.getBoundingClientRect(),r=n.width,o=n.height;return r===0&&o===0},w4=function(e,n){var r=n.displayCheck,o=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in e){var i=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!i}if(getComputedStyle(e).visibility==="hidden")return!0;var s=Gr.call(e,"details>summary:first-of-type"),l=s?e.parentElement:e;if(Gr.call(l,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof o=="function"){for(var a=e;e;){var c=e.parentElement,u=Bi(e);if(c&&!c.shadowRoot&&o(c)===!0)return Hd(e);e.assignedSlot?e=e.assignedSlot:!c&&u!==e.ownerDocument?e=u.host:e=c}e=a}if(x4(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return Hd(e);return!1},S4=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var o=n.children.item(r);if(o.tagName==="LEGEND")return Gr.call(n,"fieldset[disabled] *")?!0:!o.contains(e)}return!0}n=n.parentElement}return!1},k4=function(e,n){return!(n.disabled||Jr(n)||m4(n)||w4(n,e)||g4(n)||S4(n))},Fd=function(e,n){return!(C4(n)||Cm(n)<0||!k4(e,n))},E4=function(e){var n=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},wm=function(e){var n=[],r=[];return e.forEach(function(o,i){var s=!!o.scopeParent,l=s?o.scopeParent:o,a=h4(l,s),c=s?wm(o.candidates):l;a===0?s?n.push.apply(n,c):n.push(l):r.push({documentOrder:i,tabIndex:a,item:o,isScope:s,content:c})}),r.sort(p4).reduce(function(o,i){return i.isScope?o.push.apply(o,i.content):o.push(i.content),o},[]).concat(n)},Sm=function(e,n){n=n||{};var r;return n.getShadowRoot?r=ia([e],n.includeContainer,{filter:Fd.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:E4}):r=f4(e,n.includeContainer,Fd.bind(null,n)),wm(r)};function M4(){const t=navigator.userAgentData;return t!=null&&t.platform?t.platform:navigator.platform}function T4(){const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?t.brands.map(e=>{let{brand:n,version:r}=e;return n+"/"+r}).join(" "):navigator.userAgent}function km(){return/apple/i.test(navigator.vendor)}function A4(){return M4().toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints}function R4(){return T4().includes("jsdom/")}const $d="data-floating-ui-focusable",O4="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function sa(t){let e=t.activeElement;for(;((n=e)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;e=e.shadowRoot.activeElement}return e}function ar(t,e){if(!t||!e)return!1;const n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&ea(n)){let r=e;for(;r;){if(t===r)return!0;r=r.parentNode||r.host}}return!1}function Gn(t){return"composedPath"in t?t.composedPath()[0]:t.target}function rl(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const n=t;return n.target!=null&&e.contains(n.target)}function N4(t){return t.matches("html,body")}function dt(t){return t?.ownerDocument||document}function I4(t){return Ue(t)&&t.matches(O4)}function L4(t){if(!t||R4())return!0;try{return t.matches(":focus-visible")}catch{return!0}}function D4(t){return t?t.hasAttribute($d)?t:t.querySelector("["+$d+"]")||t:null}function Vo(t,e,n){return n===void 0&&(n=!0),t.filter(o=>{var i;return o.parentId===e&&(!n||((i=o.context)==null?void 0:i.open))}).flatMap(o=>[o,...Vo(t,o.id,n)])}function P4(t){return"nativeEvent"in t}function la(t,e){const n=["mouse","pen"];return n.push("",void 0),n.includes(t)}var j4=typeof document<"u",B4=function(){},ot=j4?D.useLayoutEffect:B4;const _4={...y};function Oo(t){const e=y.useRef(t);return ot(()=>{e.current=t}),e}const H4=_4.useInsertionEffect,F4=H4||(t=>t());function at(t){const e=y.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return F4(()=>{e.current=t}),y.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e.current==null?void 0:e.current(...r)},[])}const Em=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Mm(t,e){const n=Sm(t,Em()),r=n.length;if(r===0)return;const o=sa(dt(t)),i=n.indexOf(o),s=i===-1?e===1?0:r-1:i+e;return n[s]}function $4(t){return Mm(dt(t).body,1)||t}function V4(t){return Mm(dt(t).body,-1)||t}function ol(t,e){const n=e||t.currentTarget,r=t.relatedTarget;return!r||!ar(n,r)}function z4(t){Sm(t,Em()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Vd(t){t.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function zd(t,e,n){let{reference:r,floating:o}=t;const i=ut(e),s=fc(e),l=dc(s),a=Dt(e),c=i==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,h=r[l]/2-o[l]/2;let f;switch(a){case"top":f={x:u,y:r.y-o.height};break;case"bottom":f={x:u,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:d};break;case"left":f={x:r.x-o.width,y:d};break;default:f={x:r.x,y:r.y}}switch(fr(e)){case"start":f[s]-=h*(n&&c?-1:1);break;case"end":f[s]+=h*(n&&c?-1:1);break}return f}const U4=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,l=i.filter(Boolean),a=await(s.isRTL==null?void 0:s.isRTL(e));let c=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:u,y:d}=zd(c,r,a),h=r,f={},p=0;for(let m=0;m<l.length;m++){const{name:v,fn:b}=l[m],{x:C,y:x,data:w,reset:E}=await b({x:u,y:d,initialPlacement:r,placement:h,strategy:o,middlewareData:f,rects:c,platform:s,elements:{reference:t,floating:e}});u=C??u,d=x??d,f={...f,[v]:{...f[v],...w}},E&&p<=50&&(p++,typeof E=="object"&&(E.placement&&(h=E.placement),E.rects&&(c=E.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:o}):E.rects),{x:u,y:d}=zd(c,h,a)),m=-1)}return{x:u,y:d,placement:h,strategy:o,middlewareData:f}};async function Zr(t,e){var n;e===void 0&&(e={});const{x:r,y:o,platform:i,rects:s,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:f=0}=Lt(e,t),p=ym(f),v=l[h?d==="floating"?"reference":"floating":d],b=ji(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(v)))==null||n?v:v.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),C=d==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),w=await(i.isElement==null?void 0:i.isElement(x))?await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},E=ji(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:C,offsetParent:x,strategy:a}):C);return{top:(b.top-E.top+p.top)/w.y,bottom:(E.bottom-b.bottom+p.bottom)/w.y,left:(b.left-E.left+p.left)/w.x,right:(E.right-b.right+p.right)/w.x}}const W4=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:o,rects:i,platform:s,elements:l,middlewareData:a}=e,{element:c,padding:u=0}=Lt(t,e)||{};if(c==null)return{};const d=ym(u),h={x:n,y:r},f=fc(o),p=dc(f),m=await s.getDimensions(c),v=f==="y",b=v?"top":"left",C=v?"bottom":"right",x=v?"clientHeight":"clientWidth",w=i.reference[p]+i.reference[f]-h[f]-i.floating[p],E=h[f]-i.reference[f],k=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c));let S=k?k[x]:0;(!S||!await(s.isElement==null?void 0:s.isElement(k)))&&(S=l.floating[x]||i.floating[p]);const M=w/2-E/2,I=S/2-m[p]/2-1,j=cn(d[b],I),_=cn(d[C],I),U=j,F=S-m[p]-_,O=S/2-m[p]/2+M,H=na(U,O,F),V=!a.arrow&&fr(o)!=null&&O!==H&&i.reference[p]/2-(O<U?j:_)-m[p]/2<0,L=V?O<U?O-U:O-F:0;return{[f]:h[f]+L,data:{[f]:H,centerOffset:O-H-L,...V&&{alignmentOffset:L}},reset:V}}}),K4=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...v}=Lt(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=Dt(o),C=ut(l),x=Dt(l)===l,w=await(a.isRTL==null?void 0:a.isRTL(c.floating)),E=h||(x||!m?[Pi(l)]:o4(l)),k=p!=="none";!h&&k&&E.push(...a4(l,m,p,w));const S=[l,...E],M=await Zr(e,v),I=[];let j=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&I.push(M[b]),d){const O=r4(o,s,w);I.push(M[O[0]],M[O[1]])}if(j=[...j,{placement:o,overflows:I}],!I.every(O=>O<=0)){var _,U;const O=(((_=i.flip)==null?void 0:_.index)||0)+1,H=S[O];if(H&&(!(d==="alignment"?C!==ut(H):!1)||j.every(T=>ut(T.placement)===C?T.overflows[0]>0:!0)))return{data:{index:O,overflows:j},reset:{placement:H}};let V=(U=j.filter(L=>L.overflows[0]<=0).sort((L,T)=>L.overflows[1]-T.overflows[1])[0])==null?void 0:U.placement;if(!V)switch(f){case"bestFit":{var F;const L=(F=j.filter(T=>{if(k){const R=ut(T.placement);return R===C||R==="y"}return!0}).map(T=>[T.placement,T.overflows.filter(R=>R>0).reduce((R,W)=>R+W,0)]).sort((T,R)=>T[1]-R[1])[0])==null?void 0:F[0];L&&(V=L);break}case"initialPlacement":V=l;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function Ud(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Wd(t){return Q7.some(e=>t[e]>=0)}const q4=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...o}=Lt(t,e);switch(r){case"referenceHidden":{const i=await Zr(e,{...o,elementContext:"reference"}),s=Ud(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:Wd(s)}}}case"escaped":{const i=await Zr(e,{...o,altBoundary:!0}),s=Ud(i,n.floating);return{data:{escapedOffsets:s,escaped:Wd(s)}}}default:return{}}}}},Tm=new Set(["left","top"]);async function G4(t,e){const{placement:n,platform:r,elements:o}=t,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Dt(n),l=fr(n),a=ut(n)==="y",c=Tm.has(s)?-1:1,u=i&&a?-1:1,d=Lt(e,t);let{mainAxis:h,crossAxis:f,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof p=="number"&&(f=l==="end"?p*-1:p),a?{x:f*u,y:h*c}:{x:h*c,y:f*u}}const J4=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:o,y:i,placement:s,middlewareData:l}=e,a=await G4(e,t);return s===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+a.x,y:i+a.y,data:{...a,placement:s}}}}},Z4=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:o}=e,{mainAxis:i=!0,crossAxis:s=!1,limiter:l={fn:v=>{let{x:b,y:C}=v;return{x:b,y:C}}},...a}=Lt(t,e),c={x:n,y:r},u=await Zr(e,a),d=ut(Dt(o)),h=uc(d);let f=c[h],p=c[d];if(i){const v=h==="y"?"top":"left",b=h==="y"?"bottom":"right",C=f+u[v],x=f-u[b];f=na(C,f,x)}if(s){const v=d==="y"?"top":"left",b=d==="y"?"bottom":"right",C=p+u[v],x=p-u[b];p=na(C,p,x)}const m=l.fn({...e,[h]:f,[d]:p});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[h]:i,[d]:s}}}}}},Y4=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=e,{offset:l=0,mainAxis:a=!0,crossAxis:c=!0}=Lt(t,e),u={x:n,y:r},d=ut(o),h=uc(d);let f=u[h],p=u[d];const m=Lt(l,e),v=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(a){const x=h==="y"?"height":"width",w=i.reference[h]-i.floating[x]+v.mainAxis,E=i.reference[h]+i.reference[x]-v.mainAxis;f<w?f=w:f>E&&(f=E)}if(c){var b,C;const x=h==="y"?"width":"height",w=Tm.has(Dt(o)),E=i.reference[d]-i.floating[x]+(w&&((b=s.offset)==null?void 0:b[d])||0)+(w?0:v.crossAxis),k=i.reference[d]+i.reference[x]+(w?0:((C=s.offset)==null?void 0:C[d])||0)-(w?v.crossAxis:0);p<E?p=E:p>k&&(p=k)}return{[h]:f,[d]:p}}}},X4=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:o,rects:i,platform:s,elements:l}=e,{apply:a=()=>{},...c}=Lt(t,e),u=await Zr(e,c),d=Dt(o),h=fr(o),f=ut(o)==="y",{width:p,height:m}=i.floating;let v,b;d==="top"||d==="bottom"?(v=d,b=h===(await(s.isRTL==null?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(b=d,v=h==="end"?"top":"bottom");const C=m-u.top-u.bottom,x=p-u.left-u.right,w=cn(m-u[v],C),E=cn(p-u[b],x),k=!e.middlewareData.shift;let S=w,M=E;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(M=x),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(S=C),k&&!h){const j=$e(u.left,0),_=$e(u.right,0),U=$e(u.top,0),F=$e(u.bottom,0);f?M=p-2*(j!==0||_!==0?j+_:$e(u.left,u.right)):S=m-2*(U!==0||F!==0?U+F:$e(u.top,u.bottom))}await a({...e,availableWidth:M,availableHeight:S});const I=await s.getDimensions(l.floating);return p!==I.width||m!==I.height?{reset:{rects:!0}}:{}}}};function Am(t){const e=tt(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=Ue(t),i=o?t.offsetWidth:n,s=o?t.offsetHeight:r,l=Di(n)!==i||Di(r)!==s;return l&&(n=i,r=s),{width:n,height:r,$:l}}function hc(t){return ie(t)?t:t.contextElement}function Qn(t){const e=hc(t);if(!Ue(e))return ft(1);const n=e.getBoundingClientRect(),{width:r,height:o,$:i}=Am(e);let s=(i?Di(n.width):n.width)/r,l=(i?Di(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const Q4=ft(0);function Rm(t){const e=Fe(t);return!as()||!e.visualViewport?Q4:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function e5(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Fe(t)?!1:e}function In(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),i=hc(t);let s=ft(1);e&&(r?ie(r)&&(s=Qn(r)):s=Qn(t));const l=e5(i,n,r)?Rm(i):ft(0);let a=(o.left+l.x)/s.x,c=(o.top+l.y)/s.y,u=o.width/s.x,d=o.height/s.y;if(i){const h=Fe(i),f=r&&ie(r)?Fe(r):r;let p=h,m=ta(p);for(;m&&r&&f!==p;){const v=Qn(m),b=m.getBoundingClientRect(),C=tt(m),x=b.left+(m.clientLeft+parseFloat(C.paddingLeft))*v.x,w=b.top+(m.clientTop+parseFloat(C.paddingTop))*v.y;a*=v.x,c*=v.y,u*=v.x,d*=v.y,a+=x,c+=w,p=Fe(m),m=ta(p)}}return ji({width:u,height:d,x:a,y:c})}function us(t,e){const n=cs(t).scrollLeft;return e?e.left+n:In(mt(t)).left+n}function Om(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-us(t,n),o=n.top+e.scrollTop;return{x:r,y:o}}function t5(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t;const i=o==="fixed",s=mt(r),l=e?ls(e.floating):!1;if(r===s||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=ft(1);const u=ft(0),d=Ue(r);if((d||!d&&!i)&&((dr(r)!=="body"||so(s))&&(a=cs(r)),Ue(r))){const f=In(r);c=Qn(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}const h=s&&!d&&!i?Om(s,a):ft(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-a.scrollTop*c.y+u.y+h.y}}function n5(t){return Array.from(t.getClientRects())}function r5(t){const e=mt(t),n=cs(t),r=t.ownerDocument.body,o=$e(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=$e(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+us(t);const l=-n.scrollTop;return tt(r).direction==="rtl"&&(s+=$e(e.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:l}}const Kd=25;function o5(t,e){const n=Fe(t),r=mt(t),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,l=0,a=0;if(o){i=o.width,s=o.height;const u=as();(!u||u&&e==="fixed")&&(l=o.offsetLeft,a=o.offsetTop)}const c=us(r);if(c<=0){const u=r.ownerDocument,d=u.body,h=getComputedStyle(d),f=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-f);p<=Kd&&(i-=p)}else c<=Kd&&(i+=c);return{width:i,height:s,x:l,y:a}}const i5=new Set(["absolute","fixed"]);function s5(t,e){const n=In(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,i=Ue(t)?Qn(t):ft(1),s=t.clientWidth*i.x,l=t.clientHeight*i.y,a=o*i.x,c=r*i.y;return{width:s,height:l,x:a,y:c}}function qd(t,e,n){let r;if(e==="viewport")r=o5(t,n);else if(e==="document")r=r5(mt(t));else if(ie(e))r=s5(e,n);else{const o=Rm(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return ji(r)}function Nm(t,e){const n=It(t);return n===e||!ie(n)||Nt(n)?!1:tt(n).position==="fixed"||Nm(n,e)}function l5(t,e){const n=e.get(t);if(n)return n;let r=rn(t,[],!1).filter(l=>ie(l)&&dr(l)!=="body"),o=null;const i=tt(t).position==="fixed";let s=i?It(t):t;for(;ie(s)&&!Nt(s);){const l=tt(s),a=cc(s);!a&&l.position==="fixed"&&(o=null),(i?!a&&!o:!a&&l.position==="static"&&!!o&&i5.has(o.position)||so(s)&&!a&&Nm(t,s))?r=r.filter(u=>u!==s):o=l,s=It(s)}return e.set(t,r),r}function a5(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t;const s=[...n==="clippingAncestors"?ls(e)?[]:l5(e,this._c):[].concat(n),r],l=s[0],a=s.reduce((c,u)=>{const d=qd(e,u,o);return c.top=$e(d.top,c.top),c.right=cn(d.right,c.right),c.bottom=cn(d.bottom,c.bottom),c.left=$e(d.left,c.left),c},qd(e,l,o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function c5(t){const{width:e,height:n}=Am(t);return{width:e,height:n}}function u5(t,e,n){const r=Ue(e),o=mt(e),i=n==="fixed",s=In(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const a=ft(0);function c(){a.x=us(o)}if(r||!r&&!i)if((dr(e)!=="body"||so(o))&&(l=cs(e)),r){const f=In(e,!0,i,e);a.x=f.x+e.clientLeft,a.y=f.y+e.clientTop}else o&&c();i&&!r&&o&&c();const u=o&&!r&&!i?Om(o,l):ft(0),d=s.left+l.scrollLeft-a.x-u.x,h=s.top+l.scrollTop-a.y-u.y;return{x:d,y:h,width:s.width,height:s.height}}function il(t){return tt(t).position==="static"}function Gd(t,e){if(!Ue(t)||tt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return mt(t)===n&&(n=n.ownerDocument.body),n}function Im(t,e){const n=Fe(t);if(ls(t))return n;if(!Ue(t)){let o=It(t);for(;o&&!Nt(o);){if(ie(o)&&!il(o))return o;o=It(o)}return n}let r=Gd(t,e);for(;r&&K7(r)&&il(r);)r=Gd(r,e);return r&&Nt(r)&&il(r)&&!cc(r)?n:r||Y7(t)||n}const d5=async function(t){const e=this.getOffsetParent||Im,n=this.getDimensions,r=await n(t.floating);return{reference:u5(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function f5(t){return tt(t).direction==="rtl"}const h5={convertOffsetParentRelativeRectToViewportRelativeRect:t5,getDocumentElement:mt,getClippingRect:a5,getOffsetParent:Im,getElementRects:d5,getClientRects:n5,getDimensions:c5,getScale:Qn,isElement:ie,isRTL:f5};function Lm(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function p5(t,e){let n=null,r;const o=mt(t);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function s(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),i();const c=t.getBoundingClientRect(),{left:u,top:d,width:h,height:f}=c;if(l||e(),!h||!f)return;const p=Ro(d),m=Ro(o.clientWidth-(u+h)),v=Ro(o.clientHeight-(d+f)),b=Ro(u),x={rootMargin:-p+"px "+-m+"px "+-v+"px "+-b+"px",threshold:$e(0,cn(1,a))||1};let w=!0;function E(k){const S=k[0].intersectionRatio;if(S!==a){if(!w)return s();S?s(!1,S):r=setTimeout(()=>{s(!1,1e-7)},1e3)}S===1&&!Lm(c,t.getBoundingClientRect())&&s(),w=!1}try{n=new IntersectionObserver(E,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(E,x)}n.observe(t)}return s(!0),i}function Dm(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=hc(t),u=o||i?[...c?rn(c):[],...rn(e)]:[];u.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),i&&b.addEventListener("resize",n)});const d=c&&l?p5(c,n):null;let h=-1,f=null;s&&(f=new ResizeObserver(b=>{let[C]=b;C&&C.target===c&&f&&(f.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var x;(x=f)==null||x.observe(e)})),n()}),c&&!a&&f.observe(c),f.observe(e));let p,m=a?In(t):null;a&&v();function v(){const b=In(t);m&&!Lm(m,b)&&n(),m=b,p=requestAnimationFrame(v)}return n(),()=>{var b;u.forEach(C=>{o&&C.removeEventListener("scroll",n),i&&C.removeEventListener("resize",n)}),d?.(),(b=f)==null||b.disconnect(),f=null,a&&cancelAnimationFrame(p)}}const m5=J4,g5=Z4,y5=K4,v5=X4,b5=q4,Jd=W4,C5=Y4,x5=(t,e,n)=>{const r=new Map,o={platform:h5,...n},i={...o.platform,_c:r};return U4(t,e,{...o,platform:i})};var w5=typeof document<"u",S5=function(){},zo=w5?D.useLayoutEffect:S5;function _i(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,o;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!_i(t[r],e[r]))return!1;return!0}if(o=Object.keys(t),n=o.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&t.$$typeof)&&!_i(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function Pm(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Zd(t,e){const n=Pm(t);return Math.round(e*n)/n}function sl(t){const e=y.useRef(t);return zo(()=>{e.current=t}),e}function jm(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:l=!0,whileElementsMounted:a,open:c}=t,[u,d]=y.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,f]=y.useState(r);_i(h,r)||f(r);const[p,m]=y.useState(null),[v,b]=y.useState(null),C=y.useCallback(T=>{T!==k.current&&(k.current=T,m(T))},[]),x=y.useCallback(T=>{T!==S.current&&(S.current=T,b(T))},[]),w=i||p,E=s||v,k=y.useRef(null),S=y.useRef(null),M=y.useRef(u),I=a!=null,j=sl(a),_=sl(o),U=sl(c),F=y.useCallback(()=>{if(!k.current||!S.current)return;const T={placement:e,strategy:n,middleware:h};_.current&&(T.platform=_.current),x5(k.current,S.current,T).then(R=>{const W={...R,isPositioned:U.current!==!1};O.current&&!_i(M.current,W)&&(M.current=W,va.flushSync(()=>{d(W)}))})},[h,e,n,_,U]);zo(()=>{c===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,d(T=>({...T,isPositioned:!1})))},[c]);const O=y.useRef(!1);zo(()=>(O.current=!0,()=>{O.current=!1}),[]),zo(()=>{if(w&&(k.current=w),E&&(S.current=E),w&&E){if(j.current)return j.current(w,E,F);F()}},[w,E,F,j,I]);const H=y.useMemo(()=>({reference:k,floating:S,setReference:C,setFloating:x}),[C,x]),V=y.useMemo(()=>({reference:w,floating:E}),[w,E]),L=y.useMemo(()=>{const T={position:n,left:0,top:0};if(!V.floating)return T;const R=Zd(V.floating,u.x),W=Zd(V.floating,u.y);return l?{...T,transform:"translate("+R+"px, "+W+"px)",...Pm(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:R,top:W}},[n,l,V.floating,u.x,u.y]);return y.useMemo(()=>({...u,update:F,refs:H,elements:V,floatingStyles:L}),[u,F,H,V,L])}const k5=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:o}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?Jd({element:r.current,padding:o}).fn(n):{}:r?Jd({element:r,padding:o}).fn(n):{}}}},Bm=(t,e)=>({...m5(t),options:[t,e]}),_m=(t,e)=>({...g5(t),options:[t,e]}),E5=(t,e)=>({...C5(t),options:[t,e]}),Hm=(t,e)=>({...y5(t),options:[t,e]}),M5=(t,e)=>({...v5(t),options:[t,e]}),T5=(t,e)=>({...b5(t),options:[t,e]}),A5=(t,e)=>({...k5(t),options:[t,e]});function Fm(t){const e=y.useRef(void 0),n=y.useCallback(r=>{const o=t.map(i=>{if(i!=null){if(typeof i=="function"){const s=i,l=s(r);return typeof l=="function"?l:()=>{s(null)}}return i.current=r,()=>{i.current=null}}});return()=>{o.forEach(i=>i?.())}},t);return y.useMemo(()=>t.every(r=>r==null)?null:r=>{e.current&&(e.current(),e.current=void 0),r!=null&&(e.current=n(r))},t)}const R5="data-floating-ui-focusable",Yd="active",Xd="selected",O5={...y};let Qd=!1,N5=0;const ef=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+N5++;function I5(){const[t,e]=y.useState(()=>Qd?ef():void 0);return ot(()=>{t==null&&e(ef())},[]),y.useEffect(()=>{Qd=!0},[]),t}const L5=O5.useId,pc=L5||I5;let aa;process.env.NODE_ENV!=="production"&&(aa=new Set);function D5(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];const o="Floating UI: "+n.join(" ");if(!((t=aa)!=null&&t.has(o))){var i;(i=aa)==null||i.add(o),console.error(o)}}function P5(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(o=>o(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const j5=y.createContext(null),B5=y.createContext(null),mc=()=>{var t;return((t=y.useContext(j5))==null?void 0:t.id)||null},gc=()=>y.useContext(B5);function lo(t){return"data-floating-ui-"+t}function Ge(t){t.current!==-1&&(clearTimeout(t.current),t.current=-1)}const tf=lo("safe-polygon");function ll(t,e,n){if(n&&!la(n))return 0;if(typeof t=="number")return t;if(typeof t=="function"){const r=t();return typeof r=="number"?r:r?.[e]}return t?.[e]}function al(t){return typeof t=="function"?t():t}function _5(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,dataRef:o,events:i,elements:s}=t,{enabled:l=!0,delay:a=0,handleClose:c=null,mouseOnly:u=!1,restMs:d=0,move:h=!0}=e,f=gc(),p=mc(),m=Oo(c),v=Oo(a),b=Oo(n),C=Oo(d),x=y.useRef(),w=y.useRef(-1),E=y.useRef(),k=y.useRef(-1),S=y.useRef(!0),M=y.useRef(!1),I=y.useRef(()=>{}),j=y.useRef(!1),_=at(()=>{var L;const T=(L=o.current.openEvent)==null?void 0:L.type;return T?.includes("mouse")&&T!=="mousedown"});y.useEffect(()=>{if(!l)return;function L(T){let{open:R}=T;R||(Ge(w),Ge(k),S.current=!0,j.current=!1)}return i.on("openchange",L),()=>{i.off("openchange",L)}},[l,i]),y.useEffect(()=>{if(!l||!m.current||!n)return;function L(R){_()&&r(!1,R,"hover")}const T=dt(s.floating).documentElement;return T.addEventListener("mouseleave",L),()=>{T.removeEventListener("mouseleave",L)}},[s.floating,n,r,l,m,_]);const U=y.useCallback(function(L,T,R){T===void 0&&(T=!0),R===void 0&&(R="hover");const W=ll(v.current,"close",x.current);W&&!E.current?(Ge(w),w.current=window.setTimeout(()=>r(!1,L,R),W)):T&&(Ge(w),r(!1,L,R))},[v,r]),F=at(()=>{I.current(),E.current=void 0}),O=at(()=>{if(M.current){const L=dt(s.floating).body;L.style.pointerEvents="",L.removeAttribute(tf),M.current=!1}}),H=at(()=>o.current.openEvent?["click","mousedown"].includes(o.current.openEvent.type):!1);y.useEffect(()=>{if(!l)return;function L(K){if(Ge(w),S.current=!1,u&&!la(x.current)||al(C.current)>0&&!ll(v.current,"open"))return;const Y=ll(v.current,"open",x.current);Y?w.current=window.setTimeout(()=>{b.current||r(!0,K,"hover")},Y):n||r(!0,K,"hover")}function T(K){if(H()){O();return}I.current();const Y=dt(s.floating);if(Ge(k),j.current=!1,m.current&&o.current.floatingContext){n||Ge(w),E.current=m.current({...o.current.floatingContext,tree:f,x:K.clientX,y:K.clientY,onClose(){O(),F(),H()||U(K,!0,"safe-polygon")}});const ce=E.current;Y.addEventListener("mousemove",ce),I.current=()=>{Y.removeEventListener("mousemove",ce)};return}(x.current==="touch"?!ar(s.floating,K.relatedTarget):!0)&&U(K)}function R(K){H()||o.current.floatingContext&&(m.current==null||m.current({...o.current.floatingContext,tree:f,x:K.clientX,y:K.clientY,onClose(){O(),F(),H()||U(K)}})(K))}function W(){Ge(w)}function te(K){H()||U(K,!1)}if(ie(s.domReference)){const K=s.domReference,Y=s.floating;return n&&K.addEventListener("mouseleave",R),h&&K.addEventListener("mousemove",L,{once:!0}),K.addEventListener("mouseenter",L),K.addEventListener("mouseleave",T),Y&&(Y.addEventListener("mouseleave",R),Y.addEventListener("mouseenter",W),Y.addEventListener("mouseleave",te)),()=>{n&&K.removeEventListener("mouseleave",R),h&&K.removeEventListener("mousemove",L),K.removeEventListener("mouseenter",L),K.removeEventListener("mouseleave",T),Y&&(Y.removeEventListener("mouseleave",R),Y.removeEventListener("mouseenter",W),Y.removeEventListener("mouseleave",te))}}},[s,l,t,u,h,U,F,O,r,n,b,f,v,m,o,H,C]),ot(()=>{var L;if(l&&n&&(L=m.current)!=null&&(L=L.__options)!=null&&L.blockPointerEvents&&_()){M.current=!0;const R=s.floating;if(ie(s.domReference)&&R){var T;const W=dt(s.floating).body;W.setAttribute(tf,"");const te=s.domReference,K=f==null||(T=f.nodesRef.current.find(Y=>Y.id===p))==null||(T=T.context)==null?void 0:T.elements.floating;return K&&(K.style.pointerEvents=""),W.style.pointerEvents="none",te.style.pointerEvents="auto",R.style.pointerEvents="auto",()=>{W.style.pointerEvents="",te.style.pointerEvents="",R.style.pointerEvents=""}}}},[l,n,p,s,f,m,_]),ot(()=>{n||(x.current=void 0,j.current=!1,F(),O())},[n,F,O]),y.useEffect(()=>()=>{F(),Ge(w),Ge(k),O()},[l,s.domReference,F,O]);const V=y.useMemo(()=>{function L(T){x.current=T.pointerType}return{onPointerDown:L,onPointerEnter:L,onMouseMove(T){const{nativeEvent:R}=T;function W(){!S.current&&!b.current&&r(!0,R,"hover")}u&&!la(x.current)||n||al(C.current)===0||j.current&&T.movementX**2+T.movementY**2<2||(Ge(k),x.current==="touch"?W():(j.current=!0,k.current=window.setTimeout(W,al(C.current))))}}},[u,r,n,b,C]);return y.useMemo(()=>l?{reference:V}:{},[l,V])}const nf=()=>{},H5=y.createContext({delay:0,initialDelay:0,timeoutMs:0,currentId:null,setCurrentId:nf,setState:nf,isInstantPhase:!1});function F5(t){const{children:e,delay:n,timeoutMs:r=0}=t,[o,i]=y.useReducer((a,c)=>({...a,...c}),{delay:n,timeoutMs:r,initialDelay:n,currentId:null,isInstantPhase:!1}),s=y.useRef(null),l=y.useCallback(a=>{i({currentId:a})},[]);return ot(()=>{o.currentId?s.current===null?s.current=o.currentId:o.isInstantPhase||i({isInstantPhase:!0}):(o.isInstantPhase&&i({isInstantPhase:!1}),s.current=null)},[o.currentId,o.isInstantPhase]),g.jsx(H5.Provider,{value:y.useMemo(()=>({...o,setState:i,setCurrentId:l}),[o,l]),children:e})}const $m={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},rf=y.forwardRef(function(e,n){const[r,o]=y.useState();ot(()=>{km()&&o("button")},[]);const i={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[lo("focus-guard")]:"",style:$m};return g.jsx("span",{...e,...i})}),Vm=y.createContext(null),of=lo("portal");function $5(t){t===void 0&&(t={});const{id:e,root:n}=t,r=pc(),o=z5(),[i,s]=y.useState(null),l=y.useRef(null);return ot(()=>()=>{i?.remove(),queueMicrotask(()=>{l.current=null})},[i]),ot(()=>{if(!r||l.current)return;const a=e?document.getElementById(e):null;if(!a)return;const c=document.createElement("div");c.id=r,c.setAttribute(of,""),a.appendChild(c),l.current=c,s(c)},[e,r]),ot(()=>{if(n===null||!r||l.current)return;let a=n||o?.portalNode;a&&!ac(a)&&(a=a.current),a=a||document.body;let c=null;e&&(c=document.createElement("div"),c.id=e,a.appendChild(c));const u=document.createElement("div");u.id=r,u.setAttribute(of,""),a=c||a,a.appendChild(u),l.current=u,s(u)},[e,n,r,o]),i}function V5(t){const{children:e,id:n,root:r,preserveTabOrder:o=!0}=t,i=$5({id:n,root:r}),[s,l]=y.useState(null),a=y.useRef(null),c=y.useRef(null),u=y.useRef(null),d=y.useRef(null),h=s?.modal,f=s?.open,p=!!s&&!s.modal&&s.open&&o&&!!(r||i);return y.useEffect(()=>{if(!i||!o||h)return;function m(v){i&&ol(v)&&(v.type==="focusin"?Vd:z4)(i)}return i.addEventListener("focusin",m,!0),i.addEventListener("focusout",m,!0),()=>{i.removeEventListener("focusin",m,!0),i.removeEventListener("focusout",m,!0)}},[i,o,h]),y.useEffect(()=>{i&&(f||Vd(i))},[f,i]),g.jsxs(Vm.Provider,{value:y.useMemo(()=>({preserveTabOrder:o,beforeOutsideRef:a,afterOutsideRef:c,beforeInsideRef:u,afterInsideRef:d,portalNode:i,setFocusManagerState:l}),[o,i]),children:[p&&i&&g.jsx(rf,{"data-type":"outside",ref:a,onFocus:m=>{if(ol(m,i)){var v;(v=u.current)==null||v.focus()}else{const b=s?s.domReference:null,C=V4(b);C?.focus()}}}),p&&i&&g.jsx("span",{"aria-owns":i.id,style:$m}),i&&va.createPortal(e,i),p&&i&&g.jsx(rf,{"data-type":"outside",ref:c,onFocus:m=>{if(ol(m,i)){var v;(v=d.current)==null||v.focus()}else{const b=s?s.domReference:null,C=$4(b);C?.focus(),s?.closeOnFocusOut&&s?.onOpenChange(!1,m.nativeEvent,"focus-out")}}})]})}const z5=()=>y.useContext(Vm),U5={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},W5={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},sf=t=>{var e,n;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(n=t?.outsidePress)!=null?n:!0}};function K5(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,elements:o,dataRef:i}=t,{enabled:s=!0,escapeKey:l=!0,outsidePress:a=!0,outsidePressEvent:c="pointerdown",referencePress:u=!1,referencePressEvent:d="pointerdown",ancestorScroll:h=!1,bubbles:f,capture:p}=e,m=gc(),v=at(typeof a=="function"?a:()=>!1),b=typeof a=="function"?v:a,C=y.useRef(!1),{escapeKey:x,outsidePress:w}=sf(f),{escapeKey:E,outsidePress:k}=sf(p),S=y.useRef(!1),M=at(O=>{var H;if(!n||!s||!l||O.key!=="Escape"||S.current)return;const V=(H=i.current.floatingContext)==null?void 0:H.nodeId,L=m?Vo(m.nodesRef.current,V):[];if(!x&&(O.stopPropagation(),L.length>0)){let T=!0;if(L.forEach(R=>{var W;if((W=R.context)!=null&&W.open&&!R.context.dataRef.current.__escapeKeyBubbles){T=!1;return}}),!T)return}r(!1,P4(O)?O.nativeEvent:O,"escape-key")}),I=at(O=>{var H;const V=()=>{var L;M(O),(L=Gn(O))==null||L.removeEventListener("keydown",V)};(H=Gn(O))==null||H.addEventListener("keydown",V)}),j=at(O=>{var H;const V=i.current.insideReactTree;i.current.insideReactTree=!1;const L=C.current;if(C.current=!1,c==="click"&&L||V||typeof b=="function"&&!b(O))return;const T=Gn(O),R="["+lo("inert")+"]",W=dt(o.floating).querySelectorAll(R);let te=ie(T)?T:null;for(;te&&!Nt(te);){const ce=It(te);if(Nt(ce)||!ie(ce))break;te=ce}if(W.length&&ie(T)&&!N4(T)&&!ar(T,o.floating)&&Array.from(W).every(ce=>!ar(te,ce)))return;if(Ue(T)&&F){const ce=Nt(T),ye=tt(T),X=/auto|scroll/,ne=ce||X.test(ye.overflowX),Ke=ce||X.test(ye.overflowY),Ct=ne&&T.clientWidth>0&&T.scrollWidth>T.clientWidth,_n=Ke&&T.clientHeight>0&&T.scrollHeight>T.clientHeight,Ss=ye.direction==="rtl",Hn=_n&&(Ss?O.offsetX<=T.offsetWidth-T.clientWidth:O.offsetX>T.clientWidth),j0=Ct&&O.offsetY>T.clientHeight;if(Hn||j0)return}const K=(H=i.current.floatingContext)==null?void 0:H.nodeId,Y=m&&Vo(m.nodesRef.current,K).some(ce=>{var ye;return rl(O,(ye=ce.context)==null?void 0:ye.elements.floating)});if(rl(O,o.floating)||rl(O,o.domReference)||Y)return;const We=m?Vo(m.nodesRef.current,K):[];if(We.length>0){let ce=!0;if(We.forEach(ye=>{var X;if((X=ye.context)!=null&&X.open&&!ye.context.dataRef.current.__outsidePressBubbles){ce=!1;return}}),!ce)return}r(!1,O,"outside-press")}),_=at(O=>{var H;const V=()=>{var L;j(O),(L=Gn(O))==null||L.removeEventListener(c,V)};(H=Gn(O))==null||H.addEventListener(c,V)});y.useEffect(()=>{if(!n||!s)return;i.current.__escapeKeyBubbles=x,i.current.__outsidePressBubbles=w;let O=-1;function H(W){r(!1,W,"ancestor-scroll")}function V(){window.clearTimeout(O),S.current=!0}function L(){O=window.setTimeout(()=>{S.current=!1},as()?5:0)}const T=dt(o.floating);l&&(T.addEventListener("keydown",E?I:M,E),T.addEventListener("compositionstart",V),T.addEventListener("compositionend",L)),b&&T.addEventListener(c,k?_:j,k);let R=[];return h&&(ie(o.domReference)&&(R=rn(o.domReference)),ie(o.floating)&&(R=R.concat(rn(o.floating))),!ie(o.reference)&&o.reference&&o.reference.contextElement&&(R=R.concat(rn(o.reference.contextElement)))),R=R.filter(W=>{var te;return W!==((te=T.defaultView)==null?void 0:te.visualViewport)}),R.forEach(W=>{W.addEventListener("scroll",H,{passive:!0})}),()=>{l&&(T.removeEventListener("keydown",E?I:M,E),T.removeEventListener("compositionstart",V),T.removeEventListener("compositionend",L)),b&&T.removeEventListener(c,k?_:j,k),R.forEach(W=>{W.removeEventListener("scroll",H)}),window.clearTimeout(O)}},[i,o,l,b,c,n,r,h,s,x,w,M,E,I,j,k,_]),y.useEffect(()=>{i.current.insideReactTree=!1},[i,b,c]);const U=y.useMemo(()=>({onKeyDown:M,...u&&{[U5[d]]:O=>{r(!1,O.nativeEvent,"reference-press")},...d!=="click"&&{onClick(O){r(!1,O.nativeEvent,"reference-press")}}}}),[M,r,u,d]),F=y.useMemo(()=>({onKeyDown:M,onMouseDown(){C.current=!0},onMouseUp(){C.current=!0},[W5[c]]:()=>{i.current.insideReactTree=!0}}),[M,c,i]);return y.useMemo(()=>s?{reference:U,floating:F}:{},[s,U,F])}function q5(t){const{open:e=!1,onOpenChange:n,elements:r}=t,o=pc(),i=y.useRef({}),[s]=y.useState(()=>P5()),l=mc()!=null;if(process.env.NODE_ENV!=="production"){const f=r.reference;f&&!ie(f)&&D5("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[a,c]=y.useState(r.reference),u=at((f,p,m)=>{i.current.openEvent=f?p:void 0,s.emit("openchange",{open:f,event:p,reason:m,nested:l}),n?.(f,p,m)}),d=y.useMemo(()=>({setPositionReference:c}),[]),h=y.useMemo(()=>({reference:a||r.reference||null,floating:r.floating||null,domReference:r.reference}),[a,r.reference,r.floating]);return y.useMemo(()=>({dataRef:i,open:e,onOpenChange:u,elements:h,events:s,floatingId:o,refs:d}),[e,u,h,s,o,d])}function G5(t){t===void 0&&(t={});const{nodeId:e}=t,n=q5({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,o=r.elements,[i,s]=y.useState(null),[l,a]=y.useState(null),u=o?.domReference||i,d=y.useRef(null),h=gc();ot(()=>{u&&(d.current=u)},[u]);const f=jm({...t,elements:{...o,...l&&{reference:l}}}),p=y.useCallback(x=>{const w=ie(x)?{getBoundingClientRect:()=>x.getBoundingClientRect(),getClientRects:()=>x.getClientRects(),contextElement:x}:x;a(w),f.refs.setReference(w)},[f.refs]),m=y.useCallback(x=>{(ie(x)||x===null)&&(d.current=x,s(x)),(ie(f.refs.reference.current)||f.refs.reference.current===null||x!==null&&!ie(x))&&f.refs.setReference(x)},[f.refs]),v=y.useMemo(()=>({...f.refs,setReference:m,setPositionReference:p,domReference:d}),[f.refs,m,p]),b=y.useMemo(()=>({...f.elements,domReference:u}),[f.elements,u]),C=y.useMemo(()=>({...f,...r,refs:v,elements:b,nodeId:e}),[f,v,b,e,r]);return ot(()=>{r.dataRef.current.floatingContext=C;const x=h?.nodesRef.current.find(w=>w.id===e);x&&(x.context=C)}),y.useMemo(()=>({...f,context:C,refs:v,elements:b}),[f,v,b,C])}function cl(){return A4()&&km()}function J5(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,events:o,dataRef:i,elements:s}=t,{enabled:l=!0,visibleOnly:a=!0}=e,c=y.useRef(!1),u=y.useRef(-1),d=y.useRef(!0);y.useEffect(()=>{if(!l)return;const f=Fe(s.domReference);function p(){!n&&Ue(s.domReference)&&s.domReference===sa(dt(s.domReference))&&(c.current=!0)}function m(){d.current=!0}function v(){d.current=!1}return f.addEventListener("blur",p),cl()&&(f.addEventListener("keydown",m,!0),f.addEventListener("pointerdown",v,!0)),()=>{f.removeEventListener("blur",p),cl()&&(f.removeEventListener("keydown",m,!0),f.removeEventListener("pointerdown",v,!0))}},[s.domReference,n,l]),y.useEffect(()=>{if(!l)return;function f(p){let{reason:m}=p;(m==="reference-press"||m==="escape-key")&&(c.current=!0)}return o.on("openchange",f),()=>{o.off("openchange",f)}},[o,l]),y.useEffect(()=>()=>{Ge(u)},[]);const h=y.useMemo(()=>({onMouseLeave(){c.current=!1},onFocus(f){if(c.current)return;const p=Gn(f.nativeEvent);if(a&&ie(p)){if(cl()&&!f.relatedTarget){if(!d.current&&!I4(p))return}else if(!L4(p))return}r(!0,f.nativeEvent,"focus")},onBlur(f){c.current=!1;const p=f.relatedTarget,m=f.nativeEvent,v=ie(p)&&p.hasAttribute(lo("focus-guard"))&&p.getAttribute("data-type")==="outside";u.current=window.setTimeout(()=>{var b;const C=sa(s.domReference?s.domReference.ownerDocument:document);!p&&C===s.domReference||ar((b=i.current.floatingContext)==null?void 0:b.refs.floating.current,C)||ar(s.domReference,C)||v||r(!1,m,"focus")})}}),[i,s.domReference,r,a]);return y.useMemo(()=>l?{reference:h}:{},[l,h])}function ul(t,e,n){const r=new Map,o=n==="item";let i=t;if(o&&t){const{[Yd]:s,[Xd]:l,...a}=t;i=a}return{...n==="floating"&&{tabIndex:-1,[R5]:""},...i,...e.map(s=>{const l=s?s[n]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((s,l)=>(l&&Object.entries(l).forEach(a=>{let[c,u]=a;if(!(o&&[Yd,Xd].includes(c)))if(c.indexOf("on")===0){if(r.has(c)||r.set(c,[]),typeof u=="function"){var d;(d=r.get(c))==null||d.push(u),s[c]=function(){for(var h,f=arguments.length,p=new Array(f),m=0;m<f;m++)p[m]=arguments[m];return(h=r.get(c))==null?void 0:h.map(v=>v(...p)).find(v=>v!==void 0)}}}else s[c]=u}),s),{})}}function Z5(t){t===void 0&&(t=[]);const e=t.map(l=>l?.reference),n=t.map(l=>l?.floating),r=t.map(l=>l?.item),o=y.useCallback(l=>ul(l,t,"reference"),e),i=y.useCallback(l=>ul(l,t,"floating"),n),s=y.useCallback(l=>ul(l,t,"item"),r);return y.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:s}),[o,i,s])}const Y5=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function X5(t,e){var n,r;e===void 0&&(e={});const{open:o,elements:i,floatingId:s}=t,{enabled:l=!0,role:a="dialog"}=e,c=pc(),u=((n=i.domReference)==null?void 0:n.id)||c,d=y.useMemo(()=>{var C;return((C=D4(i.floating))==null?void 0:C.id)||s},[i.floating,s]),h=(r=Y5.get(a))!=null?r:a,p=mc()!=null,m=y.useMemo(()=>h==="tooltip"||a==="label"?{["aria-"+(a==="label"?"labelledby":"describedby")]:o?d:void 0}:{"aria-expanded":o?"true":"false","aria-haspopup":h==="alertdialog"?"dialog":h,"aria-controls":o?d:void 0,...h==="listbox"&&{role:"combobox"},...h==="menu"&&{id:u},...h==="menu"&&p&&{role:"menuitem"},...a==="select"&&{"aria-autocomplete":"none"},...a==="combobox"&&{"aria-autocomplete":"list"}},[h,d,p,o,u,a]),v=y.useMemo(()=>{const C={id:d,...h&&{role:h}};return h==="tooltip"||a==="label"?C:{...C,...h==="menu"&&{"aria-labelledby":u}}},[h,d,u,a]),b=y.useCallback(C=>{let{active:x,selected:w}=C;const E={role:"option",...x&&{id:d+"-fui-option"}};switch(a){case"select":case"combobox":return{...E,"aria-selected":w}}return{}},[d,a]);return y.useMemo(()=>l?{reference:m,floating:v,item:b}:{},[l,m,v,b])}function Q5({initialOpen:t=!1,placement:e="top",open:n,onOpenChange:r,delay:o=600,closeDelay:i=0}={}){const[s,l]=y.useState(t),a=n??s,c=r??l,u=G5({placement:e,open:a,onOpenChange:c,whileElementsMounted:Dm,middleware:[Bm(4),Hm({crossAxis:e.includes("-"),fallbackAxisSideDirection:"start",padding:4}),_m({padding:4})]}),d=u.context,h=_5(d,{mouseOnly:!0,move:!1,restMs:o,enabled:n==null,delay:{close:i}}),f=J5(d,{enabled:n==null}),p=K5(d),m=X5(d,{role:"tooltip"}),v=Z5([h,f,p,m]);return y.useMemo(()=>({open:a,setOpen:c,...v,...u}),[a,c,v,u])}const ca=y.createContext(null);function zm(){const t=y.useContext(ca);if(t==null)throw new Error("Tooltip components must be wrapped in <TooltipProvider />");return t}function Um({children:t,...e}){const n=Q5(e);return e.useDelayGroup?g.jsx(F5,{delay:{open:e.delay??0,close:e.closeDelay??0},timeoutMs:e.timeout,children:g.jsx(ca.Provider,{value:n,children:t})}):g.jsx(ca.Provider,{value:n,children:t})}const Wm=y.forwardRef(function({children:e,asChild:n=!1,...r},o){const i=zm(),s=y.isValidElement(e)?parseInt(y.version,10)>=19?e.props.ref:e.ref:void 0,l=Fm([i.refs.setReference,o,s]);if(n&&y.isValidElement(e)){const a={"data-tooltip-state":i.open?"open":"closed"};return y.cloneElement(e,i.getReferenceProps({ref:l,...r,...typeof e.props=="object"?e.props:{},...a}))}return g.jsx("button",{ref:l,"data-tooltip-state":i.open?"open":"closed",...i.getReferenceProps(r),children:e})}),Km=y.forwardRef(function({style:e,children:n,portal:r=!0,portalProps:o={},...i},s){const l=zm(),a=Fm([l.refs.setFloating,s]);if(!l.open)return null;const c=g.jsx("div",{ref:a,style:{...l.floatingStyles,...e},...l.getFloatingProps(i),className:"tiptap-tooltip",children:n});return r?g.jsx(V5,{...o,children:c}):c});Um.displayName="Tooltip";Wm.displayName="TooltipTrigger";Km.displayName="TooltipContent";const ua=5*1024*1024,e3={mod:"⌘",command:"⌘",meta:"⌘",ctrl:"⌃",control:"⌃",alt:"⌥",option:"⌥",shift:"⇧",backspace:"Del",delete:"⌦",enter:"⏎",escape:"⎋",capslock:"⇪"};function Me(...t){return t.filter(Boolean).join(" ")}function t3(){return typeof navigator<"u"&&navigator.platform.toLowerCase().includes("mac")}const n3=(t,e,n=!0)=>{if(e){const r=t.toLowerCase();return e3[r]||(n?t.toUpperCase():t)}return n?t.charAt(0).toUpperCase()+t.slice(1):t},gt=t=>{const{shortcutKeys:e,delimiter:n="+",capitalize:r=!0}=t;return e?e.split(n).map(o=>o.trim()).map(o=>n3(o,t3(),r)):[]},Dn=(t,e)=>e?.schema?e.schema.spec.marks.get(t)!==void 0:!1,Bt=(t,e)=>e?.schema?e.schema.spec.nodes.get(t)!==void 0:!1;function r3(t){const{state:e,view:n}=t,{doc:r,selection:o}=e,i=q.findFrom(o.$to,1,!0);if(i)return n.dispatch(e.tr.setSelection(i).scrollIntoView()),!0;const s=e.schema.nodes.paragraph;if(!s)return console.warn("No paragraph node type found in schema."),!1;const l=r.content.size,a=s.create();let c=e.tr.insert(l,a);const u=c.doc.resolve(l+1);return c=c.setSelection(z.near(u)).scrollIntoView(),n.dispatch(c),!0}function yt(t){return typeof t=="number"&&t>=0}function ds(t,e){if(!t)return!1;const n=Array.isArray(e)?e:[e],r=n.some(o=>t.extensionManager.extensions.some(i=>i.name===o));return r||console.warn(`None of the extensions [${n.join(", ")}] were found in the editor schema. Ensure they are included in the editor configuration.`),r}function o3(t,e){try{const n=t.state.doc.nodeAt(e);return n||(console.warn(`No node found at position ${e}`),null)}catch(n){return console.error(`Error getting node at position ${e}:`,n),null}}function hn(t){const{editor:e,node:n,nodePos:r}=t;if(!e||!e.state?.doc)return null;const o=n!=null,i=yt(r);if(!o&&!i)return null;if(o){let s=-1,l=null;if(e.state.doc.descendants((a,c)=>a===n?(s=c,l=a,!1):!0),s!==-1&&l!==null)return{pos:s,node:l}}if(i){const s=o3(e,r);if(s)return{pos:r,node:s}}return null}function vt(t,e=[]){if(!t||!t.state.selection)return!1;const{state:n}=t,{selection:r}=n;if(r.empty)return!1;if(r instanceof B){const o=r.node;return o?e.includes(o.type.name):!1}return!1}const i3=async(t,e,n)=>{if(!t)throw new Error("No file provided");if(t.size>ua)throw new Error(`File size exceeds maximum allowed (${ua/(1024*1024)}MB)`);for(let r=0;r<=100;r+=10){if(n?.aborted)throw new Error("Upload cancelled");await new Promise(o=>setTimeout(o,500)),e?.({progress:r})}return"/images/tiptap-ui-placeholder-image.jpg"},s3=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function l3(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return!t||t.replace(s3,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}function a3(t,e,n){try{const r=new URL(t,e);if(l3(r.href,n))return r.href}catch{}return"#"}const c3=({shortcuts:t})=>t.length===0?null:g.jsx("div",{children:t.map((e,n)=>g.jsxs(y.Fragment,{children:[n>0&&g.jsx("kbd",{children:"+"}),g.jsx("kbd",{children:e})]},n))}),le=y.forwardRef(({className:t,children:e,tooltip:n,showTooltip:r=!0,shortcutKeys:o,"aria-label":i,...s},l)=>{const a=y.useMemo(()=>gt({shortcutKeys:o}),[o]);return!n||!r?g.jsx("button",{className:Me("tiptap-button",t),ref:l,"aria-label":i,...s,children:e}):g.jsxs(Um,{delay:200,children:[g.jsx(Wm,{className:Me("tiptap-button",t),ref:l,"aria-label":i,...s,children:e}),g.jsxs(Km,{children:[n,g.jsx(c3,{shortcuts:a})]})]})});le.displayName="Button";const Tt=y.forwardRef(({className:t,children:e,orientation:n="vertical",...r},o)=>g.jsx("div",{ref:o,className:Me("tiptap-button-group",t),"data-orientation":n,role:"group",...r,children:e}));Tt.displayName="ButtonGroup";function lf({orientation:t="horizontal",size:e,style:n={},...r}){const o={...n,...t==="horizontal"&&!e&&{flex:1},...e&&{width:t==="vertical"?"1px":e,height:t==="horizontal"?"1px":e}};return g.jsx("div",{...r,style:o})}const er=y.forwardRef(({decorative:t,orientation:e="vertical",className:n,...r},o)=>{const s=t?{role:"none"}:{"aria-orientation":e==="vertical"?e:void 0,role:"separator"};return g.jsx("div",{className:Me("tiptap-separator",n),"data-orientation":e,...s,...r,ref:o})});er.displayName="Separator";function qm({editor:t,containerRef:e,query:n,items:r,onSelect:o,onClose:i,orientation:s="vertical",autoSelectFirstItem:l=!0}){const[a,c]=y.useState(l?0:-1);return y.useEffect(()=>{const u=h=>{if(!r.length)return!1;const f=()=>c(m=>m===-1?0:(m+1)%r.length),p=()=>c(m=>m===-1?r.length-1:(m-1+r.length)%r.length);switch(h.key){case"ArrowUp":return s==="horizontal"?!1:(h.preventDefault(),p(),!0);case"ArrowDown":return s==="horizontal"?!1:(h.preventDefault(),f(),!0);case"ArrowLeft":return s==="vertical"?!1:(h.preventDefault(),p(),!0);case"ArrowRight":return s==="vertical"?!1:(h.preventDefault(),f(),!0);case"Tab":return h.preventDefault(),h.shiftKey?p():f(),!0;case"Home":return h.preventDefault(),c(0),!0;case"End":return h.preventDefault(),c(r.length-1),!0;case"Enter":return h.isComposing?!1:(h.preventDefault(),a!==-1&&r[a]&&o?.(r[a]),!0);case"Escape":return h.preventDefault(),i?.(),!0;default:return!1}};let d=null;if(t?d=t.view.dom:e?.current&&(d=e.current),d)return d.addEventListener("keydown",u,!0),()=>{d?.removeEventListener("keydown",u,!0)}},[t,e,r,a,o,i,s]),y.useEffect(()=>{n&&c(l?0:-1)},[n,l]),{selectedIndex:r.length?a:void 0,setSelectedIndex:c}}const af=(t,e)=>{typeof t=="function"?t(e):t&&typeof t=="object"&&"current"in t&&(t.current=e)},u3=(t,e)=>{const n=y.useRef(null);return y.useCallback(r=>{t&&"current"in t&&(t.current=r),n.current&&af(n.current,null),n.current=e,e&&af(e,r)},[t,e])},d3=t=>{const[e,n]=y.useState([]),r=y.useCallback(()=>t.current?Array.from(t.current.querySelectorAll('button:not([disabled]), [role="button"]:not([disabled]), [tabindex="0"]:not([disabled])')):[],[t]);y.useEffect(()=>{const i=t.current;if(!i)return;const s=()=>n(r());s();const l=new MutationObserver(s);return l.observe(i,{childList:!0,subtree:!0}),()=>l.disconnect()},[r,t]);const{selectedIndex:o}=qm({containerRef:t,items:e,orientation:"horizontal",onSelect:i=>i.click(),autoSelectFirstItem:!1});y.useEffect(()=>{const i=t.current;if(!i)return;const s=a=>{const c=a.target;i.contains(c)&&c.setAttribute("data-focus-visible","true")},l=a=>{const c=a.target;i.contains(c)&&c.removeAttribute("data-focus-visible")};return i.addEventListener("focus",s,!0),i.addEventListener("blur",l,!0),()=>{i.removeEventListener("focus",s,!0),i.removeEventListener("blur",l,!0)}},[t]),y.useEffect(()=>{o!==void 0&&e[o]&&e[o].focus()},[o,e])},yc=y.forwardRef(({children:t,className:e,variant:n="fixed",...r},o)=>{const i=y.useRef(null),s=u3(i,o);return d3(i),g.jsx("div",{ref:s,role:"toolbar","aria-label":"toolbar","data-variant":n,className:Me("tiptap-toolbar",e),...r,children:t})});yc.displayName="Toolbar";const qt=y.forwardRef(({children:t,className:e,...n},r)=>g.jsx("div",{ref:r,role:"group",className:Me("tiptap-toolbar-group",e),...n,children:t}));qt.displayName="ToolbarGroup";const Gt=y.forwardRef(({...t},e)=>g.jsx(er,{ref:e,orientation:"vertical",decorative:!0,...t}));Gt.displayName="ToolbarSeparator";const Gm=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{d:"M18.7071 6.70711C19.0976 6.31658 19.0976 5.68342 18.7071 5.29289C18.3166 4.90237 17.6834 4.90237 17.2929 5.29289L12 10.5858L6.70711 5.29289C6.31658 4.90237 5.68342 4.90237 5.29289 5.29289C4.90237 5.68342 4.90237 6.31658 5.29289 6.70711L10.5858 12L5.29289 17.2929C4.90237 17.6834 4.90237 18.3166 5.29289 18.7071C5.68342 19.0976 6.31658 19.0976 6.70711 18.7071L12 13.4142L17.2929 18.7071C17.6834 19.0976 18.3166 19.0976 18.7071 18.7071C19.0976 18.3166 19.0976 17.6834 18.7071 17.2929L13.4142 12L18.7071 6.70711Z",fill:"currentColor"})}));Gm.displayName="CloseIcon";function f3(t){const[e,n]=y.useState([]),r=async l=>{if(l.size>t.maxSize){const d=new Error(`File size exceeds maximum allowed (${t.maxSize/1024/1024}MB)`);return t.onError?.(d),null}const a=new AbortController,c=crypto.randomUUID(),u={id:c,file:l,progress:0,status:"uploading",abortController:a};n(d=>[...d,u]);try{if(!t.upload)throw new Error("Upload function is not defined");const d=await t.upload(l,h=>{n(f=>f.map(p=>p.id===c?{...p,progress:h.progress}:p))},a.signal);if(!d)throw new Error("Upload failed: No URL returned");return a.signal.aborted?null:(n(h=>h.map(f=>f.id===c?{...f,status:"success",url:d,progress:100}:f)),t.onSuccess?.(d),d)}catch(d){return a.signal.aborted||(n(h=>h.map(f=>f.id===c?{...f,status:"error",progress:0}:f)),t.onError?.(d instanceof Error?d:new Error("Upload failed"))),null}};return{fileItems:e,uploadFiles:async l=>{if(!l||l.length===0)return t.onError?.(new Error("No files to upload")),[];if(t.limit&&l.length>t.limit)return t.onError?.(new Error(`Maximum ${t.limit} file${t.limit===1?"":"s"} allowed`)),[];const a=l.map(u=>r(u));return(await Promise.all(a)).filter(u=>u!==null)},removeFileItem:l=>{n(a=>{const c=a.find(u=>u.id===l);return c?.abortController&&c.abortController.abort(),c?.url&&URL.revokeObjectURL(c.url),a.filter(u=>u.id!==l)})},clearAllFiles:()=>{e.forEach(l=>{l.abortController&&l.abortController.abort(),l.url&&URL.revokeObjectURL(l.url)}),n([])}}}const Jm=()=>g.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"tiptap-image-upload-icon",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[g.jsx("path",{d:"M11.1953 4.41771C10.3478 4.08499 9.43578 3.94949 8.5282 4.02147C7.62062 4.09345 6.74133 4.37102 5.95691 4.83316C5.1725 5.2953 4.50354 5.92989 4.00071 6.68886C3.49788 7.44783 3.17436 8.31128 3.05465 9.2138C2.93495 10.1163 3.0222 11.0343 3.3098 11.8981C3.5974 12.7619 4.07781 13.5489 4.71463 14.1995C5.10094 14.5942 5.09414 15.2274 4.69945 15.6137C4.30476 16 3.67163 15.9932 3.28532 15.5985C2.43622 14.731 1.79568 13.6816 1.41221 12.5299C1.02875 11.3781 0.91241 10.1542 1.07201 8.95084C1.23162 7.74748 1.66298 6.59621 2.33343 5.58425C3.00387 4.57229 3.89581 3.72617 4.9417 3.10998C5.98758 2.4938 7.15998 2.1237 8.37008 2.02773C9.58018 1.93176 10.7963 2.11243 11.9262 2.55605C13.0561 2.99968 14.0703 3.69462 14.8919 4.58825C15.5423 5.29573 16.0585 6.11304 16.4177 7.00002H17.4999C18.6799 6.99991 19.8288 7.37933 20.7766 8.08222C21.7245 8.78515 22.4212 9.7743 22.7637 10.9036C23.1062 12.0328 23.0765 13.2423 22.6788 14.3534C22.2812 15.4644 21.5367 16.4181 20.5554 17.0736C20.0962 17.3803 19.4752 17.2567 19.1684 16.7975C18.8617 16.3382 18.9853 15.7172 19.4445 15.4105C20.069 14.9934 20.5427 14.3865 20.7958 13.6794C21.0488 12.9724 21.0678 12.2027 20.8498 11.4841C20.6318 10.7655 20.1885 10.136 19.5853 9.6887C18.9821 9.24138 18.251 8.99993 17.5001 9.00002H15.71C15.2679 9.00002 14.8783 8.70973 14.7518 8.28611C14.4913 7.41374 14.0357 6.61208 13.4195 5.94186C12.8034 5.27164 12.0427 4.75043 11.1953 4.41771Z",fill:"currentColor"}),g.jsx("path",{d:"M11 14.4142V21C11 21.5523 11.4477 22 12 22C12.5523 22 13 21.5523 13 21V14.4142L15.2929 16.7071C15.6834 17.0976 16.3166 17.0976 16.7071 16.7071C17.0976 16.3166 17.0976 15.6834 16.7071 15.2929L12.7078 11.2936C12.7054 11.2912 12.703 11.2888 12.7005 11.2864C12.5208 11.1099 12.2746 11.0008 12.003 11L12 11L11.997 11C11.8625 11.0004 11.7343 11.0273 11.6172 11.0759C11.502 11.1236 11.3938 11.1937 11.2995 11.2864C11.297 11.2888 11.2946 11.2912 11.2922 11.2936L7.29289 15.2929C6.90237 15.6834 6.90237 16.3166 7.29289 16.7071C7.68342 17.0976 8.31658 17.0976 8.70711 16.7071L11 14.4142Z",fill:"currentColor"})]}),h3=()=>g.jsx("svg",{width:"43",height:"57",viewBox:"0 0 43 57",fill:"currentColor",className:"tiptap-image-upload-dropzone-rect-primary",xmlns:"http://www.w3.org/2000/svg",children:g.jsx("path",{d:"M0.75 10.75C0.75 5.64137 4.89137 1.5 10 1.5H32.3431C33.2051 1.5 34.0317 1.84241 34.6412 2.4519L40.2981 8.10876C40.9076 8.71825 41.25 9.5449 41.25 10.4069V46.75C41.25 51.8586 37.1086 56 32 56H10C4.89137 56 0.75 51.8586 0.75 46.75V10.75Z",fill:"currentColor",fillOpacity:"0.11",stroke:"currentColor",strokeWidth:"1.5"})}),p3=()=>g.jsx("svg",{width:"10",height:"10",className:"tiptap-image-upload-dropzone-rect-secondary",viewBox:"0 0 10 10",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:g.jsx("path",{d:"M0 0.75H0.343146C1.40401 0.75 2.42143 1.17143 3.17157 1.92157L8.82843 7.57843C9.57857 8.32857 10 9.34599 10 10.4069V10.75H4C1.79086 10.75 0 8.95914 0 6.75V0.75Z",fill:"currentColor"})}),m3=({onFile:t,children:e})=>{const[n,r]=y.useState(!1),[o,i]=y.useState(!1),s=u=>{u.preventDefault(),u.stopPropagation(),i(!0)},l=u=>{u.preventDefault(),u.stopPropagation(),u.currentTarget.contains(u.relatedTarget)||(i(!1),r(!1))},a=u=>{u.preventDefault(),u.stopPropagation(),r(!0)},c=u=>{u.preventDefault(),u.stopPropagation(),i(!1),r(!1);const d=Array.from(u.dataTransfer.files);d.length>0&&t(d)};return g.jsx("div",{className:`tiptap-image-upload-drag-area ${o?"drag-active":""} ${n?"drag-over":""}`,onDragEnter:s,onDragLeave:l,onDragOver:a,onDrop:c,children:e})},g3=({fileItem:t,onRemove:e})=>{const n=r=>{if(r===0)return"0 Bytes";const o=1024,i=["Bytes","KB","MB","GB"],s=Math.floor(Math.log(r)/Math.log(o));return`${parseFloat((r/Math.pow(o,s)).toFixed(2))} ${i[s]}`};return g.jsxs("div",{className:"tiptap-image-upload-preview",children:[t.status==="uploading"&&g.jsx("div",{className:"tiptap-image-upload-progress",style:{width:`${t.progress}%`}}),g.jsxs("div",{className:"tiptap-image-upload-preview-content",children:[g.jsxs("div",{className:"tiptap-image-upload-file-info",children:[g.jsx("div",{className:"tiptap-image-upload-file-icon",children:g.jsx(Jm,{})}),g.jsxs("div",{className:"tiptap-image-upload-details",children:[g.jsx("span",{className:"tiptap-image-upload-text",children:t.file.name}),g.jsx("span",{className:"tiptap-image-upload-subtext",children:n(t.file.size)})]})]}),g.jsxs("div",{className:"tiptap-image-upload-actions",children:[t.status==="uploading"&&g.jsxs("span",{className:"tiptap-image-upload-progress-text",children:[t.progress,"%"]}),g.jsx(le,{type:"button","data-style":"ghost",onClick:r=>{r.stopPropagation(),e()},children:g.jsx(Gm,{className:"tiptap-button-icon"})})]})]})]})},y3=({maxSize:t,limit:e})=>g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"tiptap-image-upload-dropzone",children:[g.jsx(h3,{}),g.jsx(p3,{}),g.jsx("div",{className:"tiptap-image-upload-icon-container",children:g.jsx(Jm,{})})]}),g.jsxs("div",{className:"tiptap-image-upload-content",children:[g.jsxs("span",{className:"tiptap-image-upload-text",children:[g.jsx("em",{children:"Click to upload"})," or drag and drop"]}),g.jsxs("span",{className:"tiptap-image-upload-subtext",children:["Maximum ",e," file",e===1?"":"s",", ",t/1024/1024,"MB each."]})]})]}),v3=t=>{const{accept:e,limit:n,maxSize:r}=t.node.attrs,o=y.useRef(null),i=t.extension,s={maxSize:r,limit:n,accept:e,upload:i.options.upload,onSuccess:i.options.onSuccess,onError:i.options.onError},{fileItems:l,uploadFiles:a,removeFileItem:c,clearAllFiles:u}=f3(s),d=async m=>{const v=await a(m);if(v.length>0){const b=t.getPos();if(yt(b)){const C=v.map((x,w)=>{const E=m[w]?.name.replace(/\.[^/.]+$/,"")||"unknown";return{type:i.options.type,attrs:{...i.options,src:x,alt:E,title:E}}});t.editor.chain().focus().deleteRange({from:b,to:b+t.node.nodeSize}).insertContentAt(b,C).run(),r3(t.editor)}}},h=m=>{const v=m.target.files;if(!v||v.length===0){i.options.onError?.(new Error("No file selected"));return}d(Array.from(v))},f=()=>{o.current&&l.length===0&&(o.current.value="",o.current.click())},p=l.length>0;return g.jsxs(Bp,{className:"tiptap-image-upload",tabIndex:0,onClick:f,children:[!p&&g.jsx(m3,{onFile:d,children:g.jsx(y3,{maxSize:r,limit:n})}),p&&g.jsxs("div",{className:"tiptap-image-upload-previews",children:[l.length>1&&g.jsxs("div",{className:"tiptap-image-upload-header",children:[g.jsxs("span",{children:["Uploading ",l.length," files"]}),g.jsx(le,{type:"button","data-style":"ghost",onClick:m=>{m.stopPropagation(),u()},children:"Clear All"})]}),l.map(m=>g.jsx(g3,{fileItem:m,onRemove:()=>c(m.id)},m.id))]}),g.jsx("input",{ref:o,name:"file",accept:e,type:"file",multiple:n>1,onChange:h,onClick:m=>m.stopPropagation()})]})},b3=je.create({name:"imageUpload",group:"block",draggable:!0,atom:!0,addOptions(){return{type:"image",accept:"image/*",limit:1,maxSize:0,upload:void 0,onError:void 0,onSuccess:void 0,HTMLAttributes:{}}},addAttributes(){return{accept:{default:this.options.accept},limit:{default:this.options.limit},maxSize:{default:this.options.maxSize}}},parseHTML(){return[{tag:'div[data-type="image-upload"]'}]},renderHTML({HTMLAttributes:t}){return["div",oe({"data-type":"image-upload"},t)]},addNodeView(){return _p(v3)},addCommands(){return{setImageUploadNode:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addKeyboardShortcuts(){return{Enter:({editor:t})=>{const{selection:e}=t.state,{nodeAfter:n}=e.$from;if(n&&n.type.name==="imageUpload"&&t.isActive("imageUpload")){const r=t.view.nodeDOM(e.$from.pos);if(r&&r instanceof HTMLElement){const o=r.firstChild;if(o&&o instanceof HTMLElement)return o.click(),!0}}return!1}}}}),C3=Bx.extend({renderHTML(){return["div",oe(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}}),x3=({node:t,updateAttributes:e,selected:n})=>{const[r,o]=D.useState(!1),[i,s]=D.useState(t.attrs.width||300),[l,a]=D.useState(t.attrs.alt||""),c=D.useRef(null),u=D.useRef(null),d=D.useRef(null),h=D.useRef(!1),f=D.useRef(0),p=D.useRef(0),m=D.useRef(e);m.current=e;const v=t.attrs.imageId||`img-${Date.now()}`;D.useEffect(()=>{h.current||s(t.attrs.width||300)},[t.attrs.width]),D.useEffect(()=>{a(t.attrs.alt||"")},[t.attrs.alt]);const b=D.useCallback(_=>{a(_.target.value)},[]),C=D.useCallback(()=>{e({alt:l})},[l,e]),x=D.useCallback(_=>{_.key==="Enter"&&(_.preventDefault(),c.current?.blur()),_.stopPropagation()},[]);D.useEffect(()=>{const _=F=>{if(!h.current)return;const O=F.clientX-f.current,H=Math.max(50,p.current+O);s(H),d.current&&(d.current.style.width=`${H}px`)},U=()=>{h.current&&(h.current=!1,o(!1),s(F=>{const O=Math.round(F);return m.current({width:O}),O}))};return document.addEventListener("mousemove",_),document.addEventListener("mouseup",U),()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",U)}},[]);const w=D.useCallback(_=>{_.preventDefault(),_.stopPropagation(),h.current=!0,o(!0),f.current=_.clientX,p.current=d.current?.getBoundingClientRect().width??300},[]),E=D.useCallback(()=>{},[]),k=t.attrs.textAlign||"left",S=k==="center"?"center":k==="right"?"flex-end":"flex-start",M={position:"relative",display:"inline-block",width:i,maxWidth:"100%",userSelect:r?"none":"auto",outline:n?"2px solid #007bff":"none",outlineOffset:"2px"},I={width:"100%",height:"auto",display:"block",objectFit:"contain"},j={position:"absolute",bottom:-5,right:-5,width:12,height:12,background:"#007bff",border:"2px solid white",borderRadius:"50%",cursor:"nw-resize",opacity:n||r?1:0,transition:"opacity 0.2s ease",zIndex:10,boxShadow:"0 2px 4px rgba(0,0,0,0.2)"};return g.jsx(Bp,{className:"resizable-image-wrapper",style:{display:"flex",justifyContent:S},children:g.jsxs("div",{ref:d,id:`resizable-image-${v}`,style:M,onMouseEnter:()=>{if(d.current){const _=d.current.querySelector(".resize-handle");_&&(_.style.opacity="1")}},onMouseLeave:()=>{if(!r&&!n&&d.current){const _=d.current.querySelector(".resize-handle");_&&(_.style.opacity="0")}},children:[g.jsx("img",{ref:u,src:t.attrs.src,alt:t.attrs.alt||"",title:t.attrs.title||"",style:I,onLoad:E,"data-drag-handle":"",draggable:!1}),g.jsx("div",{className:"resize-handle",style:j,onMouseDown:w,title:"拖拽調整圖片大小"}),(n||r)&&g.jsxs("div",{style:{position:"absolute",top:-25,left:0,background:"rgba(0, 0, 0, 0.8)",color:"white",padding:"2px 6px",borderRadius:"3px",fontSize:"12px",whiteSpace:"nowrap",zIndex:11},children:[Math.round(i)," × auto"]}),n&&g.jsx("div",{className:"resizable-image-alt-input",children:g.jsx("input",{ref:c,type:"text",value:l,onChange:b,onBlur:C,onKeyDown:x,placeholder:"Add alt text…"})})]})})},w3=je.create({name:"resizableImage",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null,parseHTML:t=>{const e=t.getAttribute("width");return e?parseInt(e):null},renderHTML:t=>t.width?{width:t.width,height:"auto"}:{}},imageId:{default:null,parseHTML:t=>t.getAttribute("data-image-id"),renderHTML:t=>t.imageId?{"data-image-id":t.imageId}:{}}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])',getAttrs:t=>{const e=t,n=e.getAttribute("width"),r=e.getAttribute("data-image-id");return{src:e.getAttribute("src"),alt:e.getAttribute("alt"),title:e.getAttribute("title"),width:n?parseInt(n):300,imageId:r||`img-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}}}]},renderHTML({HTMLAttributes:t}){return["img",oe(this.options.HTMLAttributes,t)]},addCommands(){return{setResizableImage:t=>({commands:e})=>{const n=`img-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return e.insertContent({type:this.name,attrs:{...t,imageId:n,width:t.width||300}})},setImageSize:t=>({commands:e})=>e.updateAttributes(this.name,t)}},addNodeView(){return _p(x3)}}),vc=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.29289 8.29289C5.68342 7.90237 6.31658 7.90237 6.70711 8.29289L12 13.5858L17.2929 8.29289C17.6834 7.90237 18.3166 7.90237 18.7071 8.29289C19.0976 8.68342 19.0976 9.31658 18.7071 9.70711L12.7071 15.7071C12.3166 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70711C4.90237 9.31658 4.90237 8.68342 5.29289 8.29289Z",fill:"currentColor"})}));vc.displayName="ChevronDownIcon";function ee(t){const{editor:e}=ax(),n=y.useMemo(()=>t||e,[t,e]);return Dp({editor:n,selector(o){return o.editor?{editor:o.editor,editorState:o.editor.state,canCommand:o.editor.can}:{editor:null,editorState:void 0,canCommand:void 0}}})||{editor:null}}const bt=y.forwardRef(({variant:t,size:e="default",appearance:n="default",trimText:r=!1,className:o,children:i,...s},l)=>g.jsx("div",{ref:l,className:`tiptap-badge ${o||""}`,"data-style":t,"data-size":e,"data-appearance":n,"data-text-trim":r?"on":"off",...s,children:i}));bt.displayName="Badge";function S3({level:t,shortcutKeys:e=o1[t]}){return g.jsx(bt,{children:gt({shortcutKeys:e})})}const Zm=y.forwardRef(({editor:t,level:e,text:n,hideWhenUnavailable:r=!1,onToggled:o,showShortcut:i=!1,onClick:s,children:l,...a},c)=>{const{editor:u}=ee(t),{isVisible:d,canToggle:h,isActive:f,handleToggle:p,label:m,Icon:v,shortcutKeys:b}=E3({editor:u,level:e,hideWhenUnavailable:r,onToggled:o}),C=y.useCallback(x=>{s?.(x),!x.defaultPrevented&&p()},[p,s]);return d?g.jsx(le,{type:"button","data-style":"ghost","data-active-state":f?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":m,"aria-pressed":f,tooltip:m,onClick:C,...a,ref:c,children:l??g.jsxs(g.Fragment,{children:[g.jsx(v,{className:"tiptap-button-icon"}),n&&g.jsx("span",{className:"tiptap-button-text",children:n}),i&&g.jsx(S3,{level:e,shortcutKeys:b})]})}):null});Zm.displayName="HeadingButton";const Ym=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),g.jsx("path",{d:"M21.0001 10C21.0001 9.63121 20.7971 9.29235 20.472 9.11833C20.1468 8.94431 19.7523 8.96338 19.4454 9.16795L16.4454 11.168C15.9859 11.4743 15.8617 12.0952 16.1681 12.5547C16.4744 13.0142 17.0953 13.1384 17.5548 12.8321L19.0001 11.8685V18C19.0001 18.5523 19.4478 19 20.0001 19C20.5524 19 21.0001 18.5523 21.0001 18V10Z",fill:"currentColor"})]}));Ym.displayName="HeadingOneIcon";const Xm=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),g.jsx("path",{d:"M22.0001 12C22.0001 10.7611 21.1663 9.79297 20.0663 9.42632C18.9547 9.05578 17.6171 9.28724 16.4001 10.2C15.9582 10.5314 15.8687 11.1582 16.2001 11.6C16.5314 12.0418 17.1582 12.1314 17.6001 11.8C18.383 11.2128 19.0455 11.1942 19.4338 11.3237C19.8339 11.457 20.0001 11.7389 20.0001 12C20.0001 12.4839 19.8554 12.7379 19.6537 12.9481C19.4275 13.1837 19.1378 13.363 18.7055 13.6307C18.6313 13.6767 18.553 13.7252 18.4701 13.777C17.9572 14.0975 17.3128 14.5261 16.8163 15.2087C16.3007 15.9177 16.0001 16.8183 16.0001 18C16.0001 18.5523 16.4478 19 17.0001 19H21.0001C21.5523 19 22.0001 18.5523 22.0001 18C22.0001 17.4477 21.5523 17 21.0001 17H18.131C18.21 16.742 18.3176 16.5448 18.4338 16.385C18.6873 16.0364 19.0429 15.7775 19.5301 15.473C19.5898 15.4357 19.6536 15.3966 19.7205 15.3556C20.139 15.0992 20.6783 14.7687 21.0964 14.3332C21.6447 13.7621 22.0001 13.0161 22.0001 12Z",fill:"currentColor"})]}));Xm.displayName="HeadingTwoIcon";const Qm=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4608 11.2169C19.1135 11.0531 18.5876 11.0204 18.0069 11.3619C17.5309 11.642 16.918 11.4831 16.638 11.007C16.358 10.531 16.5169 9.91809 16.9929 9.63807C18.1123 8.97962 19.3364 8.94691 20.314 9.40808C21.2839 9.86558 21.9999 10.818 21.9999 12C21.9999 12.7957 21.6838 13.5587 21.1212 14.1213C20.5586 14.6839 19.7956 15 18.9999 15C18.4476 15 17.9999 14.5523 17.9999 14C17.9999 13.4477 18.4476 13 18.9999 13C19.2651 13 19.5195 12.8947 19.707 12.7071C19.8946 12.5196 19.9999 12.2652 19.9999 12C19.9999 11.6821 19.8159 11.3844 19.4608 11.2169Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.0001 14C18.0001 13.4477 18.4478 13 19.0001 13C19.7957 13 20.5588 13.3161 21.1214 13.8787C21.684 14.4413 22.0001 15.2043 22.0001 16C22.0001 17.2853 21.2767 18.3971 20.1604 18.8994C19.0257 19.41 17.642 19.2315 16.4001 18.3C15.9582 17.9686 15.8687 17.3418 16.2001 16.9C16.5314 16.4582 17.1582 16.3686 17.6001 16.7C18.3581 17.2685 18.9744 17.24 19.3397 17.0756C19.7234 16.9029 20.0001 16.5147 20.0001 16C20.0001 15.7348 19.8947 15.4804 19.7072 15.2929C19.5196 15.1054 19.2653 15 19.0001 15C18.4478 15 18.0001 14.5523 18.0001 14Z",fill:"currentColor"})]}));Qm.displayName="HeadingThreeIcon";const e1=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),g.jsx("path",{d:"M17 9C17.5523 9 18 9.44772 18 10V13H20V10C20 9.44772 20.4477 9 21 9C21.5523 9 22 9.44772 22 10V18C22 18.5523 21.5523 19 21 19C20.4477 19 20 18.5523 20 18V15H17C16.4477 15 16 14.5523 16 14V10C16 9.44772 16.4477 9 17 9Z",fill:"currentColor"})]}));e1.displayName="HeadingFourIcon";const t1=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),g.jsx("path",{d:"M16 10C16 9.44772 16.4477 9 17 9H21C21.5523 9 22 9.44772 22 10C22 10.5523 21.5523 11 21 11H18V12H18.3C20.2754 12 22 13.4739 22 15.5C22 17.5261 20.2754 19 18.3 19C17.6457 19 17.0925 18.8643 16.5528 18.5944C16.0588 18.3474 15.8586 17.7468 16.1055 17.2528C16.3525 16.7588 16.9532 16.5586 17.4472 16.8056C17.7074 16.9357 17.9542 17 18.3 17C19.3246 17 20 16.2739 20 15.5C20 14.7261 19.3246 14 18.3 14H17C16.4477 14 16 13.5523 16 13L16 12.9928V10Z",fill:"currentColor"})]}));t1.displayName="HeadingFiveIcon";const n1=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 9.29289C21.0976 9.68342 21.0976 10.3166 20.7071 10.7071C19.8392 11.575 19.2179 12.2949 18.7889 13.0073C18.8587 13.0025 18.929 13 19 13C20.6569 13 22 14.3431 22 16C22 17.6569 20.6569 19 19 19C17.3431 19 16 17.6569 16 16C16 14.6007 16.2837 13.4368 16.8676 12.3419C17.4384 11.2717 18.2728 10.3129 19.2929 9.29289C19.6834 8.90237 20.3166 8.90237 20.7071 9.29289ZM19 17C18.4477 17 18 16.5523 18 16C18 15.4477 18.4477 15 19 15C19.5523 15 20 15.4477 20 16C20 16.5523 19.5523 17 19 17Z",fill:"currentColor"})]}));n1.displayName="HeadingSixIcon";const r1={1:Ym,2:Xm,3:Qm,4:e1,5:t1,6:n1},o1={1:"ctrl+alt+1",2:"ctrl+alt+2",3:"ctrl+alt+3",4:"ctrl+alt+4",5:"ctrl+alt+5",6:"ctrl+alt+6"};function Yr(t,e,n=!0){if(!t||!t.isEditable||!Bt("heading",t)||vt(t,["image"]))return!1;if(!n)return e?t.can().setNode("heading",{level:e}):t.can().setNode("heading");try{const o=t.view.state,i=o.selection;if(i.empty||i instanceof z){const s=hn({editor:t,node:o.selection.$anchor.node(1)})?.pos;if(!yt(s))return!1}return!0}catch{return!1}}function bc(t,e){return!t||!t.isEditable?!1:Array.isArray(e)?e.some(n=>t.isActive("heading",{level:n})):e?t.isActive("heading",{level:e}):t.isActive("heading")}function k3(t,e){if(!t||!t.isEditable)return!1;const n=Array.isArray(e)?e:[e],r=n.find(o=>Yr(t,o));if(!r)return!1;try{const o=t.view;let i=o.state,s=i.tr;if(i.selection.empty||i.selection instanceof z){const d=hn({editor:t,node:i.selection.$anchor.node(1)})?.pos;if(!yt(d))return!1;s=s.setSelection(B.create(i.doc,d)),o.dispatch(s),i=o.state}const l=i.selection;let a=t.chain().focus();if(l instanceof B){const d=l.node.firstChild?.firstChild,h=l.node.lastChild?.lastChild,f=d?l.from+d.nodeSize:l.from+1,p=h?l.to-h.nodeSize:l.to-1;a=a.setTextSelection({from:f,to:p}).clearNodes()}return(n.some(d=>t.isActive("heading",{level:d}))?a.setNode("paragraph"):a.setNode("heading",{level:r})).run(),t.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function i1(t){const{editor:e,level:n,hideWhenUnavailable:r}=t;return!e||!e.isEditable||!Bt("heading",e)?!1:r&&!e.isActive("code")?Array.isArray(n)?n.some(o=>Yr(e,o)):Yr(e,n):!0}function E3(t){const{editor:e,level:n,hideWhenUnavailable:r=!1,onToggled:o}=t,{editor:i}=ee(e),[s,l]=y.useState(!0),a=Yr(i,n),c=bc(i,n);y.useEffect(()=>{if(!i)return;const d=()=>{l(i1({editor:i,level:n,hideWhenUnavailable:r}))};return d(),i.on("selectionUpdate",d),()=>{i.off("selectionUpdate",d)}},[i,n,r]);const u=y.useCallback(()=>{if(!i)return!1;const d=k3(i,n);return d&&o?.(),d},[i,n,o]);return{isVisible:s,isActive:c,handleToggle:u,canToggle:a,label:`Heading ${n}`,shortcutKeys:o1[n],Icon:r1[n]}}function J(t,e,{checkForDefaultPrevented:n=!0}={}){return function(o){if(t?.(o),n===!1||!o.defaultPrevented)return e?.(o)}}function cf(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function fs(...t){return e=>{let n=!1;const r=t.map(o=>{const i=cf(o,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():cf(t[o],null)}}}}function Oe(...t){return y.useCallback(fs(...t),t)}function hr(t,e=[]){let n=[];function r(i,s){const l=y.createContext(s),a=n.length;n=[...n,s];const c=d=>{const{scope:h,children:f,...p}=d,m=h?.[t]?.[a]||l,v=y.useMemo(()=>p,Object.values(p));return g.jsx(m.Provider,{value:v,children:f})};c.displayName=i+"Provider";function u(d,h){const f=h?.[t]?.[a]||l,p=y.useContext(f);if(p)return p;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[c,u]}const o=()=>{const i=n.map(s=>y.createContext(s));return function(l){const a=l?.[t]||i;return y.useMemo(()=>({[`__scope${t}`]:{...l,[t]:a}}),[l,a])}};return o.scopeName=t,[r,M3(o,...e)]}function M3(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((l,{useScope:a,scopeName:c})=>{const d=a(i)[`__scope${c}`];return{...l,...d}},{});return y.useMemo(()=>({[`__scope${e.scopeName}`]:s}),[s])}};return n.scopeName=e.scopeName,n}var un=globalThis?.document?y.useLayoutEffect:()=>{},T3=y[" useInsertionEffect ".trim().toString()]||un;function Cc({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[o,i,s]=A3({defaultProp:e,onChange:n}),l=t!==void 0,a=l?t:o;{const u=y.useRef(t!==void 0);y.useEffect(()=>{const d=u.current;d!==l&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=l},[l,r])}const c=y.useCallback(u=>{if(l){const d=R3(u)?u(t):u;d!==t&&s.current?.(d)}else i(u)},[l,t,i,s]);return[a,c]}function A3({defaultProp:t,onChange:e}){const[n,r]=y.useState(t),o=y.useRef(n),i=y.useRef(e);return T3(()=>{i.current=e},[e]),y.useEffect(()=>{o.current!==n&&(i.current?.(n),o.current=n)},[n,o]),[n,r,i]}function R3(t){return typeof t=="function"}function Xr(t){const e=O3(t),n=y.forwardRef((r,o)=>{const{children:i,...s}=r,l=y.Children.toArray(i),a=l.find(I3);if(a){const c=a.props.children,u=l.map(d=>d===a?y.Children.count(c)>1?y.Children.only(null):y.isValidElement(c)?c.props.children:null:d);return g.jsx(e,{...s,ref:o,children:y.isValidElement(c)?y.cloneElement(c,void 0,u):null})}return g.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function O3(t){const e=y.forwardRef((n,r)=>{const{children:o,...i}=n;if(y.isValidElement(o)){const s=D3(o),l=L3(i,o.props);return o.type!==y.Fragment&&(l.ref=r?fs(r,s):s),y.cloneElement(o,l)}return y.Children.count(o)>1?y.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var N3=Symbol("radix.slottable");function I3(t){return y.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===N3}function L3(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const a=i(...l);return o(...l),a}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function D3(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var P3=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Te=P3.reduce((t,e)=>{const n=Xr(`Primitive.${e}`),r=y.forwardRef((o,i)=>{const{asChild:s,...l}=o,a=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),g.jsx(a,{...l,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function s1(t,e){t&&va.flushSync(()=>t.dispatchEvent(e))}function l1(t){const e=t+"CollectionProvider",[n,r]=hr(e),[o,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),s=m=>{const{scope:v,children:b}=m,C=D.useRef(null),x=D.useRef(new Map).current;return g.jsx(o,{scope:v,itemMap:x,collectionRef:C,children:b})};s.displayName=e;const l=t+"CollectionSlot",a=Xr(l),c=D.forwardRef((m,v)=>{const{scope:b,children:C}=m,x=i(l,b),w=Oe(v,x.collectionRef);return g.jsx(a,{ref:w,children:C})});c.displayName=l;const u=t+"CollectionItemSlot",d="data-radix-collection-item",h=Xr(u),f=D.forwardRef((m,v)=>{const{scope:b,children:C,...x}=m,w=D.useRef(null),E=Oe(v,w),k=i(u,b);return D.useEffect(()=>(k.itemMap.set(w,{ref:w,...x}),()=>void k.itemMap.delete(w))),g.jsx(h,{[d]:"",ref:E,children:C})});f.displayName=u;function p(m){const v=i(t+"CollectionConsumer",m);return D.useCallback(()=>{const C=v.collectionRef.current;if(!C)return[];const x=Array.from(C.querySelectorAll(`[${d}]`));return Array.from(v.itemMap.values()).sort((k,S)=>x.indexOf(k.ref.current)-x.indexOf(S.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:s,Slot:c,ItemSlot:f},p,r]}var j3=y.createContext(void 0);function a1(t){const e=y.useContext(j3);return t||e||"ltr"}function Pt(t){const e=y.useRef(t);return y.useEffect(()=>{e.current=t}),y.useMemo(()=>(...n)=>e.current?.(...n),[])}function B3(t,e=globalThis?.document){const n=Pt(t);y.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var _3="DismissableLayer",da="dismissableLayer.update",H3="dismissableLayer.pointerDownOutside",F3="dismissableLayer.focusOutside",uf,c1=y.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),xc=y.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:l,...a}=t,c=y.useContext(c1),[u,d]=y.useState(null),h=u?.ownerDocument??globalThis?.document,[,f]=y.useState({}),p=Oe(e,S=>d(S)),m=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),b=m.indexOf(v),C=u?m.indexOf(u):-1,x=c.layersWithOutsidePointerEventsDisabled.size>0,w=C>=b,E=z3(S=>{const M=S.target,I=[...c.branches].some(j=>j.contains(M));!w||I||(o?.(S),s?.(S),S.defaultPrevented||l?.())},h),k=U3(S=>{const M=S.target;[...c.branches].some(j=>j.contains(M))||(i?.(S),s?.(S),S.defaultPrevented||l?.())},h);return B3(S=>{C===c.layers.size-1&&(r?.(S),!S.defaultPrevented&&l&&(S.preventDefault(),l()))},h),y.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(uf=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),df(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=uf)}},[u,h,n,c]),y.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),df())},[u,c]),y.useEffect(()=>{const S=()=>f({});return document.addEventListener(da,S),()=>document.removeEventListener(da,S)},[]),g.jsx(Te.div,{...a,ref:p,style:{pointerEvents:x?w?"auto":"none":void 0,...t.style},onFocusCapture:J(t.onFocusCapture,k.onFocusCapture),onBlurCapture:J(t.onBlurCapture,k.onBlurCapture),onPointerDownCapture:J(t.onPointerDownCapture,E.onPointerDownCapture)})});xc.displayName=_3;var $3="DismissableLayerBranch",V3=y.forwardRef((t,e)=>{const n=y.useContext(c1),r=y.useRef(null),o=Oe(e,r);return y.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),g.jsx(Te.div,{...t,ref:o})});V3.displayName=$3;function z3(t,e=globalThis?.document){const n=Pt(t),r=y.useRef(!1),o=y.useRef(()=>{});return y.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let a=function(){u1(H3,n,c,{discrete:!0})};const c={originalEvent:l};l.pointerType==="touch"?(e.removeEventListener("click",o.current),o.current=a,e.addEventListener("click",o.current,{once:!0})):a()}else e.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),e.removeEventListener("pointerdown",i),e.removeEventListener("click",o.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function U3(t,e=globalThis?.document){const n=Pt(t),r=y.useRef(!1);return y.useEffect(()=>{const o=i=>{i.target&&!r.current&&u1(F3,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",o),()=>e.removeEventListener("focusin",o)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function df(){const t=new CustomEvent(da);document.dispatchEvent(t)}function u1(t,e,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&o.addEventListener(t,e,{once:!0}),r?s1(o,i):o.dispatchEvent(i)}var dl=0;function d1(){y.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??ff()),document.body.insertAdjacentElement("beforeend",t[1]??ff()),dl++,()=>{dl===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),dl--}},[])}function ff(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var fl="focusScope.autoFocusOnMount",hl="focusScope.autoFocusOnUnmount",hf={bubbles:!1,cancelable:!0},W3="FocusScope",wc=y.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=t,[l,a]=y.useState(null),c=Pt(o),u=Pt(i),d=y.useRef(null),h=Oe(e,m=>a(m)),f=y.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;y.useEffect(()=>{if(r){let m=function(x){if(f.paused||!l)return;const w=x.target;l.contains(w)?d.current=w:$t(d.current,{select:!0})},v=function(x){if(f.paused||!l)return;const w=x.relatedTarget;w!==null&&(l.contains(w)||$t(d.current,{select:!0}))},b=function(x){if(document.activeElement===document.body)for(const E of x)E.removedNodes.length>0&&$t(l)};document.addEventListener("focusin",m),document.addEventListener("focusout",v);const C=new MutationObserver(b);return l&&C.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",v),C.disconnect()}}},[r,l,f.paused]),y.useEffect(()=>{if(l){mf.add(f);const m=document.activeElement;if(!l.contains(m)){const b=new CustomEvent(fl,hf);l.addEventListener(fl,c),l.dispatchEvent(b),b.defaultPrevented||(K3(Y3(f1(l)),{select:!0}),document.activeElement===m&&$t(l))}return()=>{l.removeEventListener(fl,c),setTimeout(()=>{const b=new CustomEvent(hl,hf);l.addEventListener(hl,u),l.dispatchEvent(b),b.defaultPrevented||$t(m??document.body,{select:!0}),l.removeEventListener(hl,u),mf.remove(f)},0)}}},[l,c,u,f]);const p=y.useCallback(m=>{if(!n&&!r||f.paused)return;const v=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,b=document.activeElement;if(v&&b){const C=m.currentTarget,[x,w]=q3(C);x&&w?!m.shiftKey&&b===w?(m.preventDefault(),n&&$t(x,{select:!0})):m.shiftKey&&b===x&&(m.preventDefault(),n&&$t(w,{select:!0})):b===C&&m.preventDefault()}},[n,r,f.paused]);return g.jsx(Te.div,{tabIndex:-1,...s,ref:h,onKeyDown:p})});wc.displayName=W3;function K3(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if($t(r,{select:e}),document.activeElement!==n)return}function q3(t){const e=f1(t),n=pf(e,t),r=pf(e.reverse(),t);return[n,r]}function f1(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function pf(t,e){for(const n of t)if(!G3(n,{upTo:e}))return n}function G3(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function J3(t){return t instanceof HTMLInputElement&&"select"in t}function $t(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&J3(t)&&e&&t.select()}}var mf=Z3();function Z3(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=gf(t,e),t.unshift(e)},remove(e){t=gf(t,e),t[0]?.resume()}}}function gf(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function Y3(t){return t.filter(e=>e.tagName!=="A")}var X3=y[" useId ".trim().toString()]||(()=>{}),Q3=0;function Hi(t){const[e,n]=y.useState(X3());return un(()=>{n(r=>r??String(Q3++))},[t]),t||(e?`radix-${e}`:"")}var eS="Arrow",h1=y.forwardRef((t,e)=>{const{children:n,width:r=10,height:o=5,...i}=t;return g.jsx(Te.svg,{...i,ref:e,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:g.jsx("polygon",{points:"0,0 30,0 15,10"})})});h1.displayName=eS;var tS=h1;function nS(t){const[e,n]=y.useState(void 0);return un(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,l;if("borderBoxSize"in i){const a=i.borderBoxSize,c=Array.isArray(a)?a[0]:a;s=c.inlineSize,l=c.blockSize}else s=t.offsetWidth,l=t.offsetHeight;n({width:s,height:l})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Sc="Popper",[p1,hs]=hr(Sc),[rS,m1]=p1(Sc),g1=t=>{const{__scopePopper:e,children:n}=t,[r,o]=y.useState(null);return g.jsx(rS,{scope:e,anchor:r,onAnchorChange:o,children:n})};g1.displayName=Sc;var y1="PopperAnchor",v1=y.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...o}=t,i=m1(y1,n),s=y.useRef(null),l=Oe(e,s),a=y.useRef(null);return y.useEffect(()=>{const c=a.current;a.current=r?.current||s.current,c!==a.current&&i.onAnchorChange(a.current)}),r?null:g.jsx(Te.div,{...o,ref:l})});v1.displayName=y1;var kc="PopperContent",[oS,iS]=p1(kc),b1=y.forwardRef((t,e)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:l=0,avoidCollisions:a=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:h=!1,updatePositionStrategy:f="optimized",onPlaced:p,...m}=t,v=m1(kc,n),[b,C]=y.useState(null),x=Oe(e,X=>C(X)),[w,E]=y.useState(null),k=nS(w),S=k?.width??0,M=k?.height??0,I=r+(i!=="center"?"-"+i:""),j=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},_=Array.isArray(c)?c:[c],U=_.length>0,F={padding:j,boundary:_.filter(lS),altBoundary:U},{refs:O,floatingStyles:H,placement:V,isPositioned:L,middlewareData:T}=jm({strategy:"fixed",placement:I,whileElementsMounted:(...X)=>Dm(...X,{animationFrame:f==="always"}),elements:{reference:v.anchor},middleware:[Bm({mainAxis:o+M,alignmentAxis:s}),a&&_m({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?E5():void 0,...F}),a&&Hm({...F}),M5({...F,apply:({elements:X,rects:ne,availableWidth:Ke,availableHeight:Ct})=>{const{width:_n,height:Ss}=ne.reference,Hn=X.floating.style;Hn.setProperty("--radix-popper-available-width",`${Ke}px`),Hn.setProperty("--radix-popper-available-height",`${Ct}px`),Hn.setProperty("--radix-popper-anchor-width",`${_n}px`),Hn.setProperty("--radix-popper-anchor-height",`${Ss}px`)}}),w&&A5({element:w,padding:l}),aS({arrowWidth:S,arrowHeight:M}),h&&T5({strategy:"referenceHidden",...F})]}),[R,W]=w1(V),te=Pt(p);un(()=>{L&&te?.()},[L,te]);const K=T.arrow?.x,Y=T.arrow?.y,We=T.arrow?.centerOffset!==0,[ce,ye]=y.useState();return un(()=>{b&&ye(window.getComputedStyle(b).zIndex)},[b]),g.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:L?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ce,"--radix-popper-transform-origin":[T.transformOrigin?.x,T.transformOrigin?.y].join(" "),...T.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:g.jsx(oS,{scope:n,placedSide:R,onArrowChange:E,arrowX:K,arrowY:Y,shouldHideArrow:We,children:g.jsx(Te.div,{"data-side":R,"data-align":W,...m,ref:x,style:{...m.style,animation:L?void 0:"none"}})})})});b1.displayName=kc;var C1="PopperArrow",sS={top:"bottom",right:"left",bottom:"top",left:"right"},x1=y.forwardRef(function(e,n){const{__scopePopper:r,...o}=e,i=iS(C1,r),s=sS[i.placedSide];return g.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:g.jsx(tS,{...o,ref:n,style:{...o.style,display:"block"}})})});x1.displayName=C1;function lS(t){return t!==null}var aS=t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:r,middlewareData:o}=e,s=o.arrow?.centerOffset!==0,l=s?0:t.arrowWidth,a=s?0:t.arrowHeight,[c,u]=w1(n),d={start:"0%",center:"50%",end:"100%"}[u],h=(o.arrow?.x??0)+l/2,f=(o.arrow?.y??0)+a/2;let p="",m="";return c==="bottom"?(p=s?d:`${h}px`,m=`${-a}px`):c==="top"?(p=s?d:`${h}px`,m=`${r.floating.height+a}px`):c==="right"?(p=`${-a}px`,m=s?d:`${f}px`):c==="left"&&(p=`${r.floating.width+a}px`,m=s?d:`${f}px`),{data:{x:p,y:m}}}});function w1(t){const[e,n="center"]=t.split("-");return[e,n]}var S1=g1,Ec=v1,k1=b1,E1=x1,cS="Portal",Mc=y.forwardRef((t,e)=>{const{container:n,...r}=t,[o,i]=y.useState(!1);un(()=>i(!0),[]);const s=n||o&&globalThis?.document?.body;return s?Ui.createPortal(g.jsx(Te.div,{...r,ref:e}),s):null});Mc.displayName=cS;function uS(t,e){return y.useReducer((n,r)=>e[n][r]??n,t)}var Pn=t=>{const{present:e,children:n}=t,r=dS(e),o=typeof n=="function"?n({present:r.isPresent}):y.Children.only(n),i=Oe(r.ref,fS(o));return typeof n=="function"||r.isPresent?y.cloneElement(o,{ref:i}):null};Pn.displayName="Presence";function dS(t){const[e,n]=y.useState(),r=y.useRef(null),o=y.useRef(t),i=y.useRef("none"),s=t?"mounted":"unmounted",[l,a]=uS(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return y.useEffect(()=>{const c=No(r.current);i.current=l==="mounted"?c:"none"},[l]),un(()=>{const c=r.current,u=o.current;if(u!==t){const h=i.current,f=No(c);t?a("MOUNT"):f==="none"||c?.display==="none"?a("UNMOUNT"):a(u&&h!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,a]),un(()=>{if(e){let c;const u=e.ownerDocument.defaultView??window,d=f=>{const m=No(r.current).includes(CSS.escape(f.animationName));if(f.target===e&&m&&(a("ANIMATION_END"),!o.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",c=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},h=f=>{f.target===e&&(i.current=No(r.current))};return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",d),e.addEventListener("animationend",d),()=>{u.clearTimeout(c),e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",d),e.removeEventListener("animationend",d)}}else a("ANIMATION_END")},[e,a]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:y.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function No(t){return t?.animationName||"none"}function fS(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var pl="rovingFocusGroup.onEntryFocus",hS={bubbles:!1,cancelable:!0},ao="RovingFocusGroup",[fa,M1,pS]=l1(ao),[mS,T1]=hr(ao,[pS]),[gS,yS]=mS(ao),A1=y.forwardRef((t,e)=>g.jsx(fa.Provider,{scope:t.__scopeRovingFocusGroup,children:g.jsx(fa.Slot,{scope:t.__scopeRovingFocusGroup,children:g.jsx(vS,{...t,ref:e})})}));A1.displayName=ao;var vS=y.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:a,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=t,h=y.useRef(null),f=Oe(e,h),p=a1(i),[m,v]=Cc({prop:s,defaultProp:l??null,onChange:a,caller:ao}),[b,C]=y.useState(!1),x=Pt(c),w=M1(n),E=y.useRef(!1),[k,S]=y.useState(0);return y.useEffect(()=>{const M=h.current;if(M)return M.addEventListener(pl,x),()=>M.removeEventListener(pl,x)},[x]),g.jsx(gS,{scope:n,orientation:r,dir:p,loop:o,currentTabStopId:m,onItemFocus:y.useCallback(M=>v(M),[v]),onItemShiftTab:y.useCallback(()=>C(!0),[]),onFocusableItemAdd:y.useCallback(()=>S(M=>M+1),[]),onFocusableItemRemove:y.useCallback(()=>S(M=>M-1),[]),children:g.jsx(Te.div,{tabIndex:b||k===0?-1:0,"data-orientation":r,...d,ref:f,style:{outline:"none",...t.style},onMouseDown:J(t.onMouseDown,()=>{E.current=!0}),onFocus:J(t.onFocus,M=>{const I=!E.current;if(M.target===M.currentTarget&&I&&!b){const j=new CustomEvent(pl,hS);if(M.currentTarget.dispatchEvent(j),!j.defaultPrevented){const _=w().filter(V=>V.focusable),U=_.find(V=>V.active),F=_.find(V=>V.id===m),H=[U,F,..._].filter(Boolean).map(V=>V.ref.current);N1(H,u)}}E.current=!1}),onBlur:J(t.onBlur,()=>C(!1))})})}),R1="RovingFocusGroupItem",O1=y.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:s,...l}=t,a=Hi(),c=i||a,u=yS(R1,n),d=u.currentTabStopId===c,h=M1(n),{onFocusableItemAdd:f,onFocusableItemRemove:p,currentTabStopId:m}=u;return y.useEffect(()=>{if(r)return f(),()=>p()},[r,f,p]),g.jsx(fa.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:g.jsx(Te.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...l,ref:e,onMouseDown:J(t.onMouseDown,v=>{r?u.onItemFocus(c):v.preventDefault()}),onFocus:J(t.onFocus,()=>u.onItemFocus(c)),onKeyDown:J(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){u.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=xS(v,u.orientation,u.dir);if(b!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let x=h().filter(w=>w.focusable).map(w=>w.ref.current);if(b==="last")x.reverse();else if(b==="prev"||b==="next"){b==="prev"&&x.reverse();const w=x.indexOf(v.currentTarget);x=u.loop?wS(x,w+1):x.slice(w+1)}setTimeout(()=>N1(x))}}),children:typeof s=="function"?s({isCurrentTabStop:d,hasTabStop:m!=null}):s})})});O1.displayName=R1;var bS={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function CS(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function xS(t,e,n){const r=CS(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return bS[r]}function N1(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function wS(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var SS=A1,kS=O1,ES=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Vn=new WeakMap,Io=new WeakMap,Lo={},ml=0,I1=function(t){return t&&(t.host||I1(t.parentNode))},MS=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=I1(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},TS=function(t,e,n,r){var o=MS(e,Array.isArray(t)?t:[t]);Lo[n]||(Lo[n]=new WeakMap);var i=Lo[n],s=[],l=new Set,a=new Set(o),c=function(d){!d||l.has(d)||(l.add(d),c(d.parentNode))};o.forEach(c);var u=function(d){!d||a.has(d)||Array.prototype.forEach.call(d.children,function(h){if(l.has(h))u(h);else try{var f=h.getAttribute(r),p=f!==null&&f!=="false",m=(Vn.get(h)||0)+1,v=(i.get(h)||0)+1;Vn.set(h,m),i.set(h,v),s.push(h),m===1&&p&&Io.set(h,!0),v===1&&h.setAttribute(n,"true"),p||h.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",h,b)}})};return u(e),l.clear(),ml++,function(){s.forEach(function(d){var h=Vn.get(d)-1,f=i.get(d)-1;Vn.set(d,h),i.set(d,f),h||(Io.has(d)||d.removeAttribute(r),Io.delete(d)),f||d.removeAttribute(n)}),ml--,ml||(Vn=new WeakMap,Vn=new WeakMap,Io=new WeakMap,Lo={})}},L1=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),o=ES(t);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),TS(r,o,n,"aria-hidden")):function(){return null}},ct=function(){return ct=Object.assign||function(e){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},ct.apply(this,arguments)};function D1(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]]);return n}function AS(t,e,n){if(n||arguments.length===2)for(var r=0,o=e.length,i;r<o;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}var Uo="right-scroll-bar-position",Wo="width-before-scroll-bar",RS="with-scroll-bars-hidden",OS="--removed-body-scroll-bar-size";function gl(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function NS(t,e){var n=D.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=e,n.facade}var IS=typeof window<"u"?y.useLayoutEffect:y.useEffect,yf=new WeakMap;function LS(t,e){var n=NS(null,function(r){return t.forEach(function(o){return gl(o,r)})});return IS(function(){var r=yf.get(n);if(r){var o=new Set(r),i=new Set(t),s=n.current;o.forEach(function(l){i.has(l)||gl(l,null)}),i.forEach(function(l){o.has(l)||gl(l,s)})}yf.set(n,t)},[t]),n}function DS(t){return t}function PS(t,e){e===void 0&&(e=DS);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(i){var s=e(i,r);return n.push(s),function(){n=n.filter(function(l){return l!==s})}},assignSyncMedium:function(i){for(r=!0;n.length;){var s=n;n=[],s.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){r=!0;var s=[];if(n.length){var l=n;n=[],l.forEach(i),s=n}var a=function(){var u=s;s=[],u.forEach(i)},c=function(){return Promise.resolve().then(a)};c(),n={push:function(u){s.push(u),c()},filter:function(u){return s=s.filter(u),n}}}};return o}function jS(t){t===void 0&&(t={});var e=PS(null);return e.options=ct({async:!0,ssr:!1},t),e}var P1=function(t){var e=t.sideCar,n=D1(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return y.createElement(r,ct({},n))};P1.isSideCarExport=!0;function BS(t,e){return t.useMedium(e),P1}var j1=jS(),yl=function(){},ps=y.forwardRef(function(t,e){var n=y.useRef(null),r=y.useState({onScrollCapture:yl,onWheelCapture:yl,onTouchMoveCapture:yl}),o=r[0],i=r[1],s=t.forwardProps,l=t.children,a=t.className,c=t.removeScrollBar,u=t.enabled,d=t.shards,h=t.sideCar,f=t.noRelative,p=t.noIsolation,m=t.inert,v=t.allowPinchZoom,b=t.as,C=b===void 0?"div":b,x=t.gapMode,w=D1(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),E=h,k=LS([n,e]),S=ct(ct({},w),o);return y.createElement(y.Fragment,null,u&&y.createElement(E,{sideCar:j1,removeScrollBar:c,shards:d,noRelative:f,noIsolation:p,inert:m,setCallbacks:i,allowPinchZoom:!!v,lockRef:n,gapMode:x}),s?y.cloneElement(y.Children.only(l),ct(ct({},S),{ref:k})):y.createElement(C,ct({},S,{className:a,ref:k}),l))});ps.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ps.classNames={fullWidth:Wo,zeroRight:Uo};var _S=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function HS(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=_S();return e&&t.setAttribute("nonce",e),t}function FS(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function $S(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var VS=function(){var t=0,e=null;return{add:function(n){t==0&&(e=HS())&&(FS(e,n),$S(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},zS=function(){var t=VS();return function(e,n){y.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},B1=function(){var t=zS(),e=function(n){var r=n.styles,o=n.dynamic;return t(r,o),null};return e},US={left:0,top:0,right:0,gap:0},vl=function(t){return parseInt(t||"",10)||0},WS=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],o=e[t==="padding"?"paddingRight":"marginRight"];return[vl(n),vl(r),vl(o)]},KS=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return US;var e=WS(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},qS=B1(),tr="data-scroll-locked",GS=function(t,e,n,r){var o=t.left,i=t.top,s=t.right,l=t.gap;return n===void 0&&(n="margin"),`
177
- .`.concat(RS,` {
176
+ */var b4=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],oa=b4.join(","),Em=typeof Element>"u",Jr=Em?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,_i=!Em&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},Zr=function(e,n){var r;n===void 0&&(n=!0);var o=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),i=o===""||o==="true",s=i||n&&e&&Zr(e.parentNode);return s},C4=function(e){var n,r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return r===""||r==="true"},x4=function(e,n,r){if(Zr(e))return[];var o=Array.prototype.slice.apply(e.querySelectorAll(oa));return n&&Jr.call(e,oa)&&o.unshift(e),o=o.filter(r),o},ia=function(e,n,r){for(var o=[],i=Array.from(e);i.length;){var s=i.shift();if(!Zr(s,!1))if(s.tagName==="SLOT"){var l=s.assignedElements(),a=l.length?l:s.children,c=ia(a,!0,r);r.flatten?o.push.apply(o,c):o.push({scopeParent:s,candidates:c})}else{var u=Jr.call(s,oa);u&&r.filter(s)&&(n||!e.includes(s))&&o.push(s);var d=s.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(s),h=!Zr(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(s));if(d&&h){var f=ia(d===!0?s.children:d.children,!0,r);r.flatten?o.push.apply(o,f):o.push({scopeParent:s,candidates:f})}else i.unshift.apply(i,s.children)}}return o},Mm=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Tm=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||C4(e))&&!Mm(e)?0:e.tabIndex},w4=function(e,n){var r=Tm(e);return r<0&&n&&!Mm(e)?0:r},S4=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},Am=function(e){return e.tagName==="INPUT"},k4=function(e){return Am(e)&&e.type==="hidden"},E4=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return n},M4=function(e,n){for(var r=0;r<e.length;r++)if(e[r].checked&&e[r].form===n)return e[r]},T4=function(e){if(!e.name)return!0;var n=e.form||_i(e),r=function(l){return n.querySelectorAll('input[type="radio"][name="'+l+'"]')},o;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")o=r(window.CSS.escape(e.name));else try{o=r(e.name)}catch(s){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",s.message),!1}var i=M4(o,e.form);return!i||i===e},A4=function(e){return Am(e)&&e.type==="radio"},R4=function(e){return A4(e)&&!T4(e)},O4=function(e){var n,r=e&&_i(e),o=(n=r)===null||n===void 0?void 0:n.host,i=!1;if(r&&r!==e){var s,l,a;for(i=!!((s=o)!==null&&s!==void 0&&(l=s.ownerDocument)!==null&&l!==void 0&&l.contains(o)||e!=null&&(a=e.ownerDocument)!==null&&a!==void 0&&a.contains(e));!i&&o;){var c,u,d;r=_i(o),o=(c=r)===null||c===void 0?void 0:c.host,i=!!((u=o)!==null&&u!==void 0&&(d=u.ownerDocument)!==null&&d!==void 0&&d.contains(o))}}return i},qd=function(e){var n=e.getBoundingClientRect(),r=n.width,o=n.height;return r===0&&o===0},N4=function(e,n){var r=n.displayCheck,o=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in e){var i=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!i}if(getComputedStyle(e).visibility==="hidden")return!0;var s=Jr.call(e,"details>summary:first-of-type"),l=s?e.parentElement:e;if(Jr.call(l,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof o=="function"){for(var a=e;e;){var c=e.parentElement,u=_i(e);if(c&&!c.shadowRoot&&o(c)===!0)return qd(e);e.assignedSlot?e=e.assignedSlot:!c&&u!==e.ownerDocument?e=u.host:e=c}e=a}if(O4(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return qd(e);return!1},I4=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var o=n.children.item(r);if(o.tagName==="LEGEND")return Jr.call(n,"fieldset[disabled] *")?!0:!o.contains(e)}return!0}n=n.parentElement}return!1},L4=function(e,n){return!(n.disabled||Zr(n)||k4(n)||N4(n,e)||E4(n)||I4(n))},Gd=function(e,n){return!(R4(n)||Tm(n)<0||!L4(e,n))},D4=function(e){var n=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Rm=function(e){var n=[],r=[];return e.forEach(function(o,i){var s=!!o.scopeParent,l=s?o.scopeParent:o,a=w4(l,s),c=s?Rm(o.candidates):l;a===0?s?n.push.apply(n,c):n.push(l):r.push({documentOrder:i,tabIndex:a,item:o,isScope:s,content:c})}),r.sort(S4).reduce(function(o,i){return i.isScope?o.push.apply(o,i.content):o.push(i.content),o},[]).concat(n)},Om=function(e,n){n=n||{};var r;return n.getShadowRoot?r=ia([e],n.includeContainer,{filter:Gd.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:D4}):r=x4(e,n.includeContainer,Gd.bind(null,n)),Rm(r)};function P4(){const t=navigator.userAgentData;return t!=null&&t.platform?t.platform:navigator.platform}function j4(){const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?t.brands.map(e=>{let{brand:n,version:r}=e;return n+"/"+r}).join(" "):navigator.userAgent}function Nm(){return/apple/i.test(navigator.vendor)}function B4(){return P4().toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints}function _4(){return j4().includes("jsdom/")}const Jd="data-floating-ui-focusable",H4="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function sa(t){let e=t.activeElement;for(;((n=e)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;e=e.shadowRoot.activeElement}return e}function cr(t,e){if(!t||!e)return!1;const n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&ea(n)){let r=e;for(;r;){if(t===r)return!0;r=r.parentNode||r.host}}return!1}function Jn(t){return"composedPath"in t?t.composedPath()[0]:t.target}function rl(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const n=t;return n.target!=null&&e.contains(n.target)}function F4(t){return t.matches("html,body")}function dt(t){return t?.ownerDocument||document}function $4(t){return Ue(t)&&t.matches(H4)}function V4(t){if(!t||_4())return!0;try{return t.matches(":focus-visible")}catch{return!0}}function z4(t){return t?t.hasAttribute(Jd)?t:t.querySelector("["+Jd+"]")||t:null}function zo(t,e,n){return n===void 0&&(n=!0),t.filter(o=>{var i;return o.parentId===e&&(!n||((i=o.context)==null?void 0:i.open))}).flatMap(o=>[o,...zo(t,o.id,n)])}function U4(t){return"nativeEvent"in t}function la(t,e){const n=["mouse","pen"];return n.push("",void 0),n.includes(t)}var W4=typeof document<"u",K4=function(){},ot=W4?L.useLayoutEffect:K4;const q4={...y};function No(t){const e=y.useRef(t);return ot(()=>{e.current=t}),e}const G4=q4.useInsertionEffect,J4=G4||(t=>t());function at(t){const e=y.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return J4(()=>{e.current=t}),y.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e.current==null?void 0:e.current(...r)},[])}const Im=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Lm(t,e){const n=Om(t,Im()),r=n.length;if(r===0)return;const o=sa(dt(t)),i=n.indexOf(o),s=i===-1?e===1?0:r-1:i+e;return n[s]}function Z4(t){return Lm(dt(t).body,1)||t}function Y4(t){return Lm(dt(t).body,-1)||t}function ol(t,e){const n=e||t.currentTarget,r=t.relatedTarget;return!r||!cr(n,r)}function X4(t){Om(t,Im()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Zd(t){t.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function Yd(t,e,n){let{reference:r,floating:o}=t;const i=ut(e),s=pc(e),l=hc(s),a=Dt(e),c=i==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,h=r[l]/2-o[l]/2;let f;switch(a){case"top":f={x:u,y:r.y-o.height};break;case"bottom":f={x:u,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:d};break;case"left":f={x:r.x-o.width,y:d};break;default:f={x:r.x,y:r.y}}switch(hr(e)){case"start":f[s]-=h*(n&&c?-1:1);break;case"end":f[s]+=h*(n&&c?-1:1);break}return f}const Q4=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,l=i.filter(Boolean),a=await(s.isRTL==null?void 0:s.isRTL(e));let c=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:u,y:d}=Yd(c,r,a),h=r,f={},p=0;for(let m=0;m<l.length;m++){const{name:v,fn:b}=l[m],{x:C,y:x,data:w,reset:E}=await b({x:u,y:d,initialPlacement:r,placement:h,strategy:o,middlewareData:f,rects:c,platform:s,elements:{reference:t,floating:e}});u=C??u,d=x??d,f={...f,[v]:{...f[v],...w}},E&&p<=50&&(p++,typeof E=="object"&&(E.placement&&(h=E.placement),E.rects&&(c=E.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:o}):E.rects),{x:u,y:d}=Yd(c,h,a)),m=-1)}return{x:u,y:d,placement:h,strategy:o,middlewareData:f}};async function Yr(t,e){var n;e===void 0&&(e={});const{x:r,y:o,platform:i,rects:s,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:f=0}=Lt(e,t),p=km(f),v=l[h?d==="floating"?"reference":"floating":d],b=Bi(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(v)))==null||n?v:v.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),C=d==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),w=await(i.isElement==null?void 0:i.isElement(x))?await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},E=Bi(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:C,offsetParent:x,strategy:a}):C);return{top:(b.top-E.top+p.top)/w.y,bottom:(E.bottom-b.bottom+p.bottom)/w.y,left:(b.left-E.left+p.left)/w.x,right:(E.right-b.right+p.right)/w.x}}const e5=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:o,rects:i,platform:s,elements:l,middlewareData:a}=e,{element:c,padding:u=0}=Lt(t,e)||{};if(c==null)return{};const d=km(u),h={x:n,y:r},f=pc(o),p=hc(f),m=await s.getDimensions(c),v=f==="y",b=v?"top":"left",C=v?"bottom":"right",x=v?"clientHeight":"clientWidth",w=i.reference[p]+i.reference[f]-h[f]-i.floating[p],E=h[f]-i.reference[f],S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c));let k=S?S[x]:0;(!k||!await(s.isElement==null?void 0:s.isElement(S)))&&(k=l.floating[x]||i.floating[p]);const M=w/2-E/2,I=k/2-m[p]/2-1,P=cn(d[b],I),_=cn(d[C],I),U=P,F=k-m[p]-_,O=k/2-m[p]/2+M,H=na(U,O,F),V=!a.arrow&&hr(o)!=null&&O!==H&&i.reference[p]/2-(O<U?P:_)-m[p]/2<0,D=V?O<U?O-U:O-F:0;return{[f]:h[f]+D,data:{[f]:H,centerOffset:O-H-D,...V&&{alignmentOffset:D}},reset:V}}}),t5=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...v}=Lt(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=Dt(o),C=ut(l),x=Dt(l)===l,w=await(a.isRTL==null?void 0:a.isRTL(c.floating)),E=h||(x||!m?[ji(l)]:h4(l)),S=p!=="none";!h&&S&&E.push(...y4(l,m,p,w));const k=[l,...E],M=await Yr(e,v),I=[];let P=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&I.push(M[b]),d){const O=f4(o,s,w);I.push(M[O[0]],M[O[1]])}if(P=[...P,{placement:o,overflows:I}],!I.every(O=>O<=0)){var _,U;const O=(((_=i.flip)==null?void 0:_.index)||0)+1,H=k[O];if(H&&(!(d==="alignment"?C!==ut(H):!1)||P.every(T=>ut(T.placement)===C?T.overflows[0]>0:!0)))return{data:{index:O,overflows:P},reset:{placement:H}};let V=(U=P.filter(D=>D.overflows[0]<=0).sort((D,T)=>D.overflows[1]-T.overflows[1])[0])==null?void 0:U.placement;if(!V)switch(f){case"bestFit":{var F;const D=(F=P.filter(T=>{if(S){const R=ut(T.placement);return R===C||R==="y"}return!0}).map(T=>[T.placement,T.overflows.filter(R=>R>0).reduce((R,W)=>R+W,0)]).sort((T,R)=>T[1]-R[1])[0])==null?void 0:F[0];D&&(V=D);break}case"initialPlacement":V=l;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function Xd(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Qd(t){return a4.some(e=>t[e]>=0)}const n5=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...o}=Lt(t,e);switch(r){case"referenceHidden":{const i=await Yr(e,{...o,elementContext:"reference"}),s=Xd(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:Qd(s)}}}case"escaped":{const i=await Yr(e,{...o,altBoundary:!0}),s=Xd(i,n.floating);return{data:{escapedOffsets:s,escaped:Qd(s)}}}default:return{}}}}},Dm=new Set(["left","top"]);async function r5(t,e){const{placement:n,platform:r,elements:o}=t,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Dt(n),l=hr(n),a=ut(n)==="y",c=Dm.has(s)?-1:1,u=i&&a?-1:1,d=Lt(e,t);let{mainAxis:h,crossAxis:f,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof p=="number"&&(f=l==="end"?p*-1:p),a?{x:f*u,y:h*c}:{x:h*c,y:f*u}}const o5=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:o,y:i,placement:s,middlewareData:l}=e,a=await r5(e,t);return s===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+a.x,y:i+a.y,data:{...a,placement:s}}}}},i5=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:o}=e,{mainAxis:i=!0,crossAxis:s=!1,limiter:l={fn:v=>{let{x:b,y:C}=v;return{x:b,y:C}}},...a}=Lt(t,e),c={x:n,y:r},u=await Yr(e,a),d=ut(Dt(o)),h=fc(d);let f=c[h],p=c[d];if(i){const v=h==="y"?"top":"left",b=h==="y"?"bottom":"right",C=f+u[v],x=f-u[b];f=na(C,f,x)}if(s){const v=d==="y"?"top":"left",b=d==="y"?"bottom":"right",C=p+u[v],x=p-u[b];p=na(C,p,x)}const m=l.fn({...e,[h]:f,[d]:p});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[h]:i,[d]:s}}}}}},s5=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=e,{offset:l=0,mainAxis:a=!0,crossAxis:c=!0}=Lt(t,e),u={x:n,y:r},d=ut(o),h=fc(d);let f=u[h],p=u[d];const m=Lt(l,e),v=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(a){const x=h==="y"?"height":"width",w=i.reference[h]-i.floating[x]+v.mainAxis,E=i.reference[h]+i.reference[x]-v.mainAxis;f<w?f=w:f>E&&(f=E)}if(c){var b,C;const x=h==="y"?"width":"height",w=Dm.has(Dt(o)),E=i.reference[d]-i.floating[x]+(w&&((b=s.offset)==null?void 0:b[d])||0)+(w?0:v.crossAxis),S=i.reference[d]+i.reference[x]+(w?0:((C=s.offset)==null?void 0:C[d])||0)-(w?v.crossAxis:0);p<E?p=E:p>S&&(p=S)}return{[h]:f,[d]:p}}}},l5=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:o,rects:i,platform:s,elements:l}=e,{apply:a=()=>{},...c}=Lt(t,e),u=await Yr(e,c),d=Dt(o),h=hr(o),f=ut(o)==="y",{width:p,height:m}=i.floating;let v,b;d==="top"||d==="bottom"?(v=d,b=h===(await(s.isRTL==null?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(b=d,v=h==="end"?"top":"bottom");const C=m-u.top-u.bottom,x=p-u.left-u.right,w=cn(m-u[v],C),E=cn(p-u[b],x),S=!e.middlewareData.shift;let k=w,M=E;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(M=x),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(k=C),S&&!h){const P=$e(u.left,0),_=$e(u.right,0),U=$e(u.top,0),F=$e(u.bottom,0);f?M=p-2*(P!==0||_!==0?P+_:$e(u.left,u.right)):k=m-2*(U!==0||F!==0?U+F:$e(u.top,u.bottom))}await a({...e,availableWidth:M,availableHeight:k});const I=await s.getDimensions(l.floating);return p!==I.width||m!==I.height?{reset:{rects:!0}}:{}}}};function Pm(t){const e=tt(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=Ue(t),i=o?t.offsetWidth:n,s=o?t.offsetHeight:r,l=Pi(n)!==i||Pi(r)!==s;return l&&(n=i,r=s),{width:n,height:r,$:l}}function mc(t){return ie(t)?t:t.contextElement}function er(t){const e=mc(t);if(!Ue(e))return ht(1);const n=e.getBoundingClientRect(),{width:r,height:o,$:i}=Pm(e);let s=(i?Pi(n.width):n.width)/r,l=(i?Pi(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const a5=ht(0);function jm(t){const e=Fe(t);return!as()||!e.visualViewport?a5:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function c5(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Fe(t)?!1:e}function In(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),i=mc(t);let s=ht(1);e&&(r?ie(r)&&(s=er(r)):s=er(t));const l=c5(i,n,r)?jm(i):ht(0);let a=(o.left+l.x)/s.x,c=(o.top+l.y)/s.y,u=o.width/s.x,d=o.height/s.y;if(i){const h=Fe(i),f=r&&ie(r)?Fe(r):r;let p=h,m=ta(p);for(;m&&r&&f!==p;){const v=er(m),b=m.getBoundingClientRect(),C=tt(m),x=b.left+(m.clientLeft+parseFloat(C.paddingLeft))*v.x,w=b.top+(m.clientTop+parseFloat(C.paddingTop))*v.y;a*=v.x,c*=v.y,u*=v.x,d*=v.y,a+=x,c+=w,p=Fe(m),m=ta(p)}}return Bi({width:u,height:d,x:a,y:c})}function us(t,e){const n=cs(t).scrollLeft;return e?e.left+n:In(gt(t)).left+n}function Bm(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-us(t,n),o=n.top+e.scrollTop;return{x:r,y:o}}function u5(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t;const i=o==="fixed",s=gt(r),l=e?ls(e.floating):!1;if(r===s||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=ht(1);const u=ht(0),d=Ue(r);if((d||!d&&!i)&&((fr(r)!=="body"||ao(s))&&(a=cs(r)),Ue(r))){const f=In(r);c=er(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}const h=s&&!d&&!i?Bm(s,a):ht(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-a.scrollTop*c.y+u.y+h.y}}function d5(t){return Array.from(t.getClientRects())}function f5(t){const e=gt(t),n=cs(t),r=t.ownerDocument.body,o=$e(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=$e(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+us(t);const l=-n.scrollTop;return tt(r).direction==="rtl"&&(s+=$e(e.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:l}}const ef=25;function h5(t,e){const n=Fe(t),r=gt(t),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,l=0,a=0;if(o){i=o.width,s=o.height;const u=as();(!u||u&&e==="fixed")&&(l=o.offsetLeft,a=o.offsetTop)}const c=us(r);if(c<=0){const u=r.ownerDocument,d=u.body,h=getComputedStyle(d),f=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-f);p<=ef&&(i-=p)}else c<=ef&&(i+=c);return{width:i,height:s,x:l,y:a}}const p5=new Set(["absolute","fixed"]);function m5(t,e){const n=In(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,i=Ue(t)?er(t):ht(1),s=t.clientWidth*i.x,l=t.clientHeight*i.y,a=o*i.x,c=r*i.y;return{width:s,height:l,x:a,y:c}}function tf(t,e,n){let r;if(e==="viewport")r=h5(t,n);else if(e==="document")r=f5(gt(t));else if(ie(e))r=m5(e,n);else{const o=jm(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return Bi(r)}function _m(t,e){const n=It(t);return n===e||!ie(n)||Nt(n)?!1:tt(n).position==="fixed"||_m(n,e)}function g5(t,e){const n=e.get(t);if(n)return n;let r=rn(t,[],!1).filter(l=>ie(l)&&fr(l)!=="body"),o=null;const i=tt(t).position==="fixed";let s=i?It(t):t;for(;ie(s)&&!Nt(s);){const l=tt(s),a=dc(s);!a&&l.position==="fixed"&&(o=null),(i?!a&&!o:!a&&l.position==="static"&&!!o&&p5.has(o.position)||ao(s)&&!a&&_m(t,s))?r=r.filter(u=>u!==s):o=l,s=It(s)}return e.set(t,r),r}function y5(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t;const s=[...n==="clippingAncestors"?ls(e)?[]:g5(e,this._c):[].concat(n),r],l=s[0],a=s.reduce((c,u)=>{const d=tf(e,u,o);return c.top=$e(d.top,c.top),c.right=cn(d.right,c.right),c.bottom=cn(d.bottom,c.bottom),c.left=$e(d.left,c.left),c},tf(e,l,o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function v5(t){const{width:e,height:n}=Pm(t);return{width:e,height:n}}function b5(t,e,n){const r=Ue(e),o=gt(e),i=n==="fixed",s=In(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const a=ht(0);function c(){a.x=us(o)}if(r||!r&&!i)if((fr(e)!=="body"||ao(o))&&(l=cs(e)),r){const f=In(e,!0,i,e);a.x=f.x+e.clientLeft,a.y=f.y+e.clientTop}else o&&c();i&&!r&&o&&c();const u=o&&!r&&!i?Bm(o,l):ht(0),d=s.left+l.scrollLeft-a.x-u.x,h=s.top+l.scrollTop-a.y-u.y;return{x:d,y:h,width:s.width,height:s.height}}function il(t){return tt(t).position==="static"}function nf(t,e){if(!Ue(t)||tt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return gt(t)===n&&(n=n.ownerDocument.body),n}function Hm(t,e){const n=Fe(t);if(ls(t))return n;if(!Ue(t)){let o=It(t);for(;o&&!Nt(o);){if(ie(o)&&!il(o))return o;o=It(o)}return n}let r=nf(t,e);for(;r&&t4(r)&&il(r);)r=nf(r,e);return r&&Nt(r)&&il(r)&&!dc(r)?n:r||s4(t)||n}const C5=async function(t){const e=this.getOffsetParent||Hm,n=this.getDimensions,r=await n(t.floating);return{reference:b5(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function x5(t){return tt(t).direction==="rtl"}const w5={convertOffsetParentRelativeRectToViewportRelativeRect:u5,getDocumentElement:gt,getClippingRect:y5,getOffsetParent:Hm,getElementRects:C5,getClientRects:d5,getDimensions:v5,getScale:er,isElement:ie,isRTL:x5};function Fm(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function S5(t,e){let n=null,r;const o=gt(t);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function s(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),i();const c=t.getBoundingClientRect(),{left:u,top:d,width:h,height:f}=c;if(l||e(),!h||!f)return;const p=Oo(d),m=Oo(o.clientWidth-(u+h)),v=Oo(o.clientHeight-(d+f)),b=Oo(u),x={rootMargin:-p+"px "+-m+"px "+-v+"px "+-b+"px",threshold:$e(0,cn(1,a))||1};let w=!0;function E(S){const k=S[0].intersectionRatio;if(k!==a){if(!w)return s();k?s(!1,k):r=setTimeout(()=>{s(!1,1e-7)},1e3)}k===1&&!Fm(c,t.getBoundingClientRect())&&s(),w=!1}try{n=new IntersectionObserver(E,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(E,x)}n.observe(t)}return s(!0),i}function $m(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=mc(t),u=o||i?[...c?rn(c):[],...rn(e)]:[];u.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),i&&b.addEventListener("resize",n)});const d=c&&l?S5(c,n):null;let h=-1,f=null;s&&(f=new ResizeObserver(b=>{let[C]=b;C&&C.target===c&&f&&(f.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var x;(x=f)==null||x.observe(e)})),n()}),c&&!a&&f.observe(c),f.observe(e));let p,m=a?In(t):null;a&&v();function v(){const b=In(t);m&&!Fm(m,b)&&n(),m=b,p=requestAnimationFrame(v)}return n(),()=>{var b;u.forEach(C=>{o&&C.removeEventListener("scroll",n),i&&C.removeEventListener("resize",n)}),d?.(),(b=f)==null||b.disconnect(),f=null,a&&cancelAnimationFrame(p)}}const k5=o5,E5=i5,M5=t5,T5=l5,A5=n5,rf=e5,R5=s5,O5=(t,e,n)=>{const r=new Map,o={platform:w5,...n},i={...o.platform,_c:r};return Q4(t,e,{...o,platform:i})};var N5=typeof document<"u",I5=function(){},Uo=N5?L.useLayoutEffect:I5;function Hi(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,o;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Hi(t[r],e[r]))return!1;return!0}if(o=Object.keys(t),n=o.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&t.$$typeof)&&!Hi(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function Vm(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function of(t,e){const n=Vm(t);return Math.round(e*n)/n}function sl(t){const e=y.useRef(t);return Uo(()=>{e.current=t}),e}function zm(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:l=!0,whileElementsMounted:a,open:c}=t,[u,d]=y.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,f]=y.useState(r);Hi(h,r)||f(r);const[p,m]=y.useState(null),[v,b]=y.useState(null),C=y.useCallback(T=>{T!==S.current&&(S.current=T,m(T))},[]),x=y.useCallback(T=>{T!==k.current&&(k.current=T,b(T))},[]),w=i||p,E=s||v,S=y.useRef(null),k=y.useRef(null),M=y.useRef(u),I=a!=null,P=sl(a),_=sl(o),U=sl(c),F=y.useCallback(()=>{if(!S.current||!k.current)return;const T={placement:e,strategy:n,middleware:h};_.current&&(T.platform=_.current),O5(S.current,k.current,T).then(R=>{const W={...R,isPositioned:U.current!==!1};O.current&&!Hi(M.current,W)&&(M.current=W,va.flushSync(()=>{d(W)}))})},[h,e,n,_,U]);Uo(()=>{c===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,d(T=>({...T,isPositioned:!1})))},[c]);const O=y.useRef(!1);Uo(()=>(O.current=!0,()=>{O.current=!1}),[]),Uo(()=>{if(w&&(S.current=w),E&&(k.current=E),w&&E){if(P.current)return P.current(w,E,F);F()}},[w,E,F,P,I]);const H=y.useMemo(()=>({reference:S,floating:k,setReference:C,setFloating:x}),[C,x]),V=y.useMemo(()=>({reference:w,floating:E}),[w,E]),D=y.useMemo(()=>{const T={position:n,left:0,top:0};if(!V.floating)return T;const R=of(V.floating,u.x),W=of(V.floating,u.y);return l?{...T,transform:"translate("+R+"px, "+W+"px)",...Vm(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:R,top:W}},[n,l,V.floating,u.x,u.y]);return y.useMemo(()=>({...u,update:F,refs:H,elements:V,floatingStyles:D}),[u,F,H,V,D])}const L5=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:o}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?rf({element:r.current,padding:o}).fn(n):{}:r?rf({element:r,padding:o}).fn(n):{}}}},Um=(t,e)=>({...k5(t),options:[t,e]}),Wm=(t,e)=>({...E5(t),options:[t,e]}),D5=(t,e)=>({...R5(t),options:[t,e]}),Km=(t,e)=>({...M5(t),options:[t,e]}),P5=(t,e)=>({...T5(t),options:[t,e]}),j5=(t,e)=>({...A5(t),options:[t,e]}),B5=(t,e)=>({...L5(t),options:[t,e]});function qm(t){const e=y.useRef(void 0),n=y.useCallback(r=>{const o=t.map(i=>{if(i!=null){if(typeof i=="function"){const s=i,l=s(r);return typeof l=="function"?l:()=>{s(null)}}return i.current=r,()=>{i.current=null}}});return()=>{o.forEach(i=>i?.())}},t);return y.useMemo(()=>t.every(r=>r==null)?null:r=>{e.current&&(e.current(),e.current=void 0),r!=null&&(e.current=n(r))},t)}const _5="data-floating-ui-focusable",sf="active",lf="selected",H5={...y};let af=!1,F5=0;const cf=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+F5++;function $5(){const[t,e]=y.useState(()=>af?cf():void 0);return ot(()=>{t==null&&e(cf())},[]),y.useEffect(()=>{af=!0},[]),t}const V5=H5.useId,gc=V5||$5;let aa;process.env.NODE_ENV!=="production"&&(aa=new Set);function z5(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];const o="Floating UI: "+n.join(" ");if(!((t=aa)!=null&&t.has(o))){var i;(i=aa)==null||i.add(o),console.error(o)}}function U5(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(o=>o(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const W5=y.createContext(null),K5=y.createContext(null),yc=()=>{var t;return((t=y.useContext(W5))==null?void 0:t.id)||null},vc=()=>y.useContext(K5);function co(t){return"data-floating-ui-"+t}function Ge(t){t.current!==-1&&(clearTimeout(t.current),t.current=-1)}const uf=co("safe-polygon");function ll(t,e,n){if(n&&!la(n))return 0;if(typeof t=="number")return t;if(typeof t=="function"){const r=t();return typeof r=="number"?r:r?.[e]}return t?.[e]}function al(t){return typeof t=="function"?t():t}function q5(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,dataRef:o,events:i,elements:s}=t,{enabled:l=!0,delay:a=0,handleClose:c=null,mouseOnly:u=!1,restMs:d=0,move:h=!0}=e,f=vc(),p=yc(),m=No(c),v=No(a),b=No(n),C=No(d),x=y.useRef(),w=y.useRef(-1),E=y.useRef(),S=y.useRef(-1),k=y.useRef(!0),M=y.useRef(!1),I=y.useRef(()=>{}),P=y.useRef(!1),_=at(()=>{var D;const T=(D=o.current.openEvent)==null?void 0:D.type;return T?.includes("mouse")&&T!=="mousedown"});y.useEffect(()=>{if(!l)return;function D(T){let{open:R}=T;R||(Ge(w),Ge(S),k.current=!0,P.current=!1)}return i.on("openchange",D),()=>{i.off("openchange",D)}},[l,i]),y.useEffect(()=>{if(!l||!m.current||!n)return;function D(R){_()&&r(!1,R,"hover")}const T=dt(s.floating).documentElement;return T.addEventListener("mouseleave",D),()=>{T.removeEventListener("mouseleave",D)}},[s.floating,n,r,l,m,_]);const U=y.useCallback(function(D,T,R){T===void 0&&(T=!0),R===void 0&&(R="hover");const W=ll(v.current,"close",x.current);W&&!E.current?(Ge(w),w.current=window.setTimeout(()=>r(!1,D,R),W)):T&&(Ge(w),r(!1,D,R))},[v,r]),F=at(()=>{I.current(),E.current=void 0}),O=at(()=>{if(M.current){const D=dt(s.floating).body;D.style.pointerEvents="",D.removeAttribute(uf),M.current=!1}}),H=at(()=>o.current.openEvent?["click","mousedown"].includes(o.current.openEvent.type):!1);y.useEffect(()=>{if(!l)return;function D(K){if(Ge(w),k.current=!1,u&&!la(x.current)||al(C.current)>0&&!ll(v.current,"open"))return;const X=ll(v.current,"open",x.current);X?w.current=window.setTimeout(()=>{b.current||r(!0,K,"hover")},X):n||r(!0,K,"hover")}function T(K){if(H()){O();return}I.current();const X=dt(s.floating);if(Ge(S),P.current=!1,m.current&&o.current.floatingContext){n||Ge(w),E.current=m.current({...o.current.floatingContext,tree:f,x:K.clientX,y:K.clientY,onClose(){O(),F(),H()||U(K,!0,"safe-polygon")}});const ce=E.current;X.addEventListener("mousemove",ce),I.current=()=>{X.removeEventListener("mousemove",ce)};return}(x.current==="touch"?!cr(s.floating,K.relatedTarget):!0)&&U(K)}function R(K){H()||o.current.floatingContext&&(m.current==null||m.current({...o.current.floatingContext,tree:f,x:K.clientX,y:K.clientY,onClose(){O(),F(),H()||U(K)}})(K))}function W(){Ge(w)}function ne(K){H()||U(K,!1)}if(ie(s.domReference)){const K=s.domReference,X=s.floating;return n&&K.addEventListener("mouseleave",R),h&&K.addEventListener("mousemove",D,{once:!0}),K.addEventListener("mouseenter",D),K.addEventListener("mouseleave",T),X&&(X.addEventListener("mouseleave",R),X.addEventListener("mouseenter",W),X.addEventListener("mouseleave",ne)),()=>{n&&K.removeEventListener("mouseleave",R),h&&K.removeEventListener("mousemove",D),K.removeEventListener("mouseenter",D),K.removeEventListener("mouseleave",T),X&&(X.removeEventListener("mouseleave",R),X.removeEventListener("mouseenter",W),X.removeEventListener("mouseleave",ne))}}},[s,l,t,u,h,U,F,O,r,n,b,f,v,m,o,H,C]),ot(()=>{var D;if(l&&n&&(D=m.current)!=null&&(D=D.__options)!=null&&D.blockPointerEvents&&_()){M.current=!0;const R=s.floating;if(ie(s.domReference)&&R){var T;const W=dt(s.floating).body;W.setAttribute(uf,"");const ne=s.domReference,K=f==null||(T=f.nodesRef.current.find(X=>X.id===p))==null||(T=T.context)==null?void 0:T.elements.floating;return K&&(K.style.pointerEvents=""),W.style.pointerEvents="none",ne.style.pointerEvents="auto",R.style.pointerEvents="auto",()=>{W.style.pointerEvents="",ne.style.pointerEvents="",R.style.pointerEvents=""}}}},[l,n,p,s,f,m,_]),ot(()=>{n||(x.current=void 0,P.current=!1,F(),O())},[n,F,O]),y.useEffect(()=>()=>{F(),Ge(w),Ge(S),O()},[l,s.domReference,F,O]);const V=y.useMemo(()=>{function D(T){x.current=T.pointerType}return{onPointerDown:D,onPointerEnter:D,onMouseMove(T){const{nativeEvent:R}=T;function W(){!k.current&&!b.current&&r(!0,R,"hover")}u&&!la(x.current)||n||al(C.current)===0||P.current&&T.movementX**2+T.movementY**2<2||(Ge(S),x.current==="touch"?W():(P.current=!0,S.current=window.setTimeout(W,al(C.current))))}}},[u,r,n,b,C]);return y.useMemo(()=>l?{reference:V}:{},[l,V])}const df=()=>{},G5=y.createContext({delay:0,initialDelay:0,timeoutMs:0,currentId:null,setCurrentId:df,setState:df,isInstantPhase:!1});function J5(t){const{children:e,delay:n,timeoutMs:r=0}=t,[o,i]=y.useReducer((a,c)=>({...a,...c}),{delay:n,timeoutMs:r,initialDelay:n,currentId:null,isInstantPhase:!1}),s=y.useRef(null),l=y.useCallback(a=>{i({currentId:a})},[]);return ot(()=>{o.currentId?s.current===null?s.current=o.currentId:o.isInstantPhase||i({isInstantPhase:!0}):(o.isInstantPhase&&i({isInstantPhase:!1}),s.current=null)},[o.currentId,o.isInstantPhase]),g.jsx(G5.Provider,{value:y.useMemo(()=>({...o,setState:i,setCurrentId:l}),[o,l]),children:e})}const Gm={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},ff=y.forwardRef(function(e,n){const[r,o]=y.useState();ot(()=>{Nm()&&o("button")},[]);const i={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[co("focus-guard")]:"",style:Gm};return g.jsx("span",{...e,...i})}),Jm=y.createContext(null),hf=co("portal");function Z5(t){t===void 0&&(t={});const{id:e,root:n}=t,r=gc(),o=X5(),[i,s]=y.useState(null),l=y.useRef(null);return ot(()=>()=>{i?.remove(),queueMicrotask(()=>{l.current=null})},[i]),ot(()=>{if(!r||l.current)return;const a=e?document.getElementById(e):null;if(!a)return;const c=document.createElement("div");c.id=r,c.setAttribute(hf,""),a.appendChild(c),l.current=c,s(c)},[e,r]),ot(()=>{if(n===null||!r||l.current)return;let a=n||o?.portalNode;a&&!uc(a)&&(a=a.current),a=a||document.body;let c=null;e&&(c=document.createElement("div"),c.id=e,a.appendChild(c));const u=document.createElement("div");u.id=r,u.setAttribute(hf,""),a=c||a,a.appendChild(u),l.current=u,s(u)},[e,n,r,o]),i}function Y5(t){const{children:e,id:n,root:r,preserveTabOrder:o=!0}=t,i=Z5({id:n,root:r}),[s,l]=y.useState(null),a=y.useRef(null),c=y.useRef(null),u=y.useRef(null),d=y.useRef(null),h=s?.modal,f=s?.open,p=!!s&&!s.modal&&s.open&&o&&!!(r||i);return y.useEffect(()=>{if(!i||!o||h)return;function m(v){i&&ol(v)&&(v.type==="focusin"?Zd:X4)(i)}return i.addEventListener("focusin",m,!0),i.addEventListener("focusout",m,!0),()=>{i.removeEventListener("focusin",m,!0),i.removeEventListener("focusout",m,!0)}},[i,o,h]),y.useEffect(()=>{i&&(f||Zd(i))},[f,i]),g.jsxs(Jm.Provider,{value:y.useMemo(()=>({preserveTabOrder:o,beforeOutsideRef:a,afterOutsideRef:c,beforeInsideRef:u,afterInsideRef:d,portalNode:i,setFocusManagerState:l}),[o,i]),children:[p&&i&&g.jsx(ff,{"data-type":"outside",ref:a,onFocus:m=>{if(ol(m,i)){var v;(v=u.current)==null||v.focus()}else{const b=s?s.domReference:null,C=Y4(b);C?.focus()}}}),p&&i&&g.jsx("span",{"aria-owns":i.id,style:Gm}),i&&va.createPortal(e,i),p&&i&&g.jsx(ff,{"data-type":"outside",ref:c,onFocus:m=>{if(ol(m,i)){var v;(v=d.current)==null||v.focus()}else{const b=s?s.domReference:null,C=Z4(b);C?.focus(),s?.closeOnFocusOut&&s?.onOpenChange(!1,m.nativeEvent,"focus-out")}}})]})}const X5=()=>y.useContext(Jm),Q5={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},eS={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},pf=t=>{var e,n;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(n=t?.outsidePress)!=null?n:!0}};function tS(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,elements:o,dataRef:i}=t,{enabled:s=!0,escapeKey:l=!0,outsidePress:a=!0,outsidePressEvent:c="pointerdown",referencePress:u=!1,referencePressEvent:d="pointerdown",ancestorScroll:h=!1,bubbles:f,capture:p}=e,m=vc(),v=at(typeof a=="function"?a:()=>!1),b=typeof a=="function"?v:a,C=y.useRef(!1),{escapeKey:x,outsidePress:w}=pf(f),{escapeKey:E,outsidePress:S}=pf(p),k=y.useRef(!1),M=at(O=>{var H;if(!n||!s||!l||O.key!=="Escape"||k.current)return;const V=(H=i.current.floatingContext)==null?void 0:H.nodeId,D=m?zo(m.nodesRef.current,V):[];if(!x&&(O.stopPropagation(),D.length>0)){let T=!0;if(D.forEach(R=>{var W;if((W=R.context)!=null&&W.open&&!R.context.dataRef.current.__escapeKeyBubbles){T=!1;return}}),!T)return}r(!1,U4(O)?O.nativeEvent:O,"escape-key")}),I=at(O=>{var H;const V=()=>{var D;M(O),(D=Jn(O))==null||D.removeEventListener("keydown",V)};(H=Jn(O))==null||H.addEventListener("keydown",V)}),P=at(O=>{var H;const V=i.current.insideReactTree;i.current.insideReactTree=!1;const D=C.current;if(C.current=!1,c==="click"&&D||V||typeof b=="function"&&!b(O))return;const T=Jn(O),R="["+co("inert")+"]",W=dt(o.floating).querySelectorAll(R);let ne=ie(T)?T:null;for(;ne&&!Nt(ne);){const ce=It(ne);if(Nt(ce)||!ie(ce))break;ne=ce}if(W.length&&ie(T)&&!F4(T)&&!cr(T,o.floating)&&Array.from(W).every(ce=>!cr(ne,ce)))return;if(Ue(T)&&F){const ce=Nt(T),ye=tt(T),Q=/auto|scroll/,re=ce||Q.test(ye.overflowX),Ke=ce||Q.test(ye.overflowY),xt=re&&T.clientWidth>0&&T.scrollWidth>T.clientWidth,Hn=Ke&&T.clientHeight>0&&T.scrollHeight>T.clientHeight,Ss=ye.direction==="rtl",Fn=Hn&&(Ss?O.offsetX<=T.offsetWidth-T.clientWidth:O.offsetX>T.clientWidth),W0=xt&&O.offsetY>T.clientHeight;if(Fn||W0)return}const K=(H=i.current.floatingContext)==null?void 0:H.nodeId,X=m&&zo(m.nodesRef.current,K).some(ce=>{var ye;return rl(O,(ye=ce.context)==null?void 0:ye.elements.floating)});if(rl(O,o.floating)||rl(O,o.domReference)||X)return;const We=m?zo(m.nodesRef.current,K):[];if(We.length>0){let ce=!0;if(We.forEach(ye=>{var Q;if((Q=ye.context)!=null&&Q.open&&!ye.context.dataRef.current.__outsidePressBubbles){ce=!1;return}}),!ce)return}r(!1,O,"outside-press")}),_=at(O=>{var H;const V=()=>{var D;P(O),(D=Jn(O))==null||D.removeEventListener(c,V)};(H=Jn(O))==null||H.addEventListener(c,V)});y.useEffect(()=>{if(!n||!s)return;i.current.__escapeKeyBubbles=x,i.current.__outsidePressBubbles=w;let O=-1;function H(W){r(!1,W,"ancestor-scroll")}function V(){window.clearTimeout(O),k.current=!0}function D(){O=window.setTimeout(()=>{k.current=!1},as()?5:0)}const T=dt(o.floating);l&&(T.addEventListener("keydown",E?I:M,E),T.addEventListener("compositionstart",V),T.addEventListener("compositionend",D)),b&&T.addEventListener(c,S?_:P,S);let R=[];return h&&(ie(o.domReference)&&(R=rn(o.domReference)),ie(o.floating)&&(R=R.concat(rn(o.floating))),!ie(o.reference)&&o.reference&&o.reference.contextElement&&(R=R.concat(rn(o.reference.contextElement)))),R=R.filter(W=>{var ne;return W!==((ne=T.defaultView)==null?void 0:ne.visualViewport)}),R.forEach(W=>{W.addEventListener("scroll",H,{passive:!0})}),()=>{l&&(T.removeEventListener("keydown",E?I:M,E),T.removeEventListener("compositionstart",V),T.removeEventListener("compositionend",D)),b&&T.removeEventListener(c,S?_:P,S),R.forEach(W=>{W.removeEventListener("scroll",H)}),window.clearTimeout(O)}},[i,o,l,b,c,n,r,h,s,x,w,M,E,I,P,S,_]),y.useEffect(()=>{i.current.insideReactTree=!1},[i,b,c]);const U=y.useMemo(()=>({onKeyDown:M,...u&&{[Q5[d]]:O=>{r(!1,O.nativeEvent,"reference-press")},...d!=="click"&&{onClick(O){r(!1,O.nativeEvent,"reference-press")}}}}),[M,r,u,d]),F=y.useMemo(()=>({onKeyDown:M,onMouseDown(){C.current=!0},onMouseUp(){C.current=!0},[eS[c]]:()=>{i.current.insideReactTree=!0}}),[M,c,i]);return y.useMemo(()=>s?{reference:U,floating:F}:{},[s,U,F])}function nS(t){const{open:e=!1,onOpenChange:n,elements:r}=t,o=gc(),i=y.useRef({}),[s]=y.useState(()=>U5()),l=yc()!=null;if(process.env.NODE_ENV!=="production"){const f=r.reference;f&&!ie(f)&&z5("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[a,c]=y.useState(r.reference),u=at((f,p,m)=>{i.current.openEvent=f?p:void 0,s.emit("openchange",{open:f,event:p,reason:m,nested:l}),n?.(f,p,m)}),d=y.useMemo(()=>({setPositionReference:c}),[]),h=y.useMemo(()=>({reference:a||r.reference||null,floating:r.floating||null,domReference:r.reference}),[a,r.reference,r.floating]);return y.useMemo(()=>({dataRef:i,open:e,onOpenChange:u,elements:h,events:s,floatingId:o,refs:d}),[e,u,h,s,o,d])}function rS(t){t===void 0&&(t={});const{nodeId:e}=t,n=nS({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,o=r.elements,[i,s]=y.useState(null),[l,a]=y.useState(null),u=o?.domReference||i,d=y.useRef(null),h=vc();ot(()=>{u&&(d.current=u)},[u]);const f=zm({...t,elements:{...o,...l&&{reference:l}}}),p=y.useCallback(x=>{const w=ie(x)?{getBoundingClientRect:()=>x.getBoundingClientRect(),getClientRects:()=>x.getClientRects(),contextElement:x}:x;a(w),f.refs.setReference(w)},[f.refs]),m=y.useCallback(x=>{(ie(x)||x===null)&&(d.current=x,s(x)),(ie(f.refs.reference.current)||f.refs.reference.current===null||x!==null&&!ie(x))&&f.refs.setReference(x)},[f.refs]),v=y.useMemo(()=>({...f.refs,setReference:m,setPositionReference:p,domReference:d}),[f.refs,m,p]),b=y.useMemo(()=>({...f.elements,domReference:u}),[f.elements,u]),C=y.useMemo(()=>({...f,...r,refs:v,elements:b,nodeId:e}),[f,v,b,e,r]);return ot(()=>{r.dataRef.current.floatingContext=C;const x=h?.nodesRef.current.find(w=>w.id===e);x&&(x.context=C)}),y.useMemo(()=>({...f,context:C,refs:v,elements:b}),[f,v,b,C])}function cl(){return B4()&&Nm()}function oS(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,events:o,dataRef:i,elements:s}=t,{enabled:l=!0,visibleOnly:a=!0}=e,c=y.useRef(!1),u=y.useRef(-1),d=y.useRef(!0);y.useEffect(()=>{if(!l)return;const f=Fe(s.domReference);function p(){!n&&Ue(s.domReference)&&s.domReference===sa(dt(s.domReference))&&(c.current=!0)}function m(){d.current=!0}function v(){d.current=!1}return f.addEventListener("blur",p),cl()&&(f.addEventListener("keydown",m,!0),f.addEventListener("pointerdown",v,!0)),()=>{f.removeEventListener("blur",p),cl()&&(f.removeEventListener("keydown",m,!0),f.removeEventListener("pointerdown",v,!0))}},[s.domReference,n,l]),y.useEffect(()=>{if(!l)return;function f(p){let{reason:m}=p;(m==="reference-press"||m==="escape-key")&&(c.current=!0)}return o.on("openchange",f),()=>{o.off("openchange",f)}},[o,l]),y.useEffect(()=>()=>{Ge(u)},[]);const h=y.useMemo(()=>({onMouseLeave(){c.current=!1},onFocus(f){if(c.current)return;const p=Jn(f.nativeEvent);if(a&&ie(p)){if(cl()&&!f.relatedTarget){if(!d.current&&!$4(p))return}else if(!V4(p))return}r(!0,f.nativeEvent,"focus")},onBlur(f){c.current=!1;const p=f.relatedTarget,m=f.nativeEvent,v=ie(p)&&p.hasAttribute(co("focus-guard"))&&p.getAttribute("data-type")==="outside";u.current=window.setTimeout(()=>{var b;const C=sa(s.domReference?s.domReference.ownerDocument:document);!p&&C===s.domReference||cr((b=i.current.floatingContext)==null?void 0:b.refs.floating.current,C)||cr(s.domReference,C)||v||r(!1,m,"focus")})}}),[i,s.domReference,r,a]);return y.useMemo(()=>l?{reference:h}:{},[l,h])}function ul(t,e,n){const r=new Map,o=n==="item";let i=t;if(o&&t){const{[sf]:s,[lf]:l,...a}=t;i=a}return{...n==="floating"&&{tabIndex:-1,[_5]:""},...i,...e.map(s=>{const l=s?s[n]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((s,l)=>(l&&Object.entries(l).forEach(a=>{let[c,u]=a;if(!(o&&[sf,lf].includes(c)))if(c.indexOf("on")===0){if(r.has(c)||r.set(c,[]),typeof u=="function"){var d;(d=r.get(c))==null||d.push(u),s[c]=function(){for(var h,f=arguments.length,p=new Array(f),m=0;m<f;m++)p[m]=arguments[m];return(h=r.get(c))==null?void 0:h.map(v=>v(...p)).find(v=>v!==void 0)}}}else s[c]=u}),s),{})}}function iS(t){t===void 0&&(t=[]);const e=t.map(l=>l?.reference),n=t.map(l=>l?.floating),r=t.map(l=>l?.item),o=y.useCallback(l=>ul(l,t,"reference"),e),i=y.useCallback(l=>ul(l,t,"floating"),n),s=y.useCallback(l=>ul(l,t,"item"),r);return y.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:s}),[o,i,s])}const sS=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function lS(t,e){var n,r;e===void 0&&(e={});const{open:o,elements:i,floatingId:s}=t,{enabled:l=!0,role:a="dialog"}=e,c=gc(),u=((n=i.domReference)==null?void 0:n.id)||c,d=y.useMemo(()=>{var C;return((C=z4(i.floating))==null?void 0:C.id)||s},[i.floating,s]),h=(r=sS.get(a))!=null?r:a,p=yc()!=null,m=y.useMemo(()=>h==="tooltip"||a==="label"?{["aria-"+(a==="label"?"labelledby":"describedby")]:o?d:void 0}:{"aria-expanded":o?"true":"false","aria-haspopup":h==="alertdialog"?"dialog":h,"aria-controls":o?d:void 0,...h==="listbox"&&{role:"combobox"},...h==="menu"&&{id:u},...h==="menu"&&p&&{role:"menuitem"},...a==="select"&&{"aria-autocomplete":"none"},...a==="combobox"&&{"aria-autocomplete":"list"}},[h,d,p,o,u,a]),v=y.useMemo(()=>{const C={id:d,...h&&{role:h}};return h==="tooltip"||a==="label"?C:{...C,...h==="menu"&&{"aria-labelledby":u}}},[h,d,u,a]),b=y.useCallback(C=>{let{active:x,selected:w}=C;const E={role:"option",...x&&{id:d+"-fui-option"}};switch(a){case"select":case"combobox":return{...E,"aria-selected":w}}return{}},[d,a]);return y.useMemo(()=>l?{reference:m,floating:v,item:b}:{},[l,m,v,b])}const Zm=y.createContext(null);function aS({children:t,container:e}){return g.jsx(Zm.Provider,{value:e,children:t})}function bc(){return y.useContext(Zm)}function cS({initialOpen:t=!1,placement:e="top",open:n,onOpenChange:r,delay:o=600,closeDelay:i=0}={}){const[s,l]=y.useState(t),a=n??s,c=r??l,u=rS({placement:e,open:a,onOpenChange:c,whileElementsMounted:$m,middleware:[Um(4),Km({crossAxis:e.includes("-"),fallbackAxisSideDirection:"start",padding:4}),Wm({padding:4})]}),d=u.context,h=q5(d,{mouseOnly:!0,move:!1,restMs:o,enabled:n==null,delay:{close:i}}),f=oS(d,{enabled:n==null}),p=tS(d),m=lS(d,{role:"tooltip"}),v=iS([h,f,p,m]);return y.useMemo(()=>({open:a,setOpen:c,...v,...u}),[a,c,v,u])}const ca=y.createContext(null);function Ym(){const t=y.useContext(ca);if(t==null)throw new Error("Tooltip components must be wrapped in <TooltipProvider />");return t}function Xm({children:t,...e}){const n=cS(e);return e.useDelayGroup?g.jsx(J5,{delay:{open:e.delay??0,close:e.closeDelay??0},timeoutMs:e.timeout,children:g.jsx(ca.Provider,{value:n,children:t})}):g.jsx(ca.Provider,{value:n,children:t})}const Qm=y.forwardRef(function({children:e,asChild:n=!1,...r},o){const i=Ym(),s=y.isValidElement(e)?parseInt(y.version,10)>=19?e.props.ref:e.ref:void 0,l=qm([i.refs.setReference,o,s]);if(n&&y.isValidElement(e)){const a={"data-tooltip-state":i.open?"open":"closed"};return y.cloneElement(e,i.getReferenceProps({ref:l,...r,...typeof e.props=="object"?e.props:{},...a}))}return g.jsx("button",{ref:l,"data-tooltip-state":i.open?"open":"closed",...i.getReferenceProps(r),children:e})}),e1=y.forwardRef(function({style:e,children:n,portal:r=!0,portalProps:o={},...i},s){const l=Ym(),a=qm([l.refs.setFloating,s]),c=bc();if(!l.open)return null;const u=g.jsx("div",{ref:a,style:{...l.floatingStyles,...e},...l.getFloatingProps(i),className:"tiptap-tooltip",children:n});if(r){const{root:d,...h}=o;return g.jsx(Y5,{...h,root:d??c??void 0,children:u})}return u});Xm.displayName="Tooltip";Qm.displayName="TooltipTrigger";e1.displayName="TooltipContent";const ua=5*1024*1024,uS={mod:"⌘",command:"⌘",meta:"⌘",ctrl:"⌃",control:"⌃",alt:"⌥",option:"⌥",shift:"⇧",backspace:"Del",delete:"⌦",enter:"⏎",escape:"⎋",capslock:"⇪"};function Me(...t){return t.filter(Boolean).join(" ")}function dS(){return typeof navigator<"u"&&navigator.platform.toLowerCase().includes("mac")}const fS=(t,e,n=!0)=>{if(e){const r=t.toLowerCase();return uS[r]||(n?t.toUpperCase():t)}return n?t.charAt(0).toUpperCase()+t.slice(1):t},yt=t=>{const{shortcutKeys:e,delimiter:n="+",capitalize:r=!0}=t;return e?e.split(n).map(o=>o.trim()).map(o=>fS(o,dS(),r)):[]},Dn=(t,e)=>e?.schema?e.schema.spec.marks.get(t)!==void 0:!1,Bt=(t,e)=>e?.schema?e.schema.spec.nodes.get(t)!==void 0:!1;function hS(t){const{state:e,view:n}=t,{doc:r,selection:o}=e,i=q.findFrom(o.$to,1,!0);if(i)return n.dispatch(e.tr.setSelection(i).scrollIntoView()),!0;const s=e.schema.nodes.paragraph;if(!s)return console.warn("No paragraph node type found in schema."),!1;const l=r.content.size,a=s.create();let c=e.tr.insert(l,a);const u=c.doc.resolve(l+1);return c=c.setSelection(z.near(u)).scrollIntoView(),n.dispatch(c),!0}function vt(t){return typeof t=="number"&&t>=0}function ds(t,e){if(!t)return!1;const n=Array.isArray(e)?e:[e],r=n.some(o=>t.extensionManager.extensions.some(i=>i.name===o));return r||console.warn(`None of the extensions [${n.join(", ")}] were found in the editor schema. Ensure they are included in the editor configuration.`),r}function pS(t,e){try{const n=t.state.doc.nodeAt(e);return n||(console.warn(`No node found at position ${e}`),null)}catch(n){return console.error(`Error getting node at position ${e}:`,n),null}}function hn(t){const{editor:e,node:n,nodePos:r}=t;if(!e||!e.state?.doc)return null;const o=n!=null,i=vt(r);if(!o&&!i)return null;if(o){let s=-1,l=null;if(e.state.doc.descendants((a,c)=>a===n?(s=c,l=a,!1):!0),s!==-1&&l!==null)return{pos:s,node:l}}if(i){const s=pS(e,r);if(s)return{pos:r,node:s}}return null}function bt(t,e=[]){if(!t||!t.state.selection)return!1;const{state:n}=t,{selection:r}=n;if(r.empty)return!1;if(r instanceof B){const o=r.node;return o?e.includes(o.type.name):!1}return!1}const mS=async(t,e,n)=>{if(!t)throw new Error("No file provided");if(t.size>ua)throw new Error(`File size exceeds maximum allowed (${ua/(1024*1024)}MB)`);for(let r=0;r<=100;r+=10){if(n?.aborted)throw new Error("Upload cancelled");await new Promise(o=>setTimeout(o,500)),e?.({progress:r})}return"/images/tiptap-ui-placeholder-image.jpg"},gS=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function yS(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return!t||t.replace(gS,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}function vS(t,e,n){try{const r=new URL(t,e);if(yS(r.href,n))return r.href}catch{}return"#"}const bS=({shortcuts:t})=>t.length===0?null:g.jsx("div",{children:t.map((e,n)=>g.jsxs(y.Fragment,{children:[n>0&&g.jsx("kbd",{children:"+"}),g.jsx("kbd",{children:e})]},n))}),se=y.forwardRef(({className:t,children:e,tooltip:n,showTooltip:r=!0,shortcutKeys:o,"aria-label":i,...s},l)=>{const a=y.useMemo(()=>yt({shortcutKeys:o}),[o]);return!n||!r?g.jsx("button",{className:Me("tiptap-button",t),ref:l,"aria-label":i,...s,children:e}):g.jsxs(Xm,{delay:200,children:[g.jsx(Qm,{className:Me("tiptap-button",t),ref:l,"aria-label":i,...s,children:e}),g.jsxs(e1,{children:[n,g.jsx(bS,{shortcuts:a})]})]})});se.displayName="Button";const ft=y.forwardRef(({className:t,children:e,orientation:n="vertical",...r},o)=>g.jsx("div",{ref:o,className:Me("tiptap-button-group",t),"data-orientation":n,role:"group",...r,children:e}));ft.displayName="ButtonGroup";function mf({orientation:t="horizontal",size:e,style:n={},...r}){const o={...n,...t==="horizontal"&&!e&&{flex:1},...e&&{width:t==="vertical"?"1px":e,height:t==="horizontal"?"1px":e}};return g.jsx("div",{...r,style:o})}const tr=y.forwardRef(({decorative:t,orientation:e="vertical",className:n,...r},o)=>{const s=t?{role:"none"}:{"aria-orientation":e==="vertical"?e:void 0,role:"separator"};return g.jsx("div",{className:Me("tiptap-separator",n),"data-orientation":e,...s,...r,ref:o})});tr.displayName="Separator";function t1({editor:t,containerRef:e,query:n,items:r,onSelect:o,onClose:i,orientation:s="vertical",autoSelectFirstItem:l=!0}){const[a,c]=y.useState(l?0:-1);return y.useEffect(()=>{const u=h=>{if(!r.length)return!1;const f=()=>c(m=>m===-1?0:(m+1)%r.length),p=()=>c(m=>m===-1?r.length-1:(m-1+r.length)%r.length);switch(h.key){case"ArrowUp":return s==="horizontal"?!1:(h.preventDefault(),p(),!0);case"ArrowDown":return s==="horizontal"?!1:(h.preventDefault(),f(),!0);case"ArrowLeft":return s==="vertical"?!1:(h.preventDefault(),p(),!0);case"ArrowRight":return s==="vertical"?!1:(h.preventDefault(),f(),!0);case"Tab":return h.preventDefault(),h.shiftKey?p():f(),!0;case"Home":return h.preventDefault(),c(0),!0;case"End":return h.preventDefault(),c(r.length-1),!0;case"Enter":return h.isComposing?!1:(h.preventDefault(),a!==-1&&r[a]&&o?.(r[a]),!0);case"Escape":return h.preventDefault(),i?.(),!0;default:return!1}};let d=null;if(t?d=t.view.dom:e?.current&&(d=e.current),d)return d.addEventListener("keydown",u,!0),()=>{d?.removeEventListener("keydown",u,!0)}},[t,e,r,a,o,i,s]),y.useEffect(()=>{n&&c(l?0:-1)},[n,l]),{selectedIndex:r.length?a:void 0,setSelectedIndex:c}}const gf=(t,e)=>{typeof t=="function"?t(e):t&&typeof t=="object"&&"current"in t&&(t.current=e)},CS=(t,e)=>{const n=y.useRef(null);return y.useCallback(r=>{t&&"current"in t&&(t.current=r),n.current&&gf(n.current,null),n.current=e,e&&gf(e,r)},[t,e])},xS=t=>{const[e,n]=y.useState([]),r=y.useCallback(()=>t.current?Array.from(t.current.querySelectorAll('button:not([disabled]), [role="button"]:not([disabled]), [tabindex="0"]:not([disabled])')):[],[t]);y.useEffect(()=>{const i=t.current;if(!i)return;const s=()=>n(r());s();const l=new MutationObserver(s);return l.observe(i,{childList:!0,subtree:!0}),()=>l.disconnect()},[r,t]);const{selectedIndex:o}=t1({containerRef:t,items:e,orientation:"horizontal",onSelect:i=>i.click(),autoSelectFirstItem:!1});y.useEffect(()=>{const i=t.current;if(!i)return;const s=a=>{const c=a.target;i.contains(c)&&c.setAttribute("data-focus-visible","true")},l=a=>{const c=a.target;i.contains(c)&&c.removeAttribute("data-focus-visible")};return i.addEventListener("focus",s,!0),i.addEventListener("blur",l,!0),()=>{i.removeEventListener("focus",s,!0),i.removeEventListener("blur",l,!0)}},[t]),y.useEffect(()=>{o!==void 0&&e[o]&&e[o].focus()},[o,e])},Cc=y.forwardRef(({children:t,className:e,variant:n="fixed",...r},o)=>{const i=y.useRef(null),s=CS(i,o);return xS(i),g.jsx("div",{ref:s,role:"toolbar","aria-label":"toolbar","data-variant":n,className:Me("tiptap-toolbar",e),...r,children:t})});Cc.displayName="Toolbar";const qt=y.forwardRef(({children:t,className:e,...n},r)=>g.jsx("div",{ref:r,role:"group",className:Me("tiptap-toolbar-group",e),...n,children:t}));qt.displayName="ToolbarGroup";const Gt=y.forwardRef(({...t},e)=>g.jsx(tr,{ref:e,orientation:"vertical",decorative:!0,...t}));Gt.displayName="ToolbarSeparator";const n1=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{d:"M18.7071 6.70711C19.0976 6.31658 19.0976 5.68342 18.7071 5.29289C18.3166 4.90237 17.6834 4.90237 17.2929 5.29289L12 10.5858L6.70711 5.29289C6.31658 4.90237 5.68342 4.90237 5.29289 5.29289C4.90237 5.68342 4.90237 6.31658 5.29289 6.70711L10.5858 12L5.29289 17.2929C4.90237 17.6834 4.90237 18.3166 5.29289 18.7071C5.68342 19.0976 6.31658 19.0976 6.70711 18.7071L12 13.4142L17.2929 18.7071C17.6834 19.0976 18.3166 19.0976 18.7071 18.7071C19.0976 18.3166 19.0976 17.6834 18.7071 17.2929L13.4142 12L18.7071 6.70711Z",fill:"currentColor"})}));n1.displayName="CloseIcon";function wS(t){const[e,n]=y.useState([]),r=async l=>{if(l.size>t.maxSize){const d=new Error(`File size exceeds maximum allowed (${t.maxSize/1024/1024}MB)`);return t.onError?.(d),null}const a=new AbortController,c=crypto.randomUUID(),u={id:c,file:l,progress:0,status:"uploading",abortController:a};n(d=>[...d,u]);try{if(!t.upload)throw new Error("Upload function is not defined");const d=await t.upload(l,h=>{n(f=>f.map(p=>p.id===c?{...p,progress:h.progress}:p))},a.signal);if(!d)throw new Error("Upload failed: No URL returned");return a.signal.aborted?null:(n(h=>h.map(f=>f.id===c?{...f,status:"success",url:d,progress:100}:f)),t.onSuccess?.(d),d)}catch(d){return a.signal.aborted||(n(h=>h.map(f=>f.id===c?{...f,status:"error",progress:0}:f)),t.onError?.(d instanceof Error?d:new Error("Upload failed"))),null}};return{fileItems:e,uploadFiles:async l=>{if(!l||l.length===0)return t.onError?.(new Error("No files to upload")),[];if(t.limit&&l.length>t.limit)return t.onError?.(new Error(`Maximum ${t.limit} file${t.limit===1?"":"s"} allowed`)),[];const a=l.map(u=>r(u));return(await Promise.all(a)).filter(u=>u!==null)},removeFileItem:l=>{n(a=>{const c=a.find(u=>u.id===l);return c?.abortController&&c.abortController.abort(),c?.url&&URL.revokeObjectURL(c.url),a.filter(u=>u.id!==l)})},clearAllFiles:()=>{e.forEach(l=>{l.abortController&&l.abortController.abort(),l.url&&URL.revokeObjectURL(l.url)}),n([])}}}const r1=()=>g.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"tiptap-image-upload-icon",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[g.jsx("path",{d:"M11.1953 4.41771C10.3478 4.08499 9.43578 3.94949 8.5282 4.02147C7.62062 4.09345 6.74133 4.37102 5.95691 4.83316C5.1725 5.2953 4.50354 5.92989 4.00071 6.68886C3.49788 7.44783 3.17436 8.31128 3.05465 9.2138C2.93495 10.1163 3.0222 11.0343 3.3098 11.8981C3.5974 12.7619 4.07781 13.5489 4.71463 14.1995C5.10094 14.5942 5.09414 15.2274 4.69945 15.6137C4.30476 16 3.67163 15.9932 3.28532 15.5985C2.43622 14.731 1.79568 13.6816 1.41221 12.5299C1.02875 11.3781 0.91241 10.1542 1.07201 8.95084C1.23162 7.74748 1.66298 6.59621 2.33343 5.58425C3.00387 4.57229 3.89581 3.72617 4.9417 3.10998C5.98758 2.4938 7.15998 2.1237 8.37008 2.02773C9.58018 1.93176 10.7963 2.11243 11.9262 2.55605C13.0561 2.99968 14.0703 3.69462 14.8919 4.58825C15.5423 5.29573 16.0585 6.11304 16.4177 7.00002H17.4999C18.6799 6.99991 19.8288 7.37933 20.7766 8.08222C21.7245 8.78515 22.4212 9.7743 22.7637 10.9036C23.1062 12.0328 23.0765 13.2423 22.6788 14.3534C22.2812 15.4644 21.5367 16.4181 20.5554 17.0736C20.0962 17.3803 19.4752 17.2567 19.1684 16.7975C18.8617 16.3382 18.9853 15.7172 19.4445 15.4105C20.069 14.9934 20.5427 14.3865 20.7958 13.6794C21.0488 12.9724 21.0678 12.2027 20.8498 11.4841C20.6318 10.7655 20.1885 10.136 19.5853 9.6887C18.9821 9.24138 18.251 8.99993 17.5001 9.00002H15.71C15.2679 9.00002 14.8783 8.70973 14.7518 8.28611C14.4913 7.41374 14.0357 6.61208 13.4195 5.94186C12.8034 5.27164 12.0427 4.75043 11.1953 4.41771Z",fill:"currentColor"}),g.jsx("path",{d:"M11 14.4142V21C11 21.5523 11.4477 22 12 22C12.5523 22 13 21.5523 13 21V14.4142L15.2929 16.7071C15.6834 17.0976 16.3166 17.0976 16.7071 16.7071C17.0976 16.3166 17.0976 15.6834 16.7071 15.2929L12.7078 11.2936C12.7054 11.2912 12.703 11.2888 12.7005 11.2864C12.5208 11.1099 12.2746 11.0008 12.003 11L12 11L11.997 11C11.8625 11.0004 11.7343 11.0273 11.6172 11.0759C11.502 11.1236 11.3938 11.1937 11.2995 11.2864C11.297 11.2888 11.2946 11.2912 11.2922 11.2936L7.29289 15.2929C6.90237 15.6834 6.90237 16.3166 7.29289 16.7071C7.68342 17.0976 8.31658 17.0976 8.70711 16.7071L11 14.4142Z",fill:"currentColor"})]}),SS=()=>g.jsx("svg",{width:"43",height:"57",viewBox:"0 0 43 57",fill:"currentColor",className:"tiptap-image-upload-dropzone-rect-primary",xmlns:"http://www.w3.org/2000/svg",children:g.jsx("path",{d:"M0.75 10.75C0.75 5.64137 4.89137 1.5 10 1.5H32.3431C33.2051 1.5 34.0317 1.84241 34.6412 2.4519L40.2981 8.10876C40.9076 8.71825 41.25 9.5449 41.25 10.4069V46.75C41.25 51.8586 37.1086 56 32 56H10C4.89137 56 0.75 51.8586 0.75 46.75V10.75Z",fill:"currentColor",fillOpacity:"0.11",stroke:"currentColor",strokeWidth:"1.5"})}),kS=()=>g.jsx("svg",{width:"10",height:"10",className:"tiptap-image-upload-dropzone-rect-secondary",viewBox:"0 0 10 10",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:g.jsx("path",{d:"M0 0.75H0.343146C1.40401 0.75 2.42143 1.17143 3.17157 1.92157L8.82843 7.57843C9.57857 8.32857 10 9.34599 10 10.4069V10.75H4C1.79086 10.75 0 8.95914 0 6.75V0.75Z",fill:"currentColor"})}),ES=({onFile:t,children:e})=>{const[n,r]=y.useState(!1),[o,i]=y.useState(!1),s=u=>{u.preventDefault(),u.stopPropagation(),i(!0)},l=u=>{u.preventDefault(),u.stopPropagation(),u.currentTarget.contains(u.relatedTarget)||(i(!1),r(!1))},a=u=>{u.preventDefault(),u.stopPropagation(),r(!0)},c=u=>{u.preventDefault(),u.stopPropagation(),i(!1),r(!1);const d=Array.from(u.dataTransfer.files);d.length>0&&t(d)};return g.jsx("div",{className:`tiptap-image-upload-drag-area ${o?"drag-active":""} ${n?"drag-over":""}`,onDragEnter:s,onDragLeave:l,onDragOver:a,onDrop:c,children:e})},MS=({fileItem:t,onRemove:e})=>{const n=r=>{if(r===0)return"0 Bytes";const o=1024,i=["Bytes","KB","MB","GB"],s=Math.floor(Math.log(r)/Math.log(o));return`${parseFloat((r/Math.pow(o,s)).toFixed(2))} ${i[s]}`};return g.jsxs("div",{className:"tiptap-image-upload-preview",children:[t.status==="uploading"&&g.jsx("div",{className:"tiptap-image-upload-progress",style:{width:`${t.progress}%`}}),g.jsxs("div",{className:"tiptap-image-upload-preview-content",children:[g.jsxs("div",{className:"tiptap-image-upload-file-info",children:[g.jsx("div",{className:"tiptap-image-upload-file-icon",children:g.jsx(r1,{})}),g.jsxs("div",{className:"tiptap-image-upload-details",children:[g.jsx("span",{className:"tiptap-image-upload-text",children:t.file.name}),g.jsx("span",{className:"tiptap-image-upload-subtext",children:n(t.file.size)})]})]}),g.jsxs("div",{className:"tiptap-image-upload-actions",children:[t.status==="uploading"&&g.jsxs("span",{className:"tiptap-image-upload-progress-text",children:[t.progress,"%"]}),g.jsx(se,{type:"button","data-style":"ghost",onClick:r=>{r.stopPropagation(),e()},children:g.jsx(n1,{className:"tiptap-button-icon"})})]})]})]})},TS=({maxSize:t,limit:e})=>g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"tiptap-image-upload-dropzone",children:[g.jsx(SS,{}),g.jsx(kS,{}),g.jsx("div",{className:"tiptap-image-upload-icon-container",children:g.jsx(r1,{})})]}),g.jsxs("div",{className:"tiptap-image-upload-content",children:[g.jsxs("span",{className:"tiptap-image-upload-text",children:[g.jsx("em",{children:"Click to upload"})," or drag and drop"]}),g.jsxs("span",{className:"tiptap-image-upload-subtext",children:["Maximum ",e," file",e===1?"":"s",", ",t/1024/1024,"MB each."]})]})]}),AS=t=>{const{accept:e,limit:n,maxSize:r}=t.node.attrs,o=y.useRef(null),i=t.extension,s={maxSize:r,limit:n,accept:e,upload:i.options.upload,onSuccess:i.options.onSuccess,onError:i.options.onError},{fileItems:l,uploadFiles:a,removeFileItem:c,clearAllFiles:u}=wS(s),d=async m=>{const v=await a(m);if(v.length>0){const b=t.getPos();if(vt(b)){const C=v.map((x,w)=>{const E=m[w]?.name.replace(/\.[^/.]+$/,"")||"unknown";return{type:i.options.type,attrs:{...i.options,src:x,alt:E,title:E}}});t.editor.chain().focus().deleteRange({from:b,to:b+t.node.nodeSize}).insertContentAt(b,C).run(),hS(t.editor)}}},h=m=>{const v=m.target.files;if(!v||v.length===0){i.options.onError?.(new Error("No file selected"));return}d(Array.from(v))},f=()=>{o.current&&l.length===0&&(o.current.value="",o.current.click())},p=l.length>0;return g.jsxs(Ya,{className:"tiptap-image-upload",tabIndex:0,onClick:f,children:[!p&&g.jsx(ES,{onFile:d,children:g.jsx(TS,{maxSize:r,limit:n})}),p&&g.jsxs("div",{className:"tiptap-image-upload-previews",children:[l.length>1&&g.jsxs("div",{className:"tiptap-image-upload-header",children:[g.jsxs("span",{children:["Uploading ",l.length," files"]}),g.jsx(se,{type:"button","data-style":"ghost",onClick:m=>{m.stopPropagation(),u()},children:"Clear All"})]}),l.map(m=>g.jsx(MS,{fileItem:m,onRemove:()=>c(m.id)},m.id))]}),g.jsx("input",{ref:o,name:"file",accept:e,type:"file",multiple:n>1,onChange:h,onClick:m=>m.stopPropagation()})]})},RS=Ie.create({name:"imageUpload",group:"block",draggable:!0,atom:!0,addOptions(){return{type:"image",accept:"image/*",limit:1,maxSize:0,upload:void 0,onError:void 0,onSuccess:void 0,HTMLAttributes:{}}},addAttributes(){return{accept:{default:this.options.accept},limit:{default:this.options.limit},maxSize:{default:this.options.maxSize}}},parseHTML(){return[{tag:'div[data-type="image-upload"]'}]},renderHTML({HTMLAttributes:t}){return["div",te({"data-type":"image-upload"},t)]},addNodeView(){return Xa(AS)},addCommands(){return{setImageUploadNode:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addKeyboardShortcuts(){return{Enter:({editor:t})=>{const{selection:e}=t.state,{nodeAfter:n}=e.$from;if(n&&n.type.name==="imageUpload"&&t.isActive("imageUpload")){const r=t.view.nodeDOM(e.$from.pos);if(r&&r instanceof HTMLElement){const o=r.firstChild;if(o&&o instanceof HTMLElement)return o.click(),!0}}return!1}}}}),OS=Kx.extend({renderHTML(){return["div",te(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}}),NS=({node:t,updateAttributes:e,selected:n})=>{const[r,o]=L.useState(!1),[i,s]=L.useState(t.attrs.width||300),[l,a]=L.useState(t.attrs.alt||""),c=L.useRef(null),u=L.useRef(null),d=L.useRef(null),h=L.useRef(!1),f=L.useRef(0),p=L.useRef(0),m=L.useRef(e);m.current=e;const v=t.attrs.imageId||`img-${Date.now()}`;L.useEffect(()=>{h.current||s(t.attrs.width||300)},[t.attrs.width]),L.useEffect(()=>{a(t.attrs.alt||"")},[t.attrs.alt]);const b=L.useCallback(_=>{a(_.target.value)},[]),C=L.useCallback(()=>{e({alt:l})},[l,e]),x=L.useCallback(_=>{_.key==="Enter"&&(_.preventDefault(),c.current?.blur()),_.stopPropagation()},[]);L.useEffect(()=>{const _=F=>{if(!h.current)return;const O=F.clientX-f.current,H=Math.max(50,p.current+O);s(H),d.current&&(d.current.style.width=`${H}px`)},U=()=>{h.current&&(h.current=!1,o(!1),s(F=>{const O=Math.round(F);return m.current({width:O}),O}))};return document.addEventListener("mousemove",_),document.addEventListener("mouseup",U),()=>{document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",U)}},[]);const w=L.useCallback(_=>{_.preventDefault(),_.stopPropagation(),h.current=!0,o(!0),f.current=_.clientX,p.current=d.current?.getBoundingClientRect().width??300},[]),E=L.useCallback(()=>{},[]),S=t.attrs.textAlign||"left",k=S==="center"?"center":S==="right"?"flex-end":"flex-start",M={position:"relative",display:"inline-block",width:i,maxWidth:"100%",userSelect:r?"none":"auto",outline:n?"2px solid #007bff":"none",outlineOffset:"2px"},I={width:"100%",height:"auto",display:"block",objectFit:"contain"},P={position:"absolute",bottom:-5,right:-5,width:12,height:12,background:"#007bff",border:"2px solid white",borderRadius:"50%",cursor:"nw-resize",opacity:n||r?1:0,transition:"opacity 0.2s ease",zIndex:10,boxShadow:"0 2px 4px rgba(0,0,0,0.2)"};return g.jsx(Ya,{className:"resizable-image-wrapper",style:{display:"flex",justifyContent:k},children:g.jsxs("div",{ref:d,id:`resizable-image-${v}`,style:M,onMouseEnter:()=>{if(d.current){const _=d.current.querySelector(".resize-handle");_&&(_.style.opacity="1")}},onMouseLeave:()=>{if(!r&&!n&&d.current){const _=d.current.querySelector(".resize-handle");_&&(_.style.opacity="0")}},children:[g.jsx("img",{ref:u,src:t.attrs.src,alt:t.attrs.alt||"",title:t.attrs.title||"",style:I,onLoad:E,"data-drag-handle":"",draggable:!1}),g.jsx("div",{className:"resize-handle",style:P,onMouseDown:w,title:"拖拽調整圖片大小"}),(n||r)&&g.jsxs("div",{style:{position:"absolute",top:-25,left:0,background:"rgba(0, 0, 0, 0.8)",color:"white",padding:"2px 6px",borderRadius:"3px",fontSize:"12px",whiteSpace:"nowrap",zIndex:11},children:[Math.round(i)," × auto"]}),n&&g.jsx("div",{className:"resizable-image-alt-input",children:g.jsx("input",{ref:c,type:"text",value:l,onChange:b,onBlur:C,onKeyDown:x,placeholder:"Add alt text…"})})]})})},IS=Ie.create({name:"resizableImage",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null,parseHTML:t=>{const e=t.getAttribute("width");return e?parseInt(e):null},renderHTML:t=>t.width?{width:t.width,height:"auto"}:{}},imageId:{default:null,parseHTML:t=>t.getAttribute("data-image-id"),renderHTML:t=>t.imageId?{"data-image-id":t.imageId}:{}}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])',getAttrs:t=>{const e=t,n=e.getAttribute("width"),r=e.getAttribute("data-image-id");return{src:e.getAttribute("src"),alt:e.getAttribute("alt"),title:e.getAttribute("title"),width:n?parseInt(n):300,imageId:r||`img-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}}}]},renderHTML({HTMLAttributes:t}){return["img",te(this.options.HTMLAttributes,t)]},addCommands(){return{setResizableImage:t=>({commands:e})=>{const n=`img-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return e.insertContent({type:this.name,attrs:{...t,imageId:n,width:t.width||300}})},setImageSize:t=>({commands:e})=>e.updateAttributes(this.name,t)}},addNodeView(){return Xa(NS)}}),LS=200,DS="100%",PS=({node:t,selected:e,updateAttributes:n})=>{const{src:r,provider:o,width:i,textAlign:s}=t.attrs,l=s||"left",a=l==="center"?"center":l==="right"?"flex-end":"flex-start",[c,u]=L.useState(!1),[d,h]=L.useState(i),f=L.useRef(null),p=L.useRef(!1),m=L.useRef(0),v=L.useRef(0),b=L.useRef(n);b.current=n,L.useEffect(()=>{p.current||h(i)},[i]),L.useEffect(()=>{const S=M=>{if(!p.current)return;const I=M.clientX-m.current,P=Math.max(LS,Math.round(v.current+I));h(P),f.current&&(f.current.style.width=`${P}px`)},k=()=>{p.current&&(p.current=!1,u(!1),h(M=>(M==null||b.current({width:M}),M)))};return document.addEventListener("mousemove",S),document.addEventListener("mouseup",k),()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",k)}},[]);const C=L.useCallback(S=>{S.preventDefault(),S.stopPropagation(),p.current=!0,u(!0),m.current=S.clientX;const k=f.current?.getBoundingClientRect(),M=i??(k?.width?Math.round(k.width):560);v.current=M,d==null&&f.current&&(h(M),f.current.style.width=`${M}px`)},[i,d]),x=d??i,w={position:"relative",width:x!=null?`${x}px`:DS,maxWidth:"100%"},E={position:"absolute",bottom:-5,right:-5,width:12,height:12,background:"#007bff",border:"2px solid white",borderRadius:"50%",cursor:"nw-resize",opacity:e||c?1:0,transition:"opacity 0.2s ease",zIndex:10,boxShadow:"0 2px 4px rgba(0,0,0,0.2)"};return g.jsx(Ya,{className:"video-embed-wrapper","data-provider":o,"data-drag-handle":"",style:{display:"flex",justifyContent:a,width:"100%"},children:g.jsxs("div",{ref:f,className:`video-embed-container${e?" selected":""}`,style:{...w,display:"inline-block"},onMouseEnter:()=>{const S=f.current?.querySelector(".video-embed-resize-handle");S&&(S.style.opacity="1")},onMouseLeave:()=>{if(!c&&!e&&f.current){const S=f.current.querySelector(".video-embed-resize-handle");S&&(S.style.opacity="0")}},children:[g.jsx("iframe",{src:r,frameBorder:"0",allowFullScreen:!0,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",title:"Embedded video",style:c?{pointerEvents:"none"}:void 0}),g.jsx("div",{className:"video-embed-resize-handle",style:E,onMouseDown:C,title:"拖拽調整寬度",contentEditable:!1}),(e||c)&&x!=null&&g.jsxs("div",{style:{position:"absolute",top:-25,left:0,background:"rgba(0, 0, 0, 0.8)",color:"white",padding:"2px 6px",borderRadius:"3px",fontSize:"12px",whiteSpace:"nowrap",zIndex:11},children:[Math.round(x),"px 寬"]})]})})};function o1(t){if(!t)return null;const e=t.trim(),n=[/(?:youtube\.com\/watch\?.*v=)([\w-]{11})/,/(?:youtu\.be\/)([\w-]{11})/,/(?:youtube\.com\/embed\/)([\w-]{11})/,/(?:youtube\.com\/shorts\/)([\w-]{11})/];for(const o of n){const i=e.match(o);if(i?.[1])return{embedUrl:`https://www.youtube.com/embed/${i[1]}`,provider:"youtube"}}const r=e.match(/(?:vimeo\.com\/)(\d+)/);return r?.[1]?{embedUrl:`https://player.vimeo.com/video/${r[1]}`,provider:"vimeo"}:null}const jS=Ie.create({name:"videoEmbed",addOptions(){return{HTMLAttributes:{},allowFullscreen:!0}},group:"block",atom:!0,draggable:!0,addAttributes(){return{src:{default:null},provider:{default:"other"},width:{default:null,parseHTML:t=>{const n=t.getAttribute("data-width");if(n==null||n==="")return null;const r=parseInt(n,10);return Number.isFinite(r)?r:null},renderHTML:t=>t.width==null?{}:{"data-width":String(t.width)}}}},parseHTML(){return[{tag:"div[data-video-embed]",getAttrs:t=>{const e=t,n=e.querySelector("iframe"),r=e.getAttribute("data-width"),o=r!=null&&r!==""?parseInt(r,10):null;return{src:n?.getAttribute("src")||e.getAttribute("data-src"),provider:e.getAttribute("data-provider")||"other",width:o!=null&&Number.isFinite(o)?o:null}}}]},renderHTML({HTMLAttributes:t}){const e=t.width,n=e!=null?`max-width: 100%; width: ${e}px;`:"max-width: 100%; width: 100%;";return["div",te({"data-video-embed":"","data-provider":t.provider,...e!=null?{"data-width":String(e)}:{},style:n},t,this.options.HTMLAttributes),["iframe",{src:t.src,frameborder:"0",allowfullscreen:this.options.allowFullscreen?"true":void 0,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",style:"width: 100%; aspect-ratio: 16/9; border: 0; display: block;"}]]},addCommands(){return{setVideoEmbed:t=>({commands:e})=>{const n=o1(t.src);return n?e.insertContent({type:this.name,attrs:{src:n.embedUrl,provider:n.provider}}):!1}}},addNodeView(){return Xa(PS)}}),xc=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.29289 8.29289C5.68342 7.90237 6.31658 7.90237 6.70711 8.29289L12 13.5858L17.2929 8.29289C17.6834 7.90237 18.3166 7.90237 18.7071 8.29289C19.0976 8.68342 19.0976 9.31658 18.7071 9.70711L12.7071 15.7071C12.3166 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70711C4.90237 9.31658 4.90237 8.68342 5.29289 8.29289Z",fill:"currentColor"})}));xc.displayName="ChevronDownIcon";function Y(t){const{editor:e}=yx(),n=y.useMemo(()=>t||e,[t,e]);return zp({editor:n,selector(o){return o.editor?{editor:o.editor,editorState:o.editor.state,canCommand:o.editor.can}:{editor:null,editorState:void 0,canCommand:void 0}}})||{editor:null}}const Ct=y.forwardRef(({variant:t,size:e="default",appearance:n="default",trimText:r=!1,className:o,children:i,...s},l)=>g.jsx("div",{ref:l,className:`tiptap-badge ${o||""}`,"data-style":t,"data-size":e,"data-appearance":n,"data-text-trim":r?"on":"off",...s,children:i}));Ct.displayName="Badge";function BS({level:t,shortcutKeys:e=h1[t]}){return g.jsx(Ct,{children:yt({shortcutKeys:e})})}const i1=y.forwardRef(({editor:t,level:e,text:n,hideWhenUnavailable:r=!1,onToggled:o,showShortcut:i=!1,onClick:s,children:l,...a},c)=>{const{editor:u}=Y(t),{isVisible:d,canToggle:h,isActive:f,handleToggle:p,label:m,Icon:v,shortcutKeys:b}=HS({editor:u,level:e,hideWhenUnavailable:r,onToggled:o}),C=y.useCallback(x=>{s?.(x),!x.defaultPrevented&&p()},[p,s]);return d?g.jsx(se,{type:"button","data-style":"ghost","data-active-state":f?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":m,"aria-pressed":f,tooltip:m,onClick:C,...a,ref:c,children:l??g.jsxs(g.Fragment,{children:[g.jsx(v,{className:"tiptap-button-icon"}),n&&g.jsx("span",{className:"tiptap-button-text",children:n}),i&&g.jsx(BS,{level:e,shortcutKeys:b})]})}):null});i1.displayName="HeadingButton";const s1=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),g.jsx("path",{d:"M21.0001 10C21.0001 9.63121 20.7971 9.29235 20.472 9.11833C20.1468 8.94431 19.7523 8.96338 19.4454 9.16795L16.4454 11.168C15.9859 11.4743 15.8617 12.0952 16.1681 12.5547C16.4744 13.0142 17.0953 13.1384 17.5548 12.8321L19.0001 11.8685V18C19.0001 18.5523 19.4478 19 20.0001 19C20.5524 19 21.0001 18.5523 21.0001 18V10Z",fill:"currentColor"})]}));s1.displayName="HeadingOneIcon";const l1=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),g.jsx("path",{d:"M22.0001 12C22.0001 10.7611 21.1663 9.79297 20.0663 9.42632C18.9547 9.05578 17.6171 9.28724 16.4001 10.2C15.9582 10.5314 15.8687 11.1582 16.2001 11.6C16.5314 12.0418 17.1582 12.1314 17.6001 11.8C18.383 11.2128 19.0455 11.1942 19.4338 11.3237C19.8339 11.457 20.0001 11.7389 20.0001 12C20.0001 12.4839 19.8554 12.7379 19.6537 12.9481C19.4275 13.1837 19.1378 13.363 18.7055 13.6307C18.6313 13.6767 18.553 13.7252 18.4701 13.777C17.9572 14.0975 17.3128 14.5261 16.8163 15.2087C16.3007 15.9177 16.0001 16.8183 16.0001 18C16.0001 18.5523 16.4478 19 17.0001 19H21.0001C21.5523 19 22.0001 18.5523 22.0001 18C22.0001 17.4477 21.5523 17 21.0001 17H18.131C18.21 16.742 18.3176 16.5448 18.4338 16.385C18.6873 16.0364 19.0429 15.7775 19.5301 15.473C19.5898 15.4357 19.6536 15.3966 19.7205 15.3556C20.139 15.0992 20.6783 14.7687 21.0964 14.3332C21.6447 13.7621 22.0001 13.0161 22.0001 12Z",fill:"currentColor"})]}));l1.displayName="HeadingTwoIcon";const a1=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.4608 11.2169C19.1135 11.0531 18.5876 11.0204 18.0069 11.3619C17.5309 11.642 16.918 11.4831 16.638 11.007C16.358 10.531 16.5169 9.91809 16.9929 9.63807C18.1123 8.97962 19.3364 8.94691 20.314 9.40808C21.2839 9.86558 21.9999 10.818 21.9999 12C21.9999 12.7957 21.6838 13.5587 21.1212 14.1213C20.5586 14.6839 19.7956 15 18.9999 15C18.4476 15 17.9999 14.5523 17.9999 14C17.9999 13.4477 18.4476 13 18.9999 13C19.2651 13 19.5195 12.8947 19.707 12.7071C19.8946 12.5196 19.9999 12.2652 19.9999 12C19.9999 11.6821 19.8159 11.3844 19.4608 11.2169Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.0001 14C18.0001 13.4477 18.4478 13 19.0001 13C19.7957 13 20.5588 13.3161 21.1214 13.8787C21.684 14.4413 22.0001 15.2043 22.0001 16C22.0001 17.2853 21.2767 18.3971 20.1604 18.8994C19.0257 19.41 17.642 19.2315 16.4001 18.3C15.9582 17.9686 15.8687 17.3418 16.2001 16.9C16.5314 16.4582 17.1582 16.3686 17.6001 16.7C18.3581 17.2685 18.9744 17.24 19.3397 17.0756C19.7234 16.9029 20.0001 16.5147 20.0001 16C20.0001 15.7348 19.8947 15.4804 19.7072 15.2929C19.5196 15.1054 19.2653 15 19.0001 15C18.4478 15 18.0001 14.5523 18.0001 14Z",fill:"currentColor"})]}));a1.displayName="HeadingThreeIcon";const c1=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M4 5C4.55228 5 5 5.44772 5 6V11H11V6C11 5.44772 11.4477 5 12 5C12.5523 5 13 5.44772 13 6V18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18V13H5V18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18V6C3 5.44772 3.44772 5 4 5Z",fill:"currentColor"}),g.jsx("path",{d:"M17 9C17.5523 9 18 9.44772 18 10V13H20V10C20 9.44772 20.4477 9 21 9C21.5523 9 22 9.44772 22 10V18C22 18.5523 21.5523 19 21 19C20.4477 19 20 18.5523 20 18V15H17C16.4477 15 16 14.5523 16 14V10C16 9.44772 16.4477 9 17 9Z",fill:"currentColor"})]}));c1.displayName="HeadingFourIcon";const u1=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),g.jsx("path",{d:"M16 10C16 9.44772 16.4477 9 17 9H21C21.5523 9 22 9.44772 22 10C22 10.5523 21.5523 11 21 11H18V12H18.3C20.2754 12 22 13.4739 22 15.5C22 17.5261 20.2754 19 18.3 19C17.6457 19 17.0925 18.8643 16.5528 18.5944C16.0588 18.3474 15.8586 17.7468 16.1055 17.2528C16.3525 16.7588 16.9532 16.5586 17.4472 16.8056C17.7074 16.9357 17.9542 17 18.3 17C19.3246 17 20 16.2739 20 15.5C20 14.7261 19.3246 14 18.3 14H17C16.4477 14 16 13.5523 16 13L16 12.9928V10Z",fill:"currentColor"})]}));u1.displayName="HeadingFiveIcon";const d1=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M5 6C5 5.44772 4.55228 5 4 5C3.44772 5 3 5.44772 3 6V18C3 18.5523 3.44772 19 4 19C4.55228 19 5 18.5523 5 18V13H11V18C11 18.5523 11.4477 19 12 19C12.5523 19 13 18.5523 13 18V6C13 5.44772 12.5523 5 12 5C11.4477 5 11 5.44772 11 6V11H5V6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.7071 9.29289C21.0976 9.68342 21.0976 10.3166 20.7071 10.7071C19.8392 11.575 19.2179 12.2949 18.7889 13.0073C18.8587 13.0025 18.929 13 19 13C20.6569 13 22 14.3431 22 16C22 17.6569 20.6569 19 19 19C17.3431 19 16 17.6569 16 16C16 14.6007 16.2837 13.4368 16.8676 12.3419C17.4384 11.2717 18.2728 10.3129 19.2929 9.29289C19.6834 8.90237 20.3166 8.90237 20.7071 9.29289ZM19 17C18.4477 17 18 16.5523 18 16C18 15.4477 18.4477 15 19 15C19.5523 15 20 15.4477 20 16C20 16.5523 19.5523 17 19 17Z",fill:"currentColor"})]}));d1.displayName="HeadingSixIcon";const f1={1:s1,2:l1,3:a1,4:c1,5:u1,6:d1},h1={1:"ctrl+alt+1",2:"ctrl+alt+2",3:"ctrl+alt+3",4:"ctrl+alt+4",5:"ctrl+alt+5",6:"ctrl+alt+6"};function Xr(t,e,n=!0){if(!t||!t.isEditable||!Bt("heading",t)||bt(t,["image"]))return!1;if(!n)return e?t.can().setNode("heading",{level:e}):t.can().setNode("heading");try{const o=t.view.state,i=o.selection;if(i.empty||i instanceof z){const s=hn({editor:t,node:o.selection.$anchor.node(1)})?.pos;if(!vt(s))return!1}return!0}catch{return!1}}function wc(t,e){return!t||!t.isEditable?!1:Array.isArray(e)?e.some(n=>t.isActive("heading",{level:n})):e?t.isActive("heading",{level:e}):t.isActive("heading")}function _S(t,e){if(!t||!t.isEditable)return!1;const n=Array.isArray(e)?e:[e],r=n.find(o=>Xr(t,o));if(!r)return!1;try{const o=t.view;let i=o.state,s=i.tr;if(i.selection.empty||i.selection instanceof z){const d=hn({editor:t,node:i.selection.$anchor.node(1)})?.pos;if(!vt(d))return!1;s=s.setSelection(B.create(i.doc,d)),o.dispatch(s),i=o.state}const l=i.selection;let a=t.chain().focus();if(l instanceof B){const d=l.node.firstChild?.firstChild,h=l.node.lastChild?.lastChild,f=d?l.from+d.nodeSize:l.from+1,p=h?l.to-h.nodeSize:l.to-1;a=a.setTextSelection({from:f,to:p}).clearNodes()}return(n.some(d=>t.isActive("heading",{level:d}))?a.setNode("paragraph"):a.setNode("heading",{level:r})).run(),t.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function p1(t){const{editor:e,level:n,hideWhenUnavailable:r}=t;return!e||!e.isEditable||!Bt("heading",e)?!1:r&&!e.isActive("code")?Array.isArray(n)?n.some(o=>Xr(e,o)):Xr(e,n):!0}function HS(t){const{editor:e,level:n,hideWhenUnavailable:r=!1,onToggled:o}=t,{editor:i}=Y(e),[s,l]=y.useState(!0),a=Xr(i,n),c=wc(i,n);y.useEffect(()=>{if(!i)return;const d=()=>{l(p1({editor:i,level:n,hideWhenUnavailable:r}))};return d(),i.on("selectionUpdate",d),()=>{i.off("selectionUpdate",d)}},[i,n,r]);const u=y.useCallback(()=>{if(!i)return!1;const d=_S(i,n);return d&&o?.(),d},[i,n,o]);return{isVisible:s,isActive:c,handleToggle:u,canToggle:a,label:`Heading ${n}`,shortcutKeys:h1[n],Icon:f1[n]}}function J(t,e,{checkForDefaultPrevented:n=!0}={}){return function(o){if(t?.(o),n===!1||!o.defaultPrevented)return e?.(o)}}function yf(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function fs(...t){return e=>{let n=!1;const r=t.map(o=>{const i=yf(o,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():yf(t[o],null)}}}}function Oe(...t){return y.useCallback(fs(...t),t)}function pr(t,e=[]){let n=[];function r(i,s){const l=y.createContext(s),a=n.length;n=[...n,s];const c=d=>{const{scope:h,children:f,...p}=d,m=h?.[t]?.[a]||l,v=y.useMemo(()=>p,Object.values(p));return g.jsx(m.Provider,{value:v,children:f})};c.displayName=i+"Provider";function u(d,h){const f=h?.[t]?.[a]||l,p=y.useContext(f);if(p)return p;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[c,u]}const o=()=>{const i=n.map(s=>y.createContext(s));return function(l){const a=l?.[t]||i;return y.useMemo(()=>({[`__scope${t}`]:{...l,[t]:a}}),[l,a])}};return o.scopeName=t,[r,FS(o,...e)]}function FS(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((l,{useScope:a,scopeName:c})=>{const d=a(i)[`__scope${c}`];return{...l,...d}},{});return y.useMemo(()=>({[`__scope${e.scopeName}`]:s}),[s])}};return n.scopeName=e.scopeName,n}var un=globalThis?.document?y.useLayoutEffect:()=>{},$S=y[" useInsertionEffect ".trim().toString()]||un;function Sc({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[o,i,s]=VS({defaultProp:e,onChange:n}),l=t!==void 0,a=l?t:o;{const u=y.useRef(t!==void 0);y.useEffect(()=>{const d=u.current;d!==l&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=l},[l,r])}const c=y.useCallback(u=>{if(l){const d=zS(u)?u(t):u;d!==t&&s.current?.(d)}else i(u)},[l,t,i,s]);return[a,c]}function VS({defaultProp:t,onChange:e}){const[n,r]=y.useState(t),o=y.useRef(n),i=y.useRef(e);return $S(()=>{i.current=e},[e]),y.useEffect(()=>{o.current!==n&&(i.current?.(n),o.current=n)},[n,o]),[n,r,i]}function zS(t){return typeof t=="function"}function Qr(t){const e=US(t),n=y.forwardRef((r,o)=>{const{children:i,...s}=r,l=y.Children.toArray(i),a=l.find(KS);if(a){const c=a.props.children,u=l.map(d=>d===a?y.Children.count(c)>1?y.Children.only(null):y.isValidElement(c)?c.props.children:null:d);return g.jsx(e,{...s,ref:o,children:y.isValidElement(c)?y.cloneElement(c,void 0,u):null})}return g.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function US(t){const e=y.forwardRef((n,r)=>{const{children:o,...i}=n;if(y.isValidElement(o)){const s=GS(o),l=qS(i,o.props);return o.type!==y.Fragment&&(l.ref=r?fs(r,s):s),y.cloneElement(o,l)}return y.Children.count(o)>1?y.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var WS=Symbol("radix.slottable");function KS(t){return y.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===WS}function qS(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const a=i(...l);return o(...l),a}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function GS(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var JS=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Te=JS.reduce((t,e)=>{const n=Qr(`Primitive.${e}`),r=y.forwardRef((o,i)=>{const{asChild:s,...l}=o,a=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),g.jsx(a,{...l,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function m1(t,e){t&&va.flushSync(()=>t.dispatchEvent(e))}function g1(t){const e=t+"CollectionProvider",[n,r]=pr(e),[o,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),s=m=>{const{scope:v,children:b}=m,C=L.useRef(null),x=L.useRef(new Map).current;return g.jsx(o,{scope:v,itemMap:x,collectionRef:C,children:b})};s.displayName=e;const l=t+"CollectionSlot",a=Qr(l),c=L.forwardRef((m,v)=>{const{scope:b,children:C}=m,x=i(l,b),w=Oe(v,x.collectionRef);return g.jsx(a,{ref:w,children:C})});c.displayName=l;const u=t+"CollectionItemSlot",d="data-radix-collection-item",h=Qr(u),f=L.forwardRef((m,v)=>{const{scope:b,children:C,...x}=m,w=L.useRef(null),E=Oe(v,w),S=i(u,b);return L.useEffect(()=>(S.itemMap.set(w,{ref:w,...x}),()=>void S.itemMap.delete(w))),g.jsx(h,{[d]:"",ref:E,children:C})});f.displayName=u;function p(m){const v=i(t+"CollectionConsumer",m);return L.useCallback(()=>{const C=v.collectionRef.current;if(!C)return[];const x=Array.from(C.querySelectorAll(`[${d}]`));return Array.from(v.itemMap.values()).sort((S,k)=>x.indexOf(S.ref.current)-x.indexOf(k.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:s,Slot:c,ItemSlot:f},p,r]}var ZS=y.createContext(void 0);function y1(t){const e=y.useContext(ZS);return t||e||"ltr"}function Pt(t){const e=y.useRef(t);return y.useEffect(()=>{e.current=t}),y.useMemo(()=>(...n)=>e.current?.(...n),[])}function YS(t,e=globalThis?.document){const n=Pt(t);y.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var XS="DismissableLayer",da="dismissableLayer.update",QS="dismissableLayer.pointerDownOutside",e3="dismissableLayer.focusOutside",vf,v1=y.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),kc=y.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:l,...a}=t,c=y.useContext(v1),[u,d]=y.useState(null),h=u?.ownerDocument??globalThis?.document,[,f]=y.useState({}),p=Oe(e,k=>d(k)),m=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),b=m.indexOf(v),C=u?m.indexOf(u):-1,x=c.layersWithOutsidePointerEventsDisabled.size>0,w=C>=b,E=r3(k=>{const M=k.target,I=[...c.branches].some(P=>P.contains(M));!w||I||(o?.(k),s?.(k),k.defaultPrevented||l?.())},h),S=o3(k=>{const M=k.target;[...c.branches].some(P=>P.contains(M))||(i?.(k),s?.(k),k.defaultPrevented||l?.())},h);return YS(k=>{C===c.layers.size-1&&(r?.(k),!k.defaultPrevented&&l&&(k.preventDefault(),l()))},h),y.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(vf=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),bf(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=vf)}},[u,h,n,c]),y.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),bf())},[u,c]),y.useEffect(()=>{const k=()=>f({});return document.addEventListener(da,k),()=>document.removeEventListener(da,k)},[]),g.jsx(Te.div,{...a,ref:p,style:{pointerEvents:x?w?"auto":"none":void 0,...t.style},onFocusCapture:J(t.onFocusCapture,S.onFocusCapture),onBlurCapture:J(t.onBlurCapture,S.onBlurCapture),onPointerDownCapture:J(t.onPointerDownCapture,E.onPointerDownCapture)})});kc.displayName=XS;var t3="DismissableLayerBranch",n3=y.forwardRef((t,e)=>{const n=y.useContext(v1),r=y.useRef(null),o=Oe(e,r);return y.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),g.jsx(Te.div,{...t,ref:o})});n3.displayName=t3;function r3(t,e=globalThis?.document){const n=Pt(t),r=y.useRef(!1),o=y.useRef(()=>{});return y.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let a=function(){b1(QS,n,c,{discrete:!0})};const c={originalEvent:l};l.pointerType==="touch"?(e.removeEventListener("click",o.current),o.current=a,e.addEventListener("click",o.current,{once:!0})):a()}else e.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),e.removeEventListener("pointerdown",i),e.removeEventListener("click",o.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function o3(t,e=globalThis?.document){const n=Pt(t),r=y.useRef(!1);return y.useEffect(()=>{const o=i=>{i.target&&!r.current&&b1(e3,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",o),()=>e.removeEventListener("focusin",o)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function bf(){const t=new CustomEvent(da);document.dispatchEvent(t)}function b1(t,e,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&o.addEventListener(t,e,{once:!0}),r?m1(o,i):o.dispatchEvent(i)}var dl=0;function C1(){y.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??Cf()),document.body.insertAdjacentElement("beforeend",t[1]??Cf()),dl++,()=>{dl===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),dl--}},[])}function Cf(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var fl="focusScope.autoFocusOnMount",hl="focusScope.autoFocusOnUnmount",xf={bubbles:!1,cancelable:!0},i3="FocusScope",Ec=y.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=t,[l,a]=y.useState(null),c=Pt(o),u=Pt(i),d=y.useRef(null),h=Oe(e,m=>a(m)),f=y.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;y.useEffect(()=>{if(r){let m=function(x){if(f.paused||!l)return;const w=x.target;l.contains(w)?d.current=w:$t(d.current,{select:!0})},v=function(x){if(f.paused||!l)return;const w=x.relatedTarget;w!==null&&(l.contains(w)||$t(d.current,{select:!0}))},b=function(x){if(document.activeElement===document.body)for(const E of x)E.removedNodes.length>0&&$t(l)};document.addEventListener("focusin",m),document.addEventListener("focusout",v);const C=new MutationObserver(b);return l&&C.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",v),C.disconnect()}}},[r,l,f.paused]),y.useEffect(()=>{if(l){Sf.add(f);const m=document.activeElement;if(!l.contains(m)){const b=new CustomEvent(fl,xf);l.addEventListener(fl,c),l.dispatchEvent(b),b.defaultPrevented||(s3(d3(x1(l)),{select:!0}),document.activeElement===m&&$t(l))}return()=>{l.removeEventListener(fl,c),setTimeout(()=>{const b=new CustomEvent(hl,xf);l.addEventListener(hl,u),l.dispatchEvent(b),b.defaultPrevented||$t(m??document.body,{select:!0}),l.removeEventListener(hl,u),Sf.remove(f)},0)}}},[l,c,u,f]);const p=y.useCallback(m=>{if(!n&&!r||f.paused)return;const v=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,b=document.activeElement;if(v&&b){const C=m.currentTarget,[x,w]=l3(C);x&&w?!m.shiftKey&&b===w?(m.preventDefault(),n&&$t(x,{select:!0})):m.shiftKey&&b===x&&(m.preventDefault(),n&&$t(w,{select:!0})):b===C&&m.preventDefault()}},[n,r,f.paused]);return g.jsx(Te.div,{tabIndex:-1,...s,ref:h,onKeyDown:p})});Ec.displayName=i3;function s3(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if($t(r,{select:e}),document.activeElement!==n)return}function l3(t){const e=x1(t),n=wf(e,t),r=wf(e.reverse(),t);return[n,r]}function x1(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function wf(t,e){for(const n of t)if(!a3(n,{upTo:e}))return n}function a3(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function c3(t){return t instanceof HTMLInputElement&&"select"in t}function $t(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&c3(t)&&e&&t.select()}}var Sf=u3();function u3(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=kf(t,e),t.unshift(e)},remove(e){t=kf(t,e),t[0]?.resume()}}}function kf(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function d3(t){return t.filter(e=>e.tagName!=="A")}var f3=y[" useId ".trim().toString()]||(()=>{}),h3=0;function Fi(t){const[e,n]=y.useState(f3());return un(()=>{n(r=>r??String(h3++))},[t]),t||(e?`radix-${e}`:"")}var p3="Arrow",w1=y.forwardRef((t,e)=>{const{children:n,width:r=10,height:o=5,...i}=t;return g.jsx(Te.svg,{...i,ref:e,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:g.jsx("polygon",{points:"0,0 30,0 15,10"})})});w1.displayName=p3;var m3=w1;function g3(t){const[e,n]=y.useState(void 0);return un(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,l;if("borderBoxSize"in i){const a=i.borderBoxSize,c=Array.isArray(a)?a[0]:a;s=c.inlineSize,l=c.blockSize}else s=t.offsetWidth,l=t.offsetHeight;n({width:s,height:l})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Mc="Popper",[S1,hs]=pr(Mc),[y3,k1]=S1(Mc),E1=t=>{const{__scopePopper:e,children:n}=t,[r,o]=y.useState(null);return g.jsx(y3,{scope:e,anchor:r,onAnchorChange:o,children:n})};E1.displayName=Mc;var M1="PopperAnchor",T1=y.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...o}=t,i=k1(M1,n),s=y.useRef(null),l=Oe(e,s),a=y.useRef(null);return y.useEffect(()=>{const c=a.current;a.current=r?.current||s.current,c!==a.current&&i.onAnchorChange(a.current)}),r?null:g.jsx(Te.div,{...o,ref:l})});T1.displayName=M1;var Tc="PopperContent",[v3,b3]=S1(Tc),A1=y.forwardRef((t,e)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:l=0,avoidCollisions:a=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:h=!1,updatePositionStrategy:f="optimized",onPlaced:p,...m}=t,v=k1(Tc,n),[b,C]=y.useState(null),x=Oe(e,Q=>C(Q)),[w,E]=y.useState(null),S=g3(w),k=S?.width??0,M=S?.height??0,I=r+(i!=="center"?"-"+i:""),P=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},_=Array.isArray(c)?c:[c],U=_.length>0,F={padding:P,boundary:_.filter(x3),altBoundary:U},{refs:O,floatingStyles:H,placement:V,isPositioned:D,middlewareData:T}=zm({strategy:"fixed",placement:I,whileElementsMounted:(...Q)=>$m(...Q,{animationFrame:f==="always"}),elements:{reference:v.anchor},middleware:[Um({mainAxis:o+M,alignmentAxis:s}),a&&Wm({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?D5():void 0,...F}),a&&Km({...F}),P5({...F,apply:({elements:Q,rects:re,availableWidth:Ke,availableHeight:xt})=>{const{width:Hn,height:Ss}=re.reference,Fn=Q.floating.style;Fn.setProperty("--radix-popper-available-width",`${Ke}px`),Fn.setProperty("--radix-popper-available-height",`${xt}px`),Fn.setProperty("--radix-popper-anchor-width",`${Hn}px`),Fn.setProperty("--radix-popper-anchor-height",`${Ss}px`)}}),w&&B5({element:w,padding:l}),w3({arrowWidth:k,arrowHeight:M}),h&&j5({strategy:"referenceHidden",...F})]}),[R,W]=N1(V),ne=Pt(p);un(()=>{D&&ne?.()},[D,ne]);const K=T.arrow?.x,X=T.arrow?.y,We=T.arrow?.centerOffset!==0,[ce,ye]=y.useState();return un(()=>{b&&ye(window.getComputedStyle(b).zIndex)},[b]),g.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:D?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ce,"--radix-popper-transform-origin":[T.transformOrigin?.x,T.transformOrigin?.y].join(" "),...T.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:g.jsx(v3,{scope:n,placedSide:R,onArrowChange:E,arrowX:K,arrowY:X,shouldHideArrow:We,children:g.jsx(Te.div,{"data-side":R,"data-align":W,...m,ref:x,style:{...m.style,animation:D?void 0:"none"}})})})});A1.displayName=Tc;var R1="PopperArrow",C3={top:"bottom",right:"left",bottom:"top",left:"right"},O1=y.forwardRef(function(e,n){const{__scopePopper:r,...o}=e,i=b3(R1,r),s=C3[i.placedSide];return g.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:g.jsx(m3,{...o,ref:n,style:{...o.style,display:"block"}})})});O1.displayName=R1;function x3(t){return t!==null}var w3=t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:r,middlewareData:o}=e,s=o.arrow?.centerOffset!==0,l=s?0:t.arrowWidth,a=s?0:t.arrowHeight,[c,u]=N1(n),d={start:"0%",center:"50%",end:"100%"}[u],h=(o.arrow?.x??0)+l/2,f=(o.arrow?.y??0)+a/2;let p="",m="";return c==="bottom"?(p=s?d:`${h}px`,m=`${-a}px`):c==="top"?(p=s?d:`${h}px`,m=`${r.floating.height+a}px`):c==="right"?(p=`${-a}px`,m=s?d:`${f}px`):c==="left"&&(p=`${r.floating.width+a}px`,m=s?d:`${f}px`),{data:{x:p,y:m}}}});function N1(t){const[e,n="center"]=t.split("-");return[e,n]}var I1=E1,Ac=T1,L1=A1,D1=O1,S3="Portal",Rc=y.forwardRef((t,e)=>{const{container:n,...r}=t,[o,i]=y.useState(!1);un(()=>i(!0),[]);const s=n||o&&globalThis?.document?.body;return s?Ui.createPortal(g.jsx(Te.div,{...r,ref:e}),s):null});Rc.displayName=S3;function k3(t,e){return y.useReducer((n,r)=>e[n][r]??n,t)}var Pn=t=>{const{present:e,children:n}=t,r=E3(e),o=typeof n=="function"?n({present:r.isPresent}):y.Children.only(n),i=Oe(r.ref,M3(o));return typeof n=="function"||r.isPresent?y.cloneElement(o,{ref:i}):null};Pn.displayName="Presence";function E3(t){const[e,n]=y.useState(),r=y.useRef(null),o=y.useRef(t),i=y.useRef("none"),s=t?"mounted":"unmounted",[l,a]=k3(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return y.useEffect(()=>{const c=Io(r.current);i.current=l==="mounted"?c:"none"},[l]),un(()=>{const c=r.current,u=o.current;if(u!==t){const h=i.current,f=Io(c);t?a("MOUNT"):f==="none"||c?.display==="none"?a("UNMOUNT"):a(u&&h!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,a]),un(()=>{if(e){let c;const u=e.ownerDocument.defaultView??window,d=f=>{const m=Io(r.current).includes(CSS.escape(f.animationName));if(f.target===e&&m&&(a("ANIMATION_END"),!o.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",c=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},h=f=>{f.target===e&&(i.current=Io(r.current))};return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",d),e.addEventListener("animationend",d),()=>{u.clearTimeout(c),e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",d),e.removeEventListener("animationend",d)}}else a("ANIMATION_END")},[e,a]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:y.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Io(t){return t?.animationName||"none"}function M3(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var pl="rovingFocusGroup.onEntryFocus",T3={bubbles:!1,cancelable:!0},uo="RovingFocusGroup",[fa,P1,A3]=g1(uo),[R3,j1]=pr(uo,[A3]),[O3,N3]=R3(uo),B1=y.forwardRef((t,e)=>g.jsx(fa.Provider,{scope:t.__scopeRovingFocusGroup,children:g.jsx(fa.Slot,{scope:t.__scopeRovingFocusGroup,children:g.jsx(I3,{...t,ref:e})})}));B1.displayName=uo;var I3=y.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:a,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=t,h=y.useRef(null),f=Oe(e,h),p=y1(i),[m,v]=Sc({prop:s,defaultProp:l??null,onChange:a,caller:uo}),[b,C]=y.useState(!1),x=Pt(c),w=P1(n),E=y.useRef(!1),[S,k]=y.useState(0);return y.useEffect(()=>{const M=h.current;if(M)return M.addEventListener(pl,x),()=>M.removeEventListener(pl,x)},[x]),g.jsx(O3,{scope:n,orientation:r,dir:p,loop:o,currentTabStopId:m,onItemFocus:y.useCallback(M=>v(M),[v]),onItemShiftTab:y.useCallback(()=>C(!0),[]),onFocusableItemAdd:y.useCallback(()=>k(M=>M+1),[]),onFocusableItemRemove:y.useCallback(()=>k(M=>M-1),[]),children:g.jsx(Te.div,{tabIndex:b||S===0?-1:0,"data-orientation":r,...d,ref:f,style:{outline:"none",...t.style},onMouseDown:J(t.onMouseDown,()=>{E.current=!0}),onFocus:J(t.onFocus,M=>{const I=!E.current;if(M.target===M.currentTarget&&I&&!b){const P=new CustomEvent(pl,T3);if(M.currentTarget.dispatchEvent(P),!P.defaultPrevented){const _=w().filter(V=>V.focusable),U=_.find(V=>V.active),F=_.find(V=>V.id===m),H=[U,F,..._].filter(Boolean).map(V=>V.ref.current);F1(H,u)}}E.current=!1}),onBlur:J(t.onBlur,()=>C(!1))})})}),_1="RovingFocusGroupItem",H1=y.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:s,...l}=t,a=Fi(),c=i||a,u=N3(_1,n),d=u.currentTabStopId===c,h=P1(n),{onFocusableItemAdd:f,onFocusableItemRemove:p,currentTabStopId:m}=u;return y.useEffect(()=>{if(r)return f(),()=>p()},[r,f,p]),g.jsx(fa.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:g.jsx(Te.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...l,ref:e,onMouseDown:J(t.onMouseDown,v=>{r?u.onItemFocus(c):v.preventDefault()}),onFocus:J(t.onFocus,()=>u.onItemFocus(c)),onKeyDown:J(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){u.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=P3(v,u.orientation,u.dir);if(b!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let x=h().filter(w=>w.focusable).map(w=>w.ref.current);if(b==="last")x.reverse();else if(b==="prev"||b==="next"){b==="prev"&&x.reverse();const w=x.indexOf(v.currentTarget);x=u.loop?j3(x,w+1):x.slice(w+1)}setTimeout(()=>F1(x))}}),children:typeof s=="function"?s({isCurrentTabStop:d,hasTabStop:m!=null}):s})})});H1.displayName=_1;var L3={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function D3(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function P3(t,e,n){const r=D3(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return L3[r]}function F1(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function j3(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var B3=B1,_3=H1,H3=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},zn=new WeakMap,Lo=new WeakMap,Do={},ml=0,$1=function(t){return t&&(t.host||$1(t.parentNode))},F3=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=$1(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},$3=function(t,e,n,r){var o=F3(e,Array.isArray(t)?t:[t]);Do[n]||(Do[n]=new WeakMap);var i=Do[n],s=[],l=new Set,a=new Set(o),c=function(d){!d||l.has(d)||(l.add(d),c(d.parentNode))};o.forEach(c);var u=function(d){!d||a.has(d)||Array.prototype.forEach.call(d.children,function(h){if(l.has(h))u(h);else try{var f=h.getAttribute(r),p=f!==null&&f!=="false",m=(zn.get(h)||0)+1,v=(i.get(h)||0)+1;zn.set(h,m),i.set(h,v),s.push(h),m===1&&p&&Lo.set(h,!0),v===1&&h.setAttribute(n,"true"),p||h.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",h,b)}})};return u(e),l.clear(),ml++,function(){s.forEach(function(d){var h=zn.get(d)-1,f=i.get(d)-1;zn.set(d,h),i.set(d,f),h||(Lo.has(d)||d.removeAttribute(r),Lo.delete(d)),f||d.removeAttribute(n)}),ml--,ml||(zn=new WeakMap,zn=new WeakMap,Lo=new WeakMap,Do={})}},V1=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),o=H3(t);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),$3(r,o,n,"aria-hidden")):function(){return null}},ct=function(){return ct=Object.assign||function(e){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},ct.apply(this,arguments)};function z1(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]]);return n}function V3(t,e,n){if(n||arguments.length===2)for(var r=0,o=e.length,i;r<o;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}var Wo="right-scroll-bar-position",Ko="width-before-scroll-bar",z3="with-scroll-bars-hidden",U3="--removed-body-scroll-bar-size";function gl(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function W3(t,e){var n=L.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=e,n.facade}var K3=typeof window<"u"?y.useLayoutEffect:y.useEffect,Ef=new WeakMap;function q3(t,e){var n=W3(null,function(r){return t.forEach(function(o){return gl(o,r)})});return K3(function(){var r=Ef.get(n);if(r){var o=new Set(r),i=new Set(t),s=n.current;o.forEach(function(l){i.has(l)||gl(l,null)}),i.forEach(function(l){o.has(l)||gl(l,s)})}Ef.set(n,t)},[t]),n}function G3(t){return t}function J3(t,e){e===void 0&&(e=G3);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(i){var s=e(i,r);return n.push(s),function(){n=n.filter(function(l){return l!==s})}},assignSyncMedium:function(i){for(r=!0;n.length;){var s=n;n=[],s.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){r=!0;var s=[];if(n.length){var l=n;n=[],l.forEach(i),s=n}var a=function(){var u=s;s=[],u.forEach(i)},c=function(){return Promise.resolve().then(a)};c(),n={push:function(u){s.push(u),c()},filter:function(u){return s=s.filter(u),n}}}};return o}function Z3(t){t===void 0&&(t={});var e=J3(null);return e.options=ct({async:!0,ssr:!1},t),e}var U1=function(t){var e=t.sideCar,n=z1(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return y.createElement(r,ct({},n))};U1.isSideCarExport=!0;function Y3(t,e){return t.useMedium(e),U1}var W1=Z3(),yl=function(){},ps=y.forwardRef(function(t,e){var n=y.useRef(null),r=y.useState({onScrollCapture:yl,onWheelCapture:yl,onTouchMoveCapture:yl}),o=r[0],i=r[1],s=t.forwardProps,l=t.children,a=t.className,c=t.removeScrollBar,u=t.enabled,d=t.shards,h=t.sideCar,f=t.noRelative,p=t.noIsolation,m=t.inert,v=t.allowPinchZoom,b=t.as,C=b===void 0?"div":b,x=t.gapMode,w=z1(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),E=h,S=q3([n,e]),k=ct(ct({},w),o);return y.createElement(y.Fragment,null,u&&y.createElement(E,{sideCar:W1,removeScrollBar:c,shards:d,noRelative:f,noIsolation:p,inert:m,setCallbacks:i,allowPinchZoom:!!v,lockRef:n,gapMode:x}),s?y.cloneElement(y.Children.only(l),ct(ct({},k),{ref:S})):y.createElement(C,ct({},k,{className:a,ref:S}),l))});ps.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ps.classNames={fullWidth:Ko,zeroRight:Wo};var X3=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Q3(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=X3();return e&&t.setAttribute("nonce",e),t}function ek(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function tk(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var nk=function(){var t=0,e=null;return{add:function(n){t==0&&(e=Q3())&&(ek(e,n),tk(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},rk=function(){var t=nk();return function(e,n){y.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},K1=function(){var t=rk(),e=function(n){var r=n.styles,o=n.dynamic;return t(r,o),null};return e},ok={left:0,top:0,right:0,gap:0},vl=function(t){return parseInt(t||"",10)||0},ik=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],o=e[t==="padding"?"paddingRight":"marginRight"];return[vl(n),vl(r),vl(o)]},sk=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return ok;var e=ik(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},lk=K1(),nr="data-scroll-locked",ak=function(t,e,n,r){var o=t.left,i=t.top,s=t.right,l=t.gap;return n===void 0&&(n="margin"),`
177
+ .`.concat(z3,` {
178
178
  overflow: hidden `).concat(r,`;
179
179
  padding-right: `).concat(l,"px ").concat(r,`;
180
180
  }
181
- body[`).concat(tr,`] {
181
+ body[`).concat(nr,`] {
182
182
  overflow: hidden `).concat(r,`;
183
183
  overscroll-behavior: contain;
184
184
  `).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
@@ -191,27 +191,27 @@ ${f.slice(c+2)}`,d+=1;else break}e.push({indent:c,number:parseInt(l,10),content:
191
191
  `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
192
192
  }
193
193
 
194
- .`).concat(Uo,` {
194
+ .`).concat(Wo,` {
195
195
  right: `).concat(l,"px ").concat(r,`;
196
196
  }
197
197
 
198
- .`).concat(Wo,` {
198
+ .`).concat(Ko,` {
199
199
  margin-right: `).concat(l,"px ").concat(r,`;
200
200
  }
201
201
 
202
- .`).concat(Uo," .").concat(Uo,` {
202
+ .`).concat(Wo," .").concat(Wo,` {
203
203
  right: 0 `).concat(r,`;
204
204
  }
205
205
 
206
- .`).concat(Wo," .").concat(Wo,` {
206
+ .`).concat(Ko," .").concat(Ko,` {
207
207
  margin-right: 0 `).concat(r,`;
208
208
  }
209
209
 
210
- body[`).concat(tr,`] {
211
- `).concat(OS,": ").concat(l,`px;
210
+ body[`).concat(nr,`] {
211
+ `).concat(U3,": ").concat(l,`px;
212
212
  }
213
- `)},vf=function(){var t=parseInt(document.body.getAttribute(tr)||"0",10);return isFinite(t)?t:0},JS=function(){y.useEffect(function(){return document.body.setAttribute(tr,(vf()+1).toString()),function(){var t=vf()-1;t<=0?document.body.removeAttribute(tr):document.body.setAttribute(tr,t.toString())}},[])},ZS=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,o=r===void 0?"margin":r;JS();var i=y.useMemo(function(){return KS(o)},[o]);return y.createElement(qS,{styles:GS(i,!e,o,n?"":"!important")})},ha=!1;if(typeof window<"u")try{var Do=Object.defineProperty({},"passive",{get:function(){return ha=!0,!0}});window.addEventListener("test",Do,Do),window.removeEventListener("test",Do,Do)}catch{ha=!1}var zn=ha?{passive:!1}:!1,YS=function(t){return t.tagName==="TEXTAREA"},_1=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!YS(t)&&n[e]==="visible")},XS=function(t){return _1(t,"overflowY")},QS=function(t){return _1(t,"overflowX")},bf=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=H1(t,r);if(o){var i=F1(t,r),s=i[1],l=i[2];if(s>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},ek=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},tk=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},H1=function(t,e){return t==="v"?XS(e):QS(e)},F1=function(t,e){return t==="v"?ek(e):tk(e)},nk=function(t,e){return t==="h"&&e==="rtl"?-1:1},rk=function(t,e,n,r,o){var i=nk(t,window.getComputedStyle(e).direction),s=i*r,l=n.target,a=e.contains(l),c=!1,u=s>0,d=0,h=0;do{if(!l)break;var f=F1(t,l),p=f[0],m=f[1],v=f[2],b=m-v-i*p;(p||b)&&H1(t,l)&&(d+=b,h+=p);var C=l.parentNode;l=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!a&&l!==document.body||a&&(e.contains(l)||e===l));return(u&&Math.abs(d)<1||!u&&Math.abs(h)<1)&&(c=!0),c},Po=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Cf=function(t){return[t.deltaX,t.deltaY]},xf=function(t){return t&&"current"in t?t.current:t},ok=function(t,e){return t[0]===e[0]&&t[1]===e[1]},ik=function(t){return`
213
+ `)},Mf=function(){var t=parseInt(document.body.getAttribute(nr)||"0",10);return isFinite(t)?t:0},ck=function(){y.useEffect(function(){return document.body.setAttribute(nr,(Mf()+1).toString()),function(){var t=Mf()-1;t<=0?document.body.removeAttribute(nr):document.body.setAttribute(nr,t.toString())}},[])},uk=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,o=r===void 0?"margin":r;ck();var i=y.useMemo(function(){return sk(o)},[o]);return y.createElement(lk,{styles:ak(i,!e,o,n?"":"!important")})},ha=!1;if(typeof window<"u")try{var Po=Object.defineProperty({},"passive",{get:function(){return ha=!0,!0}});window.addEventListener("test",Po,Po),window.removeEventListener("test",Po,Po)}catch{ha=!1}var Un=ha?{passive:!1}:!1,dk=function(t){return t.tagName==="TEXTAREA"},q1=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!dk(t)&&n[e]==="visible")},fk=function(t){return q1(t,"overflowY")},hk=function(t){return q1(t,"overflowX")},Tf=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=G1(t,r);if(o){var i=J1(t,r),s=i[1],l=i[2];if(s>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},pk=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},mk=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},G1=function(t,e){return t==="v"?fk(e):hk(e)},J1=function(t,e){return t==="v"?pk(e):mk(e)},gk=function(t,e){return t==="h"&&e==="rtl"?-1:1},yk=function(t,e,n,r,o){var i=gk(t,window.getComputedStyle(e).direction),s=i*r,l=n.target,a=e.contains(l),c=!1,u=s>0,d=0,h=0;do{if(!l)break;var f=J1(t,l),p=f[0],m=f[1],v=f[2],b=m-v-i*p;(p||b)&&G1(t,l)&&(d+=b,h+=p);var C=l.parentNode;l=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!a&&l!==document.body||a&&(e.contains(l)||e===l));return(u&&Math.abs(d)<1||!u&&Math.abs(h)<1)&&(c=!0),c},jo=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Af=function(t){return[t.deltaX,t.deltaY]},Rf=function(t){return t&&"current"in t?t.current:t},vk=function(t,e){return t[0]===e[0]&&t[1]===e[1]},bk=function(t){return`
214
214
  .block-interactivity-`.concat(t,` {pointer-events: none;}
215
215
  .allow-interactivity-`).concat(t,` {pointer-events: all;}
216
- `)},sk=0,Un=[];function lk(t){var e=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),o=y.useState(sk++)[0],i=y.useState(B1)[0],s=y.useRef(t);y.useEffect(function(){s.current=t},[t]),y.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var m=AS([t.lockRef.current],(t.shards||[]).map(xf),!0).filter(Boolean);return m.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var l=y.useCallback(function(m,v){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!s.current.allowPinchZoom;var b=Po(m),C=n.current,x="deltaX"in m?m.deltaX:C[0]-b[0],w="deltaY"in m?m.deltaY:C[1]-b[1],E,k=m.target,S=Math.abs(x)>Math.abs(w)?"h":"v";if("touches"in m&&S==="h"&&k.type==="range")return!1;var M=bf(S,k);if(!M)return!0;if(M?E=S:(E=S==="v"?"h":"v",M=bf(S,k)),!M)return!1;if(!r.current&&"changedTouches"in m&&(x||w)&&(r.current=E),!E)return!0;var I=r.current||E;return rk(I,v,m,I==="h"?x:w)},[]),a=y.useCallback(function(m){var v=m;if(!(!Un.length||Un[Un.length-1]!==i)){var b="deltaY"in v?Cf(v):Po(v),C=e.current.filter(function(E){return E.name===v.type&&(E.target===v.target||v.target===E.shadowParent)&&ok(E.delta,b)})[0];if(C&&C.should){v.cancelable&&v.preventDefault();return}if(!C){var x=(s.current.shards||[]).map(xf).filter(Boolean).filter(function(E){return E.contains(v.target)}),w=x.length>0?l(v,x[0]):!s.current.noIsolation;w&&v.cancelable&&v.preventDefault()}}},[]),c=y.useCallback(function(m,v,b,C){var x={name:m,delta:v,target:b,should:C,shadowParent:ak(b)};e.current.push(x),setTimeout(function(){e.current=e.current.filter(function(w){return w!==x})},1)},[]),u=y.useCallback(function(m){n.current=Po(m),r.current=void 0},[]),d=y.useCallback(function(m){c(m.type,Cf(m),m.target,l(m,t.lockRef.current))},[]),h=y.useCallback(function(m){c(m.type,Po(m),m.target,l(m,t.lockRef.current))},[]);y.useEffect(function(){return Un.push(i),t.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:h}),document.addEventListener("wheel",a,zn),document.addEventListener("touchmove",a,zn),document.addEventListener("touchstart",u,zn),function(){Un=Un.filter(function(m){return m!==i}),document.removeEventListener("wheel",a,zn),document.removeEventListener("touchmove",a,zn),document.removeEventListener("touchstart",u,zn)}},[]);var f=t.removeScrollBar,p=t.inert;return y.createElement(y.Fragment,null,p?y.createElement(i,{styles:ik(o)}):null,f?y.createElement(ZS,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function ak(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const ck=BS(j1,lk);var Tc=y.forwardRef(function(t,e){return y.createElement(ps,ct({},t,{ref:e,sideCar:ck}))});Tc.classNames=ps.classNames;var pa=["Enter"," "],uk=["ArrowDown","PageUp","Home"],$1=["ArrowUp","PageDown","End"],dk=[...uk,...$1],fk={ltr:[...pa,"ArrowRight"],rtl:[...pa,"ArrowLeft"]},hk={ltr:["ArrowLeft"],rtl:["ArrowRight"]},co="Menu",[Qr,pk,mk]=l1(co),[jn,V1]=hr(co,[mk,hs,T1]),ms=hs(),z1=T1(),[gk,Bn]=jn(co),[yk,uo]=jn(co),U1=t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:o,onOpenChange:i,modal:s=!0}=t,l=ms(e),[a,c]=y.useState(null),u=y.useRef(!1),d=Pt(i),h=a1(o);return y.useEffect(()=>{const f=()=>{u.current=!0,document.addEventListener("pointerdown",p,{capture:!0,once:!0}),document.addEventListener("pointermove",p,{capture:!0,once:!0})},p=()=>u.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",p,{capture:!0}),document.removeEventListener("pointermove",p,{capture:!0})}},[]),g.jsx(S1,{...l,children:g.jsx(gk,{scope:e,open:n,onOpenChange:d,content:a,onContentChange:c,children:g.jsx(yk,{scope:e,onClose:y.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:h,modal:s,children:r})})})};U1.displayName=co;var vk="MenuAnchor",Ac=y.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,o=ms(n);return g.jsx(Ec,{...o,...r,ref:e})});Ac.displayName=vk;var Rc="MenuPortal",[bk,W1]=jn(Rc,{forceMount:void 0}),K1=t=>{const{__scopeMenu:e,forceMount:n,children:r,container:o}=t,i=Bn(Rc,e);return g.jsx(bk,{scope:e,forceMount:n,children:g.jsx(Pn,{present:n||i.open,children:g.jsx(Mc,{asChild:!0,container:o,children:r})})})};K1.displayName=Rc;var et="MenuContent",[Ck,Oc]=jn(et),q1=y.forwardRef((t,e)=>{const n=W1(et,t.__scopeMenu),{forceMount:r=n.forceMount,...o}=t,i=Bn(et,t.__scopeMenu),s=uo(et,t.__scopeMenu);return g.jsx(Qr.Provider,{scope:t.__scopeMenu,children:g.jsx(Pn,{present:r||i.open,children:g.jsx(Qr.Slot,{scope:t.__scopeMenu,children:s.modal?g.jsx(xk,{...o,ref:e}):g.jsx(wk,{...o,ref:e})})})})}),xk=y.forwardRef((t,e)=>{const n=Bn(et,t.__scopeMenu),r=y.useRef(null),o=Oe(e,r);return y.useEffect(()=>{const i=r.current;if(i)return L1(i)},[]),g.jsx(Nc,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:J(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),wk=y.forwardRef((t,e)=>{const n=Bn(et,t.__scopeMenu);return g.jsx(Nc,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Sk=Xr("MenuContent.ScrollLock"),Nc=y.forwardRef((t,e)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:l,onEntryFocus:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:f,disableOutsideScroll:p,...m}=t,v=Bn(et,n),b=uo(et,n),C=ms(n),x=z1(n),w=pk(n),[E,k]=y.useState(null),S=y.useRef(null),M=Oe(e,S,v.onContentChange),I=y.useRef(0),j=y.useRef(""),_=y.useRef(0),U=y.useRef(null),F=y.useRef("right"),O=y.useRef(0),H=p?Tc:y.Fragment,V=p?{as:Sk,allowPinchZoom:!0}:void 0,L=R=>{const W=j.current+R,te=w().filter(X=>!X.disabled),K=document.activeElement,Y=te.find(X=>X.ref.current===K)?.textValue,We=te.map(X=>X.textValue),ce=Pk(We,W,Y),ye=te.find(X=>X.textValue===ce)?.ref.current;(function X(ne){j.current=ne,window.clearTimeout(I.current),ne!==""&&(I.current=window.setTimeout(()=>X(""),1e3))})(W),ye&&setTimeout(()=>ye.focus())};y.useEffect(()=>()=>window.clearTimeout(I.current),[]),d1();const T=y.useCallback(R=>F.current===U.current?.side&&Bk(R,U.current?.area),[]);return g.jsx(Ck,{scope:n,searchRef:j,onItemEnter:y.useCallback(R=>{T(R)&&R.preventDefault()},[T]),onItemLeave:y.useCallback(R=>{T(R)||(S.current?.focus(),k(null))},[T]),onTriggerLeave:y.useCallback(R=>{T(R)&&R.preventDefault()},[T]),pointerGraceTimerRef:_,onPointerGraceIntentChange:y.useCallback(R=>{U.current=R},[]),children:g.jsx(H,{...V,children:g.jsx(wc,{asChild:!0,trapped:o,onMountAutoFocus:J(i,R=>{R.preventDefault(),S.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:g.jsx(xc,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:f,children:g.jsx(SS,{asChild:!0,...x,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:k,onEntryFocus:J(a,R=>{b.isUsingKeyboardRef.current||R.preventDefault()}),preventScrollOnEntryFocus:!0,children:g.jsx(k1,{role:"menu","aria-orientation":"vertical","data-state":cg(v.open),"data-radix-menu-content":"",dir:b.dir,...C,...m,ref:M,style:{outline:"none",...m.style},onKeyDown:J(m.onKeyDown,R=>{const te=R.target.closest("[data-radix-menu-content]")===R.currentTarget,K=R.ctrlKey||R.altKey||R.metaKey,Y=R.key.length===1;te&&(R.key==="Tab"&&R.preventDefault(),!K&&Y&&L(R.key));const We=S.current;if(R.target!==We||!dk.includes(R.key))return;R.preventDefault();const ye=w().filter(X=>!X.disabled).map(X=>X.ref.current);$1.includes(R.key)&&ye.reverse(),Lk(ye)}),onBlur:J(t.onBlur,R=>{R.currentTarget.contains(R.target)||(window.clearTimeout(I.current),j.current="")}),onPointerMove:J(t.onPointerMove,eo(R=>{const W=R.target,te=O.current!==R.clientX;if(R.currentTarget.contains(W)&&te){const K=R.clientX>O.current?"right":"left";F.current=K,O.current=R.clientX}}))})})})})})})});q1.displayName=et;var kk="MenuGroup",Ic=y.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Te.div,{role:"group",...r,ref:e})});Ic.displayName=kk;var Ek="MenuLabel",G1=y.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Te.div,{...r,ref:e})});G1.displayName=Ek;var Fi="MenuItem",wf="menu.itemSelect",gs=y.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:r,...o}=t,i=y.useRef(null),s=uo(Fi,t.__scopeMenu),l=Oc(Fi,t.__scopeMenu),a=Oe(e,i),c=y.useRef(!1),u=()=>{const d=i.current;if(!n&&d){const h=new CustomEvent(wf,{bubbles:!0,cancelable:!0});d.addEventListener(wf,f=>r?.(f),{once:!0}),s1(d,h),h.defaultPrevented?c.current=!1:s.onClose()}};return g.jsx(J1,{...o,ref:a,disabled:n,onClick:J(t.onClick,u),onPointerDown:d=>{t.onPointerDown?.(d),c.current=!0},onPointerUp:J(t.onPointerUp,d=>{c.current||d.currentTarget?.click()}),onKeyDown:J(t.onKeyDown,d=>{const h=l.searchRef.current!=="";n||h&&d.key===" "||pa.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});gs.displayName=Fi;var J1=y.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...i}=t,s=Oc(Fi,n),l=z1(n),a=y.useRef(null),c=Oe(e,a),[u,d]=y.useState(!1),[h,f]=y.useState("");return y.useEffect(()=>{const p=a.current;p&&f((p.textContent??"").trim())},[i.children]),g.jsx(Qr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:g.jsx(kS,{asChild:!0,...l,focusable:!r,children:g.jsx(Te.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:c,onPointerMove:J(t.onPointerMove,eo(p=>{r?s.onItemLeave(p):(s.onItemEnter(p),p.defaultPrevented||p.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:J(t.onPointerLeave,eo(p=>s.onItemLeave(p))),onFocus:J(t.onFocus,()=>d(!0)),onBlur:J(t.onBlur,()=>d(!1))})})})}),Mk="MenuCheckboxItem",Z1=y.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:r,...o}=t;return g.jsx(tg,{scope:t.__scopeMenu,checked:n,children:g.jsx(gs,{role:"menuitemcheckbox","aria-checked":$i(n)?"mixed":n,...o,ref:e,"data-state":Dc(n),onSelect:J(o.onSelect,()=>r?.($i(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Z1.displayName=Mk;var Y1="MenuRadioGroup",[Tk,Ak]=jn(Y1,{value:void 0,onValueChange:()=>{}}),X1=y.forwardRef((t,e)=>{const{value:n,onValueChange:r,...o}=t,i=Pt(r);return g.jsx(Tk,{scope:t.__scopeMenu,value:n,onValueChange:i,children:g.jsx(Ic,{...o,ref:e})})});X1.displayName=Y1;var Q1="MenuRadioItem",eg=y.forwardRef((t,e)=>{const{value:n,...r}=t,o=Ak(Q1,t.__scopeMenu),i=n===o.value;return g.jsx(tg,{scope:t.__scopeMenu,checked:i,children:g.jsx(gs,{role:"menuitemradio","aria-checked":i,...r,ref:e,"data-state":Dc(i),onSelect:J(r.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});eg.displayName=Q1;var Lc="MenuItemIndicator",[tg,Rk]=jn(Lc,{checked:!1}),ng=y.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:r,...o}=t,i=Rk(Lc,n);return g.jsx(Pn,{present:r||$i(i.checked)||i.checked===!0,children:g.jsx(Te.span,{...o,ref:e,"data-state":Dc(i.checked)})})});ng.displayName=Lc;var Ok="MenuSeparator",rg=y.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Te.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});rg.displayName=Ok;var Nk="MenuArrow",og=y.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,o=ms(n);return g.jsx(E1,{...o,...r,ref:e})});og.displayName=Nk;var Ik="MenuSub",[AM,ig]=jn(Ik),kr="MenuSubTrigger",sg=y.forwardRef((t,e)=>{const n=Bn(kr,t.__scopeMenu),r=uo(kr,t.__scopeMenu),o=ig(kr,t.__scopeMenu),i=Oc(kr,t.__scopeMenu),s=y.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:a}=i,c={__scopeMenu:t.__scopeMenu},u=y.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return y.useEffect(()=>u,[u]),y.useEffect(()=>{const d=l.current;return()=>{window.clearTimeout(d),a(null)}},[l,a]),g.jsx(Ac,{asChild:!0,...c,children:g.jsx(J1,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":cg(n.open),...t,ref:fs(e,o.onTriggerChange),onClick:d=>{t.onClick?.(d),!(t.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:J(t.onPointerMove,eo(d=>{i.onItemEnter(d),!d.defaultPrevented&&!t.disabled&&!n.open&&!s.current&&(i.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:J(t.onPointerLeave,eo(d=>{u();const h=n.content?.getBoundingClientRect();if(h){const f=n.content?.dataset.side,p=f==="right",m=p?-5:5,v=h[p?"left":"right"],b=h[p?"right":"left"];i.onPointerGraceIntentChange({area:[{x:d.clientX+m,y:d.clientY},{x:v,y:h.top},{x:b,y:h.top},{x:b,y:h.bottom},{x:v,y:h.bottom}],side:f}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(d),d.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:J(t.onKeyDown,d=>{const h=i.searchRef.current!=="";t.disabled||h&&d.key===" "||fk[r.dir].includes(d.key)&&(n.onOpenChange(!0),n.content?.focus(),d.preventDefault())})})})});sg.displayName=kr;var lg="MenuSubContent",ag=y.forwardRef((t,e)=>{const n=W1(et,t.__scopeMenu),{forceMount:r=n.forceMount,...o}=t,i=Bn(et,t.__scopeMenu),s=uo(et,t.__scopeMenu),l=ig(lg,t.__scopeMenu),a=y.useRef(null),c=Oe(e,a);return g.jsx(Qr.Provider,{scope:t.__scopeMenu,children:g.jsx(Pn,{present:r||i.open,children:g.jsx(Qr.Slot,{scope:t.__scopeMenu,children:g.jsx(Nc,{id:l.contentId,"aria-labelledby":l.triggerId,...o,ref:c,align:"start",side:s.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{s.isUsingKeyboardRef.current&&a.current?.focus(),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:J(t.onFocusOutside,u=>{u.target!==l.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:J(t.onEscapeKeyDown,u=>{s.onClose(),u.preventDefault()}),onKeyDown:J(t.onKeyDown,u=>{const d=u.currentTarget.contains(u.target),h=hk[s.dir].includes(u.key);d&&h&&(i.onOpenChange(!1),l.trigger?.focus(),u.preventDefault())})})})})})});ag.displayName=lg;function cg(t){return t?"open":"closed"}function $i(t){return t==="indeterminate"}function Dc(t){return $i(t)?"indeterminate":t?"checked":"unchecked"}function Lk(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function Dk(t,e){return t.map((n,r)=>t[(e+r)%t.length])}function Pk(t,e,n){const o=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,i=n?t.indexOf(n):-1;let s=Dk(t,Math.max(i,0));o.length===1&&(s=s.filter(c=>c!==n));const a=s.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return a!==n?a:void 0}function jk(t,e){const{x:n,y:r}=t;let o=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){const l=e[i],a=e[s],c=l.x,u=l.y,d=a.x,h=a.y;u>r!=h>r&&n<(d-c)*(r-u)/(h-u)+c&&(o=!o)}return o}function Bk(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return jk(n,e)}function eo(t){return e=>e.pointerType==="mouse"?t(e):void 0}var _k=U1,Hk=Ac,Fk=K1,$k=q1,Vk=Ic,zk=G1,Uk=gs,Wk=Z1,Kk=X1,qk=eg,Gk=ng,Jk=rg,Zk=og,Yk=sg,Xk=ag,ys="DropdownMenu",[Qk]=hr(ys,[V1]),Be=V1(),[e9,ug]=Qk(ys),dg=t=>{const{__scopeDropdownMenu:e,children:n,dir:r,open:o,defaultOpen:i,onOpenChange:s,modal:l=!0}=t,a=Be(e),c=y.useRef(null),[u,d]=Cc({prop:o,defaultProp:i??!1,onChange:s,caller:ys});return g.jsx(e9,{scope:e,triggerId:Hi(),triggerRef:c,contentId:Hi(),open:u,onOpenChange:d,onOpenToggle:y.useCallback(()=>d(h=>!h),[d]),modal:l,children:g.jsx(_k,{...a,open:u,onOpenChange:d,dir:r,modal:l,children:n})})};dg.displayName=ys;var fg="DropdownMenuTrigger",hg=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=t,i=ug(fg,n),s=Be(n);return g.jsx(Hk,{asChild:!0,...s,children:g.jsx(Te.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:fs(e,i.triggerRef),onPointerDown:J(t.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(i.onOpenToggle(),i.open||l.preventDefault())}),onKeyDown:J(t.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&i.onOpenToggle(),l.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});hg.displayName=fg;var t9="DropdownMenuPortal",pg=t=>{const{__scopeDropdownMenu:e,...n}=t,r=Be(e);return g.jsx(Fk,{...r,...n})};pg.displayName=t9;var mg="DropdownMenuContent",gg=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=ug(mg,n),i=Be(n),s=y.useRef(!1);return g.jsx($k,{id:o.contentId,"aria-labelledby":o.triggerId,...i,...r,ref:e,onCloseAutoFocus:J(t.onCloseAutoFocus,l=>{s.current||o.triggerRef.current?.focus(),s.current=!1,l.preventDefault()}),onInteractOutside:J(t.onInteractOutside,l=>{const a=l.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0,u=a.button===2||c;(!o.modal||u)&&(s.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});gg.displayName=mg;var n9="DropdownMenuGroup",r9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(Vk,{...o,...r,ref:e})});r9.displayName=n9;var o9="DropdownMenuLabel",i9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(zk,{...o,...r,ref:e})});i9.displayName=o9;var s9="DropdownMenuItem",yg=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(Uk,{...o,...r,ref:e})});yg.displayName=s9;var l9="DropdownMenuCheckboxItem",a9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(Wk,{...o,...r,ref:e})});a9.displayName=l9;var c9="DropdownMenuRadioGroup",u9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(Kk,{...o,...r,ref:e})});u9.displayName=c9;var d9="DropdownMenuRadioItem",f9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(qk,{...o,...r,ref:e})});f9.displayName=d9;var h9="DropdownMenuItemIndicator",p9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(Gk,{...o,...r,ref:e})});p9.displayName=h9;var m9="DropdownMenuSeparator",g9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(Jk,{...o,...r,ref:e})});g9.displayName=m9;var y9="DropdownMenuArrow",v9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(Zk,{...o,...r,ref:e})});v9.displayName=y9;var b9="DropdownMenuSubTrigger",C9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(Yk,{...o,...r,ref:e})});C9.displayName=b9;var x9="DropdownMenuSubContent",vg=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(Xk,{...o,...r,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});vg.displayName=x9;var w9=dg,bg=hg,S9=pg,Cg=gg,k9=yg,xg=vg;function wg({...t}){return g.jsx(w9,{modal:!1,...t})}function Sg({...t}){return g.jsx(S9,{...t})}const Pc=y.forwardRef(({...t},e)=>g.jsx(bg,{ref:e,...t}));Pc.displayName=bg.displayName;const kg=k9,E9=y.forwardRef(({className:t,portal:e=!0,...n},r)=>{const o=g.jsx(xg,{ref:r,className:Me("tiptap-dropdown-menu",t),...n});return e?g.jsx(Sg,{...typeof e=="object"?e:{},children:o}):o});E9.displayName=xg.displayName;const jc=y.forwardRef(({className:t,sideOffset:e=4,portal:n=!1,...r},o)=>{const i=g.jsx(Cg,{ref:o,sideOffset:e,onCloseAutoFocus:s=>s.preventDefault(),className:Me("tiptap-dropdown-menu",t),...r});return n?g.jsx(Sg,{...typeof n=="object"?n:{},children:i}):i});jc.displayName=Cg.displayName;const pr=y.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:Me("tiptap-card",t),...e}));pr.displayName="Card";const M9=y.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:Me("tiptap-card-header",t),...e}));M9.displayName="CardHeader";const fo=y.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:Me("tiptap-card-body",t),...e}));fo.displayName="CardBody";const Vi=y.forwardRef(({className:t,orientation:e="vertical",...n},r)=>g.jsx("div",{ref:r,"data-orientation":e,className:Me("tiptap-card-item-group",t),...n}));Vi.displayName="CardItemGroup";const T9=y.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:Me("tiptap-card-group-label",t),...e}));T9.displayName="CardGroupLabel";const A9=y.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:Me("tiptap-card-footer",t),...e}));A9.displayName="CardFooter";const Bc=y.forwardRef(({editor:t,levels:e=[1,2,3,4,5,6],hideWhenUnavailable:n=!1,portal:r=!1,onOpenChange:o,...i},s)=>{const{editor:l}=ee(t),[a,c]=y.useState(!1),{isVisible:u,isActive:d,canToggle:h,Icon:f}=O9({editor:l,levels:e,hideWhenUnavailable:n}),p=y.useCallback(m=>{!l||!h||(c(m),o?.(m))},[h,l,o]);return u?g.jsxs(wg,{modal:!0,open:a,onOpenChange:p,children:[g.jsx(Pc,{asChild:!0,children:g.jsxs(le,{type:"button","data-style":"ghost","data-active-state":d?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":"Format text as heading","aria-pressed":d,tooltip:"Heading",...i,ref:s,children:[g.jsx(f,{className:"tiptap-button-icon"}),g.jsx(vc,{className:"tiptap-button-dropdown-small"})]})}),g.jsx(jc,{align:"start",portal:r,children:g.jsx(pr,{children:g.jsx(fo,{children:g.jsx(Tt,{children:e.map(m=>g.jsx(kg,{asChild:!0,children:g.jsx(Zm,{editor:l,level:m,text:`Heading ${m}`,showTooltip:!1})},`heading-${m}`))})})})})]}):null});Bc.displayName="HeadingDropdownMenu";const Eg=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{d:"M6 3C6.55228 3 7 3.44772 7 4V11H17V4C17 3.44772 17.4477 3 18 3C18.5523 3 19 3.44772 19 4V20C19 20.5523 18.5523 21 18 21C17.4477 21 17 20.5523 17 20V13H7V20C7 20.5523 6.55228 21 6 21C5.44772 21 5 20.5523 5 20V4C5 3.44772 5.44772 3 6 3Z",fill:"currentColor"})}));Eg.displayName="HeadingIcon";function R9(t,e=[1,2,3,4,5,6]){if(!(!t||!t.isEditable))return e.find(n=>bc(t,n))}function O9(t){const{editor:e,levels:n=[1,2,3,4,5,6],hideWhenUnavailable:r=!1}=t||{},{editor:o}=ee(e),[i,s]=y.useState(!0),l=R9(o,n),a=bc(o),c=Yr(o);return y.useEffect(()=>{if(!o)return;const u=()=>{s(i1({editor:o,hideWhenUnavailable:r,level:n}))};return u(),o.on("selectionUpdate",u),()=>{o.off("selectionUpdate",u)}},[o,r,n]),{isVisible:i,activeLevel:l,isActive:a,canToggle:c,levels:n,label:"Heading",Icon:l?r1[l]:Eg}}function N9({shortcutKeys:t=ma}){return g.jsx(bt,{children:gt({shortcutKeys:t})})}const _c=y.forwardRef(({editor:t,text:e,hideWhenUnavailable:n=!1,onInserted:r,showShortcut:o=!1,onClick:i,children:s,...l},a)=>{const{editor:c}=ee(t),{isVisible:u,canInsert:d,handleImage:h,label:f,isActive:p,shortcutKeys:m,Icon:v}=Z9({editor:c,hideWhenUnavailable:n,onInserted:r}),b=y.useCallback(C=>{i?.(C),!C.defaultPrevented&&h()},[h,i]);return u?g.jsx(le,{type:"button","data-style":"ghost","data-active-state":p?"on":"off",role:"button",tabIndex:-1,disabled:!d,"data-disabled":!d,"aria-label":f,"aria-pressed":p,tooltip:f,onClick:b,...l,ref:a,children:s??g.jsxs(g.Fragment,{children:[g.jsx(v,{className:"tiptap-button-icon"}),e&&g.jsx("span",{className:"tiptap-button-text",children:e}),o&&g.jsx(N9,{shortcutKeys:m})]})}):null});_c.displayName="ImageUploadButton";const Mg=["shift","alt","meta","mod","ctrl","control"],I9={esc:"escape",return:"enter",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function on(t){return(I9[t.trim()]||t.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Tg(t){return Mg.includes(t)}function bl(t,e=","){return t.toLowerCase().split(e)}function Cl(t,e="+",n=">",r=!1,o){let i=[],s=!1;t=t.trim(),t.includes(n)?(s=!0,i=t.toLocaleLowerCase().split(n).map(c=>on(c))):i=t.toLocaleLowerCase().split(e).map(c=>on(c));const l={alt:i.includes("alt"),ctrl:i.includes("ctrl")||i.includes("control"),shift:i.includes("shift"),meta:i.includes("meta"),mod:i.includes("mod"),useKey:r},a=i.filter(c=>!Mg.includes(c));return{...l,keys:a,description:o,isSequence:s,hotkey:t}}typeof document<"u"&&(document.addEventListener("keydown",t=>{t.code!==void 0&&Ag([on(t.code)])}),document.addEventListener("keyup",t=>{t.code!==void 0&&Rg([on(t.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{At.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{At.clear()},0)}));const At=new Set;function Hc(t){return Array.isArray(t)}function L9(t,e=","){return(Hc(t)?t:t.split(e)).every(n=>At.has(n.trim().toLowerCase()))}function Ag(t){const e=Array.isArray(t)?t:[t];At.has("meta")&&At.forEach(n=>!Tg(n)&&At.delete(n.toLowerCase())),e.forEach(n=>At.add(n.toLowerCase()))}function Rg(t){const e=Array.isArray(t)?t:[t];t==="meta"?At.clear():e.forEach(n=>At.delete(n.toLowerCase()))}function D9(t,e,n){(typeof n=="function"&&n(t,e)||n===!0)&&t.preventDefault()}function P9(t,e,n){return typeof n=="function"?n(t,e):n===!0||n===void 0}const j9=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function B9(t){return Og(t,j9)}function Og(t,e=!1){const{target:n,composed:r}=t;let o,i;return _9(n)&&r?(o=t.composedPath()[0]&&t.composedPath()[0].tagName,i=t.composedPath()[0]&&t.composedPath()[0].role):(o=n&&n.tagName,i=n&&n.role),Hc(e)?!!(o&&e&&e.some(s=>s.toLowerCase()===o.toLowerCase()||s===i)):!!(o&&e&&e)}function _9(t){return!!t.tagName&&!t.tagName.startsWith("-")&&t.tagName.includes("-")}function H9(t,e){return t.length===0&&e?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):e?t.some(n=>e.includes(n))||t.includes("*"):!0}const F9=(t,e,n=!1)=>{const{alt:r,meta:o,mod:i,shift:s,ctrl:l,keys:a,useKey:c}=e,{code:u,key:d,ctrlKey:h,metaKey:f,shiftKey:p,altKey:m}=t,v=on(u);if(c&&a?.length===1&&a.includes(d))return!0;if(!a?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!n){if(r!==m&&v!=="alt"||s!==p&&v!=="shift")return!1;if(i){if(!f&&!h)return!1}else if(o!==f&&v!=="meta"&&v!=="os"||l!==h&&v!=="ctrl"&&v!=="control")return!1}return a&&a.length===1&&a.includes(v)?!0:a?L9(a):!a},$9=D.createContext(void 0),V9=()=>D.useContext($9);function Ng(t,e){return t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(t).length===Object.keys(e).length&&Object.keys(t).reduce((n,r)=>n&&Ng(t[r],e[r]),!0):t===e}const z9=D.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),U9=()=>D.useContext(z9);function W9(t){const e=D.useRef(void 0);return Ng(e.current,t)||(e.current=t),e.current}const Sf=t=>{t.stopPropagation(),t.preventDefault(),t.stopImmediatePropagation()},K9=typeof window<"u"?D.useLayoutEffect:D.useEffect;function Ig(t,e,n,r){const o=D.useRef(null),i=D.useRef(!1),s=Array.isArray(n)?Array.isArray(r)?void 0:r:n,l=Hc(t)?t.join(s?.delimiter):t,a=Array.isArray(n)?n:Array.isArray(r)?r:void 0,c=D.useCallback(e,a??[]),u=D.useRef(c);a?u.current=c:u.current=e;const d=W9(s),{activeScopes:h}=U9(),f=V9();return K9(()=>{if(d?.enabled===!1||!H9(h,d?.scopes))return;let p=[],m;const v=(w,E=!1)=>{if(!(B9(w)&&!Og(w,d?.enableOnFormTags))){if(o.current!==null){const k=o.current.getRootNode();if((k instanceof Document||k instanceof ShadowRoot)&&k.activeElement!==o.current&&!o.current.contains(k.activeElement)){Sf(w);return}}w.target?.isContentEditable&&!d?.enableOnContentEditable||bl(l,d?.delimiter).forEach(k=>{if(k.includes(d?.splitKey??"+")&&k.includes(d?.sequenceSplitKey??">")){console.warn(`Hotkey ${k} contains both ${d?.splitKey??"+"} and ${d?.sequenceSplitKey??">"} which is not supported.`);return}const S=Cl(k,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description);if(S.isSequence){m=setTimeout(()=>{p=[]},d?.sequenceTimeoutMs??1e3);const M=S.useKey?w.key:on(w.code);if(Tg(M.toLowerCase()))return;p.push(M);const I=S.keys?.[p.length-1];if(M!==I){p=[],m&&clearTimeout(m);return}p.length===S.keys?.length&&(u.current(w,S),m&&clearTimeout(m),p=[])}else if(F9(w,S,d?.ignoreModifiers)||S.keys?.includes("*")){if(d?.ignoreEventWhen?.(w)||E&&i.current)return;if(D9(w,S,d?.preventDefault),!P9(w,S,d?.enabled)){Sf(w);return}u.current(w,S),E||(i.current=!0)}})}},b=w=>{w.code!==void 0&&(Ag(on(w.code)),(d?.keydown===void 0&&d?.keyup!==!0||d?.keydown)&&v(w))},C=w=>{w.code!==void 0&&(Rg(on(w.code)),i.current=!1,d?.keyup&&v(w,!0))},x=o.current||s?.document||document;return x.addEventListener("keyup",C,s?.eventListenerOptions),x.addEventListener("keydown",b,s?.eventListenerOptions),f&&bl(l,d?.delimiter).forEach(w=>f.addHotkey(Cl(w,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),()=>{x.removeEventListener("keyup",C,s?.eventListenerOptions),x.removeEventListener("keydown",b,s?.eventListenerOptions),f&&bl(l,d?.delimiter).forEach(w=>f.removeHotkey(Cl(w,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),p=[],m&&clearTimeout(m)}},[l,d,h]),o}function mr(t=768){const[e,n]=y.useState(void 0);return y.useEffect(()=>{const r=window.matchMedia(`(max-width: ${t-1}px)`),o=()=>{n(window.innerWidth<t)};return r.addEventListener("change",o),n(window.innerWidth<t),()=>r.removeEventListener("change",o)},[t]),!!e}const Lg=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20 2C20 1.44772 19.5523 1 19 1C18.4477 1 18 1.44772 18 2V4H16C15.4477 4 15 4.44772 15 5C15 5.55228 15.4477 6 16 6H18V8C18 8.55228 18.4477 9 19 9C19.5523 9 20 8.55228 20 8V6H22C22.5523 6 23 5.55228 23 5C23 4.44772 22.5523 4 22 4H20V2ZM5 4C4.73478 4 4.48043 4.10536 4.29289 4.29289C4.10536 4.48043 4 4.73478 4 5V19C4 19.2652 4.10536 19.5196 4.29289 19.7071C4.48043 19.8946 4.73478 20 5 20H5.58579L14.379 11.2068C14.9416 10.6444 15.7045 10.3284 16.5 10.3284C17.2955 10.3284 18.0584 10.6444 18.621 11.2068L20 12.5858V12C20 11.4477 20.4477 11 21 11C21.5523 11 22 11.4477 22 12V14.998C22 14.9994 22 15.0007 22 15.002V19C22 19.7957 21.6839 20.5587 21.1213 21.1213C20.5587 21.6839 19.7957 22 19 22H6.00219C6.00073 22 5.99927 22 5.99781 22H5C4.20435 22 3.44129 21.6839 2.87868 21.1213C2.31607 20.5587 2 19.7957 2 19V5C2 4.20435 2.31607 3.44129 2.87868 2.87868C3.44129 2.31607 4.20435 2 5 2H12C12.5523 2 13 2.44772 13 3C13 3.55228 12.5523 4 12 4H5ZM8.41422 20H19C19.2652 20 19.5196 19.8946 19.7071 19.7071C19.8946 19.5196 20 19.2652 20 19V15.4142L17.207 12.6212C17.0195 12.4338 16.7651 12.3284 16.5 12.3284C16.2349 12.3284 15.9806 12.4337 15.7931 12.6211L8.41422 20ZM6.87868 6.87868C7.44129 6.31607 8.20435 6 9 6C9.79565 6 10.5587 6.31607 11.1213 6.87868C11.6839 7.44129 12 8.20435 12 9C12 9.79565 11.6839 10.5587 11.1213 11.1213C10.5587 11.6839 9.79565 12 9 12C8.20435 12 7.44129 11.6839 6.87868 11.1213C6.31607 10.5587 6 9.79565 6 9C6 8.20435 6.31607 7.44129 6.87868 6.87868ZM9 8C8.73478 8 8.48043 8.10536 8.29289 8.29289C8.10536 8.48043 8 8.73478 8 9C8 9.26522 8.10536 9.51957 8.29289 9.70711C8.48043 9.89464 8.73478 10 9 10C9.26522 10 9.51957 9.89464 9.70711 9.70711C9.89464 9.51957 10 9.26522 10 9C10 8.73478 9.89464 8.48043 9.70711 8.29289C9.51957 8.10536 9.26522 8 9 8Z",fill:"currentColor"})}));Lg.displayName="ImagePlusIcon";const ma="mod+shift+i";function Fc(t){return!t||!t.isEditable||!ds(t,"imageUpload")||vt(t,["image"])?!1:t.can().insertContent({type:"imageUpload"})}function q9(t){return!t||!t.isEditable?!1:t.isActive("imageUpload")}function G9(t){if(!t||!t.isEditable||!Fc(t))return!1;try{return t.chain().focus().insertContent({type:"imageUpload"}).run()}catch{return!1}}function J9(t){const{editor:e,hideWhenUnavailable:n}=t;return!e||!e.isEditable||!ds(e,"imageUpload")?!1:n&&!e.isActive("code")?Fc(e):!0}function Z9(t){const{editor:e,hideWhenUnavailable:n=!1,onInserted:r}=t||{},{editor:o}=ee(e),i=mr(),[s,l]=y.useState(!0),a=Fc(o),c=q9(o);y.useEffect(()=>{if(!o)return;const d=()=>{l(J9({editor:o,hideWhenUnavailable:n}))};return d(),o.on("selectionUpdate",d),()=>{o.off("selectionUpdate",d)}},[o,n]);const u=y.useCallback(()=>{if(!o)return!1;const d=G9(o);return d&&r?.(),d},[o,r]);return Ig(ma,d=>{d.preventDefault(),u()},{enabled:s&&a,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:s,isActive:c,handleImage:u,canInsert:a,label:"Add image",shortcutKeys:ma,Icon:Lg}}function Y9({type:t,shortcutKeys:e=jg[t]}){return g.jsx(bt,{children:gt({shortcutKeys:e})})}const Dg=y.forwardRef(({editor:t,type:e,text:n,hideWhenUnavailable:r=!1,onToggled:o,showShortcut:i=!1,onClick:s,children:l,...a},c)=>{const{editor:u}=ee(t),{isVisible:d,canToggle:h,isActive:f,handleToggle:p,label:m,shortcutKeys:v,Icon:b}=tE({editor:u,type:e,hideWhenUnavailable:r,onToggled:o}),C=y.useCallback(x=>{s?.(x),!x.defaultPrevented&&p()},[p,s]);return d?g.jsx(le,{type:"button","data-style":"ghost","data-active-state":f?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":m,"aria-pressed":f,tooltip:m,onClick:C,...a,ref:c,children:l??g.jsxs(g.Fragment,{children:[g.jsx(b,{className:"tiptap-button-icon"}),n&&g.jsx("span",{className:"tiptap-button-text",children:n}),i&&g.jsx(Y9,{type:e,shortcutKeys:v})]})}):null});Dg.displayName="ListButton";const vs=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 6C7 5.44772 7.44772 5 8 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H8C7.44772 7 7 6.55228 7 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 11.4477 7.44772 11 8 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H8C7.44772 13 7 12.5523 7 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 18C7 17.4477 7.44772 17 8 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H8C7.44772 19 7 18.5523 7 18Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H3.01C3.56228 5 4.01 5.44772 4.01 6C4.01 6.55228 3.56228 7 3.01 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H3.01C3.56228 11 4.01 11.4477 4.01 12C4.01 12.5523 3.56228 13 3.01 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H3.01C3.56228 17 4.01 17.4477 4.01 18C4.01 18.5523 3.56228 19 3.01 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));vs.displayName="ListIcon";const $c=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 6C9 5.44772 9.44772 5 10 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H10C9.44772 7 9 6.55228 9 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 12C9 11.4477 9.44772 11 10 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H10C9.44772 13 9 12.5523 9 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 18C9 17.4477 9.44772 17 10 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H10C9.44772 19 9 18.5523 9 18Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 6C3 5.44772 3.44772 5 4 5H5C5.55228 5 6 5.44772 6 6V10C6 10.5523 5.55228 11 5 11C4.44772 11 4 10.5523 4 10V7C3.44772 7 3 6.55228 3 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 10C3 9.44772 3.44772 9 4 9H6C6.55228 9 7 9.44772 7 10C7 10.5523 6.55228 11 6 11H4C3.44772 11 3 10.5523 3 10Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.82219 13.0431C6.54543 13.4047 6.99997 14.1319 6.99997 15C6.99997 15.5763 6.71806 16.0426 6.48747 16.35C6.31395 16.5814 6.1052 16.8044 5.91309 17H5.99997C6.55226 17 6.99997 17.4477 6.99997 18C6.99997 18.5523 6.55226 19 5.99997 19H3.99997C3.44769 19 2.99997 18.5523 2.99997 18C2.99997 17.4237 3.28189 16.9575 3.51247 16.65C3.74323 16.3424 4.03626 16.0494 4.26965 15.8161C4.27745 15.8083 4.2852 15.8006 4.29287 15.7929C4.55594 15.5298 4.75095 15.3321 4.88748 15.15C4.96287 15.0495 4.99021 14.9922 4.99911 14.9714C4.99535 14.9112 4.9803 14.882 4.9739 14.8715C4.96613 14.8588 4.95382 14.845 4.92776 14.8319C4.87723 14.8067 4.71156 14.7623 4.44719 14.8944C3.95321 15.1414 3.35254 14.9412 3.10555 14.4472C2.85856 13.9533 3.05878 13.3526 3.55276 13.1056C4.28839 12.7378 5.12272 12.6934 5.82219 13.0431Z",fill:"currentColor"})]}));$c.displayName="ListOrderedIcon";const Vc=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 4.89543 2.89543 4 4 4H8C9.10457 4 10 4.89543 10 6V10C10 11.1046 9.10457 12 8 12H4C2.89543 12 2 11.1046 2 10V6ZM8 6H4V10H8V6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 14.2929C10.0976 14.6834 10.0976 15.3166 9.70711 15.7071L5.70711 19.7071C5.31658 20.0976 4.68342 20.0976 4.29289 19.7071L2.29289 17.7071C1.90237 17.3166 1.90237 16.6834 2.29289 16.2929C2.68342 15.9024 3.31658 15.9024 3.70711 16.2929L5 17.5858L8.29289 14.2929C8.68342 13.9024 9.31658 13.9024 9.70711 14.2929Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 6C12 5.44772 12.4477 5 13 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H13C12.4477 7 12 6.55228 12 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 12C12 11.4477 12.4477 11 13 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H13C12.4477 13 12 12.5523 12 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 18C12 17.4477 12.4477 17 13 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H13C12.4477 19 12 18.5523 12 18Z",fill:"currentColor"})]}));Vc.displayName="ListTodoIcon";const Pg={bulletList:vs,orderedList:$c,taskList:Vc},X9={bulletList:"Bullet List",orderedList:"Ordered List",taskList:"Task List"},jg={bulletList:"mod+shift+8",orderedList:"mod+shift+7",taskList:"mod+shift+9"};function bs(t,e,n=!0){if(!t||!t.isEditable||!Bt(e,t)||vt(t,["image"]))return!1;if(!n)switch(e){case"bulletList":return t.can().toggleBulletList();case"orderedList":return t.can().toggleOrderedList();case"taskList":return t.can().toggleList("taskList","taskItem");default:return!1}try{const o=t.view.state,i=o.selection;if(i.empty||i instanceof z){const s=hn({editor:t,node:o.selection.$anchor.node(1)})?.pos;if(!yt(s))return!1}return!0}catch{return!1}}function zc(t,e){if(!t||!t.isEditable)return!1;switch(e){case"bulletList":return t.isActive("bulletList");case"orderedList":return t.isActive("orderedList");case"taskList":return t.isActive("taskList");default:return!1}}function Q9(t,e){if(!t||!t.isEditable||!bs(t,e))return!1;try{const n=t.view;let r=n.state,o=r.tr;if(r.selection.empty||r.selection instanceof z){const l=hn({editor:t,node:r.selection.$anchor.node(1)})?.pos;if(!yt(l))return!1;o=o.setSelection(B.create(r.doc,l)),n.dispatch(o),r=n.state}const i=r.selection;let s=t.chain().focus();if(i instanceof B){const l=i.node.firstChild?.firstChild,a=i.node.lastChild?.lastChild,c=l?i.from+l.nodeSize:i.from+1,u=a?i.to-a.nodeSize:i.to-1;s=s.setTextSelection({from:c,to:u}).clearNodes()}if(t.isActive(e))s.liftListItem("listItem").lift("bulletList").lift("orderedList").lift("taskList").run();else{const a={bulletList:()=>s.toggleBulletList(),orderedList:()=>s.toggleOrderedList(),taskList:()=>s.toggleList("taskList","taskItem")}[e];if(!a)return!1;a().run()}return t.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function eE(t){const{editor:e,type:n,hideWhenUnavailable:r}=t;return!e||!e.isEditable||!Bt(n,e)?!1:r&&!e.isActive("code")?bs(e,n):!0}function tE(t){const{editor:e,type:n,hideWhenUnavailable:r=!1,onToggled:o}=t,{editor:i}=ee(e),[s,l]=y.useState(!0),a=bs(i,n),c=zc(i,n);y.useEffect(()=>{if(!i)return;const d=()=>{l(eE({editor:i,type:n,hideWhenUnavailable:r}))};return d(),i.on("selectionUpdate",d),()=>{i.off("selectionUpdate",d)}},[i,n,r]);const u=y.useCallback(()=>{if(!i)return!1;const d=Q9(i,n);return d&&o?.(),d},[i,n,o]);return{isVisible:s,isActive:c,handleToggle:u,canToggle:a,label:X9[n],shortcutKeys:jg[n],Icon:Pg[n]}}const nE=[{label:"Bullet List",type:"bulletList",icon:vs},{label:"Ordered List",type:"orderedList",icon:$c},{label:"Task List",type:"taskList",icon:Vc}];function rE(t,e){return!t||!t.isEditable?!1:e.some(n=>bs(t,n))}function oE(t,e){return!t||!t.isEditable?!1:e.some(n=>zc(t,n))}function iE(t){return nE.filter(e=>!e.type||t.includes(e.type))}function sE(t){const{editor:e,hideWhenUnavailable:n,listInSchema:r,canToggleAny:o}=t;return!r||!e?!1:n&&!e.isActive("code")?o:!0}function lE(t,e){if(!(!t||!t.isEditable))return e.find(n=>zc(t,n))}function aE(t){const{editor:e,types:n=["bulletList","orderedList","taskList"],hideWhenUnavailable:r=!1}=t||{},{editor:o}=ee(e),[i,s]=y.useState(!1),l=n.some(f=>Bt(f,o)),a=y.useMemo(()=>iE(n),[n]),c=rE(o,n),u=oE(o,n),d=lE(o,n),h=a.find(f=>f.type===d);return y.useEffect(()=>{if(!o)return;const f=()=>{s(sE({editor:o,hideWhenUnavailable:r,listInSchema:l,canToggleAny:c}))};return f(),o.on("selectionUpdate",f),()=>{o.off("selectionUpdate",f)}},[c,o,r,l,n]),{isVisible:i,activeType:d,isActive:u,canToggle:c,types:n,filteredLists:a,label:"List",Icon:h?Pg[h.type]:vs}}function Bg({editor:t,types:e=["bulletList","orderedList","taskList"],hideWhenUnavailable:n=!1,onOpenChange:r,portal:o=!1,...i}){const{editor:s}=ee(t),[l,a]=y.useState(!1),{filteredLists:c,canToggle:u,isActive:d,isVisible:h,Icon:f}=aE({editor:s,types:e,hideWhenUnavailable:n}),p=y.useCallback(m=>{a(m),r?.(m)},[r]);return!h||!s||!s.isEditable?null:g.jsxs(wg,{open:l,onOpenChange:p,children:[g.jsx(Pc,{asChild:!0,children:g.jsxs(le,{type:"button","data-style":"ghost","data-active-state":d?"on":"off",role:"button",tabIndex:-1,disabled:!u,"data-disabled":!u,"aria-label":"List options",tooltip:"List",...i,children:[g.jsx(f,{className:"tiptap-button-icon"}),g.jsx(vc,{className:"tiptap-button-dropdown-small"})]})}),g.jsx(jc,{align:"start",portal:o,children:g.jsx(pr,{children:g.jsx(fo,{children:g.jsx(Tt,{children:c.map(m=>g.jsx(kg,{asChild:!0,children:g.jsx(Dg,{editor:s,type:m.type,text:m.label,showTooltip:!1})},m.type))})})})})]})}function cE({shortcutKeys:t=Hg}){return g.jsx(bt,{children:gt({shortcutKeys:t})})}const Uc=y.forwardRef(({editor:t,text:e,hideWhenUnavailable:n=!1,onToggled:r,showShortcut:o=!1,onClick:i,children:s,...l},a)=>{const{editor:c}=ee(t),{isVisible:u,canToggle:d,isActive:h,handleToggle:f,label:p,shortcutKeys:m,Icon:v}=fE({editor:c,hideWhenUnavailable:n,onToggled:r}),b=y.useCallback(C=>{i?.(C),!C.defaultPrevented&&f()},[f,i]);return u?g.jsx(le,{type:"button","data-style":"ghost","data-active-state":h?"on":"off",role:"button",tabIndex:-1,disabled:!d,"data-disabled":!d,"aria-label":p,"aria-pressed":h,tooltip:"Blockquote",onClick:b,...l,ref:a,children:s??g.jsxs(g.Fragment,{children:[g.jsx(v,{className:"tiptap-button-icon"}),e&&g.jsx("span",{className:"tiptap-button-text",children:e}),o&&g.jsx(cE,{shortcutKeys:m})]})}):null});Uc.displayName="BlockquoteButton";const _g=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 6C8 5.44772 8.44772 5 9 5H16C16.5523 5 17 5.44772 17 6C17 6.55228 16.5523 7 16 7H9C8.44772 7 8 6.55228 8 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3C4.55228 3 5 3.44772 5 4L5 20C5 20.5523 4.55229 21 4 21C3.44772 21 3 20.5523 3 20L3 4C3 3.44772 3.44772 3 4 3Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H20C20.5523 11 21 11.4477 21 12C21 12.5523 20.5523 13 20 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 18C8 17.4477 8.44772 17 9 17H16C16.5523 17 17 17.4477 17 18C17 18.5523 16.5523 19 16 19H9C8.44772 19 8 18.5523 8 18Z",fill:"currentColor"})]}));_g.displayName="BlockquoteIcon";const Hg="mod+shift+b";function Wc(t,e=!0){if(!t||!t.isEditable||!Bt("blockquote",t)||vt(t,["image"]))return!1;if(!e)return t.can().toggleWrap("blockquote");try{const r=t.view.state,o=r.selection;if(o.empty||o instanceof z){const i=hn({editor:t,node:r.selection.$anchor.node(1)})?.pos;if(!yt(i))return!1}return!0}catch{return!1}}function uE(t){if(!t||!t.isEditable||!Wc(t))return!1;try{const e=t.view;let n=e.state,r=n.tr;if(n.selection.empty||n.selection instanceof z){const l=hn({editor:t,node:n.selection.$anchor.node(1)})?.pos;if(!yt(l))return!1;r=r.setSelection(B.create(n.doc,l)),e.dispatch(r),n=e.state}const o=n.selection;let i=t.chain().focus();if(o instanceof B){const l=o.node.firstChild?.firstChild,a=o.node.lastChild?.lastChild,c=l?o.from+l.nodeSize:o.from+1,u=a?o.to-a.nodeSize:o.to-1;i=i.setTextSelection({from:c,to:u}).clearNodes()}return(t.isActive("blockquote")?i.lift("blockquote"):i.wrapIn("blockquote")).run(),t.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function dE(t){const{editor:e,hideWhenUnavailable:n}=t;return!e||!e.isEditable||!Bt("blockquote",e)?!1:n&&!e.isActive("code")?Wc(e):!0}function fE(t){const{editor:e,hideWhenUnavailable:n=!1,onToggled:r}=t||{},{editor:o}=ee(e),[i,s]=y.useState(!0),l=Wc(o),a=o?.isActive("blockquote")||!1;y.useEffect(()=>{if(!o)return;const u=()=>{s(dE({editor:o,hideWhenUnavailable:n}))};return u(),o.on("selectionUpdate",u),()=>{o.off("selectionUpdate",u)}},[o,n]);const c=y.useCallback(()=>{if(!o)return!1;const u=uE(o);return u&&r?.(),u},[o,r]);return{isVisible:i,isActive:a,handleToggle:c,canToggle:l,label:"Blockquote",shortcutKeys:Hg,Icon:_g}}const ga=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.43471 4.01458C4.34773 4.06032 4.26607 4.11977 4.19292 4.19292C4.11977 4.26607 4.06032 4.34773 4.01458 4.43471C2.14611 6.40628 1 9.0693 1 12C1 18.0751 5.92487 23 12 23C14.9306 23 17.5936 21.854 19.5651 19.9856C19.6522 19.9398 19.7339 19.8803 19.8071 19.8071C19.8803 19.7339 19.9398 19.6522 19.9856 19.5651C21.854 17.5936 23 14.9306 23 12C23 5.92487 18.0751 1 12 1C9.0693 1 6.40628 2.14611 4.43471 4.01458ZM6.38231 4.9681C7.92199 3.73647 9.87499 3 12 3C16.9706 3 21 7.02944 21 12C21 14.125 20.2635 16.078 19.0319 17.6177L6.38231 4.9681ZM17.6177 19.0319C16.078 20.2635 14.125 21 12 21C7.02944 21 3 16.9706 3 12C3 9.87499 3.73647 7.92199 4.9681 6.38231L17.6177 19.0319Z",fill:"currentColor"})}));ga.displayName="BanIcon";const Cs=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.7072 4.70711C15.0977 4.31658 15.0977 3.68342 14.7072 3.29289C14.3167 2.90237 13.6835 2.90237 13.293 3.29289L8.69294 7.89286L8.68594 7.9C8.13626 8.46079 7.82837 9.21474 7.82837 10C7.82837 10.2306 7.85491 10.4584 7.90631 10.6795L2.29289 16.2929C2.10536 16.4804 2 16.7348 2 17V20C2 20.5523 2.44772 21 3 21H12C12.2652 21 12.5196 20.8946 12.7071 20.7071L15.3205 18.0937C15.5416 18.1452 15.7695 18.1717 16.0001 18.1717C16.7853 18.1717 17.5393 17.8639 18.1001 17.3142L22.7072 12.7071C23.0977 12.3166 23.0977 11.6834 22.7072 11.2929C22.3167 10.9024 21.6835 10.9024 21.293 11.2929L16.6971 15.8887C16.5105 16.0702 16.2605 16.1717 16.0001 16.1717C15.7397 16.1717 15.4897 16.0702 15.303 15.8887L10.1113 10.697C9.92992 10.5104 9.82837 10.2604 9.82837 10C9.82837 9.73963 9.92992 9.48958 10.1113 9.30297L14.7072 4.70711ZM13.5858 17L9.00004 12.4142L4 17.4142V19H11.5858L13.5858 17Z",fill:"currentColor"})}));Cs.displayName="HighlighterIcon";var xs="Popover",[Fg]=hr(xs,[hs]),ho=hs(),[hE,pn]=Fg(xs),$g=t=>{const{__scopePopover:e,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=t,l=ho(e),a=y.useRef(null),[c,u]=y.useState(!1),[d,h]=Cc({prop:r,defaultProp:o??!1,onChange:i,caller:xs});return g.jsx(S1,{...l,children:g.jsx(hE,{scope:e,contentId:Hi(),triggerRef:a,open:d,onOpenChange:h,onOpenToggle:y.useCallback(()=>h(f=>!f),[h]),hasCustomAnchor:c,onCustomAnchorAdd:y.useCallback(()=>u(!0),[]),onCustomAnchorRemove:y.useCallback(()=>u(!1),[]),modal:s,children:n})})};$g.displayName=xs;var Vg="PopoverAnchor",pE=y.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=pn(Vg,n),i=ho(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:l}=o;return y.useEffect(()=>(s(),()=>l()),[s,l]),g.jsx(Ec,{...i,...r,ref:e})});pE.displayName=Vg;var zg="PopoverTrigger",Ug=y.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=pn(zg,n),i=ho(n),s=Oe(e,o.triggerRef),l=g.jsx(Te.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Jg(o.open),...r,ref:s,onClick:J(t.onClick,o.onOpenToggle)});return o.hasCustomAnchor?l:g.jsx(Ec,{asChild:!0,...i,children:l})});Ug.displayName=zg;var Kc="PopoverPortal",[mE,gE]=Fg(Kc,{forceMount:void 0}),Wg=t=>{const{__scopePopover:e,forceMount:n,children:r,container:o}=t,i=pn(Kc,e);return g.jsx(mE,{scope:e,forceMount:n,children:g.jsx(Pn,{present:n||i.open,children:g.jsx(Mc,{asChild:!0,container:o,children:r})})})};Wg.displayName=Kc;var cr="PopoverContent",Kg=y.forwardRef((t,e)=>{const n=gE(cr,t.__scopePopover),{forceMount:r=n.forceMount,...o}=t,i=pn(cr,t.__scopePopover);return g.jsx(Pn,{present:r||i.open,children:i.modal?g.jsx(vE,{...o,ref:e}):g.jsx(bE,{...o,ref:e})})});Kg.displayName=cr;var yE=Xr("PopoverContent.RemoveScroll"),vE=y.forwardRef((t,e)=>{const n=pn(cr,t.__scopePopover),r=y.useRef(null),o=Oe(e,r),i=y.useRef(!1);return y.useEffect(()=>{const s=r.current;if(s)return L1(s)},[]),g.jsx(Tc,{as:yE,allowPinchZoom:!0,children:g.jsx(qg,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:J(t.onCloseAutoFocus,s=>{s.preventDefault(),i.current||n.triggerRef.current?.focus()}),onPointerDownOutside:J(t.onPointerDownOutside,s=>{const l=s.detail.originalEvent,a=l.button===0&&l.ctrlKey===!0,c=l.button===2||a;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:J(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),bE=y.forwardRef((t,e)=>{const n=pn(cr,t.__scopePopover),r=y.useRef(!1),o=y.useRef(!1);return g.jsx(qg,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{t.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{t.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),qg=y.forwardRef((t,e)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onInteractOutside:u,...d}=t,h=pn(cr,n),f=ho(n);return d1(),g.jsx(wc,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:g.jsx(xc,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:g.jsx(k1,{"data-state":Jg(h.open),role:"dialog",id:h.contentId,...f,...d,ref:e,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Gg="PopoverClose",CE=y.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=pn(Gg,n);return g.jsx(Te.button,{type:"button",...r,ref:e,onClick:J(t.onClick,()=>o.onOpenChange(!1))})});CE.displayName=Gg;var xE="PopoverArrow",wE=y.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=ho(n);return g.jsx(E1,{...o,...r,ref:e})});wE.displayName=xE;function Jg(t){return t?"open":"closed"}var SE=$g,kE=Ug,EE=Wg,ME=Kg;function Zg({...t}){return g.jsx(SE,{...t})}function Yg({...t}){return g.jsx(kE,{...t})}function Xg({className:t,align:e="center",sideOffset:n=4,...r}){return g.jsx(EE,{children:g.jsx(ME,{align:e,sideOffset:n,className:Me("tiptap-popover",t),...r})})}function TE({shortcutKeys:t=ya}){return g.jsx(bt,{children:gt({shortcutKeys:t})})}const Qg=y.forwardRef(({editor:t,highlightColor:e,text:n,hideWhenUnavailable:r=!1,onApplied:o,showShortcut:i=!1,onClick:s,children:l,style:a,...c},u)=>{const{editor:d}=ee(t),{isVisible:h,canColorHighlight:f,isActive:p,handleColorHighlight:m,label:v,shortcutKeys:b}=Gc({editor:d,highlightColor:e,label:n||`Toggle highlight (${e})`,hideWhenUnavailable:r,onApplied:o}),C=y.useCallback(w=>{s?.(w),!w.defaultPrevented&&m()},[m,s]),x=y.useMemo(()=>({...a,"--highlight-color":e}),[e,a]);return h?g.jsx(le,{type:"button","data-style":"ghost","data-active-state":p?"on":"off",role:"button",tabIndex:-1,disabled:!f,"data-disabled":!f,"aria-label":v,"aria-pressed":p,tooltip:v,onClick:C,style:x,...c,ref:u,children:l??g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"tiptap-button-highlight",style:{"--highlight-color":e}}),n&&g.jsx("span",{className:"tiptap-button-text",children:n}),i&&g.jsx(TE,{shortcutKeys:b})]})}):null});Qg.displayName="ColorHighlightButton";const ya="mod+shift+h",AE=[{label:"Default background",value:"var(--tt-bg-color)",border:"var(--tt-bg-color-contrast)"},{label:"Gray background",value:"var(--tt-color-highlight-gray)",border:"var(--tt-color-highlight-gray-contrast)"},{label:"Brown background",value:"var(--tt-color-highlight-brown)",border:"var(--tt-color-highlight-brown-contrast)"},{label:"Orange background",value:"var(--tt-color-highlight-orange)",border:"var(--tt-color-highlight-orange-contrast)"},{label:"Yellow background",value:"var(--tt-color-highlight-yellow)",border:"var(--tt-color-highlight-yellow-contrast)"},{label:"Green background",value:"var(--tt-color-highlight-green)",border:"var(--tt-color-highlight-green-contrast)"},{label:"Blue background",value:"var(--tt-color-highlight-blue)",border:"var(--tt-color-highlight-blue-contrast)"},{label:"Purple background",value:"var(--tt-color-highlight-purple)",border:"var(--tt-color-highlight-purple-contrast)"},{label:"Pink background",value:"var(--tt-color-highlight-pink)",border:"var(--tt-color-highlight-pink-contrast)"},{label:"Red background",value:"var(--tt-color-highlight-red)",border:"var(--tt-color-highlight-red-contrast)"}];function RE(t){const e=new Map(AE.map(n=>[n.value,n]));return t.map(n=>e.get(n)).filter(n=>!!n)}function qc(t){return!t||!t.isEditable||!Dn("highlight",t)||vt(t,["image"])?!1:t.can().setMark("highlight")}function OE(t,e){return!t||!t.isEditable?!1:e?t.isActive("highlight",{color:e}):t.isActive("highlight")}function NE(t){return!t||!t.isEditable||!qc(t)?!1:t.chain().focus().unsetMark("highlight").run()}function IE(t){const{editor:e,hideWhenUnavailable:n}=t;return!e||!e.isEditable||!Dn("highlight",e)?!1:n&&!e.isActive("code")?qc(e):!0}function Gc(t){const{editor:e,label:n,highlightColor:r,hideWhenUnavailable:o=!1,onApplied:i}=t,{editor:s}=ee(e),l=mr(),[a,c]=y.useState(!0),u=qc(s),d=OE(s,r);y.useEffect(()=>{if(!s)return;const p=()=>{c(IE({editor:s,hideWhenUnavailable:o}))};return p(),s.on("selectionUpdate",p),()=>{s.off("selectionUpdate",p)}},[s,o]);const h=y.useCallback(()=>{if(!s||!u||!r||!n)return!1;if(s.state.storedMarks){const p=s.schema.marks.highlight;p&&s.view.dispatch(s.state.tr.removeStoredMark(p))}setTimeout(()=>{const p=s.chain().focus().toggleMark("highlight",{color:r}).run();return p&&i?.({color:r,label:n}),p},0)},[u,r,s,n,i]),f=y.useCallback(()=>{const p=NE(s);return p&&i?.({color:"",label:"Remove highlight"}),p},[s,i]);return Ig(ya,p=>{p.preventDefault(),h()},{enabled:a&&u,enableOnContentEditable:!l,enableOnFormTags:!0}),{isVisible:a,isActive:d,handleColorHighlight:h,handleRemoveHighlight:f,canColorHighlight:u,label:n||"Highlight",shortcutKeys:ya,Icon:Cs}}const e0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M11.1 3C11.4762 3 11.8126 3.2286 11.9487 3.5786L16.9487 16.4214C17.1429 16.9213 16.8913 17.4816 16.3877 17.6743C15.884 17.8671 15.3196 17.6173 15.1254 17.1173L13.7569 13.5997H8.24311L6.87456 17.1173C6.68038 17.6173 6.11599 17.8671 5.61235 17.6743C5.10871 17.4816 4.85706 16.9213 5.05123 16.4214L10.0512 3.5786C10.1874 3.2286 10.5238 3 10.9 3H11.1ZM12.9879 11.6233L11 6.51102L9.0121 11.6233H12.9879Z",fill:"currentColor"}),g.jsx("rect",{x:"3",y:"19",width:"18",height:"2.5",rx:"1",fill:"currentColor"})]}));e0.displayName="TextColorIcon";const LE=[{label:"Gray",value:"var(--tt-color-text-gray)",border:"var(--tt-color-text-gray-contrast)"},{label:"Brown",value:"var(--tt-color-text-brown)",border:"var(--tt-color-text-brown-contrast)"},{label:"Orange",value:"var(--tt-color-text-orange)",border:"var(--tt-color-text-orange-contrast)"},{label:"Yellow",value:"var(--tt-color-text-yellow)",border:"var(--tt-color-text-yellow-contrast)"},{label:"Green",value:"var(--tt-color-text-green)",border:"var(--tt-color-text-green-contrast)"},{label:"Blue",value:"var(--tt-color-text-blue)",border:"var(--tt-color-text-blue-contrast)"},{label:"Purple",value:"var(--tt-color-text-purple)",border:"var(--tt-color-text-purple-contrast)"},{label:"Pink",value:"var(--tt-color-text-pink)",border:"var(--tt-color-text-pink-contrast)"},{label:"Red",value:"var(--tt-color-text-red)",border:"var(--tt-color-text-red-contrast)"}];function DE(t){const e=new Map(LE.map(n=>[n.value,n]));return t.map(n=>e.get(n)).filter(n=>!!n)}function kf(t){return!t||!t.isEditable||!Dn("textStyle",t)||vt(t,["image"])?!1:t.can().setMark("textStyle")}function PE(t,e){return!t||!t.isEditable?!1:e?t.isActive("textStyle",{color:e}):t.isActive("textStyle")}function jE(t){return!t||!t.isEditable?!1:t.chain().focus().unsetColor().run()}function t0(t){const{editor:e,label:n,color:r,hideWhenUnavailable:o=!1,onApplied:i}=t,{editor:s}=ee(e),[l,a]=y.useState(!0),c=kf(s),u=PE(s,r);y.useEffect(()=>{if(!s)return;const f=()=>{if(!s.isEditable){a(!1);return}if(!Dn("textStyle",s)){a(!1);return}if(o){a(kf(s));return}a(!0)};return f(),s.on("selectionUpdate",f),()=>{s.off("selectionUpdate",f)}},[s,o]);const d=y.useCallback(()=>{if(!s||!c||!r||!n)return!1;setTimeout(()=>{const f=s.chain().focus().setColor(r).run();return f&&i?.({color:r,label:n}),f},0)},[c,r,s,n,i]),h=y.useCallback(()=>{if(!s)return!1;const f=jE(s);return f&&i?.({color:"",label:"Remove color"}),f},[s,i]);return{isVisible:l,isActive:u,handleSetColor:d,handleRemoveColor:h,canSetColor:c,label:n||"Text color",Icon:e0}}const n0=y.forwardRef(({editor:t,color:e,text:n,hideWhenUnavailable:r=!1,onApplied:o,onClick:i,children:s,style:l,...a},c)=>{const{editor:u}=ee(t),{isVisible:d,canSetColor:h,isActive:f,handleSetColor:p,label:m}=t0({editor:u,color:e,label:n||`Text ${e}`,hideWhenUnavailable:r,onApplied:o}),v=y.useCallback(C=>{i?.(C),!C.defaultPrevented&&p()},[p,i]),b=y.useMemo(()=>({...l,"--text-color":e}),[e,l]);return d?g.jsx(le,{type:"button","data-style":"ghost","data-active-state":f?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":m,"aria-pressed":f,tooltip:m,onClick:v,style:b,...a,ref:c,children:s??g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"tiptap-button-text-color",style:{"--text-color":e}}),n&&g.jsx("span",{className:"tiptap-button-text",children:n})]})}):null});n0.displayName="TextColorButton";const Jc=y.forwardRef(({className:t,children:e,...n},r)=>g.jsx(le,{type:"button",className:t,"data-style":"ghost","data-appearance":"default",role:"button",tabIndex:-1,"aria-label":"Highlight text",tooltip:"Highlight",ref:r,...n,children:e??g.jsx(Cs,{className:"tiptap-button-icon"})}));Jc.displayName="ColorHighlightPopoverButton";const r0=DE(["var(--tt-color-text-gray)","var(--tt-color-text-brown)","var(--tt-color-text-orange)","var(--tt-color-text-yellow)","var(--tt-color-text-green)","var(--tt-color-text-blue)","var(--tt-color-text-purple)","var(--tt-color-text-pink)","var(--tt-color-text-red)"]),o0=RE(["var(--tt-color-highlight-green)","var(--tt-color-highlight-blue)","var(--tt-color-highlight-red)","var(--tt-color-highlight-purple)","var(--tt-color-highlight-yellow)"]);function i0({editor:t,colors:e=o0,textColors:n=r0}){const{handleRemoveHighlight:r}=Gc({editor:t}),{handleRemoveColor:o}=t0({editor:t}),i=mr(),s=y.useRef(null),l=y.useMemo(()=>[...n.map(f=>({...f,group:"text"})),{label:"Remove color",value:"none-text",group:"text"},...e.map(f=>({...f,group:"highlight"})),{label:"Remove highlight",value:"none-highlight",group:"highlight"}],[n,e]),{selectedIndex:a}=qm({containerRef:s,items:l,orientation:"both",onSelect:f=>{if(!s.current)return!1;const p=s.current.querySelector('[data-highlighted="true"]');p&&p.click(),f.value==="none-text"&&o(),f.value==="none-highlight"&&r()},autoSelectFirstItem:!1}),c=0,u=n.length,d=n.length+1,h=d+e.length;return g.jsx(pr,{ref:s,tabIndex:0,style:i?{boxShadow:"none",border:0}:{},children:g.jsxs(fo,{style:i?{padding:0}:{},children:[g.jsxs(Vi,{orientation:"horizontal",children:[g.jsx(Tt,{orientation:"horizontal",children:n.map((f,p)=>g.jsx(n0,{editor:t,color:f.value,tooltip:f.label,"aria-label":`${f.label} text color`,tabIndex:c+p===a?0:-1,"data-highlighted":a===c+p},f.value))}),g.jsx(er,{}),g.jsx(Tt,{orientation:"horizontal",children:g.jsx(le,{onClick:o,"aria-label":"Remove text color",tooltip:"Remove text color",tabIndex:a===u?0:-1,type:"button",role:"menuitem","data-style":"ghost","data-highlighted":a===u,children:g.jsx(ga,{className:"tiptap-button-icon"})})})]}),g.jsx(er,{}),g.jsxs(Vi,{orientation:"horizontal",children:[g.jsx(Tt,{orientation:"horizontal",children:e.map((f,p)=>g.jsx(Qg,{editor:t,highlightColor:f.value,tooltip:f.label,"aria-label":`${f.label} highlight color`,tabIndex:d+p===a?0:-1,"data-highlighted":a===d+p},f.value))}),g.jsx(er,{}),g.jsx(Tt,{orientation:"horizontal",children:g.jsx(le,{onClick:r,"aria-label":"Remove highlight",tooltip:"Remove highlight",tabIndex:a===h?0:-1,type:"button",role:"menuitem","data-style":"ghost","data-highlighted":a===h,children:g.jsx(ga,{className:"tiptap-button-icon"})})})]})]})})}function BE({editor:t,colors:e=o0,textColors:n=r0,hideWhenUnavailable:r=!1,onApplied:o,...i}){const{editor:s}=ee(t),[l,a]=y.useState(!1),{isVisible:c,canColorHighlight:u,isActive:d,label:h,Icon:f}=Gc({editor:s,hideWhenUnavailable:r,onApplied:o});return c?g.jsxs(Zg,{open:l,onOpenChange:a,children:[g.jsx(Yg,{asChild:!0,children:g.jsx(Jc,{disabled:!u,"data-active-state":d?"on":"off","data-disabled":!u,"aria-pressed":d,"aria-label":h,tooltip:h,...i,children:g.jsx(f,{className:"tiptap-button-icon"})})}),g.jsx(Xg,{"aria-label":"Text colors and highlights",children:g.jsx(i0,{editor:s,colors:e,textColors:n})})]}):null}const s0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 4C21 3.44772 20.5523 3 20 3C19.4477 3 19 3.44772 19 4V11C19 11.7956 18.6839 12.5587 18.1213 13.1213C17.5587 13.6839 16.7956 14 16 14H6.41421L9.70711 10.7071C10.0976 10.3166 10.0976 9.68342 9.70711 9.29289C9.31658 8.90237 8.68342 8.90237 8.29289 9.29289L3.29289 14.2929C2.90237 14.6834 2.90237 15.3166 3.29289 15.7071L8.29289 20.7071C8.68342 21.0976 9.31658 21.0976 9.70711 20.7071C10.0976 20.3166 10.0976 19.6834 9.70711 19.2929L6.41421 16H16C17.3261 16 18.5979 15.4732 19.5355 14.5355C20.4732 13.5979 21 12.3261 21 11V4Z",fill:"currentColor"})}));s0.displayName="CornerDownLeftIcon";const l0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M14 3C14 2.44772 14.4477 2 15 2H21C21.5523 2 22 2.44772 22 3V9C22 9.55228 21.5523 10 21 10C20.4477 10 20 9.55228 20 9V5.41421L10.7071 14.7071C10.3166 15.0976 9.68342 15.0976 9.29289 14.7071C8.90237 14.3166 8.90237 13.6834 9.29289 13.2929L18.5858 4H15C14.4477 4 14 3.55228 14 3Z",fill:"currentColor"}),g.jsx("path",{d:"M4.29289 7.29289C4.48043 7.10536 4.73478 7 5 7H11C11.5523 7 12 6.55228 12 6C12 5.44772 11.5523 5 11 5H5C4.20435 5 3.44129 5.31607 2.87868 5.87868C2.31607 6.44129 2 7.20435 2 8V19C2 19.7957 2.31607 20.5587 2.87868 21.1213C3.44129 21.6839 4.20435 22 5 22H16C16.7957 22 17.5587 21.6839 18.1213 21.1213C18.6839 20.5587 19 19.7957 19 19V13C19 12.4477 18.5523 12 18 12C17.4477 12 17 12.4477 17 13V19C17 19.2652 16.8946 19.5196 16.7071 19.7071C16.5196 19.8946 16.2652 20 16 20H5C4.73478 20 4.48043 19.8946 4.29289 19.7071C4.10536 19.5196 4 19.2652 4 19V8C4 7.73478 4.10536 7.48043 4.29289 7.29289Z",fill:"currentColor"})]}));l0.displayName="ExternalLinkIcon";const ws=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M16.9958 1.06669C15.4226 1.05302 13.907 1.65779 12.7753 2.75074L12.765 2.76086L11.045 4.47086C10.6534 4.86024 10.6515 5.49341 11.0409 5.88507C11.4303 6.27673 12.0634 6.27858 12.4551 5.88919L14.1697 4.18456C14.9236 3.45893 15.9319 3.05752 16.9784 3.06662C18.0272 3.07573 19.0304 3.49641 19.772 4.23804C20.5137 4.97967 20.9344 5.98292 20.9435 7.03171C20.9526 8.07776 20.5515 9.08563 19.8265 9.83941L16.833 12.8329C16.4274 13.2386 15.9393 13.5524 15.4019 13.7529C14.8645 13.9533 14.2903 14.0359 13.7181 13.9949C13.146 13.9539 12.5894 13.7904 12.0861 13.5154C11.5827 13.2404 11.1444 12.8604 10.8008 12.401C10.47 11.9588 9.84333 11.8685 9.40108 12.1993C8.95883 12.5301 8.86849 13.1568 9.1993 13.599C9.71464 14.288 10.3721 14.858 11.1272 15.2705C11.8822 15.683 12.7171 15.9283 13.5753 15.9898C14.4334 16.0513 15.2948 15.9274 16.1009 15.6267C16.907 15.326 17.639 14.8555 18.2473 14.247L21.2472 11.2471L21.2593 11.2347C22.3523 10.1031 22.9571 8.58751 22.9434 7.01433C22.9297 5.44115 22.2987 3.93628 21.1863 2.82383C20.0738 1.71138 18.5689 1.08036 16.9958 1.06669Z",fill:"currentColor"}),g.jsx("path",{d:"M10.4247 8.0102C9.56657 7.94874 8.70522 8.07256 7.89911 8.37326C7.09305 8.67395 6.36096 9.14458 5.75272 9.753L2.75285 12.7529L2.74067 12.7653C1.64772 13.8969 1.04295 15.4125 1.05662 16.9857C1.07029 18.5589 1.70131 20.0637 2.81376 21.1762C3.9262 22.2886 5.43108 22.9196 7.00426 22.9333C8.57744 22.947 10.0931 22.3422 11.2247 21.2493L11.2371 21.2371L12.9471 19.5271C13.3376 19.1366 13.3376 18.5034 12.9471 18.1129C12.5565 17.7223 11.9234 17.7223 11.5328 18.1129L9.82932 19.8164C9.07555 20.5414 8.06768 20.9425 7.02164 20.9334C5.97285 20.9243 4.9696 20.5036 4.22797 19.762C3.48634 19.0203 3.06566 18.0171 3.05655 16.9683C3.04746 15.9222 3.44851 14.9144 4.17355 14.1606L7.16719 11.167C7.5727 10.7613 8.06071 10.4476 8.59811 10.2471C9.13552 10.0467 9.70976 9.96412 10.2819 10.0051C10.854 10.0461 11.4106 10.2096 11.9139 10.4846C12.4173 10.7596 12.8556 11.1397 13.1992 11.599C13.53 12.0412 14.1567 12.1316 14.5989 11.8007C15.0412 11.4699 15.1315 10.8433 14.8007 10.401C14.2854 9.71205 13.6279 9.14198 12.8729 8.72948C12.1178 8.31697 11.2829 8.07166 10.4247 8.0102Z",fill:"currentColor"})]}));ws.displayName="LinkIcon";const a0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 5V4C7 3.17477 7.40255 2.43324 7.91789 1.91789C8.43324 1.40255 9.17477 1 10 1H14C14.8252 1 15.5668 1.40255 16.0821 1.91789C16.5975 2.43324 17 3.17477 17 4V5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H20V20C20 20.8252 19.5975 21.5668 19.0821 22.0821C18.5668 22.5975 17.8252 23 17 23H7C6.17477 23 5.43324 22.5975 4.91789 22.0821C4.40255 21.5668 4 20.8252 4 20V7H3C2.44772 7 2 6.55228 2 6C2 5.44772 2.44772 5 3 5H7ZM9 4C9 3.82523 9.09745 3.56676 9.33211 3.33211C9.56676 3.09745 9.82523 3 10 3H14C14.1748 3 14.4332 3.09745 14.6679 3.33211C14.9025 3.56676 15 3.82523 15 4V5H9V4ZM6 7V20C6 20.1748 6.09745 20.4332 6.33211 20.6679C6.56676 20.9025 6.82523 21 7 21H17C17.1748 21 17.4332 20.9025 17.6679 20.6679C17.9025 20.4332 18 20.1748 18 20V7H6Z",fill:"currentColor"})}));a0.displayName="TrashIcon";function _E({className:t,type:e,...n}){return g.jsx("input",{type:e,className:Me("tiptap-input",t),...n})}function HE({className:t,children:e,...n}){return g.jsx("div",{className:Me("tiptap-input-group",t),...n,children:e})}const Zc=y.forwardRef(({className:t,children:e,...n},r)=>g.jsx(le,{type:"button",className:t,"data-style":"ghost",role:"button",tabIndex:-1,"aria-label":"Link",tooltip:"Link",ref:r,...n,children:e||g.jsx(ws,{className:"tiptap-button-icon"})}));Zc.displayName="LinkButton";const c0=({url:t,setUrl:e,setLink:n,removeLink:r,openLink:o,isActive:i})=>{const s=mr(),l=a=>{a.key==="Enter"&&(a.preventDefault(),n())};return g.jsx(pr,{style:{...s?{boxShadow:"none",border:0}:{}},children:g.jsx(fo,{style:{...s?{padding:0}:{}},children:g.jsxs(Vi,{orientation:"horizontal",children:[g.jsx(HE,{children:g.jsx(_E,{type:"url",placeholder:"Paste a link...",value:t,onChange:a=>e(a.target.value),onKeyDown:l,autoFocus:!0,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"})}),g.jsx(Tt,{orientation:"horizontal",children:g.jsx(le,{type:"button",onClick:n,title:"Apply link",disabled:!t&&!i,"data-style":"ghost",children:g.jsx(s0,{className:"tiptap-button-icon"})})}),g.jsx(er,{}),g.jsxs(Tt,{orientation:"horizontal",children:[g.jsx(le,{type:"button",onClick:o,title:"Open in new window",disabled:!t&&!i,"data-style":"ghost",children:g.jsx(l0,{className:"tiptap-button-icon"})}),g.jsx(le,{type:"button",onClick:r,title:"Remove link",disabled:!t&&!i,"data-style":"ghost",children:g.jsx(a0,{className:"tiptap-button-icon"})})]})]})})})},FE=({editor:t})=>{const e=h0({editor:t});return g.jsx(c0,{...e})},u0=y.forwardRef(({editor:t,hideWhenUnavailable:e=!1,onSetLink:n,onOpenChange:r,autoOpenOnLinkActive:o=!0,onClick:i,children:s,...l},a)=>{const{editor:c}=ee(t),[u,d]=y.useState(!1),{isVisible:h,canSet:f,isActive:p,url:m,setUrl:v,setLink:b,removeLink:C,openLink:x,label:w,Icon:E}=h0({editor:c,hideWhenUnavailable:e,onSetLink:n}),k=y.useCallback(I=>{d(I),r?.(I)},[r]),S=y.useCallback(()=>{b(),d(!1)},[b]),M=y.useCallback(I=>{i?.(I),!I.defaultPrevented&&d(!u)},[i,u]);return y.useEffect(()=>{o&&p&&d(!0)},[o,p]),h?g.jsxs(Zg,{open:u,onOpenChange:k,children:[g.jsx(Yg,{asChild:!0,children:g.jsx(Zc,{disabled:!f,"data-active-state":p?"on":"off","data-disabled":!f,"aria-label":w,"aria-pressed":p,onClick:M,...l,ref:a,children:s??g.jsx(E,{className:"tiptap-button-icon"})})}),g.jsx(Xg,{children:g.jsx(c0,{url:m,setUrl:v,setLink:S,removeLink:C,openLink:x,isActive:p})})]}):null});u0.displayName="LinkPopover";function d0(t){return!t||!t.isEditable?!1:t.can().setMark("link")}function f0(t){return!t||!t.isEditable?!1:t.isActive("link")}function $E(t){const{editor:e,hideWhenUnavailable:n}=t;return!Dn("link",e)||!e?!1:n&&!e.isActive("code")?d0(e):!0}function VE(t){const{editor:e,onSetLink:n}=t,[r,o]=y.useState(null);y.useEffect(()=>{if(!e)return;const{href:a}=e.getAttributes("link");f0(e)&&r===null&&o(a||"")},[e,r]),y.useEffect(()=>{if(!e)return;const a=()=>{const{href:c}=e.getAttributes("link");o(c||"")};return e.on("selectionUpdate",a),()=>{e.off("selectionUpdate",a)}},[e]);const i=y.useCallback(()=>{if(!r||!e)return;const{selection:a}=e.state,c=a.empty;let u=e.chain().focus();u=u.extendMarkRange("link").setLink({href:r}),c&&(u=u.insertContent({type:"text",text:r})),u.run(),o(null),n?.()},[e,n,r]),s=y.useCallback(()=>{e&&(e.chain().focus().extendMarkRange("link").unsetLink().setMeta("preventAutolink",!0).run(),o(""))},[e]),l=y.useCallback((a="_blank",c="noopener,noreferrer")=>{if(!r)return;const u=a3(r,window.location.href);u!=="#"&&window.open(u,a,c)},[r]);return{url:r||"",setUrl:o,setLink:i,removeLink:s,openLink:l}}function zE(t){const{editor:e,hideWhenUnavailable:n=!1}=t,r=d0(e),o=f0(e),[i,s]=y.useState(!1);return y.useEffect(()=>{if(!e)return;const l=()=>{s($E({editor:e,hideWhenUnavailable:n}))};return l(),e.on("selectionUpdate",l),()=>{e.off("selectionUpdate",l)}},[e,n]),{isVisible:i,canSet:r,isActive:o}}function h0(t){const{editor:e,hideWhenUnavailable:n=!1,onSetLink:r}=t||{},{editor:o}=ee(e),{isVisible:i,canSet:s,isActive:l}=zE({editor:o,hideWhenUnavailable:n}),a=VE({editor:o,onSetLink:r});return{isVisible:i,canSet:s,isActive:l,label:"Link",Icon:ws,...a}}function UE({type:t,shortcutKeys:e=x0[t]}){return g.jsx(bt,{children:gt({shortcutKeys:e})})}const yn=y.forwardRef(({editor:t,type:e,text:n,hideWhenUnavailable:r=!1,onToggled:o,showShortcut:i=!1,onClick:s,children:l,...a},c)=>{const{editor:u}=ee(t),{isVisible:d,handleMark:h,label:f,canToggle:p,isActive:m,Icon:v,shortcutKeys:b}=ZE({editor:u,type:e,hideWhenUnavailable:r,onToggled:o}),C=y.useCallback(x=>{s?.(x),!x.defaultPrevented&&h()},[h,s]);return d?g.jsx(le,{type:"button",disabled:!p,"data-style":"ghost","data-active-state":m?"on":"off","data-disabled":!p,role:"button",tabIndex:-1,"aria-label":f,"aria-pressed":m,tooltip:f,onClick:C,...a,ref:c,children:l??g.jsxs(g.Fragment,{children:[g.jsx(v,{className:"tiptap-button-icon"}),n&&g.jsx("span",{className:"tiptap-button-text",children:n}),i&&g.jsx(UE,{type:e,shortcutKeys:b})]})}):null});yn.displayName="MarkButton";const p0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.5C5.17157 2.5 4.5 3.17157 4.5 4V20C4.5 20.8284 5.17157 21.5 6 21.5H15C16.4587 21.5 17.8576 20.9205 18.8891 19.8891C19.9205 18.8576 20.5 17.4587 20.5 16C20.5 14.5413 19.9205 13.1424 18.8891 12.1109C18.6781 11.9 18.4518 11.7079 18.2128 11.5359C19.041 10.5492 19.5 9.29829 19.5 8C19.5 6.54131 18.9205 5.14236 17.8891 4.11091C16.8576 3.07946 15.4587 2.5 14 2.5H6ZM14 10.5C14.663 10.5 15.2989 10.2366 15.7678 9.76777C16.2366 9.29893 16.5 8.66304 16.5 8C16.5 7.33696 16.2366 6.70107 15.7678 6.23223C15.2989 5.76339 14.663 5.5 14 5.5H7.5V10.5H14ZM7.5 18.5V13.5H15C15.663 13.5 16.2989 13.7634 16.7678 14.2322C17.2366 14.7011 17.5 15.337 17.5 16C17.5 16.663 17.2366 17.2989 16.7678 17.7678C16.2989 18.2366 15.663 18.5 15 18.5H7.5Z",fill:"currentColor"})}));p0.displayName="BoldIcon";const m0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M15.4545 4.2983C15.6192 3.77115 15.3254 3.21028 14.7983 3.04554C14.2712 2.88081 13.7103 3.1746 13.5455 3.70175L8.54554 19.7017C8.38081 20.2289 8.6746 20.7898 9.20175 20.9545C9.72889 21.1192 10.2898 20.8254 10.4545 20.2983L15.4545 4.2983Z",fill:"currentColor"}),g.jsx("path",{d:"M6.70711 7.29289C7.09763 7.68342 7.09763 8.31658 6.70711 8.70711L3.41421 12L6.70711 15.2929C7.09763 15.6834 7.09763 16.3166 6.70711 16.7071C6.31658 17.0976 5.68342 17.0976 5.29289 16.7071L1.29289 12.7071C0.902369 12.3166 0.902369 11.6834 1.29289 11.2929L5.29289 7.29289C5.68342 6.90237 6.31658 6.90237 6.70711 7.29289Z",fill:"currentColor"}),g.jsx("path",{d:"M17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289L22.7071 11.2929C23.0976 11.6834 23.0976 12.3166 22.7071 12.7071L18.7071 16.7071C18.3166 17.0976 17.6834 17.0976 17.2929 16.7071C16.9024 16.3166 16.9024 15.6834 17.2929 15.2929L20.5858 12L17.2929 8.70711C16.9024 8.31658 16.9024 7.68342 17.2929 7.29289Z",fill:"currentColor"})]}));m0.displayName="Code2Icon";const g0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{d:"M15.0222 3H19C19.5523 3 20 3.44772 20 4C20 4.55228 19.5523 5 19 5H15.693L10.443 19H14C14.5523 19 15 19.4477 15 20C15 20.5523 14.5523 21 14 21H9.02418C9.00802 21.0004 8.99181 21.0004 8.97557 21H5C4.44772 21 4 20.5523 4 20C4 19.4477 4.44772 19 5 19H8.30704L13.557 5H10C9.44772 5 9 4.55228 9 4C9 3.44772 9.44772 3 10 3H14.9782C14.9928 2.99968 15.0075 2.99967 15.0222 3Z",fill:"currentColor"})}));g0.displayName="ItalicIcon";const y0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M9.00039 3H16.0001C16.5524 3 17.0001 3.44772 17.0001 4C17.0001 4.55229 16.5524 5 16.0001 5H9.00011C8.68006 4.99983 8.36412 5.07648 8.07983 5.22349C7.79555 5.37051 7.55069 5.5836 7.36585 5.84487C7.181 6.10614 7.06155 6.40796 7.01754 6.72497C6.97352 7.04198 7.00623 7.36492 7.11292 7.66667C7.29701 8.18737 7.02414 8.75872 6.50344 8.94281C5.98274 9.1269 5.4114 8.85403 5.2273 8.33333C5.01393 7.72984 4.94851 7.08396 5.03654 6.44994C5.12456 5.81592 5.36346 5.21229 5.73316 4.68974C6.10285 4.1672 6.59256 3.74101 7.16113 3.44698C7.72955 3.15303 8.36047 2.99975 9.00039 3Z",fill:"currentColor"}),g.jsx("path",{d:"M18 13H20C20.5523 13 21 12.5523 21 12C21 11.4477 20.5523 11 20 11H4C3.44772 11 3 11.4477 3 12C3 12.5523 3.44772 13 4 13H14C14.7956 13 15.5587 13.3161 16.1213 13.8787C16.6839 14.4413 17 15.2044 17 16C17 16.7956 16.6839 17.5587 16.1213 18.1213C15.5587 18.6839 14.7956 19 14 19H6C5.44772 19 5 19.4477 5 20C5 20.5523 5.44772 21 6 21H14C15.3261 21 16.5979 20.4732 17.5355 19.5355C18.4732 18.5979 19 17.3261 19 16C19 14.9119 18.6453 13.8604 18 13Z",fill:"currentColor"})]}));y0.displayName="StrikeIcon";const v0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.4079 14.3995C18.0284 14.0487 18.7506 13.9217 19.4536 14.0397C20.1566 14.1578 20.7977 14.5138 21.2696 15.0481L21.2779 15.0574L21.2778 15.0575C21.7439 15.5988 22 16.2903 22 17C22 18.0823 21.3962 18.8401 20.7744 19.3404C20.194 19.8073 19.4858 20.141 18.9828 20.378C18.9638 20.387 18.9451 20.3958 18.9266 20.4045C18.4473 20.6306 18.2804 20.7817 18.1922 20.918C18.1773 20.9412 18.1619 20.9681 18.1467 21H21C21.5523 21 22 21.4477 22 22C22 22.5523 21.5523 23 21 23H17C16.4477 23 16 22.5523 16 22C16 21.1708 16.1176 20.4431 16.5128 19.832C16.9096 19.2184 17.4928 18.8695 18.0734 18.5956C18.6279 18.334 19.138 18.0901 19.5207 17.7821C19.8838 17.49 20 17.2477 20 17C20 16.7718 19.9176 16.5452 19.7663 16.3672C19.5983 16.1792 19.3712 16.0539 19.1224 16.0121C18.8722 15.9701 18.6152 16.015 18.3942 16.1394C18.1794 16.2628 18.0205 16.4549 17.9422 16.675C17.7572 17.1954 17.1854 17.4673 16.665 17.2822C16.1446 17.0972 15.8728 16.5254 16.0578 16.005C16.2993 15.3259 16.7797 14.7584 17.4039 14.4018L17.4079 14.3995L17.4079 14.3995Z",fill:"currentColor"})]}));v0.displayName="SubscriptIcon";const b0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.405 1.40657C18.0246 1.05456 18.7463 0.92634 19.4492 1.04344C20.1521 1.16054 20.7933 1.51583 21.2652 2.0497L21.2697 2.05469L21.2696 2.05471C21.7431 2.5975 22 3.28922 22 4.00203C22 5.08579 21.3952 5.84326 20.7727 6.34289C20.1966 6.80531 19.4941 7.13675 18.9941 7.37261C18.9714 7.38332 18.9491 7.39383 18.9273 7.40415C18.4487 7.63034 18.2814 7.78152 18.1927 7.91844C18.1778 7.94155 18.1625 7.96834 18.1473 8.00003H21C21.5523 8.00003 22 8.44774 22 9.00003C22 9.55231 21.5523 10 21 10H17C16.4477 10 16 9.55231 16 9.00003C16 8.17007 16.1183 7.44255 16.5138 6.83161C16.9107 6.21854 17.4934 5.86971 18.0728 5.59591C18.6281 5.33347 19.1376 5.09075 19.5208 4.78316C19.8838 4.49179 20 4.25026 20 4.00203C20 3.77192 19.9178 3.54865 19.7646 3.37182C19.5968 3.18324 19.3696 3.05774 19.1205 3.01625C18.8705 2.97459 18.6137 3.02017 18.3933 3.14533C18.1762 3.26898 18.0191 3.45826 17.9406 3.67557C17.7531 4.19504 17.18 4.46414 16.6605 4.27662C16.141 4.0891 15.8719 3.51596 16.0594 2.99649C16.303 2.3219 16.7817 1.76125 17.4045 1.40689L17.405 1.40657Z",fill:"currentColor"})]}));b0.displayName="SuperscriptIcon";const C0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4V10C5 11.8565 5.7375 13.637 7.05025 14.9497C8.36301 16.2625 10.1435 17 12 17C13.8565 17 15.637 16.2625 16.9497 14.9497C18.2625 13.637 19 11.8565 19 10V4C19 3.44772 18.5523 3 18 3C17.4477 3 17 3.44772 17 4V10C17 11.3261 16.4732 12.5979 15.5355 13.5355C14.5979 14.4732 13.3261 15 12 15C10.6739 15 9.40215 14.4732 8.46447 13.5355C7.52678 12.5979 7 11.3261 7 10V4ZM4 19C3.44772 19 3 19.4477 3 20C3 20.5523 3.44772 21 4 21H20C20.5523 21 21 20.5523 21 20C21 19.4477 20.5523 19 20 19H4Z",fill:"currentColor"})}));C0.displayName="UnderlineIcon";const WE={bold:p0,italic:g0,underline:C0,strike:y0,code:m0,superscript:b0,subscript:v0},x0={bold:"mod+b",italic:"mod+i",underline:"mod+u",strike:"mod+shift+s",code:"mod+e",superscript:"mod+.",subscript:"mod+,"};function Yc(t,e){return!t||!t.isEditable||!Dn(e,t)||vt(t,["image"])?!1:t.can().toggleMark(e)}function KE(t,e){return!t||!t.isEditable?!1:t.isActive(e)}function qE(t,e){return!t||!t.isEditable||!Yc(t,e)?!1:t.chain().focus().toggleMark(e).run()}function GE(t){const{editor:e,type:n,hideWhenUnavailable:r}=t;return!e||!e.isEditable||!Dn(n,e)?!1:r&&!e.isActive("code")?Yc(e,n):!0}function JE(t){return t.charAt(0).toUpperCase()+t.slice(1)}function ZE(t){const{editor:e,type:n,hideWhenUnavailable:r=!1,onToggled:o}=t,{editor:i}=ee(e),[s,l]=y.useState(!0),a=Yc(i,n),c=KE(i,n);y.useEffect(()=>{if(!i)return;const d=()=>{l(GE({editor:i,type:n,hideWhenUnavailable:r}))};return d(),i.on("selectionUpdate",d),()=>{i.off("selectionUpdate",d)}},[i,n,r]);const u=y.useCallback(()=>{if(!i)return!1;const d=qE(i,n);return d&&o?.(),d},[i,n,o]);return{isVisible:s,isActive:c,handleMark:u,canToggle:a,label:JE(n),shortcutKeys:x0[n],Icon:WE[n]}}function YE({align:t,shortcutKeys:e=M0[t]}){return g.jsx(bt,{children:gt({shortcutKeys:e})})}const Zn=y.forwardRef(({editor:t,align:e,text:n,hideWhenUnavailable:r=!1,onAligned:o,showShortcut:i=!1,onClick:s,icon:l,children:a,...c},u)=>{const{editor:d}=ee(t),{isVisible:h,handleTextAlign:f,label:p,canAlign:m,isActive:v,Icon:b,shortcutKeys:C}=oM({editor:d,align:e,hideWhenUnavailable:r,onAligned:o}),x=y.useCallback(E=>{s?.(E),!E.defaultPrevented&&f()},[f,s]);if(!h)return null;const w=l??b;return g.jsx(le,{type:"button",disabled:!m,"data-style":"ghost","data-active-state":v?"on":"off","data-disabled":!m,role:"button",tabIndex:-1,"aria-label":p,"aria-pressed":v,tooltip:p,onClick:x,...c,ref:u,children:a??g.jsxs(g.Fragment,{children:[g.jsx(w,{className:"tiptap-button-icon"}),n&&g.jsx("span",{className:"tiptap-button-text",children:n}),i&&g.jsx(YE,{align:e,shortcutKeys:C})]})})});Zn.displayName="TextAlignButton";const w0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 12C6 11.4477 6.44772 11 7 11H17C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13H7C6.44772 13 6 12.5523 6 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 18C4 17.4477 4.44772 17 5 17H19C19.5523 17 20 17.4477 20 18C20 18.5523 19.5523 19 19 19H5C4.44772 19 4 18.5523 4 18Z",fill:"currentColor"})]}));w0.displayName="AlignCenterIcon";const S0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));S0.displayName="AlignJustifyIcon";const k0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H15C15.5523 11 16 11.4477 16 12C16 12.5523 15.5523 13 15 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H17C17.5523 17 18 17.4477 18 18C18 18.5523 17.5523 19 17 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));k0.displayName="AlignLeftIcon";const E0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 18C6 17.4477 6.44772 17 7 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H7C6.44772 19 6 18.5523 6 18Z",fill:"currentColor"})]}));E0.displayName="AlignRightIcon";const M0={left:"mod+shift+l",center:"mod+shift+e",right:"mod+shift+r",justify:"mod+shift+j"},XE={left:k0,center:w0,right:E0,justify:S0},QE={left:"Align left",center:"Align center",right:"Align right",justify:"Align justify"};function Xc(t,e){if(!t||!t.isEditable||!ds(t,"textAlign"))return!1;const{selection:n}=t.state;if(n instanceof B){const r=n.node;return r?(t.extensionManager.extensions.find(s=>s.name==="textAlign")?.options?.types??[]).includes(r.type.name):!1}return vt(t,["image"])?!1:t.can().setTextAlign(e)}function eM(t){return"setTextAlign"in t}function tM(t,e){return!t||!t.isEditable?!1:t.isActive({textAlign:e})}function nM(t,e){if(!t||!t.isEditable||!Xc(t,e))return!1;const n=t.chain().focus();return eM(n)?n.setTextAlign(e).run():!1}function rM(t){const{editor:e,hideWhenUnavailable:n,align:r}=t;return!e||!e.isEditable||!ds(e,"textAlign")?!1:n&&!e.isActive("code")?Xc(e,r):!0}function oM(t){const{editor:e,align:n,hideWhenUnavailable:r=!1,onAligned:o}=t,{editor:i}=ee(e),[s,l]=y.useState(!0),a=Xc(i,n),c=tM(i,n);y.useEffect(()=>{if(!i)return;const d=()=>{l(rM({editor:i,align:n,hideWhenUnavailable:r}))};return d(),i.on("selectionUpdate",d),()=>{i.off("selectionUpdate",d)}},[i,r,n]);const u=y.useCallback(()=>{if(!i)return!1;const d=nM(i,n);return d&&o?.(),d},[i,n,o]);return{isVisible:s,isActive:c,handleTextAlign:u,canAlign:a,label:QE[n],shortcutKeys:M0[n],Icon:XE[n]}}function iM({action:t,shortcutKeys:e=R0[t]}){return g.jsx(bt,{children:gt({shortcutKeys:e})})}const zi=y.forwardRef(({editor:t,action:e,text:n,hideWhenUnavailable:r=!1,onExecuted:o,showShortcut:i=!1,onClick:s,children:l,...a},c)=>{const{editor:u}=ee(t),{isVisible:d,handleAction:h,label:f,canExecute:p,Icon:m,shortcutKeys:v}=uM({editor:u,action:e,hideWhenUnavailable:r,onExecuted:o}),b=y.useCallback(C=>{s?.(C),!C.defaultPrevented&&h()},[h,s]);return d?g.jsx(le,{type:"button",disabled:!p,"data-style":"ghost","data-disabled":!p,role:"button",tabIndex:-1,"aria-label":f,tooltip:f,onClick:b,...a,ref:c,children:l??g.jsxs(g.Fragment,{children:[g.jsx(m,{className:"tiptap-button-icon"}),n&&g.jsx("span",{className:"tiptap-button-text",children:n}),i&&g.jsx(iM,{action:e,shortcutKeys:v})]})}):null});zi.displayName="UndoRedoButton";const T0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.7071 2.29289C15.3166 1.90237 14.6834 1.90237 14.2929 2.29289C13.9024 2.68342 13.9024 3.31658 14.2929 3.70711L17.5858 7H9.5C7.77609 7 6.12279 7.68482 4.90381 8.90381C3.68482 10.1228 3 11.7761 3 13.5C3 14.3536 3.16813 15.1988 3.49478 15.9874C3.82144 16.7761 4.30023 17.4926 4.90381 18.0962C6.12279 19.3152 7.77609 20 9.5 20H13C13.5523 20 14 19.5523 14 19C14 18.4477 13.5523 18 13 18H9.5C8.30653 18 7.16193 17.5259 6.31802 16.682C5.90016 16.2641 5.56869 15.768 5.34254 15.2221C5.1164 14.6761 5 14.0909 5 13.5C5 12.3065 5.47411 11.1619 6.31802 10.318C7.16193 9.47411 8.30653 9 9.5 9H17.5858L14.2929 12.2929C13.9024 12.6834 13.9024 13.3166 14.2929 13.7071C14.6834 14.0976 15.3166 14.0976 15.7071 13.7071L20.7071 8.70711C21.0976 8.31658 21.0976 7.68342 20.7071 7.29289L15.7071 2.29289Z",fill:"currentColor"})}));T0.displayName="Redo2Icon";const A0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 3.70711C10.0976 3.31658 10.0976 2.68342 9.70711 2.29289C9.31658 1.90237 8.68342 1.90237 8.29289 2.29289L3.29289 7.29289C2.90237 7.68342 2.90237 8.31658 3.29289 8.70711L8.29289 13.7071C8.68342 14.0976 9.31658 14.0976 9.70711 13.7071C10.0976 13.3166 10.0976 12.6834 9.70711 12.2929L6.41421 9H14.5C15.0909 9 15.6761 9.1164 16.2221 9.34254C16.768 9.56869 17.2641 9.90016 17.682 10.318C18.0998 10.7359 18.4313 11.232 18.6575 11.7779C18.8836 12.3239 19 12.9091 19 13.5C19 14.0909 18.8836 14.6761 18.6575 15.2221C18.4313 15.768 18.0998 16.2641 17.682 16.682C17.2641 17.0998 16.768 17.4313 16.2221 17.6575C15.6761 17.8836 15.0909 18 14.5 18H11C10.4477 18 10 18.4477 10 19C10 19.5523 10.4477 20 11 20H14.5C15.3536 20 16.1988 19.8319 16.9874 19.5052C17.7761 19.1786 18.4926 18.6998 19.0962 18.0962C19.6998 17.4926 20.1786 16.7761 20.5052 15.9874C20.8319 15.1988 21 14.3536 21 13.5C21 12.6464 20.8319 11.8012 20.5052 11.0126C20.1786 10.2239 19.6998 9.50739 19.0962 8.90381C18.4926 8.30022 17.7761 7.82144 16.9874 7.49478C16.1988 7.16813 15.3536 7 14.5 7H6.41421L9.70711 3.70711Z",fill:"currentColor"})}));A0.displayName="Undo2Icon";const R0={undo:"mod+z",redo:"mod+shift+z"},sM={undo:"Undo",redo:"Redo"},lM={undo:A0,redo:T0};function Qc(t,e){return!t||!t.isEditable||vt(t,["image"])?!1:e==="undo"?t.can().undo():t.can().redo()}function aM(t,e){if(!t||!t.isEditable||!Qc(t,e))return!1;const n=t.chain().focus();return e==="undo"?n.undo().run():n.redo().run()}function cM(t){const{editor:e,hideWhenUnavailable:n,action:r}=t;return!e||!e.isEditable?!1:n&&!e.isActive("code")?Qc(e,r):!0}function uM(t){const{editor:e,action:n,hideWhenUnavailable:r=!1,onExecuted:o}=t,{editor:i}=ee(e),[s,l]=y.useState(!0),a=Qc(i,n);y.useEffect(()=>{if(!i)return;const u=()=>{l(cM({editor:i,hideWhenUnavailable:r,action:n}))};return u(),i.on("transaction",u),()=>{i.off("transaction",u)}},[i,r,n]);const c=y.useCallback(()=>{if(!i)return!1;const u=aM(i,n);return u&&o?.(),u},[i,n,o]);return{isVisible:s,handleAction:c,canExecute:a,label:sM[n],shortcutKeys:R0[n],Icon:lM[n]}}const O0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{d:"M12.7071 5.70711C13.0976 5.31658 13.0976 4.68342 12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289L4.29289 11.2929C3.90237 11.6834 3.90237 12.3166 4.29289 12.7071L11.2929 19.7071C11.6834 20.0976 12.3166 20.0976 12.7071 19.7071C13.0976 19.3166 13.0976 18.6834 12.7071 18.2929L7.41421 13L19 13C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11L7.41421 11L12.7071 5.70711Z",fill:"currentColor"})}));O0.displayName="ArrowLeftIcon";var xl,Ef;function dM(){if(Ef)return xl;Ef=1;var t="Expected a function",e=NaN,n="[object Symbol]",r=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt,a=typeof po=="object"&&po&&po.Object===Object&&po,c=typeof self=="object"&&self&&self.Object===Object&&self,u=a||c||Function("return this")(),d=Object.prototype,h=d.toString,f=Math.max,p=Math.min,m=function(){return u.Date.now()};function v(k,S,M){var I,j,_,U,F,O,H=0,V=!1,L=!1,T=!0;if(typeof k!="function")throw new TypeError(t);S=E(S)||0,C(M)&&(V=!!M.leading,L="maxWait"in M,_=L?f(E(M.maxWait)||0,S):_,T="trailing"in M?!!M.trailing:T);function R(ne){var Ke=I,Ct=j;return I=j=void 0,H=ne,U=k.apply(Ct,Ke),U}function W(ne){return H=ne,F=setTimeout(Y,S),V?R(ne):U}function te(ne){var Ke=ne-O,Ct=ne-H,_n=S-Ke;return L?p(_n,_-Ct):_n}function K(ne){var Ke=ne-O,Ct=ne-H;return O===void 0||Ke>=S||Ke<0||L&&Ct>=_}function Y(){var ne=m();if(K(ne))return We(ne);F=setTimeout(Y,te(ne))}function We(ne){return F=void 0,T&&I?R(ne):(I=j=void 0,U)}function ce(){F!==void 0&&clearTimeout(F),H=0,I=O=j=F=void 0}function ye(){return F===void 0?U:We(m())}function X(){var ne=m(),Ke=K(ne);if(I=arguments,j=this,O=ne,Ke){if(F===void 0)return W(O);if(L)return F=setTimeout(Y,S),R(O)}return F===void 0&&(F=setTimeout(Y,S)),U}return X.cancel=ce,X.flush=ye,X}function b(k,S,M){var I=!0,j=!0;if(typeof k!="function")throw new TypeError(t);return C(M)&&(I="leading"in M?!!M.leading:I,j="trailing"in M?!!M.trailing:j),v(k,S,{leading:I,maxWait:S,trailing:j})}function C(k){var S=typeof k;return!!k&&(S=="object"||S=="function")}function x(k){return!!k&&typeof k=="object"}function w(k){return typeof k=="symbol"||x(k)&&h.call(k)==n}function E(k){if(typeof k=="number")return k;if(w(k))return e;if(C(k)){var S=typeof k.valueOf=="function"?k.valueOf():k;k=C(S)?S+"":S}if(typeof k!="string")return k===0?k:+k;k=k.replace(r,"");var M=i.test(k);return M||s.test(k)?l(k.slice(2),M?2:8):o.test(k)?e:+k}return xl=b,xl}var fM=dM();const hM=Tf(fM),pM=t=>{const e=D.useRef(t);e.current=t,D.useEffect(()=>()=>{e.current()},[])},mM={leading:!1,trailing:!0};function N0(t,e=250,n=[],r=mM){const o=y.useMemo(()=>hM(t,e,r),n);return pM(()=>{o.cancel()}),o}function eu(){const[t,e]=y.useState({width:0,height:0,offsetTop:0,offsetLeft:0,scale:0}),n=N0(()=>{if(typeof window>"u")return;const r=window.visualViewport;if(!r)return;const{width:o=0,height:i=0,offsetTop:s=0,offsetLeft:l=0,scale:a=0}=r;e(c=>o===c.width&&i===c.height&&s===c.offsetTop&&l===c.offsetLeft&&a===c.scale?c:{width:o,height:i,offsetTop:s,offsetLeft:l,scale:a})},200);return y.useEffect(()=>{const r=window.visualViewport;if(r)return r.addEventListener("resize",n),n(),()=>{r.removeEventListener("resize",n)}},[n]),t}const jo={x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0},I0=typeof window>"u",gM=!I0&&typeof ResizeObserver<"u",Ko=()=>!I0;function yM({element:t,enabled:e=!0,throttleMs:n=100,useResizeObserver:r=!0}={}){const[o,i]=y.useState(jo),s=y.useCallback(()=>!e||!Ko()?null:t?typeof t=="string"?document.querySelector(t):"current"in t?t.current:t:document.body,[t,e]),l=N0(()=>{if(!e||!Ko())return;const a=s();if(!a){i(jo);return}const c=a.getBoundingClientRect();i({x:c.x,y:c.y,width:c.width,height:c.height,top:c.top,right:c.right,bottom:c.bottom,left:c.left})},n,[e,s],{leading:!0,trailing:!0});return y.useEffect(()=>{if(!e||!Ko()){i(jo);return}const a=s();if(!a)return;l();const c=[];if(r&&gM){const d=new ResizeObserver(()=>{window.requestAnimationFrame(l)});d.observe(a),c.push(()=>d.disconnect())}const u=()=>l();return window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u,{passive:!0}),c.push(()=>{window.removeEventListener("scroll",u),window.removeEventListener("resize",u)}),()=>{c.forEach(d=>d()),i(jo)}},[e,s,l,r]),o}function vM(t={}){return yM({...t,element:Ko()?document.body:null})}function bM({editor:t,overlayHeight:e=0}){const{height:n}=eu(),r=vM({enabled:!0,throttleMs:100,useResizeObserver:!0});return y.useEffect(()=>{(()=>{if(!t)return;const{state:i,view:s}=t;if(!s.hasFocus())return;const{from:l}=i.selection,a=s.coordsAtPos(l);if(n<r.height&&a&&n-a.top<e){const u=Math.max(n/2,e),d=window.scrollY,f=a.top+d-u;window.scrollTo({top:Math.max(0,f),behavior:"smooth"})}})()},[t,e,n,r.height]),r}const CM=({onHighlighterClick:t,onLinkClick:e,isMobile:n})=>g.jsxs(g.Fragment,{children:[g.jsx(lf,{}),g.jsxs(qt,{children:[g.jsx(zi,{action:"undo"}),g.jsx(zi,{action:"redo"})]}),g.jsx(Gt,{}),g.jsxs(qt,{children:[g.jsx(Bc,{levels:[1,2,3,4],portal:n}),g.jsx(Bg,{types:["bulletList","orderedList","taskList"],portal:n}),g.jsx(Uc,{})]}),g.jsx(Gt,{}),g.jsxs(qt,{children:[g.jsx(yn,{type:"bold"}),g.jsx(yn,{type:"italic"}),g.jsx(yn,{type:"strike"}),g.jsx(yn,{type:"code"}),g.jsx(yn,{type:"underline"}),n?g.jsx(Jc,{onClick:t}):g.jsx(BE,{}),n?g.jsx(Zc,{onClick:e}):g.jsx(u0,{})]}),g.jsx(Gt,{}),g.jsxs(qt,{children:[g.jsx(Zn,{align:"left"}),g.jsx(Zn,{align:"center"}),g.jsx(Zn,{align:"right"}),g.jsx(Zn,{align:"justify"})]}),g.jsx(Gt,{}),g.jsx(qt,{children:g.jsx(_c,{text:"Add"})}),g.jsx(lf,{}),n&&g.jsx(Gt,{})]}),xM=({type:t,onBack:e})=>g.jsxs(g.Fragment,{children:[g.jsx(qt,{children:g.jsxs(le,{"data-style":"ghost",onClick:e,children:[g.jsx(O0,{className:"tiptap-button-icon"}),t==="highlighter"?g.jsx(Cs,{className:"tiptap-button-icon"}):g.jsx(ws,{className:"tiptap-button-icon"})]})}),g.jsx(Gt,{}),t==="highlighter"?g.jsx(i0,{}):g.jsx(FE,{})]});function wM(t){const e=mr(),{height:n}=eu(),[r,o]=D.useState("main"),i=D.useRef(null),s=lx({content:t.value,immediatelyRender:!1,shouldRerenderOnTransaction:!1,onUpdate:({editor:a})=>{a&&t.onChange(a.getHTML())},editorProps:{attributes:{autocomplete:"off",autocorrect:"off",autocapitalize:"off","aria-label":"Main content area, start typing to enter text.",class:"simple-editor"}},extensions:[w3,b3.configure({type:"resizableImage",accept:"image/*",maxSize:1*1024*1024*1024,upload:(a,c,u)=>Promise.resolve(t.onUploadImage?.(a,c,u)||"")}),mm,pm,Qw.configure({horizontalRule:!1,link:{openOnClick:!1,enableClickSelection:!0}}),C3,e7.configure({types:["heading","paragraph","resizableImage"]}),sm,im.configure({nested:!0}),M7.configure({multicolor:!0}),S7,A7,T7,Zw,B7.configure({attributeName:"id",generateID:()=>`tiptap-editor-${t.id||Cx()}`})]}),l=bM({editor:s,overlayHeight:i.current?.getBoundingClientRect().height??0});return D.useEffect(()=>{!e&&r!=="main"&&o("main")},[e,r]),D.useEffect(()=>()=>{s&&s.commands.clearContent()},[s]),g.jsx("div",{className:"simple-editor-wrapper",children:g.jsxs(Za.Provider,{value:{editor:s},children:[g.jsx(yc,{ref:i,style:{...e?{bottom:`calc(100% - ${n-l.y}px)`}:{}},children:r==="main"?g.jsx(CM,{onHighlighterClick:()=>o("highlighter"),onLinkClick:()=>o("link"),isMobile:e}):g.jsx(xM,{type:r==="highlighter"?"highlighter":"link",onBack:()=>o("main")})}),g.jsx(nx,{editor:s,className:"simple-editor-content"})]})})}function SM({shortcutKeys:t=P0}){return g.jsx(bt,{children:gt({shortcutKeys:t})})}const L0=y.forwardRef(({editor:t,text:e,hideWhenUnavailable:n=!1,onToggled:r,showShortcut:o=!1,onClick:i,children:s,...l},a)=>{const{editor:c}=ee(t),{isVisible:u,canToggle:d,isActive:h,handleToggle:f,label:p,shortcutKeys:m,Icon:v}=MM({editor:c,hideWhenUnavailable:n,onToggled:r}),b=y.useCallback(C=>{i?.(C),!C.defaultPrevented&&f()},[f,i]);return u?g.jsx(le,{type:"button","data-style":"ghost","data-active-state":h?"on":"off",role:"button",disabled:!d,"data-disabled":!d,tabIndex:-1,"aria-label":p,"aria-pressed":h,tooltip:"Code Block",onClick:b,...l,ref:a,children:s??g.jsxs(g.Fragment,{children:[g.jsx(v,{className:"tiptap-button-icon"}),e&&g.jsx("span",{className:"tiptap-button-text",children:e}),o&&g.jsx(SM,{shortcutKeys:m})]})}):null});L0.displayName="CodeBlockButton";const D0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.70711 2.29289C7.09763 2.68342 7.09763 3.31658 6.70711 3.70711L4.41421 6L6.70711 8.29289C7.09763 8.68342 7.09763 9.31658 6.70711 9.70711C6.31658 10.0976 5.68342 10.0976 5.29289 9.70711L2.29289 6.70711C1.90237 6.31658 1.90237 5.68342 2.29289 5.29289L5.29289 2.29289C5.68342 1.90237 6.31658 1.90237 6.70711 2.29289Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.2929 2.29289C10.6834 1.90237 11.3166 1.90237 11.7071 2.29289L14.7071 5.29289C15.0976 5.68342 15.0976 6.31658 14.7071 6.70711L11.7071 9.70711C11.3166 10.0976 10.6834 10.0976 10.2929 9.70711C9.90237 9.31658 9.90237 8.68342 10.2929 8.29289L12.5858 6L10.2929 3.70711C9.90237 3.31658 9.90237 2.68342 10.2929 2.29289Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17 4C17 3.44772 17.4477 3 18 3H19C20.6569 3 22 4.34315 22 6V18C22 19.6569 20.6569 21 19 21H5C3.34315 21 2 19.6569 2 18V12C2 11.4477 2.44772 11 3 11C3.55228 11 4 11.4477 4 12V18C4 18.5523 4.44772 19 5 19H19C19.5523 19 20 18.5523 20 18V6C20 5.44772 19.5523 5 19 5H18C17.4477 5 17 4.55228 17 4Z",fill:"currentColor"})]}));D0.displayName="CodeBlockIcon";const P0="mod+alt+c";function tu(t,e=!0){if(!t||!t.isEditable||!Bt("codeBlock",t)||vt(t,["image"]))return!1;if(!e)return t.can().toggleNode("codeBlock","paragraph");try{const r=t.view.state,o=r.selection;if(o.empty||o instanceof z){const i=hn({editor:t,node:r.selection.$anchor.node(1)})?.pos;if(!yt(i))return!1}return!0}catch{return!1}}function kM(t){if(!t||!t.isEditable||!tu(t))return!1;try{const e=t.view;let n=e.state,r=n.tr;if(n.selection.empty||n.selection instanceof z){const l=hn({editor:t,node:n.selection.$anchor.node(1)})?.pos;if(!yt(l))return!1;r=r.setSelection(B.create(n.doc,l)),e.dispatch(r),n=e.state}const o=n.selection;let i=t.chain().focus();if(o instanceof B){const l=o.node.firstChild?.firstChild,a=o.node.lastChild?.lastChild,c=l?o.from+l.nodeSize:o.from+1,u=a?o.to-a.nodeSize:o.to-1;i=i.setTextSelection({from:c,to:u}).clearNodes()}return(t.isActive("codeBlock")?i.setNode("paragraph"):i.toggleNode("codeBlock","paragraph")).run(),t.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function EM(t){const{editor:e,hideWhenUnavailable:n}=t;return!e||!e.isEditable||!Bt("codeBlock",e)?!1:n&&!e.isActive("code")?tu(e):!0}function MM(t){const{editor:e,hideWhenUnavailable:n=!1,onToggled:r}=t||{},{editor:o}=ee(e),[i,s]=y.useState(!0),l=tu(o),a=o?.isActive("codeBlock")||!1;y.useEffect(()=>{if(!o)return;const u=()=>{s(EM({editor:o,hideWhenUnavailable:n}))};return u(),o.on("selectionUpdate",u),()=>{o.off("selectionUpdate",u)}},[o,n]);const c=y.useCallback(()=>{if(!o)return!1;const u=kM(o);return u&&r?.(),u},[o,r]);return{isVisible:i,isActive:a,handleToggle:c,canToggle:l,label:"Code Block",shortcutKeys:P0,Icon:D0}}exports.BlockquoteButton=Uc;exports.Button=le;exports.Card=pr;exports.CodeBlockButton=L0;exports.HeadingDropdownMenu=Bc;exports.ImageUploadButton=_c;exports.ListDropdownMenu=Bg;exports.MAX_FILE_SIZE=ua;exports.MarkButton=yn;exports.TextAlignButton=Zn;exports.TiptapEditor=wM;exports.Toolbar=yc;exports.ToolbarGroup=qt;exports.ToolbarSeparator=Gt;exports.UndoRedoButton=zi;exports.onUploadImage=i3;exports.useIsMobile=mr;exports.useTiptapEditor=ee;exports.useWindowSize=eu;
216
+ `)},Ck=0,Wn=[];function xk(t){var e=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),o=y.useState(Ck++)[0],i=y.useState(K1)[0],s=y.useRef(t);y.useEffect(function(){s.current=t},[t]),y.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var m=V3([t.lockRef.current],(t.shards||[]).map(Rf),!0).filter(Boolean);return m.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var l=y.useCallback(function(m,v){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!s.current.allowPinchZoom;var b=jo(m),C=n.current,x="deltaX"in m?m.deltaX:C[0]-b[0],w="deltaY"in m?m.deltaY:C[1]-b[1],E,S=m.target,k=Math.abs(x)>Math.abs(w)?"h":"v";if("touches"in m&&k==="h"&&S.type==="range")return!1;var M=Tf(k,S);if(!M)return!0;if(M?E=k:(E=k==="v"?"h":"v",M=Tf(k,S)),!M)return!1;if(!r.current&&"changedTouches"in m&&(x||w)&&(r.current=E),!E)return!0;var I=r.current||E;return yk(I,v,m,I==="h"?x:w)},[]),a=y.useCallback(function(m){var v=m;if(!(!Wn.length||Wn[Wn.length-1]!==i)){var b="deltaY"in v?Af(v):jo(v),C=e.current.filter(function(E){return E.name===v.type&&(E.target===v.target||v.target===E.shadowParent)&&vk(E.delta,b)})[0];if(C&&C.should){v.cancelable&&v.preventDefault();return}if(!C){var x=(s.current.shards||[]).map(Rf).filter(Boolean).filter(function(E){return E.contains(v.target)}),w=x.length>0?l(v,x[0]):!s.current.noIsolation;w&&v.cancelable&&v.preventDefault()}}},[]),c=y.useCallback(function(m,v,b,C){var x={name:m,delta:v,target:b,should:C,shadowParent:wk(b)};e.current.push(x),setTimeout(function(){e.current=e.current.filter(function(w){return w!==x})},1)},[]),u=y.useCallback(function(m){n.current=jo(m),r.current=void 0},[]),d=y.useCallback(function(m){c(m.type,Af(m),m.target,l(m,t.lockRef.current))},[]),h=y.useCallback(function(m){c(m.type,jo(m),m.target,l(m,t.lockRef.current))},[]);y.useEffect(function(){return Wn.push(i),t.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:h}),document.addEventListener("wheel",a,Un),document.addEventListener("touchmove",a,Un),document.addEventListener("touchstart",u,Un),function(){Wn=Wn.filter(function(m){return m!==i}),document.removeEventListener("wheel",a,Un),document.removeEventListener("touchmove",a,Un),document.removeEventListener("touchstart",u,Un)}},[]);var f=t.removeScrollBar,p=t.inert;return y.createElement(y.Fragment,null,p?y.createElement(i,{styles:bk(o)}):null,f?y.createElement(uk,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function wk(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const Sk=Y3(W1,xk);var Oc=y.forwardRef(function(t,e){return y.createElement(ps,ct({},t,{ref:e,sideCar:Sk}))});Oc.classNames=ps.classNames;var pa=["Enter"," "],kk=["ArrowDown","PageUp","Home"],Z1=["ArrowUp","PageDown","End"],Ek=[...kk,...Z1],Mk={ltr:[...pa,"ArrowRight"],rtl:[...pa,"ArrowLeft"]},Tk={ltr:["ArrowLeft"],rtl:["ArrowRight"]},fo="Menu",[eo,Ak,Rk]=g1(fo),[jn,Y1]=pr(fo,[Rk,hs,j1]),ms=hs(),X1=j1(),[Ok,Bn]=jn(fo),[Nk,ho]=jn(fo),Q1=t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:o,onOpenChange:i,modal:s=!0}=t,l=ms(e),[a,c]=y.useState(null),u=y.useRef(!1),d=Pt(i),h=y1(o);return y.useEffect(()=>{const f=()=>{u.current=!0,document.addEventListener("pointerdown",p,{capture:!0,once:!0}),document.addEventListener("pointermove",p,{capture:!0,once:!0})},p=()=>u.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",p,{capture:!0}),document.removeEventListener("pointermove",p,{capture:!0})}},[]),g.jsx(I1,{...l,children:g.jsx(Ok,{scope:e,open:n,onOpenChange:d,content:a,onContentChange:c,children:g.jsx(Nk,{scope:e,onClose:y.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:h,modal:s,children:r})})})};Q1.displayName=fo;var Ik="MenuAnchor",Nc=y.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,o=ms(n);return g.jsx(Ac,{...o,...r,ref:e})});Nc.displayName=Ik;var Ic="MenuPortal",[Lk,eg]=jn(Ic,{forceMount:void 0}),tg=t=>{const{__scopeMenu:e,forceMount:n,children:r,container:o}=t,i=Bn(Ic,e);return g.jsx(Lk,{scope:e,forceMount:n,children:g.jsx(Pn,{present:n||i.open,children:g.jsx(Rc,{asChild:!0,container:o,children:r})})})};tg.displayName=Ic;var et="MenuContent",[Dk,Lc]=jn(et),ng=y.forwardRef((t,e)=>{const n=eg(et,t.__scopeMenu),{forceMount:r=n.forceMount,...o}=t,i=Bn(et,t.__scopeMenu),s=ho(et,t.__scopeMenu);return g.jsx(eo.Provider,{scope:t.__scopeMenu,children:g.jsx(Pn,{present:r||i.open,children:g.jsx(eo.Slot,{scope:t.__scopeMenu,children:s.modal?g.jsx(Pk,{...o,ref:e}):g.jsx(jk,{...o,ref:e})})})})}),Pk=y.forwardRef((t,e)=>{const n=Bn(et,t.__scopeMenu),r=y.useRef(null),o=Oe(e,r);return y.useEffect(()=>{const i=r.current;if(i)return V1(i)},[]),g.jsx(Dc,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:J(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),jk=y.forwardRef((t,e)=>{const n=Bn(et,t.__scopeMenu);return g.jsx(Dc,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Bk=Qr("MenuContent.ScrollLock"),Dc=y.forwardRef((t,e)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:l,onEntryFocus:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:f,disableOutsideScroll:p,...m}=t,v=Bn(et,n),b=ho(et,n),C=ms(n),x=X1(n),w=Ak(n),[E,S]=y.useState(null),k=y.useRef(null),M=Oe(e,k,v.onContentChange),I=y.useRef(0),P=y.useRef(""),_=y.useRef(0),U=y.useRef(null),F=y.useRef("right"),O=y.useRef(0),H=p?Oc:y.Fragment,V=p?{as:Bk,allowPinchZoom:!0}:void 0,D=R=>{const W=P.current+R,ne=w().filter(Q=>!Q.disabled),K=document.activeElement,X=ne.find(Q=>Q.ref.current===K)?.textValue,We=ne.map(Q=>Q.textValue),ce=Jk(We,W,X),ye=ne.find(Q=>Q.textValue===ce)?.ref.current;(function Q(re){P.current=re,window.clearTimeout(I.current),re!==""&&(I.current=window.setTimeout(()=>Q(""),1e3))})(W),ye&&setTimeout(()=>ye.focus())};y.useEffect(()=>()=>window.clearTimeout(I.current),[]),C1();const T=y.useCallback(R=>F.current===U.current?.side&&Yk(R,U.current?.area),[]);return g.jsx(Dk,{scope:n,searchRef:P,onItemEnter:y.useCallback(R=>{T(R)&&R.preventDefault()},[T]),onItemLeave:y.useCallback(R=>{T(R)||(k.current?.focus(),S(null))},[T]),onTriggerLeave:y.useCallback(R=>{T(R)&&R.preventDefault()},[T]),pointerGraceTimerRef:_,onPointerGraceIntentChange:y.useCallback(R=>{U.current=R},[]),children:g.jsx(H,{...V,children:g.jsx(Ec,{asChild:!0,trapped:o,onMountAutoFocus:J(i,R=>{R.preventDefault(),k.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:g.jsx(kc,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:f,children:g.jsx(B3,{asChild:!0,...x,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:S,onEntryFocus:J(a,R=>{b.isUsingKeyboardRef.current||R.preventDefault()}),preventScrollOnEntryFocus:!0,children:g.jsx(L1,{role:"menu","aria-orientation":"vertical","data-state":vg(v.open),"data-radix-menu-content":"",dir:b.dir,...C,...m,ref:M,style:{outline:"none",...m.style},onKeyDown:J(m.onKeyDown,R=>{const ne=R.target.closest("[data-radix-menu-content]")===R.currentTarget,K=R.ctrlKey||R.altKey||R.metaKey,X=R.key.length===1;ne&&(R.key==="Tab"&&R.preventDefault(),!K&&X&&D(R.key));const We=k.current;if(R.target!==We||!Ek.includes(R.key))return;R.preventDefault();const ye=w().filter(Q=>!Q.disabled).map(Q=>Q.ref.current);Z1.includes(R.key)&&ye.reverse(),qk(ye)}),onBlur:J(t.onBlur,R=>{R.currentTarget.contains(R.target)||(window.clearTimeout(I.current),P.current="")}),onPointerMove:J(t.onPointerMove,to(R=>{const W=R.target,ne=O.current!==R.clientX;if(R.currentTarget.contains(W)&&ne){const K=R.clientX>O.current?"right":"left";F.current=K,O.current=R.clientX}}))})})})})})})});ng.displayName=et;var _k="MenuGroup",Pc=y.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Te.div,{role:"group",...r,ref:e})});Pc.displayName=_k;var Hk="MenuLabel",rg=y.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Te.div,{...r,ref:e})});rg.displayName=Hk;var $i="MenuItem",Of="menu.itemSelect",gs=y.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:r,...o}=t,i=y.useRef(null),s=ho($i,t.__scopeMenu),l=Lc($i,t.__scopeMenu),a=Oe(e,i),c=y.useRef(!1),u=()=>{const d=i.current;if(!n&&d){const h=new CustomEvent(Of,{bubbles:!0,cancelable:!0});d.addEventListener(Of,f=>r?.(f),{once:!0}),m1(d,h),h.defaultPrevented?c.current=!1:s.onClose()}};return g.jsx(og,{...o,ref:a,disabled:n,onClick:J(t.onClick,u),onPointerDown:d=>{t.onPointerDown?.(d),c.current=!0},onPointerUp:J(t.onPointerUp,d=>{c.current||d.currentTarget?.click()}),onKeyDown:J(t.onKeyDown,d=>{const h=l.searchRef.current!=="";n||h&&d.key===" "||pa.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});gs.displayName=$i;var og=y.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...i}=t,s=Lc($i,n),l=X1(n),a=y.useRef(null),c=Oe(e,a),[u,d]=y.useState(!1),[h,f]=y.useState("");return y.useEffect(()=>{const p=a.current;p&&f((p.textContent??"").trim())},[i.children]),g.jsx(eo.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:g.jsx(_3,{asChild:!0,...l,focusable:!r,children:g.jsx(Te.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:c,onPointerMove:J(t.onPointerMove,to(p=>{r?s.onItemLeave(p):(s.onItemEnter(p),p.defaultPrevented||p.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:J(t.onPointerLeave,to(p=>s.onItemLeave(p))),onFocus:J(t.onFocus,()=>d(!0)),onBlur:J(t.onBlur,()=>d(!1))})})})}),Fk="MenuCheckboxItem",ig=y.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:r,...o}=t;return g.jsx(ug,{scope:t.__scopeMenu,checked:n,children:g.jsx(gs,{role:"menuitemcheckbox","aria-checked":Vi(n)?"mixed":n,...o,ref:e,"data-state":Bc(n),onSelect:J(o.onSelect,()=>r?.(Vi(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ig.displayName=Fk;var sg="MenuRadioGroup",[$k,Vk]=jn(sg,{value:void 0,onValueChange:()=>{}}),lg=y.forwardRef((t,e)=>{const{value:n,onValueChange:r,...o}=t,i=Pt(r);return g.jsx($k,{scope:t.__scopeMenu,value:n,onValueChange:i,children:g.jsx(Pc,{...o,ref:e})})});lg.displayName=sg;var ag="MenuRadioItem",cg=y.forwardRef((t,e)=>{const{value:n,...r}=t,o=Vk(ag,t.__scopeMenu),i=n===o.value;return g.jsx(ug,{scope:t.__scopeMenu,checked:i,children:g.jsx(gs,{role:"menuitemradio","aria-checked":i,...r,ref:e,"data-state":Bc(i),onSelect:J(r.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});cg.displayName=ag;var jc="MenuItemIndicator",[ug,zk]=jn(jc,{checked:!1}),dg=y.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:r,...o}=t,i=zk(jc,n);return g.jsx(Pn,{present:r||Vi(i.checked)||i.checked===!0,children:g.jsx(Te.span,{...o,ref:e,"data-state":Bc(i.checked)})})});dg.displayName=jc;var Uk="MenuSeparator",fg=y.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Te.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});fg.displayName=Uk;var Wk="MenuArrow",hg=y.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,o=ms(n);return g.jsx(D1,{...o,...r,ref:e})});hg.displayName=Wk;var Kk="MenuSub",[$M,pg]=jn(Kk),Er="MenuSubTrigger",mg=y.forwardRef((t,e)=>{const n=Bn(Er,t.__scopeMenu),r=ho(Er,t.__scopeMenu),o=pg(Er,t.__scopeMenu),i=Lc(Er,t.__scopeMenu),s=y.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:a}=i,c={__scopeMenu:t.__scopeMenu},u=y.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return y.useEffect(()=>u,[u]),y.useEffect(()=>{const d=l.current;return()=>{window.clearTimeout(d),a(null)}},[l,a]),g.jsx(Nc,{asChild:!0,...c,children:g.jsx(og,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":vg(n.open),...t,ref:fs(e,o.onTriggerChange),onClick:d=>{t.onClick?.(d),!(t.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:J(t.onPointerMove,to(d=>{i.onItemEnter(d),!d.defaultPrevented&&!t.disabled&&!n.open&&!s.current&&(i.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:J(t.onPointerLeave,to(d=>{u();const h=n.content?.getBoundingClientRect();if(h){const f=n.content?.dataset.side,p=f==="right",m=p?-5:5,v=h[p?"left":"right"],b=h[p?"right":"left"];i.onPointerGraceIntentChange({area:[{x:d.clientX+m,y:d.clientY},{x:v,y:h.top},{x:b,y:h.top},{x:b,y:h.bottom},{x:v,y:h.bottom}],side:f}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(d),d.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:J(t.onKeyDown,d=>{const h=i.searchRef.current!=="";t.disabled||h&&d.key===" "||Mk[r.dir].includes(d.key)&&(n.onOpenChange(!0),n.content?.focus(),d.preventDefault())})})})});mg.displayName=Er;var gg="MenuSubContent",yg=y.forwardRef((t,e)=>{const n=eg(et,t.__scopeMenu),{forceMount:r=n.forceMount,...o}=t,i=Bn(et,t.__scopeMenu),s=ho(et,t.__scopeMenu),l=pg(gg,t.__scopeMenu),a=y.useRef(null),c=Oe(e,a);return g.jsx(eo.Provider,{scope:t.__scopeMenu,children:g.jsx(Pn,{present:r||i.open,children:g.jsx(eo.Slot,{scope:t.__scopeMenu,children:g.jsx(Dc,{id:l.contentId,"aria-labelledby":l.triggerId,...o,ref:c,align:"start",side:s.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{s.isUsingKeyboardRef.current&&a.current?.focus(),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:J(t.onFocusOutside,u=>{u.target!==l.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:J(t.onEscapeKeyDown,u=>{s.onClose(),u.preventDefault()}),onKeyDown:J(t.onKeyDown,u=>{const d=u.currentTarget.contains(u.target),h=Tk[s.dir].includes(u.key);d&&h&&(i.onOpenChange(!1),l.trigger?.focus(),u.preventDefault())})})})})})});yg.displayName=gg;function vg(t){return t?"open":"closed"}function Vi(t){return t==="indeterminate"}function Bc(t){return Vi(t)?"indeterminate":t?"checked":"unchecked"}function qk(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function Gk(t,e){return t.map((n,r)=>t[(e+r)%t.length])}function Jk(t,e,n){const o=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,i=n?t.indexOf(n):-1;let s=Gk(t,Math.max(i,0));o.length===1&&(s=s.filter(c=>c!==n));const a=s.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return a!==n?a:void 0}function Zk(t,e){const{x:n,y:r}=t;let o=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){const l=e[i],a=e[s],c=l.x,u=l.y,d=a.x,h=a.y;u>r!=h>r&&n<(d-c)*(r-u)/(h-u)+c&&(o=!o)}return o}function Yk(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return Zk(n,e)}function to(t){return e=>e.pointerType==="mouse"?t(e):void 0}var Xk=Q1,Qk=Nc,e9=tg,t9=ng,n9=Pc,r9=rg,o9=gs,i9=ig,s9=lg,l9=cg,a9=dg,c9=fg,u9=hg,d9=mg,f9=yg,ys="DropdownMenu",[h9]=pr(ys,[Y1]),Be=Y1(),[p9,bg]=h9(ys),Cg=t=>{const{__scopeDropdownMenu:e,children:n,dir:r,open:o,defaultOpen:i,onOpenChange:s,modal:l=!0}=t,a=Be(e),c=y.useRef(null),[u,d]=Sc({prop:o,defaultProp:i??!1,onChange:s,caller:ys});return g.jsx(p9,{scope:e,triggerId:Fi(),triggerRef:c,contentId:Fi(),open:u,onOpenChange:d,onOpenToggle:y.useCallback(()=>d(h=>!h),[d]),modal:l,children:g.jsx(Xk,{...a,open:u,onOpenChange:d,dir:r,modal:l,children:n})})};Cg.displayName=ys;var xg="DropdownMenuTrigger",wg=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=t,i=bg(xg,n),s=Be(n);return g.jsx(Qk,{asChild:!0,...s,children:g.jsx(Te.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:fs(e,i.triggerRef),onPointerDown:J(t.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(i.onOpenToggle(),i.open||l.preventDefault())}),onKeyDown:J(t.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&i.onOpenToggle(),l.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});wg.displayName=xg;var m9="DropdownMenuPortal",Sg=t=>{const{__scopeDropdownMenu:e,...n}=t,r=Be(e);return g.jsx(e9,{...r,...n})};Sg.displayName=m9;var kg="DropdownMenuContent",Eg=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=bg(kg,n),i=Be(n),s=y.useRef(!1);return g.jsx(t9,{id:o.contentId,"aria-labelledby":o.triggerId,...i,...r,ref:e,onCloseAutoFocus:J(t.onCloseAutoFocus,l=>{s.current||o.triggerRef.current?.focus(),s.current=!1,l.preventDefault()}),onInteractOutside:J(t.onInteractOutside,l=>{const a=l.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0,u=a.button===2||c;(!o.modal||u)&&(s.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Eg.displayName=kg;var g9="DropdownMenuGroup",y9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(n9,{...o,...r,ref:e})});y9.displayName=g9;var v9="DropdownMenuLabel",b9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(r9,{...o,...r,ref:e})});b9.displayName=v9;var C9="DropdownMenuItem",Mg=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(o9,{...o,...r,ref:e})});Mg.displayName=C9;var x9="DropdownMenuCheckboxItem",w9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(i9,{...o,...r,ref:e})});w9.displayName=x9;var S9="DropdownMenuRadioGroup",k9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(s9,{...o,...r,ref:e})});k9.displayName=S9;var E9="DropdownMenuRadioItem",M9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(l9,{...o,...r,ref:e})});M9.displayName=E9;var T9="DropdownMenuItemIndicator",A9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(a9,{...o,...r,ref:e})});A9.displayName=T9;var R9="DropdownMenuSeparator",O9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(c9,{...o,...r,ref:e})});O9.displayName=R9;var N9="DropdownMenuArrow",I9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(u9,{...o,...r,ref:e})});I9.displayName=N9;var L9="DropdownMenuSubTrigger",D9=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(d9,{...o,...r,ref:e})});D9.displayName=L9;var P9="DropdownMenuSubContent",Tg=y.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Be(n);return g.jsx(f9,{...o,...r,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Tg.displayName=P9;var j9=Cg,Ag=wg,B9=Sg,Rg=Eg,_9=Mg,Og=Tg;function Ng({...t}){return g.jsx(j9,{modal:!1,...t})}function Ig({container:t,...e}){const n=bc();return g.jsx(B9,{container:t??n??void 0,...e})}const _c=y.forwardRef(({...t},e)=>g.jsx(Ag,{ref:e,...t}));_c.displayName=Ag.displayName;const Lg=_9,H9=y.forwardRef(({className:t,portal:e=!0,...n},r)=>{const o=g.jsx(Og,{ref:r,className:Me("tiptap-dropdown-menu",t),...n});return e?g.jsx(Ig,{...typeof e=="object"?e:{},children:o}):o});H9.displayName=Og.displayName;const Hc=y.forwardRef(({className:t,sideOffset:e=4,portal:n=!1,...r},o)=>{const i=g.jsx(Rg,{ref:o,sideOffset:e,onCloseAutoFocus:s=>s.preventDefault(),className:Me("tiptap-dropdown-menu",t),...r});return n?g.jsx(Ig,{...typeof n=="object"?n:{},children:i}):i});Hc.displayName=Rg.displayName;const _n=y.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:Me("tiptap-card",t),...e}));_n.displayName="Card";const F9=y.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:Me("tiptap-card-header",t),...e}));F9.displayName="CardHeader";const mr=y.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:Me("tiptap-card-body",t),...e}));mr.displayName="CardBody";const no=y.forwardRef(({className:t,orientation:e="vertical",...n},r)=>g.jsx("div",{ref:r,"data-orientation":e,className:Me("tiptap-card-item-group",t),...n}));no.displayName="CardItemGroup";const $9=y.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:Me("tiptap-card-group-label",t),...e}));$9.displayName="CardGroupLabel";const V9=y.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:Me("tiptap-card-footer",t),...e}));V9.displayName="CardFooter";const Fc=y.forwardRef(({editor:t,levels:e=[1,2,3,4,5,6],hideWhenUnavailable:n=!1,portal:r=!1,onOpenChange:o,...i},s)=>{const{editor:l}=Y(t),[a,c]=y.useState(!1),{isVisible:u,isActive:d,canToggle:h,Icon:f}=U9({editor:l,levels:e,hideWhenUnavailable:n}),p=y.useCallback(m=>{!l||!h||(c(m),o?.(m))},[h,l,o]);return u?g.jsxs(Ng,{modal:!0,open:a,onOpenChange:p,children:[g.jsx(_c,{asChild:!0,children:g.jsxs(se,{type:"button","data-style":"ghost","data-active-state":d?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":"Format text as heading","aria-pressed":d,tooltip:"Heading",...i,ref:s,children:[g.jsx(f,{className:"tiptap-button-icon"}),g.jsx(xc,{className:"tiptap-button-dropdown-small"})]})}),g.jsx(Hc,{align:"start",portal:r,children:g.jsx(_n,{children:g.jsx(mr,{children:g.jsx(ft,{children:e.map(m=>g.jsx(Lg,{asChild:!0,children:g.jsx(i1,{editor:l,level:m,text:`Heading ${m}`,showTooltip:!1})},`heading-${m}`))})})})})]}):null});Fc.displayName="HeadingDropdownMenu";const Dg=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{d:"M6 3C6.55228 3 7 3.44772 7 4V11H17V4C17 3.44772 17.4477 3 18 3C18.5523 3 19 3.44772 19 4V20C19 20.5523 18.5523 21 18 21C17.4477 21 17 20.5523 17 20V13H7V20C7 20.5523 6.55228 21 6 21C5.44772 21 5 20.5523 5 20V4C5 3.44772 5.44772 3 6 3Z",fill:"currentColor"})}));Dg.displayName="HeadingIcon";function z9(t,e=[1,2,3,4,5,6]){if(!(!t||!t.isEditable))return e.find(n=>wc(t,n))}function U9(t){const{editor:e,levels:n=[1,2,3,4,5,6],hideWhenUnavailable:r=!1}=t||{},{editor:o}=Y(e),[i,s]=y.useState(!0),l=z9(o,n),a=wc(o),c=Xr(o);return y.useEffect(()=>{if(!o)return;const u=()=>{s(p1({editor:o,hideWhenUnavailable:r,level:n}))};return u(),o.on("selectionUpdate",u),()=>{o.off("selectionUpdate",u)}},[o,r,n]),{isVisible:i,activeLevel:l,isActive:a,canToggle:c,levels:n,label:"Heading",Icon:l?f1[l]:Dg}}function W9({shortcutKeys:t=ma}){return g.jsx(Ct,{children:yt({shortcutKeys:t})})}const $c=y.forwardRef(({editor:t,text:e,hideWhenUnavailable:n=!1,onInserted:r,showShortcut:o=!1,onClick:i,children:s,...l},a)=>{const{editor:c}=Y(t),{isVisible:u,canInsert:d,handleImage:h,label:f,isActive:p,shortcutKeys:m,Icon:v}=uE({editor:c,hideWhenUnavailable:n,onInserted:r}),b=y.useCallback(C=>{i?.(C),!C.defaultPrevented&&h()},[h,i]);return u?g.jsx(se,{type:"button","data-style":"ghost","data-active-state":p?"on":"off",role:"button",tabIndex:-1,disabled:!d,"data-disabled":!d,"aria-label":f,"aria-pressed":p,tooltip:f,onClick:b,...l,ref:a,children:s??g.jsxs(g.Fragment,{children:[g.jsx(v,{className:"tiptap-button-icon"}),e&&g.jsx("span",{className:"tiptap-button-text",children:e}),o&&g.jsx(W9,{shortcutKeys:m})]})}):null});$c.displayName="ImageUploadButton";const Pg=["shift","alt","meta","mod","ctrl","control"],K9={esc:"escape",return:"enter",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function on(t){return(K9[t.trim()]||t.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function jg(t){return Pg.includes(t)}function bl(t,e=","){return t.toLowerCase().split(e)}function Cl(t,e="+",n=">",r=!1,o){let i=[],s=!1;t=t.trim(),t.includes(n)?(s=!0,i=t.toLocaleLowerCase().split(n).map(c=>on(c))):i=t.toLocaleLowerCase().split(e).map(c=>on(c));const l={alt:i.includes("alt"),ctrl:i.includes("ctrl")||i.includes("control"),shift:i.includes("shift"),meta:i.includes("meta"),mod:i.includes("mod"),useKey:r},a=i.filter(c=>!Pg.includes(c));return{...l,keys:a,description:o,isSequence:s,hotkey:t}}typeof document<"u"&&(document.addEventListener("keydown",t=>{t.code!==void 0&&Bg([on(t.code)])}),document.addEventListener("keyup",t=>{t.code!==void 0&&_g([on(t.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{At.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{At.clear()},0)}));const At=new Set;function Vc(t){return Array.isArray(t)}function q9(t,e=","){return(Vc(t)?t:t.split(e)).every(n=>At.has(n.trim().toLowerCase()))}function Bg(t){const e=Array.isArray(t)?t:[t];At.has("meta")&&At.forEach(n=>!jg(n)&&At.delete(n.toLowerCase())),e.forEach(n=>At.add(n.toLowerCase()))}function _g(t){const e=Array.isArray(t)?t:[t];t==="meta"?At.clear():e.forEach(n=>At.delete(n.toLowerCase()))}function G9(t,e,n){(typeof n=="function"&&n(t,e)||n===!0)&&t.preventDefault()}function J9(t,e,n){return typeof n=="function"?n(t,e):n===!0||n===void 0}const Z9=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Y9(t){return Hg(t,Z9)}function Hg(t,e=!1){const{target:n,composed:r}=t;let o,i;return X9(n)&&r?(o=t.composedPath()[0]&&t.composedPath()[0].tagName,i=t.composedPath()[0]&&t.composedPath()[0].role):(o=n&&n.tagName,i=n&&n.role),Vc(e)?!!(o&&e&&e.some(s=>s.toLowerCase()===o.toLowerCase()||s===i)):!!(o&&e&&e)}function X9(t){return!!t.tagName&&!t.tagName.startsWith("-")&&t.tagName.includes("-")}function Q9(t,e){return t.length===0&&e?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):e?t.some(n=>e.includes(n))||t.includes("*"):!0}const eE=(t,e,n=!1)=>{const{alt:r,meta:o,mod:i,shift:s,ctrl:l,keys:a,useKey:c}=e,{code:u,key:d,ctrlKey:h,metaKey:f,shiftKey:p,altKey:m}=t,v=on(u);if(c&&a?.length===1&&a.includes(d))return!0;if(!a?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!n){if(r!==m&&v!=="alt"||s!==p&&v!=="shift")return!1;if(i){if(!f&&!h)return!1}else if(o!==f&&v!=="meta"&&v!=="os"||l!==h&&v!=="ctrl"&&v!=="control")return!1}return a&&a.length===1&&a.includes(v)?!0:a?q9(a):!a},tE=L.createContext(void 0),nE=()=>L.useContext(tE);function Fg(t,e){return t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(t).length===Object.keys(e).length&&Object.keys(t).reduce((n,r)=>n&&Fg(t[r],e[r]),!0):t===e}const rE=L.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),oE=()=>L.useContext(rE);function iE(t){const e=L.useRef(void 0);return Fg(e.current,t)||(e.current=t),e.current}const Nf=t=>{t.stopPropagation(),t.preventDefault(),t.stopImmediatePropagation()},sE=typeof window<"u"?L.useLayoutEffect:L.useEffect;function $g(t,e,n,r){const o=L.useRef(null),i=L.useRef(!1),s=Array.isArray(n)?Array.isArray(r)?void 0:r:n,l=Vc(t)?t.join(s?.delimiter):t,a=Array.isArray(n)?n:Array.isArray(r)?r:void 0,c=L.useCallback(e,a??[]),u=L.useRef(c);a?u.current=c:u.current=e;const d=iE(s),{activeScopes:h}=oE(),f=nE();return sE(()=>{if(d?.enabled===!1||!Q9(h,d?.scopes))return;let p=[],m;const v=(w,E=!1)=>{if(!(Y9(w)&&!Hg(w,d?.enableOnFormTags))){if(o.current!==null){const S=o.current.getRootNode();if((S instanceof Document||S instanceof ShadowRoot)&&S.activeElement!==o.current&&!o.current.contains(S.activeElement)){Nf(w);return}}w.target?.isContentEditable&&!d?.enableOnContentEditable||bl(l,d?.delimiter).forEach(S=>{if(S.includes(d?.splitKey??"+")&&S.includes(d?.sequenceSplitKey??">")){console.warn(`Hotkey ${S} contains both ${d?.splitKey??"+"} and ${d?.sequenceSplitKey??">"} which is not supported.`);return}const k=Cl(S,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description);if(k.isSequence){m=setTimeout(()=>{p=[]},d?.sequenceTimeoutMs??1e3);const M=k.useKey?w.key:on(w.code);if(jg(M.toLowerCase()))return;p.push(M);const I=k.keys?.[p.length-1];if(M!==I){p=[],m&&clearTimeout(m);return}p.length===k.keys?.length&&(u.current(w,k),m&&clearTimeout(m),p=[])}else if(eE(w,k,d?.ignoreModifiers)||k.keys?.includes("*")){if(d?.ignoreEventWhen?.(w)||E&&i.current)return;if(G9(w,k,d?.preventDefault),!J9(w,k,d?.enabled)){Nf(w);return}u.current(w,k),E||(i.current=!0)}})}},b=w=>{w.code!==void 0&&(Bg(on(w.code)),(d?.keydown===void 0&&d?.keyup!==!0||d?.keydown)&&v(w))},C=w=>{w.code!==void 0&&(_g(on(w.code)),i.current=!1,d?.keyup&&v(w,!0))},x=o.current||s?.document||document;return x.addEventListener("keyup",C,s?.eventListenerOptions),x.addEventListener("keydown",b,s?.eventListenerOptions),f&&bl(l,d?.delimiter).forEach(w=>f.addHotkey(Cl(w,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),()=>{x.removeEventListener("keyup",C,s?.eventListenerOptions),x.removeEventListener("keydown",b,s?.eventListenerOptions),f&&bl(l,d?.delimiter).forEach(w=>f.removeHotkey(Cl(w,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),p=[],m&&clearTimeout(m)}},[l,d,h]),o}function gr(t=768){const[e,n]=y.useState(void 0);return y.useEffect(()=>{const r=window.matchMedia(`(max-width: ${t-1}px)`),o=()=>{n(window.innerWidth<t)};return r.addEventListener("change",o),n(window.innerWidth<t),()=>r.removeEventListener("change",o)},[t]),!!e}const Vg=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20 2C20 1.44772 19.5523 1 19 1C18.4477 1 18 1.44772 18 2V4H16C15.4477 4 15 4.44772 15 5C15 5.55228 15.4477 6 16 6H18V8C18 8.55228 18.4477 9 19 9C19.5523 9 20 8.55228 20 8V6H22C22.5523 6 23 5.55228 23 5C23 4.44772 22.5523 4 22 4H20V2ZM5 4C4.73478 4 4.48043 4.10536 4.29289 4.29289C4.10536 4.48043 4 4.73478 4 5V19C4 19.2652 4.10536 19.5196 4.29289 19.7071C4.48043 19.8946 4.73478 20 5 20H5.58579L14.379 11.2068C14.9416 10.6444 15.7045 10.3284 16.5 10.3284C17.2955 10.3284 18.0584 10.6444 18.621 11.2068L20 12.5858V12C20 11.4477 20.4477 11 21 11C21.5523 11 22 11.4477 22 12V14.998C22 14.9994 22 15.0007 22 15.002V19C22 19.7957 21.6839 20.5587 21.1213 21.1213C20.5587 21.6839 19.7957 22 19 22H6.00219C6.00073 22 5.99927 22 5.99781 22H5C4.20435 22 3.44129 21.6839 2.87868 21.1213C2.31607 20.5587 2 19.7957 2 19V5C2 4.20435 2.31607 3.44129 2.87868 2.87868C3.44129 2.31607 4.20435 2 5 2H12C12.5523 2 13 2.44772 13 3C13 3.55228 12.5523 4 12 4H5ZM8.41422 20H19C19.2652 20 19.5196 19.8946 19.7071 19.7071C19.8946 19.5196 20 19.2652 20 19V15.4142L17.207 12.6212C17.0195 12.4338 16.7651 12.3284 16.5 12.3284C16.2349 12.3284 15.9806 12.4337 15.7931 12.6211L8.41422 20ZM6.87868 6.87868C7.44129 6.31607 8.20435 6 9 6C9.79565 6 10.5587 6.31607 11.1213 6.87868C11.6839 7.44129 12 8.20435 12 9C12 9.79565 11.6839 10.5587 11.1213 11.1213C10.5587 11.6839 9.79565 12 9 12C8.20435 12 7.44129 11.6839 6.87868 11.1213C6.31607 10.5587 6 9.79565 6 9C6 8.20435 6.31607 7.44129 6.87868 6.87868ZM9 8C8.73478 8 8.48043 8.10536 8.29289 8.29289C8.10536 8.48043 8 8.73478 8 9C8 9.26522 8.10536 9.51957 8.29289 9.70711C8.48043 9.89464 8.73478 10 9 10C9.26522 10 9.51957 9.89464 9.70711 9.70711C9.89464 9.51957 10 9.26522 10 9C10 8.73478 9.89464 8.48043 9.70711 8.29289C9.51957 8.10536 9.26522 8 9 8Z",fill:"currentColor"})}));Vg.displayName="ImagePlusIcon";const ma="mod+shift+i";function zc(t){return!t||!t.isEditable||!ds(t,"imageUpload")||bt(t,["image"])?!1:t.can().insertContent({type:"imageUpload"})}function lE(t){return!t||!t.isEditable?!1:t.isActive("imageUpload")}function aE(t){if(!t||!t.isEditable||!zc(t))return!1;try{return t.chain().focus().insertContent({type:"imageUpload"}).run()}catch{return!1}}function cE(t){const{editor:e,hideWhenUnavailable:n}=t;return!e||!e.isEditable||!ds(e,"imageUpload")?!1:n&&!e.isActive("code")?zc(e):!0}function uE(t){const{editor:e,hideWhenUnavailable:n=!1,onInserted:r}=t||{},{editor:o}=Y(e),i=gr(),[s,l]=y.useState(!0),a=zc(o),c=lE(o);y.useEffect(()=>{if(!o)return;const d=()=>{l(cE({editor:o,hideWhenUnavailable:n}))};return d(),o.on("selectionUpdate",d),()=>{o.off("selectionUpdate",d)}},[o,n]);const u=y.useCallback(()=>{if(!o)return!1;const d=aE(o);return d&&r?.(),d},[o,r]);return $g(ma,d=>{d.preventDefault(),u()},{enabled:s&&a,enableOnContentEditable:!i,enableOnFormTags:!0}),{isVisible:s,isActive:c,handleImage:u,canInsert:a,label:"Add image",shortcutKeys:ma,Icon:Vg}}const zg=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),g.jsx("polygon",{points:"10,8 16,12 10,16",fill:"currentColor",stroke:"none"})]}));zg.displayName="VideoIcon";function If(t){return!t||!t.isEditable?!1:t.can().insertContent({type:"videoEmbed",attrs:{src:""}})}function dE(t={}){const{editor:e,hideWhenUnavailable:n=!1,onInserted:r}=t,{editor:o}=Y(e),[i,s]=y.useState(!0),l=If(o);y.useEffect(()=>{if(!o)return;const c=()=>{if(!o.isEditable){s(!1);return}if(!o.extensionManager.extensions.some(d=>d.name==="videoEmbed")){s(!1);return}if(n){s(If(o));return}s(!0)};return c(),o.on("selectionUpdate",c),()=>{o.off("selectionUpdate",c)}},[o,n]);const a=y.useCallback(c=>{if(!o||!c)return!1;const u=o.chain().focus().setVideoEmbed({src:c}).run();return u&&r?.(),u},[o,r]);return{isVisible:i,canInsert:l,insertVideo:a,label:"Embed video",Icon:zg}}var vs="Popover",[Ug]=pr(vs,[hs]),po=hs(),[fE,pn]=Ug(vs),Wg=t=>{const{__scopePopover:e,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=t,l=po(e),a=y.useRef(null),[c,u]=y.useState(!1),[d,h]=Sc({prop:r,defaultProp:o??!1,onChange:i,caller:vs});return g.jsx(I1,{...l,children:g.jsx(fE,{scope:e,contentId:Fi(),triggerRef:a,open:d,onOpenChange:h,onOpenToggle:y.useCallback(()=>h(f=>!f),[h]),hasCustomAnchor:c,onCustomAnchorAdd:y.useCallback(()=>u(!0),[]),onCustomAnchorRemove:y.useCallback(()=>u(!1),[]),modal:s,children:n})})};Wg.displayName=vs;var Kg="PopoverAnchor",hE=y.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=pn(Kg,n),i=po(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:l}=o;return y.useEffect(()=>(s(),()=>l()),[s,l]),g.jsx(Ac,{...i,...r,ref:e})});hE.displayName=Kg;var qg="PopoverTrigger",Gg=y.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=pn(qg,n),i=po(n),s=Oe(e,o.triggerRef),l=g.jsx(Te.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Qg(o.open),...r,ref:s,onClick:J(t.onClick,o.onOpenToggle)});return o.hasCustomAnchor?l:g.jsx(Ac,{asChild:!0,...i,children:l})});Gg.displayName=qg;var Uc="PopoverPortal",[pE,mE]=Ug(Uc,{forceMount:void 0}),Jg=t=>{const{__scopePopover:e,forceMount:n,children:r,container:o}=t,i=pn(Uc,e);return g.jsx(pE,{scope:e,forceMount:n,children:g.jsx(Pn,{present:n||i.open,children:g.jsx(Rc,{asChild:!0,container:o,children:r})})})};Jg.displayName=Uc;var ur="PopoverContent",Zg=y.forwardRef((t,e)=>{const n=mE(ur,t.__scopePopover),{forceMount:r=n.forceMount,...o}=t,i=pn(ur,t.__scopePopover);return g.jsx(Pn,{present:r||i.open,children:i.modal?g.jsx(yE,{...o,ref:e}):g.jsx(vE,{...o,ref:e})})});Zg.displayName=ur;var gE=Qr("PopoverContent.RemoveScroll"),yE=y.forwardRef((t,e)=>{const n=pn(ur,t.__scopePopover),r=y.useRef(null),o=Oe(e,r),i=y.useRef(!1);return y.useEffect(()=>{const s=r.current;if(s)return V1(s)},[]),g.jsx(Oc,{as:gE,allowPinchZoom:!0,children:g.jsx(Yg,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:J(t.onCloseAutoFocus,s=>{s.preventDefault(),i.current||n.triggerRef.current?.focus()}),onPointerDownOutside:J(t.onPointerDownOutside,s=>{const l=s.detail.originalEvent,a=l.button===0&&l.ctrlKey===!0,c=l.button===2||a;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:J(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),vE=y.forwardRef((t,e)=>{const n=pn(ur,t.__scopePopover),r=y.useRef(!1),o=y.useRef(!1);return g.jsx(Yg,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{t.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{t.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),Yg=y.forwardRef((t,e)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onInteractOutside:u,...d}=t,h=pn(ur,n),f=po(n);return C1(),g.jsx(Ec,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:g.jsx(kc,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:g.jsx(L1,{"data-state":Qg(h.open),role:"dialog",id:h.contentId,...f,...d,ref:e,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Xg="PopoverClose",bE=y.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=pn(Xg,n);return g.jsx(Te.button,{type:"button",...r,ref:e,onClick:J(t.onClick,()=>o.onOpenChange(!1))})});bE.displayName=Xg;var CE="PopoverArrow",xE=y.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=po(n);return g.jsx(D1,{...o,...r,ref:e})});xE.displayName=CE;function Qg(t){return t?"open":"closed"}var wE=Wg,SE=Gg,kE=Jg,EE=Zg;function Wc({...t}){return g.jsx(wE,{...t})}function Kc({...t}){return g.jsx(SE,{...t})}function qc({className:t,align:e="center",sideOffset:n=4,...r}){const o=bc();return g.jsx(kE,{container:o??void 0,children:g.jsx(EE,{align:e,sideOffset:n,className:Me("tiptap-popover",t),...r})})}function e0({className:t,type:e,...n}){return g.jsx("input",{type:e,className:Me("tiptap-input",t),...n})}function t0({className:t,children:e,...n}){return g.jsx("div",{className:Me("tiptap-input-group",t),...n,children:e})}const Gc=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21 4C21 3.44772 20.5523 3 20 3C19.4477 3 19 3.44772 19 4V11C19 11.7956 18.6839 12.5587 18.1213 13.1213C17.5587 13.6839 16.7956 14 16 14H6.41421L9.70711 10.7071C10.0976 10.3166 10.0976 9.68342 9.70711 9.29289C9.31658 8.90237 8.68342 8.90237 8.29289 9.29289L3.29289 14.2929C2.90237 14.6834 2.90237 15.3166 3.29289 15.7071L8.29289 20.7071C8.68342 21.0976 9.31658 21.0976 9.70711 20.7071C10.0976 20.3166 10.0976 19.6834 9.70711 19.2929L6.41421 16H16C17.3261 16 18.5979 15.4732 19.5355 14.5355C20.4732 13.5979 21 12.3261 21 11V4Z",fill:"currentColor"})}));Gc.displayName="CornerDownLeftIcon";const Jc=y.forwardRef(({editor:t,text:e,hideWhenUnavailable:n=!1,onInserted:r,onClick:o,children:i,...s},l)=>{const{editor:a}=Y(t),[c,u]=y.useState(!1),[d,h]=y.useState(""),[f,p]=y.useState(""),{isVisible:m,canInsert:v,insertVideo:b,label:C,Icon:x}=dE({editor:a,hideWhenUnavailable:n,onInserted:r}),w=y.useCallback(()=>{if(!d.trim())return;if(!o1(d.trim())){p("Please enter a valid YouTube or Vimeo URL");return}p(""),b(d.trim())&&(h(""),u(!1))},[d,b]),E=y.useCallback(M=>{M.key==="Enter"&&(M.preventDefault(),w())},[w]),S=y.useCallback(M=>{u(M),M||(h(""),p(""))},[]),k=y.useCallback(M=>{o?.(M),!M.defaultPrevented&&u(!c)},[o,c]);return m?g.jsxs(Wc,{open:c,onOpenChange:S,children:[g.jsx(Kc,{asChild:!0,children:g.jsx(se,{type:"button",disabled:!v,"data-style":"ghost","data-disabled":!v,"aria-label":C,tooltip:C,onClick:k,...s,ref:l,children:i??g.jsxs(g.Fragment,{children:[g.jsx(x,{className:"tiptap-button-icon"}),e&&g.jsx("span",{className:"tiptap-button-text",children:e})]})})}),g.jsx(qc,{children:g.jsx(_n,{children:g.jsxs(mr,{children:[g.jsxs(no,{orientation:"horizontal",children:[g.jsx(t0,{children:g.jsx(e0,{type:"url",placeholder:"Paste YouTube or Vimeo URL...",value:d,onChange:M=>{h(M.target.value),p("")},onKeyDown:E,autoFocus:!0,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"})}),g.jsx(ft,{orientation:"horizontal",children:g.jsx(se,{type:"button",onClick:w,title:"Embed video",disabled:!d.trim(),"data-style":"ghost",children:g.jsx(Gc,{className:"tiptap-button-icon"})})})]}),f&&g.jsx("div",{style:{color:"var(--tt-color-red-base, #e53e3e)",fontSize:"12px",padding:"4px 8px 0"},children:f})]})})})]}):null});Jc.displayName="VideoEmbedButton";function ME({type:t,shortcutKeys:e=o0[t]}){return g.jsx(Ct,{children:yt({shortcutKeys:e})})}const n0=y.forwardRef(({editor:t,type:e,text:n,hideWhenUnavailable:r=!1,onToggled:o,showShortcut:i=!1,onClick:s,children:l,...a},c)=>{const{editor:u}=Y(t),{isVisible:d,canToggle:h,isActive:f,handleToggle:p,label:m,shortcutKeys:v,Icon:b}=OE({editor:u,type:e,hideWhenUnavailable:r,onToggled:o}),C=y.useCallback(x=>{s?.(x),!x.defaultPrevented&&p()},[p,s]);return d?g.jsx(se,{type:"button","data-style":"ghost","data-active-state":f?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":m,"aria-pressed":f,tooltip:m,onClick:C,...a,ref:c,children:l??g.jsxs(g.Fragment,{children:[g.jsx(b,{className:"tiptap-button-icon"}),n&&g.jsx("span",{className:"tiptap-button-text",children:n}),i&&g.jsx(ME,{type:e,shortcutKeys:v})]})}):null});n0.displayName="ListButton";const bs=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 6C7 5.44772 7.44772 5 8 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H8C7.44772 7 7 6.55228 7 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12C7 11.4477 7.44772 11 8 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H8C7.44772 13 7 12.5523 7 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 18C7 17.4477 7.44772 17 8 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H8C7.44772 19 7 18.5523 7 18Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H3.01C3.56228 5 4.01 5.44772 4.01 6C4.01 6.55228 3.56228 7 3.01 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H3.01C3.56228 11 4.01 11.4477 4.01 12C4.01 12.5523 3.56228 13 3.01 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H3.01C3.56228 17 4.01 17.4477 4.01 18C4.01 18.5523 3.56228 19 3.01 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));bs.displayName="ListIcon";const Zc=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 6C9 5.44772 9.44772 5 10 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H10C9.44772 7 9 6.55228 9 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 12C9 11.4477 9.44772 11 10 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H10C9.44772 13 9 12.5523 9 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 18C9 17.4477 9.44772 17 10 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H10C9.44772 19 9 18.5523 9 18Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 6C3 5.44772 3.44772 5 4 5H5C5.55228 5 6 5.44772 6 6V10C6 10.5523 5.55228 11 5 11C4.44772 11 4 10.5523 4 10V7C3.44772 7 3 6.55228 3 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3 10C3 9.44772 3.44772 9 4 9H6C6.55228 9 7 9.44772 7 10C7 10.5523 6.55228 11 6 11H4C3.44772 11 3 10.5523 3 10Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.82219 13.0431C6.54543 13.4047 6.99997 14.1319 6.99997 15C6.99997 15.5763 6.71806 16.0426 6.48747 16.35C6.31395 16.5814 6.1052 16.8044 5.91309 17H5.99997C6.55226 17 6.99997 17.4477 6.99997 18C6.99997 18.5523 6.55226 19 5.99997 19H3.99997C3.44769 19 2.99997 18.5523 2.99997 18C2.99997 17.4237 3.28189 16.9575 3.51247 16.65C3.74323 16.3424 4.03626 16.0494 4.26965 15.8161C4.27745 15.8083 4.2852 15.8006 4.29287 15.7929C4.55594 15.5298 4.75095 15.3321 4.88748 15.15C4.96287 15.0495 4.99021 14.9922 4.99911 14.9714C4.99535 14.9112 4.9803 14.882 4.9739 14.8715C4.96613 14.8588 4.95382 14.845 4.92776 14.8319C4.87723 14.8067 4.71156 14.7623 4.44719 14.8944C3.95321 15.1414 3.35254 14.9412 3.10555 14.4472C2.85856 13.9533 3.05878 13.3526 3.55276 13.1056C4.28839 12.7378 5.12272 12.6934 5.82219 13.0431Z",fill:"currentColor"})]}));Zc.displayName="ListOrderedIcon";const Yc=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 4.89543 2.89543 4 4 4H8C9.10457 4 10 4.89543 10 6V10C10 11.1046 9.10457 12 8 12H4C2.89543 12 2 11.1046 2 10V6ZM8 6H4V10H8V6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 14.2929C10.0976 14.6834 10.0976 15.3166 9.70711 15.7071L5.70711 19.7071C5.31658 20.0976 4.68342 20.0976 4.29289 19.7071L2.29289 17.7071C1.90237 17.3166 1.90237 16.6834 2.29289 16.2929C2.68342 15.9024 3.31658 15.9024 3.70711 16.2929L5 17.5858L8.29289 14.2929C8.68342 13.9024 9.31658 13.9024 9.70711 14.2929Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 6C12 5.44772 12.4477 5 13 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H13C12.4477 7 12 6.55228 12 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 12C12 11.4477 12.4477 11 13 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H13C12.4477 13 12 12.5523 12 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 18C12 17.4477 12.4477 17 13 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H13C12.4477 19 12 18.5523 12 18Z",fill:"currentColor"})]}));Yc.displayName="ListTodoIcon";const r0={bulletList:bs,orderedList:Zc,taskList:Yc},TE={bulletList:"Bullet List",orderedList:"Ordered List",taskList:"Task List"},o0={bulletList:"mod+shift+8",orderedList:"mod+shift+7",taskList:"mod+shift+9"};function Cs(t,e,n=!0){if(!t||!t.isEditable||!Bt(e,t)||bt(t,["image"]))return!1;if(!n)switch(e){case"bulletList":return t.can().toggleBulletList();case"orderedList":return t.can().toggleOrderedList();case"taskList":return t.can().toggleList("taskList","taskItem");default:return!1}try{const o=t.view.state,i=o.selection;if(i.empty||i instanceof z){const s=hn({editor:t,node:o.selection.$anchor.node(1)})?.pos;if(!vt(s))return!1}return!0}catch{return!1}}function Xc(t,e){if(!t||!t.isEditable)return!1;switch(e){case"bulletList":return t.isActive("bulletList");case"orderedList":return t.isActive("orderedList");case"taskList":return t.isActive("taskList");default:return!1}}function AE(t,e){if(!t||!t.isEditable||!Cs(t,e))return!1;try{const n=t.view;let r=n.state,o=r.tr;if(r.selection.empty||r.selection instanceof z){const l=hn({editor:t,node:r.selection.$anchor.node(1)})?.pos;if(!vt(l))return!1;o=o.setSelection(B.create(r.doc,l)),n.dispatch(o),r=n.state}const i=r.selection;let s=t.chain().focus();if(i instanceof B){const l=i.node.firstChild?.firstChild,a=i.node.lastChild?.lastChild,c=l?i.from+l.nodeSize:i.from+1,u=a?i.to-a.nodeSize:i.to-1;s=s.setTextSelection({from:c,to:u}).clearNodes()}if(t.isActive(e))s.liftListItem("listItem").lift("bulletList").lift("orderedList").lift("taskList").run();else{const a={bulletList:()=>s.toggleBulletList(),orderedList:()=>s.toggleOrderedList(),taskList:()=>s.toggleList("taskList","taskItem")}[e];if(!a)return!1;a().run()}return t.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function RE(t){const{editor:e,type:n,hideWhenUnavailable:r}=t;return!e||!e.isEditable||!Bt(n,e)?!1:r&&!e.isActive("code")?Cs(e,n):!0}function OE(t){const{editor:e,type:n,hideWhenUnavailable:r=!1,onToggled:o}=t,{editor:i}=Y(e),[s,l]=y.useState(!0),a=Cs(i,n),c=Xc(i,n);y.useEffect(()=>{if(!i)return;const d=()=>{l(RE({editor:i,type:n,hideWhenUnavailable:r}))};return d(),i.on("selectionUpdate",d),()=>{i.off("selectionUpdate",d)}},[i,n,r]);const u=y.useCallback(()=>{if(!i)return!1;const d=AE(i,n);return d&&o?.(),d},[i,n,o]);return{isVisible:s,isActive:c,handleToggle:u,canToggle:a,label:TE[n],shortcutKeys:o0[n],Icon:r0[n]}}const NE=[{label:"Bullet List",type:"bulletList",icon:bs},{label:"Ordered List",type:"orderedList",icon:Zc},{label:"Task List",type:"taskList",icon:Yc}];function IE(t,e){return!t||!t.isEditable?!1:e.some(n=>Cs(t,n))}function LE(t,e){return!t||!t.isEditable?!1:e.some(n=>Xc(t,n))}function DE(t){return NE.filter(e=>!e.type||t.includes(e.type))}function PE(t){const{editor:e,hideWhenUnavailable:n,listInSchema:r,canToggleAny:o}=t;return!r||!e?!1:n&&!e.isActive("code")?o:!0}function jE(t,e){if(!(!t||!t.isEditable))return e.find(n=>Xc(t,n))}function BE(t){const{editor:e,types:n=["bulletList","orderedList","taskList"],hideWhenUnavailable:r=!1}=t||{},{editor:o}=Y(e),[i,s]=y.useState(!1),l=n.some(f=>Bt(f,o)),a=y.useMemo(()=>DE(n),[n]),c=IE(o,n),u=LE(o,n),d=jE(o,n),h=a.find(f=>f.type===d);return y.useEffect(()=>{if(!o)return;const f=()=>{s(PE({editor:o,hideWhenUnavailable:r,listInSchema:l,canToggleAny:c}))};return f(),o.on("selectionUpdate",f),()=>{o.off("selectionUpdate",f)}},[c,o,r,l,n]),{isVisible:i,activeType:d,isActive:u,canToggle:c,types:n,filteredLists:a,label:"List",Icon:h?r0[h.type]:bs}}function i0({editor:t,types:e=["bulletList","orderedList","taskList"],hideWhenUnavailable:n=!1,onOpenChange:r,portal:o=!1,...i}){const{editor:s}=Y(t),[l,a]=y.useState(!1),{filteredLists:c,canToggle:u,isActive:d,isVisible:h,Icon:f}=BE({editor:s,types:e,hideWhenUnavailable:n}),p=y.useCallback(m=>{a(m),r?.(m)},[r]);return!h||!s||!s.isEditable?null:g.jsxs(Ng,{open:l,onOpenChange:p,children:[g.jsx(_c,{asChild:!0,children:g.jsxs(se,{type:"button","data-style":"ghost","data-active-state":d?"on":"off",role:"button",tabIndex:-1,disabled:!u,"data-disabled":!u,"aria-label":"List options",tooltip:"List",...i,children:[g.jsx(f,{className:"tiptap-button-icon"}),g.jsx(xc,{className:"tiptap-button-dropdown-small"})]})}),g.jsx(Hc,{align:"start",portal:o,children:g.jsx(_n,{children:g.jsx(mr,{children:g.jsx(ft,{children:c.map(m=>g.jsx(Lg,{asChild:!0,children:g.jsx(n0,{editor:s,type:m.type,text:m.label,showTooltip:!1})},m.type))})})})})]})}function _E({shortcutKeys:t=l0}){return g.jsx(Ct,{children:yt({shortcutKeys:t})})}const Qc=y.forwardRef(({editor:t,text:e,hideWhenUnavailable:n=!1,onToggled:r,showShortcut:o=!1,onClick:i,children:s,...l},a)=>{const{editor:c}=Y(t),{isVisible:u,canToggle:d,isActive:h,handleToggle:f,label:p,shortcutKeys:m,Icon:v}=$E({editor:c,hideWhenUnavailable:n,onToggled:r}),b=y.useCallback(C=>{i?.(C),!C.defaultPrevented&&f()},[f,i]);return u?g.jsx(se,{type:"button","data-style":"ghost","data-active-state":h?"on":"off",role:"button",tabIndex:-1,disabled:!d,"data-disabled":!d,"aria-label":p,"aria-pressed":h,tooltip:"Blockquote",onClick:b,...l,ref:a,children:s??g.jsxs(g.Fragment,{children:[g.jsx(v,{className:"tiptap-button-icon"}),e&&g.jsx("span",{className:"tiptap-button-text",children:e}),o&&g.jsx(_E,{shortcutKeys:m})]})}):null});Qc.displayName="BlockquoteButton";const s0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 6C8 5.44772 8.44772 5 9 5H16C16.5523 5 17 5.44772 17 6C17 6.55228 16.5523 7 16 7H9C8.44772 7 8 6.55228 8 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 3C4.55228 3 5 3.44772 5 4L5 20C5 20.5523 4.55229 21 4 21C3.44772 21 3 20.5523 3 20L3 4C3 3.44772 3.44772 3 4 3Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H20C20.5523 11 21 11.4477 21 12C21 12.5523 20.5523 13 20 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 18C8 17.4477 8.44772 17 9 17H16C16.5523 17 17 17.4477 17 18C17 18.5523 16.5523 19 16 19H9C8.44772 19 8 18.5523 8 18Z",fill:"currentColor"})]}));s0.displayName="BlockquoteIcon";const l0="mod+shift+b";function eu(t,e=!0){if(!t||!t.isEditable||!Bt("blockquote",t)||bt(t,["image"]))return!1;if(!e)return t.can().toggleWrap("blockquote");try{const r=t.view.state,o=r.selection;if(o.empty||o instanceof z){const i=hn({editor:t,node:r.selection.$anchor.node(1)})?.pos;if(!vt(i))return!1}return!0}catch{return!1}}function HE(t){if(!t||!t.isEditable||!eu(t))return!1;try{const e=t.view;let n=e.state,r=n.tr;if(n.selection.empty||n.selection instanceof z){const l=hn({editor:t,node:n.selection.$anchor.node(1)})?.pos;if(!vt(l))return!1;r=r.setSelection(B.create(n.doc,l)),e.dispatch(r),n=e.state}const o=n.selection;let i=t.chain().focus();if(o instanceof B){const l=o.node.firstChild?.firstChild,a=o.node.lastChild?.lastChild,c=l?o.from+l.nodeSize:o.from+1,u=a?o.to-a.nodeSize:o.to-1;i=i.setTextSelection({from:c,to:u}).clearNodes()}return(t.isActive("blockquote")?i.lift("blockquote"):i.wrapIn("blockquote")).run(),t.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function FE(t){const{editor:e,hideWhenUnavailable:n}=t;return!e||!e.isEditable||!Bt("blockquote",e)?!1:n&&!e.isActive("code")?eu(e):!0}function $E(t){const{editor:e,hideWhenUnavailable:n=!1,onToggled:r}=t||{},{editor:o}=Y(e),[i,s]=y.useState(!0),l=eu(o),a=o?.isActive("blockquote")||!1;y.useEffect(()=>{if(!o)return;const u=()=>{s(FE({editor:o,hideWhenUnavailable:n}))};return u(),o.on("selectionUpdate",u),()=>{o.off("selectionUpdate",u)}},[o,n]);const c=y.useCallback(()=>{if(!o)return!1;const u=HE(o);return u&&r?.(),u},[o,r]);return{isVisible:i,isActive:a,handleToggle:c,canToggle:l,label:"Blockquote",shortcutKeys:l0,Icon:s0}}const ga=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.43471 4.01458C4.34773 4.06032 4.26607 4.11977 4.19292 4.19292C4.11977 4.26607 4.06032 4.34773 4.01458 4.43471C2.14611 6.40628 1 9.0693 1 12C1 18.0751 5.92487 23 12 23C14.9306 23 17.5936 21.854 19.5651 19.9856C19.6522 19.9398 19.7339 19.8803 19.8071 19.8071C19.8803 19.7339 19.9398 19.6522 19.9856 19.5651C21.854 17.5936 23 14.9306 23 12C23 5.92487 18.0751 1 12 1C9.0693 1 6.40628 2.14611 4.43471 4.01458ZM6.38231 4.9681C7.92199 3.73647 9.87499 3 12 3C16.9706 3 21 7.02944 21 12C21 14.125 20.2635 16.078 19.0319 17.6177L6.38231 4.9681ZM17.6177 19.0319C16.078 20.2635 14.125 21 12 21C7.02944 21 3 16.9706 3 12C3 9.87499 3.73647 7.92199 4.9681 6.38231L17.6177 19.0319Z",fill:"currentColor"})}));ga.displayName="BanIcon";const xs=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.7072 4.70711C15.0977 4.31658 15.0977 3.68342 14.7072 3.29289C14.3167 2.90237 13.6835 2.90237 13.293 3.29289L8.69294 7.89286L8.68594 7.9C8.13626 8.46079 7.82837 9.21474 7.82837 10C7.82837 10.2306 7.85491 10.4584 7.90631 10.6795L2.29289 16.2929C2.10536 16.4804 2 16.7348 2 17V20C2 20.5523 2.44772 21 3 21H12C12.2652 21 12.5196 20.8946 12.7071 20.7071L15.3205 18.0937C15.5416 18.1452 15.7695 18.1717 16.0001 18.1717C16.7853 18.1717 17.5393 17.8639 18.1001 17.3142L22.7072 12.7071C23.0977 12.3166 23.0977 11.6834 22.7072 11.2929C22.3167 10.9024 21.6835 10.9024 21.293 11.2929L16.6971 15.8887C16.5105 16.0702 16.2605 16.1717 16.0001 16.1717C15.7397 16.1717 15.4897 16.0702 15.303 15.8887L10.1113 10.697C9.92992 10.5104 9.82837 10.2604 9.82837 10C9.82837 9.73963 9.92992 9.48958 10.1113 9.30297L14.7072 4.70711ZM13.5858 17L9.00004 12.4142L4 17.4142V19H11.5858L13.5858 17Z",fill:"currentColor"})}));xs.displayName="HighlighterIcon";function VE({shortcutKeys:t=ya}){return g.jsx(Ct,{children:yt({shortcutKeys:t})})}const a0=y.forwardRef(({editor:t,highlightColor:e,text:n,hideWhenUnavailable:r=!1,onApplied:o,showShortcut:i=!1,onClick:s,children:l,style:a,...c},u)=>{const{editor:d}=Y(t),{isVisible:h,canColorHighlight:f,isActive:p,handleColorHighlight:m,label:v,shortcutKeys:b}=nu({editor:d,highlightColor:e,label:n||`Toggle highlight (${e})`,hideWhenUnavailable:r,onApplied:o}),C=y.useCallback(w=>{s?.(w),!w.defaultPrevented&&m()},[m,s]),x=y.useMemo(()=>({...a,"--highlight-color":e}),[e,a]);return h?g.jsx(se,{type:"button","data-style":"ghost","data-active-state":p?"on":"off",role:"button",tabIndex:-1,disabled:!f,"data-disabled":!f,"aria-label":v,"aria-pressed":p,tooltip:v,onClick:C,style:x,...c,ref:u,children:l??g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"tiptap-button-highlight",style:{"--highlight-color":e}}),n&&g.jsx("span",{className:"tiptap-button-text",children:n}),i&&g.jsx(VE,{shortcutKeys:b})]})}):null});a0.displayName="ColorHighlightButton";const ya="mod+shift+h",zE=[{label:"Default background",value:"var(--tt-bg-color)",border:"var(--tt-bg-color-contrast)"},{label:"Gray background",value:"var(--tt-color-highlight-gray)",border:"var(--tt-color-highlight-gray-contrast)"},{label:"Brown background",value:"var(--tt-color-highlight-brown)",border:"var(--tt-color-highlight-brown-contrast)"},{label:"Orange background",value:"var(--tt-color-highlight-orange)",border:"var(--tt-color-highlight-orange-contrast)"},{label:"Yellow background",value:"var(--tt-color-highlight-yellow)",border:"var(--tt-color-highlight-yellow-contrast)"},{label:"Green background",value:"var(--tt-color-highlight-green)",border:"var(--tt-color-highlight-green-contrast)"},{label:"Blue background",value:"var(--tt-color-highlight-blue)",border:"var(--tt-color-highlight-blue-contrast)"},{label:"Purple background",value:"var(--tt-color-highlight-purple)",border:"var(--tt-color-highlight-purple-contrast)"},{label:"Pink background",value:"var(--tt-color-highlight-pink)",border:"var(--tt-color-highlight-pink-contrast)"},{label:"Red background",value:"var(--tt-color-highlight-red)",border:"var(--tt-color-highlight-red-contrast)"}];function UE(t){const e=new Map(zE.map(n=>[n.value,n]));return t.map(n=>e.get(n)).filter(n=>!!n)}function tu(t){return!t||!t.isEditable||!Dn("highlight",t)||bt(t,["image"])?!1:t.can().setMark("highlight")}function WE(t,e){return!t||!t.isEditable?!1:e?t.isActive("highlight",{color:e}):t.isActive("highlight")}function KE(t){return!t||!t.isEditable||!tu(t)?!1:t.chain().focus().unsetMark("highlight").run()}function qE(t){const{editor:e,hideWhenUnavailable:n}=t;return!e||!e.isEditable||!Dn("highlight",e)?!1:n&&!e.isActive("code")?tu(e):!0}function nu(t){const{editor:e,label:n,highlightColor:r,hideWhenUnavailable:o=!1,onApplied:i}=t,{editor:s}=Y(e),l=gr(),[a,c]=y.useState(!0),u=tu(s),d=WE(s,r);y.useEffect(()=>{if(!s)return;const p=()=>{c(qE({editor:s,hideWhenUnavailable:o}))};return p(),s.on("selectionUpdate",p),()=>{s.off("selectionUpdate",p)}},[s,o]);const h=y.useCallback(()=>{if(!s||!u||!r||!n)return!1;if(s.state.storedMarks){const p=s.schema.marks.highlight;p&&s.view.dispatch(s.state.tr.removeStoredMark(p))}setTimeout(()=>{const p=s.chain().focus().toggleMark("highlight",{color:r}).run();return p&&i?.({color:r,label:n}),p},0)},[u,r,s,n,i]),f=y.useCallback(()=>{const p=KE(s);return p&&i?.({color:"",label:"Remove highlight"}),p},[s,i]);return $g(ya,p=>{p.preventDefault(),h()},{enabled:a&&u,enableOnContentEditable:!l,enableOnFormTags:!0}),{isVisible:a,isActive:d,handleColorHighlight:h,handleRemoveHighlight:f,canColorHighlight:u,label:n||"Highlight",shortcutKeys:ya,Icon:xs}}const c0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M11.1 3C11.4762 3 11.8126 3.2286 11.9487 3.5786L16.9487 16.4214C17.1429 16.9213 16.8913 17.4816 16.3877 17.6743C15.884 17.8671 15.3196 17.6173 15.1254 17.1173L13.7569 13.5997H8.24311L6.87456 17.1173C6.68038 17.6173 6.11599 17.8671 5.61235 17.6743C5.10871 17.4816 4.85706 16.9213 5.05123 16.4214L10.0512 3.5786C10.1874 3.2286 10.5238 3 10.9 3H11.1ZM12.9879 11.6233L11 6.51102L9.0121 11.6233H12.9879Z",fill:"currentColor"}),g.jsx("rect",{x:"3",y:"19",width:"18",height:"2.5",rx:"1",fill:"currentColor"})]}));c0.displayName="TextColorIcon";const GE=[{label:"Gray",value:"var(--tt-color-text-gray)",border:"var(--tt-color-text-gray-contrast)"},{label:"Brown",value:"var(--tt-color-text-brown)",border:"var(--tt-color-text-brown-contrast)"},{label:"Orange",value:"var(--tt-color-text-orange)",border:"var(--tt-color-text-orange-contrast)"},{label:"Yellow",value:"var(--tt-color-text-yellow)",border:"var(--tt-color-text-yellow-contrast)"},{label:"Green",value:"var(--tt-color-text-green)",border:"var(--tt-color-text-green-contrast)"},{label:"Blue",value:"var(--tt-color-text-blue)",border:"var(--tt-color-text-blue-contrast)"},{label:"Purple",value:"var(--tt-color-text-purple)",border:"var(--tt-color-text-purple-contrast)"},{label:"Pink",value:"var(--tt-color-text-pink)",border:"var(--tt-color-text-pink-contrast)"},{label:"Red",value:"var(--tt-color-text-red)",border:"var(--tt-color-text-red-contrast)"}];function JE(t){const e=new Map(GE.map(n=>[n.value,n]));return t.map(n=>e.get(n)).filter(n=>!!n)}function Lf(t){return!t||!t.isEditable||!Dn("textStyle",t)||bt(t,["image"])?!1:t.can().setMark("textStyle")}function ZE(t,e){return!t||!t.isEditable?!1:e?t.isActive("textStyle",{color:e}):t.isActive("textStyle")}function YE(t){return!t||!t.isEditable?!1:t.chain().focus().unsetColor().run()}function u0(t){const{editor:e,label:n,color:r,hideWhenUnavailable:o=!1,onApplied:i}=t,{editor:s}=Y(e),[l,a]=y.useState(!0),c=Lf(s),u=ZE(s,r);y.useEffect(()=>{if(!s)return;const f=()=>{if(!s.isEditable){a(!1);return}if(!Dn("textStyle",s)){a(!1);return}if(o){a(Lf(s));return}a(!0)};return f(),s.on("selectionUpdate",f),()=>{s.off("selectionUpdate",f)}},[s,o]);const d=y.useCallback(()=>{if(!s||!c||!r||!n)return!1;setTimeout(()=>{const f=s.chain().focus().setColor(r).run();return f&&i?.({color:r,label:n}),f},0)},[c,r,s,n,i]),h=y.useCallback(()=>{if(!s)return!1;const f=YE(s);return f&&i?.({color:"",label:"Remove color"}),f},[s,i]);return{isVisible:l,isActive:u,handleSetColor:d,handleRemoveColor:h,canSetColor:c,label:n||"Text color",Icon:c0}}const d0=y.forwardRef(({editor:t,color:e,text:n,hideWhenUnavailable:r=!1,onApplied:o,onClick:i,children:s,style:l,...a},c)=>{const{editor:u}=Y(t),{isVisible:d,canSetColor:h,isActive:f,handleSetColor:p,label:m}=u0({editor:u,color:e,label:n||`Text ${e}`,hideWhenUnavailable:r,onApplied:o}),v=y.useCallback(C=>{i?.(C),!C.defaultPrevented&&p()},[p,i]),b=y.useMemo(()=>({...l,"--text-color":e}),[e,l]);return d?g.jsx(se,{type:"button","data-style":"ghost","data-active-state":f?"on":"off",role:"button",tabIndex:-1,disabled:!h,"data-disabled":!h,"aria-label":m,"aria-pressed":f,tooltip:m,onClick:v,style:b,...a,ref:c,children:s??g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"tiptap-button-text-color",style:{"--text-color":e}}),n&&g.jsx("span",{className:"tiptap-button-text",children:n})]})}):null});d0.displayName="TextColorButton";const ru=y.forwardRef(({className:t,children:e,...n},r)=>g.jsx(se,{type:"button",className:t,"data-style":"ghost","data-appearance":"default",role:"button",tabIndex:-1,"aria-label":"Highlight text",tooltip:"Highlight",ref:r,...n,children:e??g.jsx(xs,{className:"tiptap-button-icon"})}));ru.displayName="ColorHighlightPopoverButton";const f0=JE(["var(--tt-color-text-gray)","var(--tt-color-text-brown)","var(--tt-color-text-orange)","var(--tt-color-text-yellow)","var(--tt-color-text-green)","var(--tt-color-text-blue)","var(--tt-color-text-purple)","var(--tt-color-text-pink)","var(--tt-color-text-red)"]),h0=UE(["var(--tt-color-highlight-green)","var(--tt-color-highlight-blue)","var(--tt-color-highlight-red)","var(--tt-color-highlight-purple)","var(--tt-color-highlight-yellow)"]);function p0({editor:t,colors:e=h0,textColors:n=f0}){const{handleRemoveHighlight:r}=nu({editor:t}),{handleRemoveColor:o}=u0({editor:t}),i=gr(),s=y.useRef(null),l=y.useMemo(()=>[...n.map(f=>({...f,group:"text"})),{label:"Remove color",value:"none-text",group:"text"},...e.map(f=>({...f,group:"highlight"})),{label:"Remove highlight",value:"none-highlight",group:"highlight"}],[n,e]),{selectedIndex:a}=t1({containerRef:s,items:l,orientation:"both",onSelect:f=>{if(!s.current)return!1;const p=s.current.querySelector('[data-highlighted="true"]');p&&p.click(),f.value==="none-text"&&o(),f.value==="none-highlight"&&r()},autoSelectFirstItem:!1}),c=0,u=n.length,d=n.length+1,h=d+e.length;return g.jsx(_n,{ref:s,tabIndex:0,style:i?{boxShadow:"none",border:0}:{},children:g.jsxs(mr,{style:i?{padding:0}:{},children:[g.jsxs(no,{orientation:"horizontal",children:[g.jsx(ft,{orientation:"horizontal",children:n.map((f,p)=>g.jsx(d0,{editor:t,color:f.value,tooltip:f.label,"aria-label":`${f.label} text color`,tabIndex:c+p===a?0:-1,"data-highlighted":a===c+p},f.value))}),g.jsx(tr,{}),g.jsx(ft,{orientation:"horizontal",children:g.jsx(se,{onClick:o,"aria-label":"Remove text color",tooltip:"Remove text color",tabIndex:a===u?0:-1,type:"button",role:"menuitem","data-style":"ghost","data-highlighted":a===u,children:g.jsx(ga,{className:"tiptap-button-icon"})})})]}),g.jsx(tr,{}),g.jsxs(no,{orientation:"horizontal",children:[g.jsx(ft,{orientation:"horizontal",children:e.map((f,p)=>g.jsx(a0,{editor:t,highlightColor:f.value,tooltip:f.label,"aria-label":`${f.label} highlight color`,tabIndex:d+p===a?0:-1,"data-highlighted":a===d+p},f.value))}),g.jsx(tr,{}),g.jsx(ft,{orientation:"horizontal",children:g.jsx(se,{onClick:r,"aria-label":"Remove highlight",tooltip:"Remove highlight",tabIndex:a===h?0:-1,type:"button",role:"menuitem","data-style":"ghost","data-highlighted":a===h,children:g.jsx(ga,{className:"tiptap-button-icon"})})})]})]})})}function XE({editor:t,colors:e=h0,textColors:n=f0,hideWhenUnavailable:r=!1,onApplied:o,...i}){const{editor:s}=Y(t),[l,a]=y.useState(!1),{isVisible:c,canColorHighlight:u,isActive:d,label:h,Icon:f}=nu({editor:s,hideWhenUnavailable:r,onApplied:o});return c?g.jsxs(Wc,{open:l,onOpenChange:a,children:[g.jsx(Kc,{asChild:!0,children:g.jsx(ru,{disabled:!u,"data-active-state":d?"on":"off","data-disabled":!u,"aria-pressed":d,"aria-label":h,tooltip:h,...i,children:g.jsx(f,{className:"tiptap-button-icon"})})}),g.jsx(qc,{"aria-label":"Text colors and highlights",children:g.jsx(p0,{editor:s,colors:e,textColors:n})})]}):null}const m0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M14 3C14 2.44772 14.4477 2 15 2H21C21.5523 2 22 2.44772 22 3V9C22 9.55228 21.5523 10 21 10C20.4477 10 20 9.55228 20 9V5.41421L10.7071 14.7071C10.3166 15.0976 9.68342 15.0976 9.29289 14.7071C8.90237 14.3166 8.90237 13.6834 9.29289 13.2929L18.5858 4H15C14.4477 4 14 3.55228 14 3Z",fill:"currentColor"}),g.jsx("path",{d:"M4.29289 7.29289C4.48043 7.10536 4.73478 7 5 7H11C11.5523 7 12 6.55228 12 6C12 5.44772 11.5523 5 11 5H5C4.20435 5 3.44129 5.31607 2.87868 5.87868C2.31607 6.44129 2 7.20435 2 8V19C2 19.7957 2.31607 20.5587 2.87868 21.1213C3.44129 21.6839 4.20435 22 5 22H16C16.7957 22 17.5587 21.6839 18.1213 21.1213C18.6839 20.5587 19 19.7957 19 19V13C19 12.4477 18.5523 12 18 12C17.4477 12 17 12.4477 17 13V19C17 19.2652 16.8946 19.5196 16.7071 19.7071C16.5196 19.8946 16.2652 20 16 20H5C4.73478 20 4.48043 19.8946 4.29289 19.7071C4.10536 19.5196 4 19.2652 4 19V8C4 7.73478 4.10536 7.48043 4.29289 7.29289Z",fill:"currentColor"})]}));m0.displayName="ExternalLinkIcon";const ws=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M16.9958 1.06669C15.4226 1.05302 13.907 1.65779 12.7753 2.75074L12.765 2.76086L11.045 4.47086C10.6534 4.86024 10.6515 5.49341 11.0409 5.88507C11.4303 6.27673 12.0634 6.27858 12.4551 5.88919L14.1697 4.18456C14.9236 3.45893 15.9319 3.05752 16.9784 3.06662C18.0272 3.07573 19.0304 3.49641 19.772 4.23804C20.5137 4.97967 20.9344 5.98292 20.9435 7.03171C20.9526 8.07776 20.5515 9.08563 19.8265 9.83941L16.833 12.8329C16.4274 13.2386 15.9393 13.5524 15.4019 13.7529C14.8645 13.9533 14.2903 14.0359 13.7181 13.9949C13.146 13.9539 12.5894 13.7904 12.0861 13.5154C11.5827 13.2404 11.1444 12.8604 10.8008 12.401C10.47 11.9588 9.84333 11.8685 9.40108 12.1993C8.95883 12.5301 8.86849 13.1568 9.1993 13.599C9.71464 14.288 10.3721 14.858 11.1272 15.2705C11.8822 15.683 12.7171 15.9283 13.5753 15.9898C14.4334 16.0513 15.2948 15.9274 16.1009 15.6267C16.907 15.326 17.639 14.8555 18.2473 14.247L21.2472 11.2471L21.2593 11.2347C22.3523 10.1031 22.9571 8.58751 22.9434 7.01433C22.9297 5.44115 22.2987 3.93628 21.1863 2.82383C20.0738 1.71138 18.5689 1.08036 16.9958 1.06669Z",fill:"currentColor"}),g.jsx("path",{d:"M10.4247 8.0102C9.56657 7.94874 8.70522 8.07256 7.89911 8.37326C7.09305 8.67395 6.36096 9.14458 5.75272 9.753L2.75285 12.7529L2.74067 12.7653C1.64772 13.8969 1.04295 15.4125 1.05662 16.9857C1.07029 18.5589 1.70131 20.0637 2.81376 21.1762C3.9262 22.2886 5.43108 22.9196 7.00426 22.9333C8.57744 22.947 10.0931 22.3422 11.2247 21.2493L11.2371 21.2371L12.9471 19.5271C13.3376 19.1366 13.3376 18.5034 12.9471 18.1129C12.5565 17.7223 11.9234 17.7223 11.5328 18.1129L9.82932 19.8164C9.07555 20.5414 8.06768 20.9425 7.02164 20.9334C5.97285 20.9243 4.9696 20.5036 4.22797 19.762C3.48634 19.0203 3.06566 18.0171 3.05655 16.9683C3.04746 15.9222 3.44851 14.9144 4.17355 14.1606L7.16719 11.167C7.5727 10.7613 8.06071 10.4476 8.59811 10.2471C9.13552 10.0467 9.70976 9.96412 10.2819 10.0051C10.854 10.0461 11.4106 10.2096 11.9139 10.4846C12.4173 10.7596 12.8556 11.1397 13.1992 11.599C13.53 12.0412 14.1567 12.1316 14.5989 11.8007C15.0412 11.4699 15.1315 10.8433 14.8007 10.401C14.2854 9.71205 13.6279 9.14198 12.8729 8.72948C12.1178 8.31697 11.2829 8.07166 10.4247 8.0102Z",fill:"currentColor"})]}));ws.displayName="LinkIcon";const g0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 5V4C7 3.17477 7.40255 2.43324 7.91789 1.91789C8.43324 1.40255 9.17477 1 10 1H14C14.8252 1 15.5668 1.40255 16.0821 1.91789C16.5975 2.43324 17 3.17477 17 4V5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H20V20C20 20.8252 19.5975 21.5668 19.0821 22.0821C18.5668 22.5975 17.8252 23 17 23H7C6.17477 23 5.43324 22.5975 4.91789 22.0821C4.40255 21.5668 4 20.8252 4 20V7H3C2.44772 7 2 6.55228 2 6C2 5.44772 2.44772 5 3 5H7ZM9 4C9 3.82523 9.09745 3.56676 9.33211 3.33211C9.56676 3.09745 9.82523 3 10 3H14C14.1748 3 14.4332 3.09745 14.6679 3.33211C14.9025 3.56676 15 3.82523 15 4V5H9V4ZM6 7V20C6 20.1748 6.09745 20.4332 6.33211 20.6679C6.56676 20.9025 6.82523 21 7 21H17C17.1748 21 17.4332 20.9025 17.6679 20.6679C17.9025 20.4332 18 20.1748 18 20V7H6Z",fill:"currentColor"})}));g0.displayName="TrashIcon";const ou=y.forwardRef(({className:t,children:e,...n},r)=>g.jsx(se,{type:"button",className:t,"data-style":"ghost",role:"button",tabIndex:-1,"aria-label":"Link",tooltip:"Link",ref:r,...n,children:e||g.jsx(ws,{className:"tiptap-button-icon"})}));ou.displayName="LinkButton";const y0=({url:t,setUrl:e,setLink:n,removeLink:r,openLink:o,isActive:i})=>{const s=gr(),l=a=>{a.key==="Enter"&&(a.preventDefault(),n())};return g.jsx(_n,{style:{...s?{boxShadow:"none",border:0}:{}},children:g.jsx(mr,{style:{...s?{padding:0}:{}},children:g.jsxs(no,{orientation:"horizontal",children:[g.jsx(t0,{children:g.jsx(e0,{type:"url",placeholder:"Paste a link...",value:t,onChange:a=>e(a.target.value),onKeyDown:l,autoFocus:!0,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"})}),g.jsx(ft,{orientation:"horizontal",children:g.jsx(se,{type:"button",onClick:n,title:"Apply link",disabled:!t&&!i,"data-style":"ghost",children:g.jsx(Gc,{className:"tiptap-button-icon"})})}),g.jsx(tr,{}),g.jsxs(ft,{orientation:"horizontal",children:[g.jsx(se,{type:"button",onClick:o,title:"Open in new window",disabled:!t&&!i,"data-style":"ghost",children:g.jsx(m0,{className:"tiptap-button-icon"})}),g.jsx(se,{type:"button",onClick:r,title:"Remove link",disabled:!t&&!i,"data-style":"ghost",children:g.jsx(g0,{className:"tiptap-button-icon"})})]})]})})})},QE=({editor:t})=>{const e=x0({editor:t});return g.jsx(y0,{...e})},v0=y.forwardRef(({editor:t,hideWhenUnavailable:e=!1,onSetLink:n,onOpenChange:r,autoOpenOnLinkActive:o=!0,onClick:i,children:s,...l},a)=>{const{editor:c}=Y(t),[u,d]=y.useState(!1),{isVisible:h,canSet:f,isActive:p,url:m,setUrl:v,setLink:b,removeLink:C,openLink:x,label:w,Icon:E}=x0({editor:c,hideWhenUnavailable:e,onSetLink:n}),S=y.useCallback(I=>{d(I),r?.(I)},[r]),k=y.useCallback(()=>{b(),d(!1)},[b]),M=y.useCallback(I=>{i?.(I),!I.defaultPrevented&&d(!u)},[i,u]);return y.useEffect(()=>{o&&p&&d(!0)},[o,p]),h?g.jsxs(Wc,{open:u,onOpenChange:S,children:[g.jsx(Kc,{asChild:!0,children:g.jsx(ou,{disabled:!f,"data-active-state":p?"on":"off","data-disabled":!f,"aria-label":w,"aria-pressed":p,onClick:M,...l,ref:a,children:s??g.jsx(E,{className:"tiptap-button-icon"})})}),g.jsx(qc,{children:g.jsx(y0,{url:m,setUrl:v,setLink:k,removeLink:C,openLink:x,isActive:p})})]}):null});v0.displayName="LinkPopover";function b0(t){return!t||!t.isEditable?!1:t.can().setMark("link")}function C0(t){return!t||!t.isEditable?!1:t.isActive("link")}function eM(t){const{editor:e,hideWhenUnavailable:n}=t;return!Dn("link",e)||!e?!1:n&&!e.isActive("code")?b0(e):!0}function tM(t){const{editor:e,onSetLink:n}=t,[r,o]=y.useState(null);y.useEffect(()=>{if(!e)return;const{href:a}=e.getAttributes("link");C0(e)&&r===null&&o(a||"")},[e,r]),y.useEffect(()=>{if(!e)return;const a=()=>{const{href:c}=e.getAttributes("link");o(c||"")};return e.on("selectionUpdate",a),()=>{e.off("selectionUpdate",a)}},[e]);const i=y.useCallback(()=>{if(!r||!e)return;const{selection:a}=e.state,c=a.empty;let u=e.chain().focus();u=u.extendMarkRange("link").setLink({href:r}),c&&(u=u.insertContent({type:"text",text:r})),u.run(),o(null),n?.()},[e,n,r]),s=y.useCallback(()=>{e&&(e.chain().focus().extendMarkRange("link").unsetLink().setMeta("preventAutolink",!0).run(),o(""))},[e]),l=y.useCallback((a="_blank",c="noopener,noreferrer")=>{if(!r)return;const u=vS(r,window.location.href);u!=="#"&&window.open(u,a,c)},[r]);return{url:r||"",setUrl:o,setLink:i,removeLink:s,openLink:l}}function nM(t){const{editor:e,hideWhenUnavailable:n=!1}=t,r=b0(e),o=C0(e),[i,s]=y.useState(!1);return y.useEffect(()=>{if(!e)return;const l=()=>{s(eM({editor:e,hideWhenUnavailable:n}))};return l(),e.on("selectionUpdate",l),()=>{e.off("selectionUpdate",l)}},[e,n]),{isVisible:i,canSet:r,isActive:o}}function x0(t){const{editor:e,hideWhenUnavailable:n=!1,onSetLink:r}=t||{},{editor:o}=Y(e),{isVisible:i,canSet:s,isActive:l}=nM({editor:o,hideWhenUnavailable:n}),a=tM({editor:o,onSetLink:r});return{isVisible:i,canSet:s,isActive:l,label:"Link",Icon:ws,...a}}function rM({type:t,shortcutKeys:e=R0[t]}){return g.jsx(Ct,{children:yt({shortcutKeys:e})})}const yn=y.forwardRef(({editor:t,type:e,text:n,hideWhenUnavailable:r=!1,onToggled:o,showShortcut:i=!1,onClick:s,children:l,...a},c)=>{const{editor:u}=Y(t),{isVisible:d,handleMark:h,label:f,canToggle:p,isActive:m,Icon:v,shortcutKeys:b}=cM({editor:u,type:e,hideWhenUnavailable:r,onToggled:o}),C=y.useCallback(x=>{s?.(x),!x.defaultPrevented&&h()},[h,s]);return d?g.jsx(se,{type:"button",disabled:!p,"data-style":"ghost","data-active-state":m?"on":"off","data-disabled":!p,role:"button",tabIndex:-1,"aria-label":f,"aria-pressed":m,tooltip:f,onClick:C,...a,ref:c,children:l??g.jsxs(g.Fragment,{children:[g.jsx(v,{className:"tiptap-button-icon"}),n&&g.jsx("span",{className:"tiptap-button-text",children:n}),i&&g.jsx(rM,{type:e,shortcutKeys:b})]})}):null});yn.displayName="MarkButton";const w0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.5C5.17157 2.5 4.5 3.17157 4.5 4V20C4.5 20.8284 5.17157 21.5 6 21.5H15C16.4587 21.5 17.8576 20.9205 18.8891 19.8891C19.9205 18.8576 20.5 17.4587 20.5 16C20.5 14.5413 19.9205 13.1424 18.8891 12.1109C18.6781 11.9 18.4518 11.7079 18.2128 11.5359C19.041 10.5492 19.5 9.29829 19.5 8C19.5 6.54131 18.9205 5.14236 17.8891 4.11091C16.8576 3.07946 15.4587 2.5 14 2.5H6ZM14 10.5C14.663 10.5 15.2989 10.2366 15.7678 9.76777C16.2366 9.29893 16.5 8.66304 16.5 8C16.5 7.33696 16.2366 6.70107 15.7678 6.23223C15.2989 5.76339 14.663 5.5 14 5.5H7.5V10.5H14ZM7.5 18.5V13.5H15C15.663 13.5 16.2989 13.7634 16.7678 14.2322C17.2366 14.7011 17.5 15.337 17.5 16C17.5 16.663 17.2366 17.2989 16.7678 17.7678C16.2989 18.2366 15.663 18.5 15 18.5H7.5Z",fill:"currentColor"})}));w0.displayName="BoldIcon";const S0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M15.4545 4.2983C15.6192 3.77115 15.3254 3.21028 14.7983 3.04554C14.2712 2.88081 13.7103 3.1746 13.5455 3.70175L8.54554 19.7017C8.38081 20.2289 8.6746 20.7898 9.20175 20.9545C9.72889 21.1192 10.2898 20.8254 10.4545 20.2983L15.4545 4.2983Z",fill:"currentColor"}),g.jsx("path",{d:"M6.70711 7.29289C7.09763 7.68342 7.09763 8.31658 6.70711 8.70711L3.41421 12L6.70711 15.2929C7.09763 15.6834 7.09763 16.3166 6.70711 16.7071C6.31658 17.0976 5.68342 17.0976 5.29289 16.7071L1.29289 12.7071C0.902369 12.3166 0.902369 11.6834 1.29289 11.2929L5.29289 7.29289C5.68342 6.90237 6.31658 6.90237 6.70711 7.29289Z",fill:"currentColor"}),g.jsx("path",{d:"M17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289L22.7071 11.2929C23.0976 11.6834 23.0976 12.3166 22.7071 12.7071L18.7071 16.7071C18.3166 17.0976 17.6834 17.0976 17.2929 16.7071C16.9024 16.3166 16.9024 15.6834 17.2929 15.2929L20.5858 12L17.2929 8.70711C16.9024 8.31658 16.9024 7.68342 17.2929 7.29289Z",fill:"currentColor"})]}));S0.displayName="Code2Icon";const k0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{d:"M15.0222 3H19C19.5523 3 20 3.44772 20 4C20 4.55228 19.5523 5 19 5H15.693L10.443 19H14C14.5523 19 15 19.4477 15 20C15 20.5523 14.5523 21 14 21H9.02418C9.00802 21.0004 8.99181 21.0004 8.97557 21H5C4.44772 21 4 20.5523 4 20C4 19.4477 4.44772 19 5 19H8.30704L13.557 5H10C9.44772 5 9 4.55228 9 4C9 3.44772 9.44772 3 10 3H14.9782C14.9928 2.99968 15.0075 2.99967 15.0222 3Z",fill:"currentColor"})}));k0.displayName="ItalicIcon";const E0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{d:"M9.00039 3H16.0001C16.5524 3 17.0001 3.44772 17.0001 4C17.0001 4.55229 16.5524 5 16.0001 5H9.00011C8.68006 4.99983 8.36412 5.07648 8.07983 5.22349C7.79555 5.37051 7.55069 5.5836 7.36585 5.84487C7.181 6.10614 7.06155 6.40796 7.01754 6.72497C6.97352 7.04198 7.00623 7.36492 7.11292 7.66667C7.29701 8.18737 7.02414 8.75872 6.50344 8.94281C5.98274 9.1269 5.4114 8.85403 5.2273 8.33333C5.01393 7.72984 4.94851 7.08396 5.03654 6.44994C5.12456 5.81592 5.36346 5.21229 5.73316 4.68974C6.10285 4.1672 6.59256 3.74101 7.16113 3.44698C7.72955 3.15303 8.36047 2.99975 9.00039 3Z",fill:"currentColor"}),g.jsx("path",{d:"M18 13H20C20.5523 13 21 12.5523 21 12C21 11.4477 20.5523 11 20 11H4C3.44772 11 3 11.4477 3 12C3 12.5523 3.44772 13 4 13H14C14.7956 13 15.5587 13.3161 16.1213 13.8787C16.6839 14.4413 17 15.2044 17 16C17 16.7956 16.6839 17.5587 16.1213 18.1213C15.5587 18.6839 14.7956 19 14 19H6C5.44772 19 5 19.4477 5 20C5 20.5523 5.44772 21 6 21H14C15.3261 21 16.5979 20.4732 17.5355 19.5355C18.4732 18.5979 19 17.3261 19 16C19 14.9119 18.6453 13.8604 18 13Z",fill:"currentColor"})]}));E0.displayName="StrikeIcon";const M0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.4079 14.3995C18.0284 14.0487 18.7506 13.9217 19.4536 14.0397C20.1566 14.1578 20.7977 14.5138 21.2696 15.0481L21.2779 15.0574L21.2778 15.0575C21.7439 15.5988 22 16.2903 22 17C22 18.0823 21.3962 18.8401 20.7744 19.3404C20.194 19.8073 19.4858 20.141 18.9828 20.378C18.9638 20.387 18.9451 20.3958 18.9266 20.4045C18.4473 20.6306 18.2804 20.7817 18.1922 20.918C18.1773 20.9412 18.1619 20.9681 18.1467 21H21C21.5523 21 22 21.4477 22 22C22 22.5523 21.5523 23 21 23H17C16.4477 23 16 22.5523 16 22C16 21.1708 16.1176 20.4431 16.5128 19.832C16.9096 19.2184 17.4928 18.8695 18.0734 18.5956C18.6279 18.334 19.138 18.0901 19.5207 17.7821C19.8838 17.49 20 17.2477 20 17C20 16.7718 19.9176 16.5452 19.7663 16.3672C19.5983 16.1792 19.3712 16.0539 19.1224 16.0121C18.8722 15.9701 18.6152 16.015 18.3942 16.1394C18.1794 16.2628 18.0205 16.4549 17.9422 16.675C17.7572 17.1954 17.1854 17.4673 16.665 17.2822C16.1446 17.0972 15.8728 16.5254 16.0578 16.005C16.2993 15.3259 16.7797 14.7584 17.4039 14.4018L17.4079 14.3995L17.4079 14.3995Z",fill:"currentColor"})]}));M0.displayName="SubscriptIcon";const T0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.7071 7.29289C13.0976 7.68342 13.0976 8.31658 12.7071 8.70711L4.70711 16.7071C4.31658 17.0976 3.68342 17.0976 3.29289 16.7071C2.90237 16.3166 2.90237 15.6834 3.29289 15.2929L11.2929 7.29289C11.6834 6.90237 12.3166 6.90237 12.7071 7.29289Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.29289 7.29289C3.68342 6.90237 4.31658 6.90237 4.70711 7.29289L12.7071 15.2929C13.0976 15.6834 13.0976 16.3166 12.7071 16.7071C12.3166 17.0976 11.6834 17.0976 11.2929 16.7071L3.29289 8.70711C2.90237 8.31658 2.90237 7.68342 3.29289 7.29289Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.405 1.40657C18.0246 1.05456 18.7463 0.92634 19.4492 1.04344C20.1521 1.16054 20.7933 1.51583 21.2652 2.0497L21.2697 2.05469L21.2696 2.05471C21.7431 2.5975 22 3.28922 22 4.00203C22 5.08579 21.3952 5.84326 20.7727 6.34289C20.1966 6.80531 19.4941 7.13675 18.9941 7.37261C18.9714 7.38332 18.9491 7.39383 18.9273 7.40415C18.4487 7.63034 18.2814 7.78152 18.1927 7.91844C18.1778 7.94155 18.1625 7.96834 18.1473 8.00003H21C21.5523 8.00003 22 8.44774 22 9.00003C22 9.55231 21.5523 10 21 10H17C16.4477 10 16 9.55231 16 9.00003C16 8.17007 16.1183 7.44255 16.5138 6.83161C16.9107 6.21854 17.4934 5.86971 18.0728 5.59591C18.6281 5.33347 19.1376 5.09075 19.5208 4.78316C19.8838 4.49179 20 4.25026 20 4.00203C20 3.77192 19.9178 3.54865 19.7646 3.37182C19.5968 3.18324 19.3696 3.05774 19.1205 3.01625C18.8705 2.97459 18.6137 3.02017 18.3933 3.14533C18.1762 3.26898 18.0191 3.45826 17.9406 3.67557C17.7531 4.19504 17.18 4.46414 16.6605 4.27662C16.141 4.0891 15.8719 3.51596 16.0594 2.99649C16.303 2.3219 16.7817 1.76125 17.4045 1.40689L17.405 1.40657Z",fill:"currentColor"})]}));T0.displayName="SuperscriptIcon";const A0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4V10C5 11.8565 5.7375 13.637 7.05025 14.9497C8.36301 16.2625 10.1435 17 12 17C13.8565 17 15.637 16.2625 16.9497 14.9497C18.2625 13.637 19 11.8565 19 10V4C19 3.44772 18.5523 3 18 3C17.4477 3 17 3.44772 17 4V10C17 11.3261 16.4732 12.5979 15.5355 13.5355C14.5979 14.4732 13.3261 15 12 15C10.6739 15 9.40215 14.4732 8.46447 13.5355C7.52678 12.5979 7 11.3261 7 10V4ZM4 19C3.44772 19 3 19.4477 3 20C3 20.5523 3.44772 21 4 21H20C20.5523 21 21 20.5523 21 20C21 19.4477 20.5523 19 20 19H4Z",fill:"currentColor"})}));A0.displayName="UnderlineIcon";const oM={bold:w0,italic:k0,underline:A0,strike:E0,code:S0,superscript:T0,subscript:M0},R0={bold:"mod+b",italic:"mod+i",underline:"mod+u",strike:"mod+shift+s",code:"mod+e",superscript:"mod+.",subscript:"mod+,"};function iu(t,e){return!t||!t.isEditable||!Dn(e,t)||bt(t,["image"])?!1:t.can().toggleMark(e)}function iM(t,e){return!t||!t.isEditable?!1:t.isActive(e)}function sM(t,e){return!t||!t.isEditable||!iu(t,e)?!1:t.chain().focus().toggleMark(e).run()}function lM(t){const{editor:e,type:n,hideWhenUnavailable:r}=t;return!e||!e.isEditable||!Dn(n,e)?!1:r&&!e.isActive("code")?iu(e,n):!0}function aM(t){return t.charAt(0).toUpperCase()+t.slice(1)}function cM(t){const{editor:e,type:n,hideWhenUnavailable:r=!1,onToggled:o}=t,{editor:i}=Y(e),[s,l]=y.useState(!0),a=iu(i,n),c=iM(i,n);y.useEffect(()=>{if(!i)return;const d=()=>{l(lM({editor:i,type:n,hideWhenUnavailable:r}))};return d(),i.on("selectionUpdate",d),()=>{i.off("selectionUpdate",d)}},[i,n,r]);const u=y.useCallback(()=>{if(!i)return!1;const d=sM(i,n);return d&&o?.(),d},[i,n,o]);return{isVisible:s,isActive:c,handleMark:u,canToggle:a,label:aM(n),shortcutKeys:R0[n],Icon:oM[n]}}function uM({align:t,shortcutKeys:e=D0[t]}){return g.jsx(Ct,{children:yt({shortcutKeys:e})})}const Yn=y.forwardRef(({editor:t,align:e,text:n,hideWhenUnavailable:r=!1,onAligned:o,showShortcut:i=!1,onClick:s,icon:l,children:a,...c},u)=>{const{editor:d}=Y(t),{isVisible:h,handleTextAlign:f,label:p,canAlign:m,isActive:v,Icon:b,shortcutKeys:C}=yM({editor:d,align:e,hideWhenUnavailable:r,onAligned:o}),x=y.useCallback(E=>{s?.(E),!E.defaultPrevented&&f()},[f,s]);if(!h)return null;const w=l??b;return g.jsx(se,{type:"button",disabled:!m,"data-style":"ghost","data-active-state":v?"on":"off","data-disabled":!m,role:"button",tabIndex:-1,"aria-label":p,"aria-pressed":v,tooltip:p,onClick:x,...c,ref:u,children:a??g.jsxs(g.Fragment,{children:[g.jsx(w,{className:"tiptap-button-icon"}),n&&g.jsx("span",{className:"tiptap-button-text",children:n}),i&&g.jsx(uM,{align:e,shortcutKeys:C})]})})});Yn.displayName="TextAlignButton";const O0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 12C6 11.4477 6.44772 11 7 11H17C17.5523 11 18 11.4477 18 12C18 12.5523 17.5523 13 17 13H7C6.44772 13 6 12.5523 6 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 18C4 17.4477 4.44772 17 5 17H19C19.5523 17 20 17.4477 20 18C20 18.5523 19.5523 19 19 19H5C4.44772 19 4 18.5523 4 18Z",fill:"currentColor"})]}));O0.displayName="AlignCenterIcon";const N0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));N0.displayName="AlignJustifyIcon";const I0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 12C2 11.4477 2.44772 11 3 11H15C15.5523 11 16 11.4477 16 12C16 12.5523 15.5523 13 15 13H3C2.44772 13 2 12.5523 2 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 18C2 17.4477 2.44772 17 3 17H17C17.5523 17 18 17.4477 18 18C18 18.5523 17.5523 19 17 19H3C2.44772 19 2 18.5523 2 18Z",fill:"currentColor"})]}));I0.displayName="AlignLeftIcon";const L0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2 6C2 5.44772 2.44772 5 3 5H21C21.5523 5 22 5.44772 22 6C22 6.55228 21.5523 7 21 7H3C2.44772 7 2 6.55228 2 6Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 12C8 11.4477 8.44772 11 9 11H21C21.5523 11 22 11.4477 22 12C22 12.5523 21.5523 13 21 13H9C8.44772 13 8 12.5523 8 12Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 18C6 17.4477 6.44772 17 7 17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H7C6.44772 19 6 18.5523 6 18Z",fill:"currentColor"})]}));L0.displayName="AlignRightIcon";const D0={left:"mod+shift+l",center:"mod+shift+e",right:"mod+shift+r",justify:"mod+shift+j"},dM={left:I0,center:O0,right:L0,justify:N0},fM={left:"Align left",center:"Align center",right:"Align right",justify:"Align justify"};function su(t,e){if(!t||!t.isEditable||!ds(t,"textAlign"))return!1;const{selection:n}=t.state;if(n instanceof B){const r=n.node;return r?(t.extensionManager.extensions.find(s=>s.name==="textAlign")?.options?.types??[]).includes(r.type.name):!1}return bt(t,["image"])?!1:t.can().setTextAlign(e)}function hM(t){return"setTextAlign"in t}function pM(t,e){return!t||!t.isEditable?!1:t.isActive({textAlign:e})}function mM(t,e){if(!t||!t.isEditable||!su(t,e))return!1;const n=t.chain().focus();return hM(n)?n.setTextAlign(e).run():!1}function gM(t){const{editor:e,hideWhenUnavailable:n,align:r}=t;return!e||!e.isEditable||!ds(e,"textAlign")?!1:n&&!e.isActive("code")?su(e,r):!0}function yM(t){const{editor:e,align:n,hideWhenUnavailable:r=!1,onAligned:o}=t,{editor:i}=Y(e),[s,l]=y.useState(!0),a=su(i,n),c=pM(i,n);y.useEffect(()=>{if(!i)return;const d=()=>{l(gM({editor:i,align:n,hideWhenUnavailable:r}))};return d(),i.on("selectionUpdate",d),()=>{i.off("selectionUpdate",d)}},[i,r,n]);const u=y.useCallback(()=>{if(!i)return!1;const d=mM(i,n);return d&&o?.(),d},[i,n,o]);return{isVisible:s,isActive:c,handleTextAlign:u,canAlign:a,label:fM[n],shortcutKeys:D0[n],Icon:dM[n]}}function vM({action:t,shortcutKeys:e=B0[t]}){return g.jsx(Ct,{children:yt({shortcutKeys:e})})}const zi=y.forwardRef(({editor:t,action:e,text:n,hideWhenUnavailable:r=!1,onExecuted:o,showShortcut:i=!1,onClick:s,children:l,...a},c)=>{const{editor:u}=Y(t),{isVisible:d,handleAction:h,label:f,canExecute:p,Icon:m,shortcutKeys:v}=SM({editor:u,action:e,hideWhenUnavailable:r,onExecuted:o}),b=y.useCallback(C=>{s?.(C),!C.defaultPrevented&&h()},[h,s]);return d?g.jsx(se,{type:"button",disabled:!p,"data-style":"ghost","data-disabled":!p,role:"button",tabIndex:-1,"aria-label":f,tooltip:f,onClick:b,...a,ref:c,children:l??g.jsxs(g.Fragment,{children:[g.jsx(m,{className:"tiptap-button-icon"}),n&&g.jsx("span",{className:"tiptap-button-text",children:n}),i&&g.jsx(vM,{action:e,shortcutKeys:v})]})}):null});zi.displayName="UndoRedoButton";const P0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.7071 2.29289C15.3166 1.90237 14.6834 1.90237 14.2929 2.29289C13.9024 2.68342 13.9024 3.31658 14.2929 3.70711L17.5858 7H9.5C7.77609 7 6.12279 7.68482 4.90381 8.90381C3.68482 10.1228 3 11.7761 3 13.5C3 14.3536 3.16813 15.1988 3.49478 15.9874C3.82144 16.7761 4.30023 17.4926 4.90381 18.0962C6.12279 19.3152 7.77609 20 9.5 20H13C13.5523 20 14 19.5523 14 19C14 18.4477 13.5523 18 13 18H9.5C8.30653 18 7.16193 17.5259 6.31802 16.682C5.90016 16.2641 5.56869 15.768 5.34254 15.2221C5.1164 14.6761 5 14.0909 5 13.5C5 12.3065 5.47411 11.1619 6.31802 10.318C7.16193 9.47411 8.30653 9 9.5 9H17.5858L14.2929 12.2929C13.9024 12.6834 13.9024 13.3166 14.2929 13.7071C14.6834 14.0976 15.3166 14.0976 15.7071 13.7071L20.7071 8.70711C21.0976 8.31658 21.0976 7.68342 20.7071 7.29289L15.7071 2.29289Z",fill:"currentColor"})}));P0.displayName="Redo2Icon";const j0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.70711 3.70711C10.0976 3.31658 10.0976 2.68342 9.70711 2.29289C9.31658 1.90237 8.68342 1.90237 8.29289 2.29289L3.29289 7.29289C2.90237 7.68342 2.90237 8.31658 3.29289 8.70711L8.29289 13.7071C8.68342 14.0976 9.31658 14.0976 9.70711 13.7071C10.0976 13.3166 10.0976 12.6834 9.70711 12.2929L6.41421 9H14.5C15.0909 9 15.6761 9.1164 16.2221 9.34254C16.768 9.56869 17.2641 9.90016 17.682 10.318C18.0998 10.7359 18.4313 11.232 18.6575 11.7779C18.8836 12.3239 19 12.9091 19 13.5C19 14.0909 18.8836 14.6761 18.6575 15.2221C18.4313 15.768 18.0998 16.2641 17.682 16.682C17.2641 17.0998 16.768 17.4313 16.2221 17.6575C15.6761 17.8836 15.0909 18 14.5 18H11C10.4477 18 10 18.4477 10 19C10 19.5523 10.4477 20 11 20H14.5C15.3536 20 16.1988 19.8319 16.9874 19.5052C17.7761 19.1786 18.4926 18.6998 19.0962 18.0962C19.6998 17.4926 20.1786 16.7761 20.5052 15.9874C20.8319 15.1988 21 14.3536 21 13.5C21 12.6464 20.8319 11.8012 20.5052 11.0126C20.1786 10.2239 19.6998 9.50739 19.0962 8.90381C18.4926 8.30022 17.7761 7.82144 16.9874 7.49478C16.1988 7.16813 15.3536 7 14.5 7H6.41421L9.70711 3.70711Z",fill:"currentColor"})}));j0.displayName="Undo2Icon";const B0={undo:"mod+z",redo:"mod+shift+z"},bM={undo:"Undo",redo:"Redo"},CM={undo:j0,redo:P0};function lu(t,e){return!t||!t.isEditable||bt(t,["image"])?!1:e==="undo"?t.can().undo():t.can().redo()}function xM(t,e){if(!t||!t.isEditable||!lu(t,e))return!1;const n=t.chain().focus();return e==="undo"?n.undo().run():n.redo().run()}function wM(t){const{editor:e,hideWhenUnavailable:n,action:r}=t;return!e||!e.isEditable?!1:n&&!e.isActive("code")?lu(e,r):!0}function SM(t){const{editor:e,action:n,hideWhenUnavailable:r=!1,onExecuted:o}=t,{editor:i}=Y(e),[s,l]=y.useState(!0),a=lu(i,n);y.useEffect(()=>{if(!i)return;const u=()=>{l(wM({editor:i,hideWhenUnavailable:r,action:n}))};return u(),i.on("transaction",u),()=>{i.off("transaction",u)}},[i,r,n]);const c=y.useCallback(()=>{if(!i)return!1;const u=xM(i,n);return u&&o?.(),u},[i,n,o]);return{isVisible:s,handleAction:c,canExecute:a,label:bM[n],shortcutKeys:B0[n],Icon:CM[n]}}const _0=y.memo(({className:t,...e})=>g.jsx("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:g.jsx("path",{d:"M12.7071 5.70711C13.0976 5.31658 13.0976 4.68342 12.7071 4.29289C12.3166 3.90237 11.6834 3.90237 11.2929 4.29289L4.29289 11.2929C3.90237 11.6834 3.90237 12.3166 4.29289 12.7071L11.2929 19.7071C11.6834 20.0976 12.3166 20.0976 12.7071 19.7071C13.0976 19.3166 13.0976 18.6834 12.7071 18.2929L7.41421 13L19 13C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11L7.41421 11L12.7071 5.70711Z",fill:"currentColor"})}));_0.displayName="ArrowLeftIcon";var xl,Df;function kM(){if(Df)return xl;Df=1;var t="Expected a function",e=NaN,n="[object Symbol]",r=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt,a=typeof mo=="object"&&mo&&mo.Object===Object&&mo,c=typeof self=="object"&&self&&self.Object===Object&&self,u=a||c||Function("return this")(),d=Object.prototype,h=d.toString,f=Math.max,p=Math.min,m=function(){return u.Date.now()};function v(S,k,M){var I,P,_,U,F,O,H=0,V=!1,D=!1,T=!0;if(typeof S!="function")throw new TypeError(t);k=E(k)||0,C(M)&&(V=!!M.leading,D="maxWait"in M,_=D?f(E(M.maxWait)||0,k):_,T="trailing"in M?!!M.trailing:T);function R(re){var Ke=I,xt=P;return I=P=void 0,H=re,U=S.apply(xt,Ke),U}function W(re){return H=re,F=setTimeout(X,k),V?R(re):U}function ne(re){var Ke=re-O,xt=re-H,Hn=k-Ke;return D?p(Hn,_-xt):Hn}function K(re){var Ke=re-O,xt=re-H;return O===void 0||Ke>=k||Ke<0||D&&xt>=_}function X(){var re=m();if(K(re))return We(re);F=setTimeout(X,ne(re))}function We(re){return F=void 0,T&&I?R(re):(I=P=void 0,U)}function ce(){F!==void 0&&clearTimeout(F),H=0,I=O=P=F=void 0}function ye(){return F===void 0?U:We(m())}function Q(){var re=m(),Ke=K(re);if(I=arguments,P=this,O=re,Ke){if(F===void 0)return W(O);if(D)return F=setTimeout(X,k),R(O)}return F===void 0&&(F=setTimeout(X,k)),U}return Q.cancel=ce,Q.flush=ye,Q}function b(S,k,M){var I=!0,P=!0;if(typeof S!="function")throw new TypeError(t);return C(M)&&(I="leading"in M?!!M.leading:I,P="trailing"in M?!!M.trailing:P),v(S,k,{leading:I,maxWait:k,trailing:P})}function C(S){var k=typeof S;return!!S&&(k=="object"||k=="function")}function x(S){return!!S&&typeof S=="object"}function w(S){return typeof S=="symbol"||x(S)&&h.call(S)==n}function E(S){if(typeof S=="number")return S;if(w(S))return e;if(C(S)){var k=typeof S.valueOf=="function"?S.valueOf():S;S=C(k)?k+"":k}if(typeof S!="string")return S===0?S:+S;S=S.replace(r,"");var M=i.test(S);return M||s.test(S)?l(S.slice(2),M?2:8):o.test(S)?e:+S}return xl=b,xl}var EM=kM();const MM=jf(EM),TM=t=>{const e=L.useRef(t);e.current=t,L.useEffect(()=>()=>{e.current()},[])},AM={leading:!1,trailing:!0};function H0(t,e=250,n=[],r=AM){const o=y.useMemo(()=>MM(t,e,r),n);return TM(()=>{o.cancel()}),o}function au(){const[t,e]=y.useState({width:0,height:0,offsetTop:0,offsetLeft:0,scale:0}),n=H0(()=>{if(typeof window>"u")return;const r=window.visualViewport;if(!r)return;const{width:o=0,height:i=0,offsetTop:s=0,offsetLeft:l=0,scale:a=0}=r;e(c=>o===c.width&&i===c.height&&s===c.offsetTop&&l===c.offsetLeft&&a===c.scale?c:{width:o,height:i,offsetTop:s,offsetLeft:l,scale:a})},200);return y.useEffect(()=>{const r=window.visualViewport;if(r)return r.addEventListener("resize",n),n(),()=>{r.removeEventListener("resize",n)}},[n]),t}const Bo={x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0},F0=typeof window>"u",RM=!F0&&typeof ResizeObserver<"u",qo=()=>!F0;function OM({element:t,enabled:e=!0,throttleMs:n=100,useResizeObserver:r=!0}={}){const[o,i]=y.useState(Bo),s=y.useCallback(()=>!e||!qo()?null:t?typeof t=="string"?document.querySelector(t):"current"in t?t.current:t:document.body,[t,e]),l=H0(()=>{if(!e||!qo())return;const a=s();if(!a){i(Bo);return}const c=a.getBoundingClientRect();i({x:c.x,y:c.y,width:c.width,height:c.height,top:c.top,right:c.right,bottom:c.bottom,left:c.left})},n,[e,s],{leading:!0,trailing:!0});return y.useEffect(()=>{if(!e||!qo()){i(Bo);return}const a=s();if(!a)return;l();const c=[];if(r&&RM){const d=new ResizeObserver(()=>{window.requestAnimationFrame(l)});d.observe(a),c.push(()=>d.disconnect())}const u=()=>l();return window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u,{passive:!0}),c.push(()=>{window.removeEventListener("scroll",u),window.removeEventListener("resize",u)}),()=>{c.forEach(d=>d()),i(Bo)}},[e,s,l,r]),o}function NM(t={}){return OM({...t,element:qo()?document.body:null})}function IM({editor:t,overlayHeight:e=0}){const{height:n}=au(),r=NM({enabled:!0,throttleMs:100,useResizeObserver:!0});return y.useEffect(()=>{(()=>{if(!t)return;const{state:i,view:s}=t;if(!s.hasFocus())return;const{from:l}=i.selection,a=s.coordsAtPos(l);if(n<r.height&&a&&n-a.top<e){const u=Math.max(n/2,e),d=window.scrollY,f=a.top+d-u;window.scrollTo({top:Math.max(0,f),behavior:"smooth"})}})()},[t,e,n,r.height]),r}const $0="rtbe-root",LM=({onHighlighterClick:t,onLinkClick:e,isMobile:n})=>g.jsxs(g.Fragment,{children:[g.jsx(mf,{}),g.jsxs(qt,{children:[g.jsx(zi,{action:"undo"}),g.jsx(zi,{action:"redo"})]}),g.jsx(Gt,{}),g.jsxs(qt,{children:[g.jsx(Fc,{levels:[1,2,3,4],portal:n}),g.jsx(i0,{types:["bulletList","orderedList","taskList"],portal:n}),g.jsx(Qc,{})]}),g.jsx(Gt,{}),g.jsxs(qt,{children:[g.jsx(yn,{type:"bold"}),g.jsx(yn,{type:"italic"}),g.jsx(yn,{type:"strike"}),g.jsx(yn,{type:"code"}),g.jsx(yn,{type:"underline"}),n?g.jsx(ru,{onClick:t}):g.jsx(XE,{}),n?g.jsx(ou,{onClick:e}):g.jsx(v0,{})]}),g.jsx(Gt,{}),g.jsxs(qt,{children:[g.jsx(Yn,{align:"left"}),g.jsx(Yn,{align:"center"}),g.jsx(Yn,{align:"right"}),g.jsx(Yn,{align:"justify"})]}),g.jsx(Gt,{}),g.jsxs(qt,{children:[g.jsx($c,{text:"Add"}),g.jsx(Jc,{})]}),g.jsx(mf,{}),n&&g.jsx(Gt,{})]}),DM=({type:t,onBack:e})=>g.jsxs(g.Fragment,{children:[g.jsx(qt,{children:g.jsxs(se,{"data-style":"ghost",onClick:e,children:[g.jsx(_0,{className:"tiptap-button-icon"}),t==="highlighter"?g.jsx(xs,{className:"tiptap-button-icon"}):g.jsx(ws,{className:"tiptap-button-icon"})]})}),g.jsx(Gt,{}),t==="highlighter"?g.jsx(p0,{}):g.jsx(QE,{})]});function PM(t){const e=gr(),{height:n}=au(),[r,o]=L.useState("main"),i=L.useRef(null),[s,l]=L.useState(null),a=L.useCallback(d=>{l(d)},[]),c=gx({content:t.value,immediatelyRender:!1,shouldRerenderOnTransaction:!1,onUpdate:({editor:d})=>{d&&t.onChange(d.getHTML())},editorProps:{attributes:{autocomplete:"off",autocorrect:"off",autocapitalize:"off","aria-label":"Main content area, start typing to enter text.",class:"simple-editor"}},extensions:[jS,IS,RS.configure({type:"resizableImage",accept:"image/*",maxSize:1*1024*1024*1024,upload:(d,h,f)=>Promise.resolve(t.onUploadImage?.(d,h,f)||"")}),wm,xm,a7.configure({horizontalRule:!1,link:{openOnClick:!1,enableClickSelection:!0}}),OS,c7.configure({types:["heading","paragraph","resizableImage","videoEmbed"]}),hm,fm.configure({nested:!0}),P7.configure({multicolor:!0}),I7,B7,j7,i7,K7.configure({attributeName:"id",generateID:()=>`tiptap-editor-${t.id||Rx()}`})]}),u=IM({editor:c,overlayHeight:i.current?.getBoundingClientRect().height??0});return L.useEffect(()=>{!e&&r!=="main"&&o("main")},[e,r]),L.useEffect(()=>()=>{c&&c.commands.clearContent()},[c]),g.jsx("div",{className:`${$0} simple-editor-wrapper`,"data-react-tiptap-base-editor":"",children:g.jsxs(aS,{container:s,children:[g.jsxs(Za.Provider,{value:{editor:c},children:[g.jsx(Cc,{ref:i,style:{...e?{bottom:`calc(100% - ${n-u.y}px)`}:{}},children:r==="main"?g.jsx(LM,{onHighlighterClick:()=>o("highlighter"),onLinkClick:()=>o("link"),isMobile:e}):g.jsx(DM,{type:r==="highlighter"?"highlighter":"link",onBack:()=>o("main")})}),g.jsx(dx,{editor:c,className:"simple-editor-content"})]}),g.jsx("div",{ref:a,className:"rtbe-portal-host","aria-hidden":!0})]})})}function jM({shortcutKeys:t=U0}){return g.jsx(Ct,{children:yt({shortcutKeys:t})})}const V0=y.forwardRef(({editor:t,text:e,hideWhenUnavailable:n=!1,onToggled:r,showShortcut:o=!1,onClick:i,children:s,...l},a)=>{const{editor:c}=Y(t),{isVisible:u,canToggle:d,isActive:h,handleToggle:f,label:p,shortcutKeys:m,Icon:v}=HM({editor:c,hideWhenUnavailable:n,onToggled:r}),b=y.useCallback(C=>{i?.(C),!C.defaultPrevented&&f()},[f,i]);return u?g.jsx(se,{type:"button","data-style":"ghost","data-active-state":h?"on":"off",role:"button",disabled:!d,"data-disabled":!d,tabIndex:-1,"aria-label":p,"aria-pressed":h,tooltip:"Code Block",onClick:b,...l,ref:a,children:s??g.jsxs(g.Fragment,{children:[g.jsx(v,{className:"tiptap-button-icon"}),e&&g.jsx("span",{className:"tiptap-button-text",children:e}),o&&g.jsx(jM,{shortcutKeys:m})]})}):null});V0.displayName="CodeBlockButton";const z0=y.memo(({className:t,...e})=>g.jsxs("svg",{width:"24",height:"24",className:t,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:[g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.70711 2.29289C7.09763 2.68342 7.09763 3.31658 6.70711 3.70711L4.41421 6L6.70711 8.29289C7.09763 8.68342 7.09763 9.31658 6.70711 9.70711C6.31658 10.0976 5.68342 10.0976 5.29289 9.70711L2.29289 6.70711C1.90237 6.31658 1.90237 5.68342 2.29289 5.29289L5.29289 2.29289C5.68342 1.90237 6.31658 1.90237 6.70711 2.29289Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.2929 2.29289C10.6834 1.90237 11.3166 1.90237 11.7071 2.29289L14.7071 5.29289C15.0976 5.68342 15.0976 6.31658 14.7071 6.70711L11.7071 9.70711C11.3166 10.0976 10.6834 10.0976 10.2929 9.70711C9.90237 9.31658 9.90237 8.68342 10.2929 8.29289L12.5858 6L10.2929 3.70711C9.90237 3.31658 9.90237 2.68342 10.2929 2.29289Z",fill:"currentColor"}),g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17 4C17 3.44772 17.4477 3 18 3H19C20.6569 3 22 4.34315 22 6V18C22 19.6569 20.6569 21 19 21H5C3.34315 21 2 19.6569 2 18V12C2 11.4477 2.44772 11 3 11C3.55228 11 4 11.4477 4 12V18C4 18.5523 4.44772 19 5 19H19C19.5523 19 20 18.5523 20 18V6C20 5.44772 19.5523 5 19 5H18C17.4477 5 17 4.55228 17 4Z",fill:"currentColor"})]}));z0.displayName="CodeBlockIcon";const U0="mod+alt+c";function cu(t,e=!0){if(!t||!t.isEditable||!Bt("codeBlock",t)||bt(t,["image"]))return!1;if(!e)return t.can().toggleNode("codeBlock","paragraph");try{const r=t.view.state,o=r.selection;if(o.empty||o instanceof z){const i=hn({editor:t,node:r.selection.$anchor.node(1)})?.pos;if(!vt(i))return!1}return!0}catch{return!1}}function BM(t){if(!t||!t.isEditable||!cu(t))return!1;try{const e=t.view;let n=e.state,r=n.tr;if(n.selection.empty||n.selection instanceof z){const l=hn({editor:t,node:n.selection.$anchor.node(1)})?.pos;if(!vt(l))return!1;r=r.setSelection(B.create(n.doc,l)),e.dispatch(r),n=e.state}const o=n.selection;let i=t.chain().focus();if(o instanceof B){const l=o.node.firstChild?.firstChild,a=o.node.lastChild?.lastChild,c=l?o.from+l.nodeSize:o.from+1,u=a?o.to-a.nodeSize:o.to-1;i=i.setTextSelection({from:c,to:u}).clearNodes()}return(t.isActive("codeBlock")?i.setNode("paragraph"):i.toggleNode("codeBlock","paragraph")).run(),t.chain().focus().selectTextblockEnd().run(),!0}catch{return!1}}function _M(t){const{editor:e,hideWhenUnavailable:n}=t;return!e||!e.isEditable||!Bt("codeBlock",e)?!1:n&&!e.isActive("code")?cu(e):!0}function HM(t){const{editor:e,hideWhenUnavailable:n=!1,onToggled:r}=t||{},{editor:o}=Y(e),[i,s]=y.useState(!0),l=cu(o),a=o?.isActive("codeBlock")||!1;y.useEffect(()=>{if(!o)return;const u=()=>{s(_M({editor:o,hideWhenUnavailable:n}))};return u(),o.on("selectionUpdate",u),()=>{o.off("selectionUpdate",u)}},[o,n]);const c=y.useCallback(()=>{if(!o)return!1;const u=BM(o);return u&&r?.(),u},[o,r]);return{isVisible:i,isActive:a,handleToggle:c,canToggle:l,label:"Code Block",shortcutKeys:U0,Icon:z0}}exports.BlockquoteButton=Qc;exports.Button=se;exports.Card=_n;exports.CodeBlockButton=V0;exports.HeadingDropdownMenu=Fc;exports.ImageUploadButton=$c;exports.ListDropdownMenu=i0;exports.MAX_FILE_SIZE=ua;exports.MarkButton=yn;exports.RTBE_ROOT_CLASS=$0;exports.TextAlignButton=Yn;exports.TiptapEditor=PM;exports.Toolbar=Cc;exports.ToolbarGroup=qt;exports.ToolbarSeparator=Gt;exports.UndoRedoButton=zi;exports.VideoEmbedButton=Jc;exports.onUploadImage=mS;exports.useIsMobile=gr;exports.useTiptapEditor=Y;exports.useWindowSize=au;
217
217
  //# sourceMappingURL=index.cjs.map