@clickcns/vmedic-react 0.0.8 → 0.0.10

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.
@@ -1,25 +1,25 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../../tooltip-CmhEZXRA.cjs"),Pe=require("lucide-react"),z=require("react"),ln=require("../../compiler-runtime-BtE0QEUt.cjs");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("react-resizable-panels");const Mc=require("react-dom"),Ec=require("date-fns");require("tailwind-merge");require("@radix-ui/react-separator");var Yo={exports:{}},Qo={},ha;function Vh(){if(ha)return Qo;ha=1;var n=z.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;return Qo.c=function(e){return n.H.useMemoCache(e)},Qo}var pa={},fa;function Fh(){return fa||(fa=1,process.env.NODE_ENV!=="production"&&(function(){var n=z.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;pa.c=function(e){var t=n.H;return t===null&&console.error(`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../../tooltip-CmhEZXRA.cjs"),Pe=require("lucide-react"),z=require("react"),ln=require("../../compiler-runtime-BtE0QEUt.cjs");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("react-resizable-panels");const Ec=require("react-dom"),Tc=require("date-fns");require("tailwind-merge");require("@radix-ui/react-separator");var Yo={exports:{}},Qo={},pa;function Fh(){if(pa)return Qo;pa=1;var n=z.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;return Qo.c=function(e){return n.H.useMemoCache(e)},Qo}var fa={},ma;function Wh(){return ma||(ma=1,process.env.NODE_ENV!=="production"&&(function(){var n=z.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;fa.c=function(e){var t=n.H;return t===null&&console.error(`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
2
2
  1. You might have mismatching versions of React and the renderer (such as React DOM)
3
3
  2. You might be breaking the Rules of Hooks
4
4
  3. You might have more than one copy of React in the same app
5
- See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),t.useMemoCache(e)}})()),pa}var ma;function Wh(){return ma||(ma=1,process.env.NODE_ENV==="production"?Yo.exports=Vh():Yo.exports=Fh()),Yo.exports}var jo=Wh(),Zo={exports:{}},In={},ga;function _h(){if(ga)return In;ga=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(r,o,s){var i=null;if(s!==void 0&&(i=""+s),o.key!==void 0&&(i=""+o.key),"key"in o){s={};for(var a in o)a!=="key"&&(s[a]=o[a])}else s=o;return o=s.ref,{$$typeof:n,type:r,key:i,ref:o!==void 0?o:null,props:s}}return In.Fragment=e,In.jsx=t,In.jsxs=t,In}var br={},ya;function Uh(){return ya||(ya=1,process.env.NODE_ENV!=="production"&&(function(){function n(C){if(C==null)return null;if(typeof C=="function")return C.$$typeof===$?null:C.displayName||C.name||null;if(typeof C=="string")return C;switch(C){case g:return"Fragment";case w:return"Profiler";case y:return"StrictMode";case T:return"Suspense";case v:return"SuspenseList";case _:return"Activity"}if(typeof C=="object")switch(typeof C.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),C.$$typeof){case m:return"Portal";case E:return C.displayName||"Context";case x:return(C._context.displayName||"Context")+".Consumer";case b:var B=C.render;return C=C.displayName,C||(C=B.displayName||B.name||"",C=C!==""?"ForwardRef("+C+")":"ForwardRef"),C;case S:return B=C.displayName||null,B!==null?B:n(C.type)||"Memo";case R:B=C._payload,C=C._init;try{return n(C(B))}catch{}}return null}function e(C){return""+C}function t(C){try{e(C);var B=!1}catch{B=!0}if(B){B=console;var V=B.error,U=typeof Symbol=="function"&&Symbol.toStringTag&&C[Symbol.toStringTag]||C.constructor.name||"Object";return V.call(B,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",U),e(C)}}function r(C){if(C===g)return"<>";if(typeof C=="object"&&C!==null&&C.$$typeof===R)return"<...>";try{var B=n(C);return B?"<"+B+">":"<...>"}catch{return"<...>"}}function o(){var C=Y.A;return C===null?null:C.getOwner()}function s(){return Error("react-stack-top-frame")}function i(C){if(pe.call(C,"key")){var B=Object.getOwnPropertyDescriptor(C,"key").get;if(B&&B.isReactWarning)return!1}return C.key!==void 0}function a(C,B){function V(){X||(X=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",B))}V.isReactWarning=!0,Object.defineProperty(C,"key",{get:V,configurable:!0})}function l(){var C=n(this.type);return ee[C]||(ee[C]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),C=this.props.ref,C!==void 0?C:null}function c(C,B,V,U,J,oe){var F=V.ref;return C={$$typeof:f,type:C,key:B,props:V,_owner:U},(F!==void 0?F:null)!==null?Object.defineProperty(C,"ref",{enumerable:!1,get:l}):Object.defineProperty(C,"ref",{enumerable:!1,value:null}),C._store={},Object.defineProperty(C._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(C,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(C,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.defineProperty(C,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:oe}),Object.freeze&&(Object.freeze(C.props),Object.freeze(C)),C}function d(C,B,V,U,J,oe){var F=B.children;if(F!==void 0)if(U)if(Z(F)){for(U=0;U<F.length;U++)u(F[U]);Object.freeze&&Object.freeze(F)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else u(F);if(pe.call(B,"key")){F=n(C);var Ne=Object.keys(B).filter(function(Be){return Be!=="key"});U=0<Ne.length?"{key: someKey, "+Ne.join(": ..., ")+": ...}":"{key: someKey}",Ce[F+U]||(Ne=0<Ne.length?"{"+Ne.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
5
+ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),t.useMemoCache(e)}})()),fa}var ga;function _h(){return ga||(ga=1,process.env.NODE_ENV==="production"?Yo.exports=Fh():Yo.exports=Wh()),Yo.exports}var jo=_h(),Zo={exports:{}},In={},ya;function Uh(){if(ya)return In;ya=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(r,o,s){var i=null;if(s!==void 0&&(i=""+s),o.key!==void 0&&(i=""+o.key),"key"in o){s={};for(var a in o)a!=="key"&&(s[a]=o[a])}else s=o;return o=s.ref,{$$typeof:n,type:r,key:i,ref:o!==void 0?o:null,props:s}}return In.Fragment=e,In.jsx=t,In.jsxs=t,In}var br={},ba;function qh(){return ba||(ba=1,process.env.NODE_ENV!=="production"&&(function(){function n(C){if(C==null)return null;if(typeof C=="function")return C.$$typeof===$?null:C.displayName||C.name||null;if(typeof C=="string")return C;switch(C){case g:return"Fragment";case w:return"Profiler";case y:return"StrictMode";case T:return"Suspense";case v:return"SuspenseList";case K:return"Activity"}if(typeof C=="object")switch(typeof C.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),C.$$typeof){case m:return"Portal";case E:return C.displayName||"Context";case x:return(C._context.displayName||"Context")+".Consumer";case b:var B=C.render;return C=C.displayName,C||(C=B.displayName||B.name||"",C=C!==""?"ForwardRef("+C+")":"ForwardRef"),C;case S:return B=C.displayName||null,B!==null?B:n(C.type)||"Memo";case R:B=C._payload,C=C._init;try{return n(C(B))}catch{}}return null}function e(C){return""+C}function t(C){try{e(C);var B=!1}catch{B=!0}if(B){B=console;var V=B.error,_=typeof Symbol=="function"&&Symbol.toStringTag&&C[Symbol.toStringTag]||C.constructor.name||"Object";return V.call(B,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",_),e(C)}}function r(C){if(C===g)return"<>";if(typeof C=="object"&&C!==null&&C.$$typeof===R)return"<...>";try{var B=n(C);return B?"<"+B+">":"<...>"}catch{return"<...>"}}function o(){var C=Y.A;return C===null?null:C.getOwner()}function s(){return Error("react-stack-top-frame")}function i(C){if(pe.call(C,"key")){var B=Object.getOwnPropertyDescriptor(C,"key").get;if(B&&B.isReactWarning)return!1}return C.key!==void 0}function a(C,B){function V(){X||(X=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",B))}V.isReactWarning=!0,Object.defineProperty(C,"key",{get:V,configurable:!0})}function l(){var C=n(this.type);return ee[C]||(ee[C]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),C=this.props.ref,C!==void 0?C:null}function c(C,B,V,_,J,oe){var F=V.ref;return C={$$typeof:f,type:C,key:B,props:V,_owner:_},(F!==void 0?F:null)!==null?Object.defineProperty(C,"ref",{enumerable:!1,get:l}):Object.defineProperty(C,"ref",{enumerable:!1,value:null}),C._store={},Object.defineProperty(C._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(C,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(C,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.defineProperty(C,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:oe}),Object.freeze&&(Object.freeze(C.props),Object.freeze(C)),C}function d(C,B,V,_,J,oe){var F=B.children;if(F!==void 0)if(_)if(Z(F)){for(_=0;_<F.length;_++)u(F[_]);Object.freeze&&Object.freeze(F)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else u(F);if(pe.call(B,"key")){F=n(C);var Ne=Object.keys(B).filter(function(Be){return Be!=="key"});_=0<Ne.length?"{key: someKey, "+Ne.join(": ..., ")+": ...}":"{key: someKey}",Ce[F+_]||(Ne=0<Ne.length?"{"+Ne.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
6
6
  let props = %s;
7
7
  <%s {...props} />
8
8
  React keys must be passed directly to JSX without using spread:
9
9
  let props = %s;
10
- <%s key={someKey} {...props} />`,U,F,Ne,F),Ce[F+U]=!0)}if(F=null,V!==void 0&&(t(V),F=""+V),i(B)&&(t(B.key),F=""+B.key),"key"in B){V={};for(var je in B)je!=="key"&&(V[je]=B[je])}else V=B;return F&&a(V,typeof C=="function"?C.displayName||C.name||"Unknown":C),c(C,F,V,o(),J,oe)}function u(C){h(C)?C._store&&(C._store.validated=1):typeof C=="object"&&C!==null&&C.$$typeof===R&&(C._payload.status==="fulfilled"?h(C._payload.value)&&C._payload.value._store&&(C._payload.value._store.validated=1):C._store&&(C._store.validated=1))}function h(C){return typeof C=="object"&&C!==null&&C.$$typeof===f}var p=z,f=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),E=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),$=Symbol.for("react.client.reference"),Y=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,pe=Object.prototype.hasOwnProperty,Z=Array.isArray,q=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(C){return C()}};var X,ee={},L=p.react_stack_bottom_frame.bind(p,s)(),Se=q(r(s)),Ce={};br.Fragment=g,br.jsx=function(C,B,V){var U=1e4>Y.recentlyCreatedOwnerStacks++;return d(C,B,V,!1,U?Error("react-stack-top-frame"):L,U?q(r(C)):Se)},br.jsxs=function(C,B,V){var U=1e4>Y.recentlyCreatedOwnerStacks++;return d(C,B,V,!0,U?Error("react-stack-top-frame"):L,U?q(r(C)):Se)}})()),br}var ba;function qh(){return ba||(ba=1,process.env.NODE_ENV==="production"?Zo.exports=_h():Zo.exports=Uh()),Zo.exports}var N=qh();function Kh(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Me(n){this.content=n}Me.prototype={constructor:Me,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),s=r.content.slice();return o==-1?s.push(t||n,e):(s[o+1]=e,t&&(s[o]=t)),new Me(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Me(t)},addToStart:function(n,e){return new Me([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Me(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),s=r.find(n);return o.splice(s==-1?o.length:s,0,e,t),new Me(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Me.from(n),n.size?new Me(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Me.from(n),n.size?new Me(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Me.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};Me.from=function(n){if(n instanceof Me)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Me(e)};function Tc(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),s=e.child(r);if(o==s){t+=o.nodeSize;continue}if(!o.sameMarkup(s))return t;if(o.isText&&o.text!=s.text){for(let i=0;o.text[i]==s.text[i];i++)t++;return t}if(o.content.size||s.content.size){let i=Tc(o.content,s.content,t+1);if(i!=null)return i}t+=o.nodeSize}}function Nc(n,e,t,r){for(let o=n.childCount,s=e.childCount;;){if(o==0||s==0)return o==s?null:{a:t,b:r};let i=n.child(--o),a=e.child(--s),l=i.nodeSize;if(i==a){t-=l,r-=l;continue}if(!i.sameMarkup(a))return{a:t,b:r};if(i.isText&&i.text!=a.text){let c=0,d=Math.min(i.text.length,a.text.length);for(;c<d&&i.text[i.text.length-c-1]==a.text[a.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||a.content.size){let c=Nc(i.content,a.content,t-1,r-1);if(c)return c}t-=l,r-=l}}class M{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,s){for(let i=0,a=0;a<t;i++){let l=this.content[i],c=a+l.nodeSize;if(c>e&&r(l,o+a,s||null,i)!==!1&&l.content.size){let d=a+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,t-d),r,o+d)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let s="",i=!0;return this.nodesBetween(e,t,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,t-l):a.isLeaf?o?typeof o=="function"?o(a):o:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(i?i=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)o.push(e.content[s]);return new M(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let s=0,i=0;i<t;s++){let a=this.content[s],l=i+a.nodeSize;l>e&&((i<e||l>t)&&(a.isText?a=a.cut(Math.max(0,e-i),Math.min(a.text.length,t-i)):a=a.cut(Math.max(0,e-i-1),Math.min(a.content.size,t-i-1))),r.push(a),o+=a.nodeSize),i=l}return new M(r,o)}cutByIndex(e,t){return e==t?M.empty:e==0&&t==this.content.length?this:new M(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new M(o,s)}addToStart(e){return new M([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new M(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return Tc(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Nc(this,e,t,r)}findIndex(e){if(e==0)return xr(0,e);if(e==this.size)return xr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let o=this.child(t),s=r+o.nodeSize;if(s>=e)return s==e?xr(t+1,s):xr(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return M.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new M(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return M.empty;let t,r=0;for(let o=0;o<e.length;o++){let s=e[o];r+=s.nodeSize,o&&s.isText&&e[o-1].sameMarkup(s)?(t||(t=e.slice(0,o)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new M(t||e,r)}static from(e){if(!e)return M.empty;if(e instanceof M)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new M([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}M.empty=new M([],0);const es={index:0,offset:0};function xr(n,e){return es.index=n,es.offset=e,es}function Wr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Wr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Wr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let ne=class $s{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let s=e[o];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,o));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Wr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=r.create(t.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return $s.none;if(e instanceof $s)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};ne.none=[];class _r extends Error{}class O{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Oc(this.content,e+this.openStart,t);return r&&new O(r,this.openStart,this.openEnd)}removeBetween(e,t){return new O(Ac(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return O.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new O(M.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)o++;return new O(e,r,o)}}O.empty=new O(M.empty,0,0);function Ac(n,e,t){let{index:r,offset:o}=n.findIndex(e),s=n.maybeChild(r),{index:i,offset:a}=n.findIndex(t);if(o==e||s.isText){if(a!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Ac(s.content,e-o-1,t-o-1)))}function Oc(n,e,t,r){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o);if(s==e||i.isText)return r&&!r.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let a=Oc(i.content,e-s-1,t,i);return a&&n.replaceChild(o,i.copy(a))}function Jh(n,e,t){if(t.openStart>n.depth)throw new _r("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new _r("Inconsistent open depths");return Rc(n,e,t,0)}function Rc(n,e,t,r){let o=n.index(r),s=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let i=Rc(n,e,t,r+1);return s.copy(s.content.replaceChild(o,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,a=i.content;return Yt(i,a.cut(0,n.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:i,end:a}=Gh(t,n);return Yt(s,jc(n,i,a,e,r))}else return Yt(s,Ur(n,e,r))}function Dc(n,e){if(!e.type.compatibleContent(n.type))throw new _r("Cannot join "+e.type.name+" onto "+n.type.name)}function Is(n,e,t){let r=n.node(t);return Dc(r,e.node(t)),r}function Xt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Un(n,e,t,r){let o=(e||n).node(t),s=0,i=e?e.index(t):o.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Xt(n.nodeAfter,r),s++));for(let a=s;a<i;a++)Xt(o.child(a),r);e&&e.depth==t&&e.textOffset&&Xt(e.nodeBefore,r)}function Yt(n,e){return n.type.checkContent(e),n.copy(e)}function jc(n,e,t,r,o){let s=n.depth>o&&Is(n,e,o+1),i=r.depth>o&&Is(t,r,o+1),a=[];return Un(null,n,o,a),s&&i&&e.index(o)==t.index(o)?(Dc(s,i),Xt(Yt(s,jc(n,e,t,r,o+1)),a)):(s&&Xt(Yt(s,Ur(n,e,o+1)),a),Un(e,t,o,a),i&&Xt(Yt(i,Ur(t,r,o+1)),a)),Un(r,null,o,a),new M(a)}function Ur(n,e,t){let r=[];if(Un(null,n,t,r),n.depth>t){let o=Is(n,e,t+1);Xt(Yt(o,Ur(n,e,t+1)),r)}return Un(e,null,t,r),new M(r)}function Gh(n,e){let t=e.depth-n.openStart,r=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)r=e.node(o).copy(M.from(r));return{start:r.resolveNoCache(n.openStart+t),end:r.resolveNoCache(r.content.size-n.openEnd-t)}}class tr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.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,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)o+=r.child(s).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return ne.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let a=r;r=o,o=a}let s=r.marks;for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!o||!s[i].isInSet(o.marks))&&(s=s[i--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!o||!r[s].isInSet(o.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new qr(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 t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,s=t;for(let i=e;;){let{index:a,offset:l}=i.content.findIndex(s),c=s-l;if(r.push(i,a,o+l),!c||(i=i.child(a),i.isText))break;s=c-1,o+=l+1}return new tr(t,r,s)}static resolveCached(e,t){let r=xa.get(e);if(r)for(let s=0;s<r.elts.length;s++){let i=r.elts[s];if(i.pos==t)return i}else xa.set(e,r=new Xh);let o=r.elts[r.i]=tr.resolve(e,t);return r.i=(r.i+1)%Yh,o}}class Xh{constructor(){this.elts=[],this.i=0}}const Yh=12,xa=new WeakMap;class qr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Qh=Object.create(null);class Je{constructor(e,t,r,o=ne.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||M.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,o=0){this.content.nodesBetween(e,t,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,t,r,o){return this.content.textBetween(e,t,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,t,r){return this.type==e&&Wr(this.attrs,t||e.defaultAttrs||Qh)&&ne.sameSet(this.marks,r||ne.none)}copy(e=null){return e==this.content?this:new Je(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Je(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return O.empty;let o=this.resolve(e),s=this.resolve(t),i=r?0:o.sharedDepth(t),a=o.start(i),l=o.node(i).content.cut(o.pos-a,s.pos-a);return new O(l,o.depth-i,s.depth-i)}replace(e,t,r){return Jh(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return tr.resolveCached(this,e)}resolveNoCache(e){return tr.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.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()+")"),Lc(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=M.empty,o=0,s=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,o,s),a=i&&i.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let l=o;l<s;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let s=this.contentMatchAt(e).matchType(r),i=s&&s.matchFragment(this.content,t);return i?i.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=ne.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!ne.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t 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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=M.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,o,r);return s.type.checkAttrs(s.attrs),s}}Je.prototype.text=void 0;class Kr extends Je{constructor(e,t,r,o){if(super(e,t,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):Lc(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Kr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Kr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Lc(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class tn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Zh(e,t);if(r.next==null)return tn.empty;let o=zc(r);r.next&&r.err("Unexpected trailing text");let s=ip(sp(o));return ap(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let s=t;o&&s<r;s++)o=o.matchType(e.child(s).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:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function s(i,a){let l=i.matchFragment(e,r);if(l&&(!t||l.validEnd))return M.from(a.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:d,next:u}=i.next[c];if(!(d.isText||d.hasRequiredAttrs())&&o.indexOf(u)==-1){o.push(u);let h=s(u,a.concat(d));if(h)return h}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),s=o.match;if(s.matchType(e)){let i=[];for(let a=o;a.type;a=a.via)i.push(a.type);return i.reverse()}for(let i=0;i<s.next.length;i++){let{type:a,next:l}=s.next[i];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!o.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:o}),t[a.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 t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let s=o+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)s+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return s}).join(`
11
- `)}}tn.empty=new tn(!0);class Zh{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),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 zc(n){let e=[];do e.push(ep(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function ep(n){let e=[];do e.push(tp(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function tp(n){let e=op(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=np(n,e);else break;return e}function wa(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function np(n,e){let t=wa(n),r=t;return n.eat(",")&&(n.next!="}"?r=wa(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function rp(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let s in t){let i=t[s];i.isInGroup(e)&&o.push(i)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function op(n){if(n.eat("(")){let e=zc(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=rp(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function sp(n){let e=[[]];return o(s(n,0),t()),e;function t(){return e.push([])-1}function r(i,a,l){let c={term:l,to:a};return e[i].push(c),c}function o(i,a){i.forEach(l=>l.to=a)}function s(i,a){if(i.type=="choice")return i.exprs.reduce((l,c)=>l.concat(s(c,a)),[]);if(i.type=="seq")for(let l=0;;l++){let c=s(i.exprs[l],a);if(l==i.exprs.length-1)return c;o(c,a=t())}else if(i.type=="star"){let l=t();return r(a,l),o(s(i.expr,l),l),[r(l)]}else if(i.type=="plus"){let l=t();return o(s(i.expr,a),l),o(s(i.expr,l),l),[r(l)]}else{if(i.type=="opt")return[r(a)].concat(s(i.expr,a));if(i.type=="range"){let l=a;for(let c=0;c<i.min;c++){let d=t();o(s(i.expr,l),d),l=d}if(i.max==-1)o(s(i.expr,l),l);else for(let c=i.min;c<i.max;c++){let d=t();r(l,d),o(s(i.expr,l),d),l=d}return[r(l)]}else{if(i.type=="name")return[r(a,void 0,i.value)];throw new Error("Unknown expr type")}}}}function $c(n,e){return e-n}function ka(n,e){let t=[];return r(e),t.sort($c);function r(o){let s=n[o];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(o);for(let i=0;i<s.length;i++){let{term:a,to:l}=s[i];!a&&t.indexOf(l)==-1&&r(l)}}}function ip(n){let e=Object.create(null);return t(ka(n,0));function t(r){let o=[];r.forEach(i=>{n[i].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let d=0;d<o.length;d++)o[d][0]==a&&(c=o[d][1]);ka(n,l).forEach(d=>{c||o.push([a,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let s=e[r.join(",")]=new tn(r.indexOf(n.length-1)>-1);for(let i=0;i<o.length;i++){let a=o[i][1].sort($c);s.next.push({type:o[i][0],next:e[a.join(",")]||t(a)})}return s}}function ap(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],s=!o.validEnd,i=[];for(let a=0;a<o.next.length;a++){let{type:l,next:c}=o.next[a];i.push(l.name),s&&!(l.isText||l.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ic(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Pc(n,e){let t=Object.create(null);for(let r in n){let o=e&&e[r];if(o===void 0){let s=n[r];if(s.hasDefault)o=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=o}return t}function Hc(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);for(let o in n){let s=n[o];s.validate&&s.validate(e[o])}}function Bc(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new cp(n,r,e[r]);return t}let va=class Vc{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Bc(e,r.attrs),this.defaultAttrs=Ic(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:Pc(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Je(this,this.computeAttrs(e),M.from(t),ne.setFrom(r))}createChecked(e=null,t,r){return t=M.from(t),this.checkContent(t),new Je(this,this.computeAttrs(e),t,ne.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=M.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let o=this.contentMatch.matchFragment(t),s=o&&o.fillBefore(M.empty,!0);return s?new Je(this,e,t.append(s),ne.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.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){Hc(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 t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:ne.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,i)=>r[s]=new Vc(s,t,i));let o=t.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 s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function lp(n,e,t){let r=t.split("|");return o=>{let s=o===null?"null":typeof o;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class cp{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?lp(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Lo{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Bc(e,o.attrs),this.excluded=null;let s=Ic(this.attrs);this.instance=s?new ne(this,s):null}create(e=null){return!e&&this.instance?this.instance:new ne(this,Pc(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((s,i)=>r[s]=new Lo(s,o++,t,i)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Hc(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Fc{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=Me.from(e.nodes),t.marks=Me.from(e.marks||{}),this.nodes=va.compile(this.spec.nodes,this),this.marks=Lo.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 s=this.nodes[o],i=s.spec.content||"",a=s.spec.marks;if(s.contentMatch=r[i]||(r[i]=tn.parse(i,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=a=="_"?null:a?Sa(this,a.split(" ")):a==""||!s.inlineContent?[]:null}for(let o in this.marks){let s=this.marks[o],i=s.spec.excludes;s.excluded=i==null?[s]:i==""?[]:Sa(this,i.split(" "))}this.nodeFromJSON=o=>Je.fromJSON(this,o),this.markFromJSON=o=>ne.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof va){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(t,r,o)}text(e,t){let r=this.nodes.text;return new Kr(r,r.defaultAttrs,e,ne.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Sa(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],s=n.marks[o],i=s;if(s)t.push(s);else for(let a in n.marks){let l=n.marks[a];(o=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(o)>-1)&&t.push(i=l)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function dp(n){return n.tag!=null}function up(n){return n.style!=null}class jt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(dp(o))this.tags.push(o);else if(up(o)){let s=/[^=]*/.exec(o.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=e.nodes[o.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Ma(this,t,!1);return r.addAll(e,ne.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Ma(this,t,!0);return r.addAll(e,ne.none,t.from,t.to),O.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(fp(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(e);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(e,t,r,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let i=this.styles[s],a=i.style;if(!(a.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(i.getAttrs){let l=i.getAttrs(t);if(l===!1)continue;i.attrs=l||void 0}return i}}}static schemaRules(e){let t=[];function r(o){let s=o.priority==null?50:o.priority,i=0;for(;i<t.length;i++){let a=t[i];if((a.priority==null?50:a.priority)<s)break}t.splice(i,0,o)}for(let o in e.marks){let s=e.marks[o].spec.parseDOM;s&&s.forEach(i=>{r(i=Ea(i)),i.mark||i.ignore||i.clearMark||(i.mark=o)})}for(let o in e.nodes){let s=e.nodes[o].spec.parseDOM;s&&s.forEach(i=>{r(i=Ea(i)),i.node||i.ignore||i.mark||(i.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new jt(e,jt.schemaRules(e)))}}const Wc={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},hp={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},_c={ol:!0,ul:!0},nr=1,Ps=2,qn=4;function Ca(n,e,t){return e!=null?(e?nr:0)|(e==="full"?Ps:0):n&&n.whitespace=="pre"?nr|Ps:t&~qn}class wr{constructor(e,t,r,o,s,i){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=i,this.content=[],this.activeMarks=ne.none,this.match=s||(i&qn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(M.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);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&nr)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let t=M.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(M.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Wc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ma{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,s,i=Ca(null,t.preserveWhitespace,0)|(r?qn:0);o?s=new wr(o.type,o.attrs,ne.none,!0,t.topMatch||o.type.contentMatch,i):r?s=new wr(null,null,ne.none,!0,null,i):s=new wr(e.schema.topNodeType,null,ne.none,!0,null,i),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,s=o.options&Ps?"full":this.localPreserveWS||(o.options&nr)>0,{schema:i}=this.parser;if(s==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
12
- `);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(i.linebreakReplacement.create(),t,!0),a[l]&&this.insertNode(i.text(a[l]),t,!/\S/.test(a[l]));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 a=o.content[o.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),a;_c.hasOwnProperty(i)&&this.parser.normalizeLists&&pp(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:hp.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,d=this.needsBlock;if(Wc.hasOwnProperty(i))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=l&&l.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(s),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
13
- `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=r.getPropertyValue(s);if(i)for(let a=void 0;;){let l=this.parser.matchStyle(s,i,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?t=t.filter(c=>!l.clearMark(c)):t=t.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return t}addElementByRule(e,t,r,o){let s,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(i,t.attrs||null,r,t.preserveWhitespace);l&&(s=!0,r=l)}else{let l=this.parser.schema.marks[t.mark];r=r.concat(l.create(t.attrs))}let a=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}s&&this.sync(a)&&this.open--}addAll(e,t,r,o){let s=r||0;for(let i=r?e.childNodes[r]:e.firstChild,a=o==null?null:e.childNodes[o];i!=a;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t,r){let o,s;for(let i=this.open,a=0;i>=0;i--){let l=this.nodes[i],c=l.findWrapping(e);if(c&&(!o||o.length>c.length+a)&&(o=c,s=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)t=this.enterInner(o[i],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=ne.none;for(let a of o.concat(e.marks))(s.type?s.type.allowsMarkType(a.type):Ta(a.type,e.type))&&(i=a.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,r,o){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,o)),s}enterInner(e,t,r,o=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let a=Ca(e,s,i.options);i.options&qn&&i.content.length==0&&(a|=qn);let l=ne.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):Ta(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new wr(e,t,l,o,null,a)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=nr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?0:1),i=(a,l)=>{for(;a>=0;a--){let c=t[a];if(c==""){if(a==t.length-1||a==0)continue;for(;l>=s;l--)if(i(a-1,l))return!0;return!1}else{let d=l>0||l==0&&o?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;l--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function pp(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&_c.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function fp(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Ea(n){let e={};for(let t in n)e[t]=n[t];return e}function Ta(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let s=[],i=a=>{s.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:d}=a.edge(l);if(c==e||s.indexOf(d)<0&&i(d))return!0}};if(i(o.contentMatch))return!0}}class Bt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=ts(t).createDocumentFragment());let o=r,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let a=0,l=0;for(;a<s.length&&l<i.marks.length;){let c=i.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(s[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<s.length;)o=s.pop()[1];for(;l<i.marks.length;){let c=i.marks[l++],d=this.serializeMark(c,i.isInline,t);d&&(s.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:o}=$r(ts(t),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,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let s=this.serializeMark(e.marks[o],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&$r(ts(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return $r(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Bt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Na(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Na(e.marks)}}function Na(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function ts(n){return n.document||window.document}const Aa=new WeakMap;function mp(n){let e=Aa.get(n);return e===void 0&&Aa.set(n,e=gp(n)),e}function gp(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function $r(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=mp(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=o.indexOf(" ");i>0&&(t=o.slice(0,i),o=o.slice(i+1));let a,l=t?n.createElementNS(t,o):n.createElement(o),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let h=u.indexOf(" ");h>0?l.setAttributeNS(u.slice(0,h),u.slice(h+1),c[u]):u=="style"&&l.style?l.style.cssText=c[u]:l.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let h=e[u];if(h===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:p,contentDOM:f}=$r(n,h,t,r);if(l.appendChild(p),f){if(a)throw new RangeError("Multiple content holes");a=f}}}return{dom:l,contentDOM:a}}const Uc=65535,qc=Math.pow(2,16);function yp(n,e){return n+e*qc}function Oa(n){return n&Uc}function bp(n){return(n-(n&Uc))/qc}const Kc=1,Jc=2,Ir=4,Gc=8;class Hs{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Gc)>0}get deletedBefore(){return(this.delInfo&(Kc|Ir))>0}get deletedAfter(){return(this.delInfo&(Jc|Ir))>0}get deletedAcross(){return(this.delInfo&Ir)>0}}class Ve{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Ve.empty)return Ve.empty}recover(e){let t=0,r=Oa(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+bp(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?o:0);if(l>e)break;let c=this.ranges[a+s],d=this.ranges[a+i],u=l+c;if(e<=u){let h=c?e==l?-1:e==u?1:t:t,p=l+o+(h<0?0:d);if(r)return p;let f=e==(t<0?l:u)?null:yp(a/3,e-l),m=e==l?Jc:e==u?Kc:Ir;return(t<0?e!=l:e!=u)&&(m|=Gc),new Hs(p,m,f)}o+=d-c}return r?e+o:new Hs(e+o,0,null)}touches(e,t){let r=0,o=Oa(t),s=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+s],d=l+c;if(e<=d&&a==o*3)return!0;r+=this.ranges[a+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],a=i-(this.inverted?s:0),l=i+(this.inverted?0:s),c=this.ranges[o+t],d=this.ranges[o+r];e(a,a+c,l,l+d),s+=d-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 rr{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new rr(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let o=e.getMirror(t);this.appendMap(e._maps[t],o!=null&&o<t?r+o:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new rr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let s=this.from;s<this.to;s++){let i=this._maps[s],a=i.mapResult(e,t);if(a.recover!=null){let l=this.getMirror(s);if(l!=null&&l>s&&l<this.to){s=l,e=this._maps[l].recover(a.recover);continue}}o|=a.delInfo,e=a.pos}return r?e:new Hs(e,o,null)}}const ns=Object.create(null);class De{getMap(){return Ve.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ns[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in ns)throw new RangeError("Duplicate use of step JSON ID "+e);return ns[e]=t,t.prototype.jsonID=e,t}}class fe{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new fe(e,null)}static fail(e){return new fe(null,e)}static fromReplace(e,t,r,o){try{return fe.ok(e.replace(t,r,o))}catch(s){if(s instanceof _r)return fe.fail(s.message);throw s}}}function xi(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let s=n.child(o);s.content.size&&(s=s.copy(xi(s.content,e,s))),s.isInline&&(s=e(s,t,o)),r.push(s)}return M.fromArray(r)}class Ot extends De{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new O(xi(t.content,(i,a)=>!i.isAtom||!a.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),t.openStart,t.openEnd);return fe.fromReplace(e,this.from,this.to,s)}invert(){return new Ze(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ot(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ot&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ot(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ot(t.from,t.to,e.markFromJSON(t.mark))}}De.jsonID("addMark",Ot);class Ze extends De{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new O(xi(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return fe.fromReplace(e,this.from,this.to,r)}invert(){return new Ot(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ze(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ze&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ze(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ze(t.from,t.to,e.markFromJSON(t.mark))}}De.jsonID("removeMark",Ze);class Rt extends De{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return fe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return fe.fromReplace(e,this.pos,this.pos+1,new O(M.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new Rt(this.pos,t.marks[o]);return new Rt(this.pos,this.mark)}}return new nn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Rt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Rt(t.pos,e.markFromJSON(t.mark))}}De.jsonID("addNodeMark",Rt);class nn extends De{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return fe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return fe.fromReplace(e,this.pos,this.pos+1,new O(M.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Rt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new nn(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new nn(t.pos,e.markFromJSON(t.mark))}}De.jsonID("removeNodeMark",nn);class be extends De{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&Bs(e,this.from,this.to)?fe.fail("Structure replace would overwrite content"):fe.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 be(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new be(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof be)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?O.empty:new O(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new be(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?O.empty:new O(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new be(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new be(t.from,t.to,O.fromJSON(e,t.slice),!!t.structure)}}De.jsonID("replace",be);class we extends De{constructor(e,t,r,o,s,i,a=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=a}apply(e){if(this.structure&&(Bs(e,this.from,this.gapFrom)||Bs(e,this.gapTo,this.to)))return fe.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return fe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?fe.fromReplace(e,this.from,this.to,r):fe.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 t=this.gapTo-this.gapFrom;return new we(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||s>r.pos?null:new we(t.pos,r.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new we(t.from,t.to,t.gapFrom,t.gapTo,O.fromJSON(e,t.slice),t.insert,!!t.structure)}}De.jsonID("replaceAround",we);function Bs(n,e,t){let r=n.resolve(e),o=t-e,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function xp(n,e,t,r){let o=[],s=[],i,a;n.doc.nodesBetween(e,t,(l,c,d)=>{if(!l.isInline)return;let u=l.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let h=Math.max(c,e),p=Math.min(c+l.nodeSize,t),f=r.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(f)||(i&&i.to==h&&i.mark.eq(u[m])?i.to=p:o.push(i=new Ze(h,p,u[m])));a&&a.to==h?a.to=p:s.push(a=new Ot(h,p,r))}}),o.forEach(l=>n.step(l)),s.forEach(l=>n.step(l))}function wp(n,e,t,r){let o=[],s=0;n.doc.nodesBetween(e,t,(i,a)=>{if(!i.isInline)return;s++;let l=null;if(r instanceof Lo){let c=i.marks,d;for(;d=r.isInSet(c);)(l||(l=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(i.marks)&&(l=[r]):l=i.marks;if(l&&l.length){let c=Math.min(a+i.nodeSize,t);for(let d=0;d<l.length;d++){let u=l[d],h;for(let p=0;p<o.length;p++){let f=o[p];f.step==s-1&&u.eq(o[p].style)&&(h=f)}h?(h.to=c,h.step=s):o.push({style:u,from:Math.max(a,e),to:c,step:s})}}}),o.forEach(i=>n.step(new Ze(i.from,i.to,i.style)))}function wi(n,e,t,r=t.contentMatch,o=!0){let s=n.doc.nodeAt(e),i=[],a=e+1;for(let l=0;l<s.childCount;l++){let c=s.child(l),d=a+c.nodeSize,u=r.matchType(c.type);if(!u)i.push(new be(a,d,O.empty));else{r=u;for(let h=0;h<c.marks.length;h++)t.allowsMarkType(c.marks[h].type)||n.step(new Ze(a,d,c.marks[h]));if(o&&c.isText&&t.whitespace!="pre"){let h,p=/\r?\n|\r/g,f;for(;h=p.exec(c.text);)f||(f=new O(M.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new be(a+h.index,a+h.index+h[0].length,f))}}a=d}if(!r.validEnd){let l=r.fillBefore(M.empty,!0);n.replace(a,a,new O(l,0,0))}for(let l=i.length-1;l>=0;l--)n.step(i[l])}function kp(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function jn(n){let e=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let t=n.depth,r=0,o=0;;--t){let s=n.$from.node(t),i=n.$from.index(t)+r,a=n.$to.indexAfter(t)-o;if(t<n.depth&&s.canReplace(i,a,e))return t;if(t==0||s.type.spec.isolating||!kp(s,i,a))break;i&&(r=1),a<s.childCount&&(o=1)}return null}function vp(n,e,t){let{$from:r,$to:o,depth:s}=e,i=r.before(s+1),a=o.after(s+1),l=i,c=a,d=M.empty,u=0;for(let f=s,m=!1;f>t;f--)m||r.index(f)>0?(m=!0,d=M.from(r.node(f).copy(d)),u++):l--;let h=M.empty,p=0;for(let f=s,m=!1;f>t;f--)m||o.after(f+1)<o.end(f)?(m=!0,h=M.from(o.node(f).copy(h)),p++):c++;n.step(new we(l,c,i,a,new O(d.append(h),u,p),d.size-u,!0))}function ki(n,e,t=null,r=n){let o=Sp(n,e),s=o&&Cp(r,e);return s?o.map(Ra).concat({type:e,attrs:t}).concat(s.map(Ra)):null}function Ra(n){return{type:n,attrs:null}}function Sp(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let i=s.length?s[0]:e;return t.canReplaceWith(r,o,i)?s:null}function Cp(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.child(r),i=e.contentMatch.findWrapping(s.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let l=r;a&&l<o;l++)a=a.matchType(t.child(l).type);return!a||!a.validEnd?null:i}function Mp(n,e,t){let r=M.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let a=t[i].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=M.from(t[i].type.create(t[i].attrs,r))}let o=e.start,s=e.end;n.step(new we(o,s,o,s,new O(r,0,0),t.length,!0))}function Ep(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(i,a)=>{let l=typeof o=="function"?o(i):o;if(i.isTextblock&&!i.hasMarkup(r,l)&&Tp(n.doc,n.mapping.slice(s).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",f=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!f?c=!1:!p&&f&&(c=!0)}c===!1&&Yc(n,i,a,s),wi(n,n.mapping.slice(s).map(a,1),r,void 0,c===null);let d=n.mapping.slice(s),u=d.map(a,1),h=d.map(a+i.nodeSize,1);return n.step(new we(u,h,u+1,h-1,new O(M.from(r.create(l,null,i.marks)),0,0),1,!0)),c===!0&&Xc(n,i,a,s),!1}})}function Xc(n,e,t,r){e.forEach((o,s)=>{if(o.isText){let i,a=/\r?\n|\r/g;for(;i=a.exec(o.text);){let l=n.mapping.slice(r).map(t+1+s+i.index);n.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function Yc(n,e,t,r){e.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+s);n.replaceWith(i,i+1,e.type.schema.text(`
14
- `))}})}function Tp(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function Np(n,e,t,r,o){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let i=t.create(r,null,o||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,i);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new we(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new O(M.from(i),0,0),1,!0))}function yt(n,e,t=1,r){let o=n.resolve(e),s=o.depth-t,i=r&&r[r.length-1]||o.parent;if(s<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!i.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,d=t-2;c>s;c--,d--){let u=o.node(c),h=o.index(c);if(u.type.spec.isolating)return!1;let p=u.content.cutByIndex(h,u.childCount),f=r&&r[d+1];f&&(p=p.replaceChild(0,f.type.create(f.attrs)));let m=r&&r[d]||u;if(!u.canReplace(h+1,u.childCount)||!m.type.validContent(p))return!1}let a=o.indexAfter(s),l=r&&r[0];return o.node(s).canReplaceWith(a,a,l?l.type:o.node(s+1).type)}function Ap(n,e,t=1,r){let o=n.doc.resolve(e),s=M.empty,i=M.empty;for(let a=o.depth,l=o.depth-t,c=t-1;a>l;a--,c--){s=M.from(o.node(a).copy(s));let d=r&&r[c];i=M.from(d?d.type.create(d.attrs,i):o.node(a).copy(i))}n.step(new be(e,e,new O(s.append(i),t,t),!0))}function Vt(n,e){let t=n.resolve(e),r=t.index();return Qc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Op(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let s=e.child(o),i=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Qc(n,e){return!!(n&&e&&!n.isLeaf&&Op(n,e))}function zo(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let s,i,a=r.index(o);if(o==r.depth?(s=r.nodeBefore,i=r.nodeAfter):t>0?(s=r.node(o+1),a++,i=r.node(o).maybeChild(a)):(s=r.node(o).maybeChild(a-1),i=r.node(o+1)),s&&!s.isTextblock&&Qc(s,i)&&r.node(o).canReplace(a,a+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function Rp(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,s=n.doc.resolve(e-t),i=s.node().type;if(o&&i.inlineContent){let d=i.whitespace=="pre",u=!!i.contentMatch.matchType(o);d&&!u?r=!1:!d&&u&&(r=!0)}let a=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);Yc(n,d.node(),d.before(),a)}i.inlineContent&&wi(n,e+t-1,i,s.node().contentMatchAt(s.index()),r==null);let l=n.mapping.slice(a),c=l.map(e-t);if(n.step(new be(c,l.map(e+t,-1),O.empty,!0)),r===!0){let d=n.doc.resolve(c);Xc(n,d.node(),d.before(),n.steps.length)}return n}function Dp(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let s=r.index(o);if(r.node(o).canReplaceWith(s,s,t))return r.before(o+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let s=r.indexAfter(o);if(r.node(o).canReplaceWith(s,s,t))return r.after(o+1);if(s<r.node(o).childCount)return null}return null}function Zc(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let s=0;s<t.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let i=r.depth;i>=0;i--){let a=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,l=r.index(i)+(a>0?1:0),c=r.node(i),d=!1;if(s==1)d=c.canReplace(l,l,o);else{let u=c.contentMatchAt(l).findWrapping(o.firstChild.type);d=u&&c.canReplaceWith(l,l,u[0])}if(d)return a==0?r.pos:a<0?r.before(i+1):r.after(i+1)}return null}function $o(n,e,t=e,r=O.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),s=n.resolve(t);return ed(o,s,r)?new be(e,t,r):new jp(o,s,r).fit()}function ed(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class jp{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=M.empty;for(let o=0;o<=e.depth;o++){let s=e.node(o);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=M.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(),t=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 s=this.placed,i=r.depth,a=o.depth;for(;i&&a&&s.childCount==1;)s=s.firstChild.content,i--,a--;let l=new O(s,i,a);return e>-1?new we(r.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||r.pos!=this.$to.pos?new be(r.pos,o.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(o=0),s.type.spec.isolating&&o<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,s=null;r?(s=rs(this.unplaced.content,r-1).firstChild,o=s.content):o=this.unplaced.content;let i=o.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],d,u=null;if(t==1&&(i?c.matchType(i.type)||(u=c.fillBefore(M.from(i),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:a,parent:s,inject:u};if(t==2&&i&&(d=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:a,parent:s,wrap:d};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=rs(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new O(e,t+1,Math.max(r,o.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=rs(e,t);if(o.childCount<=1&&t>0){let s=e.size-t<=t+o.size;this.unplaced=new O(Vn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new O(Vn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let i=this.unplaced,a=r?r.content:i.content,l=i.openStart-e,c=0,d=[],{match:u,type:h}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)d.push(o.child(m));u=u.matchFragment(o)}let p=a.size+e-(i.content.size-i.openEnd);for(;c<a.childCount;){let m=a.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||l==0||m.content.size)&&(u=g,d.push(td(m.mark(h.allowedMarks(m.marks)),c==1?l:0,c==a.childCount?p:-1)))}let f=c==a.childCount;f||(p=-1),this.placed=Fn(this.placed,t,M.from(d)),this.frontier[t].match=u,f&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=a;m<p;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=f?e==0?O.empty:new O(Vn(i.content,e-1,1),e-1,p<0?i.openEnd:e-1):new O(Vn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!ss(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=ss(e,t,o,r,s);if(i){for(let a=t-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],d=ss(e,a,c,l,!0);if(!d||d.childCount)continue e}return{depth:t,fit:i,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Fn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),s=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,s)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Fn(this.placed,this.depth,M.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(M.empty,!0);e.childCount&&(this.placed=Fn(this.placed,this.frontier.length,e))}}function Vn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Vn(n.firstChild.content,e-1,t)))}function Fn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Fn(n.lastChild.content,e-1,t)))}function rs(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function td(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,td(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(M.empty,!0)))),n.copy(r)}function ss(n,e,t,r,o){let s=n.node(e),i=o?n.indexAfter(e):n.index(e);if(i==s.childCount&&!t.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,i);return a&&!Lp(t,s.content,i)?a:null}function Lp(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function zp(n){return n.spec.defining||n.spec.definingForContent}function $p(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),s=n.doc.resolve(t);if(ed(o,s,r))return n.step(new be(e,t,r));let i=rd(o,s);i[i.length-1]==0&&i.pop();let a=-(o.depth+1);i.unshift(a);for(let h=o.depth,p=o.pos-1;h>0;h--,p--){let f=o.node(h).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;i.indexOf(h)>-1?a=h:o.before(h)==p&&i.splice(1,0,-h)}let l=i.indexOf(a),c=[],d=r.openStart;for(let h=r.content,p=0;;p++){let f=h.firstChild;if(c.push(f),p==r.openStart)break;h=f.content}for(let h=d-1;h>=0;h--){let p=c[h],f=zp(p.type);if(f&&!p.sameMarkup(o.node(Math.abs(a)-1)))d=h;else if(f||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+d+1)%(r.openStart+1),f=c[p];if(f)for(let m=0;m<i.length;m++){let g=i[(m+l)%i.length],y=!0;g<0&&(y=!1,g=-g);let w=o.node(g-1),x=o.index(g-1);if(w.canReplaceWith(x,x,f.type,f.marks))return n.replace(o.before(g),y?s.after(g):t,new O(nd(r.content,0,r.openStart,p),p,r.openEnd))}}let u=n.steps.length;for(let h=i.length-1;h>=0&&(n.replace(e,t,r),!(n.steps.length>u));h--){let p=i[h];p<0||(e=o.before(p),t=s.after(p))}}function nd(n,e,t,r,o){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(nd(s.content,e+1,t,r,s)))}if(e>r){let s=o.contentMatchAt(0),i=s.fillBefore(n).append(n);n=i.append(s.matchFragment(i).fillBefore(M.empty,!0))}return n}function Ip(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=Dp(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new O(M.from(r),0,0))}function Pp(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t),s=rd(r,o);for(let i=0;i<s.length;i++){let a=s[i],l=i==s.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return n.delete(r.start(a),o.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),o.indexAfter(a-1))))return n.delete(r.before(a),o.after(a))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(e-r.start(i)==r.depth-i&&t>r.end(i)&&o.end(i)-t!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return n.delete(r.before(i),t);n.delete(e,t)}function rd(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let s=n.start(o);if(s<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(s==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==s-1)&&t.push(o)}return t}class Mn extends De{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return fe.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return fe.fromReplace(e,this.pos,this.pos+1,new O(M.from(o),0,t.isLeaf?0:1))}getMap(){return Ve.empty}invert(e){return new Mn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Mn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Mn(t.pos,t.attr,t.value)}}De.jsonID("attr",Mn);class or extends De{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return fe.ok(r)}getMap(){return Ve.empty}invert(e){return new or(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new or(t.attr,t.value)}}De.jsonID("docAttr",or);let Tn=class extends Error{};Tn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Tn.prototype=Object.create(Error.prototype);Tn.prototype.constructor=Tn;Tn.prototype.name="TransformError";class vi{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new rr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Tn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=O.empty){let o=$o(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new O(M.from(r),0,0))}delete(e,t){return this.replace(e,t,O.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return $p(this,e,t,r),this}replaceRangeWith(e,t,r){return Ip(this,e,t,r),this}deleteRange(e,t){return Pp(this,e,t),this}lift(e,t){return vp(this,e,t),this}join(e,t=1){return Rp(this,e,t),this}wrap(e,t){return Mp(this,e,t),this}setBlockType(e,t=e,r,o=null){return Ep(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return Np(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new Mn(e,t,r)),this}setDocAttribute(e,t){return this.step(new or(e,t)),this}addNodeMark(e,t){return this.step(new Rt(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof ne)t.isInSet(r.marks)&&this.step(new nn(e,t));else{let o=r.marks,s,i=[];for(;s=t.isInSet(o);)i.push(new nn(e,s)),o=s.removeFromSet(o);for(let a=i.length-1;a>=0;a--)this.step(i[a])}return this}split(e,t=1,r){return Ap(this,e,t,r),this}addMark(e,t,r){return xp(this,e,t,r),this}removeMark(e,t,r){return wp(this,e,t,r),this}clearIncompatible(e,t,r){return wi(this,e,t,r),this}}const is=Object.create(null);class W{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new od(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=O.empty){let r=t.content.lastChild,o=null;for(let a=0;a<t.openEnd;a++)o=r,r=r.lastChild;let s=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:l,$to:c}=i[a],d=e.mapping.slice(s);e.replaceRange(d.map(l.pos),d.map(c.pos),a?O.empty:t),a==0&&La(e,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:a}=o[s],l=e.mapping.slice(r),c=l.map(i.pos),d=l.map(a.pos);s?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),La(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new H(e):xn(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let s=e.depth-1;s>=0;s--){let i=t<0?xn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):xn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new We(e.node(0))}static atStart(e){return xn(e,e,0,0,1)||new We(e)}static atEnd(e){return xn(e,e,e.content.size,e.childCount,-1)||new We(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=is[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in is)throw new RangeError("Duplicate use of selection JSON ID "+e);return is[e]=t,t.prototype.jsonID=e,t}getBookmark(){return H.between(this.$anchor,this.$head).getBookmark()}}W.prototype.visible=!0;class od{constructor(e,t){this.$from=e,this.$to=t}}let Da=!1;function ja(n){!Da&&!n.parent.inlineContent&&(Da=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class H extends W{constructor(e,t=e){ja(e),ja(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return W.near(r);let o=e.resolve(t.map(this.anchor));return new H(o.parent.inlineContent?o:r,r)}replace(e,t=O.empty){if(super.replace(e,t),t==O.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof H&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Io(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new H(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let s=W.findFrom(t,r,!0)||W.findFrom(t,-r,!0);if(s)t=s.$head;else return W.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(W.findFrom(e,-r,!0)||W.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new H(e,t)}}W.jsonID("text",H);class Io{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Io(e.map(this.anchor),e.map(this.head))}resolve(e){return H.between(e.resolve(this.anchor),e.resolve(this.head))}}class I extends W{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),s=e.resolve(o);return r?W.near(s):new I(s)}content(){return new O(M.from(this.node),0,0)}eq(e){return e instanceof I&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Si(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new I(e.resolve(t.anchor))}static create(e,t){return new I(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}I.prototype.visible=!1;W.jsonID("node",I);class Si{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Io(r,r):new Si(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&I.isSelectable(r)?new I(t):W.near(t)}}class We extends W{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=O.empty){if(t==O.empty){e.delete(0,e.doc.content.size);let r=W.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new We(e)}map(e){return new We(e)}eq(e){return e instanceof We}getBookmark(){return Hp}}W.jsonID("all",We);const Hp={map(){return this},resolve(n){return new We(n)}};function xn(n,e,t,r,o,s=!1){if(e.inlineContent)return H.create(n,t);for(let i=r-(o>0?0:1);o>0?i<e.childCount:i>=0;i+=o){let a=e.child(i);if(a.isAtom){if(!s&&I.isSelectable(a))return I.create(n,t-(o<0?a.nodeSize:0))}else{let l=xn(n,a,t+o,o<0?a.childCount:0,o,s);if(l)return l}t+=a.nodeSize*o}return null}function La(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof be||o instanceof we))return;let s=n.mapping.maps[r],i;s.forEach((a,l,c,d)=>{i==null&&(i=d)}),n.setSelection(W.near(n.doc.resolve(i),t))}const za=1,kr=2,$a=4;class Bp extends vi{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|za)&~kr,this.storedMarks=null,this}get selectionSet(){return(this.updated&za)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=kr,this}ensureMarks(e){return ne.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&kr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~kr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ne.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let i=this.doc.resolve(t);s=r==t?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(W.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=$a,this}get scrolledIntoView(){return(this.updated&$a)>0}}function Ia(n,e){return!e||!n?n:n.bind(e)}class Wn{constructor(e,t,r){this.name=e,this.init=Ia(t.init,r),this.apply=Ia(t.apply,r)}}const Vp=[new Wn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Wn("selection",{init(n,e){return n.selection||W.atStart(e.doc)},apply(n){return n.selection}}),new Wn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Wn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class as{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Vp.slice(),t&&t.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 Wn(r.key,r.spec.state,r))})}}class Sn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){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 t=[e],r=this.applyInner(e),o=null;for(;;){let s=!1;for(let i=0;i<this.config.plugins.length;i++){let a=this.config.plugins[i];if(a.spec.appendTransaction){let l=o?o[i].n:0,c=o?o[i].state:this,d=l<t.length&&a.spec.appendTransaction.call(a,l?t.slice(l):t,c,r);if(d&&r.filterTransaction(d,i)){if(d.setMeta("appendedTransaction",e),!o){o=[];for(let u=0;u<this.config.plugins.length;u++)o.push(u<i?{state:r,n:t.length}:{state:this,n:0})}t.push(d),r=r.applyInner(d),s=!0}o&&(o[i]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Sn(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let s=r[o];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Bp(this)}static create(e){let t=new as(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Sn(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new as(this.schema,e.plugins),r=t.fields,o=new Sn(t);for(let s=0;s<r.length;s++){let i=r[s].name;o[i]=this.hasOwnProperty(i)?this[i]:r[s].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.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],s=o.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new as(e.schema,e.plugins),s=new Sn(o);return o.fields.forEach(i=>{if(i.name=="doc")s.doc=Je.fromJSON(e.schema,t.doc);else if(i.name=="selection")s.selection=W.fromJSON(s.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,a)){s[i.name]=c.fromJSON.call(l,e,t[a],s);return}}s[i.name]=i.init(e,s)}}),s}}function sd(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=sd(o,e,{})),t[r]=o}return t}class le{constructor(e){this.spec=e,this.props={},e.props&&sd(e.props,this,this.props),this.key=e.key?e.key.key:id("plugin")}getState(e){return e[this.key]}}const ls=Object.create(null);function id(n){return n in ls?n+"$"+ ++ls[n]:(ls[n]=0,n+"$")}class he{constructor(e="key"){this.key=id(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ci=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function ad(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const ld=(n,e,t)=>{let r=ad(n,t);if(!r)return!1;let o=Mi(r);if(!o){let i=r.blockRange(),a=i&&jn(i);return a==null?!1:(e&&e(n.tr.lift(i,a).scrollIntoView()),!0)}let s=o.nodeBefore;if(yd(n,o,e,-1))return!0;if(r.parent.content.size==0&&(Nn(s,"end")||I.isSelectable(s)))for(let i=r.depth;;i--){let a=$o(n.doc,r.before(i),r.after(i),O.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=n.tr.step(a);l.setSelection(Nn(s,"end")?W.findFrom(l.doc.resolve(l.mapping.map(o.pos,-1)),-1):I.create(l.doc,o.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1},Fp=(n,e,t)=>{let r=ad(n,t);if(!r)return!1;let o=Mi(r);return o?cd(n,o,e):!1},Wp=(n,e,t)=>{let r=ud(n,t);if(!r)return!1;let o=Ei(r);return o?cd(n,o,e):!1};function cd(n,e,t){let r=e.nodeBefore,o=r,s=e.pos-1;for(;!o.isTextblock;s--){if(o.type.spec.isolating)return!1;let d=o.lastChild;if(!d)return!1;o=d}let i=e.nodeAfter,a=i,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let d=a.firstChild;if(!d)return!1;a=d}let c=$o(n.doc,s,l,O.empty);if(!c||c.from!=s||c instanceof be&&c.slice.size>=l-s)return!1;if(t){let d=n.tr.step(c);d.setSelection(H.create(d.doc,s)),t(d.scrollIntoView())}return!0}function Nn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const dd=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=Mi(r)}let i=s&&s.nodeBefore;return!i||!I.isSelectable(i)?!1:(e&&e(n.tr.setSelection(I.create(n.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function Mi(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function ud(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const hd=(n,e,t)=>{let r=ud(n,t);if(!r)return!1;let o=Ei(r);if(!o)return!1;let s=o.nodeAfter;if(yd(n,o,e,1))return!0;if(r.parent.content.size==0&&(Nn(s,"start")||I.isSelectable(s))){let i=$o(n.doc,r.before(),r.after(),O.empty);if(i&&i.slice.size<i.to-i.from){if(e){let a=n.tr.step(i);a.setSelection(Nn(s,"start")?W.findFrom(a.doc.resolve(a.mapping.map(o.pos)),1):I.create(a.doc,a.mapping.map(o.pos))),e(a.scrollIntoView())}return!0}}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+s.nodeSize).scrollIntoView()),!0):!1},pd=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=Ei(r)}let i=s&&s.nodeAfter;return!i||!I.isSelectable(i)?!1:(e&&e(n.tr.setSelection(I.create(n.doc,s.pos)).scrollIntoView()),!0)};function Ei(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const _p=(n,e)=>{let t=n.selection,r=t instanceof I,o;if(r){if(t.node.isTextblock||!Vt(n.doc,t.from))return!1;o=t.from}else if(o=zo(n.doc,t.from,-1),o==null)return!1;if(e){let s=n.tr.join(o);r&&s.setSelection(I.create(s.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Up=(n,e)=>{let t=n.selection,r;if(t instanceof I){if(t.node.isTextblock||!Vt(n.doc,t.to))return!1;r=t.to}else if(r=zo(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},qp=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),s=o&&jn(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)},fd=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
15
- `).scrollIntoView()),!0)};function Ti(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Kp=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),s=t.indexAfter(-1),i=Ti(o.contentMatchAt(s));if(!i||!o.canReplaceWith(s,s,i))return!1;if(e){let a=t.after(),l=n.tr.replaceWith(a,a,i.createAndFill());l.setSelection(W.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},md=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof We||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=Ti(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let i=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,a=n.tr.insert(i,s.createAndFill());a.setSelection(H.create(a.doc,i+1)),e(a.scrollIntoView())}return!0},gd=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(yt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),o=r&&jn(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function Jp(n){return(e,t)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof I&&e.selection.node.isBlock)return!r.parentOffset||!yt(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],i,a,l=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){l=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),a=Ti(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),s.unshift(l&&a?{type:a}:null),i=p;break}else{if(p==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof H||e.selection instanceof We)&&d.deleteSelection();let u=d.mapping.map(r.pos),h=yt(d.doc,u,s.length,s);if(h||(s[0]=a?{type:a}:null,h=yt(d.doc,u,s.length,s)),!h)return!1;if(d.split(u,s.length,s),!l&&c&&r.node(i).type!=a){let p=d.mapping.map(r.before(i)),f=d.doc.resolve(p);a&&r.node(i-1).canReplaceWith(f.index(),f.index()+1,a)&&d.setNodeMarkup(d.mapping.map(r.before(i)),a)}return t&&t(d.scrollIntoView()),!0}}const Gp=Jp(),Xp=(n,e)=>{let{$from:t,to:r}=n.selection,o,s=t.sharedDepth(r);return s==0?!1:(o=t.before(s),e&&e(n.tr.setSelection(I.create(n.doc,o))),!0)};function Yp(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,s=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(o.isTextblock||Vt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function yd(n,e,t,r){let o=e.nodeBefore,s=e.nodeAfter,i,a,l=o.type.spec.isolating||s.type.spec.isolating;if(!l&&Yp(n,e,t))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(a=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&a.matchType(i[0]||s.type).validEnd){if(t){let p=e.pos+s.nodeSize,f=M.empty;for(let y=i.length-1;y>=0;y--)f=M.from(i[y].create(null,f));f=M.from(o.copy(f));let m=n.tr.step(new we(e.pos-1,p,e.pos,p,new O(f,1,0),i.length,!0)),g=m.doc.resolve(p+2*i.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Vt(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&l?null:W.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),h=u&&jn(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&Nn(s,"start",!0)&&Nn(o,"end")){let p=o,f=[];for(;f.push(p),!p.isTextblock;)p=p.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,m.content)){if(t){let y=M.empty;for(let x=f.length-1;x>=0;x--)y=M.from(f[x].copy(y));let w=n.tr.step(new we(e.pos-f.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new O(y,f.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function bd(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return o.node(s).isTextblock?(t&&t(e.tr.setSelection(H.create(e.doc,n<0?o.start(s):o.end(s)))),!0):!1}}const Qp=bd(-1),Zp=bd(1);function ef(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s),a=i&&ki(i,n,e);return a?(r&&r(t.tr.wrap(i,a).scrollIntoView()),!0):!1}}function Pa(n,e=null){return function(t,r){let o=!1;for(let s=0;s<t.selection.ranges.length&&!o;s++){let{$from:{pos:i},$to:{pos:a}}=t.selection.ranges[s];t.doc.nodesBetween(i,a,(l,c)=>{if(o)return!1;if(!(!l.isTextblock||l.hasMarkup(n,e)))if(l.type==n)o=!0;else{let d=t.doc.resolve(c),u=d.index();o=d.parent.canReplaceWith(u,u+1,n)}})}if(!o)return!1;if(r){let s=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:a},$to:{pos:l}}=t.selection.ranges[i];s.setBlockType(a,l,n,e)}r(s.scrollIntoView())}return!0}}function Ni(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}Ni(Ci,ld,dd);Ni(Ci,hd,pd);Ni(fd,md,gd,Gp);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function tf(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s);if(!i)return!1;let a=r?t.tr:null;return nf(a,i,n,e)?(r&&r(a.scrollIntoView()),!0):!1}}function nf(n,e,t,r=null){let o=!1,s=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=i.resolve(e.start-2);s=new qr(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new qr(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let a=ki(s,t,r,e);return a?(n&&rf(n,e,a,o,t),!0):!1}function rf(n,e,t,r,o){let s=M.empty;for(let d=t.length-1;d>=0;d--)s=M.from(t[d].type.create(t[d].attrs,s));n.step(new we(e.start-(r?2:0),e.end,e.start,e.end,new O(s,0,0),t.length,!0));let i=0;for(let d=0;d<t.length;d++)t[d].type==o&&(i=d+1);let a=t.length-i,l=e.start+t.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,h=!0;d<u;d++,h=!1)!h&&yt(n.doc,l,a)&&(n.split(l,a),l+=2*a),l+=c.child(d).nodeSize;return n}function of(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,i=>i.childCount>0&&i.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?sf(e,t,n,s):af(e,t,s):!0:!1}}function sf(n,e,t,r){let o=n.tr,s=r.end,i=r.$to.end(r.depth);s<i&&(o.step(new we(s-1,i,s,i,new O(M.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new qr(o.doc.resolve(r.$from.pos),o.doc.resolve(i),r.depth));const a=jn(r);if(a==null)return!1;o.lift(r,a);let l=o.doc.resolve(o.mapping.map(s,-1)-1);return Vt(o.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&o.join(l.pos),e(o.scrollIntoView()),!0}function af(n,e,t){let r=n.tr,o=t.parent;for(let p=t.end,f=t.endIndex-1,m=t.startIndex;f>m;f--)p-=o.child(f).nodeSize,r.delete(p-1,p+1);let s=r.doc.resolve(t.start),i=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let a=t.startIndex==0,l=t.endIndex==o.childCount,c=s.node(-1),d=s.index(-1);if(!c.canReplace(d+(a?0:1),d+1,i.content.append(l?M.empty:M.from(o))))return!1;let u=s.pos,h=u+i.nodeSize;return r.step(new we(u-(a?1:0),h+(l?1:0),u+1,h-1,new O((a?M.empty:M.from(o.copy(M.empty))).append(l?M.empty:M.from(o.copy(M.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function lf(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let a=s.parent,l=a.child(i-1);if(l.type!=n)return!1;if(t){let c=l.lastChild&&l.lastChild.type==a.type,d=M.from(c?n.create():null),u=new O(M.from(n.create(null,M.from(a.type.create(null,d)))),c?3:1,0),h=s.start,p=s.end;t(e.tr.step(new we(h-(c?3:1),p,h,p,u,1,!0)).scrollIntoView())}return!0}}const Ee=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},An=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Vs=null;const mt=function(n,e,t){let r=Vs||(Vs=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},cf=function(){Vs=null},rn=function(n,e,t,r){return t&&(Ha(n,e,t,r,-1)||Ha(n,e,t,r,1))},df=/^(img|br|input|textarea|hr)$/i;function Ha(n,e,t,r,o){for(var s;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Ke(n))){let i=n.parentNode;if(!i||i.nodeType!=1||pr(n)||df.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ee(n)+(o<0?0:1),n=i}else if(n.nodeType==1){let i=n.childNodes[e+(o<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((s=i.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=o;else return!1;else n=i,e=o<0?Ke(n):0}else return!1}}function Ke(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function uf(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Ke(n)}else if(n.parentNode&&!pr(n))e=Ee(n),n=n.parentNode;else return null}}function hf(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!pr(n))e=Ee(n)+1,n=n.parentNode;else return null}}function pf(n,e,t){for(let r=e==0,o=e==Ke(n);r||o;){if(n==t)return!0;let s=Ee(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Ke(n)}}function pr(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Po=function(n){return n.focusNode&&rn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Ut(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function ff(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function mf(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Ke(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Ke(r.startContainer),r.startOffset)}}}const it=typeof navigator<"u"?navigator:null,Ba=typeof document<"u"?document:null,Ft=it&&it.userAgent||"",Fs=/Edge\/(\d+)/.exec(Ft),xd=/MSIE \d/.exec(Ft),Ws=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ft),He=!!(xd||Ws||Fs),Lt=xd?document.documentMode:Ws?+Ws[1]:Fs?+Fs[1]:0,Ge=!He&&/gecko\/(\d+)/i.test(Ft);Ge&&+(/Firefox\/(\d+)/.exec(Ft)||[0,0])[1];const _s=!He&&/Chrome\/(\d+)/.exec(Ft),Oe=!!_s,wd=_s?+_s[1]:0,Le=!He&&!!it&&/Apple Computer/.test(it.vendor),On=Le&&(/Mobile\/\w+/.test(Ft)||!!it&&it.maxTouchPoints>2),qe=On||(it?/Mac/.test(it.platform):!1),gf=it?/Win/.test(it.platform):!1,gt=/Android \d/.test(Ft),fr=!!Ba&&"webkitFontSmoothing"in Ba.documentElement.style,yf=fr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function bf(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function ct(n,e){return typeof n=="number"?n:n[e]}function xf(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Va(n,e,t){let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let i=t||n.dom;i;){if(i.nodeType!=1){i=An(i);continue}let a=i,l=a==s.body,c=l?bf(s):xf(a),d=0,u=0;if(e.top<c.top+ct(r,"top")?u=-(c.top-e.top+ct(o,"top")):e.bottom>c.bottom-ct(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+ct(o,"top")-c.top:e.bottom-c.bottom+ct(o,"bottom")),e.left<c.left+ct(r,"left")?d=-(c.left-e.left+ct(o,"left")):e.right>c.right-ct(r,"right")&&(d=e.right-c.right+ct(o,"right")),d||u)if(l)s.defaultView.scrollBy(d,u);else{let p=a.scrollLeft,f=a.scrollTop;u&&(a.scrollTop+=u),d&&(a.scrollLeft+=d);let m=a.scrollLeft-p,g=a.scrollTop-f;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let h=l?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(h))break;i=h=="absolute"?i.offsetParent:An(i)}}function wf(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let s=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let a=n.root.elementFromPoint(s,i);if(!a||a==n.dom||!n.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=t-20){r=a,o=l.top;break}}return{refDOM:r,refTop:o,stack:kd(n.dom)}}function kd(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=An(r));return e}function kf({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;vd(t,r==0?0:r-e)}function vd(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:s}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let gn=null;function vf(n){if(n.setActive)return n.setActive();if(gn)return n.focus(gn);let e=kd(n);n.focus(gn==null?{get preventScroll(){return gn={preventScroll:!0},!0}}:void 0),gn||(gn=!1,vd(e,0))}function Sd(n,e){let t,r=2e8,o,s=0,i=e.top,a=e.top,l,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let h;if(d.nodeType==1)h=d.getClientRects();else if(d.nodeType==3)h=mt(d).getClientRects();else continue;for(let p=0;p<h.length;p++){let f=h[p];if(f.top<=i&&f.bottom>=a){i=Math.max(f.bottom,i),a=Math.min(f.top,a);let m=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(m<r){t=d,r=m,o=m&&t.nodeType==3?{left:f.right<e.left?f.right:f.left,top:e.top}:e,d.nodeType==1&&m&&(s=u+(e.left>=(f.left+f.right)/2?1:0));continue}}else f.top>e.top&&!l&&f.left<=e.left&&f.right>=e.left&&(l=d,c={left:Math.max(f.left,Math.min(f.right,e.left)),top:f.top});!t&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(s=u+1)}}return!t&&l&&(t=l,o=c,r=0),t&&t.nodeType==3?Sf(t,o):!t||r&&t.nodeType==1?{node:n,offset:s}:Sd(t,o)}function Sf(n,e){let t=n.nodeValue.length,r=document.createRange();for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=St(r,1);if(s.top!=s.bottom&&Ai(e,s))return{node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function Ai(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Cf(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Mf(n,e,t){let{node:r,offset:o}=Sd(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();s=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(r,o,s)}function Ef(n,e,t,r){let o=-1;for(let s=e,i=!1;s!=n.dom;){let a=n.docView.nearestDesc(s,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!i&&l.left>r.left||l.top>r.top?o=a.posBefore:(!i&&l.right<r.left||l.bottom<r.top)&&(o=a.posAfter),i=!0),!a.contentDOM&&o<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;s=a.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function Cd(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=o;;){let i=n.childNodes[s];if(i.nodeType==1){let a=i.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(Ai(e,c))return Cd(i,e,c)}}if((s=(s+1)%r)==o)break}return n}function Tf(n,e){let t=n.dom.ownerDocument,r,o=0,s=mf(t,e.left,e.top);s&&({node:r,offset:o}=s);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),a;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!Ai(e,c)||(i=Cd(n.dom,e,c),!i))return null}if(Le)for(let c=i;r&&c;c=An(c))c.draggable&&(r=void 0);if(i=Cf(i,e),r){if(Ge&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let d=r.childNodes[o],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&o++}let c;fr&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=n.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(a=Ef(n,r,o,e))}a==null&&(a=Mf(n,i,e));let l=n.docView.nearestDesc(i,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Fa(n){return n.top<n.bottom||n.left<n.right}function St(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Fa(r))return r}return Array.prototype.find.call(t,Fa)||n.getBoundingClientRect()}const Nf=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Md(n,e,t){let{node:r,offset:o,atom:s}=n.docView.domFromPos(e,t<0?-1:1),i=fr||Ge;if(r.nodeType==3)if(i&&(Nf.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=St(mt(r,o,o),t);if(Ge&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let l=St(mt(r,o-1,o-1),-1);if(l.top==a.top){let c=St(mt(r,o,o+1),-1);if(c.top!=a.top)return Pn(c,c.left<l.left)}}return a}else{let a=o,l=o,c=t<0?1:-1;return t<0&&!o?(l++,c=-1):t>=0&&o==r.nodeValue.length?(a--,c=1):t<0?a--:l++,Pn(St(mt(r,a,l),c),c<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&o&&(t<0||o==Ke(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return cs(a.getBoundingClientRect(),!1)}if(s==null&&o<Ke(r)){let a=r.childNodes[o];if(a.nodeType==1)return cs(a.getBoundingClientRect(),!0)}return cs(r.getBoundingClientRect(),t>=0)}if(s==null&&o&&(t<0||o==Ke(r))){let a=r.childNodes[o-1],l=a.nodeType==3?mt(a,Ke(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(l)return Pn(St(l,1),!1)}if(s==null&&o<Ke(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let l=a?a.nodeType==3?mt(a,0,i?0:1):a.nodeType==1?a:null:null;if(l)return Pn(St(l,-1),!0)}return Pn(St(r.nodeType==3?mt(r):r,-t),t>=0)}function Pn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function cs(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Ed(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function Af(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return Ed(n,e,()=>{let{node:s}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let a=n.docView.nearestDesc(s,!0);if(!a)break;if(a.node.isBlock){s=a.contentDOM||a.dom;break}s=a.dom.parentNode}let i=Md(n,o.pos,1);for(let a=s.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=mt(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let d=l[c];if(d.bottom>d.top+1&&(t=="up"?i.top-d.top>(d.bottom-i.top)*2:d.bottom-i.bottom>(i.bottom-d.top)*2))return!1}}return!0})}const Of=/[\u0590-\u08ac]/;function Rf(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,s=!o,i=o==r.parent.content.size,a=n.domSelection();return a?!Of.test(r.parent.textContent)||!a.modify?t=="left"||t=="backward"?s:i:Ed(n,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),h=a.caretBidiLevel;a.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:f,focusOffset:m}=n.domSelectionRange(),g=f&&!p.contains(f.nodeType==1?f:f.parentNode)||l==f&&c==m;try{a.collapse(d,u),l&&(l!=d||c!=u)&&a.extend&&a.extend(l,c)}catch{}return h!=null&&(a.caretBidiLevel=h),g}):r.pos==r.start()||r.pos==r.end()}let Wa=null,_a=null,Ua=!1;function Df(n,e,t){return Wa==e&&_a==t?Ua:(Wa=e,_a=t,Ua=t=="up"||t=="down"?Af(n,e,t):Rf(n,e,t))}const Xe=0,qa=1,qt=2,at=3;class mr{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.dirty=Xe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let o=this.children[t];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,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>Ee(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(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let s=this.getDesc(o),i;if(s&&(!t||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)for(let i=0;i<o.children.length;i++){let a=o.children[i];if(a.size){o=a;break}}return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){let i=this.children[r],a=s+i.size;if(a>e||i instanceof Nd){o=e-s;break}s=a}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Td&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Ee(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Ee(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,a=0;;a++){let l=this.children[a],c=i+l.size;if(o==-1&&e<=c){let d=i+l.border;if(e>=d&&t<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,d);e=i;for(let u=a;u>0;u--){let h=this.children[u-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){o=Ee(h.dom)+1;break}e-=h.size}o==-1&&(o=0)}if(o>-1&&(c>t||a==this.children.length-1)){t=c;for(let d=a+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){s=Ee(u.dom);break}t+=u.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,o=!1){let s=Math.min(e,t),i=Math.max(e,t);for(let p=0,f=0;p<this.children.length;p++){let m=this.children[p],g=f+m.size;if(s>f&&i<g)return m.setSelection(e-f-m.border,t-f-m.border,r,o);f=g}let a=this.domFromPos(e,e?-1:1),l=t==e?a:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((Ge||Le)&&e==t){let{node:p,offset:f}=a;if(p.nodeType==3){if(u=!!(f&&p.nodeValue[f-1]==`
16
- `),u&&f==p.nodeValue.length)for(let m=p,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(a=l={node:g.parentNode,offset:Ee(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=p.childNodes[f-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Ge&&d.focusNode&&d.focusNode!=l.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(o=!0)}if(!(o||u&&Le)&&rn(a.node,a.offset,d.anchorNode,d.anchorOffset)&&rn(l.node,l.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==t)&&!(u&&Ge)){c.collapse(a.node,a.offset);try{e!=t&&c.extend(l.node,l.offset),h=!0}catch{}}if(!h){if(e>t){let f=a;a=l,l=f}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){let s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let a=r+s.border,l=i-s.border;if(e>=a&&t<=l){this.dirty=e==r||t==i?qt:qa,e==a&&t==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=at:s.markDirty(e-a,t-a);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?qt:at}r=i}this.dirty=qt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?qt:qa;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Td extends mr{constructor(e,t,r,o){let s,i=t.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!s)return o;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(i.nodeType!=1){let a=document.createElement("span");a.appendChild(i),i=a}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Xe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class jf extends mr{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class on extends mr{constructor(e,t,r,o,s){super(e,[],r,o),this.mark=t,this.spec=s}static create(e,t,r,o){let s=o.nodeViews[t.type.name],i=s&&s(t,o,r);return(!i||!i.dom)&&(i=Bt.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new on(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&at||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=at&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Xe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Xe}}slice(e,t,r){let o=on.create(this.parent,this.mark,!0,r),s=this.children,i=this.size;t<i&&(s=qs(s,t,i,r)),e>0&&(s=qs(s,0,e,r));for(let a=0;a<s.length;a++)s[a].parent=o;return o.children=s,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class zt extends mr{constructor(e,t,r,o,s,i,a,l,c){super(e,[],s,i),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=a}static create(e,t,r,o,s,i){let a=s.nodeViews[t.type.name],l,c=a&&a(t,s,()=>{if(!l)return i;if(l.parent)return l.parent.posBeforeChild(l)},r,o),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Bt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let h=d;return d=Rd(d,r,t),c?l=new Lf(e,t,r,o,d,u||null,h,c,s,i+1):t.isText?new Ho(e,t,r,o,d,h,s):new zt(e,t,r,o,d,u||null,h,s,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>M.empty)}return e}matchesNode(e,t,r){return this.dirty==Xe&&e.eq(this.node)&&Jr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,s=e.composing?this.localCompositionInfo(e,t):null,i=s&&s.pos>-1?s:null,a=s&&s.pos<0,l=new $f(this,i&&i.node,e);Hf(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&l.syncToMarks(d==this.node.childCount?ne.none:this.node.child(d).marks,r,e),l.placeWidget(c,e,o)},(c,d,u,h)=>{l.syncToMarks(c.marks,r,e);let p;l.findNodeMatch(c,d,u,h)||a&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(p=l.findIndexWithChild(s.node))>-1&&l.updateNodeAt(c,d,u,p,e)||l.updateNextNode(c,d,u,e,h,o)||l.addNode(c,d,u,e,o),o+=c.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==qt)&&(i&&this.protectLocalComposition(e,i),Ad(this.contentDOM,this.children,e),On&&Bf(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof H)||r<t||o>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let i=s.nodeValue,a=Vf(this.node.content,i,r-t,o-t);return a<0?null:{node:s,pos:a,text:i}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let i=new jf(this,s,t,o);e.input.compositionNodes.push(i),this.children=qs(this.children,r,r+o.length,e,i)}update(e,t,r,o){return this.dirty==at||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o),!0)}updateInner(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Xe}updateOuterDeco(e){if(Jr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Od(this.dom,this.nodeDOM,Us(this.outerDeco,this.node,t),Us(e,this.node,t)),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 Ka(n,e,t,r,o){Rd(r,e,n);let s=new zt(void 0,n,e,t,r,r,r,o,0);return s.contentDOM&&s.updateChildren(o,0),s}class Ho extends zt{constructor(e,t,r,o,s,i,a){super(e,t,r,o,s,null,i,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.dirty==at||this.dirty!=Xe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Xe||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=Xe,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let o=this.node.cut(e,t),s=document.createTextNode(o.text);return new Ho(this.parent,o,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=at)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Nd extends mr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Xe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Lf extends zt{constructor(e,t,r,o,s,i,a,l,c,d){super(e,t,r,o,s,i,a,c,d),this.spec=l}update(e,t,r,o){if(this.dirty==at)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,o){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,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 Ad(n,e,t){let r=n.firstChild,o=!1;for(let s=0;s<e.length;s++){let i=e[s],a=i.dom;if(a.parentNode==n){for(;a!=r;)r=Ja(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(a,r);if(i instanceof on){let l=r?r.previousSibling:n.lastChild;Ad(i.contentDOM,i.children,t),r=l?l.nextSibling:n.firstChild}}for(;r;)r=Ja(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const Kn=function(n){n&&(this.nodeName=n)};Kn.prototype=Object.create(null);const Kt=[new Kn];function Us(n,e,t){if(n.length==0)return Kt;let r=t?Kt[0]:new Kn,o=[r];for(let s=0;s<n.length;s++){let i=n[s].type.attrs;if(i){i.nodeName&&o.push(r=new Kn(i.nodeName));for(let a in i){let l=i[a];l!=null&&(t&&o.length==1&&o.push(r=new Kn(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return o}function Od(n,e,t,r){if(t==Kt&&r==Kt)return e;let o=e;for(let s=0;s<r.length;s++){let i=r[s],a=t[s];if(s){let l;a&&a.nodeName==i.nodeName&&o!=n&&(l=o.parentNode)&&l.nodeName.toLowerCase()==i.nodeName||(l=document.createElement(i.nodeName),l.pmIsDeco=!0,l.appendChild(o),a=Kt[0]),o=l}zf(o,a||Kt[0],i)}return o}function zf(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)o.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<o.length;s++)r.indexOf(o[s])==-1&&n.classList.add(o[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Rd(n,e,t){return Od(n,n,Kt,Us(e,t,n.nodeType!=1))}function Jr(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Ja(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class $f{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=If(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let o=0,s=this.stack.length>>1,i=Math.min(s,e.length);for(;o<i&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Xe,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1;for(let l=this.index;l<Math.min(this.index+3,this.top.children.length);l++){let c=this.top.children[l];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){a=l;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=on.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let s=-1,i;if(o>=this.preMatch.index&&(i=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,r))s=this.top.children.indexOf(i,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){s=a;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,o,s){let i=this.top.children[o];return i.dirty==at&&i.dom==i.contentDOM&&(i.dirty=qt),i.update(e,t,r,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==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=t}}updateNextNode(e,t,r,o,s,i){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof zt){let c=this.preMatch.matched.get(l);if(c!=null&&c!=s)return!1;let d=l.dom,u,h=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=at&&Jr(t,l.outerDeco));if(!h&&l.update(e,t,r,o))return this.destroyBetween(this.index,a),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(u=this.recreateWrapper(l,e,t,r,o,i)))return this.destroyBetween(this.index,a),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=qt,u.updateChildren(o,i+1),u.dirty=Xe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,s,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Jr(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let a=zt.create(this.top,t,r,o,s,i);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,t,r,o,s){let i=zt.create(this.top,e,t,r,o,s);i.contentDOM&&i.updateChildren(o,s+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,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 s=new Td(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof on;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ho)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Le||Oe)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new Nd(this.top,[],r,null);t!=this.top?t.children.push(o):t.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 If(n,e){let t=e,r=t.children.length,o=n.childCount,s=new Map,i=[];e:for(;o>0;){let a;for(;;)if(r){let c=t.children[r-1];if(c instanceof on)t=c,r=c.children.length;else{a=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let l=a.node;if(l){if(l!=n.child(o-1))break;--o,s.set(a,o),i.push(a)}}return{index:o,matched:s,matches:i.reverse()}}function Pf(n,e){return n.type.side-e.type.side}function Hf(n,e,t,r){let o=e.locals(n),s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,o,e.forChild(s,d),c),s+=d.nodeSize}return}let i=0,a=[],l=null;for(let c=0;;){let d,u;for(;i<o.length&&o[i].to==s;){let g=o[i++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(Pf);for(let g=0;g<u.length;g++)t(u[g],c,!!l)}else t(d,c,!!l);let h,p;if(l)p=-1,h=l,l=null;else if(c<n.childCount)p=c,h=n.child(c++);else break;for(let g=0;g<a.length;g++)a[g].to<=s&&a.splice(g--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)a.push(o[i++]);let f=s+h.nodeSize;if(h.isText){let g=f;i<o.length&&o[i].from<g&&(g=o[i].from);for(let y=0;y<a.length;y++)a[y].to<g&&(g=a[y].to);g<f&&(l=h.cut(g-s),h=h.cut(0,g-s),f=g,p=-1)}else for(;i<o.length&&o[i].to<f;)i++;let m=h.isInline&&!h.isLeaf?a.filter(g=>!g.inline):a.slice();r(h,m,e.forChild(s,h),p),s=f}}function Bf(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Vf(n,e,t,r){for(let o=0,s=0;o<n.childCount&&s<=r;){let i=n.child(o++),a=s;if(s+=i.nodeSize,!i.isText)continue;let l=i.text;for(;o<n.childCount;){let c=n.child(o++);if(s+=c.nodeSize,!c.isText)break;l+=c.text}if(s>=t){if(s>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=t)return a+c;if(t==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function qs(n,e,t,r,o){let s=[];for(let i=0,a=0;i<n.length;i++){let l=n[i],c=a,d=a+=l.size;c>=t||d<=e?s.push(l):(c<e&&s.push(l.slice(0,e-c,r)),o&&(s.push(o),o=void 0),d>t&&s.push(l.slice(t-c,l.size,r)))}return s}function Oi(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let a=r.resolve(i),l,c;if(Po(t)){for(l=i;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&I.isSelectable(u)&&o.parent&&!(u.isInline&&pf(t.focusNode,t.focusOffset,o.dom))){let h=o.posBefore;c=new I(i==h?a:r.resolve(h))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=i,h=i;for(let p=0;p<t.rangeCount;p++){let f=t.getRangeAt(p);u=Math.min(u,n.docView.posFromDOM(f.startContainer,f.startOffset,1)),h=Math.max(h,n.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(u<0)return null;[l,i]=h==n.state.selection.anchor?[h,u]:[u,h],a=r.resolve(i)}else l=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!c){let u=e=="pointer"||n.state.selection.head<a.pos&&!s?1:-1;c=Ri(n,d,a,u)}return c}function Dd(n){return n.editable?n.hasFocus():Ld(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function bt(n,e=!1){let t=n.state.selection;if(jd(n,t),!!Dd(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Oe){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&rn(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Wf(n);else{let{anchor:r,head:o}=t,s,i;Ga&&!(t instanceof H)&&(t.$from.parent.inlineContent||(s=Xa(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Xa(n,t.to))),n.docView.setSelection(r,o,n,e),Ga&&(s&&Ya(s),i&&Ya(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ff(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Ga=Le||Oe&&wd<63;function Xa(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(Le&&o&&o.contentEditable=="false")return ds(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return ds(o);if(s)return ds(s)}}function ds(n){return n.contentEditable="true",Le&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ya(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Ff(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Dd(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Wf(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,Ee(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&He&&Lt<=11&&(t.disabled=!0,t.disabled=!1)}function jd(n,e){if(e instanceof I){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Qa(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Qa(n)}function Qa(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Ri(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||H.between(e,t,r)}function Za(n){return n.editable&&!n.hasFocus()?!1:Ld(n)}function Ld(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function _f(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return rn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ks(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&W.findFrom(s,e)}function Ct(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function el(n,e,t){let r=n.state.selection;if(r instanceof H)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return Ct(n,new H(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Ks(n.state,e);return o&&o instanceof I?Ct(n,o):!1}else if(!(qe&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let a=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(a))&&!i.contentDOM?I.isSelectable(s)?Ct(n,new I(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):fr?Ct(n,new H(n.state.doc.resolve(e<0?a:a+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof I&&r.node.isInline)return Ct(n,new H(e>0?r.$to:r.$from));{let o=Ks(n.state,e);return o?Ct(n,o):!1}}}function Gr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Jn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function yn(n,e){return e<0?Uf(n):qf(n)}function Uf(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Ge&&t.nodeType==1&&r<Gr(t)&&Jn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let a=t.childNodes[r-1];if(Jn(a,-1))o=t,s=--r;else if(a.nodeType==3)t=a,r=t.nodeValue.length;else break}}else{if(zd(t))break;{let a=t.previousSibling;for(;a&&Jn(a,-1);)o=t.parentNode,s=Ee(a),a=a.previousSibling;if(a)t=a,r=Gr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Js(n,t,r):o&&Js(n,o,s)}function qf(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Gr(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let a=t.childNodes[r];if(Jn(a,1))s=t,i=++r;else break}else{if(zd(t))break;{let a=t.nextSibling;for(;a&&Jn(a,1);)s=a.parentNode,i=Ee(a)+1,a=a.nextSibling;if(a)t=a,r=0,o=Gr(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&Js(n,s,i)}function zd(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Kf(n,e){for(;n&&e==n.childNodes.length&&!pr(n);)e=Ee(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Jf(n,e){for(;n&&!e&&!pr(n);)e=Ee(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Js(n,e,t){if(e.nodeType!=3){let s,i;(i=Kf(e,t))?(e=i,t=0):(s=Jf(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Po(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&bt(n)},50)}function tl(n,e){let t=n.state.doc.resolve(e);if(!(Oe||gf)&&t.parent.inlineContent){let r=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(o.left-r.left)>1)return o.left<r.left?"ltr":"rtl"}if(e<t.end()){let o=n.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(o.left-r.left)>1)return o.left>r.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function nl(n,e,t){let r=n.state.selection;if(r instanceof H&&!r.empty||t.indexOf("s")>-1||qe&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Ks(n.state,e);if(i&&i instanceof I)return Ct(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,a=r instanceof We?W.near(i,e):W.findFrom(i,e);return a?Ct(n,a):!1}return!1}function rl(n,e){if(!(n.state.selection instanceof H))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function ol(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Gf(n){if(!Le||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;ol(n,r,"true"),setTimeout(()=>ol(n,r,"false"),20)}return!1}function Xf(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Yf(n,e){let t=e.keyCode,r=Xf(e);if(t==8||qe&&t==72&&r=="c")return rl(n,-1)||yn(n,-1);if(t==46&&!e.shiftKey||qe&&t==68&&r=="c")return rl(n,1)||yn(n,1);if(t==13||t==27)return!0;if(t==37||qe&&t==66&&r=="c"){let o=t==37?tl(n,n.state.selection.from)=="ltr"?-1:1:-1;return el(n,o,r)||yn(n,o)}else if(t==39||qe&&t==70&&r=="c"){let o=t==39?tl(n,n.state.selection.from)=="ltr"?1:-1:1;return el(n,o,r)||yn(n,o)}else{if(t==38||qe&&t==80&&r=="c")return nl(n,-1,r)||yn(n,-1);if(t==40||qe&&t==78&&r=="c")return Gf(n)||nl(n,1,r)||yn(n,1);if(r==(qe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Di(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let i=n.someProp("clipboardSerializer")||Bt.fromSchema(n.state.schema),a=Vd(),l=a.createElement("div");l.appendChild(i.serializeFragment(r,{document:a}));let c=l.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Bd[c.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let f=a.createElement(d[p]);for(;l.firstChild;)f.appendChild(l.firstChild);l.appendChild(f),u++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${u?` -${u}`:""} ${JSON.stringify(t)}`);let h=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
17
-
18
- `);return{dom:l,text:h,slice:e}}function $d(n,e,t,r,o){let s=o.parent.type.spec.code,i,a;if(!t&&!e)return null;let l=!!e&&(r||s||!t);if(l){if(n.someProp("transformPastedText",h=>{e=h(e,s||r,n)}),s)return a=new O(M.from(n.state.schema.text(e.replace(/\r\n?/g,`
19
- `))),0,0),n.someProp("transformPasted",h=>{a=h(a,n,!0)}),a;let u=n.someProp("clipboardTextParser",h=>h(e,o,r,n));if(u)a=u;else{let h=o.marks(),{schema:p}=n.state,f=Bt.fromSchema(p);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=i.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(p.text(m,h)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),i=tm(t),fr&&nm(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let h=i.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;i=h}if(a||(a=(n.someProp("clipboardParser")||n.someProp("domParser")||jt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(l||d),context:o,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!Qf.test(u.parentNode.nodeName)?{ignore:!0}:null}})),d)a=rm(sl(a,+d[1],+d[2]),d[4]);else if(a=O.maxOpen(Zf(a.content,o),!0),a.openStart||a.openEnd){let u=0,h=0;for(let p=a.content.firstChild;u<a.openStart&&!p.type.spec.isolating;u++,p=p.firstChild);for(let p=a.content.lastChild;h<a.openEnd&&!p.type.spec.isolating;h++,p=p.lastChild);a=sl(a,u,h)}return n.someProp("transformPasted",u=>{a=u(a,n,l)}),a}const Qf=/^(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 Zf(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(n.forEach(i=>{if(!s)return;let a=r.findWrapping(i.type),l;if(!a)return s=null;if(l=s.length&&o.length&&Pd(a,o,i,s[s.length-1],0))s[s.length-1]=l;else{s.length&&(s[s.length-1]=Hd(s[s.length-1],o.length));let c=Id(i,a);s.push(c),r=r.matchType(c.type),o=a}}),s)return M.from(s)}return n}function Id(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,M.from(n));return n}function Pd(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=Pd(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(M.from(Id(t,n,o+1))))}}function Hd(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Hd(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(M.empty,!0);return n.copy(t.append(r))}function Gs(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,a=i.content;return n.childCount>1&&(s=0),o<r-1&&(a=Gs(a,e,t,r,o+1,s)),o>=t&&(a=e<0?i.contentMatchAt(0).fillBefore(a,s<=o).append(a):a.append(i.contentMatchAt(i.childCount).fillBefore(M.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(a))}function sl(n,e,t){return e<n.openStart&&(n=new O(Gs(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new O(Gs(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Bd={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 il=null;function Vd(){return il||(il=document.implementation.createHTMLDocument("title"))}let us=null;function em(n){let e=window.trustedTypes;return e?(us||(us=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),us.createHTML(n)):n}function tm(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Vd().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&Bd[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=em(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function nm(n){let e=n.querySelectorAll(Oe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function rm(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let a=r.length-2;a>=0;a-=2){let l=t.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;o=M.from(l.create(r[a+1],o)),s++,i++}return new O(o,s,i)}const ze={},$e={},om={touchstart:!0,touchmove:!0};class sm{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 im(n){for(let e in ze){let t=ze[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{lm(n,r)&&!ji(n,r)&&(n.editable||!(r.type in $e))&&t(n,r)},om[e]?{passive:!0}:void 0)}Le&&n.dom.addEventListener("input",()=>null),Xs(n)}function Dt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function am(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Xs(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>ji(n,r))})}function ji(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function lm(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function cm(n,e){!ji(n,e)&&ze[e.type]&&(n.editable||!(e.type in $e))&&ze[e.type](n,e)}$e.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Wd(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(gt&&Oe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),On&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Ut(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Yf(n,t)?t.preventDefault():Dt(n,"key")};$e.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};$e.keypress=(n,e)=>{let t=e;if(Wd(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||qe&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof H)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,o,s))&&n.dispatch(s()),t.preventDefault()}};function Bo(n){return{left:n.clientX,top:n.clientY}}function dm(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Li(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,a=>i>s.depth?a(n,t,s.nodeAfter,s.before(i),o,!0):a(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function En(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function um(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&I.isSelectable(r)?(En(n,new I(t)),!0):!1}function hm(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof I&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let a=i>s.depth?s.nodeAfter:s.node(i);if(I.isSelectable(a)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(En(n,I.create(n.state.doc,o)),!0):!1}function pm(n,e,t,r,o){return Li(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?hm(n,t):um(n,t))}function fm(n,e,t,r){return Li(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function mm(n,e,t,r){return Li(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||gm(n,t,r)}function gm(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(En(n,H.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),a=o.before(s);if(i.inlineContent)En(n,H.create(r,a+1,a+1+i.content.size));else if(I.isSelectable(i))En(n,I.create(r,a));else continue;return!0}}function zi(n){return Xr(n)}const Fd=qe?"metaKey":"ctrlKey";ze.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=zi(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&dm(t,n.input.lastClick)&&!t[Fd]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s,button:t.button};let i=n.posAtCoords(Bo(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new ym(n,i,t,!!r)):(s=="doubleClick"?fm:mm)(n,i.pos,i.inside,t)?t.preventDefault():Dt(n,"pointer"))};class ym{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Fd],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let d=e.state.doc.resolve(t.pos);s=d.parent,i=d.depth?d.before():0}const a=o?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof I&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ge&&!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)),Dt(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(()=>bt(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Bo(e))),this.updateAllowDefault(e),this.allowDefault||!t?Dt(this.view,"pointer"):pm(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Le&&this.mightDrag&&!this.mightDrag.node.isAtom||Oe&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(En(this.view,W.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Dt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Dt(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)}}ze.touchstart=n=>{n.input.lastTouch=Date.now(),zi(n),Dt(n,"pointer")};ze.touchmove=n=>{n.input.lastTouch=Date.now(),Dt(n,"pointer")};ze.contextmenu=n=>zi(n);function Wd(n,e){return n.composing?!0:Le&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const bm=gt?5e3:-1;$e.compositionstart=$e.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof H&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Xr(n,!0),n.markCursor=null;else if(Xr(n,!e.selection.empty),Ge&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let a=n.domSelection();a&&a.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}_d(n,bm)};$e.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,_d(n,20))};function _d(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Xr(n),e))}function Ud(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=wm());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function xm(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=uf(e.focusNode,e.focusOffset),r=hf(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t||r}function wm(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Xr(n,e=!1){if(!(gt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ud(n),e||n.docView&&n.docView.dirty){let t=Oi(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function km(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const sr=He&&Lt<15||On&&yf<604;ze.copy=$e.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=sr?null:t.clipboardData,i=r.content(),{dom:a,text:l}=Di(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):km(n,a),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function vm(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Sm(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?ir(n,r.value,null,o,e):ir(n,r.textContent,r.innerHTML,o,e)},50)}function ir(n,e,t,r,o){let s=$d(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",l=>l(n,o,s||O.empty)))return!0;if(!s)return!1;let i=vm(s),a=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function qd(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}$e.paste=(n,e)=>{let t=e;if(n.composing&&!gt)return;let r=sr?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&ir(n,qd(r),r.getData("text/html"),o,t)?t.preventDefault():Sm(n,t)};class Kd{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Cm=qe?"altKey":"ctrlKey";function Jd(n,e){return n.someProp("dragCopies",r=>!r(e))??!e[Cm]}ze.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Bo(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof I?o.to-1:o.to))){if(r&&r.mightDrag)i=I.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(i=I.create(n.state.doc,u.posBefore))}}let a=(i||n.state.selection).content(),{dom:l,text:c,slice:d}=Di(n,a);(!t.dataTransfer.files.length||!Oe||wd>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(sr?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",sr||t.dataTransfer.setData("text/plain",c),n.dragging=new Kd(d,Jd(n,t),i)};ze.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};$e.dragover=$e.dragenter=(n,e)=>e.preventDefault();$e.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Bo(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",f=>{i=f(i,n,!1)}):i=$d(n,qd(t.dataTransfer),sr?null:t.dataTransfer.getData("text/html"),!1,s);let a=!!(r&&Jd(n,t));if(n.someProp("handleDrop",f=>f(n,t,i||O.empty,a))){t.preventDefault();return}if(!i)return;t.preventDefault();let l=i?Zc(n.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let c=n.state.tr;if(a){let{node:f}=r;f?f.replace(c):c.deleteSelection()}let d=c.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(h))return;let p=c.doc.resolve(d);if(u&&I.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new I(p));else{let f=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,w)=>f=w),c.setSelection(Ri(n,p,c.doc.resolve(f)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};ze.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&bt(n)},20))};ze.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};ze.beforeinput=(n,e)=>{if(Oe&&gt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:t}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=t||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,Ut(8,"Backspace")))))return;let{$cursor:r}=n.state.selection;r&&r.pos>0&&n.dispatch(n.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let n in $e)ze[n]=$e[n];function ar(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Yr{constructor(e,t){this.toDOM=e,this.spec=t||Qt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new xe(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Yr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ar(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class $t{constructor(e,t){this.attrs=e,this.spec=t||Qt}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new xe(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof $t&&ar(this.attrs,e.attrs)&&ar(this.spec,e.spec)}static is(e){return e.type instanceof $t}destroy(){}}class $i{constructor(e,t){this.attrs=e,this.spec=t||Qt}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new xe(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof $i&&ar(this.attrs,e.attrs)&&ar(this.spec,e.spec)}destroy(){}}class xe{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new xe(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new xe(e,e,new Yr(t,r))}static inline(e,t,r,o){return new xe(e,t,new $t(r,o))}static node(e,t,r,o){return new xe(e,t,new $i(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof $t}get widget(){return this.type instanceof Yr}}const wn=[],Qt={};class se{constructor(e,t){this.local=e.length?e:wn,this.children=t.length?t:wn}static create(e,t){return t.length?Qr(t,e,0,Qt):Ae}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let a=this.local[i];a.from<=t&&a.to>=e&&(!s||s(a.spec))&&r.push(a.copy(a.from+o,a.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let a=this.children[i]+1;this.children[i+2].findInner(e-a,t-a,r,o+a,s)}}map(e,t,r){return this==Ae||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Qt)}mapInner(e,t,r,o,s){let i;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,o);l&&l.type.valid(t,l)?(i||(i=[])).push(l):s.onRemove&&s.onRemove(this.local[a].spec)}return this.children.length?Mm(this.children,i||[],e,t,r,o,s):i?new se(i.sort(Zt),wn):Ae}add(e,t){return t.length?this==Ae?se.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((a,l)=>{let c=l+r,d;if(d=Xd(t,a,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<l;)s+=3;o[s]==l?o[s+2]=o[s+2].addInner(a,d,c+1):o.splice(s,0,l,l+a.nodeSize,Qr(d,a,c+1,Qt)),s+=3}});let i=Gd(s?Yd(t):t,-r);for(let a=0;a<i.length;a++)i[a].type.valid(e,i[a])||i.splice(a--,1);return new se(i.length?this.local.concat(i).sort(Zt):this.local,o||this.children)}remove(e){return e.length==0||this==Ae?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,a=r[s]+t,l=r[s+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>a&&u.to<l&&(e[d]=null,(i||(i=[])).push(u));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,a+1);c!=Ae?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let a=0;a<o.length;a++)o[a].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(a--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new se(o,r):Ae}forChild(e,t){if(this==Ae)return this;if(t.isLeaf)return se.empty;let r,o;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let s=e+1,i=s+t.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<i&&l.to>s&&l.type instanceof $t){let c=Math.max(s,l.from)-s,d=Math.min(i,l.to)-s;c<d&&(o||(o=[])).push(l.copy(c,d))}}if(o){let a=new se(o.sort(Zt),wn);return r?new Tt([a,r]):a}return r||Ae}eq(e){if(this==e)return!0;if(!(e instanceof se)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ii(this.localsInner(e))}localsInner(e){if(this==Ae)return wn;if(e.inlineContent||!this.local.some($t.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof $t||t.push(this.local[r]);return t}forEachSet(e){e(this)}}se.empty=new se([],[]);se.removeOverlap=Ii;const Ae=se.empty;class Tt{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,Qt));return Tt.from(r)}forChild(e,t){if(t.isLeaf)return se.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=Ae&&(s instanceof Tt?r=r.concat(s.members):r.push(s))}return Tt.from(r)}eq(e){if(!(e instanceof Tt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?Ii(r?t:t.sort(Zt)):wn}static from(e){switch(e.length){case 0:return Ae;case 1:return e[0];default:return new Tt(e.every(t=>t instanceof se)?e:e.reduce((t,r)=>t.concat(r instanceof se?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Mm(n,e,t,r,o,s,i){let a=n.slice();for(let c=0,d=s;c<t.maps.length;c++){let u=0;t.maps[c].forEach((h,p,f,m)=>{let g=m-f-(p-h);for(let y=0;y<a.length;y+=3){let w=a[y+1];if(w<0||h>w+d-u)continue;let x=a[y]+d-u;p>=x?a[y+1]=h<=x?-2:-1:h>=d&&g&&(a[y]+=g,a[y+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let d=t.map(n[c]+s),u=d-o;if(u<0||u>=r.content.size){l=!0;continue}let h=t.map(n[c+1]+s,-1),p=h-o,{index:f,offset:m}=r.content.findIndex(u),g=r.maybeChild(f);if(g&&m==u&&m+g.nodeSize==p){let y=a[c+2].mapInner(t,g,d+1,n[c]+s+1,i);y!=Ae?(a[c]=u,a[c+1]=p,a[c+2]=y):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=Em(a,n,e,t,o,s,i),d=Qr(c,r,0,i);e=d.local;for(let u=0;u<a.length;u+=3)a[u+1]<0&&(a.splice(u,3),u-=3);for(let u=0,h=0;u<d.children.length;u+=3){let p=d.children[u];for(;h<a.length&&a[h]<p;)h+=3;a.splice(h,0,d.children[u],d.children[u+1],d.children[u+2])}}return new se(e.sort(Zt),a)}function Gd(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new xe(o.from+e,o.to+e,o.type))}return t}function Em(n,e,t,r,o,s,i){function a(l,c){for(let d=0;d<l.local.length;d++){let u=l.local[d].map(r,o,c);u?t.push(u):i.onRemove&&i.onRemove(l.local[d].spec)}for(let d=0;d<l.children.length;d+=3)a(l.children[d+2],l.children[d]+c+1)}for(let l=0;l<n.length;l+=3)n[l+1]==-1&&a(n[l+2],e[l]+s+1);return t}function Xd(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function Yd(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Qr(n,e,t,r){let o=[],s=!1;e.forEach((a,l)=>{let c=Xd(n,a,l+t);if(c){s=!0;let d=Qr(c,a,t+l+1,r);d!=Ae&&o.push(l,l+a.nodeSize,d)}});let i=Gd(s?Yd(n):n,-t).sort(Zt);for(let a=0;a<i.length;a++)i[a].type.valid(e,i[a])||(r.onRemove&&r.onRemove(i[a].spec),i.splice(a--,1));return i.length||o.length?new se(i,o):Ae}function Zt(n,e){return n.from-e.from||n.to-e.to}function Ii(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),al(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),al(e,o,r.copy(s.from,r.to)));break}}}return e}function al(n,e,t){for(;e<n.length&&Zt(t,n[e])>0;)e++;n.splice(e,0,t)}function hs(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Ae&&e.push(r)}),n.cursorWrapper&&e.push(se.create(n.state.doc,[n.cursorWrapper.deco])),Tt.from(e)}const Tm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Nm=He&&Lt<=11;class Am{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 Om{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Am,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&&Lt<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),Nm&&(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,Tm)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Za(this.view)){if(this.suppressingSelectionUpdates)return bt(this.view);if(He&&Lt<=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 t=new Set,r;for(let s=e.focusNode;s;s=An(s))t.add(s);for(let s=e.anchorNode;s;s=An(s))if(t.has(s)){r=s;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 t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Za(e)&&!this.ignoreSelectionChange(r),s=-1,i=-1,a=!1,l=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],l);u&&(s=s<0?u.from:Math.min(u.from,s),i=i<0?u.to:Math.max(u.to,i),u.typeOver&&(a=!0))}if(Ge&&l.length){let d=l.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,h]=d;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of d){let p=h.parentNode;p&&p.nodeName=="LI"&&(!u||jm(e,u)!=p)&&h.remove()}}}let c=null;s<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Po(r)&&(c=Oi(e))&&c.eq(W.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,bt(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||o)&&(s>-1&&(e.docView.markDirty(s,i),Rm(e)),this.handleDOMChange(s,i,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||bt(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.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 d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,s=e.nextSibling;if(He&&Lt<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:h}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(o=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(s=h)}let i=o&&o.parentNode==e.target?Ee(o)+1:0,a=r.localPosFromDOM(e.target,i,-1),l=s&&s.parentNode==e.target?Ee(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:a,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 ll=new WeakMap,cl=!1;function Rm(n){if(!ll.has(n)&&(ll.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ge,cl)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."),cl=!0}}function dl(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return rn(i.node,i.offset,o,s)&&([t,r,o,s]=[o,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:o,focusOffset:s}}function Dm(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return dl(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?dl(n,t):null}function jm(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Lm(n,e,t){let{node:r,fromOffset:o,toOffset:s,from:i,to:a}=n.docView.parseRange(e,t),l=n.domSelectionRange(),c,d=l.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:l.anchorOffset}],Po(l)||c.push({node:l.focusNode,offset:l.focusOffset})),Oe&&n.input.lastKeyCode===8)for(let g=s;g>o;g--){let y=r.childNodes[g-1],w=y.pmViewDesc;if(y.nodeName=="BR"&&!w){s=g;break}if(!w||w.size)break}let u=n.state.doc,h=n.someProp("domParser")||jt.fromSchema(n.state.schema),p=u.resolve(i),f=null,m=h.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:zm,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),f={anchor:g+i,head:y+i}}return{doc:m,sel:f,from:i,to:a}}function zm(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Le&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Le&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const $m=/^(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 Im(n,e,t,r,o){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let v=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,S=Oi(n,v);if(S&&!n.state.selection.eq(S)){if(Oe&&gt&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",_=>_(n,Ut(13,"Enter"))))return;let R=n.state.tr.setSelection(S);v=="pointer"?R.setMeta("pointer",!0):v=="key"&&R.scrollIntoView(),s&&R.setMeta("composition",s),n.dispatch(R)}return}let i=n.state.doc.resolve(e),a=i.sharedDepth(t);e=i.before(a+1),t=n.state.doc.resolve(t).after(a+1);let l=n.state.selection,c=Lm(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),h,p;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(h=n.state.selection.to,p="end"):(h=n.state.selection.from,p="start"),n.input.lastKeyCode=null;let f=Bm(u.content,c.doc.content,c.from,h,p);if(f&&n.input.domChangeCount++,(On&&n.input.lastIOSEnter>Date.now()-225||gt)&&o.some(v=>v.nodeType==1&&!$m.test(v.nodeName))&&(!f||f.endA>=f.endB)&&n.someProp("handleKeyDown",v=>v(n,Ut(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!f)if(r&&l instanceof H&&!l.empty&&l.$head.sameParent(l.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))f={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let v=ul(n,n.state.doc,c.sel);if(v&&!v.eq(n.state.selection)){let S=n.state.tr.setSelection(v);s&&S.setMeta("composition",s),n.dispatch(S)}}return}n.state.selection.from<n.state.selection.to&&f.start==f.endB&&n.state.selection instanceof H&&(f.start>n.state.selection.from&&f.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?f.start=n.state.selection.from:f.endA<n.state.selection.to&&f.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(f.endB+=n.state.selection.to-f.endA,f.endA=n.state.selection.to)),He&&Lt<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>c.from&&c.doc.textBetween(f.start-c.from-1,f.start-c.from+1)=="  "&&(f.start--,f.endA--,f.endB--);let m=c.doc.resolveNoCache(f.start-c.from),g=c.doc.resolveNoCache(f.endB-c.from),y=d.resolve(f.start),w=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=f.endA;if((On&&n.input.lastIOSEnter>Date.now()-225&&(!w||o.some(v=>v.nodeName=="DIV"||v.nodeName=="P"))||!w&&m.pos<c.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(c.doc.textBetween(m.pos,g.pos,"","")))&&n.someProp("handleKeyDown",v=>v(n,Ut(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>f.start&&Hm(d,f.start,f.endA,m,g)&&n.someProp("handleKeyDown",v=>v(n,Ut(8,"Backspace")))){gt&&Oe&&n.domObserver.suppressSelectionUpdates();return}Oe&&f.endB==f.start&&(n.input.lastChromeDelete=Date.now()),gt&&!w&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==f.endA&&(f.endB-=2,g=c.doc.resolveNoCache(f.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(v){return v(n,Ut(13,"Enter"))})},20));let x=f.start,E=f.endA,b=v=>{let S=v||n.state.tr.replace(x,E,c.doc.slice(f.start-c.from,f.endB-c.from));if(c.sel){let R=ul(n,S.doc,c.sel);R&&!(Oe&&n.composing&&R.empty&&(f.start!=f.endB||n.input.lastChromeDelete<Date.now()-100)&&(R.head==x||R.head==S.mapping.map(E)-1)||He&&R.empty&&R.head==x)&&S.setSelection(R)}return s&&S.setMeta("composition",s),S.scrollIntoView()},T;if(w)if(m.pos==g.pos){He&&Lt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>bt(n),20));let v=b(n.state.tr.delete(x,E)),S=d.resolve(f.start).marksAcross(d.resolve(f.endA));S&&v.ensureMarks(S),n.dispatch(v)}else if(f.endA==f.endB&&(T=Pm(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,f.endA-y.start())))){let v=b(n.state.tr);T.type=="add"?v.addMark(x,E,T.mark):v.removeMark(x,E,T.mark),n.dispatch(v)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let v=m.parent.textBetween(m.parentOffset,g.parentOffset),S=()=>b(n.state.tr.insertText(v,x,E));n.someProp("handleTextInput",R=>R(n,x,E,v,S))||n.dispatch(S())}else n.dispatch(b());else n.dispatch(b())}function ul(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Ri(n,e.resolve(t.anchor),e.resolve(t.head))}function Pm(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,s=r,i,a,l;for(let d=0;d<r.length;d++)o=r[d].removeFromSet(o);for(let d=0;d<t.length;d++)s=t[d].removeFromSet(s);if(o.length==1&&s.length==0)a=o[0],i="add",l=d=>d.mark(a.addToSet(d.marks));else if(o.length==0&&s.length==1)a=s[0],i="remove",l=d=>d.mark(a.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(l(e.child(d)));if(M.from(c).eq(n))return{mark:a,type:i}}function Hm(n,e,t,r,o){if(t-e<=o.pos-r.pos||ps(r,!0,!1)<o.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let a=s.nodeAfter;return a!=null&&t==e+a.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let i=n.resolve(ps(s,!0,!0));return!i.parent.isTextblock||i.pos>t||ps(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function ps(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,o++}return o}function Bm(n,e,t,r,o){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:i,b:a}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let l=Math.max(0,s-Math.min(i,a));r-=i+l-s}if(i<s&&n.size<e.size){let l=r<=s&&r>=i?s-r:0;s-=l,s&&s<e.size&&hl(e.textBetween(s-1,s+1))&&(s+=l?1:-1),a=s+(a-i),i=s}else if(a<s){let l=r<=s&&r>=a?s-r:0;s-=l,s&&s<n.size&&hl(n.textBetween(s-1,s+1))&&(s+=l?1:-1),i=s+(i-a),a=s}return{start:s,endA:i,endB:a}}function hl(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Qd{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new sm,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(yl),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=ml(this),fl(this),this.nodeViews=gl(this),this.docView=Ka(this.state.doc,pl(this),hs(this),this.dom,this),this.domObserver=new Om(this,(r,o,s,i)=>Im(this,r,o,s,i)),this.domObserver.start(),im(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Xs(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(yl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(Ud(this),i=!0),this.state=e;let a=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=gl(this);Fm(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Xs(this),this.editable=ml(this),fl(this);let l=hs(this),c=pl(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",u=s||!this.docView.matchesNode(e.doc,c,l);(u||!e.selection.eq(o.selection))&&(i=!0);let h=d=="preserve"&&i&&this.dom.style.overflowAnchor==null&&wf(this);if(i){this.domObserver.stop();let p=u&&(He||Oe)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Vm(o.selection,e.selection);if(u){let f=Oe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=xm(this)),(s||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ka(e.doc,c,l,this.dom,this)),f&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&_f(this))?bt(this,p):(jd(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),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():h&&kf(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof I){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Va(this,t.getBoundingClientRect(),e)}else Va(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 t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(o=s)}this.dragging=new Kd(e.slice,e.move,o<0?void 0:I.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let i=0;i<this.directPlugins.length;i++){let a=this.directPlugins[i].props[e];if(a!=null&&(o=t?t(a):a))return o}let s=this.state.plugins;if(s)for(let i=0;i<s.length;i++){let a=s[i].props[e];if(a!=null&&(o=t?t(a):a))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&&vf(this.dom),bt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Tf(this,e)}coordsAtPos(e,t=1){return Md(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Df(this,t||this.state,e)}pasteHTML(e,t){return ir(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ir(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Di(this,e)}destroy(){this.docView&&(am(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],hs(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,cf())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return cm(this,e)}domSelectionRange(){let e=this.domSelection();return e?Le&&this.root.nodeType===11&&ff(this.dom.ownerDocument)==this.dom&&Dm(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Qd.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function pl(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[xe.node(0,n.state.doc.content.size,e)]}function fl(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:xe.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ml(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Vm(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function gl(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Fm(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function yl(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var It={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:"'"},Zr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Wm=typeof navigator<"u"&&/Mac/.test(navigator.platform),_m=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Te=0;Te<10;Te++)It[48+Te]=It[96+Te]=String(Te);for(var Te=1;Te<=24;Te++)It[Te+111]="F"+Te;for(var Te=65;Te<=90;Te++)It[Te]=String.fromCharCode(Te+32),Zr[Te]=String.fromCharCode(Te);for(var fs in It)Zr.hasOwnProperty(fs)||(Zr[fs]=It[fs]);function Um(n){var e=Wm&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||_m&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Zr:It)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const qm=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Km=typeof navigator<"u"&&/Win/.test(navigator.platform);function Jm(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,s,i;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))i=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))o=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))qm?i=!0:o=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),i&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Gm(n){let e=Object.create(null);for(let t in n)e[Jm(t)]=n[t];return e}function ms(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Xm(n){return new le({props:{handleKeyDown:Pi(n)}})}function Pi(n){let e=Gm(n);return function(t,r){let o=Um(r),s,i=e[ms(o,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let a=e[ms(o,r,!1)];if(a&&a(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Km&&r.ctrlKey&&r.altKey)&&(s=It[r.keyCode])&&s!=o){let a=e[ms(s,r)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}var Ym=Object.defineProperty,Hi=(n,e)=>{for(var t in e)Ym(n,t,{get:e[t],enumerable:!0})};function Vo(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:o}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return o},get tr(){return r=t.selection,o=t.doc,s=t.storedMarks,t}}}var Fo=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:o}=t,s=this.buildProps(o);return Object.fromEntries(Object.entries(n).map(([i,a])=>[i,(...l)=>{const c=a(...l)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(o),c}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:r,state:o}=this,{view:s}=r,i=[],a=!!n,l=n||o.tr,c=()=>(!a&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(l),i.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(t).map(([u,h])=>[u,(...p)=>{const f=this.buildProps(l,e),m=h(...p)(f);return i.push(m),d}])),run:c};return d}createCan(n){const{rawCommands:e,state:t}=this,r=!1,o=n||t.tr,s=this.buildProps(o,r);return{...Object.fromEntries(Object.entries(e).map(([i,a])=>[i,(...l)=>a(...l)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,r)}}buildProps(n,e=!0){const{rawCommands:t,editor:r,state:o}=this,{view:s}=r,i={tr:n,editor:r,view:s,state:Vo({state:o,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([a,l])=>[a,(...c)=>l(...c)(i)]))}};return i}},Zd={};Hi(Zd,{blur:()=>Qm,clearContent:()=>Zm,clearNodes:()=>eg,command:()=>tg,createParagraphNear:()=>ng,cut:()=>rg,deleteCurrentNode:()=>og,deleteNode:()=>sg,deleteRange:()=>ig,deleteSelection:()=>ag,enter:()=>lg,exitCode:()=>cg,extendMarkRange:()=>dg,first:()=>ug,focus:()=>hg,forEach:()=>pg,insertContent:()=>fg,insertContentAt:()=>yg,joinBackward:()=>wg,joinDown:()=>xg,joinForward:()=>kg,joinItemBackward:()=>vg,joinItemForward:()=>Sg,joinTextblockBackward:()=>Cg,joinTextblockForward:()=>Mg,joinUp:()=>bg,keyboardShortcut:()=>Tg,lift:()=>Ng,liftEmptyBlock:()=>Ag,liftListItem:()=>Og,newlineInCode:()=>Rg,resetAttributes:()=>Dg,scrollIntoView:()=>jg,selectAll:()=>Lg,selectNodeBackward:()=>zg,selectNodeForward:()=>$g,selectParentNode:()=>Ig,selectTextblockEnd:()=>Pg,selectTextblockStart:()=>Hg,setContent:()=>Bg,setMark:()=>ry,setMeta:()=>oy,setNode:()=>sy,setNodeSelection:()=>iy,setTextDirection:()=>ay,setTextSelection:()=>ly,sinkListItem:()=>cy,splitBlock:()=>dy,splitListItem:()=>uy,toggleList:()=>hy,toggleMark:()=>py,toggleNode:()=>fy,toggleWrap:()=>my,undoInputRule:()=>gy,unsetAllMarks:()=>yy,unsetMark:()=>by,unsetTextDirection:()=>xy,updateAttributes:()=>wy,wrapIn:()=>ky,wrapInList:()=>vy});var Qm=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),Zm=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),eg=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:o}=r;return t&&o.forEach(({$from:s,$to:i})=>{n.doc.nodesBetween(s.pos,i.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(l)),h=c.resolve(d.map(l+a.nodeSize)),p=u.blockRange(h);if(!p)return;const f=jn(p);if(a.type.isTextblock){const{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(p.start,m)}(f||f===0)&&e.lift(p,f)})}),!0},tg=n=>e=>n(e),ng=()=>({state:n,dispatch:e})=>md(n,e),rg=(n,e)=>({editor:t,tr:r})=>{const{state:o}=t,s=o.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const i=r.mapping.map(e);return r.insert(i,s.content),r.setSelection(new H(r.doc.resolve(Math.max(i-1,0)))),!0},og=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const o=n.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===r.type){if(e){const i=o.before(s),a=o.after(s);n.delete(i,a).scrollIntoView()}return!0}return!1};function me(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var sg=n=>({tr:e,state:t,dispatch:r})=>{const o=me(n,t.schema),s=e.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===o){if(r){const a=s.before(i),l=s.after(i);e.delete(a,l).scrollIntoView()}return!0}return!1},ig=n=>({tr:e,dispatch:t})=>{const{from:r,to:o}=n;return t&&e.delete(r,o),!0},ag=()=>({state:n,dispatch:e})=>Ci(n,e),lg=()=>({commands:n})=>n.keyboardShortcut("Enter"),cg=()=>({state:n,dispatch:e})=>Kp(n,e);function Bi(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function eo(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(o=>t.strict?e[o]===n[o]:Bi(e[o])?e[o].test(n[o]):e[o]===n[o]):!0}function eu(n,e,t={}){return n.find(r=>r.type===e&&eo(Object.fromEntries(Object.keys(t).map(o=>[o,r.attrs[o]])),t))}function bl(n,e,t={}){return!!eu(n,e,t)}function Vi(n,e,t){var r;if(!n||!e)return;let o=n.parent.childAfter(n.parentOffset);if((!o.node||!o.node.marks.some(c=>c.type===e))&&(o=n.parent.childBefore(n.parentOffset)),!o.node||!o.node.marks.some(c=>c.type===e)||(t=t||((r=o.node.marks[0])==null?void 0:r.attrs),!eu([...o.node.marks],e,t)))return;let s=o.index,i=n.start()+o.offset,a=s+1,l=i+o.node.nodeSize;for(;s>0&&bl([...n.parent.child(s-1).marks],e,t);)s-=1,i-=n.parent.child(s).nodeSize;for(;a<n.parent.childCount&&bl([...n.parent.child(a).marks],e,t);)l+=n.parent.child(a).nodeSize,a+=1;return{from:i,to:l}}function xt(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var dg=(n,e={})=>({tr:t,state:r,dispatch:o})=>{const s=xt(n,r.schema),{doc:i,selection:a}=t,{$from:l,from:c,to:d}=a;if(o){const u=Vi(l,s,e);if(u&&u.from<=c&&u.to>=d){const h=H.create(i,u.from,u.to);t.setSelection(h)}}return!0},ug=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function tu(n){return n instanceof H}function Jt(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function nu(n,e=null){if(!e)return null;const t=W.atStart(n),r=W.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const o=t.from,s=r.to;return e==="all"?H.create(n,Jt(0,o,s),Jt(n.content.size,o,s)):H.create(n,Jt(e,o,s),Jt(e,o,s))}function ru(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Wo(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var hg=(n=null,e={})=>({editor:t,view:r,tr:o,dispatch:s})=>{e={scrollIntoView:!0,...e};const i=()=>{(Wo()||ru())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!tu(t.state.selection))return i(),!0;const a=nu(o.doc,n)||t.state.selection,l=t.state.selection.eq(a);return s&&(l||o.setSelection(a),l&&o.storedMarks&&o.setStoredMarks(o.storedMarks),i()),!0},pg=(n,e)=>t=>n.every((r,o)=>e(r,{...t,index:o})),fg=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),ou=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&ou(r)}return n};function vr(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return ou(t)}function lr(n,e,t){if(n instanceof Je||n instanceof M)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,o=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return M.fromArray(n.map(i=>e.nodeFromJSON(i)));const s=e.nodeFromJSON(n);return t.errorOnInvalidContent&&s.check(),s}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),lr("",e,t)}if(o){if(t.errorOnInvalidContent){let i=!1,a="";const l=new Fc({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=>(i=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?jt.fromSchema(l).parseSlice(vr(n),t.parseOptions):jt.fromSchema(l).parse(vr(n),t.parseOptions),t.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const s=jt.fromSchema(e);return t.slice?s.parseSlice(vr(n),t.parseOptions).content:s.parse(vr(n),t.parseOptions)}return lr("",e,t)}function mg(n,e,t){const r=n.steps.length-1;if(r<e)return;const o=n.steps[r];if(!(o instanceof be||o instanceof we))return;const s=n.mapping.maps[r];let i=0;s.forEach((a,l,c,d)=>{i===0&&(i=d)}),n.setSelection(W.near(n.doc.resolve(i),t))}var gg=n=>!("type"in n),yg=(n,e,t)=>({tr:r,dispatch:o,editor:s})=>{var i;if(o){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let a;const l=m=>{s.emit("contentError",{editor:s,error:m,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{lr(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(m){l(m)}try{a=lr(e,s.schema,{parseOptions:c,errorOnInvalidContent:(i=t.errorOnInvalidContent)!=null?i:s.options.enableContentCheck})}catch(m){return l(m),!1}let{from:d,to:u}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},h=!0,p=!0;if((gg(a)?a:[a]).forEach(m=>{m.check(),h=h?m.isText&&m.marks.length===0:!1,p=p?m.isBlock:!1}),d===u&&p){const{parent:m}=r.doc.resolve(d);m.isTextblock&&!m.type.spec.code&&!m.childCount&&(d-=1,u+=1)}let f;if(h){if(Array.isArray(e))f=e.map(m=>m.text||"").join("");else if(e instanceof M){let m="";e.forEach(g=>{g.text&&(m+=g.text)}),f=m}else typeof e=="object"&&e&&e.text?f=e.text:f=e;r.insertText(f,d,u)}else{f=a;const m=r.doc.resolve(d),g=m.node(),y=m.parentOffset===0,w=g.isText||g.isTextblock,x=g.content.size>0;y&&w&&x&&(d=Math.max(0,d-1)),r.replaceWith(d,u,f)}t.updateSelection&&mg(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:f}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:f})}return!0},bg=()=>({state:n,dispatch:e})=>_p(n,e),xg=()=>({state:n,dispatch:e})=>Up(n,e),wg=()=>({state:n,dispatch:e})=>ld(n,e),kg=()=>({state:n,dispatch:e})=>hd(n,e),vg=()=>({state:n,dispatch:e,tr:t})=>{try{const r=zo(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Sg=()=>({state:n,dispatch:e,tr:t})=>{try{const r=zo(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Cg=()=>({state:n,dispatch:e})=>Fp(n,e),Mg=()=>({state:n,dispatch:e})=>Wp(n,e);function su(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Eg(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,o,s,i;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))i=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))o=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))Wo()||su()?i=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(t=`Alt-${t}`),o&&(t=`Ctrl-${t}`),i&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var Tg=n=>({editor:e,view:t,tr:r,dispatch:o})=>{const s=Eg(n).split(/-(?!$)/),i=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0});return e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,a))})?.steps.forEach(c=>{const d=c.map(r.mapping);d&&o&&r.maybeStep(d)}),!0};function Pt(n,e,t={}){const{from:r,to:o,empty:s}=n.selection,i=e?me(e,n.schema):null,a=[];n.doc.nodesBetween(r,o,(d,u)=>{if(d.isText)return;const h=Math.max(r,u),p=Math.min(o,u+d.nodeSize);a.push({node:d,from:h,to:p})});const l=o-r,c=a.filter(d=>i?i.name===d.node.type.name:!0).filter(d=>eo(d.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((d,u)=>d+u.to-u.from,0)>=l}var Ng=(n,e={})=>({state:t,dispatch:r})=>{const o=me(n,t.schema);return Pt(t,o,e)?qp(t,r):!1},Ag=()=>({state:n,dispatch:e})=>gd(n,e),Og=n=>({state:e,dispatch:t})=>{const r=me(n,e.schema);return of(r)(e,t)},Rg=()=>({state:n,dispatch:e})=>fd(n,e);function _o(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function xl(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,o)=>(t.includes(o)||(r[o]=n[o]),r),{})}var Dg=(n,e)=>({tr:t,state:r,dispatch:o})=>{let s=null,i=null;const a=_o(typeof n=="string"?n:n.name,r.schema);if(!a)return!1;a==="node"&&(s=me(n,r.schema)),a==="mark"&&(i=xt(n,r.schema));let l=!1;return t.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,u)=>{s&&s===d.type&&(l=!0,o&&t.setNodeMarkup(u,void 0,xl(d.attrs,e))),i&&d.marks.length&&d.marks.forEach(h=>{i===h.type&&(l=!0,o&&t.addMark(u,u+d.nodeSize,i.create(xl(h.attrs,e))))})})}),l},jg=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Lg=()=>({tr:n,dispatch:e})=>{if(e){const t=new We(n.doc);n.setSelection(t)}return!0},zg=()=>({state:n,dispatch:e})=>dd(n,e),$g=()=>({state:n,dispatch:e})=>pd(n,e),Ig=()=>({state:n,dispatch:e})=>Xp(n,e),Pg=()=>({state:n,dispatch:e})=>Zp(n,e),Hg=()=>({state:n,dispatch:e})=>Qp(n,e);function Ys(n,e,t={},r={}){return lr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var Bg=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:o,tr:s,dispatch:i,commands:a})=>{const{doc:l}=s;if(r.preserveWhitespace!=="full"){const c=Ys(n,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});return i&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!t),!0}return i&&s.setMeta("preventUpdate",!t),a.insertContentAt({from:0,to:l.content.size},n,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function iu(n,e){const t=xt(e,n.schema),{from:r,to:o,empty:s}=n.selection,i=[];s?(n.storedMarks&&i.push(...n.storedMarks),i.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,o,l=>{i.push(...l.marks)});const a=i.find(l=>l.type.name===t.name);return a?{...a.attrs}:{}}function au(n,e){const t=new vi(n);return e.forEach(r=>{r.steps.forEach(o=>{t.step(o)})}),t}function Vg(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Fg(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(o,s)=>{t(o)&&r.push({node:o,pos:s})}),r}function lu(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Uo(n){return e=>lu(e.$from,n)}function P(n,e,t){return n.config[e]===void 0&&n.parent?P(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?P(n.parent,e,t):null}):n.config[e]}function Fi(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},r=P(e,"addExtensions",t);return r?[e,...Fi(r())]:e}).flat(10)}function Wi(n,e){const t=Bt.fromSchema(e).serializeFragment(n),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(t),r.innerHTML}function cu(n){return typeof n=="function"}function Q(n,e=void 0,...t){return cu(n)?e?n.bind(e)(...t):n(...t):n}function Wg(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Rn(n){const e=n.filter(o=>o.type==="extension"),t=n.filter(o=>o.type==="node"),r=n.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function du(n){const e=[],{nodeExtensions:t,markExtensions:r}=Rn(n),o=[...t,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage,extensions:o},l=P(i,"addGlobalAttributes",a);l&&l().forEach(c=>{c.types.forEach(d=>{Object.entries(c.attributes).forEach(([u,h])=>{e.push({type:d,name:u,attribute:{...s,...h}})})})})}),o.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage},l=P(i,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([d,u])=>{const h={...s,...u};typeof h?.default=="function"&&(h.default=h.default()),h?.isRequired&&h?.default===void 0&&delete h.default,e.push({type:i.name,name:d,attribute:h})})}),e}function re(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([o,s])=>{if(!r[o]){r[o]=s;return}if(o==="class"){const i=s?String(s).split(" "):[],a=r[o]?r[o].split(" "):[],l=i.filter(c=>!a.includes(c));r[o]=[...a,...l].join(" ")}else if(o==="style"){const i=s?s.split(";").map(c=>c.trim()).filter(Boolean):[],a=r[o]?r[o].split(";").map(c=>c.trim()).filter(Boolean):[],l=new Map;a.forEach(c=>{const[d,u]=c.split(":").map(h=>h.trim());l.set(d,u)}),i.forEach(c=>{const[d,u]=c.split(":").map(h=>h.trim());l.set(d,u)}),r[o]=Array.from(l.entries()).map(([c,d])=>`${c}: ${d}`).join("; ")}else r[o]=s}),r},{})}function cr(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>re(t,r),{})}function _g(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function wl(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const o=e.reduce((s,i)=>{const a=i.attribute.parseHTML?i.attribute.parseHTML(t):_g(t.getAttribute(i.name));return a==null?s:{...s,[i.name]:a}},{});return{...r,...o}}}}function kl(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Wg(t)?!1:t!=null))}function vl(n){var e,t;const r={};return!((e=n?.attribute)!=null&&e.isRequired)&&"default"in(n?.attribute||{})&&(r.default=n.attribute.default),((t=n?.attribute)==null?void 0:t.validate)!==void 0&&(r.validate=n.attribute.validate),[n.name,r]}function uu(n,e){var t;const r=du(n),{nodeExtensions:o,markExtensions:s}=Rn(n),i=(t=o.find(c=>P(c,"topNode")))==null?void 0:t.name,a=Object.fromEntries(o.map(c=>{const d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=n.reduce((y,w)=>{const x=P(w,"extendNodeSchema",u);return{...y,...x?x(c):{}}},{}),p=kl({...h,content:Q(P(c,"content",u)),marks:Q(P(c,"marks",u)),group:Q(P(c,"group",u)),inline:Q(P(c,"inline",u)),atom:Q(P(c,"atom",u)),selectable:Q(P(c,"selectable",u)),draggable:Q(P(c,"draggable",u)),code:Q(P(c,"code",u)),whitespace:Q(P(c,"whitespace",u)),linebreakReplacement:Q(P(c,"linebreakReplacement",u)),defining:Q(P(c,"defining",u)),isolating:Q(P(c,"isolating",u)),attrs:Object.fromEntries(d.map(vl))}),f=Q(P(c,"parseHTML",u));f&&(p.parseDOM=f.map(y=>wl(y,d)));const m=P(c,"renderHTML",u);m&&(p.toDOM=y=>m({node:y,HTMLAttributes:cr(y,d)}));const g=P(c,"renderText",u);return g&&(p.toText=g),[c.name,p]})),l=Object.fromEntries(s.map(c=>{const d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=n.reduce((g,y)=>{const w=P(y,"extendMarkSchema",u);return{...g,...w?w(c):{}}},{}),p=kl({...h,inclusive:Q(P(c,"inclusive",u)),excludes:Q(P(c,"excludes",u)),group:Q(P(c,"group",u)),spanning:Q(P(c,"spanning",u)),code:Q(P(c,"code",u)),attrs:Object.fromEntries(d.map(vl))}),f=Q(P(c,"parseHTML",u));f&&(p.parseDOM=f.map(g=>wl(g,d)));const m=P(c,"renderHTML",u);return m&&(p.toDOM=g=>m({mark:g,HTMLAttributes:cr(g,d)})),[c.name,p]}));return new Fc({topNode:i,nodes:a,marks:l})}function Ug(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function _i(n){return n.sort((e,t)=>{const r=P(e,"priority")||100,o=P(t,"priority")||100;return r>o?-1:r<o?1:0})}function Ui(n){const e=_i(Fi(n)),t=Ug(e.map(r=>r.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function qg(n,e){const t=Ui(n);return uu(t,e)}function hu(n,e,t){const{from:r,to:o}=e,{blockSeparator:s=`
20
-
21
- `,textSerializers:i={}}=t||{};let a="";return n.nodesBetween(r,o,(l,c,d,u)=>{var h;l.isBlock&&c>r&&(a+=s);const p=i?.[l.type.name];if(p)return d&&(a+=p({node:l,pos:c,parent:d,index:u,range:e})),!1;l.isText&&(a+=(h=l?.text)==null?void 0:h.slice(Math.max(r,c)-c,o-c))}),a}function Kg(n,e){const t={from:0,to:n.content.size};return hu(n,t,e)}function pu(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Jg(n,e){const t=me(e,n.schema),{from:r,to:o}=n.selection,s=[];n.doc.nodesBetween(r,o,a=>{s.push(a)});const i=s.reverse().find(a=>a.type.name===t.name);return i?{...i.attrs}:{}}function fu(n,e){const t=_o(typeof e=="string"?e:e.name,n.schema);return t==="node"?Jg(n,e):t==="mark"?iu(n,e):{}}function Gg(n,e=JSON.stringify){const t={};return n.filter(r=>{const o=e(r);return Object.prototype.hasOwnProperty.call(t,o)?!1:t[o]=!0})}function Xg(n){const e=Gg(n);return e.length===1?e:e.filter((t,r)=>!e.filter((o,s)=>s!==r).some(o=>t.oldRange.from>=o.oldRange.from&&t.oldRange.to<=o.oldRange.to&&t.newRange.from>=o.newRange.from&&t.newRange.to<=o.newRange.to))}function mu(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((o,s)=>{const i=[];if(o.ranges.length)o.forEach((a,l)=>{i.push({from:a,to:l})});else{const{from:a,to:l}=t[s];if(a===void 0||l===void 0)return;i.push({from:a,to:l})}i.forEach(({from:a,to:l})=>{const c=e.slice(s).map(a,-1),d=e.slice(s).map(l),u=e.invert().map(c,-1),h=e.invert().map(d);r.push({oldRange:{from:u,to:h},newRange:{from:c,to:d}})})}),Xg(r)}function qi(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(o=>{const s=t.resolve(n),i=Vi(s,o.type);i&&r.push({mark:o,...i})}):t.nodesBetween(n,e,(o,s)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(i=>({from:s,to:s+o.nodeSize,mark:i})))}),r}var Yg=(n,e,t,r=20)=>{const o=n.doc.resolve(t);let s=r,i=null;for(;s>0&&i===null;){const a=o.node(s);a?.type.name===e?i=a:s-=1}return[i,s]};function gs(n,e){return e.nodes[n]||e.marks[n]||null}function Pr(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const o=n.find(s=>s.type===e&&s.name===r);return o?o.attribute.keepOnSplit:!1}))}var Qg=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(o,s,i,a)=>{var l,c;const d=((c=(l=o.type.spec).toText)==null?void 0:c.call(l,{node:o,pos:s,parent:i,index:a}))||o.textContent||"%leaf%";t+=o.isAtom&&!o.isText?d:d.slice(0,Math.max(0,r-s))}),t};function Qs(n,e,t={}){const{empty:r,ranges:o}=n.selection,s=e?xt(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>eo(d.attrs,t,{strict:!1}));let i=0;const a=[];if(o.forEach(({$from:d,$to:u})=>{const h=d.pos,p=u.pos;n.doc.nodesBetween(h,p,(f,m)=>{if(!f.isText&&!f.marks.length)return;const g=Math.max(h,m),y=Math.min(p,m+f.nodeSize),w=y-g;i+=w,a.push(...f.marks.map(x=>({mark:x,from:g,to:y})))})}),i===0)return!1;const l=a.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>eo(d.mark.attrs,t,{strict:!1})).reduce((d,u)=>d+u.to-u.from,0),c=a.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,u)=>d+u.to-u.from,0);return(l>0?l+c:l)>=i}function Zg(n,e,t={}){if(!e)return Pt(n,null,t)||Qs(n,null,t);const r=_o(e,n.schema);return r==="node"?Pt(n,e,t):r==="mark"?Qs(n,e,t):!1}var ey=(n,e)=>{const{$from:t,$to:r,$anchor:o}=n.selection;if(e){const s=Uo(a=>a.type.name===e)(n.selection);if(!s)return!1;const i=n.doc.resolve(s.pos+1);return o.pos+1===i.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},ty=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Sl(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Cl(n,e){const{nodeExtensions:t}=Rn(e),r=t.find(i=>i.name===n);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},s=Q(P(r,"group",o));return typeof s!="string"?!1:s.split(" ").includes("list")}function qo(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let o=!0;return n.content.forEach(s=>{o!==!1&&(qo(s,{ignoreWhitespace:t,checkChildren:e})||(o=!1))}),o}return!1}function gu(n){return n instanceof I}function ny(n,e,t){var r;const{selection:o}=e;let s=null;if(tu(o)&&(s=o.$cursor),s){const a=(r=n.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(a)||!a.some(l=>l.type.excludes(t)))}const{ranges:i}=o;return i.some(({$from:a,$to:l})=>{let c=a.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(a.pos,l.pos,(d,u,h)=>{if(c)return!1;if(d.isInline){const p=!h||h.type.allowsMarkType(t),f=!!t.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(t));c=p&&f}return!c}),c})}var ry=(n,e={})=>({tr:t,state:r,dispatch:o})=>{const{selection:s}=t,{empty:i,ranges:a}=s,l=xt(n,r.schema);if(o)if(i){const c=iu(r,l);t.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(h,p)=>{const f=Math.max(p,d),m=Math.min(p+h.nodeSize,u);h.marks.find(g=>g.type===l)?h.marks.forEach(g=>{l===g.type&&t.addMark(f,m,l.create({...g.attrs,...e}))}):t.addMark(f,m,l.create(e))})});return ny(r,t,l)},oy=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),sy=(n,e={})=>({state:t,dispatch:r,chain:o})=>{const s=me(n,t.schema);let i;return t.selection.$anchor.sameParent(t.selection.$head)&&(i=t.selection.$anchor.parent.attrs),s.isTextblock?o().command(({commands:a})=>Pa(s,{...i,...e})(t)?!0:a.clearNodes()).command(({state:a})=>Pa(s,{...i,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},iy=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,o=Jt(n,0,r.content.size),s=I.create(r,o);e.setSelection(s)}return!0},ay=(n,e)=>({tr:t,state:r,dispatch:o})=>{const{selection:s}=r;let i,a;return typeof e=="number"?(i=e,a=e):e&&"from"in e&&"to"in e?(i=e.from,a=e.to):(i=s.from,a=s.to),o&&t.doc.nodesBetween(i,a,(l,c)=>{l.isText||t.setNodeMarkup(c,void 0,{...l.attrs,dir:n})}),!0},ly=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:o,to:s}=typeof n=="number"?{from:n,to:n}:n,i=H.atStart(r).from,a=H.atEnd(r).to,l=Jt(o,i,a),c=Jt(s,i,a),d=H.create(r,l,c);e.setSelection(d)}return!0},cy=n=>({state:e,dispatch:t})=>{const r=me(n,e.schema);return lf(r)(e,t)};function Ml(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(o=>e?.includes(o.type.name));n.tr.ensureMarks(r)}}var dy=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:o})=>{const{selection:s,doc:i}=e,{$from:a,$to:l}=s,c=o.extensionManager.attributes,d=Pr(c,a.node().type.name,a.node().attrs);if(s instanceof I&&s.node.isBlock)return!a.parentOffset||!yt(i,a.pos)?!1:(r&&(n&&Ml(t,o.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const u=l.parentOffset===l.parent.content.size,h=a.depth===0?void 0:Vg(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=u&&h?[{type:h,attrs:d}]:void 0,f=yt(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!f&&yt(e.doc,e.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(f=!0,p=h?[{type:h,attrs:d}]:void 0),r){if(f&&(s instanceof H&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,p),h&&!u&&!a.parentOffset&&a.parent.type!==h)){const m=e.mapping.map(a.before()),g=e.doc.resolve(m);a.node(-1).canReplaceWith(g.index(),g.index()+1,h)&&e.setNodeMarkup(e.mapping.map(a.before()),h)}n&&Ml(t,o.extensionManager.splittableMarks),e.scrollIntoView()}return f},uy=(n,e={})=>({tr:t,state:r,dispatch:o,editor:s})=>{var i;const a=me(n,r.schema),{$from:l,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const u=l.node(-1);if(u.type!==a)return!1;const h=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(o){let y=M.empty;const w=l.index(-1)?1:l.index(-2)?2:3;for(let S=l.depth-w;S>=l.depth-3;S-=1)y=M.from(l.node(S).copy(y));const x=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,E={...Pr(h,l.node().type.name,l.node().attrs),...e},b=((i=a.contentMatch.defaultType)==null?void 0:i.createAndFill(E))||void 0;y=y.append(M.from(a.createAndFill(null,b)||void 0));const T=l.before(l.depth-(w-1));t.replace(T,l.after(-x),new O(y,4-w,0));let v=-1;t.doc.nodesBetween(T,t.doc.content.size,(S,R)=>{if(v>-1)return!1;S.isTextblock&&S.content.size===0&&(v=R+1)}),v>-1&&t.setSelection(H.near(t.doc.resolve(v))),t.scrollIntoView()}return!0}const p=c.pos===l.end()?u.contentMatchAt(0).defaultType:null,f={...Pr(h,u.type.name,u.attrs),...e},m={...Pr(h,l.node().type.name,l.node().attrs),...e};t.delete(l.pos,c.pos);const g=p?[{type:a,attrs:f},{type:p,attrs:m}]:[{type:a,attrs:f}];if(!yt(t.doc,l.pos,2))return!1;if(o){const{selection:y,storedMarks:w}=r,{splittableMarks:x}=s.extensionManager,E=w||y.$to.parentOffset&&y.$from.marks();if(t.split(l.pos,2,g).scrollIntoView(),!E||!o)return!0;const b=E.filter(T=>x.includes(T.type.name));t.ensureMarks(b)}return!0},ys=(n,e)=>{const t=Uo(s=>s.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const o=n.doc.nodeAt(r);return t.node.type===o?.type&&Vt(n.doc,t.pos)&&n.join(t.pos),!0},bs=(n,e)=>{const t=Uo(s=>s.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const o=n.doc.nodeAt(r);return t.node.type===o?.type&&Vt(n.doc,r)&&n.join(r),!0},hy=(n,e,t,r={})=>({editor:o,tr:s,state:i,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:u,splittableMarks:h}=o.extensionManager,p=me(n,i.schema),f=me(e,i.schema),{selection:m,storedMarks:g}=i,{$from:y,$to:w}=m,x=y.blockRange(w),E=g||m.$to.parentOffset&&m.$from.marks();if(!x)return!1;const b=Uo(T=>Cl(T.type.name,u))(m);if(x.depth>=1&&b&&x.depth-b.depth<=1){if(b.node.type===p)return c.liftListItem(f);if(Cl(b.node.type.name,u)&&p.validContent(b.node.content)&&a)return l().command(()=>(s.setNodeMarkup(b.pos,p),!0)).command(()=>ys(s,p)).command(()=>bs(s,p)).run()}return!t||!E||!a?l().command(()=>d().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>ys(s,p)).command(()=>bs(s,p)).run():l().command(()=>{const T=d().wrapInList(p,r),v=E.filter(S=>h.includes(S.type.name));return s.ensureMarks(v),T?!0:c.clearNodes()}).wrapInList(p,r).command(()=>ys(s,p)).command(()=>bs(s,p)).run()},py=(n,e={},t={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:s=!1}=t,i=xt(n,r.schema);return Qs(r,i,e)?o.unsetMark(i,{extendEmptyMarkRange:s}):o.setMark(i,e)},fy=(n,e,t={})=>({state:r,commands:o})=>{const s=me(n,r.schema),i=me(e,r.schema),a=Pt(r,s,t);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?o.setNode(i,l):o.setNode(s,{...l,...t})},my=(n,e={})=>({state:t,commands:r})=>{const o=me(n,t.schema);return Pt(t,o,e)?r.lift(o):r.wrapIn(o,e)},gy=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const o=t[r];let s;if(o.spec.isInputRules&&(s=o.getState(n))){if(e){const i=n.tr,a=s.transform;for(let l=a.steps.length-1;l>=0;l-=1)i.step(a.steps[l].invert(a.docs[l]));if(s.text){const l=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,n.schema.text(s.text,l))}else i.delete(s.from,s.to)}return!0}}return!1},yy=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:o}=t;return r||e&&o.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},by=(n,e={})=>({tr:t,state:r,dispatch:o})=>{var s;const{extendEmptyMarkRange:i=!1}=e,{selection:a}=t,l=xt(n,r.schema),{$from:c,empty:d,ranges:u}=a;if(!o)return!0;if(d&&i){let{from:h,to:p}=a;const f=(s=c.marks().find(g=>g.type===l))==null?void 0:s.attrs,m=Vi(c,l,f);m&&(h=m.from,p=m.to),t.removeMark(h,p,l)}else u.forEach(h=>{t.removeMark(h.$from.pos,h.$to.pos,l)});return t.removeStoredMark(l),!0},xy=n=>({tr:e,state:t,dispatch:r})=>{const{selection:o}=t;let s,i;return typeof n=="number"?(s=n,i=n):n&&"from"in n&&"to"in n?(s=n.from,i=n.to):(s=o.from,i=o.to),r&&e.doc.nodesBetween(s,i,(a,l)=>{if(a.isText)return;const c={...a.attrs};delete c.dir,e.setNodeMarkup(l,void 0,c)}),!0},wy=(n,e={})=>({tr:t,state:r,dispatch:o})=>{let s=null,i=null;const a=_o(typeof n=="string"?n:n.name,r.schema);if(!a)return!1;a==="node"&&(s=me(n,r.schema)),a==="mark"&&(i=xt(n,r.schema));let l=!1;return t.selection.ranges.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;let h,p,f,m;t.selection.empty?r.doc.nodesBetween(d,u,(g,y)=>{s&&s===g.type&&(l=!0,f=Math.max(y,d),m=Math.min(y+g.nodeSize,u),h=y,p=g)}):r.doc.nodesBetween(d,u,(g,y)=>{y<d&&s&&s===g.type&&(l=!0,f=Math.max(y,d),m=Math.min(y+g.nodeSize,u),h=y,p=g),y>=d&&y<=u&&(s&&s===g.type&&(l=!0,o&&t.setNodeMarkup(y,void 0,{...g.attrs,...e})),i&&g.marks.length&&g.marks.forEach(w=>{if(i===w.type&&(l=!0,o)){const x=Math.max(y,d),E=Math.min(y+g.nodeSize,u);t.addMark(x,E,i.create({...w.attrs,...e}))}}))}),p&&(h!==void 0&&o&&t.setNodeMarkup(h,void 0,{...p.attrs,...e}),i&&p.marks.length&&p.marks.forEach(g=>{i===g.type&&o&&t.addMark(f,m,i.create({...g.attrs,...e}))}))}),l},ky=(n,e={})=>({state:t,dispatch:r})=>{const o=me(n,t.schema);return ef(o,e)(t,r)},vy=(n,e={})=>({state:t,dispatch:r})=>{const o=me(n,t.schema);return tf(o,e)(t,r)},Sy=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){const t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},Ko=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},Cy=(n,e)=>{if(Bi(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Sr(n){var e;const{editor:t,from:r,to:o,text:s,rules:i,plugin:a}=n,{view:l}=t;if(l.composing)return!1;const c=l.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 d=!1;const u=Qg(c)+s;return i.forEach(h=>{if(d)return;const p=Cy(u,h.find);if(!p)return;const f=l.state.tr,m=Vo({state:l.state,transaction:f}),g={from:r-(p[0].length-s.length),to:o},{commands:y,chain:w,can:x}=new Fo({editor:t,state:m});h.handler({state:m,range:g,match:p,commands:y,chain:w,can:x})===null||!f.steps.length||(h.undoable&&f.setMeta(a,{transform:f,from:r,to:o,text:s}),l.dispatch(f),d=!0)}),d}function My(n){const{editor:e,rules:t}=n,r=new le({state:{init(){return null},apply(o,s,i){const a=o.getMeta(r);if(a)return a;const l=o.getMeta("applyInputRules");return l&&setTimeout(()=>{let{text:c}=l;typeof c=="string"?c=c:c=Wi(M.from(c),i.schema);const{from:d}=l,u=d+c.length;Sr({editor:e,from:d,to:u,text:c,rules:t,plugin:r})}),o.selectionSet||o.docChanged?null:s}},props:{handleTextInput(o,s,i,a){return Sr({editor:e,from:s,to:i,text:a,rules:t,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{const{$cursor:s}=o.state.selection;s&&Sr({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(o,s){if(s.key!=="Enter")return!1;const{$cursor:i}=o.state.selection;return i?Sr({editor:e,from:i.pos,to:i.pos,text:`
22
- `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function Ey(n){return Object.prototype.toString.call(n).slice(8,-1)}function Cr(n){return Ey(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function yu(n,e){const t={...n};return Cr(n)&&Cr(e)&&Object.keys(e).forEach(r=>{Cr(e[r])&&Cr(n[r])?t[r]=yu(n[r],e[r]):t[r]=e[r]}),t}var Ki=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...Q(P(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Q(P(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>yu(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},wt=class bu extends Ki{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new bu(t)}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){const s=o.marks();if(!s.find(a=>a?.type.name===t.name))return!1;const i=s.find(a=>a?.type.name===t.name);return i&&r.removeStoredMark(i),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function Ty(n){return typeof n=="number"}var Ny=class{constructor(n){this.find=n.find,this.handler=n.handler}},Ay=(n,e,t)=>{if(Bi(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(o=>{const s=[o.text];return s.index=o.index,s.input=n,s.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(o.replaceWith)),s}):[]};function Oy(n){const{editor:e,state:t,from:r,to:o,rule:s,pasteEvent:i,dropEvent:a}=n,{commands:l,chain:c,can:d}=new Fo({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,o,(h,p)=>{var f,m,g,y,w;if((m=(f=h.type)==null?void 0:f.spec)!=null&&m.code||!(h.isText||h.isTextblock||h.isInline))return;const x=(w=(y=(g=h.content)==null?void 0:g.size)!=null?y:h.nodeSize)!=null?w:0,E=Math.max(r,p),b=Math.min(o,p+x);if(E>=b)return;const T=h.isText?h.text||"":h.textBetween(E-p,b-p,void 0,"");Ay(T,s.find,i).forEach(v=>{if(v.index===void 0)return;const S=E+v.index+1,R=S+v[0].length,_={from:t.tr.mapping.map(S),to:t.tr.mapping.map(R)},$=s.handler({state:t,range:_,match:v,commands:l,chain:c,can:d,pasteEvent:i,dropEvent:a});u.push($)})}),u.every(h=>h!==null)}var Mr=null,Ry=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function Dy(n){const{editor:e,rules:t}=n;let r=null,o=!1,s=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:c,from:d,to:u,rule:h,pasteEvt:p})=>{const f=c.tr,m=Vo({state:c,transaction:f});if(!(!Oy({editor:e,state:m,from:Math.max(d-1,0),to:u.b-1,rule:h,pasteEvent:p,dropEvent:a})||!f.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,f}};return t.map(c=>new le({view(d){const u=p=>{var f;r=(f=d.dom.parentElement)!=null&&f.contains(p.target)?d.dom.parentElement:null,r&&(Mr=e)},h=()=>{Mr&&(Mr=null)};return window.addEventListener("dragstart",u),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",u),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,u)=>{if(s=r===d.dom.parentElement,a=u,!s){const h=Mr;h?.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,u)=>{var h;const p=(h=u.clipboardData)==null?void 0:h.getData("text/html");return i=u,o=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(d,u,h)=>{const p=d[0],f=p.getMeta("uiEvent")==="paste"&&!o,m=p.getMeta("uiEvent")==="drop"&&!s,g=p.getMeta("applyPasteRules"),y=!!g;if(!f&&!m&&!y)return;if(y){let{text:E}=g;typeof E=="string"?E=E:E=Wi(M.from(E),h.schema);const{from:b}=g,T=b+E.length,v=Ry(E);return l({rule:c,state:h,from:b,to:{b:T},pasteEvt:v})}const w=u.doc.content.findDiffStart(h.doc.content),x=u.doc.content.findDiffEnd(h.doc.content);if(!(!Ty(w)||!x||w===x.b))return l({rule:c,state:h,from:w,to:x,pasteEvt:i})}}))}var Jo=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=n,this.extensions=Ui(n),this.schema=uu(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:gs(e.name,this.schema)},r=P(e,"addCommands",t);return r?{...n,...r()}:n},{})}get plugins(){const{editor:n}=this;return _i([...this.extensions].reverse()).flatMap(e=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:n,type:gs(e.name,this.schema)},r=[],o=P(e,"addKeyboardShortcuts",t);let s={};if(e.type==="mark"&&P(e,"exitable",t)&&(s.ArrowRight=()=>wt.handleExit({editor:n,mark:e})),o){const d=Object.fromEntries(Object.entries(o()).map(([u,h])=>[u,()=>h({editor:n})]));s={...s,...d}}const i=Xm(s);r.push(i);const a=P(e,"addInputRules",t);if(Sl(e,n.options.enableInputRules)&&a){const d=a();if(d&&d.length){const u=My({editor:n,rules:d}),h=Array.isArray(u)?u:[u];r.push(...h)}}const l=P(e,"addPasteRules",t);if(Sl(e,n.options.enablePasteRules)&&l){const d=l();if(d&&d.length){const u=Dy({editor:n,rules:d});r.push(...u)}}const c=P(e,"addProseMirrorPlugins",t);if(c){const d=c();r.push(...d)}return r})}get attributes(){return du(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=Rn(this.extensions);return Object.fromEntries(e.filter(t=>!!P(t,"addNodeView")).map(t=>{const r=this.attributes.filter(l=>l.type===t.name),o={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:me(t.name,this.schema)},s=P(t,"addNodeView",o);if(!s)return[];const i=s();if(!i)return[];const a=(l,c,d,u,h)=>{const p=cr(l,r);return i({node:l,view:c,getPos:d,decorations:u,innerDecorations:h,editor:n,extension:t,HTMLAttributes:p})};return[t.name,a]}))}get markViews(){const{editor:n}=this,{markExtensions:e}=Rn(this.extensions);return Object.fromEntries(e.filter(t=>!!P(t,"addMarkView")).map(t=>{const r=this.attributes.filter(a=>a.type===t.name),o={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:xt(t.name,this.schema)},s=P(t,"addMarkView",o);if(!s)return[];const i=(a,l,c)=>{const d=cr(a,r);return s()({mark:a,view:l,inline:c,editor:n,extension:t,HTMLAttributes:d,updateAttributes:u=>{Ky(a,n,u)}})};return[t.name,i]}))}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:gs(e.name,this.schema)};e.type==="mark"&&((t=Q(P(e,"keepOnSplit",r)))==null||t)&&this.splittableMarks.push(e.name);const o=P(e,"onBeforeCreate",r),s=P(e,"onCreate",r),i=P(e,"onUpdate",r),a=P(e,"onSelectionUpdate",r),l=P(e,"onTransaction",r),c=P(e,"onFocus",r),d=P(e,"onBlur",r),u=P(e,"onDestroy",r);o&&this.editor.on("beforeCreate",o),s&&this.editor.on("create",s),i&&this.editor.on("update",i),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}};Jo.resolve=Ui;Jo.sort=_i;Jo.flatten=Fi;var jy={};Hi(jy,{ClipboardTextSerializer:()=>wu,Commands:()=>ku,Delete:()=>vu,Drop:()=>Su,Editable:()=>Cu,FocusEvents:()=>Eu,Keymap:()=>Tu,Paste:()=>Nu,Tabindex:()=>Au,TextDirection:()=>Ou,focusEventsPluginKey:()=>Mu});var te=class xu extends Ki{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new xu(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},wu=te.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new le({key:new he("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:o}=e,{ranges:s}=o,i=Math.min(...s.map(c=>c.$from.pos)),a=Math.max(...s.map(c=>c.$to.pos)),l=pu(t);return hu(r,{from:i,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),ku=te.create({name:"commands",addCommands(){return{...Zd}}}),vu=te.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,o;const s=()=>{var i,a,l,c;if((c=(l=(a=(i=this.editor.options.coreExtensionOptions)==null?void 0:i.delete)==null?void 0:a.filterTransaction)==null?void 0:l.call(a,n))!=null?c:n.getMeta("y-sync$"))return;const d=au(n.before,[n,...e]);mu(d).forEach(h=>{d.mapping.mapResult(h.oldRange.from).deletedAfter&&d.mapping.mapResult(h.oldRange.to).deletedBefore&&d.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,f)=>{const m=f+p.nodeSize-2,g=h.oldRange.from<=f&&m<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:f,to:m,newFrom:d.mapping.map(f),newTo:d.mapping.map(m),deletedRange:h.oldRange,newRange:h.newRange,partial:!g,editor:this.editor,transaction:n,combinedTransform:d})})});const u=d.mapping;d.steps.forEach((h,p)=>{var f,m;if(h instanceof Ze){const g=u.slice(p).map(h.from,-1),y=u.slice(p).map(h.to),w=u.invert().map(g,-1),x=u.invert().map(y),E=(f=d.doc.nodeAt(g-1))==null?void 0:f.marks.some(T=>T.eq(h.mark)),b=(m=d.doc.nodeAt(y))==null?void 0:m.marks.some(T=>T.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:w,to:x},newRange:{from:g,to:y},partial:!!(b||E),editor:this.editor,transaction:n,combinedTransform:d})}})};(o=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||o?setTimeout(s,0):s()}}),Su=te.create({name:"drop",addProseMirrorPlugins(){return[new le({key:new he("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),Cu=te.create({name:"editable",addProseMirrorPlugins(){return[new le({key:new he("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Mu=new he("focusEvents"),Eu=te.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new le({key:Mu,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Tu=te.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:i})=>{const{selection:a,doc:l}=i,{empty:c,$anchor:d}=a,{pos:u,parent:h}=d,p=d.parent.isTextblock&&u>0?i.doc.resolve(u-1):d,f=p.parent.type.spec.isolating,m=d.pos-d.parentOffset,g=f&&p.parent.childCount===1?m===d.pos:W.atStart(l).from===u;return!c||!h.type.isTextblock||h.textContent.length||!g||g&&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()]),t={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...t},o={...t,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Wo()||su()?o:r},addProseMirrorPlugins(){return[new le({key:new he("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(p=>p.getMeta("composition")))return;const r=n.some(p=>p.docChanged)&&!e.doc.eq(t.doc),o=n.some(p=>p.getMeta("preventClearDocument"));if(!r||o)return;const{empty:s,from:i,to:a}=e.selection,l=W.atStart(e.doc).from,c=W.atEnd(e.doc).to;if(s||!(i===l&&a===c)||!qo(t.doc))return;const d=t.tr,u=Vo({state:t,transaction:d}),{commands:h}=new Fo({editor:this.editor,state:u});if(h.clearNodes(),!!d.steps.length)return d}})]}}),Nu=te.create({name:"paste",addProseMirrorPlugins(){return[new le({key:new he("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Au=te.create({name:"tabindex",addProseMirrorPlugins(){return[new le({key:new he("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Ou=te.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=Rn(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new le({key:new he("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}}),Ly=class kn{constructor(e,t,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,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 t=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}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,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),t=this.resolvedPos.doc.resolve(e);return new kn(t,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 kn(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 kn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const o=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,i=this.pos+r+(s?0:1);if(i<0||i>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(i);if(!o&&a.depth<=this.depth)return;const l=new kn(a,this.editor,o,o?t:null);o&&(l.actualDepth=this.depth+1),e.push(new kn(a,this.editor,o,o?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(t).length>0){const s=o.node.attrs,i=Object.keys(t);for(let a=0;a<i.length;a+=1){const l=i[a];if(s[l]!==t[l])break}}else r=o;o=o.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;const s=Object.keys(t);return this.children.forEach(i=>{r&&o.length>0||(i.node.type.name===e&&s.every(a=>t[a]===i.node.attrs[a])&&o.push(i),!(r&&o.length>0)&&(o=o.concat(i.querySelectorAll(e,t,r))))}),o}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},zy=`.ProseMirror {
10
+ <%s key={someKey} {...props} />`,_,F,Ne,F),Ce[F+_]=!0)}if(F=null,V!==void 0&&(t(V),F=""+V),i(B)&&(t(B.key),F=""+B.key),"key"in B){V={};for(var je in B)je!=="key"&&(V[je]=B[je])}else V=B;return F&&a(V,typeof C=="function"?C.displayName||C.name||"Unknown":C),c(C,F,V,o(),J,oe)}function u(C){h(C)?C._store&&(C._store.validated=1):typeof C=="object"&&C!==null&&C.$$typeof===R&&(C._payload.status==="fulfilled"?h(C._payload.value)&&C._payload.value._store&&(C._payload.value._store.validated=1):C._store&&(C._store.validated=1))}function h(C){return typeof C=="object"&&C!==null&&C.$$typeof===f}var p=z,f=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),E=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),$=Symbol.for("react.client.reference"),Y=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,pe=Object.prototype.hasOwnProperty,Z=Array.isArray,U=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(C){return C()}};var X,ee={},L=p.react_stack_bottom_frame.bind(p,s)(),Se=U(r(s)),Ce={};br.Fragment=g,br.jsx=function(C,B,V){var _=1e4>Y.recentlyCreatedOwnerStacks++;return d(C,B,V,!1,_?Error("react-stack-top-frame"):L,_?U(r(C)):Se)},br.jsxs=function(C,B,V){var _=1e4>Y.recentlyCreatedOwnerStacks++;return d(C,B,V,!0,_?Error("react-stack-top-frame"):L,_?U(r(C)):Se)}})()),br}var xa;function Kh(){return xa||(xa=1,process.env.NODE_ENV==="production"?Zo.exports=Uh():Zo.exports=qh()),Zo.exports}var N=Kh();function Jh(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Me(n){this.content=n}Me.prototype={constructor:Me,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),s=r.content.slice();return o==-1?s.push(t||n,e):(s[o+1]=e,t&&(s[o]=t)),new Me(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Me(t)},addToStart:function(n,e){return new Me([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Me(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),s=r.find(n);return o.splice(s==-1?o.length:s,0,e,t),new Me(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Me.from(n),n.size?new Me(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Me.from(n),n.size?new Me(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Me.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};Me.from=function(n){if(n instanceof Me)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Me(e)};function Nc(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),s=e.child(r);if(o==s){t+=o.nodeSize;continue}if(!o.sameMarkup(s))return t;if(o.isText&&o.text!=s.text){for(let i=0;o.text[i]==s.text[i];i++)t++;return t}if(o.content.size||s.content.size){let i=Nc(o.content,s.content,t+1);if(i!=null)return i}t+=o.nodeSize}}function Ac(n,e,t,r){for(let o=n.childCount,s=e.childCount;;){if(o==0||s==0)return o==s?null:{a:t,b:r};let i=n.child(--o),a=e.child(--s),l=i.nodeSize;if(i==a){t-=l,r-=l;continue}if(!i.sameMarkup(a))return{a:t,b:r};if(i.isText&&i.text!=a.text){let c=0,d=Math.min(i.text.length,a.text.length);for(;c<d&&i.text[i.text.length-c-1]==a.text[a.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||a.content.size){let c=Ac(i.content,a.content,t-1,r-1);if(c)return c}t-=l,r-=l}}class M{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,s){for(let i=0,a=0;a<t;i++){let l=this.content[i],c=a+l.nodeSize;if(c>e&&r(l,o+a,s||null,i)!==!1&&l.content.size){let d=a+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,t-d),r,o+d)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let s="",i=!0;return this.nodesBetween(e,t,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,t-l):a.isLeaf?o?typeof o=="function"?o(a):o:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(i?i=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)o.push(e.content[s]);return new M(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let s=0,i=0;i<t;s++){let a=this.content[s],l=i+a.nodeSize;l>e&&((i<e||l>t)&&(a.isText?a=a.cut(Math.max(0,e-i),Math.min(a.text.length,t-i)):a=a.cut(Math.max(0,e-i-1),Math.min(a.content.size,t-i-1))),r.push(a),o+=a.nodeSize),i=l}return new M(r,o)}cutByIndex(e,t){return e==t?M.empty:e==0&&t==this.content.length?this:new M(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new M(o,s)}addToStart(e){return new M([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new M(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return Nc(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Ac(this,e,t,r)}findIndex(e){if(e==0)return xr(0,e);if(e==this.size)return xr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let o=this.child(t),s=r+o.nodeSize;if(s>=e)return s==e?xr(t+1,s):xr(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return M.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new M(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return M.empty;let t,r=0;for(let o=0;o<e.length;o++){let s=e[o];r+=s.nodeSize,o&&s.isText&&e[o-1].sameMarkup(s)?(t||(t=e.slice(0,o)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new M(t||e,r)}static from(e){if(!e)return M.empty;if(e instanceof M)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new M([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}M.empty=new M([],0);const es={index:0,offset:0};function xr(n,e){return es.index=n,es.offset=e,es}function Wr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Wr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Wr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let ne=class $s{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let s=e[o];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,o));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Wr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=r.create(t.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return $s.none;if(e instanceof $s)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};ne.none=[];class _r extends Error{}class O{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Rc(this.content,e+this.openStart,t);return r&&new O(r,this.openStart,this.openEnd)}removeBetween(e,t){return new O(Oc(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return O.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new O(M.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)o++;return new O(e,r,o)}}O.empty=new O(M.empty,0,0);function Oc(n,e,t){let{index:r,offset:o}=n.findIndex(e),s=n.maybeChild(r),{index:i,offset:a}=n.findIndex(t);if(o==e||s.isText){if(a!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Oc(s.content,e-o-1,t-o-1)))}function Rc(n,e,t,r){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o);if(s==e||i.isText)return r&&!r.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let a=Rc(i.content,e-s-1,t,i);return a&&n.replaceChild(o,i.copy(a))}function Gh(n,e,t){if(t.openStart>n.depth)throw new _r("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new _r("Inconsistent open depths");return Dc(n,e,t,0)}function Dc(n,e,t,r){let o=n.index(r),s=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let i=Dc(n,e,t,r+1);return s.copy(s.content.replaceChild(o,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,a=i.content;return Yt(i,a.cut(0,n.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:i,end:a}=Xh(t,n);return Yt(s,Lc(n,i,a,e,r))}else return Yt(s,Ur(n,e,r))}function jc(n,e){if(!e.type.compatibleContent(n.type))throw new _r("Cannot join "+e.type.name+" onto "+n.type.name)}function Is(n,e,t){let r=n.node(t);return jc(r,e.node(t)),r}function Xt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Un(n,e,t,r){let o=(e||n).node(t),s=0,i=e?e.index(t):o.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Xt(n.nodeAfter,r),s++));for(let a=s;a<i;a++)Xt(o.child(a),r);e&&e.depth==t&&e.textOffset&&Xt(e.nodeBefore,r)}function Yt(n,e){return n.type.checkContent(e),n.copy(e)}function Lc(n,e,t,r,o){let s=n.depth>o&&Is(n,e,o+1),i=r.depth>o&&Is(t,r,o+1),a=[];return Un(null,n,o,a),s&&i&&e.index(o)==t.index(o)?(jc(s,i),Xt(Yt(s,Lc(n,e,t,r,o+1)),a)):(s&&Xt(Yt(s,Ur(n,e,o+1)),a),Un(e,t,o,a),i&&Xt(Yt(i,Ur(t,r,o+1)),a)),Un(r,null,o,a),new M(a)}function Ur(n,e,t){let r=[];if(Un(null,n,t,r),n.depth>t){let o=Is(n,e,t+1);Xt(Yt(o,Ur(n,e,t+1)),r)}return Un(e,null,t,r),new M(r)}function Xh(n,e){let t=e.depth-n.openStart,r=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)r=e.node(o).copy(M.from(r));return{start:r.resolveNoCache(n.openStart+t),end:r.resolveNoCache(r.content.size-n.openEnd-t)}}class tr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.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,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)o+=r.child(s).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return ne.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let a=r;r=o,o=a}let s=r.marks;for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!o||!s[i].isInSet(o.marks))&&(s=s[i--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!o||!r[s].isInSet(o.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new qr(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 t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,s=t;for(let i=e;;){let{index:a,offset:l}=i.content.findIndex(s),c=s-l;if(r.push(i,a,o+l),!c||(i=i.child(a),i.isText))break;s=c-1,o+=l+1}return new tr(t,r,s)}static resolveCached(e,t){let r=wa.get(e);if(r)for(let s=0;s<r.elts.length;s++){let i=r.elts[s];if(i.pos==t)return i}else wa.set(e,r=new Yh);let o=r.elts[r.i]=tr.resolve(e,t);return r.i=(r.i+1)%Qh,o}}class Yh{constructor(){this.elts=[],this.i=0}}const Qh=12,wa=new WeakMap;class qr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Zh=Object.create(null);class Je{constructor(e,t,r,o=ne.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||M.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,o=0){this.content.nodesBetween(e,t,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,t,r,o){return this.content.textBetween(e,t,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,t,r){return this.type==e&&Wr(this.attrs,t||e.defaultAttrs||Zh)&&ne.sameSet(this.marks,r||ne.none)}copy(e=null){return e==this.content?this:new Je(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Je(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return O.empty;let o=this.resolve(e),s=this.resolve(t),i=r?0:o.sharedDepth(t),a=o.start(i),l=o.node(i).content.cut(o.pos-a,s.pos-a);return new O(l,o.depth-i,s.depth-i)}replace(e,t,r){return Gh(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return tr.resolveCached(this,e)}resolveNoCache(e){return tr.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.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()+")"),zc(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=M.empty,o=0,s=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,o,s),a=i&&i.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let l=o;l<s;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let s=this.contentMatchAt(e).matchType(r),i=s&&s.matchFragment(this.content,t);return i?i.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=ne.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!ne.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t 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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=M.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,o,r);return s.type.checkAttrs(s.attrs),s}}Je.prototype.text=void 0;class Kr extends Je{constructor(e,t,r,o){if(super(e,t,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):zc(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Kr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Kr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function zc(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class tn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new ep(e,t);if(r.next==null)return tn.empty;let o=$c(r);r.next&&r.err("Unexpected trailing text");let s=ap(ip(o));return lp(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let s=t;o&&s<r;s++)o=o.matchType(e.child(s).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:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function s(i,a){let l=i.matchFragment(e,r);if(l&&(!t||l.validEnd))return M.from(a.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:d,next:u}=i.next[c];if(!(d.isText||d.hasRequiredAttrs())&&o.indexOf(u)==-1){o.push(u);let h=s(u,a.concat(d));if(h)return h}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),s=o.match;if(s.matchType(e)){let i=[];for(let a=o;a.type;a=a.via)i.push(a.type);return i.reverse()}for(let i=0;i<s.next.length;i++){let{type:a,next:l}=s.next[i];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!o.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:o}),t[a.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 t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let s=o+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)s+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return s}).join(`
11
+ `)}}tn.empty=new tn(!0);class ep{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),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 $c(n){let e=[];do e.push(tp(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function tp(n){let e=[];do e.push(np(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function np(n){let e=sp(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=rp(n,e);else break;return e}function ka(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function rp(n,e){let t=ka(n),r=t;return n.eat(",")&&(n.next!="}"?r=ka(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function op(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let s in t){let i=t[s];i.isInGroup(e)&&o.push(i)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function sp(n){if(n.eat("(")){let e=$c(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=op(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function ip(n){let e=[[]];return o(s(n,0),t()),e;function t(){return e.push([])-1}function r(i,a,l){let c={term:l,to:a};return e[i].push(c),c}function o(i,a){i.forEach(l=>l.to=a)}function s(i,a){if(i.type=="choice")return i.exprs.reduce((l,c)=>l.concat(s(c,a)),[]);if(i.type=="seq")for(let l=0;;l++){let c=s(i.exprs[l],a);if(l==i.exprs.length-1)return c;o(c,a=t())}else if(i.type=="star"){let l=t();return r(a,l),o(s(i.expr,l),l),[r(l)]}else if(i.type=="plus"){let l=t();return o(s(i.expr,a),l),o(s(i.expr,l),l),[r(l)]}else{if(i.type=="opt")return[r(a)].concat(s(i.expr,a));if(i.type=="range"){let l=a;for(let c=0;c<i.min;c++){let d=t();o(s(i.expr,l),d),l=d}if(i.max==-1)o(s(i.expr,l),l);else for(let c=i.min;c<i.max;c++){let d=t();r(l,d),o(s(i.expr,l),d),l=d}return[r(l)]}else{if(i.type=="name")return[r(a,void 0,i.value)];throw new Error("Unknown expr type")}}}}function Ic(n,e){return e-n}function va(n,e){let t=[];return r(e),t.sort(Ic);function r(o){let s=n[o];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(o);for(let i=0;i<s.length;i++){let{term:a,to:l}=s[i];!a&&t.indexOf(l)==-1&&r(l)}}}function ap(n){let e=Object.create(null);return t(va(n,0));function t(r){let o=[];r.forEach(i=>{n[i].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let d=0;d<o.length;d++)o[d][0]==a&&(c=o[d][1]);va(n,l).forEach(d=>{c||o.push([a,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let s=e[r.join(",")]=new tn(r.indexOf(n.length-1)>-1);for(let i=0;i<o.length;i++){let a=o[i][1].sort(Ic);s.next.push({type:o[i][0],next:e[a.join(",")]||t(a)})}return s}}function lp(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],s=!o.validEnd,i=[];for(let a=0;a<o.next.length;a++){let{type:l,next:c}=o.next[a];i.push(l.name),s&&!(l.isText||l.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Pc(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Hc(n,e){let t=Object.create(null);for(let r in n){let o=e&&e[r];if(o===void 0){let s=n[r];if(s.hasDefault)o=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=o}return t}function Bc(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);for(let o in n){let s=n[o];s.validate&&s.validate(e[o])}}function Vc(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new dp(n,r,e[r]);return t}let Sa=class Fc{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Vc(e,r.attrs),this.defaultAttrs=Pc(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:Hc(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Je(this,this.computeAttrs(e),M.from(t),ne.setFrom(r))}createChecked(e=null,t,r){return t=M.from(t),this.checkContent(t),new Je(this,this.computeAttrs(e),t,ne.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=M.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let o=this.contentMatch.matchFragment(t),s=o&&o.fillBefore(M.empty,!0);return s?new Je(this,e,t.append(s),ne.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.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){Bc(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 t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:ne.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,i)=>r[s]=new Fc(s,t,i));let o=t.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 s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function cp(n,e,t){let r=t.split("|");return o=>{let s=o===null?"null":typeof o;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class dp{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?cp(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Lo{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Vc(e,o.attrs),this.excluded=null;let s=Pc(this.attrs);this.instance=s?new ne(this,s):null}create(e=null){return!e&&this.instance?this.instance:new ne(this,Hc(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((s,i)=>r[s]=new Lo(s,o++,t,i)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Bc(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Wc{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=Me.from(e.nodes),t.marks=Me.from(e.marks||{}),this.nodes=Sa.compile(this.spec.nodes,this),this.marks=Lo.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 s=this.nodes[o],i=s.spec.content||"",a=s.spec.marks;if(s.contentMatch=r[i]||(r[i]=tn.parse(i,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=a=="_"?null:a?Ca(this,a.split(" ")):a==""||!s.inlineContent?[]:null}for(let o in this.marks){let s=this.marks[o],i=s.spec.excludes;s.excluded=i==null?[s]:i==""?[]:Ca(this,i.split(" "))}this.nodeFromJSON=o=>Je.fromJSON(this,o),this.markFromJSON=o=>ne.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Sa){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(t,r,o)}text(e,t){let r=this.nodes.text;return new Kr(r,r.defaultAttrs,e,ne.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Ca(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],s=n.marks[o],i=s;if(s)t.push(s);else for(let a in n.marks){let l=n.marks[a];(o=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(o)>-1)&&t.push(i=l)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function up(n){return n.tag!=null}function hp(n){return n.style!=null}class jt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(up(o))this.tags.push(o);else if(hp(o)){let s=/[^=]*/.exec(o.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=e.nodes[o.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Ea(this,t,!1);return r.addAll(e,ne.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Ea(this,t,!0);return r.addAll(e,ne.none,t.from,t.to),O.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(mp(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(e);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(e,t,r,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let i=this.styles[s],a=i.style;if(!(a.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(i.getAttrs){let l=i.getAttrs(t);if(l===!1)continue;i.attrs=l||void 0}return i}}}static schemaRules(e){let t=[];function r(o){let s=o.priority==null?50:o.priority,i=0;for(;i<t.length;i++){let a=t[i];if((a.priority==null?50:a.priority)<s)break}t.splice(i,0,o)}for(let o in e.marks){let s=e.marks[o].spec.parseDOM;s&&s.forEach(i=>{r(i=Ta(i)),i.mark||i.ignore||i.clearMark||(i.mark=o)})}for(let o in e.nodes){let s=e.nodes[o].spec.parseDOM;s&&s.forEach(i=>{r(i=Ta(i)),i.node||i.ignore||i.mark||(i.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new jt(e,jt.schemaRules(e)))}}const _c={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},pp={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Uc={ol:!0,ul:!0},nr=1,Ps=2,qn=4;function Ma(n,e,t){return e!=null?(e?nr:0)|(e==="full"?Ps:0):n&&n.whitespace=="pre"?nr|Ps:t&~qn}class wr{constructor(e,t,r,o,s,i){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=i,this.content=[],this.activeMarks=ne.none,this.match=s||(i&qn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(M.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);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&nr)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let t=M.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(M.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!_c.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ea{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,s,i=Ma(null,t.preserveWhitespace,0)|(r?qn:0);o?s=new wr(o.type,o.attrs,ne.none,!0,t.topMatch||o.type.contentMatch,i):r?s=new wr(null,null,ne.none,!0,null,i):s=new wr(e.schema.topNodeType,null,ne.none,!0,null,i),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,s=o.options&Ps?"full":this.localPreserveWS||(o.options&nr)>0,{schema:i}=this.parser;if(s==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
12
+ `);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(i.linebreakReplacement.create(),t,!0),a[l]&&this.insertNode(i.text(a[l]),t,!/\S/.test(a[l]));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 a=o.content[o.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),a;Uc.hasOwnProperty(i)&&this.parser.normalizeLists&&fp(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:pp.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,d=this.needsBlock;if(_c.hasOwnProperty(i))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=l&&l.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(s),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
13
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=r.getPropertyValue(s);if(i)for(let a=void 0;;){let l=this.parser.matchStyle(s,i,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?t=t.filter(c=>!l.clearMark(c)):t=t.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return t}addElementByRule(e,t,r,o){let s,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(i,t.attrs||null,r,t.preserveWhitespace);l&&(s=!0,r=l)}else{let l=this.parser.schema.marks[t.mark];r=r.concat(l.create(t.attrs))}let a=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}s&&this.sync(a)&&this.open--}addAll(e,t,r,o){let s=r||0;for(let i=r?e.childNodes[r]:e.firstChild,a=o==null?null:e.childNodes[o];i!=a;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t,r){let o,s;for(let i=this.open,a=0;i>=0;i--){let l=this.nodes[i],c=l.findWrapping(e);if(c&&(!o||o.length>c.length+a)&&(o=c,s=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)t=this.enterInner(o[i],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=ne.none;for(let a of o.concat(e.marks))(s.type?s.type.allowsMarkType(a.type):Na(a.type,e.type))&&(i=a.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,r,o){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,o)),s}enterInner(e,t,r,o=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let a=Ma(e,s,i.options);i.options&qn&&i.content.length==0&&(a|=qn);let l=ne.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):Na(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new wr(e,t,l,o,null,a)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=nr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?0:1),i=(a,l)=>{for(;a>=0;a--){let c=t[a];if(c==""){if(a==t.length-1||a==0)continue;for(;l>=s;l--)if(i(a-1,l))return!0;return!1}else{let d=l>0||l==0&&o?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;l--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function fp(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Uc.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function mp(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Ta(n){let e={};for(let t in n)e[t]=n[t];return e}function Na(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let s=[],i=a=>{s.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:d}=a.edge(l);if(c==e||s.indexOf(d)<0&&i(d))return!0}};if(i(o.contentMatch))return!0}}class Bt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=ts(t).createDocumentFragment());let o=r,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let a=0,l=0;for(;a<s.length&&l<i.marks.length;){let c=i.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(s[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<s.length;)o=s.pop()[1];for(;l<i.marks.length;){let c=i.marks[l++],d=this.serializeMark(c,i.isInline,t);d&&(s.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:o}=$r(ts(t),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,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let s=this.serializeMark(e.marks[o],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&$r(ts(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return $r(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Bt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Aa(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Aa(e.marks)}}function Aa(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function ts(n){return n.document||window.document}const Oa=new WeakMap;function gp(n){let e=Oa.get(n);return e===void 0&&Oa.set(n,e=yp(n)),e}function yp(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function $r(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=gp(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=o.indexOf(" ");i>0&&(t=o.slice(0,i),o=o.slice(i+1));let a,l=t?n.createElementNS(t,o):n.createElement(o),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let h=u.indexOf(" ");h>0?l.setAttributeNS(u.slice(0,h),u.slice(h+1),c[u]):u=="style"&&l.style?l.style.cssText=c[u]:l.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let h=e[u];if(h===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:p,contentDOM:f}=$r(n,h,t,r);if(l.appendChild(p),f){if(a)throw new RangeError("Multiple content holes");a=f}}}return{dom:l,contentDOM:a}}const qc=65535,Kc=Math.pow(2,16);function bp(n,e){return n+e*Kc}function Ra(n){return n&qc}function xp(n){return(n-(n&qc))/Kc}const Jc=1,Gc=2,Ir=4,Xc=8;class Hs{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Xc)>0}get deletedBefore(){return(this.delInfo&(Jc|Ir))>0}get deletedAfter(){return(this.delInfo&(Gc|Ir))>0}get deletedAcross(){return(this.delInfo&Ir)>0}}class Ve{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Ve.empty)return Ve.empty}recover(e){let t=0,r=Ra(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+xp(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?o:0);if(l>e)break;let c=this.ranges[a+s],d=this.ranges[a+i],u=l+c;if(e<=u){let h=c?e==l?-1:e==u?1:t:t,p=l+o+(h<0?0:d);if(r)return p;let f=e==(t<0?l:u)?null:bp(a/3,e-l),m=e==l?Gc:e==u?Jc:Ir;return(t<0?e!=l:e!=u)&&(m|=Xc),new Hs(p,m,f)}o+=d-c}return r?e+o:new Hs(e+o,0,null)}touches(e,t){let r=0,o=Ra(t),s=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+s],d=l+c;if(e<=d&&a==o*3)return!0;r+=this.ranges[a+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],a=i-(this.inverted?s:0),l=i+(this.inverted?0:s),c=this.ranges[o+t],d=this.ranges[o+r];e(a,a+c,l,l+d),s+=d-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 rr{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new rr(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let o=e.getMirror(t);this.appendMap(e._maps[t],o!=null&&o<t?r+o:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new rr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let s=this.from;s<this.to;s++){let i=this._maps[s],a=i.mapResult(e,t);if(a.recover!=null){let l=this.getMirror(s);if(l!=null&&l>s&&l<this.to){s=l,e=this._maps[l].recover(a.recover);continue}}o|=a.delInfo,e=a.pos}return r?e:new Hs(e,o,null)}}const ns=Object.create(null);class De{getMap(){return Ve.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ns[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in ns)throw new RangeError("Duplicate use of step JSON ID "+e);return ns[e]=t,t.prototype.jsonID=e,t}}class fe{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new fe(e,null)}static fail(e){return new fe(null,e)}static fromReplace(e,t,r,o){try{return fe.ok(e.replace(t,r,o))}catch(s){if(s instanceof _r)return fe.fail(s.message);throw s}}}function xi(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let s=n.child(o);s.content.size&&(s=s.copy(xi(s.content,e,s))),s.isInline&&(s=e(s,t,o)),r.push(s)}return M.fromArray(r)}class Ot extends De{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new O(xi(t.content,(i,a)=>!i.isAtom||!a.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),t.openStart,t.openEnd);return fe.fromReplace(e,this.from,this.to,s)}invert(){return new Ze(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ot(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ot&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ot(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ot(t.from,t.to,e.markFromJSON(t.mark))}}De.jsonID("addMark",Ot);class Ze extends De{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new O(xi(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return fe.fromReplace(e,this.from,this.to,r)}invert(){return new Ot(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ze(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ze&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ze(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ze(t.from,t.to,e.markFromJSON(t.mark))}}De.jsonID("removeMark",Ze);class Rt extends De{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return fe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return fe.fromReplace(e,this.pos,this.pos+1,new O(M.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new Rt(this.pos,t.marks[o]);return new Rt(this.pos,this.mark)}}return new nn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Rt(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Rt(t.pos,e.markFromJSON(t.mark))}}De.jsonID("addNodeMark",Rt);class nn extends De{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return fe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return fe.fromReplace(e,this.pos,this.pos+1,new O(M.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Rt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new nn(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new nn(t.pos,e.markFromJSON(t.mark))}}De.jsonID("removeNodeMark",nn);class be extends De{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&Bs(e,this.from,this.to)?fe.fail("Structure replace would overwrite content"):fe.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 be(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new be(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof be)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?O.empty:new O(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new be(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?O.empty:new O(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new be(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new be(t.from,t.to,O.fromJSON(e,t.slice),!!t.structure)}}De.jsonID("replace",be);class we extends De{constructor(e,t,r,o,s,i,a=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=a}apply(e){if(this.structure&&(Bs(e,this.from,this.gapFrom)||Bs(e,this.gapTo,this.to)))return fe.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return fe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?fe.fromReplace(e,this.from,this.to,r):fe.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 t=this.gapTo-this.gapFrom;return new we(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||s>r.pos?null:new we(t.pos,r.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new we(t.from,t.to,t.gapFrom,t.gapTo,O.fromJSON(e,t.slice),t.insert,!!t.structure)}}De.jsonID("replaceAround",we);function Bs(n,e,t){let r=n.resolve(e),o=t-e,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function wp(n,e,t,r){let o=[],s=[],i,a;n.doc.nodesBetween(e,t,(l,c,d)=>{if(!l.isInline)return;let u=l.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let h=Math.max(c,e),p=Math.min(c+l.nodeSize,t),f=r.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(f)||(i&&i.to==h&&i.mark.eq(u[m])?i.to=p:o.push(i=new Ze(h,p,u[m])));a&&a.to==h?a.to=p:s.push(a=new Ot(h,p,r))}}),o.forEach(l=>n.step(l)),s.forEach(l=>n.step(l))}function kp(n,e,t,r){let o=[],s=0;n.doc.nodesBetween(e,t,(i,a)=>{if(!i.isInline)return;s++;let l=null;if(r instanceof Lo){let c=i.marks,d;for(;d=r.isInSet(c);)(l||(l=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(i.marks)&&(l=[r]):l=i.marks;if(l&&l.length){let c=Math.min(a+i.nodeSize,t);for(let d=0;d<l.length;d++){let u=l[d],h;for(let p=0;p<o.length;p++){let f=o[p];f.step==s-1&&u.eq(o[p].style)&&(h=f)}h?(h.to=c,h.step=s):o.push({style:u,from:Math.max(a,e),to:c,step:s})}}}),o.forEach(i=>n.step(new Ze(i.from,i.to,i.style)))}function wi(n,e,t,r=t.contentMatch,o=!0){let s=n.doc.nodeAt(e),i=[],a=e+1;for(let l=0;l<s.childCount;l++){let c=s.child(l),d=a+c.nodeSize,u=r.matchType(c.type);if(!u)i.push(new be(a,d,O.empty));else{r=u;for(let h=0;h<c.marks.length;h++)t.allowsMarkType(c.marks[h].type)||n.step(new Ze(a,d,c.marks[h]));if(o&&c.isText&&t.whitespace!="pre"){let h,p=/\r?\n|\r/g,f;for(;h=p.exec(c.text);)f||(f=new O(M.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new be(a+h.index,a+h.index+h[0].length,f))}}a=d}if(!r.validEnd){let l=r.fillBefore(M.empty,!0);n.replace(a,a,new O(l,0,0))}for(let l=i.length-1;l>=0;l--)n.step(i[l])}function vp(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function jn(n){let e=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let t=n.depth,r=0,o=0;;--t){let s=n.$from.node(t),i=n.$from.index(t)+r,a=n.$to.indexAfter(t)-o;if(t<n.depth&&s.canReplace(i,a,e))return t;if(t==0||s.type.spec.isolating||!vp(s,i,a))break;i&&(r=1),a<s.childCount&&(o=1)}return null}function Sp(n,e,t){let{$from:r,$to:o,depth:s}=e,i=r.before(s+1),a=o.after(s+1),l=i,c=a,d=M.empty,u=0;for(let f=s,m=!1;f>t;f--)m||r.index(f)>0?(m=!0,d=M.from(r.node(f).copy(d)),u++):l--;let h=M.empty,p=0;for(let f=s,m=!1;f>t;f--)m||o.after(f+1)<o.end(f)?(m=!0,h=M.from(o.node(f).copy(h)),p++):c++;n.step(new we(l,c,i,a,new O(d.append(h),u,p),d.size-u,!0))}function ki(n,e,t=null,r=n){let o=Cp(n,e),s=o&&Mp(r,e);return s?o.map(Da).concat({type:e,attrs:t}).concat(s.map(Da)):null}function Da(n){return{type:n,attrs:null}}function Cp(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let i=s.length?s[0]:e;return t.canReplaceWith(r,o,i)?s:null}function Mp(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.child(r),i=e.contentMatch.findWrapping(s.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let l=r;a&&l<o;l++)a=a.matchType(t.child(l).type);return!a||!a.validEnd?null:i}function Ep(n,e,t){let r=M.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let a=t[i].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=M.from(t[i].type.create(t[i].attrs,r))}let o=e.start,s=e.end;n.step(new we(o,s,o,s,new O(r,0,0),t.length,!0))}function Tp(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(i,a)=>{let l=typeof o=="function"?o(i):o;if(i.isTextblock&&!i.hasMarkup(r,l)&&Np(n.doc,n.mapping.slice(s).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",f=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!f?c=!1:!p&&f&&(c=!0)}c===!1&&Qc(n,i,a,s),wi(n,n.mapping.slice(s).map(a,1),r,void 0,c===null);let d=n.mapping.slice(s),u=d.map(a,1),h=d.map(a+i.nodeSize,1);return n.step(new we(u,h,u+1,h-1,new O(M.from(r.create(l,null,i.marks)),0,0),1,!0)),c===!0&&Yc(n,i,a,s),!1}})}function Yc(n,e,t,r){e.forEach((o,s)=>{if(o.isText){let i,a=/\r?\n|\r/g;for(;i=a.exec(o.text);){let l=n.mapping.slice(r).map(t+1+s+i.index);n.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function Qc(n,e,t,r){e.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+s);n.replaceWith(i,i+1,e.type.schema.text(`
14
+ `))}})}function Np(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function Ap(n,e,t,r,o){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let i=t.create(r,null,o||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,i);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new we(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new O(M.from(i),0,0),1,!0))}function yt(n,e,t=1,r){let o=n.resolve(e),s=o.depth-t,i=r&&r[r.length-1]||o.parent;if(s<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!i.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,d=t-2;c>s;c--,d--){let u=o.node(c),h=o.index(c);if(u.type.spec.isolating)return!1;let p=u.content.cutByIndex(h,u.childCount),f=r&&r[d+1];f&&(p=p.replaceChild(0,f.type.create(f.attrs)));let m=r&&r[d]||u;if(!u.canReplace(h+1,u.childCount)||!m.type.validContent(p))return!1}let a=o.indexAfter(s),l=r&&r[0];return o.node(s).canReplaceWith(a,a,l?l.type:o.node(s+1).type)}function Op(n,e,t=1,r){let o=n.doc.resolve(e),s=M.empty,i=M.empty;for(let a=o.depth,l=o.depth-t,c=t-1;a>l;a--,c--){s=M.from(o.node(a).copy(s));let d=r&&r[c];i=M.from(d?d.type.create(d.attrs,i):o.node(a).copy(i))}n.step(new be(e,e,new O(s.append(i),t,t),!0))}function Vt(n,e){let t=n.resolve(e),r=t.index();return Zc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Rp(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let s=e.child(o),i=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Zc(n,e){return!!(n&&e&&!n.isLeaf&&Rp(n,e))}function zo(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let s,i,a=r.index(o);if(o==r.depth?(s=r.nodeBefore,i=r.nodeAfter):t>0?(s=r.node(o+1),a++,i=r.node(o).maybeChild(a)):(s=r.node(o).maybeChild(a-1),i=r.node(o+1)),s&&!s.isTextblock&&Zc(s,i)&&r.node(o).canReplace(a,a+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function Dp(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,s=n.doc.resolve(e-t),i=s.node().type;if(o&&i.inlineContent){let d=i.whitespace=="pre",u=!!i.contentMatch.matchType(o);d&&!u?r=!1:!d&&u&&(r=!0)}let a=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);Qc(n,d.node(),d.before(),a)}i.inlineContent&&wi(n,e+t-1,i,s.node().contentMatchAt(s.index()),r==null);let l=n.mapping.slice(a),c=l.map(e-t);if(n.step(new be(c,l.map(e+t,-1),O.empty,!0)),r===!0){let d=n.doc.resolve(c);Yc(n,d.node(),d.before(),n.steps.length)}return n}function jp(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let s=r.index(o);if(r.node(o).canReplaceWith(s,s,t))return r.before(o+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let s=r.indexAfter(o);if(r.node(o).canReplaceWith(s,s,t))return r.after(o+1);if(s<r.node(o).childCount)return null}return null}function ed(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let s=0;s<t.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let i=r.depth;i>=0;i--){let a=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,l=r.index(i)+(a>0?1:0),c=r.node(i),d=!1;if(s==1)d=c.canReplace(l,l,o);else{let u=c.contentMatchAt(l).findWrapping(o.firstChild.type);d=u&&c.canReplaceWith(l,l,u[0])}if(d)return a==0?r.pos:a<0?r.before(i+1):r.after(i+1)}return null}function $o(n,e,t=e,r=O.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),s=n.resolve(t);return td(o,s,r)?new be(e,t,r):new Lp(o,s,r).fit()}function td(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Lp{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=M.empty;for(let o=0;o<=e.depth;o++){let s=e.node(o);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=M.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(),t=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 s=this.placed,i=r.depth,a=o.depth;for(;i&&a&&s.childCount==1;)s=s.firstChild.content,i--,a--;let l=new O(s,i,a);return e>-1?new we(r.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||r.pos!=this.$to.pos?new be(r.pos,o.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(o=0),s.type.spec.isolating&&o<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,s=null;r?(s=rs(this.unplaced.content,r-1).firstChild,o=s.content):o=this.unplaced.content;let i=o.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],d,u=null;if(t==1&&(i?c.matchType(i.type)||(u=c.fillBefore(M.from(i),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:a,parent:s,inject:u};if(t==2&&i&&(d=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:a,parent:s,wrap:d};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=rs(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new O(e,t+1,Math.max(r,o.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=rs(e,t);if(o.childCount<=1&&t>0){let s=e.size-t<=t+o.size;this.unplaced=new O(Vn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new O(Vn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let i=this.unplaced,a=r?r.content:i.content,l=i.openStart-e,c=0,d=[],{match:u,type:h}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)d.push(o.child(m));u=u.matchFragment(o)}let p=a.size+e-(i.content.size-i.openEnd);for(;c<a.childCount;){let m=a.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||l==0||m.content.size)&&(u=g,d.push(nd(m.mark(h.allowedMarks(m.marks)),c==1?l:0,c==a.childCount?p:-1)))}let f=c==a.childCount;f||(p=-1),this.placed=Fn(this.placed,t,M.from(d)),this.frontier[t].match=u,f&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=a;m<p;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=f?e==0?O.empty:new O(Vn(i.content,e-1,1),e-1,p<0?i.openEnd:e-1):new O(Vn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!ss(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=ss(e,t,o,r,s);if(i){for(let a=t-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],d=ss(e,a,c,l,!0);if(!d||d.childCount)continue e}return{depth:t,fit:i,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Fn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),s=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,s)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Fn(this.placed,this.depth,M.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(M.empty,!0);e.childCount&&(this.placed=Fn(this.placed,this.frontier.length,e))}}function Vn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Vn(n.firstChild.content,e-1,t)))}function Fn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Fn(n.lastChild.content,e-1,t)))}function rs(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function nd(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,nd(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(M.empty,!0)))),n.copy(r)}function ss(n,e,t,r,o){let s=n.node(e),i=o?n.indexAfter(e):n.index(e);if(i==s.childCount&&!t.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,i);return a&&!zp(t,s.content,i)?a:null}function zp(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function $p(n){return n.spec.defining||n.spec.definingForContent}function Ip(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),s=n.doc.resolve(t);if(td(o,s,r))return n.step(new be(e,t,r));let i=od(o,s);i[i.length-1]==0&&i.pop();let a=-(o.depth+1);i.unshift(a);for(let h=o.depth,p=o.pos-1;h>0;h--,p--){let f=o.node(h).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;i.indexOf(h)>-1?a=h:o.before(h)==p&&i.splice(1,0,-h)}let l=i.indexOf(a),c=[],d=r.openStart;for(let h=r.content,p=0;;p++){let f=h.firstChild;if(c.push(f),p==r.openStart)break;h=f.content}for(let h=d-1;h>=0;h--){let p=c[h],f=$p(p.type);if(f&&!p.sameMarkup(o.node(Math.abs(a)-1)))d=h;else if(f||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+d+1)%(r.openStart+1),f=c[p];if(f)for(let m=0;m<i.length;m++){let g=i[(m+l)%i.length],y=!0;g<0&&(y=!1,g=-g);let w=o.node(g-1),x=o.index(g-1);if(w.canReplaceWith(x,x,f.type,f.marks))return n.replace(o.before(g),y?s.after(g):t,new O(rd(r.content,0,r.openStart,p),p,r.openEnd))}}let u=n.steps.length;for(let h=i.length-1;h>=0&&(n.replace(e,t,r),!(n.steps.length>u));h--){let p=i[h];p<0||(e=o.before(p),t=s.after(p))}}function rd(n,e,t,r,o){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(rd(s.content,e+1,t,r,s)))}if(e>r){let s=o.contentMatchAt(0),i=s.fillBefore(n).append(n);n=i.append(s.matchFragment(i).fillBefore(M.empty,!0))}return n}function Pp(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=jp(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new O(M.from(r),0,0))}function Hp(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t),s=od(r,o);for(let i=0;i<s.length;i++){let a=s[i],l=i==s.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return n.delete(r.start(a),o.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),o.indexAfter(a-1))))return n.delete(r.before(a),o.after(a))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(e-r.start(i)==r.depth-i&&t>r.end(i)&&o.end(i)-t!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return n.delete(r.before(i),t);n.delete(e,t)}function od(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let s=n.start(o);if(s<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(s==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==s-1)&&t.push(o)}return t}class Mn extends De{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return fe.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return fe.fromReplace(e,this.pos,this.pos+1,new O(M.from(o),0,t.isLeaf?0:1))}getMap(){return Ve.empty}invert(e){return new Mn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Mn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Mn(t.pos,t.attr,t.value)}}De.jsonID("attr",Mn);class or extends De{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return fe.ok(r)}getMap(){return Ve.empty}invert(e){return new or(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new or(t.attr,t.value)}}De.jsonID("docAttr",or);let Tn=class extends Error{};Tn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Tn.prototype=Object.create(Error.prototype);Tn.prototype.constructor=Tn;Tn.prototype.name="TransformError";class vi{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new rr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Tn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=O.empty){let o=$o(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new O(M.from(r),0,0))}delete(e,t){return this.replace(e,t,O.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Ip(this,e,t,r),this}replaceRangeWith(e,t,r){return Pp(this,e,t,r),this}deleteRange(e,t){return Hp(this,e,t),this}lift(e,t){return Sp(this,e,t),this}join(e,t=1){return Dp(this,e,t),this}wrap(e,t){return Ep(this,e,t),this}setBlockType(e,t=e,r,o=null){return Tp(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return Ap(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new Mn(e,t,r)),this}setDocAttribute(e,t){return this.step(new or(e,t)),this}addNodeMark(e,t){return this.step(new Rt(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof ne)t.isInSet(r.marks)&&this.step(new nn(e,t));else{let o=r.marks,s,i=[];for(;s=t.isInSet(o);)i.push(new nn(e,s)),o=s.removeFromSet(o);for(let a=i.length-1;a>=0;a--)this.step(i[a])}return this}split(e,t=1,r){return Op(this,e,t,r),this}addMark(e,t,r){return wp(this,e,t,r),this}removeMark(e,t,r){return kp(this,e,t,r),this}clearIncompatible(e,t,r){return wi(this,e,t,r),this}}const is=Object.create(null);class W{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new sd(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=O.empty){let r=t.content.lastChild,o=null;for(let a=0;a<t.openEnd;a++)o=r,r=r.lastChild;let s=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:l,$to:c}=i[a],d=e.mapping.slice(s);e.replaceRange(d.map(l.pos),d.map(c.pos),a?O.empty:t),a==0&&za(e,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:a}=o[s],l=e.mapping.slice(r),c=l.map(i.pos),d=l.map(a.pos);s?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),za(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new H(e):xn(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let s=e.depth-1;s>=0;s--){let i=t<0?xn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):xn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new We(e.node(0))}static atStart(e){return xn(e,e,0,0,1)||new We(e)}static atEnd(e){return xn(e,e,e.content.size,e.childCount,-1)||new We(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=is[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in is)throw new RangeError("Duplicate use of selection JSON ID "+e);return is[e]=t,t.prototype.jsonID=e,t}getBookmark(){return H.between(this.$anchor,this.$head).getBookmark()}}W.prototype.visible=!0;class sd{constructor(e,t){this.$from=e,this.$to=t}}let ja=!1;function La(n){!ja&&!n.parent.inlineContent&&(ja=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class H extends W{constructor(e,t=e){La(e),La(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return W.near(r);let o=e.resolve(t.map(this.anchor));return new H(o.parent.inlineContent?o:r,r)}replace(e,t=O.empty){if(super.replace(e,t),t==O.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof H&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Io(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new H(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let s=W.findFrom(t,r,!0)||W.findFrom(t,-r,!0);if(s)t=s.$head;else return W.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(W.findFrom(e,-r,!0)||W.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new H(e,t)}}W.jsonID("text",H);class Io{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Io(e.map(this.anchor),e.map(this.head))}resolve(e){return H.between(e.resolve(this.anchor),e.resolve(this.head))}}class I extends W{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),s=e.resolve(o);return r?W.near(s):new I(s)}content(){return new O(M.from(this.node),0,0)}eq(e){return e instanceof I&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Si(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new I(e.resolve(t.anchor))}static create(e,t){return new I(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}I.prototype.visible=!1;W.jsonID("node",I);class Si{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Io(r,r):new Si(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&I.isSelectable(r)?new I(t):W.near(t)}}class We extends W{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=O.empty){if(t==O.empty){e.delete(0,e.doc.content.size);let r=W.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new We(e)}map(e){return new We(e)}eq(e){return e instanceof We}getBookmark(){return Bp}}W.jsonID("all",We);const Bp={map(){return this},resolve(n){return new We(n)}};function xn(n,e,t,r,o,s=!1){if(e.inlineContent)return H.create(n,t);for(let i=r-(o>0?0:1);o>0?i<e.childCount:i>=0;i+=o){let a=e.child(i);if(a.isAtom){if(!s&&I.isSelectable(a))return I.create(n,t-(o<0?a.nodeSize:0))}else{let l=xn(n,a,t+o,o<0?a.childCount:0,o,s);if(l)return l}t+=a.nodeSize*o}return null}function za(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof be||o instanceof we))return;let s=n.mapping.maps[r],i;s.forEach((a,l,c,d)=>{i==null&&(i=d)}),n.setSelection(W.near(n.doc.resolve(i),t))}const $a=1,kr=2,Ia=4;class Vp extends vi{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|$a)&~kr,this.storedMarks=null,this}get selectionSet(){return(this.updated&$a)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=kr,this}ensureMarks(e){return ne.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&kr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~kr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ne.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let i=this.doc.resolve(t);s=r==t?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(W.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ia,this}get scrolledIntoView(){return(this.updated&Ia)>0}}function Pa(n,e){return!e||!n?n:n.bind(e)}class Wn{constructor(e,t,r){this.name=e,this.init=Pa(t.init,r),this.apply=Pa(t.apply,r)}}const Fp=[new Wn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Wn("selection",{init(n,e){return n.selection||W.atStart(e.doc)},apply(n){return n.selection}}),new Wn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Wn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class as{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Fp.slice(),t&&t.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 Wn(r.key,r.spec.state,r))})}}class Sn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){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 t=[e],r=this.applyInner(e),o=null;for(;;){let s=!1;for(let i=0;i<this.config.plugins.length;i++){let a=this.config.plugins[i];if(a.spec.appendTransaction){let l=o?o[i].n:0,c=o?o[i].state:this,d=l<t.length&&a.spec.appendTransaction.call(a,l?t.slice(l):t,c,r);if(d&&r.filterTransaction(d,i)){if(d.setMeta("appendedTransaction",e),!o){o=[];for(let u=0;u<this.config.plugins.length;u++)o.push(u<i?{state:r,n:t.length}:{state:this,n:0})}t.push(d),r=r.applyInner(d),s=!0}o&&(o[i]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Sn(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let s=r[o];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Vp(this)}static create(e){let t=new as(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Sn(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new as(this.schema,e.plugins),r=t.fields,o=new Sn(t);for(let s=0;s<r.length;s++){let i=r[s].name;o[i]=this.hasOwnProperty(i)?this[i]:r[s].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.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],s=o.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new as(e.schema,e.plugins),s=new Sn(o);return o.fields.forEach(i=>{if(i.name=="doc")s.doc=Je.fromJSON(e.schema,t.doc);else if(i.name=="selection")s.selection=W.fromJSON(s.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,a)){s[i.name]=c.fromJSON.call(l,e,t[a],s);return}}s[i.name]=i.init(e,s)}}),s}}function id(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=id(o,e,{})),t[r]=o}return t}class le{constructor(e){this.spec=e,this.props={},e.props&&id(e.props,this,this.props),this.key=e.key?e.key.key:ad("plugin")}getState(e){return e[this.key]}}const ls=Object.create(null);function ad(n){return n in ls?n+"$"+ ++ls[n]:(ls[n]=0,n+"$")}class he{constructor(e="key"){this.key=ad(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ci=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function ld(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const cd=(n,e,t)=>{let r=ld(n,t);if(!r)return!1;let o=Mi(r);if(!o){let i=r.blockRange(),a=i&&jn(i);return a==null?!1:(e&&e(n.tr.lift(i,a).scrollIntoView()),!0)}let s=o.nodeBefore;if(bd(n,o,e,-1))return!0;if(r.parent.content.size==0&&(Nn(s,"end")||I.isSelectable(s)))for(let i=r.depth;;i--){let a=$o(n.doc,r.before(i),r.after(i),O.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=n.tr.step(a);l.setSelection(Nn(s,"end")?W.findFrom(l.doc.resolve(l.mapping.map(o.pos,-1)),-1):I.create(l.doc,o.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1},Wp=(n,e,t)=>{let r=ld(n,t);if(!r)return!1;let o=Mi(r);return o?dd(n,o,e):!1},_p=(n,e,t)=>{let r=hd(n,t);if(!r)return!1;let o=Ei(r);return o?dd(n,o,e):!1};function dd(n,e,t){let r=e.nodeBefore,o=r,s=e.pos-1;for(;!o.isTextblock;s--){if(o.type.spec.isolating)return!1;let d=o.lastChild;if(!d)return!1;o=d}let i=e.nodeAfter,a=i,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let d=a.firstChild;if(!d)return!1;a=d}let c=$o(n.doc,s,l,O.empty);if(!c||c.from!=s||c instanceof be&&c.slice.size>=l-s)return!1;if(t){let d=n.tr.step(c);d.setSelection(H.create(d.doc,s)),t(d.scrollIntoView())}return!0}function Nn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const ud=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=Mi(r)}let i=s&&s.nodeBefore;return!i||!I.isSelectable(i)?!1:(e&&e(n.tr.setSelection(I.create(n.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function Mi(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function hd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const pd=(n,e,t)=>{let r=hd(n,t);if(!r)return!1;let o=Ei(r);if(!o)return!1;let s=o.nodeAfter;if(bd(n,o,e,1))return!0;if(r.parent.content.size==0&&(Nn(s,"start")||I.isSelectable(s))){let i=$o(n.doc,r.before(),r.after(),O.empty);if(i&&i.slice.size<i.to-i.from){if(e){let a=n.tr.step(i);a.setSelection(Nn(s,"start")?W.findFrom(a.doc.resolve(a.mapping.map(o.pos)),1):I.create(a.doc,a.mapping.map(o.pos))),e(a.scrollIntoView())}return!0}}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+s.nodeSize).scrollIntoView()),!0):!1},fd=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=Ei(r)}let i=s&&s.nodeAfter;return!i||!I.isSelectable(i)?!1:(e&&e(n.tr.setSelection(I.create(n.doc,s.pos)).scrollIntoView()),!0)};function Ei(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Up=(n,e)=>{let t=n.selection,r=t instanceof I,o;if(r){if(t.node.isTextblock||!Vt(n.doc,t.from))return!1;o=t.from}else if(o=zo(n.doc,t.from,-1),o==null)return!1;if(e){let s=n.tr.join(o);r&&s.setSelection(I.create(s.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},qp=(n,e)=>{let t=n.selection,r;if(t instanceof I){if(t.node.isTextblock||!Vt(n.doc,t.to))return!1;r=t.to}else if(r=zo(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Kp=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),s=o&&jn(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)},md=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
15
+ `).scrollIntoView()),!0)};function Ti(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Jp=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),s=t.indexAfter(-1),i=Ti(o.contentMatchAt(s));if(!i||!o.canReplaceWith(s,s,i))return!1;if(e){let a=t.after(),l=n.tr.replaceWith(a,a,i.createAndFill());l.setSelection(W.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},gd=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof We||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=Ti(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let i=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,a=n.tr.insert(i,s.createAndFill());a.setSelection(H.create(a.doc,i+1)),e(a.scrollIntoView())}return!0},yd=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(yt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),o=r&&jn(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function Gp(n){return(e,t)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof I&&e.selection.node.isBlock)return!r.parentOffset||!yt(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],i,a,l=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){l=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),a=Ti(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),s.unshift(l&&a?{type:a}:null),i=p;break}else{if(p==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof H||e.selection instanceof We)&&d.deleteSelection();let u=d.mapping.map(r.pos),h=yt(d.doc,u,s.length,s);if(h||(s[0]=a?{type:a}:null,h=yt(d.doc,u,s.length,s)),!h)return!1;if(d.split(u,s.length,s),!l&&c&&r.node(i).type!=a){let p=d.mapping.map(r.before(i)),f=d.doc.resolve(p);a&&r.node(i-1).canReplaceWith(f.index(),f.index()+1,a)&&d.setNodeMarkup(d.mapping.map(r.before(i)),a)}return t&&t(d.scrollIntoView()),!0}}const Xp=Gp(),Yp=(n,e)=>{let{$from:t,to:r}=n.selection,o,s=t.sharedDepth(r);return s==0?!1:(o=t.before(s),e&&e(n.tr.setSelection(I.create(n.doc,o))),!0)};function Qp(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,s=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(o.isTextblock||Vt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function bd(n,e,t,r){let o=e.nodeBefore,s=e.nodeAfter,i,a,l=o.type.spec.isolating||s.type.spec.isolating;if(!l&&Qp(n,e,t))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(a=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&a.matchType(i[0]||s.type).validEnd){if(t){let p=e.pos+s.nodeSize,f=M.empty;for(let y=i.length-1;y>=0;y--)f=M.from(i[y].create(null,f));f=M.from(o.copy(f));let m=n.tr.step(new we(e.pos-1,p,e.pos,p,new O(f,1,0),i.length,!0)),g=m.doc.resolve(p+2*i.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Vt(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&l?null:W.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),h=u&&jn(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&Nn(s,"start",!0)&&Nn(o,"end")){let p=o,f=[];for(;f.push(p),!p.isTextblock;)p=p.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,m.content)){if(t){let y=M.empty;for(let x=f.length-1;x>=0;x--)y=M.from(f[x].copy(y));let w=n.tr.step(new we(e.pos-f.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new O(y,f.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function xd(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return o.node(s).isTextblock?(t&&t(e.tr.setSelection(H.create(e.doc,n<0?o.start(s):o.end(s)))),!0):!1}}const Zp=xd(-1),ef=xd(1);function tf(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s),a=i&&ki(i,n,e);return a?(r&&r(t.tr.wrap(i,a).scrollIntoView()),!0):!1}}function Ha(n,e=null){return function(t,r){let o=!1;for(let s=0;s<t.selection.ranges.length&&!o;s++){let{$from:{pos:i},$to:{pos:a}}=t.selection.ranges[s];t.doc.nodesBetween(i,a,(l,c)=>{if(o)return!1;if(!(!l.isTextblock||l.hasMarkup(n,e)))if(l.type==n)o=!0;else{let d=t.doc.resolve(c),u=d.index();o=d.parent.canReplaceWith(u,u+1,n)}})}if(!o)return!1;if(r){let s=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:a},$to:{pos:l}}=t.selection.ranges[i];s.setBlockType(a,l,n,e)}r(s.scrollIntoView())}return!0}}function Ni(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}Ni(Ci,cd,ud);Ni(Ci,pd,fd);Ni(md,gd,yd,Xp);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function nf(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s);if(!i)return!1;let a=r?t.tr:null;return rf(a,i,n,e)?(r&&r(a.scrollIntoView()),!0):!1}}function rf(n,e,t,r=null){let o=!1,s=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=i.resolve(e.start-2);s=new qr(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new qr(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let a=ki(s,t,r,e);return a?(n&&of(n,e,a,o,t),!0):!1}function of(n,e,t,r,o){let s=M.empty;for(let d=t.length-1;d>=0;d--)s=M.from(t[d].type.create(t[d].attrs,s));n.step(new we(e.start-(r?2:0),e.end,e.start,e.end,new O(s,0,0),t.length,!0));let i=0;for(let d=0;d<t.length;d++)t[d].type==o&&(i=d+1);let a=t.length-i,l=e.start+t.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,h=!0;d<u;d++,h=!1)!h&&yt(n.doc,l,a)&&(n.split(l,a),l+=2*a),l+=c.child(d).nodeSize;return n}function sf(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,i=>i.childCount>0&&i.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?af(e,t,n,s):lf(e,t,s):!0:!1}}function af(n,e,t,r){let o=n.tr,s=r.end,i=r.$to.end(r.depth);s<i&&(o.step(new we(s-1,i,s,i,new O(M.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new qr(o.doc.resolve(r.$from.pos),o.doc.resolve(i),r.depth));const a=jn(r);if(a==null)return!1;o.lift(r,a);let l=o.doc.resolve(o.mapping.map(s,-1)-1);return Vt(o.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&o.join(l.pos),e(o.scrollIntoView()),!0}function lf(n,e,t){let r=n.tr,o=t.parent;for(let p=t.end,f=t.endIndex-1,m=t.startIndex;f>m;f--)p-=o.child(f).nodeSize,r.delete(p-1,p+1);let s=r.doc.resolve(t.start),i=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let a=t.startIndex==0,l=t.endIndex==o.childCount,c=s.node(-1),d=s.index(-1);if(!c.canReplace(d+(a?0:1),d+1,i.content.append(l?M.empty:M.from(o))))return!1;let u=s.pos,h=u+i.nodeSize;return r.step(new we(u-(a?1:0),h+(l?1:0),u+1,h-1,new O((a?M.empty:M.from(o.copy(M.empty))).append(l?M.empty:M.from(o.copy(M.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function cf(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let a=s.parent,l=a.child(i-1);if(l.type!=n)return!1;if(t){let c=l.lastChild&&l.lastChild.type==a.type,d=M.from(c?n.create():null),u=new O(M.from(n.create(null,M.from(a.type.create(null,d)))),c?3:1,0),h=s.start,p=s.end;t(e.tr.step(new we(h-(c?3:1),p,h,p,u,1,!0)).scrollIntoView())}return!0}}const Ee=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},An=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Vs=null;const mt=function(n,e,t){let r=Vs||(Vs=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},df=function(){Vs=null},rn=function(n,e,t,r){return t&&(Ba(n,e,t,r,-1)||Ba(n,e,t,r,1))},uf=/^(img|br|input|textarea|hr)$/i;function Ba(n,e,t,r,o){for(var s;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Ke(n))){let i=n.parentNode;if(!i||i.nodeType!=1||pr(n)||uf.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ee(n)+(o<0?0:1),n=i}else if(n.nodeType==1){let i=n.childNodes[e+(o<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((s=i.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=o;else return!1;else n=i,e=o<0?Ke(n):0}else return!1}}function Ke(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function hf(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Ke(n)}else if(n.parentNode&&!pr(n))e=Ee(n),n=n.parentNode;else return null}}function pf(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!pr(n))e=Ee(n)+1,n=n.parentNode;else return null}}function ff(n,e,t){for(let r=e==0,o=e==Ke(n);r||o;){if(n==t)return!0;let s=Ee(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Ke(n)}}function pr(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Po=function(n){return n.focusNode&&rn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Ut(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function mf(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function gf(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Ke(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Ke(r.startContainer),r.startOffset)}}}const it=typeof navigator<"u"?navigator:null,Va=typeof document<"u"?document:null,Ft=it&&it.userAgent||"",Fs=/Edge\/(\d+)/.exec(Ft),wd=/MSIE \d/.exec(Ft),Ws=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ft),He=!!(wd||Ws||Fs),Lt=wd?document.documentMode:Ws?+Ws[1]:Fs?+Fs[1]:0,Ge=!He&&/gecko\/(\d+)/i.test(Ft);Ge&&+(/Firefox\/(\d+)/.exec(Ft)||[0,0])[1];const _s=!He&&/Chrome\/(\d+)/.exec(Ft),Oe=!!_s,kd=_s?+_s[1]:0,Le=!He&&!!it&&/Apple Computer/.test(it.vendor),On=Le&&(/Mobile\/\w+/.test(Ft)||!!it&&it.maxTouchPoints>2),qe=On||(it?/Mac/.test(it.platform):!1),yf=it?/Win/.test(it.platform):!1,gt=/Android \d/.test(Ft),fr=!!Va&&"webkitFontSmoothing"in Va.documentElement.style,bf=fr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function xf(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function ct(n,e){return typeof n=="number"?n:n[e]}function wf(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Fa(n,e,t){let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let i=t||n.dom;i;){if(i.nodeType!=1){i=An(i);continue}let a=i,l=a==s.body,c=l?xf(s):wf(a),d=0,u=0;if(e.top<c.top+ct(r,"top")?u=-(c.top-e.top+ct(o,"top")):e.bottom>c.bottom-ct(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+ct(o,"top")-c.top:e.bottom-c.bottom+ct(o,"bottom")),e.left<c.left+ct(r,"left")?d=-(c.left-e.left+ct(o,"left")):e.right>c.right-ct(r,"right")&&(d=e.right-c.right+ct(o,"right")),d||u)if(l)s.defaultView.scrollBy(d,u);else{let p=a.scrollLeft,f=a.scrollTop;u&&(a.scrollTop+=u),d&&(a.scrollLeft+=d);let m=a.scrollLeft-p,g=a.scrollTop-f;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let h=l?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(h))break;i=h=="absolute"?i.offsetParent:An(i)}}function kf(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let s=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let a=n.root.elementFromPoint(s,i);if(!a||a==n.dom||!n.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=t-20){r=a,o=l.top;break}}return{refDOM:r,refTop:o,stack:vd(n.dom)}}function vd(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=An(r));return e}function vf({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Sd(t,r==0?0:r-e)}function Sd(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:s}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let gn=null;function Sf(n){if(n.setActive)return n.setActive();if(gn)return n.focus(gn);let e=vd(n);n.focus(gn==null?{get preventScroll(){return gn={preventScroll:!0},!0}}:void 0),gn||(gn=!1,Sd(e,0))}function Cd(n,e){let t,r=2e8,o,s=0,i=e.top,a=e.top,l,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let h;if(d.nodeType==1)h=d.getClientRects();else if(d.nodeType==3)h=mt(d).getClientRects();else continue;for(let p=0;p<h.length;p++){let f=h[p];if(f.top<=i&&f.bottom>=a){i=Math.max(f.bottom,i),a=Math.min(f.top,a);let m=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(m<r){t=d,r=m,o=m&&t.nodeType==3?{left:f.right<e.left?f.right:f.left,top:e.top}:e,d.nodeType==1&&m&&(s=u+(e.left>=(f.left+f.right)/2?1:0));continue}}else f.top>e.top&&!l&&f.left<=e.left&&f.right>=e.left&&(l=d,c={left:Math.max(f.left,Math.min(f.right,e.left)),top:f.top});!t&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(s=u+1)}}return!t&&l&&(t=l,o=c,r=0),t&&t.nodeType==3?Cf(t,o):!t||r&&t.nodeType==1?{node:n,offset:s}:Cd(t,o)}function Cf(n,e){let t=n.nodeValue.length,r=document.createRange();for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=St(r,1);if(s.top!=s.bottom&&Ai(e,s))return{node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function Ai(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Mf(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Ef(n,e,t){let{node:r,offset:o}=Cd(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();s=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(r,o,s)}function Tf(n,e,t,r){let o=-1;for(let s=e,i=!1;s!=n.dom;){let a=n.docView.nearestDesc(s,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!i&&l.left>r.left||l.top>r.top?o=a.posBefore:(!i&&l.right<r.left||l.bottom<r.top)&&(o=a.posAfter),i=!0),!a.contentDOM&&o<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;s=a.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function Md(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=o;;){let i=n.childNodes[s];if(i.nodeType==1){let a=i.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(Ai(e,c))return Md(i,e,c)}}if((s=(s+1)%r)==o)break}return n}function Nf(n,e){let t=n.dom.ownerDocument,r,o=0,s=gf(t,e.left,e.top);s&&({node:r,offset:o}=s);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),a;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!Ai(e,c)||(i=Md(n.dom,e,c),!i))return null}if(Le)for(let c=i;r&&c;c=An(c))c.draggable&&(r=void 0);if(i=Mf(i,e),r){if(Ge&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let d=r.childNodes[o],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&o++}let c;fr&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=n.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(a=Tf(n,r,o,e))}a==null&&(a=Ef(n,i,e));let l=n.docView.nearestDesc(i,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Wa(n){return n.top<n.bottom||n.left<n.right}function St(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Wa(r))return r}return Array.prototype.find.call(t,Wa)||n.getBoundingClientRect()}const Af=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ed(n,e,t){let{node:r,offset:o,atom:s}=n.docView.domFromPos(e,t<0?-1:1),i=fr||Ge;if(r.nodeType==3)if(i&&(Af.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=St(mt(r,o,o),t);if(Ge&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let l=St(mt(r,o-1,o-1),-1);if(l.top==a.top){let c=St(mt(r,o,o+1),-1);if(c.top!=a.top)return Pn(c,c.left<l.left)}}return a}else{let a=o,l=o,c=t<0?1:-1;return t<0&&!o?(l++,c=-1):t>=0&&o==r.nodeValue.length?(a--,c=1):t<0?a--:l++,Pn(St(mt(r,a,l),c),c<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&o&&(t<0||o==Ke(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return cs(a.getBoundingClientRect(),!1)}if(s==null&&o<Ke(r)){let a=r.childNodes[o];if(a.nodeType==1)return cs(a.getBoundingClientRect(),!0)}return cs(r.getBoundingClientRect(),t>=0)}if(s==null&&o&&(t<0||o==Ke(r))){let a=r.childNodes[o-1],l=a.nodeType==3?mt(a,Ke(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(l)return Pn(St(l,1),!1)}if(s==null&&o<Ke(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let l=a?a.nodeType==3?mt(a,0,i?0:1):a.nodeType==1?a:null:null;if(l)return Pn(St(l,-1),!0)}return Pn(St(r.nodeType==3?mt(r):r,-t),t>=0)}function Pn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function cs(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Td(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function Of(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return Td(n,e,()=>{let{node:s}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let a=n.docView.nearestDesc(s,!0);if(!a)break;if(a.node.isBlock){s=a.contentDOM||a.dom;break}s=a.dom.parentNode}let i=Ed(n,o.pos,1);for(let a=s.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=mt(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let d=l[c];if(d.bottom>d.top+1&&(t=="up"?i.top-d.top>(d.bottom-i.top)*2:d.bottom-i.bottom>(i.bottom-d.top)*2))return!1}}return!0})}const Rf=/[\u0590-\u08ac]/;function Df(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,s=!o,i=o==r.parent.content.size,a=n.domSelection();return a?!Rf.test(r.parent.textContent)||!a.modify?t=="left"||t=="backward"?s:i:Td(n,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),h=a.caretBidiLevel;a.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:f,focusOffset:m}=n.domSelectionRange(),g=f&&!p.contains(f.nodeType==1?f:f.parentNode)||l==f&&c==m;try{a.collapse(d,u),l&&(l!=d||c!=u)&&a.extend&&a.extend(l,c)}catch{}return h!=null&&(a.caretBidiLevel=h),g}):r.pos==r.start()||r.pos==r.end()}let _a=null,Ua=null,qa=!1;function jf(n,e,t){return _a==e&&Ua==t?qa:(_a=e,Ua=t,qa=t=="up"||t=="down"?Of(n,e,t):Df(n,e,t))}const Xe=0,Ka=1,qt=2,at=3;class mr{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.dirty=Xe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let o=this.children[t];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,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>Ee(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(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let s=this.getDesc(o),i;if(s&&(!t||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)for(let i=0;i<o.children.length;i++){let a=o.children[i];if(a.size){o=a;break}}return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){let i=this.children[r],a=s+i.size;if(a>e||i instanceof Ad){o=e-s;break}s=a}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Nd&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Ee(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Ee(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,a=0;;a++){let l=this.children[a],c=i+l.size;if(o==-1&&e<=c){let d=i+l.border;if(e>=d&&t<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,d);e=i;for(let u=a;u>0;u--){let h=this.children[u-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){o=Ee(h.dom)+1;break}e-=h.size}o==-1&&(o=0)}if(o>-1&&(c>t||a==this.children.length-1)){t=c;for(let d=a+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){s=Ee(u.dom);break}t+=u.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,o=!1){let s=Math.min(e,t),i=Math.max(e,t);for(let p=0,f=0;p<this.children.length;p++){let m=this.children[p],g=f+m.size;if(s>f&&i<g)return m.setSelection(e-f-m.border,t-f-m.border,r,o);f=g}let a=this.domFromPos(e,e?-1:1),l=t==e?a:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((Ge||Le)&&e==t){let{node:p,offset:f}=a;if(p.nodeType==3){if(u=!!(f&&p.nodeValue[f-1]==`
16
+ `),u&&f==p.nodeValue.length)for(let m=p,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(a=l={node:g.parentNode,offset:Ee(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=p.childNodes[f-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Ge&&d.focusNode&&d.focusNode!=l.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(o=!0)}if(!(o||u&&Le)&&rn(a.node,a.offset,d.anchorNode,d.anchorOffset)&&rn(l.node,l.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==t)&&!(u&&Ge)){c.collapse(a.node,a.offset);try{e!=t&&c.extend(l.node,l.offset),h=!0}catch{}}if(!h){if(e>t){let f=a;a=l,l=f}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){let s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let a=r+s.border,l=i-s.border;if(e>=a&&t<=l){this.dirty=e==r||t==i?qt:Ka,e==a&&t==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=at:s.markDirty(e-a,t-a);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?qt:at}r=i}this.dirty=qt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?qt:Ka;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Nd extends mr{constructor(e,t,r,o){let s,i=t.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!s)return o;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(i.nodeType!=1){let a=document.createElement("span");a.appendChild(i),i=a}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Xe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Lf extends mr{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class on extends mr{constructor(e,t,r,o,s){super(e,[],r,o),this.mark=t,this.spec=s}static create(e,t,r,o){let s=o.nodeViews[t.type.name],i=s&&s(t,o,r);return(!i||!i.dom)&&(i=Bt.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new on(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&at||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=at&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Xe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Xe}}slice(e,t,r){let o=on.create(this.parent,this.mark,!0,r),s=this.children,i=this.size;t<i&&(s=qs(s,t,i,r)),e>0&&(s=qs(s,0,e,r));for(let a=0;a<s.length;a++)s[a].parent=o;return o.children=s,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class zt extends mr{constructor(e,t,r,o,s,i,a,l,c){super(e,[],s,i),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=a}static create(e,t,r,o,s,i){let a=s.nodeViews[t.type.name],l,c=a&&a(t,s,()=>{if(!l)return i;if(l.parent)return l.parent.posBeforeChild(l)},r,o),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Bt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let h=d;return d=Dd(d,r,t),c?l=new zf(e,t,r,o,d,u||null,h,c,s,i+1):t.isText?new Ho(e,t,r,o,d,h,s):new zt(e,t,r,o,d,u||null,h,s,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>M.empty)}return e}matchesNode(e,t,r){return this.dirty==Xe&&e.eq(this.node)&&Jr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,s=e.composing?this.localCompositionInfo(e,t):null,i=s&&s.pos>-1?s:null,a=s&&s.pos<0,l=new If(this,i&&i.node,e);Bf(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&l.syncToMarks(d==this.node.childCount?ne.none:this.node.child(d).marks,r,e),l.placeWidget(c,e,o)},(c,d,u,h)=>{l.syncToMarks(c.marks,r,e);let p;l.findNodeMatch(c,d,u,h)||a&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(p=l.findIndexWithChild(s.node))>-1&&l.updateNodeAt(c,d,u,p,e)||l.updateNextNode(c,d,u,e,h,o)||l.addNode(c,d,u,e,o),o+=c.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==qt)&&(i&&this.protectLocalComposition(e,i),Od(this.contentDOM,this.children,e),On&&Vf(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof H)||r<t||o>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let i=s.nodeValue,a=Ff(this.node.content,i,r-t,o-t);return a<0?null:{node:s,pos:a,text:i}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let i=new Lf(this,s,t,o);e.input.compositionNodes.push(i),this.children=qs(this.children,r,r+o.length,e,i)}update(e,t,r,o){return this.dirty==at||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o),!0)}updateInner(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Xe}updateOuterDeco(e){if(Jr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Rd(this.dom,this.nodeDOM,Us(this.outerDeco,this.node,t),Us(e,this.node,t)),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 Ja(n,e,t,r,o){Dd(r,e,n);let s=new zt(void 0,n,e,t,r,r,r,o,0);return s.contentDOM&&s.updateChildren(o,0),s}class Ho extends zt{constructor(e,t,r,o,s,i,a){super(e,t,r,o,s,null,i,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.dirty==at||this.dirty!=Xe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Xe||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=Xe,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let o=this.node.cut(e,t),s=document.createTextNode(o.text);return new Ho(this.parent,o,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=at)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Ad extends mr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Xe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class zf extends zt{constructor(e,t,r,o,s,i,a,l,c,d){super(e,t,r,o,s,i,a,c,d),this.spec=l}update(e,t,r,o){if(this.dirty==at)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,o){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,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 Od(n,e,t){let r=n.firstChild,o=!1;for(let s=0;s<e.length;s++){let i=e[s],a=i.dom;if(a.parentNode==n){for(;a!=r;)r=Ga(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(a,r);if(i instanceof on){let l=r?r.previousSibling:n.lastChild;Od(i.contentDOM,i.children,t),r=l?l.nextSibling:n.firstChild}}for(;r;)r=Ga(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const Kn=function(n){n&&(this.nodeName=n)};Kn.prototype=Object.create(null);const Kt=[new Kn];function Us(n,e,t){if(n.length==0)return Kt;let r=t?Kt[0]:new Kn,o=[r];for(let s=0;s<n.length;s++){let i=n[s].type.attrs;if(i){i.nodeName&&o.push(r=new Kn(i.nodeName));for(let a in i){let l=i[a];l!=null&&(t&&o.length==1&&o.push(r=new Kn(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return o}function Rd(n,e,t,r){if(t==Kt&&r==Kt)return e;let o=e;for(let s=0;s<r.length;s++){let i=r[s],a=t[s];if(s){let l;a&&a.nodeName==i.nodeName&&o!=n&&(l=o.parentNode)&&l.nodeName.toLowerCase()==i.nodeName||(l=document.createElement(i.nodeName),l.pmIsDeco=!0,l.appendChild(o),a=Kt[0]),o=l}$f(o,a||Kt[0],i)}return o}function $f(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)o.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<o.length;s++)r.indexOf(o[s])==-1&&n.classList.add(o[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Dd(n,e,t){return Rd(n,n,Kt,Us(e,t,n.nodeType!=1))}function Jr(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Ga(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class If{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Pf(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let o=0,s=this.stack.length>>1,i=Math.min(s,e.length);for(;o<i&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Xe,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1;for(let l=this.index;l<Math.min(this.index+3,this.top.children.length);l++){let c=this.top.children[l];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){a=l;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=on.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let s=-1,i;if(o>=this.preMatch.index&&(i=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,r))s=this.top.children.indexOf(i,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){s=a;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,o,s){let i=this.top.children[o];return i.dirty==at&&i.dom==i.contentDOM&&(i.dirty=qt),i.update(e,t,r,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==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=t}}updateNextNode(e,t,r,o,s,i){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof zt){let c=this.preMatch.matched.get(l);if(c!=null&&c!=s)return!1;let d=l.dom,u,h=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=at&&Jr(t,l.outerDeco));if(!h&&l.update(e,t,r,o))return this.destroyBetween(this.index,a),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(u=this.recreateWrapper(l,e,t,r,o,i)))return this.destroyBetween(this.index,a),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=qt,u.updateChildren(o,i+1),u.dirty=Xe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,s,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Jr(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let a=zt.create(this.top,t,r,o,s,i);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,t,r,o,s){let i=zt.create(this.top,e,t,r,o,s);i.contentDOM&&i.updateChildren(o,s+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,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 s=new Nd(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof on;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ho)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Le||Oe)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new Ad(this.top,[],r,null);t!=this.top?t.children.push(o):t.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 Pf(n,e){let t=e,r=t.children.length,o=n.childCount,s=new Map,i=[];e:for(;o>0;){let a;for(;;)if(r){let c=t.children[r-1];if(c instanceof on)t=c,r=c.children.length;else{a=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let l=a.node;if(l){if(l!=n.child(o-1))break;--o,s.set(a,o),i.push(a)}}return{index:o,matched:s,matches:i.reverse()}}function Hf(n,e){return n.type.side-e.type.side}function Bf(n,e,t,r){let o=e.locals(n),s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,o,e.forChild(s,d),c),s+=d.nodeSize}return}let i=0,a=[],l=null;for(let c=0;;){let d,u;for(;i<o.length&&o[i].to==s;){let g=o[i++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(Hf);for(let g=0;g<u.length;g++)t(u[g],c,!!l)}else t(d,c,!!l);let h,p;if(l)p=-1,h=l,l=null;else if(c<n.childCount)p=c,h=n.child(c++);else break;for(let g=0;g<a.length;g++)a[g].to<=s&&a.splice(g--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)a.push(o[i++]);let f=s+h.nodeSize;if(h.isText){let g=f;i<o.length&&o[i].from<g&&(g=o[i].from);for(let y=0;y<a.length;y++)a[y].to<g&&(g=a[y].to);g<f&&(l=h.cut(g-s),h=h.cut(0,g-s),f=g,p=-1)}else for(;i<o.length&&o[i].to<f;)i++;let m=h.isInline&&!h.isLeaf?a.filter(g=>!g.inline):a.slice();r(h,m,e.forChild(s,h),p),s=f}}function Vf(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Ff(n,e,t,r){for(let o=0,s=0;o<n.childCount&&s<=r;){let i=n.child(o++),a=s;if(s+=i.nodeSize,!i.isText)continue;let l=i.text;for(;o<n.childCount;){let c=n.child(o++);if(s+=c.nodeSize,!c.isText)break;l+=c.text}if(s>=t){if(s>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=t)return a+c;if(t==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function qs(n,e,t,r,o){let s=[];for(let i=0,a=0;i<n.length;i++){let l=n[i],c=a,d=a+=l.size;c>=t||d<=e?s.push(l):(c<e&&s.push(l.slice(0,e-c,r)),o&&(s.push(o),o=void 0),d>t&&s.push(l.slice(t-c,l.size,r)))}return s}function Oi(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let a=r.resolve(i),l,c;if(Po(t)){for(l=i;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&I.isSelectable(u)&&o.parent&&!(u.isInline&&ff(t.focusNode,t.focusOffset,o.dom))){let h=o.posBefore;c=new I(i==h?a:r.resolve(h))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=i,h=i;for(let p=0;p<t.rangeCount;p++){let f=t.getRangeAt(p);u=Math.min(u,n.docView.posFromDOM(f.startContainer,f.startOffset,1)),h=Math.max(h,n.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(u<0)return null;[l,i]=h==n.state.selection.anchor?[h,u]:[u,h],a=r.resolve(i)}else l=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!c){let u=e=="pointer"||n.state.selection.head<a.pos&&!s?1:-1;c=Ri(n,d,a,u)}return c}function jd(n){return n.editable?n.hasFocus():zd(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function bt(n,e=!1){let t=n.state.selection;if(Ld(n,t),!!jd(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Oe){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&rn(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)_f(n);else{let{anchor:r,head:o}=t,s,i;Xa&&!(t instanceof H)&&(t.$from.parent.inlineContent||(s=Ya(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Ya(n,t.to))),n.docView.setSelection(r,o,n,e),Xa&&(s&&Qa(s),i&&Qa(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Wf(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Xa=Le||Oe&&kd<63;function Ya(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(Le&&o&&o.contentEditable=="false")return ds(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return ds(o);if(s)return ds(s)}}function ds(n){return n.contentEditable="true",Le&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Qa(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Wf(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!jd(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function _f(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,Ee(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&He&&Lt<=11&&(t.disabled=!0,t.disabled=!1)}function Ld(n,e){if(e instanceof I){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Za(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Za(n)}function Za(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Ri(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||H.between(e,t,r)}function el(n){return n.editable&&!n.hasFocus()?!1:zd(n)}function zd(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Uf(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return rn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ks(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&W.findFrom(s,e)}function Ct(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function tl(n,e,t){let r=n.state.selection;if(r instanceof H)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return Ct(n,new H(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Ks(n.state,e);return o&&o instanceof I?Ct(n,o):!1}else if(!(qe&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let a=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(a))&&!i.contentDOM?I.isSelectable(s)?Ct(n,new I(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):fr?Ct(n,new H(n.state.doc.resolve(e<0?a:a+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof I&&r.node.isInline)return Ct(n,new H(e>0?r.$to:r.$from));{let o=Ks(n.state,e);return o?Ct(n,o):!1}}}function Gr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Jn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function yn(n,e){return e<0?qf(n):Kf(n)}function qf(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Ge&&t.nodeType==1&&r<Gr(t)&&Jn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let a=t.childNodes[r-1];if(Jn(a,-1))o=t,s=--r;else if(a.nodeType==3)t=a,r=t.nodeValue.length;else break}}else{if($d(t))break;{let a=t.previousSibling;for(;a&&Jn(a,-1);)o=t.parentNode,s=Ee(a),a=a.previousSibling;if(a)t=a,r=Gr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Js(n,t,r):o&&Js(n,o,s)}function Kf(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Gr(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let a=t.childNodes[r];if(Jn(a,1))s=t,i=++r;else break}else{if($d(t))break;{let a=t.nextSibling;for(;a&&Jn(a,1);)s=a.parentNode,i=Ee(a)+1,a=a.nextSibling;if(a)t=a,r=0,o=Gr(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&Js(n,s,i)}function $d(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Jf(n,e){for(;n&&e==n.childNodes.length&&!pr(n);)e=Ee(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Gf(n,e){for(;n&&!e&&!pr(n);)e=Ee(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Js(n,e,t){if(e.nodeType!=3){let s,i;(i=Jf(e,t))?(e=i,t=0):(s=Gf(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Po(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&bt(n)},50)}function nl(n,e){let t=n.state.doc.resolve(e);if(!(Oe||yf)&&t.parent.inlineContent){let r=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(o.left-r.left)>1)return o.left<r.left?"ltr":"rtl"}if(e<t.end()){let o=n.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(o.left-r.left)>1)return o.left>r.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function rl(n,e,t){let r=n.state.selection;if(r instanceof H&&!r.empty||t.indexOf("s")>-1||qe&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Ks(n.state,e);if(i&&i instanceof I)return Ct(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,a=r instanceof We?W.near(i,e):W.findFrom(i,e);return a?Ct(n,a):!1}return!1}function ol(n,e){if(!(n.state.selection instanceof H))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function sl(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Xf(n){if(!Le||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;sl(n,r,"true"),setTimeout(()=>sl(n,r,"false"),20)}return!1}function Yf(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Qf(n,e){let t=e.keyCode,r=Yf(e);if(t==8||qe&&t==72&&r=="c")return ol(n,-1)||yn(n,-1);if(t==46&&!e.shiftKey||qe&&t==68&&r=="c")return ol(n,1)||yn(n,1);if(t==13||t==27)return!0;if(t==37||qe&&t==66&&r=="c"){let o=t==37?nl(n,n.state.selection.from)=="ltr"?-1:1:-1;return tl(n,o,r)||yn(n,o)}else if(t==39||qe&&t==70&&r=="c"){let o=t==39?nl(n,n.state.selection.from)=="ltr"?1:-1:1;return tl(n,o,r)||yn(n,o)}else{if(t==38||qe&&t==80&&r=="c")return rl(n,-1,r)||yn(n,-1);if(t==40||qe&&t==78&&r=="c")return Xf(n)||rl(n,1,r)||yn(n,1);if(r==(qe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Di(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let i=n.someProp("clipboardSerializer")||Bt.fromSchema(n.state.schema),a=Fd(),l=a.createElement("div");l.appendChild(i.serializeFragment(r,{document:a}));let c=l.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Vd[c.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let f=a.createElement(d[p]);for(;l.firstChild;)f.appendChild(l.firstChild);l.appendChild(f),u++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${u?` -${u}`:""} ${JSON.stringify(t)}`);let h=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
17
+
18
+ `);return{dom:l,text:h,slice:e}}function Id(n,e,t,r,o){let s=o.parent.type.spec.code,i,a;if(!t&&!e)return null;let l=!!e&&(r||s||!t);if(l){if(n.someProp("transformPastedText",h=>{e=h(e,s||r,n)}),s)return a=new O(M.from(n.state.schema.text(e.replace(/\r\n?/g,`
19
+ `))),0,0),n.someProp("transformPasted",h=>{a=h(a,n,!0)}),a;let u=n.someProp("clipboardTextParser",h=>h(e,o,r,n));if(u)a=u;else{let h=o.marks(),{schema:p}=n.state,f=Bt.fromSchema(p);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=i.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(p.text(m,h)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),i=nm(t),fr&&rm(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let h=i.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;i=h}if(a||(a=(n.someProp("clipboardParser")||n.someProp("domParser")||jt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(l||d),context:o,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!Zf.test(u.parentNode.nodeName)?{ignore:!0}:null}})),d)a=om(il(a,+d[1],+d[2]),d[4]);else if(a=O.maxOpen(em(a.content,o),!0),a.openStart||a.openEnd){let u=0,h=0;for(let p=a.content.firstChild;u<a.openStart&&!p.type.spec.isolating;u++,p=p.firstChild);for(let p=a.content.lastChild;h<a.openEnd&&!p.type.spec.isolating;h++,p=p.lastChild);a=il(a,u,h)}return n.someProp("transformPasted",u=>{a=u(a,n,l)}),a}const Zf=/^(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 em(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(n.forEach(i=>{if(!s)return;let a=r.findWrapping(i.type),l;if(!a)return s=null;if(l=s.length&&o.length&&Hd(a,o,i,s[s.length-1],0))s[s.length-1]=l;else{s.length&&(s[s.length-1]=Bd(s[s.length-1],o.length));let c=Pd(i,a);s.push(c),r=r.matchType(c.type),o=a}}),s)return M.from(s)}return n}function Pd(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,M.from(n));return n}function Hd(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=Hd(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(M.from(Pd(t,n,o+1))))}}function Bd(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Bd(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(M.empty,!0);return n.copy(t.append(r))}function Gs(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,a=i.content;return n.childCount>1&&(s=0),o<r-1&&(a=Gs(a,e,t,r,o+1,s)),o>=t&&(a=e<0?i.contentMatchAt(0).fillBefore(a,s<=o).append(a):a.append(i.contentMatchAt(i.childCount).fillBefore(M.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(a))}function il(n,e,t){return e<n.openStart&&(n=new O(Gs(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new O(Gs(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Vd={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 al=null;function Fd(){return al||(al=document.implementation.createHTMLDocument("title"))}let us=null;function tm(n){let e=window.trustedTypes;return e?(us||(us=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),us.createHTML(n)):n}function nm(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Fd().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&Vd[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=tm(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function rm(n){let e=n.querySelectorAll(Oe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function om(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let a=r.length-2;a>=0;a-=2){let l=t.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;o=M.from(l.create(r[a+1],o)),s++,i++}return new O(o,s,i)}const ze={},$e={},sm={touchstart:!0,touchmove:!0};class im{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 am(n){for(let e in ze){let t=ze[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{cm(n,r)&&!ji(n,r)&&(n.editable||!(r.type in $e))&&t(n,r)},sm[e]?{passive:!0}:void 0)}Le&&n.dom.addEventListener("input",()=>null),Xs(n)}function Dt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function lm(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Xs(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>ji(n,r))})}function ji(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function cm(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function dm(n,e){!ji(n,e)&&ze[e.type]&&(n.editable||!(e.type in $e))&&ze[e.type](n,e)}$e.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!_d(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(gt&&Oe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),On&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Ut(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Qf(n,t)?t.preventDefault():Dt(n,"key")};$e.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};$e.keypress=(n,e)=>{let t=e;if(_d(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||qe&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof H)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,o,s))&&n.dispatch(s()),t.preventDefault()}};function Bo(n){return{left:n.clientX,top:n.clientY}}function um(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Li(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,a=>i>s.depth?a(n,t,s.nodeAfter,s.before(i),o,!0):a(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function En(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function hm(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&I.isSelectable(r)?(En(n,new I(t)),!0):!1}function pm(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof I&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let a=i>s.depth?s.nodeAfter:s.node(i);if(I.isSelectable(a)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(En(n,I.create(n.state.doc,o)),!0):!1}function fm(n,e,t,r,o){return Li(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?pm(n,t):hm(n,t))}function mm(n,e,t,r){return Li(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function gm(n,e,t,r){return Li(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||ym(n,t,r)}function ym(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(En(n,H.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),a=o.before(s);if(i.inlineContent)En(n,H.create(r,a+1,a+1+i.content.size));else if(I.isSelectable(i))En(n,I.create(r,a));else continue;return!0}}function zi(n){return Xr(n)}const Wd=qe?"metaKey":"ctrlKey";ze.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=zi(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&um(t,n.input.lastClick)&&!t[Wd]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s,button:t.button};let i=n.posAtCoords(Bo(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new bm(n,i,t,!!r)):(s=="doubleClick"?mm:gm)(n,i.pos,i.inside,t)?t.preventDefault():Dt(n,"pointer"))};class bm{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Wd],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let d=e.state.doc.resolve(t.pos);s=d.parent,i=d.depth?d.before():0}const a=o?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof I&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ge&&!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)),Dt(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(()=>bt(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Bo(e))),this.updateAllowDefault(e),this.allowDefault||!t?Dt(this.view,"pointer"):fm(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Le&&this.mightDrag&&!this.mightDrag.node.isAtom||Oe&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(En(this.view,W.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Dt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Dt(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)}}ze.touchstart=n=>{n.input.lastTouch=Date.now(),zi(n),Dt(n,"pointer")};ze.touchmove=n=>{n.input.lastTouch=Date.now(),Dt(n,"pointer")};ze.contextmenu=n=>zi(n);function _d(n,e){return n.composing?!0:Le&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const xm=gt?5e3:-1;$e.compositionstart=$e.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof H&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Xr(n,!0),n.markCursor=null;else if(Xr(n,!e.selection.empty),Ge&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let a=n.domSelection();a&&a.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}Ud(n,xm)};$e.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Ud(n,20))};function Ud(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Xr(n),e))}function qd(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=km());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function wm(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=hf(e.focusNode,e.focusOffset),r=pf(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t||r}function km(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Xr(n,e=!1){if(!(gt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),qd(n),e||n.docView&&n.docView.dirty){let t=Oi(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function vm(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const sr=He&&Lt<15||On&&bf<604;ze.copy=$e.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=sr?null:t.clipboardData,i=r.content(),{dom:a,text:l}=Di(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):vm(n,a),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Sm(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Cm(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?ir(n,r.value,null,o,e):ir(n,r.textContent,r.innerHTML,o,e)},50)}function ir(n,e,t,r,o){let s=Id(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",l=>l(n,o,s||O.empty)))return!0;if(!s)return!1;let i=Sm(s),a=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Kd(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}$e.paste=(n,e)=>{let t=e;if(n.composing&&!gt)return;let r=sr?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&ir(n,Kd(r),r.getData("text/html"),o,t)?t.preventDefault():Cm(n,t)};class Jd{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Mm=qe?"altKey":"ctrlKey";function Gd(n,e){return n.someProp("dragCopies",r=>!r(e))??!e[Mm]}ze.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Bo(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof I?o.to-1:o.to))){if(r&&r.mightDrag)i=I.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(i=I.create(n.state.doc,u.posBefore))}}let a=(i||n.state.selection).content(),{dom:l,text:c,slice:d}=Di(n,a);(!t.dataTransfer.files.length||!Oe||kd>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(sr?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",sr||t.dataTransfer.setData("text/plain",c),n.dragging=new Jd(d,Gd(n,t),i)};ze.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};$e.dragover=$e.dragenter=(n,e)=>e.preventDefault();$e.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Bo(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",f=>{i=f(i,n,!1)}):i=Id(n,Kd(t.dataTransfer),sr?null:t.dataTransfer.getData("text/html"),!1,s);let a=!!(r&&Gd(n,t));if(n.someProp("handleDrop",f=>f(n,t,i||O.empty,a))){t.preventDefault();return}if(!i)return;t.preventDefault();let l=i?ed(n.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let c=n.state.tr;if(a){let{node:f}=r;f?f.replace(c):c.deleteSelection()}let d=c.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(h))return;let p=c.doc.resolve(d);if(u&&I.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new I(p));else{let f=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,w)=>f=w),c.setSelection(Ri(n,p,c.doc.resolve(f)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};ze.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&bt(n)},20))};ze.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};ze.beforeinput=(n,e)=>{if(Oe&&gt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:t}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=t||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,Ut(8,"Backspace")))))return;let{$cursor:r}=n.state.selection;r&&r.pos>0&&n.dispatch(n.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let n in $e)ze[n]=$e[n];function ar(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Yr{constructor(e,t){this.toDOM=e,this.spec=t||Qt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new xe(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Yr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ar(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class $t{constructor(e,t){this.attrs=e,this.spec=t||Qt}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new xe(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof $t&&ar(this.attrs,e.attrs)&&ar(this.spec,e.spec)}static is(e){return e.type instanceof $t}destroy(){}}class $i{constructor(e,t){this.attrs=e,this.spec=t||Qt}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new xe(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof $i&&ar(this.attrs,e.attrs)&&ar(this.spec,e.spec)}destroy(){}}class xe{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new xe(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new xe(e,e,new Yr(t,r))}static inline(e,t,r,o){return new xe(e,t,new $t(r,o))}static node(e,t,r,o){return new xe(e,t,new $i(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof $t}get widget(){return this.type instanceof Yr}}const wn=[],Qt={};class se{constructor(e,t){this.local=e.length?e:wn,this.children=t.length?t:wn}static create(e,t){return t.length?Qr(t,e,0,Qt):Ae}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let a=this.local[i];a.from<=t&&a.to>=e&&(!s||s(a.spec))&&r.push(a.copy(a.from+o,a.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let a=this.children[i]+1;this.children[i+2].findInner(e-a,t-a,r,o+a,s)}}map(e,t,r){return this==Ae||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Qt)}mapInner(e,t,r,o,s){let i;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,o);l&&l.type.valid(t,l)?(i||(i=[])).push(l):s.onRemove&&s.onRemove(this.local[a].spec)}return this.children.length?Em(this.children,i||[],e,t,r,o,s):i?new se(i.sort(Zt),wn):Ae}add(e,t){return t.length?this==Ae?se.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((a,l)=>{let c=l+r,d;if(d=Yd(t,a,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<l;)s+=3;o[s]==l?o[s+2]=o[s+2].addInner(a,d,c+1):o.splice(s,0,l,l+a.nodeSize,Qr(d,a,c+1,Qt)),s+=3}});let i=Xd(s?Qd(t):t,-r);for(let a=0;a<i.length;a++)i[a].type.valid(e,i[a])||i.splice(a--,1);return new se(i.length?this.local.concat(i).sort(Zt):this.local,o||this.children)}remove(e){return e.length==0||this==Ae?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,a=r[s]+t,l=r[s+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>a&&u.to<l&&(e[d]=null,(i||(i=[])).push(u));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,a+1);c!=Ae?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let a=0;a<o.length;a++)o[a].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(a--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new se(o,r):Ae}forChild(e,t){if(this==Ae)return this;if(t.isLeaf)return se.empty;let r,o;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let s=e+1,i=s+t.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<i&&l.to>s&&l.type instanceof $t){let c=Math.max(s,l.from)-s,d=Math.min(i,l.to)-s;c<d&&(o||(o=[])).push(l.copy(c,d))}}if(o){let a=new se(o.sort(Zt),wn);return r?new Tt([a,r]):a}return r||Ae}eq(e){if(this==e)return!0;if(!(e instanceof se)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ii(this.localsInner(e))}localsInner(e){if(this==Ae)return wn;if(e.inlineContent||!this.local.some($t.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof $t||t.push(this.local[r]);return t}forEachSet(e){e(this)}}se.empty=new se([],[]);se.removeOverlap=Ii;const Ae=se.empty;class Tt{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,Qt));return Tt.from(r)}forChild(e,t){if(t.isLeaf)return se.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=Ae&&(s instanceof Tt?r=r.concat(s.members):r.push(s))}return Tt.from(r)}eq(e){if(!(e instanceof Tt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?Ii(r?t:t.sort(Zt)):wn}static from(e){switch(e.length){case 0:return Ae;case 1:return e[0];default:return new Tt(e.every(t=>t instanceof se)?e:e.reduce((t,r)=>t.concat(r instanceof se?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Em(n,e,t,r,o,s,i){let a=n.slice();for(let c=0,d=s;c<t.maps.length;c++){let u=0;t.maps[c].forEach((h,p,f,m)=>{let g=m-f-(p-h);for(let y=0;y<a.length;y+=3){let w=a[y+1];if(w<0||h>w+d-u)continue;let x=a[y]+d-u;p>=x?a[y+1]=h<=x?-2:-1:h>=d&&g&&(a[y]+=g,a[y+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let d=t.map(n[c]+s),u=d-o;if(u<0||u>=r.content.size){l=!0;continue}let h=t.map(n[c+1]+s,-1),p=h-o,{index:f,offset:m}=r.content.findIndex(u),g=r.maybeChild(f);if(g&&m==u&&m+g.nodeSize==p){let y=a[c+2].mapInner(t,g,d+1,n[c]+s+1,i);y!=Ae?(a[c]=u,a[c+1]=p,a[c+2]=y):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=Tm(a,n,e,t,o,s,i),d=Qr(c,r,0,i);e=d.local;for(let u=0;u<a.length;u+=3)a[u+1]<0&&(a.splice(u,3),u-=3);for(let u=0,h=0;u<d.children.length;u+=3){let p=d.children[u];for(;h<a.length&&a[h]<p;)h+=3;a.splice(h,0,d.children[u],d.children[u+1],d.children[u+2])}}return new se(e.sort(Zt),a)}function Xd(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new xe(o.from+e,o.to+e,o.type))}return t}function Tm(n,e,t,r,o,s,i){function a(l,c){for(let d=0;d<l.local.length;d++){let u=l.local[d].map(r,o,c);u?t.push(u):i.onRemove&&i.onRemove(l.local[d].spec)}for(let d=0;d<l.children.length;d+=3)a(l.children[d+2],l.children[d]+c+1)}for(let l=0;l<n.length;l+=3)n[l+1]==-1&&a(n[l+2],e[l]+s+1);return t}function Yd(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function Qd(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Qr(n,e,t,r){let o=[],s=!1;e.forEach((a,l)=>{let c=Yd(n,a,l+t);if(c){s=!0;let d=Qr(c,a,t+l+1,r);d!=Ae&&o.push(l,l+a.nodeSize,d)}});let i=Xd(s?Qd(n):n,-t).sort(Zt);for(let a=0;a<i.length;a++)i[a].type.valid(e,i[a])||(r.onRemove&&r.onRemove(i[a].spec),i.splice(a--,1));return i.length||o.length?new se(i,o):Ae}function Zt(n,e){return n.from-e.from||n.to-e.to}function Ii(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),ll(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),ll(e,o,r.copy(s.from,r.to)));break}}}return e}function ll(n,e,t){for(;e<n.length&&Zt(t,n[e])>0;)e++;n.splice(e,0,t)}function hs(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Ae&&e.push(r)}),n.cursorWrapper&&e.push(se.create(n.state.doc,[n.cursorWrapper.deco])),Tt.from(e)}const Nm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Am=He&&Lt<=11;class Om{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 Rm{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Om,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&&Lt<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),Am&&(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,Nm)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(el(this.view)){if(this.suppressingSelectionUpdates)return bt(this.view);if(He&&Lt<=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 t=new Set,r;for(let s=e.focusNode;s;s=An(s))t.add(s);for(let s=e.anchorNode;s;s=An(s))if(t.has(s)){r=s;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 t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&el(e)&&!this.ignoreSelectionChange(r),s=-1,i=-1,a=!1,l=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],l);u&&(s=s<0?u.from:Math.min(u.from,s),i=i<0?u.to:Math.max(u.to,i),u.typeOver&&(a=!0))}if(Ge&&l.length){let d=l.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,h]=d;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of d){let p=h.parentNode;p&&p.nodeName=="LI"&&(!u||Lm(e,u)!=p)&&h.remove()}}}let c=null;s<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Po(r)&&(c=Oi(e))&&c.eq(W.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,bt(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||o)&&(s>-1&&(e.docView.markDirty(s,i),Dm(e)),this.handleDOMChange(s,i,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||bt(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.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 d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,s=e.nextSibling;if(He&&Lt<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:h}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(o=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(s=h)}let i=o&&o.parentNode==e.target?Ee(o)+1:0,a=r.localPosFromDOM(e.target,i,-1),l=s&&s.parentNode==e.target?Ee(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:a,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 cl=new WeakMap,dl=!1;function Dm(n){if(!cl.has(n)&&(cl.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ge,dl)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."),dl=!0}}function ul(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return rn(i.node,i.offset,o,s)&&([t,r,o,s]=[o,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:o,focusOffset:s}}function jm(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return ul(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?ul(n,t):null}function Lm(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function zm(n,e,t){let{node:r,fromOffset:o,toOffset:s,from:i,to:a}=n.docView.parseRange(e,t),l=n.domSelectionRange(),c,d=l.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:l.anchorOffset}],Po(l)||c.push({node:l.focusNode,offset:l.focusOffset})),Oe&&n.input.lastKeyCode===8)for(let g=s;g>o;g--){let y=r.childNodes[g-1],w=y.pmViewDesc;if(y.nodeName=="BR"&&!w){s=g;break}if(!w||w.size)break}let u=n.state.doc,h=n.someProp("domParser")||jt.fromSchema(n.state.schema),p=u.resolve(i),f=null,m=h.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:$m,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),f={anchor:g+i,head:y+i}}return{doc:m,sel:f,from:i,to:a}}function $m(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Le&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Le&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Im=/^(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 Pm(n,e,t,r,o){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let v=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,S=Oi(n,v);if(S&&!n.state.selection.eq(S)){if(Oe&&gt&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",K=>K(n,Ut(13,"Enter"))))return;let R=n.state.tr.setSelection(S);v=="pointer"?R.setMeta("pointer",!0):v=="key"&&R.scrollIntoView(),s&&R.setMeta("composition",s),n.dispatch(R)}return}let i=n.state.doc.resolve(e),a=i.sharedDepth(t);e=i.before(a+1),t=n.state.doc.resolve(t).after(a+1);let l=n.state.selection,c=zm(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),h,p;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(h=n.state.selection.to,p="end"):(h=n.state.selection.from,p="start"),n.input.lastKeyCode=null;let f=Vm(u.content,c.doc.content,c.from,h,p);if(f&&n.input.domChangeCount++,(On&&n.input.lastIOSEnter>Date.now()-225||gt)&&o.some(v=>v.nodeType==1&&!Im.test(v.nodeName))&&(!f||f.endA>=f.endB)&&n.someProp("handleKeyDown",v=>v(n,Ut(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!f)if(r&&l instanceof H&&!l.empty&&l.$head.sameParent(l.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))f={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let v=hl(n,n.state.doc,c.sel);if(v&&!v.eq(n.state.selection)){let S=n.state.tr.setSelection(v);s&&S.setMeta("composition",s),n.dispatch(S)}}return}n.state.selection.from<n.state.selection.to&&f.start==f.endB&&n.state.selection instanceof H&&(f.start>n.state.selection.from&&f.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?f.start=n.state.selection.from:f.endA<n.state.selection.to&&f.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(f.endB+=n.state.selection.to-f.endA,f.endA=n.state.selection.to)),He&&Lt<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>c.from&&c.doc.textBetween(f.start-c.from-1,f.start-c.from+1)=="  "&&(f.start--,f.endA--,f.endB--);let m=c.doc.resolveNoCache(f.start-c.from),g=c.doc.resolveNoCache(f.endB-c.from),y=d.resolve(f.start),w=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=f.endA;if((On&&n.input.lastIOSEnter>Date.now()-225&&(!w||o.some(v=>v.nodeName=="DIV"||v.nodeName=="P"))||!w&&m.pos<c.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(c.doc.textBetween(m.pos,g.pos,"","")))&&n.someProp("handleKeyDown",v=>v(n,Ut(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>f.start&&Bm(d,f.start,f.endA,m,g)&&n.someProp("handleKeyDown",v=>v(n,Ut(8,"Backspace")))){gt&&Oe&&n.domObserver.suppressSelectionUpdates();return}Oe&&f.endB==f.start&&(n.input.lastChromeDelete=Date.now()),gt&&!w&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==f.endA&&(f.endB-=2,g=c.doc.resolveNoCache(f.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(v){return v(n,Ut(13,"Enter"))})},20));let x=f.start,E=f.endA,b=v=>{let S=v||n.state.tr.replace(x,E,c.doc.slice(f.start-c.from,f.endB-c.from));if(c.sel){let R=hl(n,S.doc,c.sel);R&&!(Oe&&n.composing&&R.empty&&(f.start!=f.endB||n.input.lastChromeDelete<Date.now()-100)&&(R.head==x||R.head==S.mapping.map(E)-1)||He&&R.empty&&R.head==x)&&S.setSelection(R)}return s&&S.setMeta("composition",s),S.scrollIntoView()},T;if(w)if(m.pos==g.pos){He&&Lt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>bt(n),20));let v=b(n.state.tr.delete(x,E)),S=d.resolve(f.start).marksAcross(d.resolve(f.endA));S&&v.ensureMarks(S),n.dispatch(v)}else if(f.endA==f.endB&&(T=Hm(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,f.endA-y.start())))){let v=b(n.state.tr);T.type=="add"?v.addMark(x,E,T.mark):v.removeMark(x,E,T.mark),n.dispatch(v)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let v=m.parent.textBetween(m.parentOffset,g.parentOffset),S=()=>b(n.state.tr.insertText(v,x,E));n.someProp("handleTextInput",R=>R(n,x,E,v,S))||n.dispatch(S())}else n.dispatch(b());else n.dispatch(b())}function hl(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Ri(n,e.resolve(t.anchor),e.resolve(t.head))}function Hm(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,s=r,i,a,l;for(let d=0;d<r.length;d++)o=r[d].removeFromSet(o);for(let d=0;d<t.length;d++)s=t[d].removeFromSet(s);if(o.length==1&&s.length==0)a=o[0],i="add",l=d=>d.mark(a.addToSet(d.marks));else if(o.length==0&&s.length==1)a=s[0],i="remove",l=d=>d.mark(a.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(l(e.child(d)));if(M.from(c).eq(n))return{mark:a,type:i}}function Bm(n,e,t,r,o){if(t-e<=o.pos-r.pos||ps(r,!0,!1)<o.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let a=s.nodeAfter;return a!=null&&t==e+a.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let i=n.resolve(ps(s,!0,!0));return!i.parent.isTextblock||i.pos>t||ps(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function ps(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,o++}return o}function Vm(n,e,t,r,o){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:i,b:a}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let l=Math.max(0,s-Math.min(i,a));r-=i+l-s}if(i<s&&n.size<e.size){let l=r<=s&&r>=i?s-r:0;s-=l,s&&s<e.size&&pl(e.textBetween(s-1,s+1))&&(s+=l?1:-1),a=s+(a-i),i=s}else if(a<s){let l=r<=s&&r>=a?s-r:0;s-=l,s&&s<n.size&&pl(n.textBetween(s-1,s+1))&&(s+=l?1:-1),i=s+(i-a),a=s}return{start:s,endA:i,endB:a}}function pl(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Zd{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new im,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(bl),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=gl(this),ml(this),this.nodeViews=yl(this),this.docView=Ja(this.state.doc,fl(this),hs(this),this.dom,this),this.domObserver=new Rm(this,(r,o,s,i)=>Pm(this,r,o,s,i)),this.domObserver.start(),am(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Xs(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(bl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(qd(this),i=!0),this.state=e;let a=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=yl(this);Wm(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Xs(this),this.editable=gl(this),ml(this);let l=hs(this),c=fl(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",u=s||!this.docView.matchesNode(e.doc,c,l);(u||!e.selection.eq(o.selection))&&(i=!0);let h=d=="preserve"&&i&&this.dom.style.overflowAnchor==null&&kf(this);if(i){this.domObserver.stop();let p=u&&(He||Oe)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Fm(o.selection,e.selection);if(u){let f=Oe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=wm(this)),(s||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ja(e.doc,c,l,this.dom,this)),f&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Uf(this))?bt(this,p):(Ld(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),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():h&&vf(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof I){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Fa(this,t.getBoundingClientRect(),e)}else Fa(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 t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(o=s)}this.dragging=new Jd(e.slice,e.move,o<0?void 0:I.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let i=0;i<this.directPlugins.length;i++){let a=this.directPlugins[i].props[e];if(a!=null&&(o=t?t(a):a))return o}let s=this.state.plugins;if(s)for(let i=0;i<s.length;i++){let a=s[i].props[e];if(a!=null&&(o=t?t(a):a))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&&Sf(this.dom),bt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Nf(this,e)}coordsAtPos(e,t=1){return Ed(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return jf(this,t||this.state,e)}pasteHTML(e,t){return ir(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ir(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Di(this,e)}destroy(){this.docView&&(lm(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],hs(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,df())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return dm(this,e)}domSelectionRange(){let e=this.domSelection();return e?Le&&this.root.nodeType===11&&mf(this.dom.ownerDocument)==this.dom&&jm(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Zd.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function fl(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[xe.node(0,n.state.doc.content.size,e)]}function ml(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:xe.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function gl(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Fm(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function yl(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Wm(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function bl(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var It={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:"'"},Zr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},_m=typeof navigator<"u"&&/Mac/.test(navigator.platform),Um=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Te=0;Te<10;Te++)It[48+Te]=It[96+Te]=String(Te);for(var Te=1;Te<=24;Te++)It[Te+111]="F"+Te;for(var Te=65;Te<=90;Te++)It[Te]=String.fromCharCode(Te+32),Zr[Te]=String.fromCharCode(Te);for(var fs in It)Zr.hasOwnProperty(fs)||(Zr[fs]=It[fs]);function qm(n){var e=_m&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Um&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Zr:It)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Km=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Jm=typeof navigator<"u"&&/Win/.test(navigator.platform);function Gm(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,s,i;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))i=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))o=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))Km?i=!0:o=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),i&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Xm(n){let e=Object.create(null);for(let t in n)e[Gm(t)]=n[t];return e}function ms(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Ym(n){return new le({props:{handleKeyDown:Pi(n)}})}function Pi(n){let e=Xm(n);return function(t,r){let o=qm(r),s,i=e[ms(o,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let a=e[ms(o,r,!1)];if(a&&a(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Jm&&r.ctrlKey&&r.altKey)&&(s=It[r.keyCode])&&s!=o){let a=e[ms(s,r)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}var Qm=Object.defineProperty,Hi=(n,e)=>{for(var t in e)Qm(n,t,{get:e[t],enumerable:!0})};function Vo(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:o}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return o},get tr(){return r=t.selection,o=t.doc,s=t.storedMarks,t}}}var Fo=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:o}=t,s=this.buildProps(o);return Object.fromEntries(Object.entries(n).map(([i,a])=>[i,(...l)=>{const c=a(...l)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(o),c}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:r,state:o}=this,{view:s}=r,i=[],a=!!n,l=n||o.tr,c=()=>(!a&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(l),i.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(t).map(([u,h])=>[u,(...p)=>{const f=this.buildProps(l,e),m=h(...p)(f);return i.push(m),d}])),run:c};return d}createCan(n){const{rawCommands:e,state:t}=this,r=!1,o=n||t.tr,s=this.buildProps(o,r);return{...Object.fromEntries(Object.entries(e).map(([i,a])=>[i,(...l)=>a(...l)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,r)}}buildProps(n,e=!0){const{rawCommands:t,editor:r,state:o}=this,{view:s}=r,i={tr:n,editor:r,view:s,state:Vo({state:o,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([a,l])=>[a,(...c)=>l(...c)(i)]))}};return i}},eu={};Hi(eu,{blur:()=>Zm,clearContent:()=>eg,clearNodes:()=>tg,command:()=>ng,createParagraphNear:()=>rg,cut:()=>og,deleteCurrentNode:()=>sg,deleteNode:()=>ig,deleteRange:()=>ag,deleteSelection:()=>lg,enter:()=>cg,exitCode:()=>dg,extendMarkRange:()=>ug,first:()=>hg,focus:()=>pg,forEach:()=>fg,insertContent:()=>mg,insertContentAt:()=>bg,joinBackward:()=>kg,joinDown:()=>wg,joinForward:()=>vg,joinItemBackward:()=>Sg,joinItemForward:()=>Cg,joinTextblockBackward:()=>Mg,joinTextblockForward:()=>Eg,joinUp:()=>xg,keyboardShortcut:()=>Ng,lift:()=>Ag,liftEmptyBlock:()=>Og,liftListItem:()=>Rg,newlineInCode:()=>Dg,resetAttributes:()=>jg,scrollIntoView:()=>Lg,selectAll:()=>zg,selectNodeBackward:()=>$g,selectNodeForward:()=>Ig,selectParentNode:()=>Pg,selectTextblockEnd:()=>Hg,selectTextblockStart:()=>Bg,setContent:()=>Vg,setMark:()=>oy,setMeta:()=>sy,setNode:()=>iy,setNodeSelection:()=>ay,setTextDirection:()=>ly,setTextSelection:()=>cy,sinkListItem:()=>dy,splitBlock:()=>uy,splitListItem:()=>hy,toggleList:()=>py,toggleMark:()=>fy,toggleNode:()=>my,toggleWrap:()=>gy,undoInputRule:()=>yy,unsetAllMarks:()=>by,unsetMark:()=>xy,unsetTextDirection:()=>wy,updateAttributes:()=>ky,wrapIn:()=>vy,wrapInList:()=>Sy});var Zm=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),eg=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),tg=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:o}=r;return t&&o.forEach(({$from:s,$to:i})=>{n.doc.nodesBetween(s.pos,i.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(l)),h=c.resolve(d.map(l+a.nodeSize)),p=u.blockRange(h);if(!p)return;const f=jn(p);if(a.type.isTextblock){const{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(p.start,m)}(f||f===0)&&e.lift(p,f)})}),!0},ng=n=>e=>n(e),rg=()=>({state:n,dispatch:e})=>gd(n,e),og=(n,e)=>({editor:t,tr:r})=>{const{state:o}=t,s=o.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const i=r.mapping.map(e);return r.insert(i,s.content),r.setSelection(new H(r.doc.resolve(Math.max(i-1,0)))),!0},sg=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const o=n.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===r.type){if(e){const i=o.before(s),a=o.after(s);n.delete(i,a).scrollIntoView()}return!0}return!1};function me(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}var ig=n=>({tr:e,state:t,dispatch:r})=>{const o=me(n,t.schema),s=e.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===o){if(r){const a=s.before(i),l=s.after(i);e.delete(a,l).scrollIntoView()}return!0}return!1},ag=n=>({tr:e,dispatch:t})=>{const{from:r,to:o}=n;return t&&e.delete(r,o),!0},lg=()=>({state:n,dispatch:e})=>Ci(n,e),cg=()=>({commands:n})=>n.keyboardShortcut("Enter"),dg=()=>({state:n,dispatch:e})=>Jp(n,e);function Bi(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function eo(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(o=>t.strict?e[o]===n[o]:Bi(e[o])?e[o].test(n[o]):e[o]===n[o]):!0}function tu(n,e,t={}){return n.find(r=>r.type===e&&eo(Object.fromEntries(Object.keys(t).map(o=>[o,r.attrs[o]])),t))}function xl(n,e,t={}){return!!tu(n,e,t)}function Vi(n,e,t){var r;if(!n||!e)return;let o=n.parent.childAfter(n.parentOffset);if((!o.node||!o.node.marks.some(c=>c.type===e))&&(o=n.parent.childBefore(n.parentOffset)),!o.node||!o.node.marks.some(c=>c.type===e)||(t=t||((r=o.node.marks[0])==null?void 0:r.attrs),!tu([...o.node.marks],e,t)))return;let s=o.index,i=n.start()+o.offset,a=s+1,l=i+o.node.nodeSize;for(;s>0&&xl([...n.parent.child(s-1).marks],e,t);)s-=1,i-=n.parent.child(s).nodeSize;for(;a<n.parent.childCount&&xl([...n.parent.child(a).marks],e,t);)l+=n.parent.child(a).nodeSize,a+=1;return{from:i,to:l}}function xt(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var ug=(n,e={})=>({tr:t,state:r,dispatch:o})=>{const s=xt(n,r.schema),{doc:i,selection:a}=t,{$from:l,from:c,to:d}=a;if(o){const u=Vi(l,s,e);if(u&&u.from<=c&&u.to>=d){const h=H.create(i,u.from,u.to);t.setSelection(h)}}return!0},hg=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function nu(n){return n instanceof H}function Jt(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function ru(n,e=null){if(!e)return null;const t=W.atStart(n),r=W.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const o=t.from,s=r.to;return e==="all"?H.create(n,Jt(0,o,s),Jt(n.content.size,o,s)):H.create(n,Jt(e,o,s),Jt(e,o,s))}function ou(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Wo(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var pg=(n=null,e={})=>({editor:t,view:r,tr:o,dispatch:s})=>{e={scrollIntoView:!0,...e};const i=()=>{(Wo()||ou())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!nu(t.state.selection))return i(),!0;const a=ru(o.doc,n)||t.state.selection,l=t.state.selection.eq(a);return s&&(l||o.setSelection(a),l&&o.storedMarks&&o.setStoredMarks(o.storedMarks),i()),!0},fg=(n,e)=>t=>n.every((r,o)=>e(r,{...t,index:o})),mg=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),su=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&su(r)}return n};function vr(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return su(t)}function lr(n,e,t){if(n instanceof Je||n instanceof M)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,o=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return M.fromArray(n.map(i=>e.nodeFromJSON(i)));const s=e.nodeFromJSON(n);return t.errorOnInvalidContent&&s.check(),s}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),lr("",e,t)}if(o){if(t.errorOnInvalidContent){let i=!1,a="";const l=new Wc({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=>(i=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?jt.fromSchema(l).parseSlice(vr(n),t.parseOptions):jt.fromSchema(l).parse(vr(n),t.parseOptions),t.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const s=jt.fromSchema(e);return t.slice?s.parseSlice(vr(n),t.parseOptions).content:s.parse(vr(n),t.parseOptions)}return lr("",e,t)}function gg(n,e,t){const r=n.steps.length-1;if(r<e)return;const o=n.steps[r];if(!(o instanceof be||o instanceof we))return;const s=n.mapping.maps[r];let i=0;s.forEach((a,l,c,d)=>{i===0&&(i=d)}),n.setSelection(W.near(n.doc.resolve(i),t))}var yg=n=>!("type"in n),bg=(n,e,t)=>({tr:r,dispatch:o,editor:s})=>{var i;if(o){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let a;const l=m=>{s.emit("contentError",{editor:s,error:m,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{lr(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(m){l(m)}try{a=lr(e,s.schema,{parseOptions:c,errorOnInvalidContent:(i=t.errorOnInvalidContent)!=null?i:s.options.enableContentCheck})}catch(m){return l(m),!1}let{from:d,to:u}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},h=!0,p=!0;if((yg(a)?a:[a]).forEach(m=>{m.check(),h=h?m.isText&&m.marks.length===0:!1,p=p?m.isBlock:!1}),d===u&&p){const{parent:m}=r.doc.resolve(d);m.isTextblock&&!m.type.spec.code&&!m.childCount&&(d-=1,u+=1)}let f;if(h){if(Array.isArray(e))f=e.map(m=>m.text||"").join("");else if(e instanceof M){let m="";e.forEach(g=>{g.text&&(m+=g.text)}),f=m}else typeof e=="object"&&e&&e.text?f=e.text:f=e;r.insertText(f,d,u)}else{f=a;const m=r.doc.resolve(d),g=m.node(),y=m.parentOffset===0,w=g.isText||g.isTextblock,x=g.content.size>0;y&&w&&x&&(d=Math.max(0,d-1)),r.replaceWith(d,u,f)}t.updateSelection&&gg(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:f}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:f})}return!0},xg=()=>({state:n,dispatch:e})=>Up(n,e),wg=()=>({state:n,dispatch:e})=>qp(n,e),kg=()=>({state:n,dispatch:e})=>cd(n,e),vg=()=>({state:n,dispatch:e})=>pd(n,e),Sg=()=>({state:n,dispatch:e,tr:t})=>{try{const r=zo(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Cg=()=>({state:n,dispatch:e,tr:t})=>{try{const r=zo(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Mg=()=>({state:n,dispatch:e})=>Wp(n,e),Eg=()=>({state:n,dispatch:e})=>_p(n,e);function iu(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Tg(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,o,s,i;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))i=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))o=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))Wo()||iu()?i=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(t=`Alt-${t}`),o&&(t=`Ctrl-${t}`),i&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var Ng=n=>({editor:e,view:t,tr:r,dispatch:o})=>{const s=Tg(n).split(/-(?!$)/),i=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0});return e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,a))})?.steps.forEach(c=>{const d=c.map(r.mapping);d&&o&&r.maybeStep(d)}),!0};function Pt(n,e,t={}){const{from:r,to:o,empty:s}=n.selection,i=e?me(e,n.schema):null,a=[];n.doc.nodesBetween(r,o,(d,u)=>{if(d.isText)return;const h=Math.max(r,u),p=Math.min(o,u+d.nodeSize);a.push({node:d,from:h,to:p})});const l=o-r,c=a.filter(d=>i?i.name===d.node.type.name:!0).filter(d=>eo(d.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((d,u)=>d+u.to-u.from,0)>=l}var Ag=(n,e={})=>({state:t,dispatch:r})=>{const o=me(n,t.schema);return Pt(t,o,e)?Kp(t,r):!1},Og=()=>({state:n,dispatch:e})=>yd(n,e),Rg=n=>({state:e,dispatch:t})=>{const r=me(n,e.schema);return sf(r)(e,t)},Dg=()=>({state:n,dispatch:e})=>md(n,e);function _o(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function wl(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,o)=>(t.includes(o)||(r[o]=n[o]),r),{})}var jg=(n,e)=>({tr:t,state:r,dispatch:o})=>{let s=null,i=null;const a=_o(typeof n=="string"?n:n.name,r.schema);if(!a)return!1;a==="node"&&(s=me(n,r.schema)),a==="mark"&&(i=xt(n,r.schema));let l=!1;return t.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,u)=>{s&&s===d.type&&(l=!0,o&&t.setNodeMarkup(u,void 0,wl(d.attrs,e))),i&&d.marks.length&&d.marks.forEach(h=>{i===h.type&&(l=!0,o&&t.addMark(u,u+d.nodeSize,i.create(wl(h.attrs,e))))})})}),l},Lg=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),zg=()=>({tr:n,dispatch:e})=>{if(e){const t=new We(n.doc);n.setSelection(t)}return!0},$g=()=>({state:n,dispatch:e})=>ud(n,e),Ig=()=>({state:n,dispatch:e})=>fd(n,e),Pg=()=>({state:n,dispatch:e})=>Yp(n,e),Hg=()=>({state:n,dispatch:e})=>ef(n,e),Bg=()=>({state:n,dispatch:e})=>Zp(n,e);function Ys(n,e,t={},r={}){return lr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var Vg=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:o,tr:s,dispatch:i,commands:a})=>{const{doc:l}=s;if(r.preserveWhitespace!=="full"){const c=Ys(n,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});return i&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!t),!0}return i&&s.setMeta("preventUpdate",!t),a.insertContentAt({from:0,to:l.content.size},n,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function au(n,e){const t=xt(e,n.schema),{from:r,to:o,empty:s}=n.selection,i=[];s?(n.storedMarks&&i.push(...n.storedMarks),i.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,o,l=>{i.push(...l.marks)});const a=i.find(l=>l.type.name===t.name);return a?{...a.attrs}:{}}function lu(n,e){const t=new vi(n);return e.forEach(r=>{r.steps.forEach(o=>{t.step(o)})}),t}function Fg(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Wg(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(o,s)=>{t(o)&&r.push({node:o,pos:s})}),r}function cu(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Uo(n){return e=>cu(e.$from,n)}function P(n,e,t){return n.config[e]===void 0&&n.parent?P(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?P(n.parent,e,t):null}):n.config[e]}function Fi(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},r=P(e,"addExtensions",t);return r?[e,...Fi(r())]:e}).flat(10)}function Wi(n,e){const t=Bt.fromSchema(e).serializeFragment(n),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(t),r.innerHTML}function du(n){return typeof n=="function"}function Q(n,e=void 0,...t){return du(n)?e?n.bind(e)(...t):n(...t):n}function _g(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Rn(n){const e=n.filter(o=>o.type==="extension"),t=n.filter(o=>o.type==="node"),r=n.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function uu(n){const e=[],{nodeExtensions:t,markExtensions:r}=Rn(n),o=[...t,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage,extensions:o},l=P(i,"addGlobalAttributes",a);l&&l().forEach(c=>{c.types.forEach(d=>{Object.entries(c.attributes).forEach(([u,h])=>{e.push({type:d,name:u,attribute:{...s,...h}})})})})}),o.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage},l=P(i,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([d,u])=>{const h={...s,...u};typeof h?.default=="function"&&(h.default=h.default()),h?.isRequired&&h?.default===void 0&&delete h.default,e.push({type:i.name,name:d,attribute:h})})}),e}function re(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([o,s])=>{if(!r[o]){r[o]=s;return}if(o==="class"){const i=s?String(s).split(" "):[],a=r[o]?r[o].split(" "):[],l=i.filter(c=>!a.includes(c));r[o]=[...a,...l].join(" ")}else if(o==="style"){const i=s?s.split(";").map(c=>c.trim()).filter(Boolean):[],a=r[o]?r[o].split(";").map(c=>c.trim()).filter(Boolean):[],l=new Map;a.forEach(c=>{const[d,u]=c.split(":").map(h=>h.trim());l.set(d,u)}),i.forEach(c=>{const[d,u]=c.split(":").map(h=>h.trim());l.set(d,u)}),r[o]=Array.from(l.entries()).map(([c,d])=>`${c}: ${d}`).join("; ")}else r[o]=s}),r},{})}function cr(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>re(t,r),{})}function Ug(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function kl(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const o=e.reduce((s,i)=>{const a=i.attribute.parseHTML?i.attribute.parseHTML(t):Ug(t.getAttribute(i.name));return a==null?s:{...s,[i.name]:a}},{});return{...r,...o}}}}function vl(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&_g(t)?!1:t!=null))}function Sl(n){var e,t;const r={};return!((e=n?.attribute)!=null&&e.isRequired)&&"default"in(n?.attribute||{})&&(r.default=n.attribute.default),((t=n?.attribute)==null?void 0:t.validate)!==void 0&&(r.validate=n.attribute.validate),[n.name,r]}function hu(n,e){var t;const r=uu(n),{nodeExtensions:o,markExtensions:s}=Rn(n),i=(t=o.find(c=>P(c,"topNode")))==null?void 0:t.name,a=Object.fromEntries(o.map(c=>{const d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=n.reduce((y,w)=>{const x=P(w,"extendNodeSchema",u);return{...y,...x?x(c):{}}},{}),p=vl({...h,content:Q(P(c,"content",u)),marks:Q(P(c,"marks",u)),group:Q(P(c,"group",u)),inline:Q(P(c,"inline",u)),atom:Q(P(c,"atom",u)),selectable:Q(P(c,"selectable",u)),draggable:Q(P(c,"draggable",u)),code:Q(P(c,"code",u)),whitespace:Q(P(c,"whitespace",u)),linebreakReplacement:Q(P(c,"linebreakReplacement",u)),defining:Q(P(c,"defining",u)),isolating:Q(P(c,"isolating",u)),attrs:Object.fromEntries(d.map(Sl))}),f=Q(P(c,"parseHTML",u));f&&(p.parseDOM=f.map(y=>kl(y,d)));const m=P(c,"renderHTML",u);m&&(p.toDOM=y=>m({node:y,HTMLAttributes:cr(y,d)}));const g=P(c,"renderText",u);return g&&(p.toText=g),[c.name,p]})),l=Object.fromEntries(s.map(c=>{const d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=n.reduce((g,y)=>{const w=P(y,"extendMarkSchema",u);return{...g,...w?w(c):{}}},{}),p=vl({...h,inclusive:Q(P(c,"inclusive",u)),excludes:Q(P(c,"excludes",u)),group:Q(P(c,"group",u)),spanning:Q(P(c,"spanning",u)),code:Q(P(c,"code",u)),attrs:Object.fromEntries(d.map(Sl))}),f=Q(P(c,"parseHTML",u));f&&(p.parseDOM=f.map(g=>kl(g,d)));const m=P(c,"renderHTML",u);return m&&(p.toDOM=g=>m({mark:g,HTMLAttributes:cr(g,d)})),[c.name,p]}));return new Wc({topNode:i,nodes:a,marks:l})}function qg(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function _i(n){return n.sort((e,t)=>{const r=P(e,"priority")||100,o=P(t,"priority")||100;return r>o?-1:r<o?1:0})}function Ui(n){const e=_i(Fi(n)),t=qg(e.map(r=>r.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Kg(n,e){const t=Ui(n);return hu(t,e)}function pu(n,e,t){const{from:r,to:o}=e,{blockSeparator:s=`
20
+
21
+ `,textSerializers:i={}}=t||{};let a="";return n.nodesBetween(r,o,(l,c,d,u)=>{var h;l.isBlock&&c>r&&(a+=s);const p=i?.[l.type.name];if(p)return d&&(a+=p({node:l,pos:c,parent:d,index:u,range:e})),!1;l.isText&&(a+=(h=l?.text)==null?void 0:h.slice(Math.max(r,c)-c,o-c))}),a}function Jg(n,e){const t={from:0,to:n.content.size};return pu(n,t,e)}function fu(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Gg(n,e){const t=me(e,n.schema),{from:r,to:o}=n.selection,s=[];n.doc.nodesBetween(r,o,a=>{s.push(a)});const i=s.reverse().find(a=>a.type.name===t.name);return i?{...i.attrs}:{}}function mu(n,e){const t=_o(typeof e=="string"?e:e.name,n.schema);return t==="node"?Gg(n,e):t==="mark"?au(n,e):{}}function Xg(n,e=JSON.stringify){const t={};return n.filter(r=>{const o=e(r);return Object.prototype.hasOwnProperty.call(t,o)?!1:t[o]=!0})}function Yg(n){const e=Xg(n);return e.length===1?e:e.filter((t,r)=>!e.filter((o,s)=>s!==r).some(o=>t.oldRange.from>=o.oldRange.from&&t.oldRange.to<=o.oldRange.to&&t.newRange.from>=o.newRange.from&&t.newRange.to<=o.newRange.to))}function gu(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((o,s)=>{const i=[];if(o.ranges.length)o.forEach((a,l)=>{i.push({from:a,to:l})});else{const{from:a,to:l}=t[s];if(a===void 0||l===void 0)return;i.push({from:a,to:l})}i.forEach(({from:a,to:l})=>{const c=e.slice(s).map(a,-1),d=e.slice(s).map(l),u=e.invert().map(c,-1),h=e.invert().map(d);r.push({oldRange:{from:u,to:h},newRange:{from:c,to:d}})})}),Yg(r)}function qi(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(o=>{const s=t.resolve(n),i=Vi(s,o.type);i&&r.push({mark:o,...i})}):t.nodesBetween(n,e,(o,s)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(i=>({from:s,to:s+o.nodeSize,mark:i})))}),r}var Qg=(n,e,t,r=20)=>{const o=n.doc.resolve(t);let s=r,i=null;for(;s>0&&i===null;){const a=o.node(s);a?.type.name===e?i=a:s-=1}return[i,s]};function gs(n,e){return e.nodes[n]||e.marks[n]||null}function Pr(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const o=n.find(s=>s.type===e&&s.name===r);return o?o.attribute.keepOnSplit:!1}))}var Zg=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(o,s,i,a)=>{var l,c;const d=((c=(l=o.type.spec).toText)==null?void 0:c.call(l,{node:o,pos:s,parent:i,index:a}))||o.textContent||"%leaf%";t+=o.isAtom&&!o.isText?d:d.slice(0,Math.max(0,r-s))}),t};function Qs(n,e,t={}){const{empty:r,ranges:o}=n.selection,s=e?xt(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>eo(d.attrs,t,{strict:!1}));let i=0;const a=[];if(o.forEach(({$from:d,$to:u})=>{const h=d.pos,p=u.pos;n.doc.nodesBetween(h,p,(f,m)=>{if(!f.isText&&!f.marks.length)return;const g=Math.max(h,m),y=Math.min(p,m+f.nodeSize),w=y-g;i+=w,a.push(...f.marks.map(x=>({mark:x,from:g,to:y})))})}),i===0)return!1;const l=a.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>eo(d.mark.attrs,t,{strict:!1})).reduce((d,u)=>d+u.to-u.from,0),c=a.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,u)=>d+u.to-u.from,0);return(l>0?l+c:l)>=i}function ey(n,e,t={}){if(!e)return Pt(n,null,t)||Qs(n,null,t);const r=_o(e,n.schema);return r==="node"?Pt(n,e,t):r==="mark"?Qs(n,e,t):!1}var ty=(n,e)=>{const{$from:t,$to:r,$anchor:o}=n.selection;if(e){const s=Uo(a=>a.type.name===e)(n.selection);if(!s)return!1;const i=n.doc.resolve(s.pos+1);return o.pos+1===i.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},ny=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Cl(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Ml(n,e){const{nodeExtensions:t}=Rn(e),r=t.find(i=>i.name===n);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},s=Q(P(r,"group",o));return typeof s!="string"?!1:s.split(" ").includes("list")}function qo(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let o=!0;return n.content.forEach(s=>{o!==!1&&(qo(s,{ignoreWhitespace:t,checkChildren:e})||(o=!1))}),o}return!1}function yu(n){return n instanceof I}function ry(n,e,t){var r;const{selection:o}=e;let s=null;if(nu(o)&&(s=o.$cursor),s){const a=(r=n.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(a)||!a.some(l=>l.type.excludes(t)))}const{ranges:i}=o;return i.some(({$from:a,$to:l})=>{let c=a.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(a.pos,l.pos,(d,u,h)=>{if(c)return!1;if(d.isInline){const p=!h||h.type.allowsMarkType(t),f=!!t.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(t));c=p&&f}return!c}),c})}var oy=(n,e={})=>({tr:t,state:r,dispatch:o})=>{const{selection:s}=t,{empty:i,ranges:a}=s,l=xt(n,r.schema);if(o)if(i){const c=au(r,l);t.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(h,p)=>{const f=Math.max(p,d),m=Math.min(p+h.nodeSize,u);h.marks.find(g=>g.type===l)?h.marks.forEach(g=>{l===g.type&&t.addMark(f,m,l.create({...g.attrs,...e}))}):t.addMark(f,m,l.create(e))})});return ry(r,t,l)},sy=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),iy=(n,e={})=>({state:t,dispatch:r,chain:o})=>{const s=me(n,t.schema);let i;return t.selection.$anchor.sameParent(t.selection.$head)&&(i=t.selection.$anchor.parent.attrs),s.isTextblock?o().command(({commands:a})=>Ha(s,{...i,...e})(t)?!0:a.clearNodes()).command(({state:a})=>Ha(s,{...i,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ay=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,o=Jt(n,0,r.content.size),s=I.create(r,o);e.setSelection(s)}return!0},ly=(n,e)=>({tr:t,state:r,dispatch:o})=>{const{selection:s}=r;let i,a;return typeof e=="number"?(i=e,a=e):e&&"from"in e&&"to"in e?(i=e.from,a=e.to):(i=s.from,a=s.to),o&&t.doc.nodesBetween(i,a,(l,c)=>{l.isText||t.setNodeMarkup(c,void 0,{...l.attrs,dir:n})}),!0},cy=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:o,to:s}=typeof n=="number"?{from:n,to:n}:n,i=H.atStart(r).from,a=H.atEnd(r).to,l=Jt(o,i,a),c=Jt(s,i,a),d=H.create(r,l,c);e.setSelection(d)}return!0},dy=n=>({state:e,dispatch:t})=>{const r=me(n,e.schema);return cf(r)(e,t)};function El(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(o=>e?.includes(o.type.name));n.tr.ensureMarks(r)}}var uy=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:o})=>{const{selection:s,doc:i}=e,{$from:a,$to:l}=s,c=o.extensionManager.attributes,d=Pr(c,a.node().type.name,a.node().attrs);if(s instanceof I&&s.node.isBlock)return!a.parentOffset||!yt(i,a.pos)?!1:(r&&(n&&El(t,o.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const u=l.parentOffset===l.parent.content.size,h=a.depth===0?void 0:Fg(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=u&&h?[{type:h,attrs:d}]:void 0,f=yt(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!f&&yt(e.doc,e.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(f=!0,p=h?[{type:h,attrs:d}]:void 0),r){if(f&&(s instanceof H&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,p),h&&!u&&!a.parentOffset&&a.parent.type!==h)){const m=e.mapping.map(a.before()),g=e.doc.resolve(m);a.node(-1).canReplaceWith(g.index(),g.index()+1,h)&&e.setNodeMarkup(e.mapping.map(a.before()),h)}n&&El(t,o.extensionManager.splittableMarks),e.scrollIntoView()}return f},hy=(n,e={})=>({tr:t,state:r,dispatch:o,editor:s})=>{var i;const a=me(n,r.schema),{$from:l,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const u=l.node(-1);if(u.type!==a)return!1;const h=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(o){let y=M.empty;const w=l.index(-1)?1:l.index(-2)?2:3;for(let S=l.depth-w;S>=l.depth-3;S-=1)y=M.from(l.node(S).copy(y));const x=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,E={...Pr(h,l.node().type.name,l.node().attrs),...e},b=((i=a.contentMatch.defaultType)==null?void 0:i.createAndFill(E))||void 0;y=y.append(M.from(a.createAndFill(null,b)||void 0));const T=l.before(l.depth-(w-1));t.replace(T,l.after(-x),new O(y,4-w,0));let v=-1;t.doc.nodesBetween(T,t.doc.content.size,(S,R)=>{if(v>-1)return!1;S.isTextblock&&S.content.size===0&&(v=R+1)}),v>-1&&t.setSelection(H.near(t.doc.resolve(v))),t.scrollIntoView()}return!0}const p=c.pos===l.end()?u.contentMatchAt(0).defaultType:null,f={...Pr(h,u.type.name,u.attrs),...e},m={...Pr(h,l.node().type.name,l.node().attrs),...e};t.delete(l.pos,c.pos);const g=p?[{type:a,attrs:f},{type:p,attrs:m}]:[{type:a,attrs:f}];if(!yt(t.doc,l.pos,2))return!1;if(o){const{selection:y,storedMarks:w}=r,{splittableMarks:x}=s.extensionManager,E=w||y.$to.parentOffset&&y.$from.marks();if(t.split(l.pos,2,g).scrollIntoView(),!E||!o)return!0;const b=E.filter(T=>x.includes(T.type.name));t.ensureMarks(b)}return!0},ys=(n,e)=>{const t=Uo(s=>s.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const o=n.doc.nodeAt(r);return t.node.type===o?.type&&Vt(n.doc,t.pos)&&n.join(t.pos),!0},bs=(n,e)=>{const t=Uo(s=>s.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const o=n.doc.nodeAt(r);return t.node.type===o?.type&&Vt(n.doc,r)&&n.join(r),!0},py=(n,e,t,r={})=>({editor:o,tr:s,state:i,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:u,splittableMarks:h}=o.extensionManager,p=me(n,i.schema),f=me(e,i.schema),{selection:m,storedMarks:g}=i,{$from:y,$to:w}=m,x=y.blockRange(w),E=g||m.$to.parentOffset&&m.$from.marks();if(!x)return!1;const b=Uo(T=>Ml(T.type.name,u))(m);if(x.depth>=1&&b&&x.depth-b.depth<=1){if(b.node.type===p)return c.liftListItem(f);if(Ml(b.node.type.name,u)&&p.validContent(b.node.content)&&a)return l().command(()=>(s.setNodeMarkup(b.pos,p),!0)).command(()=>ys(s,p)).command(()=>bs(s,p)).run()}return!t||!E||!a?l().command(()=>d().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>ys(s,p)).command(()=>bs(s,p)).run():l().command(()=>{const T=d().wrapInList(p,r),v=E.filter(S=>h.includes(S.type.name));return s.ensureMarks(v),T?!0:c.clearNodes()}).wrapInList(p,r).command(()=>ys(s,p)).command(()=>bs(s,p)).run()},fy=(n,e={},t={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:s=!1}=t,i=xt(n,r.schema);return Qs(r,i,e)?o.unsetMark(i,{extendEmptyMarkRange:s}):o.setMark(i,e)},my=(n,e,t={})=>({state:r,commands:o})=>{const s=me(n,r.schema),i=me(e,r.schema),a=Pt(r,s,t);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?o.setNode(i,l):o.setNode(s,{...l,...t})},gy=(n,e={})=>({state:t,commands:r})=>{const o=me(n,t.schema);return Pt(t,o,e)?r.lift(o):r.wrapIn(o,e)},yy=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const o=t[r];let s;if(o.spec.isInputRules&&(s=o.getState(n))){if(e){const i=n.tr,a=s.transform;for(let l=a.steps.length-1;l>=0;l-=1)i.step(a.steps[l].invert(a.docs[l]));if(s.text){const l=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,n.schema.text(s.text,l))}else i.delete(s.from,s.to)}return!0}}return!1},by=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:o}=t;return r||e&&o.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},xy=(n,e={})=>({tr:t,state:r,dispatch:o})=>{var s;const{extendEmptyMarkRange:i=!1}=e,{selection:a}=t,l=xt(n,r.schema),{$from:c,empty:d,ranges:u}=a;if(!o)return!0;if(d&&i){let{from:h,to:p}=a;const f=(s=c.marks().find(g=>g.type===l))==null?void 0:s.attrs,m=Vi(c,l,f);m&&(h=m.from,p=m.to),t.removeMark(h,p,l)}else u.forEach(h=>{t.removeMark(h.$from.pos,h.$to.pos,l)});return t.removeStoredMark(l),!0},wy=n=>({tr:e,state:t,dispatch:r})=>{const{selection:o}=t;let s,i;return typeof n=="number"?(s=n,i=n):n&&"from"in n&&"to"in n?(s=n.from,i=n.to):(s=o.from,i=o.to),r&&e.doc.nodesBetween(s,i,(a,l)=>{if(a.isText)return;const c={...a.attrs};delete c.dir,e.setNodeMarkup(l,void 0,c)}),!0},ky=(n,e={})=>({tr:t,state:r,dispatch:o})=>{let s=null,i=null;const a=_o(typeof n=="string"?n:n.name,r.schema);if(!a)return!1;a==="node"&&(s=me(n,r.schema)),a==="mark"&&(i=xt(n,r.schema));let l=!1;return t.selection.ranges.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;let h,p,f,m;t.selection.empty?r.doc.nodesBetween(d,u,(g,y)=>{s&&s===g.type&&(l=!0,f=Math.max(y,d),m=Math.min(y+g.nodeSize,u),h=y,p=g)}):r.doc.nodesBetween(d,u,(g,y)=>{y<d&&s&&s===g.type&&(l=!0,f=Math.max(y,d),m=Math.min(y+g.nodeSize,u),h=y,p=g),y>=d&&y<=u&&(s&&s===g.type&&(l=!0,o&&t.setNodeMarkup(y,void 0,{...g.attrs,...e})),i&&g.marks.length&&g.marks.forEach(w=>{if(i===w.type&&(l=!0,o)){const x=Math.max(y,d),E=Math.min(y+g.nodeSize,u);t.addMark(x,E,i.create({...w.attrs,...e}))}}))}),p&&(h!==void 0&&o&&t.setNodeMarkup(h,void 0,{...p.attrs,...e}),i&&p.marks.length&&p.marks.forEach(g=>{i===g.type&&o&&t.addMark(f,m,i.create({...g.attrs,...e}))}))}),l},vy=(n,e={})=>({state:t,dispatch:r})=>{const o=me(n,t.schema);return tf(o,e)(t,r)},Sy=(n,e={})=>({state:t,dispatch:r})=>{const o=me(n,t.schema);return nf(o,e)(t,r)},Cy=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){const t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},Ko=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},My=(n,e)=>{if(Bi(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Sr(n){var e;const{editor:t,from:r,to:o,text:s,rules:i,plugin:a}=n,{view:l}=t;if(l.composing)return!1;const c=l.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 d=!1;const u=Zg(c)+s;return i.forEach(h=>{if(d)return;const p=My(u,h.find);if(!p)return;const f=l.state.tr,m=Vo({state:l.state,transaction:f}),g={from:r-(p[0].length-s.length),to:o},{commands:y,chain:w,can:x}=new Fo({editor:t,state:m});h.handler({state:m,range:g,match:p,commands:y,chain:w,can:x})===null||!f.steps.length||(h.undoable&&f.setMeta(a,{transform:f,from:r,to:o,text:s}),l.dispatch(f),d=!0)}),d}function Ey(n){const{editor:e,rules:t}=n,r=new le({state:{init(){return null},apply(o,s,i){const a=o.getMeta(r);if(a)return a;const l=o.getMeta("applyInputRules");return l&&setTimeout(()=>{let{text:c}=l;typeof c=="string"?c=c:c=Wi(M.from(c),i.schema);const{from:d}=l,u=d+c.length;Sr({editor:e,from:d,to:u,text:c,rules:t,plugin:r})}),o.selectionSet||o.docChanged?null:s}},props:{handleTextInput(o,s,i,a){return Sr({editor:e,from:s,to:i,text:a,rules:t,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{const{$cursor:s}=o.state.selection;s&&Sr({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(o,s){if(s.key!=="Enter")return!1;const{$cursor:i}=o.state.selection;return i?Sr({editor:e,from:i.pos,to:i.pos,text:`
22
+ `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function Ty(n){return Object.prototype.toString.call(n).slice(8,-1)}function Cr(n){return Ty(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function bu(n,e){const t={...n};return Cr(n)&&Cr(e)&&Object.keys(e).forEach(r=>{Cr(e[r])&&Cr(n[r])?t[r]=bu(n[r],e[r]):t[r]=e[r]}),t}var Ki=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...Q(P(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Q(P(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>bu(this.options,n)});return e.name=this.name,e.parent=this.parent,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},wt=class xu extends Ki{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new xu(t)}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){const s=o.marks();if(!s.find(a=>a?.type.name===t.name))return!1;const i=s.find(a=>a?.type.name===t.name);return i&&r.removeStoredMark(i),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function Ny(n){return typeof n=="number"}var Ay=class{constructor(n){this.find=n.find,this.handler=n.handler}},Oy=(n,e,t)=>{if(Bi(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(o=>{const s=[o.text];return s.index=o.index,s.input=n,s.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(o.replaceWith)),s}):[]};function Ry(n){const{editor:e,state:t,from:r,to:o,rule:s,pasteEvent:i,dropEvent:a}=n,{commands:l,chain:c,can:d}=new Fo({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,o,(h,p)=>{var f,m,g,y,w;if((m=(f=h.type)==null?void 0:f.spec)!=null&&m.code||!(h.isText||h.isTextblock||h.isInline))return;const x=(w=(y=(g=h.content)==null?void 0:g.size)!=null?y:h.nodeSize)!=null?w:0,E=Math.max(r,p),b=Math.min(o,p+x);if(E>=b)return;const T=h.isText?h.text||"":h.textBetween(E-p,b-p,void 0,"");Oy(T,s.find,i).forEach(v=>{if(v.index===void 0)return;const S=E+v.index+1,R=S+v[0].length,K={from:t.tr.mapping.map(S),to:t.tr.mapping.map(R)},$=s.handler({state:t,range:K,match:v,commands:l,chain:c,can:d,pasteEvent:i,dropEvent:a});u.push($)})}),u.every(h=>h!==null)}var Mr=null,Dy=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function jy(n){const{editor:e,rules:t}=n;let r=null,o=!1,s=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:c,from:d,to:u,rule:h,pasteEvt:p})=>{const f=c.tr,m=Vo({state:c,transaction:f});if(!(!Ry({editor:e,state:m,from:Math.max(d-1,0),to:u.b-1,rule:h,pasteEvent:p,dropEvent:a})||!f.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,f}};return t.map(c=>new le({view(d){const u=p=>{var f;r=(f=d.dom.parentElement)!=null&&f.contains(p.target)?d.dom.parentElement:null,r&&(Mr=e)},h=()=>{Mr&&(Mr=null)};return window.addEventListener("dragstart",u),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",u),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,u)=>{if(s=r===d.dom.parentElement,a=u,!s){const h=Mr;h?.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,u)=>{var h;const p=(h=u.clipboardData)==null?void 0:h.getData("text/html");return i=u,o=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(d,u,h)=>{const p=d[0],f=p.getMeta("uiEvent")==="paste"&&!o,m=p.getMeta("uiEvent")==="drop"&&!s,g=p.getMeta("applyPasteRules"),y=!!g;if(!f&&!m&&!y)return;if(y){let{text:E}=g;typeof E=="string"?E=E:E=Wi(M.from(E),h.schema);const{from:b}=g,T=b+E.length,v=Dy(E);return l({rule:c,state:h,from:b,to:{b:T},pasteEvt:v})}const w=u.doc.content.findDiffStart(h.doc.content),x=u.doc.content.findDiffEnd(h.doc.content);if(!(!Ny(w)||!x||w===x.b))return l({rule:c,state:h,from:w,to:x,pasteEvt:i})}}))}var Jo=class{constructor(n,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=n,this.extensions=Ui(n),this.schema=hu(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:gs(e.name,this.schema)},r=P(e,"addCommands",t);return r?{...n,...r()}:n},{})}get plugins(){const{editor:n}=this;return _i([...this.extensions].reverse()).flatMap(e=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:n,type:gs(e.name,this.schema)},r=[],o=P(e,"addKeyboardShortcuts",t);let s={};if(e.type==="mark"&&P(e,"exitable",t)&&(s.ArrowRight=()=>wt.handleExit({editor:n,mark:e})),o){const d=Object.fromEntries(Object.entries(o()).map(([u,h])=>[u,()=>h({editor:n})]));s={...s,...d}}const i=Ym(s);r.push(i);const a=P(e,"addInputRules",t);if(Cl(e,n.options.enableInputRules)&&a){const d=a();if(d&&d.length){const u=Ey({editor:n,rules:d}),h=Array.isArray(u)?u:[u];r.push(...h)}}const l=P(e,"addPasteRules",t);if(Cl(e,n.options.enablePasteRules)&&l){const d=l();if(d&&d.length){const u=jy({editor:n,rules:d});r.push(...u)}}const c=P(e,"addProseMirrorPlugins",t);if(c){const d=c();r.push(...d)}return r})}get attributes(){return uu(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=Rn(this.extensions);return Object.fromEntries(e.filter(t=>!!P(t,"addNodeView")).map(t=>{const r=this.attributes.filter(l=>l.type===t.name),o={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:me(t.name,this.schema)},s=P(t,"addNodeView",o);if(!s)return[];const i=s();if(!i)return[];const a=(l,c,d,u,h)=>{const p=cr(l,r);return i({node:l,view:c,getPos:d,decorations:u,innerDecorations:h,editor:n,extension:t,HTMLAttributes:p})};return[t.name,a]}))}get markViews(){const{editor:n}=this,{markExtensions:e}=Rn(this.extensions);return Object.fromEntries(e.filter(t=>!!P(t,"addMarkView")).map(t=>{const r=this.attributes.filter(a=>a.type===t.name),o={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:xt(t.name,this.schema)},s=P(t,"addMarkView",o);if(!s)return[];const i=(a,l,c)=>{const d=cr(a,r);return s()({mark:a,view:l,inline:c,editor:n,extension:t,HTMLAttributes:d,updateAttributes:u=>{Jy(a,n,u)}})};return[t.name,i]}))}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:gs(e.name,this.schema)};e.type==="mark"&&((t=Q(P(e,"keepOnSplit",r)))==null||t)&&this.splittableMarks.push(e.name);const o=P(e,"onBeforeCreate",r),s=P(e,"onCreate",r),i=P(e,"onUpdate",r),a=P(e,"onSelectionUpdate",r),l=P(e,"onTransaction",r),c=P(e,"onFocus",r),d=P(e,"onBlur",r),u=P(e,"onDestroy",r);o&&this.editor.on("beforeCreate",o),s&&this.editor.on("create",s),i&&this.editor.on("update",i),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}};Jo.resolve=Ui;Jo.sort=_i;Jo.flatten=Fi;var Ly={};Hi(Ly,{ClipboardTextSerializer:()=>ku,Commands:()=>vu,Delete:()=>Su,Drop:()=>Cu,Editable:()=>Mu,FocusEvents:()=>Tu,Keymap:()=>Nu,Paste:()=>Au,Tabindex:()=>Ou,TextDirection:()=>Ru,focusEventsPluginKey:()=>Eu});var te=class wu extends Ki{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new wu(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},ku=te.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new le({key:new he("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:o}=e,{ranges:s}=o,i=Math.min(...s.map(c=>c.$from.pos)),a=Math.max(...s.map(c=>c.$to.pos)),l=fu(t);return pu(r,{from:i,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),vu=te.create({name:"commands",addCommands(){return{...eu}}}),Su=te.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,o;const s=()=>{var i,a,l,c;if((c=(l=(a=(i=this.editor.options.coreExtensionOptions)==null?void 0:i.delete)==null?void 0:a.filterTransaction)==null?void 0:l.call(a,n))!=null?c:n.getMeta("y-sync$"))return;const d=lu(n.before,[n,...e]);gu(d).forEach(h=>{d.mapping.mapResult(h.oldRange.from).deletedAfter&&d.mapping.mapResult(h.oldRange.to).deletedBefore&&d.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,f)=>{const m=f+p.nodeSize-2,g=h.oldRange.from<=f&&m<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:f,to:m,newFrom:d.mapping.map(f),newTo:d.mapping.map(m),deletedRange:h.oldRange,newRange:h.newRange,partial:!g,editor:this.editor,transaction:n,combinedTransform:d})})});const u=d.mapping;d.steps.forEach((h,p)=>{var f,m;if(h instanceof Ze){const g=u.slice(p).map(h.from,-1),y=u.slice(p).map(h.to),w=u.invert().map(g,-1),x=u.invert().map(y),E=(f=d.doc.nodeAt(g-1))==null?void 0:f.marks.some(T=>T.eq(h.mark)),b=(m=d.doc.nodeAt(y))==null?void 0:m.marks.some(T=>T.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:w,to:x},newRange:{from:g,to:y},partial:!!(b||E),editor:this.editor,transaction:n,combinedTransform:d})}})};(o=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||o?setTimeout(s,0):s()}}),Cu=te.create({name:"drop",addProseMirrorPlugins(){return[new le({key:new he("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),Mu=te.create({name:"editable",addProseMirrorPlugins(){return[new le({key:new he("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Eu=new he("focusEvents"),Tu=te.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new le({key:Eu,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Nu=te.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:i})=>{const{selection:a,doc:l}=i,{empty:c,$anchor:d}=a,{pos:u,parent:h}=d,p=d.parent.isTextblock&&u>0?i.doc.resolve(u-1):d,f=p.parent.type.spec.isolating,m=d.pos-d.parentOffset,g=f&&p.parent.childCount===1?m===d.pos:W.atStart(l).from===u;return!c||!h.type.isTextblock||h.textContent.length||!g||g&&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()]),t={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...t},o={...t,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Wo()||iu()?o:r},addProseMirrorPlugins(){return[new le({key:new he("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(p=>p.getMeta("composition")))return;const r=n.some(p=>p.docChanged)&&!e.doc.eq(t.doc),o=n.some(p=>p.getMeta("preventClearDocument"));if(!r||o)return;const{empty:s,from:i,to:a}=e.selection,l=W.atStart(e.doc).from,c=W.atEnd(e.doc).to;if(s||!(i===l&&a===c)||!qo(t.doc))return;const d=t.tr,u=Vo({state:t,transaction:d}),{commands:h}=new Fo({editor:this.editor,state:u});if(h.clearNodes(),!!d.steps.length)return d}})]}}),Au=te.create({name:"paste",addProseMirrorPlugins(){return[new le({key:new he("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Ou=te.create({name:"tabindex",addProseMirrorPlugins(){return[new le({key:new he("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Ru=te.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=Rn(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return t&&(t==="ltr"||t==="rtl"||t==="auto")?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new le({key:new he("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}}),zy=class kn{constructor(e,t,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,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 t=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}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,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),t=this.resolvedPos.doc.resolve(e);return new kn(t,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 kn(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 kn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const o=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,i=this.pos+r+(s?0:1);if(i<0||i>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(i);if(!o&&a.depth<=this.depth)return;const l=new kn(a,this.editor,o,o?t:null);o&&(l.actualDepth=this.depth+1),e.push(new kn(a,this.editor,o,o?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(t).length>0){const s=o.node.attrs,i=Object.keys(t);for(let a=0;a<i.length;a+=1){const l=i[a];if(s[l]!==t[l])break}}else r=o;o=o.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;const s=Object.keys(t);return this.children.forEach(i=>{r&&o.length>0||(i.node.type.name===e&&s.every(a=>t[a]===i.node.attrs[a])&&o.push(i),!(r&&o.length>0)&&(o=o.concat(i.querySelectorAll(e,t,r))))}),o}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},$y=`.ProseMirror {
23
23
  position: relative;
24
24
  }
25
25
 
@@ -89,15 +89,15 @@ img.ProseMirror-separator {
89
89
 
90
90
  .ProseMirror-focused .ProseMirror-gapcursor {
91
91
  display: block;
92
- }`;function $y(n,e,t){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=n,document.getElementsByTagName("head")[0].appendChild(o),o}var Iy=class extends Sy{constructor(n={}){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},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(n),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:s})=>this.options.onDrop(r,o,s)),this.on("paste",({event:r,slice:o})=>this.options.onPaste(r,o)),this.on("delete",this.options.onDelete);const e=this.createDoc(),t=nu(e,this.options.autofocus);this.editorState=Sn.create({doc:e,schema:this.schema,selection:t||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){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(n),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 n=this.editorView.dom;n?.editor&&delete n.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(n){console.warn("Failed to remove CSS element:",n)}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=$y(zy,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),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:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,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(n,e){const t=cu(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;const e=this.state.plugins;let t=e;if([].concat(n).forEach(o=>{const s=typeof o=="string"?`${o}$`:o.key;t=t.filter(i=>!i.key.startsWith(s))}),e.length===t.length)return;const r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e;const t=[...this.options.enableCoreExtensions?[Cu,wu.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),ku,Eu,Tu,Au,Su,Nu,vu,Ou.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new Jo(t,this)}createCommandManager(){this.commandManager=new Fo({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=Ys(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(t=>t.name!=="collaboration"),this.createExtensionManager()}}),n=Ys(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){var e;this.editorView=new Qd(n,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const t=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(t),this.prependClass(),this.injectCSS();const r=this.view.dom;r.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(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(c)});return}const{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),o=t.includes(n),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});const i=t.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),a=i?.getMeta("focus"),l=i?.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:i}),l&&this.emit("blur",{editor:this,event:l.event,transaction:i}),!(n.getMeta("preventUpdate")||!t.some(c=>c.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return fu(this.state,n)}isActive(n,e){const t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return Zg(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Wi(this.state.doc.content,this.schema)}getText(n){const{blockSeparator:e=`
92
+ }`;function Iy(n,e,t){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=n,document.getElementsByTagName("head")[0].appendChild(o),o}var Py=class extends Cy{constructor(n={}){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},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(n),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:s})=>this.options.onDrop(r,o,s)),this.on("paste",({event:r,slice:o})=>this.options.onPaste(r,o)),this.on("delete",this.options.onDelete);const e=this.createDoc(),t=ru(e,this.options.autofocus);this.editorState=Sn.create({doc:e,schema:this.schema,selection:t||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){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(n),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 n=this.editorView.dom;n?.editor&&delete n.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(n){console.warn("Failed to remove CSS element:",n)}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=Iy($y,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),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:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,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(n,e){const t=du(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;const e=this.state.plugins;let t=e;if([].concat(n).forEach(o=>{const s=typeof o=="string"?`${o}$`:o.key;t=t.filter(i=>!i.key.startsWith(s))}),e.length===t.length)return;const r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e;const t=[...this.options.enableCoreExtensions?[Mu,ku.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),vu,Tu,Nu,Ou,Cu,Au,Su,Ru.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new Jo(t,this)}createCommandManager(){this.commandManager=new Fo({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=Ys(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(t=>t.name!=="collaboration"),this.createExtensionManager()}}),n=Ys(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){var e;this.editorView=new Zd(n,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const t=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(t),this.prependClass(),this.injectCSS();const r=this.view.dom;r.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(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(c)});return}const{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),o=t.includes(n),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});const i=t.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),a=i?.getMeta("focus"),l=i?.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:i}),l&&this.emit("blur",{editor:this,event:l.event,transaction:i}),!(n.getMeta("preventUpdate")||!t.some(c=>c.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return mu(this.state,n)}isActive(n,e){const t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return ey(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Wi(this.state.doc.content,this.schema)}getText(n){const{blockSeparator:e=`
93
93
 
94
- `,textSerializers:t={}}=n||{};return Kg(this.state.doc,{blockSeparator:e,textSerializers:{...pu(this.schema),...t}})}get isEmpty(){return qo(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n);return new Ly(e,this)}get $doc(){return this.$pos(0)}};function sn(n){return new Ko({find:n.find,handler:({state:e,range:t,match:r})=>{const o=Q(n.getAttributes,void 0,r);if(o===!1||o===null)return null;const{tr:s}=e,i=r[r.length-1],a=r[0];if(i){const l=a.search(/\S/),c=t.from+a.indexOf(i),d=c+i.length;if(qi(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(p=>p===n.type&&p!==h.mark.type)).filter(h=>h.to>c).length)return null;d<t.to&&s.delete(d,t.to),c>t.from&&s.delete(t.from+l,c);const u=t.from+l+i.length;s.addMark(t.from+l,u,n.type.create(o||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}function Ru(n){return new Ko({find:n.find,handler:({state:e,range:t,match:r})=>{const o=Q(n.getAttributes,void 0,r)||{},{tr:s}=e,i=t.from;let a=t.to;const l=n.type.create(o);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=i+c;d>a?d=a:a=d+r[1].length;const u=r[0][r[0].length-1];s.insertText(u,i+r[0].length-1),s.replaceWith(d,a,l)}else if(r[0]){const c=n.type.isInline?i:i-1;s.insert(c,n.type.create(o)).delete(s.mapping.map(i),s.mapping.map(a))}s.scrollIntoView()},undoable:n.undoable})}function Zs(n){return new Ko({find:n.find,handler:({state:e,range:t,match:r})=>{const o=e.doc.resolve(t.from),s=Q(n.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)},undoable:n.undoable})}function Dn(n){return new Ko({find:n.find,handler:({state:e,range:t,match:r,chain:o})=>{const s=Q(n.getAttributes,void 0,r)||{},i=e.tr.delete(t.from,t.to),a=i.doc.resolve(t.from).blockRange(),l=a&&ki(a,n.type,s);if(!l)return null;if(i.wrap(a,l),n.keepMarks&&n.editor){const{selection:d,storedMarks:u}=e,{splittableMarks:h}=n.editor.extensionManager,p=u||d.$to.parentOffset&&d.$from.marks();if(p){const f=p.filter(m=>h.includes(m.type.name));i.ensureMarks(f)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(d,s).run()}const c=i.doc.resolve(t.from-1).nodeBefore;c&&c.type===n.type&&Vt(i.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,c))&&i.join(t.from-1)},undoable:n.undoable})}var Py=n=>"touches"in n,Hy=class{constructor(n){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=i=>{if(!this.isResizing||!this.activeHandle)return;const a=i.clientX-this.startX,l=i.clientY-this.startY;this.handleResize(a,l)},this.handleTouchMove=i=>{if(!this.isResizing||!this.activeHandle)return;const a=i.touches[0];if(!a)return;const l=a.clientX-this.startX,c=a.clientY-this.startY;this.handleResize(l,c)},this.handleMouseUp=()=>{if(!this.isResizing)return;const i=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(i,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=i=>{i.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=i=>{i.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,t,r,o,s;this.node=n.node,this.element=n.element,this.contentElement=n.contentElement,this.getPos=n.getPos,this.onResize=n.onResize,this.onCommit=n.onCommit,this.onUpdate=n.onUpdate,(e=n.options)!=null&&e.min&&(this.minSize={...this.minSize,...n.options.min}),(t=n.options)!=null&&t.max&&(this.maxSize=n.options.max),(r=n?.options)!=null&&r.directions&&(this.directions=n.options.directions),(o=n.options)!=null&&o.preserveAspectRatio&&(this.preserveAspectRatio=n.options.preserveAspectRatio),(s=n.options)!=null&&s.className&&(this.classNames={container:n.options.className.container||"",wrapper:n.options.className.wrapper||"",handle:n.options.className.handle||"",resizing:n.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(n,e,t){return n.type!==this.node.type?!1:(this.node=n,this.onUpdate?this.onUpdate(n,e,t):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const n=document.createElement("div");return n.dataset.resizeContainer="",n.dataset.node=this.node.type.name,n.style.display="flex",n.style.justifyContent="flex-start",n.style.alignItems="flex-start",this.classNames.container&&(n.className=this.classNames.container),n.appendChild(this.wrapper),n}createWrapper(){const n=document.createElement("div");return n.style.position="relative",n.style.display="block",n.dataset.resizeWrapper="",this.classNames.wrapper&&(n.className=this.classNames.wrapper),n.appendChild(this.element),n}createHandle(n){const e=document.createElement("div");return e.dataset.resizeHandle=n,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(n,e){const t=e.includes("top"),r=e.includes("bottom"),o=e.includes("left"),s=e.includes("right");t&&(n.style.top="0"),r&&(n.style.bottom="0"),o&&(n.style.left="0"),s&&(n.style.right="0"),(e==="top"||e==="bottom")&&(n.style.left="0",n.style.right="0"),(e==="left"||e==="right")&&(n.style.top="0",n.style.bottom="0")}attachHandles(){this.directions.forEach(n=>{const e=this.createHandle(n);this.positionHandle(e,n),e.addEventListener("mousedown",t=>this.handleResizeStart(t,n)),e.addEventListener("touchstart",t=>this.handleResizeStart(t,n)),this.wrapper.appendChild(e)})}applyInitialSize(){const n=this.node.attrs.width,e=this.node.attrs.height;n?(this.element.style.width=`${n}px`,this.initialWidth=n):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(n,e){n.preventDefault(),n.stopPropagation(),this.isResizing=!0,this.activeHandle=e,Py(n)?(this.startX=n.touches[0].clientX,this.startY=n.touches[0].clientY):(this.startX=n.clientX,this.startY=n.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(n,e){if(!this.activeHandle)return;const t=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:o}=this.calculateNewDimensions(this.activeHandle,n,e),s=this.applyConstraints(r,o,t);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(n,e,t){let r=this.startWidth,o=this.startHeight;const s=n.includes("right"),i=n.includes("left"),a=n.includes("bottom"),l=n.includes("top");return s?r=this.startWidth+e:i&&(r=this.startWidth-e),a?o=this.startHeight+t:l&&(o=this.startHeight-t),(n==="right"||n==="left")&&(r=this.startWidth+(s?e:-e)),(n==="top"||n==="bottom")&&(o=this.startHeight+(a?t:-t)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,o,n):{width:r,height:o}}applyConstraints(n,e,t){var r,o,s,i;if(!t){let c=Math.max(this.minSize.width,n),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(c=Math.min(this.maxSize.width,c)),(o=this.maxSize)!=null&&o.height&&(d=Math.min(this.maxSize.height,d)),{width:c,height:d}}let a=n,l=e;return a<this.minSize.width&&(a=this.minSize.width,l=a/this.aspectRatio),l<this.minSize.height&&(l=this.minSize.height,a=l*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&a>this.maxSize.width&&(a=this.maxSize.width,l=a/this.aspectRatio),(i=this.maxSize)!=null&&i.height&&l>this.maxSize.height&&(l=this.maxSize.height,a=l*this.aspectRatio),{width:a,height:l}}applyAspectRatio(n,e,t){return t==="left"||t==="right"?{width:n,height:n/this.aspectRatio}:t==="top"||t==="bottom"?{width:e*this.aspectRatio,height:e}:{width:n,height:n/this.aspectRatio}}};function By(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof I){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let o=r.depth;for(;o>=0;){const s=r.index(o);if(r.node(o).contentMatchAt(s).matchType(e))return!0;o-=1}return!1}var Vy={};Hi(Vy,{createAtomBlockMarkdownSpec:()=>Fy,createBlockMarkdownSpec:()=>Wy,createInlineMarkdownSpec:()=>qy,parseAttributes:()=>Ji,parseIndentedBlocks:()=>ei,renderNestedMarkdownContent:()=>Xi,serializeAttributes:()=>Gi});function Ji(n){if(!n?.trim())return{};const e={},t=[],r=n.replace(/["']([^"']*)["']/g,l=>(t.push(l),`__QUOTED_${t.length-1}__`)),o=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(o){const l=o.map(c=>c.trim().slice(1));e.class=l.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const i=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(i)).forEach(([,l,c])=>{var d;const u=parseInt(((d=c.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),h=t[u];h&&(e[l]=h.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(l=>{l.match(/^[a-zA-Z][\w-]*$/)&&(e[l]=!0)}),e}function Gi(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(t=>e.push(`.${t}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function Fy(n){const{nodeName:e,name:t,parseAttributes:r=Ji,serializeAttributes:o=Gi,defaultAttributes:s={},requiredAttributes:i=[],allowedAttributes:a}=n,l=t||e,c=d=>{if(!a)return d;const u={};return a.forEach(h=>{h in d&&(u[h]=d[h])}),u};return{parseMarkdown:(d,u)=>{const h={...s,...d.attributes};return u.createNode(e,h,[])},markdownTokenizer:{name:e,level:"block",start(d){var u;const h=new RegExp(`^:::${l}(?:\\s|$)`,"m"),p=(u=d.match(h))==null?void 0:u.index;return p!==void 0?p:-1},tokenize(d,u,h){const p=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),f=d.match(p);if(!f)return;const m=f[1]||"",g=r(m);if(!i.find(y=>!(y in g)))return{type:e,raw:f[0],attributes:g}}},renderMarkdown:d=>{const u=c(d.attrs||{}),h=o(u),p=h?` {${h}}`:"";return`:::${l}${p} :::`}}}function Wy(n){const{nodeName:e,name:t,getContent:r,parseAttributes:o=Ji,serializeAttributes:s=Gi,defaultAttributes:i={},content:a="block",allowedAttributes:l}=n,c=t||e,d=u=>{if(!l)return u;const h={};return l.forEach(p=>{p in u&&(h[p]=u[p])}),h};return{parseMarkdown:(u,h)=>{let p;if(r){const m=r(u);p=typeof m=="string"?[{type:"text",text:m}]:m}else a==="block"?p=h.parseChildren(u.tokens||[]):p=h.parseInline(u.tokens||[]);const f={...i,...u.attributes};return h.createNode(e,f,p)},markdownTokenizer:{name:e,level:"block",start(u){var h;const p=new RegExp(`^:::${c}`,"m"),f=(h=u.match(p))==null?void 0:h.index;return f!==void 0?f:-1},tokenize(u,h,p){var f;const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=u.match(m);if(!g)return;const[y,w=""]=g,x=o(w);let E=1;const b=y.length;let T="";const v=/^:::([\w-]*)(\s.*)?/gm,S=u.slice(b);for(v.lastIndex=0;;){const R=v.exec(S);if(R===null)break;const _=R.index,$=R[1];if(!((f=R[2])!=null&&f.endsWith(":::"))){if($)E+=1;else if(E-=1,E===0){const Y=S.slice(0,_);T=Y.trim();const pe=u.slice(0,b+_+R[0].length);let Z=[];if(T)if(a==="block")for(Z=p.blockTokens(Y),Z.forEach(q=>{q.text&&(!q.tokens||q.tokens.length===0)&&(q.tokens=p.inlineTokens(q.text))});Z.length>0;){const q=Z[Z.length-1];if(q.type==="paragraph"&&(!q.text||q.text.trim()===""))Z.pop();else break}else Z=p.inlineTokens(T);return{type:e,raw:pe,attributes:x,content:T,tokens:Z}}}}}},renderMarkdown:(u,h)=>{const p=d(u.attrs||{}),f=s(p),m=f?` {${f}}`:"",g=h.renderChildren(u.content||[],`
94
+ `,textSerializers:t={}}=n||{};return Jg(this.state.doc,{blockSeparator:e,textSerializers:{...fu(this.schema),...t}})}get isEmpty(){return qo(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n);return new zy(e,this)}get $doc(){return this.$pos(0)}};function sn(n){return new Ko({find:n.find,handler:({state:e,range:t,match:r})=>{const o=Q(n.getAttributes,void 0,r);if(o===!1||o===null)return null;const{tr:s}=e,i=r[r.length-1],a=r[0];if(i){const l=a.search(/\S/),c=t.from+a.indexOf(i),d=c+i.length;if(qi(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(p=>p===n.type&&p!==h.mark.type)).filter(h=>h.to>c).length)return null;d<t.to&&s.delete(d,t.to),c>t.from&&s.delete(t.from+l,c);const u=t.from+l+i.length;s.addMark(t.from+l,u,n.type.create(o||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}function Du(n){return new Ko({find:n.find,handler:({state:e,range:t,match:r})=>{const o=Q(n.getAttributes,void 0,r)||{},{tr:s}=e,i=t.from;let a=t.to;const l=n.type.create(o);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=i+c;d>a?d=a:a=d+r[1].length;const u=r[0][r[0].length-1];s.insertText(u,i+r[0].length-1),s.replaceWith(d,a,l)}else if(r[0]){const c=n.type.isInline?i:i-1;s.insert(c,n.type.create(o)).delete(s.mapping.map(i),s.mapping.map(a))}s.scrollIntoView()},undoable:n.undoable})}function Zs(n){return new Ko({find:n.find,handler:({state:e,range:t,match:r})=>{const o=e.doc.resolve(t.from),s=Q(n.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)},undoable:n.undoable})}function Dn(n){return new Ko({find:n.find,handler:({state:e,range:t,match:r,chain:o})=>{const s=Q(n.getAttributes,void 0,r)||{},i=e.tr.delete(t.from,t.to),a=i.doc.resolve(t.from).blockRange(),l=a&&ki(a,n.type,s);if(!l)return null;if(i.wrap(a,l),n.keepMarks&&n.editor){const{selection:d,storedMarks:u}=e,{splittableMarks:h}=n.editor.extensionManager,p=u||d.$to.parentOffset&&d.$from.marks();if(p){const f=p.filter(m=>h.includes(m.type.name));i.ensureMarks(f)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(d,s).run()}const c=i.doc.resolve(t.from-1).nodeBefore;c&&c.type===n.type&&Vt(i.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,c))&&i.join(t.from-1)},undoable:n.undoable})}var Hy=n=>"touches"in n,By=class{constructor(n){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=i=>{if(!this.isResizing||!this.activeHandle)return;const a=i.clientX-this.startX,l=i.clientY-this.startY;this.handleResize(a,l)},this.handleTouchMove=i=>{if(!this.isResizing||!this.activeHandle)return;const a=i.touches[0];if(!a)return;const l=a.clientX-this.startX,c=a.clientY-this.startY;this.handleResize(l,c)},this.handleMouseUp=()=>{if(!this.isResizing)return;const i=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(i,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=i=>{i.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=i=>{i.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,t,r,o,s;this.node=n.node,this.element=n.element,this.contentElement=n.contentElement,this.getPos=n.getPos,this.onResize=n.onResize,this.onCommit=n.onCommit,this.onUpdate=n.onUpdate,(e=n.options)!=null&&e.min&&(this.minSize={...this.minSize,...n.options.min}),(t=n.options)!=null&&t.max&&(this.maxSize=n.options.max),(r=n?.options)!=null&&r.directions&&(this.directions=n.options.directions),(o=n.options)!=null&&o.preserveAspectRatio&&(this.preserveAspectRatio=n.options.preserveAspectRatio),(s=n.options)!=null&&s.className&&(this.classNames={container:n.options.className.container||"",wrapper:n.options.className.wrapper||"",handle:n.options.className.handle||"",resizing:n.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(n,e,t){return n.type!==this.node.type?!1:(this.node=n,this.onUpdate?this.onUpdate(n,e,t):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const n=document.createElement("div");return n.dataset.resizeContainer="",n.dataset.node=this.node.type.name,n.style.display="flex",n.style.justifyContent="flex-start",n.style.alignItems="flex-start",this.classNames.container&&(n.className=this.classNames.container),n.appendChild(this.wrapper),n}createWrapper(){const n=document.createElement("div");return n.style.position="relative",n.style.display="block",n.dataset.resizeWrapper="",this.classNames.wrapper&&(n.className=this.classNames.wrapper),n.appendChild(this.element),n}createHandle(n){const e=document.createElement("div");return e.dataset.resizeHandle=n,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(n,e){const t=e.includes("top"),r=e.includes("bottom"),o=e.includes("left"),s=e.includes("right");t&&(n.style.top="0"),r&&(n.style.bottom="0"),o&&(n.style.left="0"),s&&(n.style.right="0"),(e==="top"||e==="bottom")&&(n.style.left="0",n.style.right="0"),(e==="left"||e==="right")&&(n.style.top="0",n.style.bottom="0")}attachHandles(){this.directions.forEach(n=>{const e=this.createHandle(n);this.positionHandle(e,n),e.addEventListener("mousedown",t=>this.handleResizeStart(t,n)),e.addEventListener("touchstart",t=>this.handleResizeStart(t,n)),this.wrapper.appendChild(e)})}applyInitialSize(){const n=this.node.attrs.width,e=this.node.attrs.height;n?(this.element.style.width=`${n}px`,this.initialWidth=n):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(n,e){n.preventDefault(),n.stopPropagation(),this.isResizing=!0,this.activeHandle=e,Hy(n)?(this.startX=n.touches[0].clientX,this.startY=n.touches[0].clientY):(this.startX=n.clientX,this.startY=n.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(n,e){if(!this.activeHandle)return;const t=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:o}=this.calculateNewDimensions(this.activeHandle,n,e),s=this.applyConstraints(r,o,t);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(n,e,t){let r=this.startWidth,o=this.startHeight;const s=n.includes("right"),i=n.includes("left"),a=n.includes("bottom"),l=n.includes("top");return s?r=this.startWidth+e:i&&(r=this.startWidth-e),a?o=this.startHeight+t:l&&(o=this.startHeight-t),(n==="right"||n==="left")&&(r=this.startWidth+(s?e:-e)),(n==="top"||n==="bottom")&&(o=this.startHeight+(a?t:-t)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,o,n):{width:r,height:o}}applyConstraints(n,e,t){var r,o,s,i;if(!t){let c=Math.max(this.minSize.width,n),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(c=Math.min(this.maxSize.width,c)),(o=this.maxSize)!=null&&o.height&&(d=Math.min(this.maxSize.height,d)),{width:c,height:d}}let a=n,l=e;return a<this.minSize.width&&(a=this.minSize.width,l=a/this.aspectRatio),l<this.minSize.height&&(l=this.minSize.height,a=l*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&a>this.maxSize.width&&(a=this.maxSize.width,l=a/this.aspectRatio),(i=this.maxSize)!=null&&i.height&&l>this.maxSize.height&&(l=this.maxSize.height,a=l*this.aspectRatio),{width:a,height:l}}applyAspectRatio(n,e,t){return t==="left"||t==="right"?{width:n,height:n/this.aspectRatio}:t==="top"||t==="bottom"?{width:e*this.aspectRatio,height:e}:{width:n,height:n/this.aspectRatio}}};function Vy(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof I){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let o=r.depth;for(;o>=0;){const s=r.index(o);if(r.node(o).contentMatchAt(s).matchType(e))return!0;o-=1}return!1}var Fy={};Hi(Fy,{createAtomBlockMarkdownSpec:()=>Wy,createBlockMarkdownSpec:()=>_y,createInlineMarkdownSpec:()=>Ky,parseAttributes:()=>Ji,parseIndentedBlocks:()=>ei,renderNestedMarkdownContent:()=>Xi,serializeAttributes:()=>Gi});function Ji(n){if(!n?.trim())return{};const e={},t=[],r=n.replace(/["']([^"']*)["']/g,l=>(t.push(l),`__QUOTED_${t.length-1}__`)),o=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(o){const l=o.map(c=>c.trim().slice(1));e.class=l.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const i=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(i)).forEach(([,l,c])=>{var d;const u=parseInt(((d=c.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),h=t[u];h&&(e[l]=h.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(l=>{l.match(/^[a-zA-Z][\w-]*$/)&&(e[l]=!0)}),e}function Gi(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(t=>e.push(`.${t}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function Wy(n){const{nodeName:e,name:t,parseAttributes:r=Ji,serializeAttributes:o=Gi,defaultAttributes:s={},requiredAttributes:i=[],allowedAttributes:a}=n,l=t||e,c=d=>{if(!a)return d;const u={};return a.forEach(h=>{h in d&&(u[h]=d[h])}),u};return{parseMarkdown:(d,u)=>{const h={...s,...d.attributes};return u.createNode(e,h,[])},markdownTokenizer:{name:e,level:"block",start(d){var u;const h=new RegExp(`^:::${l}(?:\\s|$)`,"m"),p=(u=d.match(h))==null?void 0:u.index;return p!==void 0?p:-1},tokenize(d,u,h){const p=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),f=d.match(p);if(!f)return;const m=f[1]||"",g=r(m);if(!i.find(y=>!(y in g)))return{type:e,raw:f[0],attributes:g}}},renderMarkdown:d=>{const u=c(d.attrs||{}),h=o(u),p=h?` {${h}}`:"";return`:::${l}${p} :::`}}}function _y(n){const{nodeName:e,name:t,getContent:r,parseAttributes:o=Ji,serializeAttributes:s=Gi,defaultAttributes:i={},content:a="block",allowedAttributes:l}=n,c=t||e,d=u=>{if(!l)return u;const h={};return l.forEach(p=>{p in u&&(h[p]=u[p])}),h};return{parseMarkdown:(u,h)=>{let p;if(r){const m=r(u);p=typeof m=="string"?[{type:"text",text:m}]:m}else a==="block"?p=h.parseChildren(u.tokens||[]):p=h.parseInline(u.tokens||[]);const f={...i,...u.attributes};return h.createNode(e,f,p)},markdownTokenizer:{name:e,level:"block",start(u){var h;const p=new RegExp(`^:::${c}`,"m"),f=(h=u.match(p))==null?void 0:h.index;return f!==void 0?f:-1},tokenize(u,h,p){var f;const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=u.match(m);if(!g)return;const[y,w=""]=g,x=o(w);let E=1;const b=y.length;let T="";const v=/^:::([\w-]*)(\s.*)?/gm,S=u.slice(b);for(v.lastIndex=0;;){const R=v.exec(S);if(R===null)break;const K=R.index,$=R[1];if(!((f=R[2])!=null&&f.endsWith(":::"))){if($)E+=1;else if(E-=1,E===0){const Y=S.slice(0,K);T=Y.trim();const pe=u.slice(0,b+K+R[0].length);let Z=[];if(T)if(a==="block")for(Z=p.blockTokens(Y),Z.forEach(U=>{U.text&&(!U.tokens||U.tokens.length===0)&&(U.tokens=p.inlineTokens(U.text))});Z.length>0;){const U=Z[Z.length-1];if(U.type==="paragraph"&&(!U.text||U.text.trim()===""))Z.pop();else break}else Z=p.inlineTokens(T);return{type:e,raw:pe,attributes:x,content:T,tokens:Z}}}}}},renderMarkdown:(u,h)=>{const p=d(u.attrs||{}),f=s(p),m=f?` {${f}}`:"",g=h.renderChildren(u.content||[],`
95
95
 
96
96
  `);return`:::${c}${m}
97
97
 
98
98
  ${g}
99
99
 
100
- :::`}}}function _y(n){if(!n.trim())return{};const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,o,s,i]=r;e[o]=s||i,r=t.exec(n)}return e}function Uy(n){return Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(" ")}function qy(n){const{nodeName:e,name:t,getContent:r,parseAttributes:o=_y,serializeAttributes:s=Uy,defaultAttributes:i={},selfClosing:a=!1,allowedAttributes:l}=n,c=t||e,d=h=>{if(!l)return h;const p={};return l.forEach(f=>{f in h&&(p[f]=h[f])}),p},u=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(h,p)=>{const f={...i,...h.attributes};if(a)return p.createNode(e,f);const m=r?r(h):h.content||"";return m?p.createNode(e,f,[p.createTextNode(m)]):p.createNode(e,f,[])},markdownTokenizer:{name:e,level:"inline",start(h){const p=a?new RegExp(`\\[${u}\\s*[^\\]]*\\]`):new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`),f=h.match(p),m=f?.index;return m!==void 0?m:-1},tokenize(h,p,f){const m=a?new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`),g=h.match(m);if(!g)return;let y="",w="";if(a){const[,E]=g;w=E}else{const[,E,b]=g;w=E,y=b||""}const x=o(w.trim());return{type:e,raw:g[0],content:y.trim(),attributes:x}}},renderMarkdown:h=>{let p="";r?p=r(h):h.content&&h.content.length>0&&(p=h.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const f=d(h.attrs||{}),m=s(f),g=m?` ${m}`:"";return a?`[${c}${g}]`:`[${c}${g}]${p}[/${c}]`}}}function ei(n,e,t){var r,o,s,i;const a=n.split(`
100
+ :::`}}}function Uy(n){if(!n.trim())return{};const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,o,s,i]=r;e[o]=s||i,r=t.exec(n)}return e}function qy(n){return Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(" ")}function Ky(n){const{nodeName:e,name:t,getContent:r,parseAttributes:o=Uy,serializeAttributes:s=qy,defaultAttributes:i={},selfClosing:a=!1,allowedAttributes:l}=n,c=t||e,d=h=>{if(!l)return h;const p={};return l.forEach(f=>{f in h&&(p[f]=h[f])}),p},u=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(h,p)=>{const f={...i,...h.attributes};if(a)return p.createNode(e,f);const m=r?r(h):h.content||"";return m?p.createNode(e,f,[p.createTextNode(m)]):p.createNode(e,f,[])},markdownTokenizer:{name:e,level:"inline",start(h){const p=a?new RegExp(`\\[${u}\\s*[^\\]]*\\]`):new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`),f=h.match(p),m=f?.index;return m!==void 0?m:-1},tokenize(h,p,f){const m=a?new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`),g=h.match(m);if(!g)return;let y="",w="";if(a){const[,E]=g;w=E}else{const[,E,b]=g;w=E,y=b||""}const x=o(w.trim());return{type:e,raw:g[0],content:y.trim(),attributes:x}}},renderMarkdown:h=>{let p="";r?p=r(h):h.content&&h.content.length>0&&(p=h.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const f=d(h.attrs||{}),m=s(f),g=m?` ${m}`:"";return a?`[${c}${g}]`:`[${c}${g}]${p}[/${c}]`}}}function ei(n,e,t){var r,o,s,i;const a=n.split(`
101
101
  `),l=[];let c="",d=0;const u=e.baseIndentSize||2;for(;d<a.length;){const h=a[d],p=h.match(e.itemPattern);if(!p){if(l.length>0)break;if(h.trim()===""){d+=1,c=`${c}${h}
102
102
  `;continue}else return}const f=e.extractItemData(p),{indentLevel:m,mainContent:g}=f;c=`${c}${h}
103
103
  `;const y=[g];for(d+=1;d<a.length;){const b=a[d];if(b.trim()===""){const T=a.slice(d+1).findIndex(v=>v.trim()!=="");if(T===-1)break;if((((o=(r=a[d+1+T].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:o.length)||0)>m){y.push(b),c=`${c}${b}
@@ -106,15 +106,15 @@ ${g}
106
106
  `);b.trim()&&(e.customNestedParser?w=e.customNestedParser(b):w=t.blockTokens(b))}const E=e.createToken(f,w);l.push(E)}if(l.length!==0)return{items:l,raw:c}}function Xi(n,e,t,r){if(!n||!Array.isArray(n.content))return"";const o=typeof t=="function"?t(r):t,[s,...i]=n.content,a=e.renderChildren([s]),l=[`${o}${a}`];return i&&i.length>0&&i.forEach(c=>{const d=e.renderChildren([c]);if(d){const u=d.split(`
107
107
  `).map(h=>h?e.indent(h):"").join(`
108
108
  `);l.push(u)}}),l.join(`
109
- `)}function Ky(n,e,t={}){const{state:r}=e,{doc:o,tr:s}=r,i=n;o.descendants((a,l)=>{const c=s.mapping.map(l),d=s.mapping.map(l)+a.nodeSize;let u=null;if(a.marks.forEach(p=>{if(p!==i)return!1;u=p}),!u)return;let h=!1;if(Object.keys(t).forEach(p=>{t[p]!==u.attrs[p]&&(h=!0)}),h){const p=n.type.create({...n.attrs,...t});s.removeMark(c,d,n.type),s.addMark(c,d,p)}}),s.docChanged&&e.view.dispatch(s)}var ve=class Du extends Ki{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Du(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Jy=class{constructor(n,e,t){this.isDragging=!1,this.component=n,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(n){var e,t,r,o,s,i,a;const{view:l}=this.editor,c=n.target,d=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(c)||!d)return;let u=0,h=0;if(this.dom!==d){const w=this.dom.getBoundingClientRect(),x=d.getBoundingClientRect(),E=(o=n.offsetX)!=null?o:(r=n.nativeEvent)==null?void 0:r.offsetX,b=(i=n.offsetY)!=null?i:(s=n.nativeEvent)==null?void 0:s.offsetY;u=x.x-w.x+E,h=x.y-w.y+b}const p=this.dom.cloneNode(!0);try{const w=this.dom.getBoundingClientRect();p.style.width=`${Math.round(w.width)}px`,p.style.height=`${Math.round(w.height)}px`,p.style.boxSizing="border-box",p.style.pointerEvents="none"}catch{}let f=null;try{f=document.createElement("div"),f.style.position="absolute",f.style.top="-9999px",f.style.left="-9999px",f.style.pointerEvents="none",f.appendChild(p),document.body.appendChild(f),(a=n.dataTransfer)==null||a.setDragImage(p,u,h)}finally{f&&setTimeout(()=>{try{f?.remove()}catch{}},0)}const m=this.getPos();if(typeof m!="number")return;const g=I.create(l.state.doc,m),y=l.state.tr.setSelection(g);l.dispatch(y)}stopEvent(n){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:n});const t=n.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const r=n.type.startsWith("drag"),o=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!o&&!r)return!0;const{isEditable:s}=this.editor,{isDragging:i}=this,a=!!this.node.type.spec.draggable,l=I.isSelectable(this.node),c=n.type==="copy",d=n.type==="paste",u=n.type==="cut",h=n.type==="mousedown";if(!a&&l&&r&&n.target===this.dom&&n.preventDefault(),a&&r&&!i&&n.target===this.dom)return n.preventDefault(),!1;if(a&&s&&!i&&h){const p=t.closest("[data-drag-handle]");p&&(this.dom===p||this.dom.contains(p))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(i||o||c||d||u||h&&l)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):this.node.isLeaf||this.node.isAtom?!0:n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(Wo()||ru())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(e=>e.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}updateAttributes(n){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...n}),!0)})}deleteNode(){const n=this.getPos();if(typeof n!="number")return;const e=n+this.node.nodeSize;this.editor.commands.deleteRange({from:n,to:e})}};function Ht(n){return new Ny({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:o})=>{const s=Q(n.getAttributes,void 0,r,o);if(s===!1||s===null)return null;const{tr:i}=e,a=r[r.length-1],l=r[0];let c=t.to;if(a){const d=l.search(/\S/),u=t.from+l.indexOf(a),h=u+a.length;if(qi(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(f=>f===n.type&&f!==p.mark.type)).filter(p=>p.to>u).length)return null;h<t.to&&i.delete(h,t.to),u>t.from&&i.delete(t.from+d,u),c=t.from+d+a.length,i.addMark(t.from+d,c,n.type.create(s||{})),i.removeStoredMark(n.type)}}})}var Gy=20,ju=(n,e=0)=>{const t=[];return!n.children.length||e>Gy||Array.from(n.children).forEach(r=>{r.tagName==="SPAN"?t.push(r):r.children.length&&t.push(...ju(r,e+1))}),t},Xy=n=>{if(!n.children.length)return;const e=ju(n);e&&e.forEach(t=>{var r,o;const s=t.getAttribute("style"),i=(o=(r=t.parentElement)==null?void 0:r.closest("span"))==null?void 0:o.getAttribute("style");t.setAttribute("style",`${i};${s}`)})},Lu=wt.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Xy(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",re(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleTextStyle:n=>({commands:e})=>e.toggleMark(this.name,n),removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,r)=>{if(t.isTextblock)return!0;t.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(s=>!!s))||n.removeMark(r,r+t.nodeSize,this.type)}),!0}}}}),Yy=te.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:n=>{var e;const t=n.getAttribute("style");if(t){const r=t.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const s=r[o].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),a=s.slice(1).join(":").trim();if(i==="background-color")return a.replace(/['"]+/g,"")}}}return(e=n.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.backgroundColor?{style:`background-color: ${n.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:n=>({chain:e})=>e().setMark("textStyle",{backgroundColor:n}).run(),unsetBackgroundColor:()=>({chain:n})=>n().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),zu=te.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;const t=n.getAttribute("style");if(t){const r=t.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const s=r[o].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),a=s.slice(1).join(":").trim();if(i==="color")return a.replace(/['"]+/g,"")}}}return(e=n.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Qy=te.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:n=>n.style.fontFamily,renderHTML:n=>n.fontFamily?{style:`font-family: ${n.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:n=>({chain:e})=>e().setMark("textStyle",{fontFamily:n}).run(),unsetFontFamily:()=>({chain:n})=>n().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),Zy=te.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:n=>n.style.fontSize,renderHTML:n=>n.fontSize?{style:`font-size: ${n.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:n=>({chain:e})=>e().setMark("textStyle",{fontSize:n}).run(),unsetFontSize:()=>({chain:n})=>n().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),eb=te.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:n=>n.style.lineHeight,renderHTML:n=>n.lineHeight?{style:`line-height: ${n.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:n=>({chain:e})=>e().setMark("textStyle",{lineHeight:n}).run(),unsetLineHeight:()=>({chain:n})=>n().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});te.create({name:"textStyleKit",addExtensions(){const n=[];return this.options.backgroundColor!==!1&&n.push(Yy.configure(this.options.backgroundColor)),this.options.color!==!1&&n.push(zu.configure(this.options.color)),this.options.fontFamily!==!1&&n.push(Qy.configure(this.options.fontFamily)),this.options.fontSize!==!1&&n.push(Zy.configure(this.options.fontSize)),this.options.lineHeight!==!1&&n.push(eb.configure(this.options.lineHeight)),this.options.textStyle!==!1&&n.push(Lu.configure(this.options.textStyle)),n}});var tb=zu,nb=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,rb=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,ob=wt.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",re(this.options.HTMLAttributes,n),0]},renderMarkdown:(n,e)=>`==${e.renderChildren(n)}==`,parseMarkdown:(n,e)=>e.applyMark("highlight",e.parseInline(n.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:n=>n.indexOf("=="),tokenize(n,e,t){const r=/^(==)([^=]+)(==)/.exec(n);if(r){const o=r[2].trim(),s=t.inlineTokens(o);return{type:"highlight",raw:r[0],text:o,tokens:s}}}},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[sn({find:nb,type:this.type})]},addPasteRules(){return[Ht({find:rb,type:this.type})]}}),sb=ob,ti,ni;if(typeof WeakMap<"u"){let n=new WeakMap;ti=e=>n.get(e),ni=(e,t)=>(n.set(e,t),t)}else{const n=[];let e=0;ti=t=>{for(let r=0;r<n.length;r+=2)if(n[r]==t)return n[r+1]},ni=(t,r)=>(e==10&&(e=0),n[e++]=t,n[e++]=r)}var ue=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,o=e/this.width|0;let s=r+1,i=o+1;for(let a=1;s<this.width&&this.map[e+a]==t;a++)s++;for(let a=1;i<this.height&&this.map[e+this.width*a]==t;a++)i++;return{left:r,top:o,right:s,bottom:i}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:o,top:s,bottom:i}=this.findCell(n);return e=="horiz"?(t<0?r==0:o==this.width)?null:this.map[s*this.width+(t<0?r-1:o)]:(t<0?s==0:i==this.height)?null:this.map[r+this.width*(t<0?s-1:i)]}rectBetween(n,e){const{left:t,right:r,top:o,bottom:s}=this.findCell(n),{left:i,right:a,top:l,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(o,l),right:Math.max(r,a),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let o=n.left;o<n.right;o++){const s=r*this.width+o,i=this.map[s];t[i]||(t[i]=!0,!(o==n.left&&o&&this.map[s-1]==i||r==n.top&&r&&this.map[s-this.width]==i)&&e.push(i))}return e}positionAt(n,e,t){for(let r=0,o=0;;r++){const s=o+t.child(r).nodeSize;if(r==n){let i=e+n*this.width;const a=(n+1)*this.width;for(;i<a&&this.map[i]<o;)i++;return i==a?s-1:this.map[i]}o=s}}static get(n){return ti(n)||ni(n,ib(n))}};function ib(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=ab(n),t=n.childCount,r=[];let o=0,s=null;const i=[];for(let c=0,d=e*t;c<d;c++)r[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let f=0;;f++){for(;o<r.length&&r[o]!=0;)o++;if(f==u.childCount)break;const m=u.child(f),{colspan:g,rowspan:y,colwidth:w}=m.attrs;for(let x=0;x<y;x++){if(x+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:d,n:y-x});break}const E=o+x*e;for(let b=0;b<g;b++){r[E+b]==0?r[E+b]=d:(s||(s=[])).push({type:"collision",row:c,pos:d,n:g-b});const T=w&&w[b];if(T){const v=(E+b)%e*2,S=i[v];S==null||S!=T&&i[v+1]==1?(i[v]=T,i[v+1]=1):S==T&&i[v+1]++}}}o+=g,d+=m.nodeSize}const h=(c+1)*e;let p=0;for(;o<h;)r[o++]==0&&p++;p&&(s||(s=[])).push({type:"missing",row:c,n:p}),d++}(e===0||t===0)&&(s||(s=[])).push({type:"zero_sized"});const a=new ue(e,t,r,s);let l=!1;for(let c=0;!l&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(l=!0);return l&&lb(a,i,n),a}function ab(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const o=n.child(r);let s=0;if(t)for(let i=0;i<r;i++){const a=n.child(i);for(let l=0;l<a.childCount;l++){const c=a.child(l);i+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let i=0;i<o.childCount;i++){const a=o.child(i);s+=a.attrs.colspan,a.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function lb(n,e,t){n.problems||(n.problems=[]);const r={};for(let o=0;o<n.map.length;o++){const s=n.map[o];if(r[s])continue;r[s]=!0;const i=t.nodeAt(s);if(!i)throw new RangeError(`No cell with offset ${s} found`);let a=null;const l=i.attrs;for(let c=0;c<l.colspan;c++){const d=(o+c)%n.width,u=e[d*2];u!=null&&(!l.colwidth||l.colwidth[c]!=u)&&((a||(a=cb(l)))[c]=u)}a&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:a})}}function cb(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Re(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var Nt=new he("selectingCells");function Ln(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function db(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function et(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Go(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Ln(e.$head)||ub(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function ub(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ri(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function hb(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Yi(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function $u(n,e,t){const r=n.node(-1),o=ue.get(r),s=n.start(-1),i=o.nextCell(n.pos-s,e,t);return i==null?null:n.node(0).resolve(s+i)}function an(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Iu(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function pb(n,e,t){const r=Re(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}var ie=class pt extends W{constructor(e,t=e){const r=e.node(-1),o=ue.get(r),s=e.start(-1),i=o.rectBetween(e.pos-s,t.pos-s),a=e.node(0),l=o.cellsInRect(i).filter(d=>d!=t.pos-s);l.unshift(t.pos-s);const c=l.map(d=>{const u=r.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const h=s+d+1;return new od(a.resolve(h),a.resolve(h+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(ri(r)&&ri(o)&&Yi(r,o)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?pt.rowSelection(r,o):s&&this.isColSelection()?pt.colSelection(r,o):new pt(r,o)}return H.between(r,o)}content(){const e=this.$anchorCell.node(-1),t=ue.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},i=[];for(let l=o.top;l<o.bottom;l++){const c=[];for(let d=l*t.width+o.left,u=o.left;u<o.right;u++,d++){const h=t.map[d];if(s[h])continue;s[h]=!0;const p=t.findCell(h);let f=e.nodeAt(h);if(!f)throw RangeError(`No cell with offset ${h} found`);const m=o.left-p.left,g=p.right-o.right;if(m>0||g>0){let y=f.attrs;if(m>0&&(y=an(y,0,m)),g>0&&(y=an(y,y.colspan-g,g)),p.left<o.left){if(f=f.type.createAndFill(y),!f)throw RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else f=f.type.create(y,f.content)}if(p.top<o.top||p.bottom>o.bottom){const y={...f.attrs,rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)};p.top<o.top?f=f.type.createAndFill(y):f=f.type.create(y,f.content)}c.push(f)}i.push(e.child(l).copy(M.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:i;return new O(M.from(a),1,1)}replace(e,t=O.empty){const r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){const{$from:a,$to:l}=o[i],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),i?O.empty:t)}const s=W.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new O(M.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=ue.get(t),o=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let i=0;i<s.length;i++)e(t.nodeAt(s[i]),o+s[i])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),o=ue.get(r),s=e.start(-1),i=o.findCell(e.pos-s),a=o.findCell(t.pos-s),l=e.node(0);return i.top<=a.top?(i.top>0&&(e=l.resolve(s+o.map[i.left])),a.bottom<o.height&&(t=l.resolve(s+o.map[o.width*(o.height-1)+a.right-1]))):(a.top>0&&(t=l.resolve(s+o.map[a.left])),i.bottom<o.height&&(e=l.resolve(s+o.map[o.width*(o.height-1)+i.right-1]))),new pt(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=ue.get(e),r=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-r),s=t.colCount(this.$headCell.pos-r);if(Math.min(o,s)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,a=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,a)==t.width}eq(e){return e instanceof pt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),o=ue.get(r),s=e.start(-1),i=o.findCell(e.pos-s),a=o.findCell(t.pos-s),l=e.node(0);return i.left<=a.left?(i.left>0&&(e=l.resolve(s+o.map[i.top*o.width])),a.right<o.width&&(t=l.resolve(s+o.map[o.width*(a.top+1)-1]))):(a.left>0&&(t=l.resolve(s+o.map[a.top*o.width])),i.right<o.width&&(e=l.resolve(s+o.map[o.width*(i.top+1)-1]))),new pt(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new pt(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new pt(e.resolve(t),e.resolve(r))}getBookmark(){return new fb(this.$anchorCell.pos,this.$headCell.pos)}};ie.prototype.visible=!1;W.jsonID("cell",ie);var fb=class Pu{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Pu(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Yi(t,r)?new ie(t,r):W.near(r,1)}};function mb(n){if(!(n.selection instanceof ie))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(xe.node(r,r+t.nodeSize,{class:"selectedCell"}))}),se.create(n.doc,e)}function gb({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function yb({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){const s=n.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let o=e.depth;o>0;o--){const s=e.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function bb(n,e,t){const r=(e||n).selection,o=(e||n).doc;let s,i;if(r instanceof I&&(i=r.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")s=ie.create(o,r.from);else if(i=="row"){const a=o.resolve(r.from+1);s=ie.rowSelection(a,a)}else if(!t){const a=ue.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];s=ie.create(o,l+1,c)}}else r instanceof H&&gb(r)?s=H.create(o,r.from):r instanceof H&&yb(r)&&(s=H.create(o,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var xb=new he("fix-tables");function Hu(n,e,t,r){const o=n.childCount,s=e.childCount;e:for(let i=0,a=0;i<s;i++){const l=e.child(i);for(let c=a,d=Math.min(o,i+3);c<d;c++)if(n.child(c)==l){a=c+1,t+=l.nodeSize;continue e}r(l,t),a<o&&n.child(a).sameMarkup(l)?Hu(n.child(a),l,t+1,r):l.nodesBetween(0,l.content.size,r,t+1),t+=l.nodeSize}}function Bu(n,e){let t;const r=(o,s)=>{o.type.spec.tableRole=="table"&&(t=wb(n,o,s,t))};return e?e.doc!=n.doc&&Hu(e.doc,n.doc,0,r):n.doc.descendants(r),t}function wb(n,e,t,r){const o=ue.get(e);if(!o.problems)return r;r||(r=n.tr);const s=[];for(let l=0;l<o.height;l++)s.push(0);for(let l=0;l<o.problems.length;l++){const c=o.problems[l];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let h=0;h<u.rowspan;h++)s[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,an(u,u.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(t);r.delete(d,d+e.nodeSize)}}let i,a;for(let l=0;l<s.length;l++)s[l]&&(i==null&&(i=l),a=l);for(let l=0,c=t+1;l<o.height;l++){const d=e.child(l),u=c+d.nodeSize,h=s[l];if(h>0){let p="cell";d.firstChild&&(p=d.firstChild.type.spec.tableRole);const f=[];for(let g=0;g<h;g++){const y=Re(n.schema)[p].createAndFill();y&&f.push(y)}const m=(l==0||i==l-1)&&a==l?c+1:u-1;r.insert(r.mapping.map(m),f)}c=u}return r.setMeta(xb,{fixTables:!0})}function lt(n){const e=n.selection,t=Go(n),r=t.node(-1),o=t.start(-1),s=ue.get(r);return{...e instanceof ie?s.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):s.findCell(t.pos-o),tableStart:o,map:s,table:r}}function Vu(n,{map:e,tableStart:t,table:r},o){let s=o>0?-1:0;pb(e,r,o+s)&&(s=o==0||o==e.width?null:0);for(let i=0;i<e.height;i++){const a=i*e.width+o;if(o>0&&o<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],c=r.nodeAt(l);n.setNodeMarkup(n.mapping.map(t+l),null,Iu(c.attrs,o-e.colCount(l))),i+=c.attrs.rowspan-1}else{const l=s==null?Re(r.type.schema).cell:r.nodeAt(e.map[a+s]).type,c=e.positionAt(i,o,r);n.insert(n.mapping.map(t+c),l.createAndFill())}}return n}function kb(n,e){if(!et(n))return!1;if(e){const t=lt(n);e(Vu(n.tr,t,t.left))}return!0}function vb(n,e){if(!et(n))return!1;if(e){const t=lt(n);e(Vu(n.tr,t,t.right))}return!0}function Sb(n,{map:e,table:t,tableStart:r},o){const s=n.mapping.maps.length;for(let i=0;i<e.height;){const a=i*e.width+o,l=e.map[a],c=t.nodeAt(l),d=c.attrs;if(o>0&&e.map[a-1]==l||o<e.width-1&&e.map[a+1]==l)n.setNodeMarkup(n.mapping.slice(s).map(r+l),null,an(d,o-e.colCount(l)));else{const u=n.mapping.slice(s).map(r+l);n.delete(u,u+c.nodeSize)}i+=d.rowspan}}function Cb(n,e){if(!et(n))return!1;if(e){const t=lt(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;Sb(r,t,o),o!=t.left;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=ue.get(s)}e(r)}return!0}function Mb(n,e,t){var r;const o=Re(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(((r=e.nodeAt(n.map[s+t*n.width]))==null?void 0:r.type)!=o)return!1;return!0}function Fu(n,{map:e,tableStart:t,table:r},o){var s;let i=t;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;const a=[];let l=o>0?-1:0;Mb(e,r,o+l)&&(l=o==0||o==e.height?null:0);for(let c=0,d=e.width*o;c<e.width;c++,d++)if(o>0&&o<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],h=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{const u=l==null?Re(r.type.schema).cell:(s=r.nodeAt(e.map[d+l*e.width]))==null?void 0:s.type,h=u?.createAndFill();h&&a.push(h)}return n.insert(i,Re(r.type.schema).row.create(null,a)),n}function Eb(n,e){if(!et(n))return!1;if(e){const t=lt(n);e(Fu(n.tr,t,t.top))}return!0}function Tb(n,e){if(!et(n))return!1;if(e){const t=lt(n);e(Fu(n.tr,t,t.bottom))}return!0}function Nb(n,{map:e,table:t,tableStart:r},o){let s=0;for(let c=0;c<o;c++)s+=t.child(c).nodeSize;const i=s+t.child(o).nodeSize,a=n.mapping.maps.length;n.delete(s+r,i+r);const l=new Set;for(let c=0,d=o*e.width;c<e.width;c++,d++){const u=e.map[d];if(!l.has(u)){if(l.add(u),o>0&&u==e.map[d-e.width]){const h=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(a).map(u+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(o<e.height&&u==e.map[d+e.width]){const h=t.nodeAt(u),p=h.attrs,f=h.type.create({...p,rowspan:h.attrs.rowspan-1},h.content),m=e.positionAt(o+1,c,t);n.insert(n.mapping.slice(a).map(r+m),f),c+=p.colspan-1}}}}function Ab(n,e){if(!et(n))return!1;if(e){const t=lt(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;Nb(r,t,o),o!=t.top;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=ue.get(t.table)}e(r)}return!0}function El(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Ob({width:n,height:e,map:t},r){let o=r.top*n+r.left,s=o,i=(r.bottom-1)*n+r.left,a=o+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[a]==t[a+1])return!0;s+=n,a+=n}for(let l=r.left;l<r.right;l++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[i]==t[i+n])return!0;o++,i++}return!1}function Tl(n,e){const t=n.selection;if(!(t instanceof ie)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=lt(n),{map:o}=r;if(Ob(o,r))return!1;if(e){const s=n.tr,i={};let a=M.empty,l,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const h=o.map[d*o.width+u],p=r.table.nodeAt(h);if(!(i[h]||!p))if(i[h]=!0,l==null)l=h,c=p;else{El(p)||(a=a.append(p.content));const f=s.mapping.map(h+r.tableStart);s.delete(f,f+p.nodeSize)}}if(l==null||c==null)return!0;if(s.setNodeMarkup(l+r.tableStart,null,{...Iu(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),a.size){const d=l+1+c.content.size,u=El(c)?l+1:d;s.replaceWith(u+r.tableStart,d+r.tableStart,a)}s.setSelection(new ie(s.doc.resolve(l+r.tableStart))),e(s)}return!0}function Nl(n,e){const t=Re(n.schema);return Rb(({node:r})=>t[r.type.spec.tableRole])(n,e)}function Rb(n){return(e,t)=>{var r;const o=e.selection;let s,i;if(o instanceof ie){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;s=o.$anchorCell.nodeAfter,i=o.$anchorCell.pos}else{if(s=db(o.$from),!s)return!1;i=(r=Ln(o.$from))==null?void 0:r.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let a=s.attrs;const l=[],c=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const d=lt(e),u=e.tr;for(let p=0;p<d.right-d.left;p++)l.push(c?{...a,colwidth:c&&c[p]?[c[p]]:null}:a);let h;for(let p=d.top;p<d.bottom;p++){let f=d.map.positionAt(p,d.left,d.table);p==d.top&&(f+=s.nodeSize);for(let m=d.left,g=0;m<d.right;m++,g++)m==d.left&&p==d.top||u.insert(h=u.mapping.map(f+d.tableStart,1),n({node:s,row:p,col:m}).createAndFill(l[g]))}u.setNodeMarkup(i,n({node:s,row:d.top,col:d.left}),l[0]),o instanceof ie&&u.setSelection(new ie(u.doc.resolve(o.$anchorCell.pos),h?u.doc.resolve(h):void 0)),t(u)}return!0}}function Db(n,e){return function(t,r){if(!et(t))return!1;const o=Go(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){const s=t.tr;t.selection instanceof ie?t.selection.forEachCell((i,a)=>{i.attrs[n]!==e&&s.setNodeMarkup(a,null,{...i.attrs,[n]:e})}):s.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[n]:e}),r(s)}return!0}}function jb(n){return function(e,t){if(!et(e))return!1;if(t){const r=Re(e.schema),o=lt(e),s=e.tr,i=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),a=i.map(l=>o.table.nodeAt(l));for(let l=0;l<i.length;l++)a[l].type==r.header_cell&&s.setNodeMarkup(o.tableStart+i[l],r.cell,a[l].attrs);if(s.steps.length==0)for(let l=0;l<i.length;l++)s.setNodeMarkup(o.tableStart+i[l],r.header_cell,a[l].attrs);t(s)}return!0}}function Al(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const s=e.table.nodeAt(r[o]);if(s&&s.type!==t.header_cell)return!1}return!0}function dr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?jb(n):function(t,r){if(!et(t))return!1;if(r){const o=Re(t.schema),s=lt(t),i=t.tr,a=Al("row",s,o),l=Al("column",s,o),c=(n==="column"?a:n==="row"&&l)?1:0,d=n=="column"?{left:0,top:c,right:1,bottom:s.map.height}:n=="row"?{left:c,top:0,right:s.map.width,bottom:1}:s,u=n=="column"?l?o.cell:o.header_cell:n=="row"?a?o.cell:o.header_cell:o.cell;s.map.cellsInRect(d).forEach(h=>{const p=h+s.tableStart,f=i.doc.nodeAt(p);f&&i.setNodeMarkup(p,u,f.attrs)}),r(i)}return!0}}dr("row",{useDeprecatedLogic:!0});dr("column",{useDeprecatedLogic:!0});var Lb=dr("cell",{useDeprecatedLogic:!0});function zb(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){const s=n.node(-1).child(r),i=s.lastChild;if(i)return o-1-i.nodeSize;o-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){const s=t.child(r);if(s.childCount)return o+1;o+=s.nodeSize}}return null}function Ol(n){return function(e,t){if(!et(e))return!1;const r=zb(Go(e),n);if(r==null)return!1;if(t){const o=e.doc.resolve(r);t(e.tr.setSelection(H.between(o,hb(o))).scrollIntoView())}return!0}}function $b(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Er(n,e){const t=n.selection;if(!(t instanceof ie))return!1;if(e){const r=n.tr,o=Re(n.schema).cell.createAndFill().content;t.forEachCell((s,i)=>{s.content.eq(o)||r.replace(r.mapping.map(i+1),r.mapping.map(i+s.nodeSize-1),new O(o,0,0))}),r.docChanged&&e(r)}return!0}function Ib(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const o=e.child(0),s=o.type.spec.tableRole,i=o.type.schema,a=[];if(s=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content;const d=l?0:Math.max(0,t-1),u=l<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=oi(Re(i).row,new O(c,d,u)).content),a.push(c)}else if(s=="cell"||s=="header_cell")a.push(t||r?oi(Re(i).row,new O(e,t,r)).content:e);else return null;return Pb(i,a)}function Pb(n,e){const t=[];for(let o=0;o<e.length;o++){const s=e[o];for(let i=s.childCount-1;i>=0;i--){const{rowspan:a,colspan:l}=s.child(i).attrs;for(let c=o;c<o+a;c++)t[c]=(t[c]||0)+l}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(M.empty),t[o]<r){const s=Re(n).cell.createAndFill(),i=[];for(let a=t[o];a<r;a++)i.push(s);e[o]=e[o].append(M.from(i))}return{height:e.length,width:r,rows:e}}function oi(n,e){const t=n.createAndFill();return new vi(t).replace(0,t.content.size,e).doc}function Hb({width:n,height:e,rows:t},r,o){if(n!=r){const s=[],i=[];for(let a=0;a<t.length;a++){const l=t[a],c=[];for(let d=s[a]||0,u=0;d<r;u++){let h=l.child(u%l.childCount);d+h.attrs.colspan>r&&(h=h.type.createChecked(an(h.attrs,h.attrs.colspan,d+h.attrs.colspan-r),h.content)),c.push(h),d+=h.attrs.colspan;for(let p=1;p<h.attrs.rowspan;p++)s[a+p]=(s[a+p]||0)+h.attrs.colspan}i.push(M.from(c))}t=i,n=r}if(e!=o){const s=[];for(let i=0,a=0;i<o;i++,a++){const l=[],c=t[a%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);i+u.attrs.rowspan>o&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,o-u.attrs.rowspan)},u.content)),l.push(u)}s.push(M.from(l))}t=s,e=o}return{width:n,height:e,rows:t}}function Bb(n,e,t,r,o,s,i){const a=n.doc.type.schema,l=Re(a);let c,d;if(o>e.width)for(let u=0,h=0;u<e.height;u++){const p=t.child(u);h+=p.nodeSize;const f=[];let m;p.lastChild==null||p.lastChild.type==l.cell?m=c||(c=l.cell.createAndFill()):m=d||(d=l.header_cell.createAndFill());for(let g=e.width;g<o;g++)f.push(m);n.insert(n.mapping.slice(i).map(h-1+r),f)}if(s>e.height){const u=[];for(let f=0,m=(e.height-1)*e.width;f<Math.max(e.width,o);f++){const g=f>=e.width?!1:t.nodeAt(e.map[m+f]).type==l.header_cell;u.push(g?d||(d=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const h=l.row.create(null,M.from(u)),p=[];for(let f=e.height;f<s;f++)p.push(h);n.insert(n.mapping.slice(i).map(r+t.nodeSize-2),p)}return!!(c||d)}function Rl(n,e,t,r,o,s,i,a){if(i==0||i==e.height)return!1;let l=!1;for(let c=o;c<s;c++){const d=i*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){l=!0;const h=t.nodeAt(u),{top:p,left:f}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(a).map(u+r),null,{...h.attrs,rowspan:i-p}),n.insert(n.mapping.slice(a).map(e.positionAt(i,f,t)),h.type.createAndFill({...h.attrs,rowspan:p+h.attrs.rowspan-i})),c+=h.attrs.colspan-1}}return l}function Dl(n,e,t,r,o,s,i,a){if(i==0||i==e.width)return!1;let l=!1;for(let c=o;c<s;c++){const d=c*e.width+i,u=e.map[d];if(e.map[d-1]==u){l=!0;const h=t.nodeAt(u),p=e.colCount(u),f=n.mapping.slice(a).map(u+r);n.setNodeMarkup(f,null,an(h.attrs,i-p,h.attrs.colspan-(i-p))),n.insert(f+h.nodeSize,h.type.createAndFill(an(h.attrs,0,i-p))),c+=h.attrs.rowspan-1}}return l}function jl(n,e,t,r,o){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let i=ue.get(s);const{top:a,left:l}=r,c=l+o.width,d=a+o.height,u=n.tr;let h=0;function p(){if(s=t?u.doc.nodeAt(t-1):u.doc,!s)throw new Error("No table found");i=ue.get(s),h=u.mapping.maps.length}Bb(u,i,s,t,c,d,h)&&p(),Rl(u,i,s,t,l,c,a,h)&&p(),Rl(u,i,s,t,l,c,d,h)&&p(),Dl(u,i,s,t,a,d,l,h)&&p(),Dl(u,i,s,t,a,d,c,h)&&p();for(let f=a;f<d;f++){const m=i.positionAt(f,l,s),g=i.positionAt(f,c,s);u.replace(u.mapping.slice(h).map(m+t),u.mapping.slice(h).map(g+t),new O(o.rows[f-a],0,0))}p(),u.setSelection(new ie(u.doc.resolve(t+i.positionAt(a,l,s)),u.doc.resolve(t+i.positionAt(d-1,c-1,s)))),e(u)}var Vb=Pi({ArrowLeft:Tr("horiz",-1),ArrowRight:Tr("horiz",1),ArrowUp:Tr("vert",-1),ArrowDown:Tr("vert",1),"Shift-ArrowLeft":Nr("horiz",-1),"Shift-ArrowRight":Nr("horiz",1),"Shift-ArrowUp":Nr("vert",-1),"Shift-ArrowDown":Nr("vert",1),Backspace:Er,"Mod-Backspace":Er,Delete:Er,"Mod-Delete":Er});function Hr(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Tr(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;if(s instanceof ie)return Hr(t,r,W.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const i=Wu(o,n,e);if(i==null)return!1;if(n=="horiz")return Hr(t,r,W.near(t.doc.resolve(s.head+e),e));{const a=t.doc.resolve(i),l=$u(a,n,e);let c;return l?c=W.near(l,1):e<0?c=W.near(t.doc.resolve(a.before(-1)),-1):c=W.near(t.doc.resolve(a.after(-1)),1),Hr(t,r,c)}}}function Nr(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;let i;if(s instanceof ie)i=s;else{const l=Wu(o,n,e);if(l==null)return!1;i=new ie(t.doc.resolve(l))}const a=$u(i.$headCell,n,e);return a?Hr(t,r,new ie(i.$anchorCell,a)):!1}}function Fb(n,e){const t=n.state.doc,r=Ln(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new ie(r))),!0):!1}function Wb(n,e,t){if(!et(n.state))return!1;let r=Ib(t);const o=n.state.selection;if(o instanceof ie){r||(r={width:1,height:1,rows:[M.from(oi(Re(n.state.schema).cell,t))]});const s=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),a=ue.get(s).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=Hb(r,a.right-a.left,a.bottom-a.top),jl(n.state,n.dispatch,i,a,r),!0}else if(r){const s=Go(n.state),i=s.start(-1);return jl(n.state,n.dispatch,i,ue.get(s.node(-1)).findCell(s.pos-i),r),!0}else return!1}function _b(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Ll(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof ie)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Ln(n.state.selection.$anchor))!=null&&((t=xs(n,e))==null?void 0:t.pos)!=o.pos)s(o,e),e.preventDefault();else if(!r)return;function s(l,c){let d=xs(n,c);const u=Nt.getState(n.state)==null;if(!d||!Yi(l,d))if(u)d=l;else return;const h=new ie(l,d);if(u||!n.state.selection.eq(h)){const p=n.state.tr.setSelection(h);u&&p.setMeta(Nt,l.pos),n.dispatch(p)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",a),Nt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Nt,-1))}function a(l){const c=l,d=Nt.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(Ll(n,c.target)!=r&&(u=xs(n,e),!u))return i();u&&s(u,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",a)}function Wu(n,e,t){if(!(n.state.selection instanceof H))return null;const{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){const s=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const i=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?i:null}}return null}function Ll(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function xs(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Ln(n.state.doc.resolve(t.pos)):null}var Ub=class{constructor(n,e){this.node=n,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),si(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!=this.node.type?!1:(this.node=n,si(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function si(n,e,t,r,o,s){var i;let a=0,l=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let u=0,h=0;u<d.childCount;u++){const{colspan:p,colwidth:f}=d.child(u).attrs;for(let m=0;m<p;m++,h++){const g=o==h?s:f&&f[m],y=g?g+"px":"";if(a+=g||r,g||(l=!1),c)c.style.width!=y&&(c.style.width=y),c=c.nextSibling;else{const w=document.createElement("col");w.style.width=y,e.appendChild(w)}}}for(;c;){const u=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=u}l?(t.style.width=a+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=a+"px")}}var Fe=new he("tableColumnResizing");function qb({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=Ub,lastColumnResizable:o=!0}={}){const s=new le({key:Fe,state:{init(i,a){var l,c;const d=(c=(l=s.spec)==null?void 0:l.props)==null?void 0:c.nodeViews,u=Re(a.schema).table.name;return r&&d&&(d[u]=(h,p)=>new r(h,t,p)),new Kb(-1,!1)},apply(i,a){return a.apply(i)}},props:{attributes:i=>{const a=Fe.getState(i);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(i,a)=>{Jb(i,a,n,o)},mouseleave:i=>{Gb(i)},mousedown:(i,a)=>{Xb(i,a,e,t)}},decorations:i=>{const a=Fe.getState(i);if(a&&a.activeHandle>-1)return t0(i,a.activeHandle)},nodeViews:{}}});return s}var Kb=class Br{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(Fe);if(r&&r.setHandle!=null)return new Br(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Br(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return ri(e.doc.resolve(o))||(o=-1),new Br(o,t.dragging)}return t}};function Jb(n,e,t,r){if(!n.editable)return;const o=Fe.getState(n.state);if(o&&!o.dragging){const s=Qb(e.target);let i=-1;if(s){const{left:a,right:l}=s.getBoundingClientRect();e.clientX-a<=t?i=zl(n,e,"left",t):l-e.clientX<=t&&(i=zl(n,e,"right",t))}if(i!=o.activeHandle){if(!r&&i!==-1){const a=n.state.doc.resolve(i),l=a.node(-1),c=ue.get(l),d=a.start(-1);if(c.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==c.width-1)return}_u(n,i)}}}function Gb(n){if(!n.editable)return;const e=Fe.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&_u(n,-1)}function Xb(n,e,t,r){var o;if(!n.editable)return!1;const s=(o=n.dom.ownerDocument.defaultView)!=null?o:window,i=Fe.getState(n.state);if(!i||i.activeHandle==-1||i.dragging)return!1;const a=n.state.doc.nodeAt(i.activeHandle),l=Yb(n,i.activeHandle,a.attrs);n.dispatch(n.state.tr.setMeta(Fe,{setDragging:{startX:e.clientX,startWidth:l}}));function c(u){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",d);const h=Fe.getState(n.state);h?.dragging&&(Zb(n,h.activeHandle,$l(h.dragging,u,t)),n.dispatch(n.state.tr.setMeta(Fe,{setDragging:null})))}function d(u){if(!u.which)return c(u);const h=Fe.getState(n.state);if(h&&h.dragging){const p=$l(h.dragging,u,t);Il(n,h.activeHandle,p,r)}}return Il(n,i.activeHandle,l,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",d),e.preventDefault(),!0}function Yb(n,e,{colspan:t,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const s=n.domAtPos(e);let i=s.node.childNodes[s.offset].offsetWidth,a=t;if(r)for(let l=0;l<t;l++)r[l]&&(i-=r[l],a--);return i/a}function Qb(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function zl(n,e,t,r){const o=t=="right"?-r:r,s=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!s)return-1;const{pos:i}=s,a=Ln(n.state.doc.resolve(i));if(!a)return-1;if(t=="right")return a.pos;const l=ue.get(a.node(-1)),c=a.start(-1),d=l.map.indexOf(a.pos-c);return d%l.width==0?-1:c+l.map[d-1]}function $l(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function _u(n,e){n.dispatch(n.state.tr.setMeta(Fe,{setHandle:e}))}function Zb(n,e,t){const r=n.state.doc.resolve(e),o=r.node(-1),s=ue.get(o),i=r.start(-1),a=s.colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1,l=n.state.tr;for(let c=0;c<s.height;c++){const d=c*s.width+a;if(c&&s.map[d]==s.map[d-s.width])continue;const u=s.map[d],h=o.nodeAt(u).attrs,p=h.colspan==1?0:a-s.colCount(u);if(h.colwidth&&h.colwidth[p]==t)continue;const f=h.colwidth?h.colwidth.slice():e0(h.colspan);f[p]=t,l.setNodeMarkup(i+u,null,{...h,colwidth:f})}l.docChanged&&n.dispatch(l)}function Il(n,e,t,r){const o=n.state.doc.resolve(e),s=o.node(-1),i=o.start(-1),a=ue.get(s).colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1;let l=n.domAtPos(o.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&si(s,l.firstChild,l,r,a,t)}function e0(n){return Array(n).fill(0)}function t0(n,e){var t;const r=[],o=n.doc.resolve(e),s=o.node(-1);if(!s)return se.empty;const i=ue.get(s),a=o.start(-1),l=i.colCount(o.pos-a)+o.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const d=l+c*i.width;if((l==i.width-1||i.map[d]!=i.map[d+1])&&(c==0||i.map[d]!=i.map[d-i.width])){const u=i.map[d],h=a+u+s.nodeAt(u).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",(t=Fe.getState(n))!=null&&t.dragging&&r.push(xe.node(a+u,a+u+s.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),r.push(xe.widget(h,p))}}return se.create(n.doc,r)}function n0({allowTableNodeSelection:n=!1}={}){return new le({key:Nt,state:{init(){return null},apply(e,t){const r=e.getMeta(Nt);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:o,pos:s}=e.mapping.mapResult(t);return o?null:s}},props:{decorations:mb,handleDOMEvents:{mousedown:_b},createSelectionBetween(e){return Nt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Fb,handleKeyDown:Vb,handlePaste:Wb},appendTransaction(e,t,r){return bb(r,Bu(r,t),n)}})}var Uu=ve.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{var e,t;const r=n.getAttribute("colwidth"),o=r?r.split(",").map(s=>parseInt(s,10)):null;if(!o){const s=(e=n.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),i=Array.from(((t=n.parentElement)==null?void 0:t.children)||[]).indexOf(n);if(i&&i>-1&&s&&s[i]){const a=s[i].getAttribute("width");return a?[parseInt(a,10)]:null}}return o}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",re(this.options.HTMLAttributes,n),0]}}),qu=ve.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(t=>parseInt(t,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",re(this.options.HTMLAttributes,n),0]}}),Ku=ve.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",re(this.options.HTMLAttributes,n),0]}});function ii(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function Pl(n,e,t,r,o,s){var i;let a=0,l=!0,c=e.firstChild;const d=n.firstChild;if(d!==null)for(let h=0,p=0;h<d.childCount;h+=1){const{colspan:f,colwidth:m}=d.child(h).attrs;for(let g=0;g<f;g+=1,p+=1){const y=o===p?s:m&&m[g],w=y?`${y}px`:"";if(a+=y||r,y||(l=!1),c){if(c.style.width!==w){const[x,E]=ii(r,y);c.style.setProperty(x,E)}c=c.nextSibling}else{const x=document.createElement("col"),[E,b]=ii(r,y);x.style.setProperty(E,b),e.appendChild(x)}}}for(;c;){const h=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=h}const u=n.attrs.style&&typeof n.attrs.style=="string"&&/\bwidth\s*:/i.test(n.attrs.style);l&&!u?(t.style.width=`${a}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${a}px`)}var r0=class{constructor(n,e){this.node=n,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),n.attrs.style&&(this.table.style.cssText=n.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Pl(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!==this.node.type?!1:(this.node=n,Pl(n,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(n){const e=n.target,t=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(t&&!r&&(n.type==="attributes"||n.type==="childList"||n.type==="characterData"))}};function o0(n,e,t,r){let o=0,s=!0;const i=[],a=n.firstChild;if(!a)return{};for(let d=0,u=0;d<a.childCount;d+=1){const{colspan:h,colwidth:p}=a.child(d).attrs;for(let f=0;f<h;f+=1,u+=1){const m=t===u?r:p&&p[f];o+=m||e,m||(s=!1);const[g,y]=ii(e,m);i.push(["col",{style:`${g}: ${y}`}])}}const l=s?`${o}px`:"",c=s?"":`${o}px`;return{colgroup:["colgroup",{},...i],tableWidth:l,tableMinWidth:c}}function Hl(n,e){return n.createAndFill()}function s0(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function i0(n,e,t,r,o){const s=s0(n),i=[],a=[];for(let c=0;c<t;c+=1){const d=Hl(s.cell);if(d&&a.push(d),r){const u=Hl(s.header_cell);u&&i.push(u)}}const l=[];for(let c=0;c<e;c+=1)l.push(s.row.createChecked(null,r&&c===0?i:a));return s.table.createChecked(null,l)}function a0(n){return n instanceof ie}var Ar=({editor:n})=>{const{selection:e}=n.state;if(!a0(e))return!1;let t=0;return lu(e.ranges[0].$from,o=>o.type.name==="table")?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},l0="";function c0(n){return(n||"").replace(/\s+/g," ").trim()}function d0(n,e,t={}){var r;const o=(r=t.cellLineSeparator)!=null?r:l0;if(!n||!n.content||n.content.length===0)return"";const s=[];n.content.forEach(p=>{const f=[];p.content&&p.content.forEach(m=>{let g="";m.content&&Array.isArray(m.content)&&m.content.length>1?g=m.content.map(x=>e.renderChildren(x)).join(o):g=m.content?e.renderChildren(m.content):"";const y=c0(g),w=m.type==="tableHeader";f.push({text:y,isHeader:w})}),s.push(f)});const i=s.reduce((p,f)=>Math.max(p,f.length),0);if(i===0)return"";const a=new Array(i).fill(0);s.forEach(p=>{var f;for(let m=0;m<i;m+=1){const g=(((f=p[m])==null?void 0:f.text)||"").length;g>a[m]&&(a[m]=g),a[m]<3&&(a[m]=3)}});const l=(p,f)=>p+" ".repeat(Math.max(0,f-p.length)),c=s[0],d=c.some(p=>p.isHeader);let u=`
109
+ `)}function Jy(n,e,t={}){const{state:r}=e,{doc:o,tr:s}=r,i=n;o.descendants((a,l)=>{const c=s.mapping.map(l),d=s.mapping.map(l)+a.nodeSize;let u=null;if(a.marks.forEach(p=>{if(p!==i)return!1;u=p}),!u)return;let h=!1;if(Object.keys(t).forEach(p=>{t[p]!==u.attrs[p]&&(h=!0)}),h){const p=n.type.create({...n.attrs,...t});s.removeMark(c,d,n.type),s.addMark(c,d,p)}}),s.docChanged&&e.view.dispatch(s)}var ve=class ju extends Ki{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new ju(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Gy=class{constructor(n,e,t){this.isDragging=!1,this.component=n,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...t},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(n){var e,t,r,o,s,i,a;const{view:l}=this.editor,c=n.target,d=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(t=this.contentDOM)!=null&&t.contains(c)||!d)return;let u=0,h=0;if(this.dom!==d){const w=this.dom.getBoundingClientRect(),x=d.getBoundingClientRect(),E=(o=n.offsetX)!=null?o:(r=n.nativeEvent)==null?void 0:r.offsetX,b=(i=n.offsetY)!=null?i:(s=n.nativeEvent)==null?void 0:s.offsetY;u=x.x-w.x+E,h=x.y-w.y+b}const p=this.dom.cloneNode(!0);try{const w=this.dom.getBoundingClientRect();p.style.width=`${Math.round(w.width)}px`,p.style.height=`${Math.round(w.height)}px`,p.style.boxSizing="border-box",p.style.pointerEvents="none"}catch{}let f=null;try{f=document.createElement("div"),f.style.position="absolute",f.style.top="-9999px",f.style.left="-9999px",f.style.pointerEvents="none",f.appendChild(p),document.body.appendChild(f),(a=n.dataTransfer)==null||a.setDragImage(p,u,h)}finally{f&&setTimeout(()=>{try{f?.remove()}catch{}},0)}const m=this.getPos();if(typeof m!="number")return;const g=I.create(l.state.doc,m),y=l.state.tr.setSelection(g);l.dispatch(y)}stopEvent(n){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:n});const t=n.target;if(!(this.dom.contains(t)&&!((e=this.contentDOM)!=null&&e.contains(t))))return!1;const r=n.type.startsWith("drag"),o=n.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(t.tagName)||t.isContentEditable)&&!o&&!r)return!0;const{isEditable:s}=this.editor,{isDragging:i}=this,a=!!this.node.type.spec.draggable,l=I.isSelectable(this.node),c=n.type==="copy",d=n.type==="paste",u=n.type==="cut",h=n.type==="mousedown";if(!a&&l&&r&&n.target===this.dom&&n.preventDefault(),a&&r&&!i&&n.target===this.dom)return n.preventDefault(),!1;if(a&&s&&!i&&h){const p=t.closest("[data-drag-handle]");p&&(this.dom===p||this.dom.contains(p))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(i||o||c||d||u||h&&l)}ignoreMutation(n){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:n}):this.node.isLeaf||this.node.isAtom?!0:n.type==="selection"||this.dom.contains(n.target)&&n.type==="childList"&&(Wo()||ou())&&this.editor.isFocused&&[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].every(e=>e.isContentEditable)?!1:this.contentDOM===n.target&&n.type==="attributes"?!0:!this.contentDOM.contains(n.target)}updateAttributes(n){this.editor.commands.command(({tr:e})=>{const t=this.getPos();return typeof t!="number"?!1:(e.setNodeMarkup(t,void 0,{...this.node.attrs,...n}),!0)})}deleteNode(){const n=this.getPos();if(typeof n!="number")return;const e=n+this.node.nodeSize;this.editor.commands.deleteRange({from:n,to:e})}};function Ht(n){return new Ay({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:o})=>{const s=Q(n.getAttributes,void 0,r,o);if(s===!1||s===null)return null;const{tr:i}=e,a=r[r.length-1],l=r[0];let c=t.to;if(a){const d=l.search(/\S/),u=t.from+l.indexOf(a),h=u+a.length;if(qi(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(f=>f===n.type&&f!==p.mark.type)).filter(p=>p.to>u).length)return null;h<t.to&&i.delete(h,t.to),u>t.from&&i.delete(t.from+d,u),c=t.from+d+a.length,i.addMark(t.from+d,c,n.type.create(s||{})),i.removeStoredMark(n.type)}}})}var Xy=20,Lu=(n,e=0)=>{const t=[];return!n.children.length||e>Xy||Array.from(n.children).forEach(r=>{r.tagName==="SPAN"?t.push(r):r.children.length&&t.push(...Lu(r,e+1))}),t},Yy=n=>{if(!n.children.length)return;const e=Lu(n);e&&e.forEach(t=>{var r,o;const s=t.getAttribute("style"),i=(o=(r=t.parentElement)==null?void 0:r.closest("span"))==null?void 0:o.getAttribute("style");t.setAttribute("style",`${i};${s}`)})},zu=wt.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Yy(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",re(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleTextStyle:n=>({commands:e})=>e.toggleMark(this.name,n),removeEmptyTextStyle:()=>({tr:n})=>{const{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,r)=>{if(t.isTextblock)return!0;t.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(s=>!!s))||n.removeMark(r,r+t.nodeSize,this.type)}),!0}}}}),Qy=te.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:n=>{var e;const t=n.getAttribute("style");if(t){const r=t.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const s=r[o].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),a=s.slice(1).join(":").trim();if(i==="background-color")return a.replace(/['"]+/g,"")}}}return(e=n.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.backgroundColor?{style:`background-color: ${n.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:n=>({chain:e})=>e().setMark("textStyle",{backgroundColor:n}).run(),unsetBackgroundColor:()=>({chain:n})=>n().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),$u=te.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;const t=n.getAttribute("style");if(t){const r=t.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const s=r[o].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),a=s.slice(1).join(":").trim();if(i==="color")return a.replace(/['"]+/g,"")}}}return(e=n.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Zy=te.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:n=>n.style.fontFamily,renderHTML:n=>n.fontFamily?{style:`font-family: ${n.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:n=>({chain:e})=>e().setMark("textStyle",{fontFamily:n}).run(),unsetFontFamily:()=>({chain:n})=>n().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),eb=te.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:n=>n.style.fontSize,renderHTML:n=>n.fontSize?{style:`font-size: ${n.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:n=>({chain:e})=>e().setMark("textStyle",{fontSize:n}).run(),unsetFontSize:()=>({chain:n})=>n().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),tb=te.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:n=>n.style.lineHeight,renderHTML:n=>n.lineHeight?{style:`line-height: ${n.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:n=>({chain:e})=>e().setMark("textStyle",{lineHeight:n}).run(),unsetLineHeight:()=>({chain:n})=>n().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});te.create({name:"textStyleKit",addExtensions(){const n=[];return this.options.backgroundColor!==!1&&n.push(Qy.configure(this.options.backgroundColor)),this.options.color!==!1&&n.push($u.configure(this.options.color)),this.options.fontFamily!==!1&&n.push(Zy.configure(this.options.fontFamily)),this.options.fontSize!==!1&&n.push(eb.configure(this.options.fontSize)),this.options.lineHeight!==!1&&n.push(tb.configure(this.options.lineHeight)),this.options.textStyle!==!1&&n.push(zu.configure(this.options.textStyle)),n}});var nb=$u,rb=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,ob=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,sb=wt.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",re(this.options.HTMLAttributes,n),0]},renderMarkdown:(n,e)=>`==${e.renderChildren(n)}==`,parseMarkdown:(n,e)=>e.applyMark("highlight",e.parseInline(n.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:n=>n.indexOf("=="),tokenize(n,e,t){const r=/^(==)([^=]+)(==)/.exec(n);if(r){const o=r[2].trim(),s=t.inlineTokens(o);return{type:"highlight",raw:r[0],text:o,tokens:s}}}},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[sn({find:rb,type:this.type})]},addPasteRules(){return[Ht({find:ob,type:this.type})]}}),ib=sb,ti,ni;if(typeof WeakMap<"u"){let n=new WeakMap;ti=e=>n.get(e),ni=(e,t)=>(n.set(e,t),t)}else{const n=[];let e=0;ti=t=>{for(let r=0;r<n.length;r+=2)if(n[r]==t)return n[r+1]},ni=(t,r)=>(e==10&&(e=0),n[e++]=t,n[e++]=r)}var ue=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,o=e/this.width|0;let s=r+1,i=o+1;for(let a=1;s<this.width&&this.map[e+a]==t;a++)s++;for(let a=1;i<this.height&&this.map[e+this.width*a]==t;a++)i++;return{left:r,top:o,right:s,bottom:i}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:o,top:s,bottom:i}=this.findCell(n);return e=="horiz"?(t<0?r==0:o==this.width)?null:this.map[s*this.width+(t<0?r-1:o)]:(t<0?s==0:i==this.height)?null:this.map[r+this.width*(t<0?s-1:i)]}rectBetween(n,e){const{left:t,right:r,top:o,bottom:s}=this.findCell(n),{left:i,right:a,top:l,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(o,l),right:Math.max(r,a),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let o=n.left;o<n.right;o++){const s=r*this.width+o,i=this.map[s];t[i]||(t[i]=!0,!(o==n.left&&o&&this.map[s-1]==i||r==n.top&&r&&this.map[s-this.width]==i)&&e.push(i))}return e}positionAt(n,e,t){for(let r=0,o=0;;r++){const s=o+t.child(r).nodeSize;if(r==n){let i=e+n*this.width;const a=(n+1)*this.width;for(;i<a&&this.map[i]<o;)i++;return i==a?s-1:this.map[i]}o=s}}static get(n){return ti(n)||ni(n,ab(n))}};function ab(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=lb(n),t=n.childCount,r=[];let o=0,s=null;const i=[];for(let c=0,d=e*t;c<d;c++)r[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let f=0;;f++){for(;o<r.length&&r[o]!=0;)o++;if(f==u.childCount)break;const m=u.child(f),{colspan:g,rowspan:y,colwidth:w}=m.attrs;for(let x=0;x<y;x++){if(x+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:d,n:y-x});break}const E=o+x*e;for(let b=0;b<g;b++){r[E+b]==0?r[E+b]=d:(s||(s=[])).push({type:"collision",row:c,pos:d,n:g-b});const T=w&&w[b];if(T){const v=(E+b)%e*2,S=i[v];S==null||S!=T&&i[v+1]==1?(i[v]=T,i[v+1]=1):S==T&&i[v+1]++}}}o+=g,d+=m.nodeSize}const h=(c+1)*e;let p=0;for(;o<h;)r[o++]==0&&p++;p&&(s||(s=[])).push({type:"missing",row:c,n:p}),d++}(e===0||t===0)&&(s||(s=[])).push({type:"zero_sized"});const a=new ue(e,t,r,s);let l=!1;for(let c=0;!l&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(l=!0);return l&&cb(a,i,n),a}function lb(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const o=n.child(r);let s=0;if(t)for(let i=0;i<r;i++){const a=n.child(i);for(let l=0;l<a.childCount;l++){const c=a.child(l);i+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let i=0;i<o.childCount;i++){const a=o.child(i);s+=a.attrs.colspan,a.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function cb(n,e,t){n.problems||(n.problems=[]);const r={};for(let o=0;o<n.map.length;o++){const s=n.map[o];if(r[s])continue;r[s]=!0;const i=t.nodeAt(s);if(!i)throw new RangeError(`No cell with offset ${s} found`);let a=null;const l=i.attrs;for(let c=0;c<l.colspan;c++){const d=(o+c)%n.width,u=e[d*2];u!=null&&(!l.colwidth||l.colwidth[c]!=u)&&((a||(a=db(l)))[c]=u)}a&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:a})}}function db(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Re(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var Nt=new he("selectingCells");function Ln(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function ub(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function et(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Go(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Ln(e.$head)||hb(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function hb(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ri(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function pb(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Yi(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Iu(n,e,t){const r=n.node(-1),o=ue.get(r),s=n.start(-1),i=o.nextCell(n.pos-s,e,t);return i==null?null:n.node(0).resolve(s+i)}function an(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Pu(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function fb(n,e,t){const r=Re(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}var ie=class pt extends W{constructor(e,t=e){const r=e.node(-1),o=ue.get(r),s=e.start(-1),i=o.rectBetween(e.pos-s,t.pos-s),a=e.node(0),l=o.cellsInRect(i).filter(d=>d!=t.pos-s);l.unshift(t.pos-s);const c=l.map(d=>{const u=r.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const h=s+d+1;return new sd(a.resolve(h),a.resolve(h+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(ri(r)&&ri(o)&&Yi(r,o)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?pt.rowSelection(r,o):s&&this.isColSelection()?pt.colSelection(r,o):new pt(r,o)}return H.between(r,o)}content(){const e=this.$anchorCell.node(-1),t=ue.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},i=[];for(let l=o.top;l<o.bottom;l++){const c=[];for(let d=l*t.width+o.left,u=o.left;u<o.right;u++,d++){const h=t.map[d];if(s[h])continue;s[h]=!0;const p=t.findCell(h);let f=e.nodeAt(h);if(!f)throw RangeError(`No cell with offset ${h} found`);const m=o.left-p.left,g=p.right-o.right;if(m>0||g>0){let y=f.attrs;if(m>0&&(y=an(y,0,m)),g>0&&(y=an(y,y.colspan-g,g)),p.left<o.left){if(f=f.type.createAndFill(y),!f)throw RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else f=f.type.create(y,f.content)}if(p.top<o.top||p.bottom>o.bottom){const y={...f.attrs,rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)};p.top<o.top?f=f.type.createAndFill(y):f=f.type.create(y,f.content)}c.push(f)}i.push(e.child(l).copy(M.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:i;return new O(M.from(a),1,1)}replace(e,t=O.empty){const r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){const{$from:a,$to:l}=o[i],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),i?O.empty:t)}const s=W.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new O(M.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=ue.get(t),o=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let i=0;i<s.length;i++)e(t.nodeAt(s[i]),o+s[i])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),o=ue.get(r),s=e.start(-1),i=o.findCell(e.pos-s),a=o.findCell(t.pos-s),l=e.node(0);return i.top<=a.top?(i.top>0&&(e=l.resolve(s+o.map[i.left])),a.bottom<o.height&&(t=l.resolve(s+o.map[o.width*(o.height-1)+a.right-1]))):(a.top>0&&(t=l.resolve(s+o.map[a.left])),i.bottom<o.height&&(e=l.resolve(s+o.map[o.width*(o.height-1)+i.right-1]))),new pt(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=ue.get(e),r=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-r),s=t.colCount(this.$headCell.pos-r);if(Math.min(o,s)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,a=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,a)==t.width}eq(e){return e instanceof pt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),o=ue.get(r),s=e.start(-1),i=o.findCell(e.pos-s),a=o.findCell(t.pos-s),l=e.node(0);return i.left<=a.left?(i.left>0&&(e=l.resolve(s+o.map[i.top*o.width])),a.right<o.width&&(t=l.resolve(s+o.map[o.width*(a.top+1)-1]))):(a.left>0&&(t=l.resolve(s+o.map[a.top*o.width])),i.right<o.width&&(e=l.resolve(s+o.map[o.width*(i.top+1)-1]))),new pt(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new pt(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new pt(e.resolve(t),e.resolve(r))}getBookmark(){return new mb(this.$anchorCell.pos,this.$headCell.pos)}};ie.prototype.visible=!1;W.jsonID("cell",ie);var mb=class Hu{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Hu(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Yi(t,r)?new ie(t,r):W.near(r,1)}};function gb(n){if(!(n.selection instanceof ie))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(xe.node(r,r+t.nodeSize,{class:"selectedCell"}))}),se.create(n.doc,e)}function yb({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function bb({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){const s=n.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let o=e.depth;o>0;o--){const s=e.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function xb(n,e,t){const r=(e||n).selection,o=(e||n).doc;let s,i;if(r instanceof I&&(i=r.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")s=ie.create(o,r.from);else if(i=="row"){const a=o.resolve(r.from+1);s=ie.rowSelection(a,a)}else if(!t){const a=ue.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];s=ie.create(o,l+1,c)}}else r instanceof H&&yb(r)?s=H.create(o,r.from):r instanceof H&&bb(r)&&(s=H.create(o,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var wb=new he("fix-tables");function Bu(n,e,t,r){const o=n.childCount,s=e.childCount;e:for(let i=0,a=0;i<s;i++){const l=e.child(i);for(let c=a,d=Math.min(o,i+3);c<d;c++)if(n.child(c)==l){a=c+1,t+=l.nodeSize;continue e}r(l,t),a<o&&n.child(a).sameMarkup(l)?Bu(n.child(a),l,t+1,r):l.nodesBetween(0,l.content.size,r,t+1),t+=l.nodeSize}}function Vu(n,e){let t;const r=(o,s)=>{o.type.spec.tableRole=="table"&&(t=kb(n,o,s,t))};return e?e.doc!=n.doc&&Bu(e.doc,n.doc,0,r):n.doc.descendants(r),t}function kb(n,e,t,r){const o=ue.get(e);if(!o.problems)return r;r||(r=n.tr);const s=[];for(let l=0;l<o.height;l++)s.push(0);for(let l=0;l<o.problems.length;l++){const c=o.problems[l];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let h=0;h<u.rowspan;h++)s[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,an(u,u.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(t);r.delete(d,d+e.nodeSize)}}let i,a;for(let l=0;l<s.length;l++)s[l]&&(i==null&&(i=l),a=l);for(let l=0,c=t+1;l<o.height;l++){const d=e.child(l),u=c+d.nodeSize,h=s[l];if(h>0){let p="cell";d.firstChild&&(p=d.firstChild.type.spec.tableRole);const f=[];for(let g=0;g<h;g++){const y=Re(n.schema)[p].createAndFill();y&&f.push(y)}const m=(l==0||i==l-1)&&a==l?c+1:u-1;r.insert(r.mapping.map(m),f)}c=u}return r.setMeta(wb,{fixTables:!0})}function lt(n){const e=n.selection,t=Go(n),r=t.node(-1),o=t.start(-1),s=ue.get(r);return{...e instanceof ie?s.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):s.findCell(t.pos-o),tableStart:o,map:s,table:r}}function Fu(n,{map:e,tableStart:t,table:r},o){let s=o>0?-1:0;fb(e,r,o+s)&&(s=o==0||o==e.width?null:0);for(let i=0;i<e.height;i++){const a=i*e.width+o;if(o>0&&o<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],c=r.nodeAt(l);n.setNodeMarkup(n.mapping.map(t+l),null,Pu(c.attrs,o-e.colCount(l))),i+=c.attrs.rowspan-1}else{const l=s==null?Re(r.type.schema).cell:r.nodeAt(e.map[a+s]).type,c=e.positionAt(i,o,r);n.insert(n.mapping.map(t+c),l.createAndFill())}}return n}function vb(n,e){if(!et(n))return!1;if(e){const t=lt(n);e(Fu(n.tr,t,t.left))}return!0}function Sb(n,e){if(!et(n))return!1;if(e){const t=lt(n);e(Fu(n.tr,t,t.right))}return!0}function Cb(n,{map:e,table:t,tableStart:r},o){const s=n.mapping.maps.length;for(let i=0;i<e.height;){const a=i*e.width+o,l=e.map[a],c=t.nodeAt(l),d=c.attrs;if(o>0&&e.map[a-1]==l||o<e.width-1&&e.map[a+1]==l)n.setNodeMarkup(n.mapping.slice(s).map(r+l),null,an(d,o-e.colCount(l)));else{const u=n.mapping.slice(s).map(r+l);n.delete(u,u+c.nodeSize)}i+=d.rowspan}}function Mb(n,e){if(!et(n))return!1;if(e){const t=lt(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;Cb(r,t,o),o!=t.left;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=ue.get(s)}e(r)}return!0}function Eb(n,e,t){var r;const o=Re(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(((r=e.nodeAt(n.map[s+t*n.width]))==null?void 0:r.type)!=o)return!1;return!0}function Wu(n,{map:e,tableStart:t,table:r},o){var s;let i=t;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;const a=[];let l=o>0?-1:0;Eb(e,r,o+l)&&(l=o==0||o==e.height?null:0);for(let c=0,d=e.width*o;c<e.width;c++,d++)if(o>0&&o<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],h=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{const u=l==null?Re(r.type.schema).cell:(s=r.nodeAt(e.map[d+l*e.width]))==null?void 0:s.type,h=u?.createAndFill();h&&a.push(h)}return n.insert(i,Re(r.type.schema).row.create(null,a)),n}function Tb(n,e){if(!et(n))return!1;if(e){const t=lt(n);e(Wu(n.tr,t,t.top))}return!0}function Nb(n,e){if(!et(n))return!1;if(e){const t=lt(n);e(Wu(n.tr,t,t.bottom))}return!0}function Ab(n,{map:e,table:t,tableStart:r},o){let s=0;for(let c=0;c<o;c++)s+=t.child(c).nodeSize;const i=s+t.child(o).nodeSize,a=n.mapping.maps.length;n.delete(s+r,i+r);const l=new Set;for(let c=0,d=o*e.width;c<e.width;c++,d++){const u=e.map[d];if(!l.has(u)){if(l.add(u),o>0&&u==e.map[d-e.width]){const h=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(a).map(u+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(o<e.height&&u==e.map[d+e.width]){const h=t.nodeAt(u),p=h.attrs,f=h.type.create({...p,rowspan:h.attrs.rowspan-1},h.content),m=e.positionAt(o+1,c,t);n.insert(n.mapping.slice(a).map(r+m),f),c+=p.colspan-1}}}}function Ob(n,e){if(!et(n))return!1;if(e){const t=lt(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;Ab(r,t,o),o!=t.top;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=ue.get(t.table)}e(r)}return!0}function Tl(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Rb({width:n,height:e,map:t},r){let o=r.top*n+r.left,s=o,i=(r.bottom-1)*n+r.left,a=o+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[a]==t[a+1])return!0;s+=n,a+=n}for(let l=r.left;l<r.right;l++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[i]==t[i+n])return!0;o++,i++}return!1}function Nl(n,e){const t=n.selection;if(!(t instanceof ie)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=lt(n),{map:o}=r;if(Rb(o,r))return!1;if(e){const s=n.tr,i={};let a=M.empty,l,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const h=o.map[d*o.width+u],p=r.table.nodeAt(h);if(!(i[h]||!p))if(i[h]=!0,l==null)l=h,c=p;else{Tl(p)||(a=a.append(p.content));const f=s.mapping.map(h+r.tableStart);s.delete(f,f+p.nodeSize)}}if(l==null||c==null)return!0;if(s.setNodeMarkup(l+r.tableStart,null,{...Pu(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),a.size){const d=l+1+c.content.size,u=Tl(c)?l+1:d;s.replaceWith(u+r.tableStart,d+r.tableStart,a)}s.setSelection(new ie(s.doc.resolve(l+r.tableStart))),e(s)}return!0}function Al(n,e){const t=Re(n.schema);return Db(({node:r})=>t[r.type.spec.tableRole])(n,e)}function Db(n){return(e,t)=>{var r;const o=e.selection;let s,i;if(o instanceof ie){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;s=o.$anchorCell.nodeAfter,i=o.$anchorCell.pos}else{if(s=ub(o.$from),!s)return!1;i=(r=Ln(o.$from))==null?void 0:r.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let a=s.attrs;const l=[],c=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const d=lt(e),u=e.tr;for(let p=0;p<d.right-d.left;p++)l.push(c?{...a,colwidth:c&&c[p]?[c[p]]:null}:a);let h;for(let p=d.top;p<d.bottom;p++){let f=d.map.positionAt(p,d.left,d.table);p==d.top&&(f+=s.nodeSize);for(let m=d.left,g=0;m<d.right;m++,g++)m==d.left&&p==d.top||u.insert(h=u.mapping.map(f+d.tableStart,1),n({node:s,row:p,col:m}).createAndFill(l[g]))}u.setNodeMarkup(i,n({node:s,row:d.top,col:d.left}),l[0]),o instanceof ie&&u.setSelection(new ie(u.doc.resolve(o.$anchorCell.pos),h?u.doc.resolve(h):void 0)),t(u)}return!0}}function jb(n,e){return function(t,r){if(!et(t))return!1;const o=Go(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){const s=t.tr;t.selection instanceof ie?t.selection.forEachCell((i,a)=>{i.attrs[n]!==e&&s.setNodeMarkup(a,null,{...i.attrs,[n]:e})}):s.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[n]:e}),r(s)}return!0}}function Lb(n){return function(e,t){if(!et(e))return!1;if(t){const r=Re(e.schema),o=lt(e),s=e.tr,i=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),a=i.map(l=>o.table.nodeAt(l));for(let l=0;l<i.length;l++)a[l].type==r.header_cell&&s.setNodeMarkup(o.tableStart+i[l],r.cell,a[l].attrs);if(s.steps.length==0)for(let l=0;l<i.length;l++)s.setNodeMarkup(o.tableStart+i[l],r.header_cell,a[l].attrs);t(s)}return!0}}function Ol(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const s=e.table.nodeAt(r[o]);if(s&&s.type!==t.header_cell)return!1}return!0}function dr(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Lb(n):function(t,r){if(!et(t))return!1;if(r){const o=Re(t.schema),s=lt(t),i=t.tr,a=Ol("row",s,o),l=Ol("column",s,o),c=(n==="column"?a:n==="row"&&l)?1:0,d=n=="column"?{left:0,top:c,right:1,bottom:s.map.height}:n=="row"?{left:c,top:0,right:s.map.width,bottom:1}:s,u=n=="column"?l?o.cell:o.header_cell:n=="row"?a?o.cell:o.header_cell:o.cell;s.map.cellsInRect(d).forEach(h=>{const p=h+s.tableStart,f=i.doc.nodeAt(p);f&&i.setNodeMarkup(p,u,f.attrs)}),r(i)}return!0}}dr("row",{useDeprecatedLogic:!0});dr("column",{useDeprecatedLogic:!0});var zb=dr("cell",{useDeprecatedLogic:!0});function $b(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){const s=n.node(-1).child(r),i=s.lastChild;if(i)return o-1-i.nodeSize;o-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){const s=t.child(r);if(s.childCount)return o+1;o+=s.nodeSize}}return null}function Rl(n){return function(e,t){if(!et(e))return!1;const r=$b(Go(e),n);if(r==null)return!1;if(t){const o=e.doc.resolve(r);t(e.tr.setSelection(H.between(o,pb(o))).scrollIntoView())}return!0}}function Ib(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Er(n,e){const t=n.selection;if(!(t instanceof ie))return!1;if(e){const r=n.tr,o=Re(n.schema).cell.createAndFill().content;t.forEachCell((s,i)=>{s.content.eq(o)||r.replace(r.mapping.map(i+1),r.mapping.map(i+s.nodeSize-1),new O(o,0,0))}),r.docChanged&&e(r)}return!0}function Pb(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const o=e.child(0),s=o.type.spec.tableRole,i=o.type.schema,a=[];if(s=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content;const d=l?0:Math.max(0,t-1),u=l<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=oi(Re(i).row,new O(c,d,u)).content),a.push(c)}else if(s=="cell"||s=="header_cell")a.push(t||r?oi(Re(i).row,new O(e,t,r)).content:e);else return null;return Hb(i,a)}function Hb(n,e){const t=[];for(let o=0;o<e.length;o++){const s=e[o];for(let i=s.childCount-1;i>=0;i--){const{rowspan:a,colspan:l}=s.child(i).attrs;for(let c=o;c<o+a;c++)t[c]=(t[c]||0)+l}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(M.empty),t[o]<r){const s=Re(n).cell.createAndFill(),i=[];for(let a=t[o];a<r;a++)i.push(s);e[o]=e[o].append(M.from(i))}return{height:e.length,width:r,rows:e}}function oi(n,e){const t=n.createAndFill();return new vi(t).replace(0,t.content.size,e).doc}function Bb({width:n,height:e,rows:t},r,o){if(n!=r){const s=[],i=[];for(let a=0;a<t.length;a++){const l=t[a],c=[];for(let d=s[a]||0,u=0;d<r;u++){let h=l.child(u%l.childCount);d+h.attrs.colspan>r&&(h=h.type.createChecked(an(h.attrs,h.attrs.colspan,d+h.attrs.colspan-r),h.content)),c.push(h),d+=h.attrs.colspan;for(let p=1;p<h.attrs.rowspan;p++)s[a+p]=(s[a+p]||0)+h.attrs.colspan}i.push(M.from(c))}t=i,n=r}if(e!=o){const s=[];for(let i=0,a=0;i<o;i++,a++){const l=[],c=t[a%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);i+u.attrs.rowspan>o&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,o-u.attrs.rowspan)},u.content)),l.push(u)}s.push(M.from(l))}t=s,e=o}return{width:n,height:e,rows:t}}function Vb(n,e,t,r,o,s,i){const a=n.doc.type.schema,l=Re(a);let c,d;if(o>e.width)for(let u=0,h=0;u<e.height;u++){const p=t.child(u);h+=p.nodeSize;const f=[];let m;p.lastChild==null||p.lastChild.type==l.cell?m=c||(c=l.cell.createAndFill()):m=d||(d=l.header_cell.createAndFill());for(let g=e.width;g<o;g++)f.push(m);n.insert(n.mapping.slice(i).map(h-1+r),f)}if(s>e.height){const u=[];for(let f=0,m=(e.height-1)*e.width;f<Math.max(e.width,o);f++){const g=f>=e.width?!1:t.nodeAt(e.map[m+f]).type==l.header_cell;u.push(g?d||(d=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}const h=l.row.create(null,M.from(u)),p=[];for(let f=e.height;f<s;f++)p.push(h);n.insert(n.mapping.slice(i).map(r+t.nodeSize-2),p)}return!!(c||d)}function Dl(n,e,t,r,o,s,i,a){if(i==0||i==e.height)return!1;let l=!1;for(let c=o;c<s;c++){const d=i*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){l=!0;const h=t.nodeAt(u),{top:p,left:f}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(a).map(u+r),null,{...h.attrs,rowspan:i-p}),n.insert(n.mapping.slice(a).map(e.positionAt(i,f,t)),h.type.createAndFill({...h.attrs,rowspan:p+h.attrs.rowspan-i})),c+=h.attrs.colspan-1}}return l}function jl(n,e,t,r,o,s,i,a){if(i==0||i==e.width)return!1;let l=!1;for(let c=o;c<s;c++){const d=c*e.width+i,u=e.map[d];if(e.map[d-1]==u){l=!0;const h=t.nodeAt(u),p=e.colCount(u),f=n.mapping.slice(a).map(u+r);n.setNodeMarkup(f,null,an(h.attrs,i-p,h.attrs.colspan-(i-p))),n.insert(f+h.nodeSize,h.type.createAndFill(an(h.attrs,0,i-p))),c+=h.attrs.rowspan-1}}return l}function Ll(n,e,t,r,o){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let i=ue.get(s);const{top:a,left:l}=r,c=l+o.width,d=a+o.height,u=n.tr;let h=0;function p(){if(s=t?u.doc.nodeAt(t-1):u.doc,!s)throw new Error("No table found");i=ue.get(s),h=u.mapping.maps.length}Vb(u,i,s,t,c,d,h)&&p(),Dl(u,i,s,t,l,c,a,h)&&p(),Dl(u,i,s,t,l,c,d,h)&&p(),jl(u,i,s,t,a,d,l,h)&&p(),jl(u,i,s,t,a,d,c,h)&&p();for(let f=a;f<d;f++){const m=i.positionAt(f,l,s),g=i.positionAt(f,c,s);u.replace(u.mapping.slice(h).map(m+t),u.mapping.slice(h).map(g+t),new O(o.rows[f-a],0,0))}p(),u.setSelection(new ie(u.doc.resolve(t+i.positionAt(a,l,s)),u.doc.resolve(t+i.positionAt(d-1,c-1,s)))),e(u)}var Fb=Pi({ArrowLeft:Tr("horiz",-1),ArrowRight:Tr("horiz",1),ArrowUp:Tr("vert",-1),ArrowDown:Tr("vert",1),"Shift-ArrowLeft":Nr("horiz",-1),"Shift-ArrowRight":Nr("horiz",1),"Shift-ArrowUp":Nr("vert",-1),"Shift-ArrowDown":Nr("vert",1),Backspace:Er,"Mod-Backspace":Er,Delete:Er,"Mod-Delete":Er});function Hr(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Tr(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;if(s instanceof ie)return Hr(t,r,W.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const i=_u(o,n,e);if(i==null)return!1;if(n=="horiz")return Hr(t,r,W.near(t.doc.resolve(s.head+e),e));{const a=t.doc.resolve(i),l=Iu(a,n,e);let c;return l?c=W.near(l,1):e<0?c=W.near(t.doc.resolve(a.before(-1)),-1):c=W.near(t.doc.resolve(a.after(-1)),1),Hr(t,r,c)}}}function Nr(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;let i;if(s instanceof ie)i=s;else{const l=_u(o,n,e);if(l==null)return!1;i=new ie(t.doc.resolve(l))}const a=Iu(i.$headCell,n,e);return a?Hr(t,r,new ie(i.$anchorCell,a)):!1}}function Wb(n,e){const t=n.state.doc,r=Ln(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new ie(r))),!0):!1}function _b(n,e,t){if(!et(n.state))return!1;let r=Pb(t);const o=n.state.selection;if(o instanceof ie){r||(r={width:1,height:1,rows:[M.from(oi(Re(n.state.schema).cell,t))]});const s=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),a=ue.get(s).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=Bb(r,a.right-a.left,a.bottom-a.top),Ll(n.state,n.dispatch,i,a,r),!0}else if(r){const s=Go(n.state),i=s.start(-1);return Ll(n.state,n.dispatch,i,ue.get(s.node(-1)).findCell(s.pos-i),r),!0}else return!1}function Ub(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=zl(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof ie)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Ln(n.state.selection.$anchor))!=null&&((t=xs(n,e))==null?void 0:t.pos)!=o.pos)s(o,e),e.preventDefault();else if(!r)return;function s(l,c){let d=xs(n,c);const u=Nt.getState(n.state)==null;if(!d||!Yi(l,d))if(u)d=l;else return;const h=new ie(l,d);if(u||!n.state.selection.eq(h)){const p=n.state.tr.setSelection(h);u&&p.setMeta(Nt,l.pos),n.dispatch(p)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",a),Nt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Nt,-1))}function a(l){const c=l,d=Nt.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(zl(n,c.target)!=r&&(u=xs(n,e),!u))return i();u&&s(u,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",a)}function _u(n,e,t){if(!(n.state.selection instanceof H))return null;const{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){const s=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const i=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?i:null}}return null}function zl(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function xs(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Ln(n.state.doc.resolve(t.pos)):null}var qb=class{constructor(n,e){this.node=n,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),si(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!=this.node.type?!1:(this.node=n,si(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function si(n,e,t,r,o,s){var i;let a=0,l=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let u=0,h=0;u<d.childCount;u++){const{colspan:p,colwidth:f}=d.child(u).attrs;for(let m=0;m<p;m++,h++){const g=o==h?s:f&&f[m],y=g?g+"px":"";if(a+=g||r,g||(l=!1),c)c.style.width!=y&&(c.style.width=y),c=c.nextSibling;else{const w=document.createElement("col");w.style.width=y,e.appendChild(w)}}}for(;c;){const u=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=u}l?(t.style.width=a+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=a+"px")}}var Fe=new he("tableColumnResizing");function Kb({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=qb,lastColumnResizable:o=!0}={}){const s=new le({key:Fe,state:{init(i,a){var l,c;const d=(c=(l=s.spec)==null?void 0:l.props)==null?void 0:c.nodeViews,u=Re(a.schema).table.name;return r&&d&&(d[u]=(h,p)=>new r(h,t,p)),new Jb(-1,!1)},apply(i,a){return a.apply(i)}},props:{attributes:i=>{const a=Fe.getState(i);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(i,a)=>{Gb(i,a,n,o)},mouseleave:i=>{Xb(i)},mousedown:(i,a)=>{Yb(i,a,e,t)}},decorations:i=>{const a=Fe.getState(i);if(a&&a.activeHandle>-1)return n0(i,a.activeHandle)},nodeViews:{}}});return s}var Jb=class Br{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(Fe);if(r&&r.setHandle!=null)return new Br(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Br(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return ri(e.doc.resolve(o))||(o=-1),new Br(o,t.dragging)}return t}};function Gb(n,e,t,r){if(!n.editable)return;const o=Fe.getState(n.state);if(o&&!o.dragging){const s=Zb(e.target);let i=-1;if(s){const{left:a,right:l}=s.getBoundingClientRect();e.clientX-a<=t?i=$l(n,e,"left",t):l-e.clientX<=t&&(i=$l(n,e,"right",t))}if(i!=o.activeHandle){if(!r&&i!==-1){const a=n.state.doc.resolve(i),l=a.node(-1),c=ue.get(l),d=a.start(-1);if(c.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==c.width-1)return}Uu(n,i)}}}function Xb(n){if(!n.editable)return;const e=Fe.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Uu(n,-1)}function Yb(n,e,t,r){var o;if(!n.editable)return!1;const s=(o=n.dom.ownerDocument.defaultView)!=null?o:window,i=Fe.getState(n.state);if(!i||i.activeHandle==-1||i.dragging)return!1;const a=n.state.doc.nodeAt(i.activeHandle),l=Qb(n,i.activeHandle,a.attrs);n.dispatch(n.state.tr.setMeta(Fe,{setDragging:{startX:e.clientX,startWidth:l}}));function c(u){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",d);const h=Fe.getState(n.state);h?.dragging&&(e0(n,h.activeHandle,Il(h.dragging,u,t)),n.dispatch(n.state.tr.setMeta(Fe,{setDragging:null})))}function d(u){if(!u.which)return c(u);const h=Fe.getState(n.state);if(h&&h.dragging){const p=Il(h.dragging,u,t);Pl(n,h.activeHandle,p,r)}}return Pl(n,i.activeHandle,l,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",d),e.preventDefault(),!0}function Qb(n,e,{colspan:t,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const s=n.domAtPos(e);let i=s.node.childNodes[s.offset].offsetWidth,a=t;if(r)for(let l=0;l<t;l++)r[l]&&(i-=r[l],a--);return i/a}function Zb(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function $l(n,e,t,r){const o=t=="right"?-r:r,s=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!s)return-1;const{pos:i}=s,a=Ln(n.state.doc.resolve(i));if(!a)return-1;if(t=="right")return a.pos;const l=ue.get(a.node(-1)),c=a.start(-1),d=l.map.indexOf(a.pos-c);return d%l.width==0?-1:c+l.map[d-1]}function Il(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Uu(n,e){n.dispatch(n.state.tr.setMeta(Fe,{setHandle:e}))}function e0(n,e,t){const r=n.state.doc.resolve(e),o=r.node(-1),s=ue.get(o),i=r.start(-1),a=s.colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1,l=n.state.tr;for(let c=0;c<s.height;c++){const d=c*s.width+a;if(c&&s.map[d]==s.map[d-s.width])continue;const u=s.map[d],h=o.nodeAt(u).attrs,p=h.colspan==1?0:a-s.colCount(u);if(h.colwidth&&h.colwidth[p]==t)continue;const f=h.colwidth?h.colwidth.slice():t0(h.colspan);f[p]=t,l.setNodeMarkup(i+u,null,{...h,colwidth:f})}l.docChanged&&n.dispatch(l)}function Pl(n,e,t,r){const o=n.state.doc.resolve(e),s=o.node(-1),i=o.start(-1),a=ue.get(s).colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1;let l=n.domAtPos(o.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&si(s,l.firstChild,l,r,a,t)}function t0(n){return Array(n).fill(0)}function n0(n,e){var t;const r=[],o=n.doc.resolve(e),s=o.node(-1);if(!s)return se.empty;const i=ue.get(s),a=o.start(-1),l=i.colCount(o.pos-a)+o.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const d=l+c*i.width;if((l==i.width-1||i.map[d]!=i.map[d+1])&&(c==0||i.map[d]!=i.map[d-i.width])){const u=i.map[d],h=a+u+s.nodeAt(u).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",(t=Fe.getState(n))!=null&&t.dragging&&r.push(xe.node(a+u,a+u+s.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),r.push(xe.widget(h,p))}}return se.create(n.doc,r)}function r0({allowTableNodeSelection:n=!1}={}){return new le({key:Nt,state:{init(){return null},apply(e,t){const r=e.getMeta(Nt);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:o,pos:s}=e.mapping.mapResult(t);return o?null:s}},props:{decorations:gb,handleDOMEvents:{mousedown:Ub},createSelectionBetween(e){return Nt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Wb,handleKeyDown:Fb,handlePaste:_b},appendTransaction(e,t,r){return xb(r,Vu(r,t),n)}})}var qu=ve.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{var e,t;const r=n.getAttribute("colwidth"),o=r?r.split(",").map(s=>parseInt(s,10)):null;if(!o){const s=(e=n.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),i=Array.from(((t=n.parentElement)==null?void 0:t.children)||[]).indexOf(n);if(i&&i>-1&&s&&s[i]){const a=s[i].getAttribute("width");return a?[parseInt(a,10)]:null}}return o}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",re(this.options.HTMLAttributes,n),0]}}),Ku=ve.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?e.split(",").map(t=>parseInt(t,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",re(this.options.HTMLAttributes,n),0]}}),Ju=ve.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",re(this.options.HTMLAttributes,n),0]}});function ii(n,e){return e?["width",`${Math.max(e,n)}px`]:["min-width",`${n}px`]}function Hl(n,e,t,r,o,s){var i;let a=0,l=!0,c=e.firstChild;const d=n.firstChild;if(d!==null)for(let h=0,p=0;h<d.childCount;h+=1){const{colspan:f,colwidth:m}=d.child(h).attrs;for(let g=0;g<f;g+=1,p+=1){const y=o===p?s:m&&m[g],w=y?`${y}px`:"";if(a+=y||r,y||(l=!1),c){if(c.style.width!==w){const[x,E]=ii(r,y);c.style.setProperty(x,E)}c=c.nextSibling}else{const x=document.createElement("col"),[E,b]=ii(r,y);x.style.setProperty(E,b),e.appendChild(x)}}}for(;c;){const h=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=h}const u=n.attrs.style&&typeof n.attrs.style=="string"&&/\bwidth\s*:/i.test(n.attrs.style);l&&!u?(t.style.width=`${a}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${a}px`)}var o0=class{constructor(n,e){this.node=n,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),n.attrs.style&&(this.table.style.cssText=n.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Hl(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!==this.node.type?!1:(this.node=n,Hl(n,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(n){const e=n.target,t=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(t&&!r&&(n.type==="attributes"||n.type==="childList"||n.type==="characterData"))}};function s0(n,e,t,r){let o=0,s=!0;const i=[],a=n.firstChild;if(!a)return{};for(let d=0,u=0;d<a.childCount;d+=1){const{colspan:h,colwidth:p}=a.child(d).attrs;for(let f=0;f<h;f+=1,u+=1){const m=t===u?r:p&&p[f];o+=m||e,m||(s=!1);const[g,y]=ii(e,m);i.push(["col",{style:`${g}: ${y}`}])}}const l=s?`${o}px`:"",c=s?"":`${o}px`;return{colgroup:["colgroup",{},...i],tableWidth:l,tableMinWidth:c}}function Bl(n,e){return n.createAndFill()}function i0(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function a0(n,e,t,r,o){const s=i0(n),i=[],a=[];for(let c=0;c<t;c+=1){const d=Bl(s.cell);if(d&&a.push(d),r){const u=Bl(s.header_cell);u&&i.push(u)}}const l=[];for(let c=0;c<e;c+=1)l.push(s.row.createChecked(null,r&&c===0?i:a));return s.table.createChecked(null,l)}function l0(n){return n instanceof ie}var Ar=({editor:n})=>{const{selection:e}=n.state;if(!l0(e))return!1;let t=0;return cu(e.ranges[0].$from,o=>o.type.name==="table")?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},c0="";function d0(n){return(n||"").replace(/\s+/g," ").trim()}function u0(n,e,t={}){var r;const o=(r=t.cellLineSeparator)!=null?r:c0;if(!n||!n.content||n.content.length===0)return"";const s=[];n.content.forEach(p=>{const f=[];p.content&&p.content.forEach(m=>{let g="";m.content&&Array.isArray(m.content)&&m.content.length>1?g=m.content.map(x=>e.renderChildren(x)).join(o):g=m.content?e.renderChildren(m.content):"";const y=d0(g),w=m.type==="tableHeader";f.push({text:y,isHeader:w})}),s.push(f)});const i=s.reduce((p,f)=>Math.max(p,f.length),0);if(i===0)return"";const a=new Array(i).fill(0);s.forEach(p=>{var f;for(let m=0;m<i;m+=1){const g=(((f=p[m])==null?void 0:f.text)||"").length;g>a[m]&&(a[m]=g),a[m]<3&&(a[m]=3)}});const l=(p,f)=>p+" ".repeat(Math.max(0,f-p.length)),c=s[0],d=c.some(p=>p.isHeader);let u=`
110
110
  `;const h=new Array(i).fill(0).map((p,f)=>d&&c[f]&&c[f].text||"");return u+=`| ${h.map((p,f)=>l(p,a[f])).join(" | ")} |
111
111
  `,u+=`| ${a.map(p=>"-".repeat(Math.max(3,p))).join(" | ")} |
112
112
  `,(d?s.slice(1):s).forEach(p=>{u+=`| ${new Array(i).fill(0).map((f,m)=>l(p[m]&&p[m].text||"",a[m])).join(" | ")} |
113
- `}),u}var u0=d0,Ju=ve.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:r0,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){const{colgroup:t,tableWidth:r,tableMinWidth:o}=o0(n,this.options.cellMinWidth),s=e.style;function i(){return s||(r?`width: ${r}`:`min-width: ${o}`)}const a=["table",re(this.options.HTMLAttributes,e,{style:i()}),t,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},a]:a},parseMarkdown:(n,e)=>{const t=[];if(n.header){const r=[];n.header.forEach(o=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),t.push(e.createNode("tableRow",{},r))}return n.rows&&n.rows.forEach(r=>{const o=[];r.forEach(s=>{o.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),t.push(e.createNode("tableRow",{},o))}),e.createNode("table",void 0,t)},renderMarkdown:(n,e)=>u0(n,e),addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:o,editor:s})=>{const i=i0(s.schema,n,e,t);if(o){const a=r.selection.from+1;r.replaceSelectionWith(i).scrollIntoView().setSelection(H.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>kb(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>vb(n,e),deleteColumn:()=>({state:n,dispatch:e})=>Cb(n,e),addRowBefore:()=>({state:n,dispatch:e})=>Eb(n,e),addRowAfter:()=>({state:n,dispatch:e})=>Tb(n,e),deleteRow:()=>({state:n,dispatch:e})=>Ab(n,e),deleteTable:()=>({state:n,dispatch:e})=>$b(n,e),mergeCells:()=>({state:n,dispatch:e})=>Tl(n,e),splitCell:()=>({state:n,dispatch:e})=>Nl(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>dr("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>dr("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>Lb(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Tl(n,e)?!0:Nl(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>Db(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Ol(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Ol(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Bu(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=ie.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Ar,"Mod-Backspace":Ar,Delete:Ar,"Mod-Delete":Ar}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[qb({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],n0({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:Q(P(n,"tableRole",e))}}});te.create({name:"tableKit",addExtensions(){const n=[];return this.options.table!==!1&&n.push(Ju.configure(this.options.table)),this.options.tableCell!==!1&&n.push(Uu.configure(this.options.tableCell)),this.options.tableHeader!==!1&&n.push(qu.configure(this.options.tableHeader)),this.options.tableRow!==!1&&n.push(Ku.configure(this.options.tableRow)),n}});var h0=Uu,p0=qu,f0=Ku,m0=te.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:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).some(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:n=>({editor:e,commands:t})=>this.options.alignments.includes(n)?e.isActive({textAlign:n})?t.unsetTextAlign():t.setTextAlign(n):!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")}}}),g0=m0,Gu=wt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",re(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!r)return;const o=r[2].trim();return{type:"underline",raw:r[0],text:o,tokens:t.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),y0=Gu,to=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},b0=/^\s*>\s$/,x0=ve.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return to("blockquote",{...re(this.options.HTMLAttributes,n),children:to("slot",{})})},parseMarkdown:(n,e)=>e.createNode("blockquote",void 0,e.parseChildren(n.tokens||[])),renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach(o=>{const s=e.renderChildren([o]).split(`
113
+ `}),u}var h0=u0,Gu=ve.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:o0,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){const{colgroup:t,tableWidth:r,tableMinWidth:o}=s0(n,this.options.cellMinWidth),s=e.style;function i(){return s||(r?`width: ${r}`:`min-width: ${o}`)}const a=["table",re(this.options.HTMLAttributes,e,{style:i()}),t,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},a]:a},parseMarkdown:(n,e)=>{const t=[];if(n.header){const r=[];n.header.forEach(o=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),t.push(e.createNode("tableRow",{},r))}return n.rows&&n.rows.forEach(r=>{const o=[];r.forEach(s=>{o.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),t.push(e.createNode("tableRow",{},o))}),e.createNode("table",void 0,t)},renderMarkdown:(n,e)=>h0(n,e),addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:o,editor:s})=>{const i=a0(s.schema,n,e,t);if(o){const a=r.selection.from+1;r.replaceSelectionWith(i).scrollIntoView().setSelection(H.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>vb(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>Sb(n,e),deleteColumn:()=>({state:n,dispatch:e})=>Mb(n,e),addRowBefore:()=>({state:n,dispatch:e})=>Tb(n,e),addRowAfter:()=>({state:n,dispatch:e})=>Nb(n,e),deleteRow:()=>({state:n,dispatch:e})=>Ob(n,e),deleteTable:()=>({state:n,dispatch:e})=>Ib(n,e),mergeCells:()=>({state:n,dispatch:e})=>Nl(n,e),splitCell:()=>({state:n,dispatch:e})=>Al(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>dr("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>dr("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>zb(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Nl(n,e)?!0:Al(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>jb(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Rl(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Rl(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Vu(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=ie.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Ar,"Mod-Backspace":Ar,Delete:Ar,"Mod-Delete":Ar}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Kb({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],r0({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:Q(P(n,"tableRole",e))}}});te.create({name:"tableKit",addExtensions(){const n=[];return this.options.table!==!1&&n.push(Gu.configure(this.options.table)),this.options.tableCell!==!1&&n.push(qu.configure(this.options.tableCell)),this.options.tableHeader!==!1&&n.push(Ku.configure(this.options.tableHeader)),this.options.tableRow!==!1&&n.push(Ju.configure(this.options.tableRow)),n}});var p0=qu,f0=Ku,m0=Ju,g0=te.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:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).some(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:n=>({editor:e,commands:t})=>this.options.alignments.includes(n)?e.isActive({textAlign:n})?t.unsetTextAlign():t.setTextAlign(n):!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")}}}),y0=g0,Xu=wt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",re(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!r)return;const o=r[2].trim();return{type:"underline",raw:r[0],text:o,tokens:t.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),b0=Xu,to=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]},x0=/^\s*>\s$/,w0=ve.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return to("blockquote",{...re(this.options.HTMLAttributes,n),children:to("slot",{})})},parseMarkdown:(n,e)=>e.createNode("blockquote",void 0,e.parseChildren(n.tokens||[])),renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach(o=>{const s=e.renderChildren([o]).split(`
114
114
  `).map(i=>i.trim()===""?t:`${t} ${i}`);r.push(s.join(`
115
115
  `))}),r.join(`
116
116
  ${t}
117
- `)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Dn({find:b0,type:this.type})]}}),w0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,k0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,v0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,S0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,C0=wt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return to("strong",{...re(this.options.HTMLAttributes,n),children:to("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[sn({find:w0,type:this.type}),sn({find:v0,type:this.type})]},addPasteRules(){return[Ht({find:k0,type:this.type}),Ht({find:S0,type:this.type})]}}),M0=/(^|[^`])`([^`]+)`(?!`)$/,E0=/(^|[^`])`([^`]+)`(?!`)/g,T0=wt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",re(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,e)=>e.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,e)=>n.content?`\`${e.renderChildren(n.content)}\``:"",addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[sn({find:M0,type:this.type})]},addPasteRules(){return[Ht({find:E0,type:this.type})]}}),ws=4,N0=/^```([a-z]+)?[\s\n]$/,A0=/^~~~([a-z]+)?[\s\n]$/,O0=ve.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:ws,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;return t&&[...((e=n.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0]||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",re(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,e)=>{var t;return((t=n.raw)==null?void 0:t.startsWith("```"))===!1&&n.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:n.lang||null},n.text?[e.createTextNode(n.text)]:[])},renderMarkdown:(n,e)=>{var t;let r="";const o=((t=n.attrs)==null?void 0:t.language)||"";return n.content?r=[`\`\`\`${o}`,e.renderChildren(n.content),"```"].join(`
117
+ `)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Dn({find:x0,type:this.type})]}}),k0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,v0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,S0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,C0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,M0=wt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return to("strong",{...re(this.options.HTMLAttributes,n),children:to("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[sn({find:k0,type:this.type}),sn({find:S0,type:this.type})]},addPasteRules(){return[Ht({find:v0,type:this.type}),Ht({find:C0,type:this.type})]}}),E0=/(^|[^`])`([^`]+)`(?!`)$/,T0=/(^|[^`])`([^`]+)`(?!`)/g,N0=wt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",re(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,e)=>e.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,e)=>n.content?`\`${e.renderChildren(n.content)}\``:"",addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[sn({find:E0,type:this.type})]},addPasteRules(){return[Ht({find:T0,type:this.type})]}}),ws=4,A0=/^```([a-z]+)?[\s\n]$/,O0=/^~~~([a-z]+)?[\s\n]$/,R0=ve.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:ws,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;return t&&[...((e=n.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0]||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",re(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,e)=>{var t;return((t=n.raw)==null?void 0:t.startsWith("```"))===!1&&n.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:n.lang||null},n.text?[e.createTextNode(n.text)]:[])},renderMarkdown:(n,e)=>{var t;let r="";const o=((t=n.attrs)==null?void 0:t.language)||"";return n.content?r=[`\`\`\`${o}`,e.renderChildren(n.content),"```"].join(`
118
118
  `):r=`\`\`\`${o}
119
119
 
120
120
  \`\`\``,r},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:ws,{state:r}=n,{selection:o}=r,{$from:s,empty:i}=o;if(s.parent.type!==this.type)return!1;const a=" ".repeat(t);return i?n.commands.insertContent(a):n.commands.command(({tr:l})=>{const{from:c,to:d}=o,u=r.doc.textBetween(c,d,`
@@ -130,25 +130,25 @@ ${t}
130
130
  `).map(u=>{var h;const p=((h=u.match(/^ */))==null?void 0:h[0])||"",f=Math.min(p.length,t);return u.slice(f)}).join(`
131
131
  `);return a.replaceWith(l,c,r.schema.text(d)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:o}=t;if(!o||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
132
132
 
133
- `);return!s||!i?!1:n.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:o,empty:s}=t;if(!s||o.parent.type!==this.type||o.parentOffset!==o.parent.nodeSize-2)return!1;const i=o.after();return i===void 0?!1:r.nodeAt(i)?n.commands.command(({tr:a})=>(a.setSelection(W.near(r.resolve(i))),!0)):n.commands.exitCode()}}},addInputRules(){return[Zs({find:N0,type:this.type,getAttributes:n=>({language:n[1]})}),Zs({find:A0,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new le({key:new he("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,s=o?.mode;if(!t||!s)return!1;const{tr:i,schema:a}=n.state,l=a.text(t.replace(/\r\n?/g,`
134
- `));return i.replaceSelectionWith(this.type.create({language:s},l)),i.selection.$from.parent.type!==this.type&&i.setSelection(H.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),n.dispatch(i),!0}}})]}}),R0=ve.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
133
+ `);return!s||!i?!1:n.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:o,empty:s}=t;if(!s||o.parent.type!==this.type||o.parentOffset!==o.parent.nodeSize-2)return!1;const i=o.after();return i===void 0?!1:r.nodeAt(i)?n.commands.command(({tr:a})=>(a.setSelection(W.near(r.resolve(i))),!0)):n.commands.exitCode()}}},addInputRules(){return[Zs({find:A0,type:this.type,getAttributes:n=>({language:n[1]})}),Zs({find:O0,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new le({key:new he("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,s=o?.mode;if(!t||!s)return!1;const{tr:i,schema:a}=n.state,l=a.text(t.replace(/\r\n?/g,`
134
+ `));return i.replaceSelectionWith(this.type.create({language:s},l)),i.selection.$from.parent.type!==this.type&&i.setSelection(H.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),n.dispatch(i),!0}}})]}}),D0=ve.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
135
135
 
136
- `):""}),D0=ve.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",re(this.options.HTMLAttributes,n)]},renderText(){return`
136
+ `):""}),j0=ve.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",re(this.options.HTMLAttributes,n)]},renderText(){return`
137
137
  `},renderMarkdown:()=>`
138
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:o,storedMarks:s}=t;if(o.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:a}=r.extensionManager,l=s||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&l&&i){const u=l.filter(h=>a.includes(h.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),j0=ve.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(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,re(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const r=(t=n.attrs)!=null&&t.level?parseInt(n.attrs.level,10):1,o="#".repeat(r);return n.content?`${o} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Zs({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),L0=ve.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",re(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!By(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:r}=t,o=n();return gu(t)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({state:s,tr:i,dispatch:a})=>{if(a){const{$to:l}=i.selection,c=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?i.setSelection(H.create(i.doc,l.pos+1)):l.nodeAfter.isBlock?i.setSelection(I.create(i.doc,l.pos)):i.setSelection(H.create(i.doc,l.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,u=d?.create();u&&(i.insert(c,u),i.setSelection(H.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Ru({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),z0=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,$0=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,I0=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,P0=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,H0=wt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",re(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[sn({find:z0,type:this.type}),sn({find:I0,type:this.type})]},addPasteRules(){return[Ht({find:$0,type:this.type}),Ht({find:P0,type:this.type})]}});const B0="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",V0="ελ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",ai="numeric",li="ascii",ci="alpha",Gn="asciinumeric",_n="alphanumeric",di="domain",Xu="emoji",F0="scheme",W0="slashscheme",ks="whitespace";function _0(n,e){return n in e||(e[n]=[]),e[n]}function Gt(n,e,t){e[ai]&&(e[Gn]=!0,e[_n]=!0),e[li]&&(e[Gn]=!0,e[ci]=!0),e[Gn]&&(e[_n]=!0),e[ci]&&(e[_n]=!0),e[_n]&&(e[di]=!0),e[Xu]&&(e[di]=!0);for(const r in e){const o=_0(r,t);o.indexOf(n)<0&&o.push(n)}}function U0(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Ie(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Ie.groups={};Ie.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const o=e.jr[r][0],s=e.jr[r][1];if(s&&o.test(n))return s}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let o=0;o<n.length;o++)this.tt(n[o],e,t,r)},tr(n,e,t,r){r=r||Ie.groups;let o;return e&&e.j?o=e:(o=new Ie(e),t&&r&&Gt(e,t,r)),this.jr.push([n,o]),o},ts(n,e,t,r){let o=this;const s=n.length;if(!s)return o;for(let i=0;i<s-1;i++)o=o.tt(n[i]);return o.tt(n[s-1],e,t,r)},tt(n,e,t,r){r=r||Ie.groups;const o=this;if(e&&e.j)return o.j[n]=e,e;const s=e;let i,a=o.go(n);if(a?(i=new Ie,Object.assign(i.j,a.j),i.jr.push.apply(i.jr,a.jr),i.jd=a.jd,i.t=a.t):i=new Ie,s){if(r)if(i.t&&typeof i.t=="string"){const l=Object.assign(U0(i.t,r),t);Gt(s,l,r)}else t&&Gt(s,t,r);i.t=s}return o.j[n]=i,i}};const K=(n,e,t,r,o)=>n.ta(e,t,r,o),ce=(n,e,t,r,o)=>n.tr(e,t,r,o),Bl=(n,e,t,r,o)=>n.ts(e,t,r,o),A=(n,e,t,r,o)=>n.tt(e,t,r,o),ft="WORD",ui="UWORD",Yu="ASCIINUMERICAL",Qu="ALPHANUMERICAL",ur="LOCALHOST",hi="TLD",pi="UTLD",Vr="SCHEME",vn="SLASH_SCHEME",Qi="NUM",fi="WS",Zi="NL",Xn="OPENBRACE",Yn="CLOSEBRACE",no="OPENBRACKET",ro="CLOSEBRACKET",oo="OPENPAREN",so="CLOSEPAREN",io="OPENANGLEBRACKET",ao="CLOSEANGLEBRACKET",lo="FULLWIDTHLEFTPAREN",co="FULLWIDTHRIGHTPAREN",uo="LEFTCORNERBRACKET",ho="RIGHTCORNERBRACKET",po="LEFTWHITECORNERBRACKET",fo="RIGHTWHITECORNERBRACKET",mo="FULLWIDTHLESSTHAN",go="FULLWIDTHGREATERTHAN",yo="AMPERSAND",bo="APOSTROPHE",xo="ASTERISK",Mt="AT",wo="BACKSLASH",ko="BACKTICK",vo="CARET",At="COLON",ea="COMMA",So="DOLLAR",rt="DOT",Co="EQUALS",ta="EXCLAMATION",Ue="HYPHEN",Qn="PERCENT",Mo="PIPE",Eo="PLUS",To="POUND",Zn="QUERY",na="QUOTE",Zu="FULLWIDTHMIDDLEDOT",ra="SEMI",ot="SLASH",er="TILDE",No="UNDERSCORE",eh="EMOJI",Ao="SYM";var th=Object.freeze({__proto__:null,ALPHANUMERICAL:Qu,AMPERSAND:yo,APOSTROPHE:bo,ASCIINUMERICAL:Yu,ASTERISK:xo,AT:Mt,BACKSLASH:wo,BACKTICK:ko,CARET:vo,CLOSEANGLEBRACKET:ao,CLOSEBRACE:Yn,CLOSEBRACKET:ro,CLOSEPAREN:so,COLON:At,COMMA:ea,DOLLAR:So,DOT:rt,EMOJI:eh,EQUALS:Co,EXCLAMATION:ta,FULLWIDTHGREATERTHAN:go,FULLWIDTHLEFTPAREN:lo,FULLWIDTHLESSTHAN:mo,FULLWIDTHMIDDLEDOT:Zu,FULLWIDTHRIGHTPAREN:co,HYPHEN:Ue,LEFTCORNERBRACKET:uo,LEFTWHITECORNERBRACKET:po,LOCALHOST:ur,NL:Zi,NUM:Qi,OPENANGLEBRACKET:io,OPENBRACE:Xn,OPENBRACKET:no,OPENPAREN:oo,PERCENT:Qn,PIPE:Mo,PLUS:Eo,POUND:To,QUERY:Zn,QUOTE:na,RIGHTCORNERBRACKET:ho,RIGHTWHITECORNERBRACKET:fo,SCHEME:Vr,SEMI:ra,SLASH:ot,SLASH_SCHEME:vn,SYM:Ao,TILDE:er,TLD:hi,UNDERSCORE:No,UTLD:pi,UWORD:ui,WORD:ft,WS:fi});const dt=/[a-z]/,Hn=new RegExp("\\p{L}","u"),vs=new RegExp("\\p{Emoji}","u"),ut=/\d/,Ss=/\s/,Vl="\r",Cs=`
139
- `,q0="️",K0="‍",Ms="";let Or=null,Rr=null;function J0(n=[]){const e={};Ie.groups=e;const t=new Ie;Or==null&&(Or=Fl(B0)),Rr==null&&(Rr=Fl(V0)),A(t,"'",bo),A(t,"{",Xn),A(t,"}",Yn),A(t,"[",no),A(t,"]",ro),A(t,"(",oo),A(t,")",so),A(t,"<",io),A(t,">",ao),A(t,"(",lo),A(t,")",co),A(t,"「",uo),A(t,"」",ho),A(t,"『",po),A(t,"』",fo),A(t,"<",mo),A(t,">",go),A(t,"&",yo),A(t,"*",xo),A(t,"@",Mt),A(t,"`",ko),A(t,"^",vo),A(t,":",At),A(t,",",ea),A(t,"$",So),A(t,".",rt),A(t,"=",Co),A(t,"!",ta),A(t,"-",Ue),A(t,"%",Qn),A(t,"|",Mo),A(t,"+",Eo),A(t,"#",To),A(t,"?",Zn),A(t,'"',na),A(t,"/",ot),A(t,";",ra),A(t,"~",er),A(t,"_",No),A(t,"\\",wo),A(t,"・",Zu);const r=ce(t,ut,Qi,{[ai]:!0});ce(r,ut,r);const o=ce(r,dt,Yu,{[Gn]:!0}),s=ce(r,Hn,Qu,{[_n]:!0}),i=ce(t,dt,ft,{[li]:!0});ce(i,ut,o),ce(i,dt,i),ce(o,ut,o),ce(o,dt,o);const a=ce(t,Hn,ui,{[ci]:!0});ce(a,dt),ce(a,ut,s),ce(a,Hn,a),ce(s,ut,s),ce(s,dt),ce(s,Hn,s);const l=A(t,Cs,Zi,{[ks]:!0}),c=A(t,Vl,fi,{[ks]:!0}),d=ce(t,Ss,fi,{[ks]:!0});A(t,Ms,d),A(c,Cs,l),A(c,Ms,d),ce(c,Ss,d),A(d,Vl),A(d,Cs),ce(d,Ss,d),A(d,Ms,d);const u=ce(t,vs,eh,{[Xu]:!0});A(u,"#"),ce(u,vs,u),A(u,q0,u);const h=A(u,K0);A(h,"#"),ce(h,vs,u);const p=[[dt,i],[ut,o]],f=[[dt,null],[Hn,a],[ut,s]];for(let m=0;m<Or.length;m++)kt(t,Or[m],hi,ft,p);for(let m=0;m<Rr.length;m++)kt(t,Rr[m],pi,ui,f);Gt(hi,{tld:!0,ascii:!0},e),Gt(pi,{utld:!0,alpha:!0},e),kt(t,"file",Vr,ft,p),kt(t,"mailto",Vr,ft,p),kt(t,"http",vn,ft,p),kt(t,"https",vn,ft,p),kt(t,"ftp",vn,ft,p),kt(t,"ftps",vn,ft,p),Gt(Vr,{scheme:!0,ascii:!0},e),Gt(vn,{slashscheme:!0,ascii:!0},e),n=n.sort((m,g)=>m[0]>g[0]?1:-1);for(let m=0;m<n.length;m++){const g=n[m][0],y=n[m][1]?{[F0]:!0}:{[W0]:!0};g.indexOf("-")>=0?y[di]=!0:dt.test(g)?ut.test(g)?y[Gn]=!0:y[li]=!0:y[ai]=!0,Bl(t,g,g,y)}return Bl(t,"localhost",ur,{ascii:!0}),t.jd=new Ie(Ao),{start:t,tokens:Object.assign({groups:e},th)}}function nh(n,e){const t=G0(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=t.length,o=[];let s=0,i=0;for(;i<r;){let a=n,l=null,c=0,d=null,u=-1,h=-1;for(;i<r&&(l=a.go(t[i]));)a=l,a.accepts()?(u=0,h=0,d=a):u>=0&&(u+=t[i].length,h++),c+=t[i].length,s+=t[i].length,i++;s-=u,i-=h,c-=u,o.push({t:d.t,v:e.slice(s-c,s),s:s-c,e:s})}return o}function G0(n){const e=[],t=n.length;let r=0;for(;r<t;){let o=n.charCodeAt(r),s,i=o<55296||o>56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(i),r+=i.length}return e}function kt(n,e,t,r,o){let s;const i=e.length;for(let a=0;a<i-1;a++){const l=e[a];n.j[l]?s=n.j[l]:(s=new Ie(r),s.jr=o.slice(),n.j[l]=s),n=s}return s=new Ie(t),s.jr=o.slice(),n.j[e[i-1]]=s,s}function Fl(n){const e=[],t=[];let r=0,o="0123456789";for(;r<n.length;){let s=0;for(;o.indexOf(n[r+s])>=0;)s++;if(s>0){e.push(t.join(""));for(let i=parseInt(n.substring(r,r+s),10);i>0;i--)t.pop();r+=s}else t.push(n[r]),r++}return e}const hr={defaultProtocol:"http",events:null,format:Wl,formatHref:Wl,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function oa(n,e=null){let t=Object.assign({},hr);n&&(t=Object.assign(t,n instanceof oa?n.o:n));const r=t.ignoreTags,o=[];for(let s=0;s<r.length;s++)o.push(r[s].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=o}oa.prototype={o:hr,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let o=this.o[n];return o&&(typeof o=="object"?(o=t.t in o?o[t.t]:hr[n],typeof o=="function"&&r&&(o=o(e,t))):typeof o=="function"&&r&&(o=o(e,t.t,t)),o)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function Wl(n){return n}function rh(n,e){this.t="token",this.v=n,this.tk=e}rh.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=hr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),o=n.get("tagName",t,e),s=this.toFormattedString(n),i={},a=n.get("className",t,e),l=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return i.href=r,a&&(i.class=a),l&&(i.target=l),c&&(i.rel=c),d&&Object.assign(i,d),{tagName:o,attributes:i,content:s,eventListeners:u}}};function Xo(n,e){class t extends rh{constructor(o,s){super(o,s),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const _l=Xo("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Ul=Xo("text"),X0=Xo("nl"),Dr=Xo("url",{isLink:!0,toHref(n=hr.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==ur&&n[1].t===At}}),_e=n=>new Ie(n);function Y0({groups:n}){const e=n.domain.concat([yo,xo,Mt,wo,ko,vo,So,Co,Ue,Qi,Qn,Mo,Eo,To,ot,Ao,er,No]),t=[bo,At,ea,rt,ta,Qn,Zn,na,ra,io,ao,Xn,Yn,ro,no,oo,so,lo,co,uo,ho,po,fo,mo,go],r=[yo,bo,xo,wo,ko,vo,So,Co,Ue,Xn,Yn,Qn,Mo,Eo,To,Zn,ot,Ao,er,No],o=_e(),s=A(o,er);K(s,r,s),K(s,n.domain,s);const i=_e(),a=_e(),l=_e();K(o,n.domain,i),K(o,n.scheme,a),K(o,n.slashscheme,l),K(i,r,s),K(i,n.domain,i);const c=A(i,Mt);A(s,Mt,c),A(a,Mt,c),A(l,Mt,c);const d=A(s,rt);K(d,r,s),K(d,n.domain,s);const u=_e();K(c,n.domain,u),K(u,n.domain,u);const h=A(u,rt);K(h,n.domain,u);const p=_e(_l);K(h,n.tld,p),K(h,n.utld,p),A(c,ur,p);const f=A(u,Ue);A(f,Ue,f),K(f,n.domain,u),K(p,n.domain,u),A(p,rt,h),A(p,Ue,f);const m=A(p,At);K(m,n.numeric,_l);const g=A(i,Ue),y=A(i,rt);A(g,Ue,g),K(g,n.domain,i),K(y,r,s),K(y,n.domain,i);const w=_e(Dr);K(y,n.tld,w),K(y,n.utld,w),K(w,n.domain,i),K(w,r,s),A(w,rt,y),A(w,Ue,g),A(w,Mt,c);const x=A(w,At),E=_e(Dr);K(x,n.numeric,E);const b=_e(Dr),T=_e();K(b,e,b),K(b,t,T),K(T,e,b),K(T,t,T),A(w,ot,b),A(E,ot,b);const v=A(a,At),S=A(l,At),R=A(S,ot),_=A(R,ot);K(a,n.domain,i),A(a,rt,y),A(a,Ue,g),K(l,n.domain,i),A(l,rt,y),A(l,Ue,g),K(v,n.domain,b),A(v,ot,b),A(v,Zn,b),K(_,n.domain,b),K(_,e,b),A(_,ot,b);const $=[[Xn,Yn],[no,ro],[oo,so],[io,ao],[lo,co],[uo,ho],[po,fo],[mo,go]];for(let Y=0;Y<$.length;Y++){const[pe,Z]=$[Y],q=A(b,pe);A(T,pe,q),A(q,Z,b);const X=_e(Dr);K(q,e,X);const ee=_e();K(q,t),K(X,e,X),K(X,t,ee),K(ee,e,X),K(ee,t,ee),A(X,Z,b),A(ee,Z,b)}return A(o,ur,w),A(o,Zi,X0),{start:o,tokens:th}}function Q0(n,e,t){let r=t.length,o=0,s=[],i=[];for(;o<r;){let a=n,l=null,c=null,d=0,u=null,h=-1;for(;o<r&&!(l=a.go(t[o].t));)i.push(t[o++]);for(;o<r&&(c=l||a.go(t[o].t));)l=null,a=c,a.accepts()?(h=0,u=a):h>=0&&h++,o++,d++;if(h<0)o-=d,o<r&&(i.push(t[o]),o++);else{i.length>0&&(s.push(Es(Ul,e,i)),i=[]),o-=h,d-=h;const p=u.t,f=t.slice(o-d,o);s.push(Es(p,e,f))}}return i.length>0&&s.push(Es(Ul,e,i)),s}function Es(n,e,t){const r=t[0].s,o=t[t.length-1].e,s=e.slice(r,o);return new n(s,t)}const Z0=typeof console<"u"&&console&&console.warn||(()=>{}),e1="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ae={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function t1(){return Ie.groups={},ae.scanner=null,ae.parser=null,ae.tokenQueue=[],ae.pluginQueue=[],ae.customSchemes=[],ae.initialized=!1,ae}function ql(n,e=!1){if(ae.initialized&&Z0(`linkifyjs: already initialized - will not register custom scheme "${n}" ${e1}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
138
+ `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:o,storedMarks:s}=t;if(o.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:a}=r.extensionManager,l=s||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&l&&i){const u=l.filter(h=>a.includes(h.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),L0=ve.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(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,re(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const r=(t=n.attrs)!=null&&t.level?parseInt(n.attrs.level,10):1,o="#".repeat(r);return n.content?`${o} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Zs({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),z0=ve.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",re(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!Vy(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:r}=t,o=n();return yu(t)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({state:s,tr:i,dispatch:a})=>{if(a){const{$to:l}=i.selection,c=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?i.setSelection(H.create(i.doc,l.pos+1)):l.nodeAfter.isBlock?i.setSelection(I.create(i.doc,l.pos)):i.setSelection(H.create(i.doc,l.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,u=d?.create();u&&(i.insert(c,u),i.setSelection(H.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Du({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),$0=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,I0=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,P0=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,H0=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,B0=wt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",re(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[sn({find:$0,type:this.type}),sn({find:P0,type:this.type})]},addPasteRules(){return[Ht({find:I0,type:this.type}),Ht({find:H0,type:this.type})]}});const V0="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",F0="ελ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",ai="numeric",li="ascii",ci="alpha",Gn="asciinumeric",_n="alphanumeric",di="domain",Yu="emoji",W0="scheme",_0="slashscheme",ks="whitespace";function U0(n,e){return n in e||(e[n]=[]),e[n]}function Gt(n,e,t){e[ai]&&(e[Gn]=!0,e[_n]=!0),e[li]&&(e[Gn]=!0,e[ci]=!0),e[Gn]&&(e[_n]=!0),e[ci]&&(e[_n]=!0),e[_n]&&(e[di]=!0),e[Yu]&&(e[di]=!0);for(const r in e){const o=U0(r,t);o.indexOf(n)<0&&o.push(n)}}function q0(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Ie(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Ie.groups={};Ie.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const o=e.jr[r][0],s=e.jr[r][1];if(s&&o.test(n))return s}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let o=0;o<n.length;o++)this.tt(n[o],e,t,r)},tr(n,e,t,r){r=r||Ie.groups;let o;return e&&e.j?o=e:(o=new Ie(e),t&&r&&Gt(e,t,r)),this.jr.push([n,o]),o},ts(n,e,t,r){let o=this;const s=n.length;if(!s)return o;for(let i=0;i<s-1;i++)o=o.tt(n[i]);return o.tt(n[s-1],e,t,r)},tt(n,e,t,r){r=r||Ie.groups;const o=this;if(e&&e.j)return o.j[n]=e,e;const s=e;let i,a=o.go(n);if(a?(i=new Ie,Object.assign(i.j,a.j),i.jr.push.apply(i.jr,a.jr),i.jd=a.jd,i.t=a.t):i=new Ie,s){if(r)if(i.t&&typeof i.t=="string"){const l=Object.assign(q0(i.t,r),t);Gt(s,l,r)}else t&&Gt(s,t,r);i.t=s}return o.j[n]=i,i}};const q=(n,e,t,r,o)=>n.ta(e,t,r,o),ce=(n,e,t,r,o)=>n.tr(e,t,r,o),Vl=(n,e,t,r,o)=>n.ts(e,t,r,o),A=(n,e,t,r,o)=>n.tt(e,t,r,o),ft="WORD",ui="UWORD",Qu="ASCIINUMERICAL",Zu="ALPHANUMERICAL",ur="LOCALHOST",hi="TLD",pi="UTLD",Vr="SCHEME",vn="SLASH_SCHEME",Qi="NUM",fi="WS",Zi="NL",Xn="OPENBRACE",Yn="CLOSEBRACE",no="OPENBRACKET",ro="CLOSEBRACKET",oo="OPENPAREN",so="CLOSEPAREN",io="OPENANGLEBRACKET",ao="CLOSEANGLEBRACKET",lo="FULLWIDTHLEFTPAREN",co="FULLWIDTHRIGHTPAREN",uo="LEFTCORNERBRACKET",ho="RIGHTCORNERBRACKET",po="LEFTWHITECORNERBRACKET",fo="RIGHTWHITECORNERBRACKET",mo="FULLWIDTHLESSTHAN",go="FULLWIDTHGREATERTHAN",yo="AMPERSAND",bo="APOSTROPHE",xo="ASTERISK",Mt="AT",wo="BACKSLASH",ko="BACKTICK",vo="CARET",At="COLON",ea="COMMA",So="DOLLAR",rt="DOT",Co="EQUALS",ta="EXCLAMATION",Ue="HYPHEN",Qn="PERCENT",Mo="PIPE",Eo="PLUS",To="POUND",Zn="QUERY",na="QUOTE",eh="FULLWIDTHMIDDLEDOT",ra="SEMI",ot="SLASH",er="TILDE",No="UNDERSCORE",th="EMOJI",Ao="SYM";var nh=Object.freeze({__proto__:null,ALPHANUMERICAL:Zu,AMPERSAND:yo,APOSTROPHE:bo,ASCIINUMERICAL:Qu,ASTERISK:xo,AT:Mt,BACKSLASH:wo,BACKTICK:ko,CARET:vo,CLOSEANGLEBRACKET:ao,CLOSEBRACE:Yn,CLOSEBRACKET:ro,CLOSEPAREN:so,COLON:At,COMMA:ea,DOLLAR:So,DOT:rt,EMOJI:th,EQUALS:Co,EXCLAMATION:ta,FULLWIDTHGREATERTHAN:go,FULLWIDTHLEFTPAREN:lo,FULLWIDTHLESSTHAN:mo,FULLWIDTHMIDDLEDOT:eh,FULLWIDTHRIGHTPAREN:co,HYPHEN:Ue,LEFTCORNERBRACKET:uo,LEFTWHITECORNERBRACKET:po,LOCALHOST:ur,NL:Zi,NUM:Qi,OPENANGLEBRACKET:io,OPENBRACE:Xn,OPENBRACKET:no,OPENPAREN:oo,PERCENT:Qn,PIPE:Mo,PLUS:Eo,POUND:To,QUERY:Zn,QUOTE:na,RIGHTCORNERBRACKET:ho,RIGHTWHITECORNERBRACKET:fo,SCHEME:Vr,SEMI:ra,SLASH:ot,SLASH_SCHEME:vn,SYM:Ao,TILDE:er,TLD:hi,UNDERSCORE:No,UTLD:pi,UWORD:ui,WORD:ft,WS:fi});const dt=/[a-z]/,Hn=new RegExp("\\p{L}","u"),vs=new RegExp("\\p{Emoji}","u"),ut=/\d/,Ss=/\s/,Fl="\r",Cs=`
139
+ `,K0="️",J0="‍",Ms="";let Or=null,Rr=null;function G0(n=[]){const e={};Ie.groups=e;const t=new Ie;Or==null&&(Or=Wl(V0)),Rr==null&&(Rr=Wl(F0)),A(t,"'",bo),A(t,"{",Xn),A(t,"}",Yn),A(t,"[",no),A(t,"]",ro),A(t,"(",oo),A(t,")",so),A(t,"<",io),A(t,">",ao),A(t,"(",lo),A(t,")",co),A(t,"「",uo),A(t,"」",ho),A(t,"『",po),A(t,"』",fo),A(t,"<",mo),A(t,">",go),A(t,"&",yo),A(t,"*",xo),A(t,"@",Mt),A(t,"`",ko),A(t,"^",vo),A(t,":",At),A(t,",",ea),A(t,"$",So),A(t,".",rt),A(t,"=",Co),A(t,"!",ta),A(t,"-",Ue),A(t,"%",Qn),A(t,"|",Mo),A(t,"+",Eo),A(t,"#",To),A(t,"?",Zn),A(t,'"',na),A(t,"/",ot),A(t,";",ra),A(t,"~",er),A(t,"_",No),A(t,"\\",wo),A(t,"・",eh);const r=ce(t,ut,Qi,{[ai]:!0});ce(r,ut,r);const o=ce(r,dt,Qu,{[Gn]:!0}),s=ce(r,Hn,Zu,{[_n]:!0}),i=ce(t,dt,ft,{[li]:!0});ce(i,ut,o),ce(i,dt,i),ce(o,ut,o),ce(o,dt,o);const a=ce(t,Hn,ui,{[ci]:!0});ce(a,dt),ce(a,ut,s),ce(a,Hn,a),ce(s,ut,s),ce(s,dt),ce(s,Hn,s);const l=A(t,Cs,Zi,{[ks]:!0}),c=A(t,Fl,fi,{[ks]:!0}),d=ce(t,Ss,fi,{[ks]:!0});A(t,Ms,d),A(c,Cs,l),A(c,Ms,d),ce(c,Ss,d),A(d,Fl),A(d,Cs),ce(d,Ss,d),A(d,Ms,d);const u=ce(t,vs,th,{[Yu]:!0});A(u,"#"),ce(u,vs,u),A(u,K0,u);const h=A(u,J0);A(h,"#"),ce(h,vs,u);const p=[[dt,i],[ut,o]],f=[[dt,null],[Hn,a],[ut,s]];for(let m=0;m<Or.length;m++)kt(t,Or[m],hi,ft,p);for(let m=0;m<Rr.length;m++)kt(t,Rr[m],pi,ui,f);Gt(hi,{tld:!0,ascii:!0},e),Gt(pi,{utld:!0,alpha:!0},e),kt(t,"file",Vr,ft,p),kt(t,"mailto",Vr,ft,p),kt(t,"http",vn,ft,p),kt(t,"https",vn,ft,p),kt(t,"ftp",vn,ft,p),kt(t,"ftps",vn,ft,p),Gt(Vr,{scheme:!0,ascii:!0},e),Gt(vn,{slashscheme:!0,ascii:!0},e),n=n.sort((m,g)=>m[0]>g[0]?1:-1);for(let m=0;m<n.length;m++){const g=n[m][0],y=n[m][1]?{[W0]:!0}:{[_0]:!0};g.indexOf("-")>=0?y[di]=!0:dt.test(g)?ut.test(g)?y[Gn]=!0:y[li]=!0:y[ai]=!0,Vl(t,g,g,y)}return Vl(t,"localhost",ur,{ascii:!0}),t.jd=new Ie(Ao),{start:t,tokens:Object.assign({groups:e},nh)}}function rh(n,e){const t=X0(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=t.length,o=[];let s=0,i=0;for(;i<r;){let a=n,l=null,c=0,d=null,u=-1,h=-1;for(;i<r&&(l=a.go(t[i]));)a=l,a.accepts()?(u=0,h=0,d=a):u>=0&&(u+=t[i].length,h++),c+=t[i].length,s+=t[i].length,i++;s-=u,i-=h,c-=u,o.push({t:d.t,v:e.slice(s-c,s),s:s-c,e:s})}return o}function X0(n){const e=[],t=n.length;let r=0;for(;r<t;){let o=n.charCodeAt(r),s,i=o<55296||o>56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(i),r+=i.length}return e}function kt(n,e,t,r,o){let s;const i=e.length;for(let a=0;a<i-1;a++){const l=e[a];n.j[l]?s=n.j[l]:(s=new Ie(r),s.jr=o.slice(),n.j[l]=s),n=s}return s=new Ie(t),s.jr=o.slice(),n.j[e[i-1]]=s,s}function Wl(n){const e=[],t=[];let r=0,o="0123456789";for(;r<n.length;){let s=0;for(;o.indexOf(n[r+s])>=0;)s++;if(s>0){e.push(t.join(""));for(let i=parseInt(n.substring(r,r+s),10);i>0;i--)t.pop();r+=s}else t.push(n[r]),r++}return e}const hr={defaultProtocol:"http",events:null,format:_l,formatHref:_l,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function oa(n,e=null){let t=Object.assign({},hr);n&&(t=Object.assign(t,n instanceof oa?n.o:n));const r=t.ignoreTags,o=[];for(let s=0;s<r.length;s++)o.push(r[s].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=o}oa.prototype={o:hr,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let o=this.o[n];return o&&(typeof o=="object"?(o=t.t in o?o[t.t]:hr[n],typeof o=="function"&&r&&(o=o(e,t))):typeof o=="function"&&r&&(o=o(e,t.t,t)),o)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function _l(n){return n}function oh(n,e){this.t="token",this.v=n,this.tk=e}oh.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=hr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),o=n.get("tagName",t,e),s=this.toFormattedString(n),i={},a=n.get("className",t,e),l=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return i.href=r,a&&(i.class=a),l&&(i.target=l),c&&(i.rel=c),d&&Object.assign(i,d),{tagName:o,attributes:i,content:s,eventListeners:u}}};function Xo(n,e){class t extends oh{constructor(o,s){super(o,s),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const Ul=Xo("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),ql=Xo("text"),Y0=Xo("nl"),Dr=Xo("url",{isLink:!0,toHref(n=hr.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==ur&&n[1].t===At}}),_e=n=>new Ie(n);function Q0({groups:n}){const e=n.domain.concat([yo,xo,Mt,wo,ko,vo,So,Co,Ue,Qi,Qn,Mo,Eo,To,ot,Ao,er,No]),t=[bo,At,ea,rt,ta,Qn,Zn,na,ra,io,ao,Xn,Yn,ro,no,oo,so,lo,co,uo,ho,po,fo,mo,go],r=[yo,bo,xo,wo,ko,vo,So,Co,Ue,Xn,Yn,Qn,Mo,Eo,To,Zn,ot,Ao,er,No],o=_e(),s=A(o,er);q(s,r,s),q(s,n.domain,s);const i=_e(),a=_e(),l=_e();q(o,n.domain,i),q(o,n.scheme,a),q(o,n.slashscheme,l),q(i,r,s),q(i,n.domain,i);const c=A(i,Mt);A(s,Mt,c),A(a,Mt,c),A(l,Mt,c);const d=A(s,rt);q(d,r,s),q(d,n.domain,s);const u=_e();q(c,n.domain,u),q(u,n.domain,u);const h=A(u,rt);q(h,n.domain,u);const p=_e(Ul);q(h,n.tld,p),q(h,n.utld,p),A(c,ur,p);const f=A(u,Ue);A(f,Ue,f),q(f,n.domain,u),q(p,n.domain,u),A(p,rt,h),A(p,Ue,f);const m=A(p,At);q(m,n.numeric,Ul);const g=A(i,Ue),y=A(i,rt);A(g,Ue,g),q(g,n.domain,i),q(y,r,s),q(y,n.domain,i);const w=_e(Dr);q(y,n.tld,w),q(y,n.utld,w),q(w,n.domain,i),q(w,r,s),A(w,rt,y),A(w,Ue,g),A(w,Mt,c);const x=A(w,At),E=_e(Dr);q(x,n.numeric,E);const b=_e(Dr),T=_e();q(b,e,b),q(b,t,T),q(T,e,b),q(T,t,T),A(w,ot,b),A(E,ot,b);const v=A(a,At),S=A(l,At),R=A(S,ot),K=A(R,ot);q(a,n.domain,i),A(a,rt,y),A(a,Ue,g),q(l,n.domain,i),A(l,rt,y),A(l,Ue,g),q(v,n.domain,b),A(v,ot,b),A(v,Zn,b),q(K,n.domain,b),q(K,e,b),A(K,ot,b);const $=[[Xn,Yn],[no,ro],[oo,so],[io,ao],[lo,co],[uo,ho],[po,fo],[mo,go]];for(let Y=0;Y<$.length;Y++){const[pe,Z]=$[Y],U=A(b,pe);A(T,pe,U),A(U,Z,b);const X=_e(Dr);q(U,e,X);const ee=_e();q(U,t),q(X,e,X),q(X,t,ee),q(ee,e,X),q(ee,t,ee),A(X,Z,b),A(ee,Z,b)}return A(o,ur,w),A(o,Zi,Y0),{start:o,tokens:nh}}function Z0(n,e,t){let r=t.length,o=0,s=[],i=[];for(;o<r;){let a=n,l=null,c=null,d=0,u=null,h=-1;for(;o<r&&!(l=a.go(t[o].t));)i.push(t[o++]);for(;o<r&&(c=l||a.go(t[o].t));)l=null,a=c,a.accepts()?(h=0,u=a):h>=0&&h++,o++,d++;if(h<0)o-=d,o<r&&(i.push(t[o]),o++);else{i.length>0&&(s.push(Es(ql,e,i)),i=[]),o-=h,d-=h;const p=u.t,f=t.slice(o-d,o);s.push(Es(p,e,f))}}return i.length>0&&s.push(Es(ql,e,i)),s}function Es(n,e,t){const r=t[0].s,o=t[t.length-1].e,s=e.slice(r,o);return new n(s,t)}const e1=typeof console<"u"&&console&&console.warn||(()=>{}),t1="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ae={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function n1(){return Ie.groups={},ae.scanner=null,ae.parser=null,ae.tokenQueue=[],ae.pluginQueue=[],ae.customSchemes=[],ae.initialized=!1,ae}function Kl(n,e=!1){if(ae.initialized&&e1(`linkifyjs: already initialized - will not register custom scheme "${n}" ${t1}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
140
140
  1. Must only contain digits, lowercase ASCII letters or "-"
141
141
  2. Cannot start or end with "-"
142
- 3. "-" cannot repeat`);ae.customSchemes.push([n,e])}function n1(){ae.scanner=J0(ae.customSchemes);for(let n=0;n<ae.tokenQueue.length;n++)ae.tokenQueue[n][1]({scanner:ae.scanner});ae.parser=Y0(ae.scanner.tokens);for(let n=0;n<ae.pluginQueue.length;n++)ae.pluginQueue[n][1]({scanner:ae.scanner,parser:ae.parser});return ae.initialized=!0,ae}function sa(n){return ae.initialized||n1(),Q0(ae.parser.start,n,nh(ae.scanner.start,n))}sa.scan=nh;function oh(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new oa(t),o=sa(n),s=[];for(let i=0;i<o.length;i++){const a=o[i];a.isLink&&(!e||a.t===e)&&r.check(a)&&s.push(a.toFormattedObject(r))}return s}var ia="[\0-   ᠎ -\u2029  ]",r1=new RegExp(ia),o1=new RegExp(`${ia}$`),s1=new RegExp(ia,"g");function i1(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function a1(n){return new le({key:new he("autolink"),appendTransaction:(e,t,r)=>{const o=e.some(l=>l.docChanged)&&!t.doc.eq(r.doc),s=e.some(l=>l.getMeta("preventAutolink"));if(!o||s)return;const{tr:i}=r,a=au(t.doc,[...e]);if(mu(a).forEach(({newRange:l})=>{const c=Fg(r.doc,l,h=>h.isTextblock);let d,u;if(c.length>1)d=c[0],u=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(c.length){const h=r.doc.textBetween(l.from,l.to," "," ");if(!o1.test(h))return;d=c[0],u=r.doc.textBetween(d.pos,l.to,void 0," ")}if(d&&u){const h=u.split(r1).filter(Boolean);if(h.length<=0)return!1;const p=h[h.length-1],f=d.pos+u.lastIndexOf(p);if(!p)return!1;const m=sa(p).map(g=>g.toObject(n.defaultProtocol));if(!i1(m))return!1;m.filter(g=>g.isLink).map(g=>({...g,from:f+g.start+1,to:f+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>n.validate(g.value)).filter(g=>n.shouldAutoLink(g.value)).forEach(g=>{qi(g.from,g.to,r.doc).some(y=>y.mark.type===n.type)||i.addMark(g.from,g.to,n.type.create({href:g.href}))})}}),!!i.steps.length)return i}})}function l1(n){return new le({key:new he("handleClickLink"),props:{handleClick:(e,t,r)=>{var o,s;if(r.button!==0||!e.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let d=r.target;const u=[];for(;d.nodeName!=="DIV";)u.push(d),d=d.parentNode;i=u.find(h=>h.nodeName==="A")}if(!i)return!1;const a=fu(e.state,n.type.name),l=(o=i?.href)!=null?o:a.href,c=(s=i?.target)!=null?s:a.target;return n.enableClickSelection&&n.editor.commands.extendMarkRange(n.type.name),i&&l?(window.open(l,c),!0):!1}}})}function c1(n){return new le({key:new he("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{shouldAutoLink:o}=n,{state:s}=e,{selection:i}=s,{empty:a}=i;if(a)return!1;let l="";r.content.forEach(d=>{l+=d.textContent});const c=oh(l,{defaultProtocol:n.defaultProtocol}).find(d=>d.isLink&&d.value===l);return!l||!c||o!==void 0&&!o(c.href)?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function Wt(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const o=typeof r=="string"?r:r.scheme;o&&t.push(o)}),!n||n.replace(s1,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var d1=wt.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(n=>{if(typeof n=="string"){ql(n);return}ql(n.scheme,n.optionalSlashes)})},onDestroy(){t1()},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:(n,e)=>!!Wt(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.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:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Wt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Wt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",re(this.options.HTMLAttributes,n),0]:["a",re(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t;const r=((t=n.attrs)==null?void 0:t.href)||"";return`[${e.renderChildren(n)}](${r})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Wt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!Wt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ht({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,o=oh(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!Wt(i,t),protocols:t,defaultProtocol:r}));o.length&&o.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(a1({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Wt(o,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(l1({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(c1({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),u1=Object.defineProperty,h1=(n,e)=>{for(var t in e)u1(n,t,{get:e[t],enumerable:!0})},p1="listItem",Kl="textStyle",Jl=/^\s*([-+*])\s$/,sh=ve.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:n}){return["ul",re(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
143
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(p1,this.editor.getAttributes(Kl)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Dn({find:Jl,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Dn({find:Jl,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Kl),editor:this.editor})),[n]}}),ih=ve.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",re(this.options.HTMLAttributes,n),0]},markdownTokenName:"list_item",parseMarkdown:(n,e)=>{if(n.type!=="list_item")return[];let t=[];if(n.tokens&&n.tokens.length>0)if(n.tokens.some(r=>r.type==="paragraph"))t=e.parseChildren(n.tokens);else{const r=n.tokens[0];if(r&&r.type==="text"&&r.tokens&&r.tokens.length>0){if(t=[{type:"paragraph",content:e.parseInline(r.tokens)}],n.tokens.length>1){const o=n.tokens.slice(1),s=e.parseChildren(o);t.push(...s)}}else t=e.parseChildren(n.tokens)}return t.length===0&&(t=[{type:"paragraph",content:[]}]),{type:"listItem",content:t}},renderMarkdown:(n,e,t)=>Xi(n,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",t),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),f1={};h1(f1,{findListItemPos:()=>gr,getNextListDepth:()=>aa,handleBackspace:()=>mi,handleDelete:()=>gi,hasListBefore:()=>ah,hasListItemAfter:()=>m1,hasListItemBefore:()=>lh,listItemHasSubList:()=>ch,nextListIsDeeper:()=>dh,nextListIsHigher:()=>uh});var gr=(n,e)=>{const{$from:t}=e.selection,r=me(n,e.schema);let o=null,s=t.depth,i=t.pos,a=null;for(;s>0&&a===null;)o=t.node(s),o.type===r?a=s:(s-=1,i-=1);return a===null?null:{$pos:e.doc.resolve(i),depth:a}},aa=(n,e)=>{const t=gr(n,e);if(!t)return!1;const[,r]=Yg(e,n,t.$pos.pos+4);return r},ah=(n,e,t)=>{const{$anchor:r}=n.selection,o=Math.max(0,r.pos-2),s=n.doc.resolve(o).node();return!(!s||!t.includes(s.type.name))},lh=(n,e)=>{var t;const{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-2);return!(o.index()===0||((t=o.nodeBefore)==null?void 0:t.type.name)!==n)},ch=(n,e,t)=>{if(!t)return!1;const r=me(n,e.schema);let o=!1;return t.descendants(s=>{s.type===r&&(o=!0)}),o},mi=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Pt(n.state,e)&&ah(n.state,e,t)){const{$anchor:i}=n.state.selection,a=n.state.doc.resolve(i.before()-1),l=[];a.node().descendants((u,h)=>{u.type.name===e&&l.push({node:u,pos:h})});const c=l.at(-1);if(!c)return!1;const d=n.state.doc.resolve(a.start()+c.pos+1);return n.chain().cut({from:i.start()-1,to:i.end()+1},d.end()).joinForward().run()}if(!Pt(n.state,e)||!ty(n.state))return!1;const r=gr(e,n.state);if(!r)return!1;const o=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=ch(e,n.state,o);return lh(e,n.state)&&!s?n.commands.joinItemBackward():n.chain().liftListItem(e).run()},dh=(n,e)=>{const t=aa(n,e),r=gr(n,e);return!r||!t?!1:t>r.depth},uh=(n,e)=>{const t=aa(n,e),r=gr(n,e);return!r||!t?!1:t<r.depth},gi=(n,e)=>{if(!Pt(n.state,e)||!ey(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:o}=t;return!t.empty&&r.sameParent(o)?!1:dh(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():uh(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},m1=(n,e)=>{var t;const{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-r.parentOffset-2);return!(o.index()===o.parent.childCount-1||((t=o.nodeAfter)==null?void 0:t.type.name)!==n)},hh=te.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&gi(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&gi(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&mi(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&mi(n,t,r)&&(e=!0)}),e}}}}),Gl=/^(\s*)(\d+)\.\s+(.*)$/,g1=/^\s/;function y1(n){const e=[];let t=0,r=0;for(;t<n.length;){const o=n[t],s=o.match(Gl);if(!s)break;const[,i,a,l]=s,c=i.length;let d=l,u=t+1;const h=[o];for(;u<n.length;){const p=n[u];if(p.match(Gl))break;if(p.trim()==="")h.push(p),d+=`
144
- `,u+=1;else if(p.match(g1))h.push(p),d+=`
142
+ 3. "-" cannot repeat`);ae.customSchemes.push([n,e])}function r1(){ae.scanner=G0(ae.customSchemes);for(let n=0;n<ae.tokenQueue.length;n++)ae.tokenQueue[n][1]({scanner:ae.scanner});ae.parser=Q0(ae.scanner.tokens);for(let n=0;n<ae.pluginQueue.length;n++)ae.pluginQueue[n][1]({scanner:ae.scanner,parser:ae.parser});return ae.initialized=!0,ae}function sa(n){return ae.initialized||r1(),Z0(ae.parser.start,n,rh(ae.scanner.start,n))}sa.scan=rh;function sh(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new oa(t),o=sa(n),s=[];for(let i=0;i<o.length;i++){const a=o[i];a.isLink&&(!e||a.t===e)&&r.check(a)&&s.push(a.toFormattedObject(r))}return s}var ia="[\0-   ᠎ -\u2029  ]",o1=new RegExp(ia),s1=new RegExp(`${ia}$`),i1=new RegExp(ia,"g");function a1(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function l1(n){return new le({key:new he("autolink"),appendTransaction:(e,t,r)=>{const o=e.some(l=>l.docChanged)&&!t.doc.eq(r.doc),s=e.some(l=>l.getMeta("preventAutolink"));if(!o||s)return;const{tr:i}=r,a=lu(t.doc,[...e]);if(gu(a).forEach(({newRange:l})=>{const c=Wg(r.doc,l,h=>h.isTextblock);let d,u;if(c.length>1)d=c[0],u=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(c.length){const h=r.doc.textBetween(l.from,l.to," "," ");if(!s1.test(h))return;d=c[0],u=r.doc.textBetween(d.pos,l.to,void 0," ")}if(d&&u){const h=u.split(o1).filter(Boolean);if(h.length<=0)return!1;const p=h[h.length-1],f=d.pos+u.lastIndexOf(p);if(!p)return!1;const m=sa(p).map(g=>g.toObject(n.defaultProtocol));if(!a1(m))return!1;m.filter(g=>g.isLink).map(g=>({...g,from:f+g.start+1,to:f+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>n.validate(g.value)).filter(g=>n.shouldAutoLink(g.value)).forEach(g=>{qi(g.from,g.to,r.doc).some(y=>y.mark.type===n.type)||i.addMark(g.from,g.to,n.type.create({href:g.href}))})}}),!!i.steps.length)return i}})}function c1(n){return new le({key:new he("handleClickLink"),props:{handleClick:(e,t,r)=>{var o,s;if(r.button!==0||!e.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let d=r.target;const u=[];for(;d.nodeName!=="DIV";)u.push(d),d=d.parentNode;i=u.find(h=>h.nodeName==="A")}if(!i)return!1;const a=mu(e.state,n.type.name),l=(o=i?.href)!=null?o:a.href,c=(s=i?.target)!=null?s:a.target;return n.enableClickSelection&&n.editor.commands.extendMarkRange(n.type.name),i&&l?(window.open(l,c),!0):!1}}})}function d1(n){return new le({key:new he("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{shouldAutoLink:o}=n,{state:s}=e,{selection:i}=s,{empty:a}=i;if(a)return!1;let l="";r.content.forEach(d=>{l+=d.textContent});const c=sh(l,{defaultProtocol:n.defaultProtocol}).find(d=>d.isLink&&d.value===l);return!l||!c||o!==void 0&&!o(c.href)?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function Wt(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const o=typeof r=="string"?r:r.scheme;o&&t.push(o)}),!n||n.replace(i1,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var u1=wt.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(n=>{if(typeof n=="string"){Kl(n);return}Kl(n.scheme,n.optionalSlashes)})},onDestroy(){n1()},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:(n,e)=>!!Wt(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.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:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!Wt(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!Wt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",re(this.options.HTMLAttributes,n),0]:["a",re(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t;const r=((t=n.attrs)==null?void 0:t.href)||"";return`[${e.renderChildren(n)}](${r})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!Wt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!Wt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ht({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,o=sh(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!Wt(i,t),protocols:t,defaultProtocol:r}));o.length&&o.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(l1({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Wt(o,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(c1({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(d1({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),h1=Object.defineProperty,p1=(n,e)=>{for(var t in e)h1(n,t,{get:e[t],enumerable:!0})},f1="listItem",Jl="textStyle",Gl=/^\s*([-+*])\s$/,ih=ve.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:n}){return["ul",re(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
143
+ `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(f1,this.editor.getAttributes(Jl)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Dn({find:Gl,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Dn({find:Gl,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Jl),editor:this.editor})),[n]}}),ah=ve.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",re(this.options.HTMLAttributes,n),0]},markdownTokenName:"list_item",parseMarkdown:(n,e)=>{if(n.type!=="list_item")return[];let t=[];if(n.tokens&&n.tokens.length>0)if(n.tokens.some(r=>r.type==="paragraph"))t=e.parseChildren(n.tokens);else{const r=n.tokens[0];if(r&&r.type==="text"&&r.tokens&&r.tokens.length>0){if(t=[{type:"paragraph",content:e.parseInline(r.tokens)}],n.tokens.length>1){const o=n.tokens.slice(1),s=e.parseChildren(o);t.push(...s)}}else t=e.parseChildren(n.tokens)}return t.length===0&&(t=[{type:"paragraph",content:[]}]),{type:"listItem",content:t}},renderMarkdown:(n,e,t)=>Xi(n,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",t),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),m1={};p1(m1,{findListItemPos:()=>gr,getNextListDepth:()=>aa,handleBackspace:()=>mi,handleDelete:()=>gi,hasListBefore:()=>lh,hasListItemAfter:()=>g1,hasListItemBefore:()=>ch,listItemHasSubList:()=>dh,nextListIsDeeper:()=>uh,nextListIsHigher:()=>hh});var gr=(n,e)=>{const{$from:t}=e.selection,r=me(n,e.schema);let o=null,s=t.depth,i=t.pos,a=null;for(;s>0&&a===null;)o=t.node(s),o.type===r?a=s:(s-=1,i-=1);return a===null?null:{$pos:e.doc.resolve(i),depth:a}},aa=(n,e)=>{const t=gr(n,e);if(!t)return!1;const[,r]=Qg(e,n,t.$pos.pos+4);return r},lh=(n,e,t)=>{const{$anchor:r}=n.selection,o=Math.max(0,r.pos-2),s=n.doc.resolve(o).node();return!(!s||!t.includes(s.type.name))},ch=(n,e)=>{var t;const{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-2);return!(o.index()===0||((t=o.nodeBefore)==null?void 0:t.type.name)!==n)},dh=(n,e,t)=>{if(!t)return!1;const r=me(n,e.schema);let o=!1;return t.descendants(s=>{s.type===r&&(o=!0)}),o},mi=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!Pt(n.state,e)&&lh(n.state,e,t)){const{$anchor:i}=n.state.selection,a=n.state.doc.resolve(i.before()-1),l=[];a.node().descendants((u,h)=>{u.type.name===e&&l.push({node:u,pos:h})});const c=l.at(-1);if(!c)return!1;const d=n.state.doc.resolve(a.start()+c.pos+1);return n.chain().cut({from:i.start()-1,to:i.end()+1},d.end()).joinForward().run()}if(!Pt(n.state,e)||!ny(n.state))return!1;const r=gr(e,n.state);if(!r)return!1;const o=n.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=dh(e,n.state,o);return ch(e,n.state)&&!s?n.commands.joinItemBackward():n.chain().liftListItem(e).run()},uh=(n,e)=>{const t=aa(n,e),r=gr(n,e);return!r||!t?!1:t>r.depth},hh=(n,e)=>{const t=aa(n,e),r=gr(n,e);return!r||!t?!1:t<r.depth},gi=(n,e)=>{if(!Pt(n.state,e)||!ty(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:o}=t;return!t.empty&&r.sameParent(o)?!1:uh(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():hh(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},g1=(n,e)=>{var t;const{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-r.parentOffset-2);return!(o.index()===o.parent.childCount-1||((t=o.nodeAfter)==null?void 0:t.type.name)!==n)},ph=te.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&gi(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&gi(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&mi(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&mi(n,t,r)&&(e=!0)}),e}}}}),Xl=/^(\s*)(\d+)\.\s+(.*)$/,y1=/^\s/;function b1(n){const e=[];let t=0,r=0;for(;t<n.length;){const o=n[t],s=o.match(Xl);if(!s)break;const[,i,a,l]=s,c=i.length;let d=l,u=t+1;const h=[o];for(;u<n.length;){const p=n[u];if(p.match(Xl))break;if(p.trim()==="")h.push(p),d+=`
144
+ `,u+=1;else if(p.match(y1))h.push(p),d+=`
145
145
  ${p.slice(c+2)}`,u+=1;else break}e.push({indent:c,number:parseInt(a,10),content:d.trim(),raw:h.join(`
146
- `)}),r=u,t=u}return[e,r]}function ph(n,e,t){var r;const o=[];let s=0;for(;s<n.length;){const i=n[s];if(i.indent===e){const a=i.content.split(`
146
+ `)}),r=u,t=u}return[e,r]}function fh(n,e,t){var r;const o=[];let s=0;for(;s<n.length;){const i=n[s];if(i.indent===e){const a=i.content.split(`
147
147
  `),l=((r=a[0])==null?void 0:r.trim())||"",c=[];l&&c.push({type:"paragraph",raw:l,tokens:t.inlineTokens(l)});const d=a.slice(1).join(`
148
- `).trim();if(d){const p=t.blockTokens(d);c.push(...p)}let u=s+1;const h=[];for(;u<n.length&&n[u].indent>e;)h.push(n[u]),u+=1;if(h.length>0){const p=Math.min(...h.map(m=>m.indent)),f=ph(h,p,t);c.push({type:"list",ordered:!0,start:h[0].number,items:f,raw:h.map(m=>m.raw).join(`
149
- `)})}o.push({type:"list_item",raw:i.raw,tokens:c}),s=u}else s+=1}return o}function b1(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];const r=[];return t.tokens&&t.tokens.length>0&&t.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 s=e.parseChildren([o]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([o]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var x1="listItem",Xl="textStyle",Yl=/^(\d+)\.\s$/,fh=ve.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:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",re(this.options.HTMLAttributes,t),0]:["ol",re(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];const t=n.start||1,r=n.items?b1(n.items,e):[];return t!==1?{type:"orderedList",attrs:{start:t},content:r}:{type:"orderedList",content:r}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
148
+ `).trim();if(d){const p=t.blockTokens(d);c.push(...p)}let u=s+1;const h=[];for(;u<n.length&&n[u].indent>e;)h.push(n[u]),u+=1;if(h.length>0){const p=Math.min(...h.map(m=>m.indent)),f=fh(h,p,t);c.push({type:"list",ordered:!0,start:h[0].number,items:f,raw:h.map(m=>m.raw).join(`
149
+ `)})}o.push({type:"list_item",raw:i.raw,tokens:c}),s=u}else s+=1}return o}function x1(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];const r=[];return t.tokens&&t.tokens.length>0&&t.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 s=e.parseChildren([o]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([o]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var w1="listItem",Yl="textStyle",Ql=/^(\d+)\.\s$/,mh=ve.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:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",re(this.options.HTMLAttributes,t),0]:["ol",re(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];const t=n.start||1,r=n.items?x1(n.items,e):[];return t!==1?{type:"orderedList",attrs:{start:t},content:r}:{type:"orderedList",content:r}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
150
150
  `):"",markdownTokenizer:{name:"orderedList",level:"block",start:n=>{const e=n.match(/^(\s*)(\d+)\.\s+/),t=e?.index;return t!==void 0?t:-1},tokenize:(n,e,t)=>{var r;const o=n.split(`
151
- `),[s,i]=y1(o);if(s.length===0)return;const a=ph(s,0,t);return a.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:a,raw:o.slice(0,i).join(`
152
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(x1,this.editor.getAttributes(Xl)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Dn({find:Yl,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Dn({find:Yl,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Xl)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),w1=/^\s*(\[([( |x])?\])\s$/,k1=ve.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:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",re(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const r=`- [${(t=n.attrs)!=null&&t.checked?"x":" "}] `;return Xi(n,e,r)},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const o=document.createElement("li"),s=document.createElement("label"),i=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),c=d=>{var u,h;a.ariaLabel=((h=(u=this.options.a11y)==null?void 0:u.checkboxLabel)==null?void 0:h.call(u,d,a.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return c(n),s.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",d=>d.preventDefault()),a.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:u}=d.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const p=t();if(typeof p!="number")return!1;const f=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...f?.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,u)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,u])=>{o.setAttribute(d,u)}),o.dataset.checked=n.attrs.checked,a.checked=n.attrs.checked,s.append(a,i),o.append(s,l),Object.entries(e).forEach(([d,u])=>{o.setAttribute(d,u)}),{dom:o,contentDOM:l,update:d=>d.type!==this.type?!1:(o.dataset.checked=d.attrs.checked,a.checked=d.attrs.checked,c(d),!0)}}},addInputRules(){return[Dn({find:w1,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),v1=ve.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:n}){return["ul",re(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
153
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=s=>{const i=ei(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,l)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:t.inlineTokens(a.mainContent),nestedTokens:l}),customNestedParser:r},t);return i?[{type:"taskList",raw:i.raw,items:i.items}]:t.blockTokens(s)},o=ei(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,i)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:t.inlineTokens(s.mainContent),nestedTokens:i}),customNestedParser:r},t);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});te.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(sh.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(ih.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(hh.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(fh.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(k1.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(v1.configure(this.options.taskList)),n}});var S1=ve.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",re(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];return t.length===1&&t[0].type==="image"?e.parseChildren([t[0]]):e.createNode("paragraph",void 0,e.parseInline(t))},renderMarkdown:(n,e)=>!n||!Array.isArray(n.content)?"":e.renderChildren(n.content),addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),C1=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,M1=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,E1=wt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",re(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[sn({find:C1,type:this.type})]},addPasteRules(){return[Ht({find:M1,type:this.type})]}}),T1=ve.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""});function N1(n={}){return new le({view(e){return new A1(e,n)}})}class A1{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let s=i=>{this[o](i)};return e.dom.addEventListener(o,s),{name:o,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.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),t=!e.parent.inlineContent,r,o=this.editorView.dom,s=o.getBoundingClientRect(),i=s.width/o.offsetWidth,a=s.height/o.offsetHeight;if(t){let u=e.nodeBefore,h=e.nodeAfter;if(u||h){let p=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(p){let f=p.getBoundingClientRect(),m=u?f.bottom:f.top;u&&h&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*a;r={left:f.left,right:f.right,top:m-g,bottom:m+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*i;r={left:u.left-h,right:u.left+h,top:u.top,bottom:u.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.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",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=l.getBoundingClientRect(),h=u.width/l.offsetWidth,p=u.height/l.offsetHeight;c=u.left-l.scrollLeft*h,d=u.top-l.scrollTop*p}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-d)/a+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,s=typeof o=="function"?o(this.editorView,t,e):o;if(t&&!s){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=Zc(this.editorView.state.doc,i,this.editorView.dragging.slice);a!=null&&(i=a)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class de extends W{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return de.valid(r)?new de(r):W.near(r)}content(){return O.empty}eq(e){return e instanceof de&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new de(e.resolve(t.pos))}getBookmark(){return new la(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!O1(e)||!R1(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&de.valid(e))return e;let o=e.pos,s=null;for(let i=e.depth;;i--){let a=e.node(i);if(t>0?e.indexAfter(i)<a.childCount:e.index(i)>0){s=a.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;o+=t;let l=e.doc.resolve(o);if(de.valid(l))return l}for(;;){let i=t>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!I.isSelectable(s)){e=e.doc.resolve(o+s.nodeSize*t),r=!1;continue e}break}s=i,o+=t;let a=e.doc.resolve(o);if(de.valid(a))return a}return null}}}de.prototype.visible=!1;de.findFrom=de.findGapCursorFrom;W.jsonID("gapcursor",de);class la{constructor(e){this.pos=e}map(e){return new la(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return de.valid(t)?new de(t):W.near(t)}}function mh(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function O1(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||mh(o.type))return!0;if(o.inlineContent)return!1}}return!0}function R1(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||mh(o.type))return!0;if(o.inlineContent)return!1}}return!0}function D1(){return new le({props:{decorations:$1,createSelectionBetween(n,e,t){return e.pos==t.pos&&de.valid(t)?new de(t):null},handleClick:L1,handleKeyDown:j1,handleDOMEvents:{beforeinput:z1}}})}const j1=Pi({ArrowLeft:jr("horiz",-1),ArrowRight:jr("horiz",1),ArrowUp:jr("vert",-1),ArrowDown:jr("vert",1)});function jr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,a=e>0?i.$to:i.$from,l=i.empty;if(i instanceof H){if(!s.endOfTextblock(t)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=de.findGapCursorFrom(a,e,l);return c?(o&&o(r.tr.setSelection(new de(c))),!0):!1}}function L1(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!de.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&I.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new de(r))),!0)}function z1(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof de))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=M.empty;for(let i=r.length-1;i>=0;i--)o=M.from(r[i].createAndFill(null,o));let s=n.state.tr.replace(t.pos,t.pos,new O(o,0,0));return s.setSelection(H.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function $1(n){if(!(n.selection instanceof de))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",se.create(n.doc,[xe.widget(n.selection.head,e,{key:"gapcursor"})])}var Oo=200,ke=function(){};ke.prototype.append=function(n){return n.length?(n=ke.from(n),!this.length&&n||n.length<Oo&&this.leafAppend(n)||this.length<Oo&&n.leafPrepend(this)||this.appendInner(n)):this};ke.prototype.prepend=function(n){return n.length?ke.from(n).append(this):this};ke.prototype.appendInner=function(n){return new I1(this,n)};ke.prototype.slice=function(n,e){return n===void 0&&(n=0),e===void 0&&(e=this.length),n>=e?ke.empty:this.sliceInner(Math.max(0,n),Math.min(this.length,e))};ke.prototype.get=function(n){if(!(n<0||n>=this.length))return this.getInner(n)};ke.prototype.forEach=function(n,e,t){e===void 0&&(e=0),t===void 0&&(t=this.length),e<=t?this.forEachInner(n,e,t,0):this.forEachInvertedInner(n,e,t,0)};ke.prototype.map=function(n,e,t){e===void 0&&(e=0),t===void 0&&(t=this.length);var r=[];return this.forEach(function(o,s){return r.push(n(o,s))},e,t),r};ke.from=function(n){return n instanceof ke?n:n&&n.length?new gh(n):ke.empty};var gh=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,o){return r==0&&o==this.length?this:new e(this.values.slice(r,o))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,o,s,i){for(var a=o;a<s;a++)if(r(this.values[a],i+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,s,i){for(var a=o-1;a>=s;a--)if(r(this.values[a],i+a)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=Oo)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=Oo)return new e(r.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ke);ke.empty=new gh([]);var I1=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,r,o,s){var i=this.left.length;if(r<i&&this.left.forEachInner(t,r,Math.min(o,i),s)===!1||o>i&&this.right.forEachInner(t,Math.max(r-i,0),Math.min(this.length,o)-i,s+i)===!1)return!1},e.prototype.forEachInvertedInner=function(t,r,o,s){var i=this.left.length;if(r>i&&this.right.forEachInvertedInner(t,r-i,Math.max(o,i)-i,s+i)===!1||o<i&&this.left.forEachInvertedInner(t,Math.min(r,i),o,s)===!1)return!1},e.prototype.sliceInner=function(t,r){if(t==0&&r==this.length)return this;var o=this.left.length;return r<=o?this.left.slice(t,r):t>=o?this.right.slice(t-o,r-o):this.left.slice(t,o).append(this.right.slice(0,r-o))},e.prototype.leafAppend=function(t){var r=this.right.leafAppend(t);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(t){var r=this.left.leafPrepend(t);if(r)return new e(r,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e})(ke);const P1=500;class Qe{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,s;t&&(o=this.remapping(r,this.items.length),s=o.maps.length);let i=e.tr,a,l,c=[],d=[];return this.items.forEach((u,h)=>{if(!u.step){o||(o=this.remapping(r,h+1),s=o.maps.length),s--,d.push(u);return}if(o){d.push(new st(u.map));let p=u.step.map(o.slice(s)),f;p&&i.maybeStep(p).doc&&(f=i.mapping.maps[i.mapping.maps.length-1],c.push(new st(f,void 0,void 0,c.length+d.length))),s--,f&&o.appendMap(f,s)}else i.maybeStep(u.step);if(u.selection)return a=o?u.selection.map(o.slice(s)):u.selection,l=new Qe(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:i,selection:a}}addTransform(e,t,r,o){let s=[],i=this.eventCount,a=this.items,l=!o&&a.length?a.get(a.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),h=new st(e.mapping.maps[d],u,t),p;(p=l&&l.merge(h))&&(h=p,d?s.pop():a=a.slice(0,a.length-1)),s.push(h),t&&(i++,t=void 0),o||(l=h)}let c=i-r.depth;return c>B1&&(a=H1(a,c),i-=c),new Qe(a.append(s),i)}remapping(e,t){let r=new rr;return this.items.forEach((o,s)=>{let i=o.mirrorOffset!=null&&s-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new Qe(this.items.append(e.map(t=>new st(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-t),s=e.mapping,i=e.steps.length,a=this.eventCount;this.items.forEach(h=>{h.selection&&a--},o);let l=t;this.items.forEach(h=>{let p=s.getMirror(--l);if(p==null)return;i=Math.min(i,p);let f=s.maps[p];if(h.step){let m=e.steps[p].invert(e.docs[p]),g=h.selection&&h.selection.map(s.slice(l+1,p));g&&a++,r.push(new st(f,m,g))}else r.push(new st(f))},o);let c=[];for(let h=t;h<i;h++)c.push(new st(s.maps[h]));let d=this.items.slice(0,o).append(c).append(r),u=new Qe(d,a);return u.emptyItemCount()>P1&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],s=0;return this.items.forEach((i,a)=>{if(a>=e)o.push(i),i.selection&&s++;else if(i.step){let l=i.step.map(t.slice(r)),c=l&&l.getMap();if(r--,c&&t.appendMap(c,r),l){let d=i.selection&&i.selection.map(t.slice(r));d&&s++;let u=new st(c.invert(),l,d),h,p=o.length-1;(h=o.length&&o[p].merge(u))?o[p]=h:o.push(u)}}else i.map&&r--},this.items.length,0),new Qe(ke.from(o.reverse()),s)}}Qe.empty=new Qe(ke.empty,0);function H1(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}class st{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new st(t.getMap().invert(),t,this.selection)}}}class Et{constructor(e,t,r,o,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=s}}const B1=20;function V1(n,e,t,r){let o=t.getMeta(en),s;if(o)return o.historyState;t.getMeta(_1)&&(n=new Et(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(en))return i.getMeta(en).redo?new Et(n.done.addTransform(t,void 0,r,Fr(e)),n.undone,Ql(t.mapping.maps),n.prevTime,n.prevComposition):new Et(n.done,n.undone.addTransform(t,void 0,r,Fr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let a=t.getMeta("composition"),l=n.prevTime==0||!i&&n.prevComposition!=a&&(n.prevTime<(t.time||0)-r.newGroupDelay||!F1(t,n.prevRanges)),c=i?Ts(n.prevRanges,t.mapping):Ql(t.mapping.maps);return new Et(n.done.addTransform(t,l?e.selection.getBookmark():void 0,r,Fr(e)),Qe.empty,c,t.time,a??n.prevComposition)}else return(s=t.getMeta("rebased"))?new Et(n.done.rebased(t,s),n.undone.rebased(t,s),Ts(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Et(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Ts(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function F1(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&o>=e[s]&&(t=!0)}),t}function Ql(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,s,i)=>e.push(s,i));return e}function Ts(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),s=e.map(n[r+1],-1);o<=s&&t.push(o,s)}return t}function W1(n,e,t){let r=Fr(e),o=en.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let i=s.selection.resolve(s.transform.doc),a=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),o,r),l=new Et(t?a:s.remaining,t?s.remaining:a,null,0,-1);return s.transform.setSelection(i).setMeta(en,{redo:t,historyState:l})}let Ns=!1,Zl=null;function Fr(n){let e=n.plugins;if(Zl!=e){Ns=!1,Zl=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ns=!0;break}}return Ns}const en=new he("history"),_1=new he("closeHistory");function U1(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new le({key:en,state:{init(){return new Et(Qe.empty,Qe.empty,null,0,-1)},apply(e,t,r){return V1(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?bh:r=="historyRedo"?xh:null;return!o||!e.editable?!1:(t.preventDefault(),o(e.state,e.dispatch))}}}})}function yh(n,e){return(t,r)=>{let o=en.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let s=W1(o,t,n);s&&r(s.scrollIntoView())}return!0}}const bh=yh(!1),xh=yh(!0);te.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const t=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(t)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new le({key:new he("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const o=this.options.limit;if(o==null||o===0){n=!0;return}const s=this.storage.characters({node:r.doc});if(s>o){const i=s-o,a=0,l=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(a,l);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const o=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=r||o>r&&s>r&&s<=o)return!0;if(o>r&&s>r&&s>o||!e.getMeta("paste"))return!1;const i=e.selection.$head.pos,a=s-r,l=i-a,c=i;return e.deleteRange(l,c),!(this.storage.characters({node:e.doc})>r)}})]}});var q1=te.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[N1(this.options)]}});te.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new le({key:new he("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:o}=e,s=[];if(!t||!r)return se.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((l,c)=>{if(!l.isText){if(!(o>=c&&o<=c+l.nodeSize-1))return!1;i+=1}});let a=0;return n.descendants((l,c)=>{if(l.isText||!(o>=c&&o<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&i-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";s.push(xe.node(c,c+l.nodeSize,{class:this.options.className}))}),se.create(n,s)}}})]}});var K1=te.create({name:"gapCursor",addProseMirrorPlugins(){return[D1()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=Q(P(n,"allowGapCursor",t)))!=null?e:null}}});te.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new le({key:new he("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!t)return null;const s=this.editor.isEmpty;return n.descendants((i,a)=>{const l=r>=a&&r<=a+i.nodeSize,c=!i.isLeaf&&qo(i);if((l||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];s&&d.push(this.options.emptyEditorClass);const u=xe.node(a,a+i.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:a,hasAnchor:l}):this.options.placeholder});o.push(u)}return this.options.includeChildren}),se.create(n,o)}}})]}});te.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new le({key:new he("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||gu(t.selection)||n.view.dragging?null:se.create(t.doc,[xe.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function ec({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var J1=te.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new he(this.name),t=((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||this.options.node||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(t).includes(o.name));return[new le({key:e,appendTransaction:(o,s,i)=>{const{doc:a,tr:l,schema:c}=i,d=e.getState(i),u=a.content.size,h=c.nodes[t];if(d)return l.insert(u,h.create())},state:{init:(o,s)=>{const i=s.tr.doc.lastChild;return!ec({node:i,types:r})},apply:(o,s)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return s;const i=o.doc.lastChild;return!ec({node:i,types:r})}}})]}}),G1=te.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>bh(n,e),redo:()=>({state:n,dispatch:e})=>xh(n,e)}},addProseMirrorPlugins(){return[U1(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()}}}),X1=te.create({name:"starterKit",addExtensions(){var n,e,t,r;const o=[];return this.options.bold!==!1&&o.push(C0.configure(this.options.bold)),this.options.blockquote!==!1&&o.push(x0.configure(this.options.blockquote)),this.options.bulletList!==!1&&o.push(sh.configure(this.options.bulletList)),this.options.code!==!1&&o.push(T0.configure(this.options.code)),this.options.codeBlock!==!1&&o.push(O0.configure(this.options.codeBlock)),this.options.document!==!1&&o.push(R0.configure(this.options.document)),this.options.dropcursor!==!1&&o.push(q1.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&o.push(K1.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&o.push(D0.configure(this.options.hardBreak)),this.options.heading!==!1&&o.push(j0.configure(this.options.heading)),this.options.undoRedo!==!1&&o.push(G1.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&o.push(L0.configure(this.options.horizontalRule)),this.options.italic!==!1&&o.push(H0.configure(this.options.italic)),this.options.listItem!==!1&&o.push(ih.configure(this.options.listItem)),this.options.listKeymap!==!1&&o.push(hh.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&o.push(d1.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&o.push(fh.configure(this.options.orderedList)),this.options.paragraph!==!1&&o.push(S1.configure(this.options.paragraph)),this.options.strike!==!1&&o.push(E1.configure(this.options.strike)),this.options.text!==!1&&o.push(T1.configure(this.options.text)),this.options.underline!==!1&&o.push(Gu.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&o.push(J1.configure((r=this.options)==null?void 0:r.trailingNode)),o}}),Y1=X1,Q1=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Z1=ve.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},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},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",re(this.options.HTMLAttributes,n)]},parseMarkdown:(n,e)=>e.createNode("image",{src:n.href,title:n.title,alt:n.text}),renderMarkdown:n=>{var e,t,r,o,s,i;const a=(t=(e=n.attrs)==null?void 0:e.src)!=null?t:"",l=(o=(r=n.attrs)==null?void 0:r.alt)!=null?o:"",c=(i=(s=n.attrs)==null?void 0:s.title)!=null?i:"";return c?`![${l}](${a} "${c}")`:`![${l}](${a})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:n,minWidth:e,minHeight:t,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:o,getPos:s,HTMLAttributes:i})=>{const a=document.createElement("img");Object.entries(i).forEach(([d,u])=>{if(u!=null)switch(d){case"width":case"height":break;default:a.setAttribute(d,u);break}}),a.src=i.src;const l=new Hy({element:a,node:o,getPos:s,onResize:(d,u)=>{a.style.width=`${d}px`,a.style.height=`${u}px`},onCommit:(d,u)=>{const h=s();h!==void 0&&this.editor.chain().setNodeSelection(h).updateAttributes(this.name,{width:d,height:u}).run()},onUpdate:(d,u,h)=>d.type===o.type,options:{directions:n,min:{width:e,height:t},preserveAspectRatio:r===!0}}),c=l.dom;return c.style.visibility="hidden",c.style.pointerEvents="none",a.onload=()=>{c.style.visibility="",c.style.pointerEvents=""},l}},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[Ru({find:Q1,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}}),ex=Z1,As={exports:{}},Os={},tc;function tx(){if(tc)return Os;tc=1;var n=z;function e(u,h){return u===h&&(u!==0||1/u===1/h)||u!==u&&h!==h}var t=typeof Object.is=="function"?Object.is:e,r=n.useState,o=n.useEffect,s=n.useLayoutEffect,i=n.useDebugValue;function a(u,h){var p=h(),f=r({inst:{value:p,getSnapshot:h}}),m=f[0].inst,g=f[1];return s(function(){m.value=p,m.getSnapshot=h,l(m)&&g({inst:m})},[u,p,h]),o(function(){return l(m)&&g({inst:m}),u(function(){l(m)&&g({inst:m})})},[u]),i(p),p}function l(u){var h=u.getSnapshot;u=u.value;try{var p=h();return!t(u,p)}catch{return!0}}function c(u,h){return h()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return Os.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:d,Os}var nc={},rc;function nx(){return rc||(rc=1,process.env.NODE_ENV!=="production"&&(function(){function n(p,f){return p===f&&(p!==0||1/p===1/f)||p!==p&&f!==f}function e(p,f){d||o.startTransition===void 0||(d=!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=f();if(!u){var g=f();s(m,g)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}g=i({inst:{value:m,getSnapshot:f}});var y=g[0].inst,w=g[1];return l(function(){y.value=m,y.getSnapshot=f,t(y)&&w({inst:y})},[p,m,f]),a(function(){return t(y)&&w({inst:y}),p(function(){t(y)&&w({inst:y})})},[p]),c(m),m}function t(p){var f=p.getSnapshot;p=p.value;try{var m=f();return!s(p,m)}catch{return!0}}function r(p,f){return f()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=z,s=typeof Object.is=="function"?Object.is:n,i=o.useState,a=o.useEffect,l=o.useLayoutEffect,c=o.useDebugValue,d=!1,u=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:e;nc.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())})()),nc}var oc;function ca(){return oc||(oc=1,process.env.NODE_ENV==="production"?As.exports=tx():As.exports=nx()),As.exports}var wh=ca(),sc,ic;function rx(){return ic||(ic=1,sc=function n(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var r,o,s;if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(o=r;o--!==0;)if(!n(e[o],t[o]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(o of e.entries())if(!t.has(o[0]))return!1;for(o of e.entries())if(!n(o[1],t.get(o[0])))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(o of e.entries())if(!t.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(r=e.length,r!=t.length)return!1;for(o=r;o--!==0;)if(e[o]!==t[o])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(s=Object.keys(e),r=s.length,r!==Object.keys(t).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(t,s[o]))return!1;for(o=r;o--!==0;){var i=s[o];if(!(i==="_owner"&&e.$$typeof)&&!n(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}),sc}var ox=rx();const sx=Kh(ox);var Rs={exports:{}},Ds={},ac;function ix(){if(ac)return Ds;ac=1;var n=z,e=ca();function t(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:t,o=e.useSyncExternalStore,s=n.useRef,i=n.useEffect,a=n.useMemo,l=n.useDebugValue;return Ds.useSyncExternalStoreWithSelector=function(c,d,u,h,p){var f=s(null);if(f.current===null){var m={hasValue:!1,value:null};f.current=m}else m=f.current;f=a(function(){function y(T){if(!w){if(w=!0,x=T,T=h(T),p!==void 0&&m.hasValue){var v=m.value;if(p(v,T))return E=v}return E=T}if(v=E,r(x,T))return v;var S=h(T);return p!==void 0&&p(v,S)?(x=T,v):(x=T,E=S)}var w=!1,x,E,b=u===void 0?null:u;return[function(){return y(d())},b===null?void 0:function(){return y(b())}]},[d,u,h,p]);var g=o(c,f[0],f[1]);return i(function(){m.hasValue=!0,m.value=g},[g]),l(g),g},Ds}var lc={},cc;function ax(){return cc||(cc=1,process.env.NODE_ENV!=="production"&&(function(){function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=z,t=ca(),r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,i=e.useEffect,a=e.useMemo,l=e.useDebugValue;lc.useSyncExternalStoreWithSelector=function(c,d,u,h,p){var f=s(null);if(f.current===null){var m={hasValue:!1,value:null};f.current=m}else m=f.current;f=a(function(){function y(T){if(!w){if(w=!0,x=T,T=h(T),p!==void 0&&m.hasValue){var v=m.value;if(p(v,T))return E=v}return E=T}if(v=E,r(x,T))return v;var S=h(T);return p!==void 0&&p(v,S)?(x=T,v):(x=T,E=S)}var w=!1,x,E,b=u===void 0?null:u;return[function(){return y(d())},b===null?void 0:function(){return y(b())}]},[d,u,h,p]);var g=o(c,f[0],f[1]);return i(function(){m.hasValue=!0,m.value=g},[g]),l(g),g},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),lc}var dc;function lx(){return dc||(dc=1,process.env.NODE_ENV==="production"?Rs.exports=ix():Rs.exports=ax()),Rs.exports}var cx=lx(),dx=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},ux=({contentComponent:n})=>{const e=wh.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return N.jsx(N.Fragment,{children:Object.values(e)})};function hx(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:Mc.createPortal(r.reactElement,r.element,t)},n.forEach(o=>o())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(o=>o())}}}var px=class extends z.Component{constructor(n){var e;super(n),this.editorContentRef=z.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=n.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const n=this.props.editor;if(n&&!n.isDestroyed&&n.options.element){if(n.contentComponent)return;const e=this.editorContentRef.current;e.append(n.view.dom),n.setOptions({element:e}),n.contentComponent=hx(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=n.contentComponent.subscribe(()=>{this.setState(t=>t.hasContentComponentInitialized?t:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),n.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((n=e.view.dom)!=null&&n.firstChild))return;const t=document.createElement("div");t.append(e.view.dom),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return N.jsxs(N.Fragment,{children:[N.jsx("div",{ref:dx(e,this.editorContentRef),...t}),n?.contentComponent&&N.jsx(ux,{contentComponent:n.contentComponent})]})}},fx=z.forwardRef((n,e)=>{const t=z.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return z.createElement(px,{key:t,innerRef:e,...n})}),mx=z.memo(fx),gx=typeof window<"u"?z.useLayoutEffect:z.useEffect,yx=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function kh(n){var e;const[t]=z.useState(()=>new yx(n.editor)),r=cx.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:sx);return gx(()=>t.watch(n.editor),[n.editor,t]),z.useDebugValue(r),r}var uc=process.env.NODE_ENV!=="production",yi=typeof window>"u",bx=yi||!!(typeof window<"u"&&window.next),xx=class vh{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(t=>t())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0){if(yi||bx){if(uc)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&&yi&&uc)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:(...t)=>{var r,o;return(o=(r=this.options.current).onBeforeCreate)==null?void 0:o.call(r,...t)},onBlur:(...t)=>{var r,o;return(o=(r=this.options.current).onBlur)==null?void 0:o.call(r,...t)},onCreate:(...t)=>{var r,o;return(o=(r=this.options.current).onCreate)==null?void 0:o.call(r,...t)},onDestroy:(...t)=>{var r,o;return(o=(r=this.options.current).onDestroy)==null?void 0:o.call(r,...t)},onFocus:(...t)=>{var r,o;return(o=(r=this.options.current).onFocus)==null?void 0:o.call(r,...t)},onSelectionUpdate:(...t)=>{var r,o;return(o=(r=this.options.current).onSelectionUpdate)==null?void 0:o.call(r,...t)},onTransaction:(...t)=>{var r,o;return(o=(r=this.options.current).onTransaction)==null?void 0:o.call(r,...t)},onUpdate:(...t)=>{var r,o;return(o=(r=this.options.current).onUpdate)==null?void 0:o.call(r,...t)},onContentError:(...t)=>{var r,o;return(o=(r=this.options.current).onContentError)==null?void 0:o.call(r,...t)},onDrop:(...t)=>{var r,o;return(o=(r=this.options.current).onDrop)==null?void 0:o.call(r,...t)},onPaste:(...t)=>{var r,o;return(o=(r=this.options.current).onPaste)==null?void 0:o.call(r,...t)},onDelete:(...t)=>{var r,o;return(o=(r=this.options.current).onDelete)==null?void 0:o.call(r,...t)}};return new Iy(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((o,s)=>{var i;return o===((i=t.extensions)==null?void 0:i[s])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?vh.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((t,r)=>t===e[r]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function wx(n={},e=[]){const t=z.useRef(n);t.current=n;const[r]=z.useState(()=>new xx(t)),o=wh.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return z.useDebugValue(o),z.useEffect(r.onRender(e)),kh({editor:o,selector:({transactionNumber:s})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&s===0?0:s+1}),o}var kx=z.createContext({editor:null});kx.Consumer;var Sh=z.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),vx=()=>z.useContext(Sh),js=z.forwardRef((n,e)=>{const{onDragStart:t}=vx(),r=n.as||"div";return N.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function hc(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function pc(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function Sx(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function Cx(n){if(hc(n)||pc(n))return!0;if(Sx(n)){const e=n.type;if(e)return hc(e)||pc(e)}return!1}function Mx(){try{if(z.version)return parseInt(z.version.split(".")[0],10)>=19}catch{}return!1}var Ex=class{constructor(n,{editor:e,props:t={},as:r="div",className:o=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=n,this.editor=e,this.props=t,this.element=document.createElement(r),this.element.classList.add("react-renderer"),o&&this.element.classList.add(...o.split(" ")),this.editor.isInitialized?Mc.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var n;const e=this.component,t=this.props,r=this.editor,o=Mx(),s=Cx(e),i={...t};i.ref&&!(o||s)&&delete i.ref,!i.ref&&(o||s)&&(i.ref=a=>{this.ref=a}),this.reactElement=N.jsx(e,{...i}),(n=r?.contentComponent)==null||n.setRenderer(this.id,this)}updateProps(n={}){this.props={...this.props,...n},this.render()}destroy(){var n;(n=this.editor?.contentComponent)==null||n.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(n){Object.keys(n).forEach(e=>{this.element.setAttribute(e,n[e])})}};z.createContext({markViewContentRef:()=>{}});var Tx=class extends Jy{constructor(n,e,t){if(super(n,e,t),!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}mount(){const n={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(i={})=>this.updateAttributes(i),deleteNode:()=>this.deleteNode(),ref:z.createRef()};if(!this.component.displayName){const i=a=>a.charAt(0).toUpperCase()+a.substring(1);this.component.displayName=i(this.extension.name)}const e={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:i=>{i&&this.contentDOMElement&&i.firstChild!==this.contentDOMElement&&(i.hasAttribute("data-node-view-wrapper")&&i.removeAttribute("data-node-view-wrapper"),i.appendChild(this.contentDOMElement))}},t=this.component,r=z.memo(i=>N.jsx(Sh.Provider,{value:e,children:z.createElement(t,i)}));r.displayName="ReactNodeView";let o=this.node.isInline?"span":"div";this.options.as&&(o=this.options.as);const{className:s=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Ex(r,{editor:this.editor,props:n,as:o,className:`node-${this.node.type.name} ${s}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var n;if(this.renderer.element.firstElementChild&&!((n=this.renderer.element.firstElementChild)!=null&&n.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:n,to:e}=this.editor.state.selection,t=this.getPos();if(typeof t=="number")if(n<=t&&e>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(n,e,t){const r=o=>{this.renderer.updateProps(o),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(n.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const o=this.node,s=this.decorations,i=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:o,oldDecorations:s,newNode:n,newDecorations:e,oldInnerDecorations:i,innerDecorations:t,updateProps:()=>r({node:n,decorations:e,innerDecorations:t})})}return n===this.node&&this.decorations===e&&this.innerDecorations===t||(this.node=n,this.decorations=e,this.innerDecorations=t,r({node:n,decorations:e,innerDecorations:t})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let n={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,t=cr(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function Nx(n,e){return t=>t.editor.contentComponent?new Tx(n,t,e):{}}function Ax(n){const e=jo.c(23),{node:t,updateAttributes:r}=n,o=z.useRef(null),s=z.useRef(null),[i,a]=z.useState(!1),[l,c]=z.useState(!1),[d,u]=z.useState(!1),h=t.attrs.src;if(!h){let $;return e[0]===Symbol.for("react.memo_cache_sentinel")?($=N.jsx(js,{as:"div",className:"resizable-image-error",children:"이미지 소스가 없습니다."}),e[0]=$):$=e[0],$}if(d){let $;e[1]!==h?($=h?.substring(0,50),e[1]=h,e[2]=$):$=e[2];let Y;return e[3]!==$?(Y=N.jsxs(js,{as:"div",className:"resizable-image-error",children:["이미지를 불러올 수 없습니다: ",$,"..."]}),e[3]=$,e[4]=Y):Y=e[4],Y}let p;e[5]!==r?(p=($,Y)=>{if($.button!==0)return;$.preventDefault(),a(!0);const pe=$.clientX,Z=$.clientY,q=o.current?.offsetWidth||0,X=o.current?.offsetHeight||0,ee=X/q,L=Ce=>{const C=Ce.clientX-pe,B=Ce.clientY-Z;let V=q;e:switch(Y){case"se":case"e":{V=Math.max(100,q+C);break e}case"sw":case"w":{V=Math.max(100,q-C);break e}case"ne":case"n":{V=Math.max(100,q+C);break e}case"nw":{V=Math.max(100,q-C);break e}case"s":V=Math.max(100*ee,X+B)/ee}o.current&&(o.current.style.width=`${V}px`,o.current.style.height=`${V*ee}px`)},Se=()=>{a(!1),o.current&&r({width:o.current.offsetWidth,height:o.current.offsetHeight}),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",Se)};document.addEventListener("mousemove",L),document.addEventListener("mouseup",Se)},e[5]=r,e[6]=p):p=e[6];const f=p;let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{c(!0)},e[7]=m):m=e[7];const g=m;let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=$=>{s.current&&!s.current.contains($.target)&&c(!1)},e[8]=y):y=e[8];const w=y;let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=()=>u(!0),e[9]=x):x=e[9];const E=`resizable-image ${i?"resizing":""} ${l?"selected":""}`,b=t.attrs.width?`${t.attrs.width}px`:"auto",T=t.attrs.height?`${t.attrs.height}px`:"auto";let v;e[10]!==b||e[11]!==T?(v={width:b,height:T},e[10]=b,e[11]=T,e[12]=v):v=e[12];let S;e[13]!==h||e[14]!==E||e[15]!==v?(S=N.jsx("img",{ref:o,src:h,alt:"inserted image",onClick:g,onError:x,className:E,style:v,draggable:"false"}),e[13]=h,e[14]=E,e[15]=v,e[16]=S):S=e[16];let R;e[17]!==f||e[18]!==l?(R=l&&N.jsxs(N.Fragment,{children:[N.jsx("div",{className:"resizable-image-border"}),N.jsx("div",{onMouseDown:$=>f($,"nw"),className:"resize-handle tl"}),N.jsx("div",{onMouseDown:$=>f($,"n"),className:"resize-handle t"}),N.jsx("div",{onMouseDown:$=>f($,"ne"),className:"resize-handle tr"}),N.jsx("div",{onMouseDown:$=>f($,"w"),className:"resize-handle l"}),N.jsx("div",{onMouseDown:$=>f($,"e"),className:"resize-handle r"}),N.jsx("div",{onMouseDown:$=>f($,"sw"),className:"resize-handle bl"}),N.jsx("div",{onMouseDown:$=>f($,"s"),className:"resize-handle b"}),N.jsx("div",{onMouseDown:$=>f($,"se"),className:"resize-handle br"})]}),e[17]=f,e[18]=l,e[19]=R):R=e[19];let _;return e[20]!==R||e[21]!==S?(_=N.jsx(js,{as:"div",onClick:w,className:"resizable-image-wrapper",draggable:"true","data-drag-handle":!0,children:N.jsxs("div",{ref:s,className:"resizable-image-container",onClick:Ox,children:[S,R]})}),e[20]=R,e[21]=S,e[22]=_):_=e[22],_}function Ox(n){return n.stopPropagation()}const Rx=ex.extend({addAttributes(){return{src:{default:null,parseHTML:n=>{const e=n.getAttribute("src");return console.log("Parsing image src:",e),e},renderHTML:n=>({src:n.src})},alt:{default:null,parseHTML:n=>n.getAttribute("alt"),renderHTML:n=>({alt:n.alt||"image"})},title:{default:null,parseHTML:n=>n.getAttribute("title"),renderHTML:n=>({title:n.title})},width:{default:null,parseHTML:n=>{const e=n.getAttribute("width");return e?parseInt(e,10):null},renderHTML:n=>({width:n.width})},height:{default:null,parseHTML:n=>{const e=n.getAttribute("height");return e?parseInt(e,10):null},renderHTML:n=>({height:n.height})}}},addNodeView(){return Nx(Ax)},draggable:!0,addStorage(){return{clipboardTextSerializer:n=>n.attrs.src||""}},renderHTML({HTMLAttributes:n}){return["img",{...n,class:"resizable-image"}]}}),Ch=[Y1.configure({paragraph:{HTMLAttributes:{class:"tiptap-paragraph"}},heading:{levels:[1,2,3]},bulletList:{HTMLAttributes:{class:"tiptap-bullet-list"}},orderedList:{HTMLAttributes:{class:"tiptap-ordered-list"}},codeBlock:{HTMLAttributes:{class:"tiptap-code-block"}},code:{HTMLAttributes:{class:"tiptap-inline-code"}},blockquote:{HTMLAttributes:{class:"tiptap-blockquote"}}}),y0,Lu,tb,sb.configure({multicolor:!0}),g0.configure({types:["heading","paragraph"]}),Rx,Ju.configure({resizable:!0}),f0,p0,h0];function Mh(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(e=0;e<o;e++)n[e]&&(t=Mh(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function Dx(){for(var n,e,t=0,r="",o=arguments.length;t<o;t++)(n=arguments[t])&&(e=Mh(n))&&(r&&(r+=" "),r+=e);return r}const jx=(n,e)=>{const t=new Array(n.length+e.length);for(let r=0;r<n.length;r++)t[r]=n[r];for(let r=0;r<e.length;r++)t[n.length+r]=e[r];return t},Lx=(n,e)=>({classGroupId:n,validator:e}),Eh=(n=new Map,e=null,t)=>({nextPart:n,validators:e,classGroupId:t}),Ro="-",fc=[],zx="arbitrary..",$x=n=>{const e=Px(n),{conflictingClassGroups:t,conflictingClassGroupModifiers:r}=n;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return Ix(o);const s=o.split(Ro),i=s[0]===""&&s.length>1?1:0;return Th(s,i,e)},getConflictingClassGroupIds:(o,s)=>{if(s){const i=r[o],a=t[o];return i?a?jx(a,i):i:a||fc}return t[o]||fc}}},Th=(n,e,t)=>{if(n.length-e===0)return t.classGroupId;const r=n[e],o=t.nextPart.get(r);if(o){const l=Th(n,e+1,o);if(l)return l}const s=t.validators;if(s===null)return;const i=e===0?n.join(Ro):n.slice(e).join(Ro),a=s.length;for(let l=0;l<a;l++){const c=s[l];if(c.validator(i))return c.classGroupId}},Ix=n=>n.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=n.slice(1,-1),t=e.indexOf(":"),r=e.slice(0,t);return r?zx+r:void 0})(),Px=n=>{const{theme:e,classGroups:t}=n;return Hx(t,e)},Hx=(n,e)=>{const t=Eh();for(const r in n){const o=n[r];da(o,t,r,e)}return t},da=(n,e,t,r)=>{const o=n.length;for(let s=0;s<o;s++){const i=n[s];Bx(i,e,t,r)}},Bx=(n,e,t,r)=>{if(typeof n=="string"){Vx(n,e,t);return}if(typeof n=="function"){Fx(n,e,t,r);return}Wx(n,e,t,r)},Vx=(n,e,t)=>{const r=n===""?e:Nh(e,n);r.classGroupId=t},Fx=(n,e,t,r)=>{if(_x(n)){da(n(r),e,t,r);return}e.validators===null&&(e.validators=[]),e.validators.push(Lx(t,n))},Wx=(n,e,t,r)=>{const o=Object.entries(n),s=o.length;for(let i=0;i<s;i++){const[a,l]=o[i];da(l,Nh(e,a),t,r)}},Nh=(n,e)=>{let t=n;const r=e.split(Ro),o=r.length;for(let s=0;s<o;s++){const i=r[s];let a=t.nextPart.get(i);a||(a=Eh(),t.nextPart.set(i,a)),t=a}return t},_x=n=>"isThemeGetter"in n&&n.isThemeGetter===!0,Ux=n=>{if(n<1)return{get:()=>{},set:()=>{}};let e=0,t=Object.create(null),r=Object.create(null);const o=(s,i)=>{t[s]=i,e++,e>n&&(e=0,r=t,t=Object.create(null))};return{get(s){let i=t[s];if(i!==void 0)return i;if((i=r[s])!==void 0)return o(s,i),i},set(s,i){s in t?t[s]=i:o(s,i)}}},bi="!",mc=":",qx=[],gc=(n,e,t,r,o)=>({modifiers:n,hasImportantModifier:e,baseClassName:t,maybePostfixModifierPosition:r,isExternal:o}),Kx=n=>{const{prefix:e,experimentalParseClassName:t}=n;let r=o=>{const s=[];let i=0,a=0,l=0,c;const d=o.length;for(let m=0;m<d;m++){const g=o[m];if(i===0&&a===0){if(g===mc){s.push(o.slice(l,m)),l=m+1;continue}if(g==="/"){c=m;continue}}g==="["?i++:g==="]"?i--:g==="("?a++:g===")"&&a--}const u=s.length===0?o:o.slice(l);let h=u,p=!1;u.endsWith(bi)?(h=u.slice(0,-1),p=!0):u.startsWith(bi)&&(h=u.slice(1),p=!0);const f=c&&c>l?c-l:void 0;return gc(s,p,h,f)};if(e){const o=e+mc,s=r;r=i=>i.startsWith(o)?s(i.slice(o.length)):gc(qx,!1,i,void 0,!0)}if(t){const o=r;r=s=>t({className:s,parseClassName:o})}return r},Jx=n=>{const e=new Map;return n.orderSensitiveModifiers.forEach((t,r)=>{e.set(t,1e6+r)}),t=>{const r=[];let o=[];for(let s=0;s<t.length;s++){const i=t[s],a=i[0]==="[",l=e.has(i);a||l?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(i)):o.push(i)}return o.length>0&&(o.sort(),r.push(...o)),r}},Gx=n=>({cache:Ux(n.cacheSize),parseClassName:Kx(n),sortModifiers:Jx(n),...$x(n)}),Xx=/\s+/,Yx=(n,e)=>{const{parseClassName:t,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s}=e,i=[],a=n.trim().split(Xx);let l="";for(let c=a.length-1;c>=0;c-=1){const d=a[c],{isExternal:u,modifiers:h,hasImportantModifier:p,baseClassName:f,maybePostfixModifierPosition:m}=t(d);if(u){l=d+(l.length>0?" "+l:l);continue}let g=!!m,y=r(g?f.substring(0,m):f);if(!y){if(!g){l=d+(l.length>0?" "+l:l);continue}if(y=r(f),!y){l=d+(l.length>0?" "+l:l);continue}g=!1}const w=h.length===0?"":h.length===1?h[0]:s(h).join(":"),x=p?w+bi:w,E=x+y;if(i.indexOf(E)>-1)continue;i.push(E);const b=o(y,g);for(let T=0;T<b.length;++T){const v=b[T];i.push(x+v)}l=d+(l.length>0?" "+l:l)}return l},Qx=(...n)=>{let e=0,t,r,o="";for(;e<n.length;)(t=n[e++])&&(r=Ah(t))&&(o&&(o+=" "),o+=r);return o},Ah=n=>{if(typeof n=="string")return n;let e,t="";for(let r=0;r<n.length;r++)n[r]&&(e=Ah(n[r]))&&(t&&(t+=" "),t+=e);return t},Zx=(n,...e)=>{let t,r,o,s;const i=l=>{const c=e.reduce((d,u)=>u(d),n());return t=Gx(c),r=t.cache.get,o=t.cache.set,s=a,a(l)},a=l=>{const c=r(l);if(c)return c;const d=Yx(l,t);return o(l,d),d};return s=i,(...l)=>s(Qx(...l))},ew=[],ye=n=>{const e=t=>t[n]||ew;return e.isThemeGetter=!0,e},Oh=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Rh=/^\((?:(\w[\w-]*):)?(.+)\)$/i,tw=/^\d+\/\d+$/,nw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,rw=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ow=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,sw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,iw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,bn=n=>tw.test(n),G=n=>!!n&&!Number.isNaN(Number(n)),vt=n=>!!n&&Number.isInteger(Number(n)),Ls=n=>n.endsWith("%")&&G(n.slice(0,-1)),ht=n=>nw.test(n),aw=()=>!0,lw=n=>rw.test(n)&&!ow.test(n),Dh=()=>!1,cw=n=>sw.test(n),dw=n=>iw.test(n),uw=n=>!D(n)&&!j(n),hw=n=>zn(n,zh,Dh),D=n=>Oh.test(n),_t=n=>zn(n,$h,lw),zs=n=>zn(n,yw,G),yc=n=>zn(n,jh,Dh),pw=n=>zn(n,Lh,dw),Lr=n=>zn(n,Ih,cw),j=n=>Rh.test(n),Bn=n=>$n(n,$h),fw=n=>$n(n,bw),bc=n=>$n(n,jh),mw=n=>$n(n,zh),gw=n=>$n(n,Lh),zr=n=>$n(n,Ih,!0),zn=(n,e,t)=>{const r=Oh.exec(n);return r?r[1]?e(r[1]):t(r[2]):!1},$n=(n,e,t=!1)=>{const r=Rh.exec(n);return r?r[1]?e(r[1]):t:!1},jh=n=>n==="position"||n==="percentage",Lh=n=>n==="image"||n==="url",zh=n=>n==="length"||n==="size"||n==="bg-size",$h=n=>n==="length",yw=n=>n==="number",bw=n=>n==="family-name",Ih=n=>n==="shadow",xw=()=>{const n=ye("color"),e=ye("font"),t=ye("text"),r=ye("font-weight"),o=ye("tracking"),s=ye("leading"),i=ye("breakpoint"),a=ye("container"),l=ye("spacing"),c=ye("radius"),d=ye("shadow"),u=ye("inset-shadow"),h=ye("text-shadow"),p=ye("drop-shadow"),f=ye("blur"),m=ye("perspective"),g=ye("aspect"),y=ye("ease"),w=ye("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],E=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],b=()=>[...E(),j,D],T=()=>["auto","hidden","clip","visible","scroll"],v=()=>["auto","contain","none"],S=()=>[j,D,l],R=()=>[bn,"full","auto",...S()],_=()=>[vt,"none","subgrid",j,D],$=()=>["auto",{span:["full",vt,j,D]},vt,j,D],Y=()=>[vt,"auto",j,D],pe=()=>["auto","min","max","fr",j,D],Z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],q=()=>["start","end","center","stretch","center-safe","end-safe"],X=()=>["auto",...S()],ee=()=>[bn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...S()],L=()=>[n,j,D],Se=()=>[...E(),bc,yc,{position:[j,D]}],Ce=()=>["no-repeat",{repeat:["","x","y","space","round"]}],C=()=>["auto","cover","contain",mw,hw,{size:[j,D]}],B=()=>[Ls,Bn,_t],V=()=>["","none","full",c,j,D],U=()=>["",G,Bn,_t],J=()=>["solid","dashed","dotted","double"],oe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],F=()=>[G,Ls,bc,yc],Ne=()=>["","none",f,j,D],je=()=>["none",G,j,D],Be=()=>["none",G,j,D],tt=()=>[G,j,D],Ye=()=>[bn,"full",...S()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ht],breakpoint:[ht],color:[aw],container:[ht],"drop-shadow":[ht],ease:["in","out","in-out"],font:[uw],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ht],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ht],shadow:[ht],spacing:["px",G],text:[ht],"text-shadow":[ht],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",bn,D,j,g]}],container:["container"],columns:[{columns:[G,D,j,a]}],"break-after":[{"break-after":x()}],"break-before":[{"break-before":x()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:b()}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:v()}],"overscroll-x":[{"overscroll-x":v()}],"overscroll-y":[{"overscroll-y":v()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{start:R()}],end:[{end:R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[vt,"auto",j,D]}],basis:[{basis:[bn,"full","auto",a,...S()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[G,bn,"auto","initial","none",D]}],grow:[{grow:["",G,j,D]}],shrink:[{shrink:["",G,j,D]}],order:[{order:[vt,"first","last","none",j,D]}],"grid-cols":[{"grid-cols":_()}],"col-start-end":[{col:$()}],"col-start":[{"col-start":Y()}],"col-end":[{"col-end":Y()}],"grid-rows":[{"grid-rows":_()}],"row-start-end":[{row:$()}],"row-start":[{"row-start":Y()}],"row-end":[{"row-end":Y()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":pe()}],"auto-rows":[{"auto-rows":pe()}],gap:[{gap:S()}],"gap-x":[{"gap-x":S()}],"gap-y":[{"gap-y":S()}],"justify-content":[{justify:[...Z(),"normal"]}],"justify-items":[{"justify-items":[...q(),"normal"]}],"justify-self":[{"justify-self":["auto",...q()]}],"align-content":[{content:["normal",...Z()]}],"align-items":[{items:[...q(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...q(),{baseline:["","last"]}]}],"place-content":[{"place-content":Z()}],"place-items":[{"place-items":[...q(),"baseline"]}],"place-self":[{"place-self":["auto",...q()]}],p:[{p:S()}],px:[{px:S()}],py:[{py:S()}],ps:[{ps:S()}],pe:[{pe:S()}],pt:[{pt:S()}],pr:[{pr:S()}],pb:[{pb:S()}],pl:[{pl:S()}],m:[{m:X()}],mx:[{mx:X()}],my:[{my:X()}],ms:[{ms:X()}],me:[{me:X()}],mt:[{mt:X()}],mr:[{mr:X()}],mb:[{mb:X()}],ml:[{ml:X()}],"space-x":[{"space-x":S()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":S()}],"space-y-reverse":["space-y-reverse"],size:[{size:ee()}],w:[{w:[a,"screen",...ee()]}],"min-w":[{"min-w":[a,"screen","none",...ee()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...ee()]}],h:[{h:["screen","lh",...ee()]}],"min-h":[{"min-h":["screen","lh","none",...ee()]}],"max-h":[{"max-h":["screen","lh",...ee()]}],"font-size":[{text:["base",t,Bn,_t]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,j,zs]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ls,D]}],"font-family":[{font:[fw,D,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,j,D]}],"line-clamp":[{"line-clamp":[G,"none",j,zs]}],leading:[{leading:[s,...S()]}],"list-image":[{"list-image":["none",j,D]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",j,D]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:L()}],"text-color":[{text:L()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...J(),"wavy"]}],"text-decoration-thickness":[{decoration:[G,"from-font","auto",j,_t]}],"text-decoration-color":[{decoration:L()}],"underline-offset":[{"underline-offset":[G,"auto",j,D]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:S()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",j,D]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",j,D]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Se()}],"bg-repeat":[{bg:Ce()}],"bg-size":[{bg:C()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},vt,j,D],radial:["",j,D],conic:[vt,j,D]},gw,pw]}],"bg-color":[{bg:L()}],"gradient-from-pos":[{from:B()}],"gradient-via-pos":[{via:B()}],"gradient-to-pos":[{to:B()}],"gradient-from":[{from:L()}],"gradient-via":[{via:L()}],"gradient-to":[{to:L()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:U()}],"border-w-x":[{"border-x":U()}],"border-w-y":[{"border-y":U()}],"border-w-s":[{"border-s":U()}],"border-w-e":[{"border-e":U()}],"border-w-t":[{"border-t":U()}],"border-w-r":[{"border-r":U()}],"border-w-b":[{"border-b":U()}],"border-w-l":[{"border-l":U()}],"divide-x":[{"divide-x":U()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":U()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...J(),"hidden","none"]}],"divide-style":[{divide:[...J(),"hidden","none"]}],"border-color":[{border:L()}],"border-color-x":[{"border-x":L()}],"border-color-y":[{"border-y":L()}],"border-color-s":[{"border-s":L()}],"border-color-e":[{"border-e":L()}],"border-color-t":[{"border-t":L()}],"border-color-r":[{"border-r":L()}],"border-color-b":[{"border-b":L()}],"border-color-l":[{"border-l":L()}],"divide-color":[{divide:L()}],"outline-style":[{outline:[...J(),"none","hidden"]}],"outline-offset":[{"outline-offset":[G,j,D]}],"outline-w":[{outline:["",G,Bn,_t]}],"outline-color":[{outline:L()}],shadow:[{shadow:["","none",d,zr,Lr]}],"shadow-color":[{shadow:L()}],"inset-shadow":[{"inset-shadow":["none",u,zr,Lr]}],"inset-shadow-color":[{"inset-shadow":L()}],"ring-w":[{ring:U()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:L()}],"ring-offset-w":[{"ring-offset":[G,_t]}],"ring-offset-color":[{"ring-offset":L()}],"inset-ring-w":[{"inset-ring":U()}],"inset-ring-color":[{"inset-ring":L()}],"text-shadow":[{"text-shadow":["none",h,zr,Lr]}],"text-shadow-color":[{"text-shadow":L()}],opacity:[{opacity:[G,j,D]}],"mix-blend":[{"mix-blend":[...oe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":oe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[G]}],"mask-image-linear-from-pos":[{"mask-linear-from":F()}],"mask-image-linear-to-pos":[{"mask-linear-to":F()}],"mask-image-linear-from-color":[{"mask-linear-from":L()}],"mask-image-linear-to-color":[{"mask-linear-to":L()}],"mask-image-t-from-pos":[{"mask-t-from":F()}],"mask-image-t-to-pos":[{"mask-t-to":F()}],"mask-image-t-from-color":[{"mask-t-from":L()}],"mask-image-t-to-color":[{"mask-t-to":L()}],"mask-image-r-from-pos":[{"mask-r-from":F()}],"mask-image-r-to-pos":[{"mask-r-to":F()}],"mask-image-r-from-color":[{"mask-r-from":L()}],"mask-image-r-to-color":[{"mask-r-to":L()}],"mask-image-b-from-pos":[{"mask-b-from":F()}],"mask-image-b-to-pos":[{"mask-b-to":F()}],"mask-image-b-from-color":[{"mask-b-from":L()}],"mask-image-b-to-color":[{"mask-b-to":L()}],"mask-image-l-from-pos":[{"mask-l-from":F()}],"mask-image-l-to-pos":[{"mask-l-to":F()}],"mask-image-l-from-color":[{"mask-l-from":L()}],"mask-image-l-to-color":[{"mask-l-to":L()}],"mask-image-x-from-pos":[{"mask-x-from":F()}],"mask-image-x-to-pos":[{"mask-x-to":F()}],"mask-image-x-from-color":[{"mask-x-from":L()}],"mask-image-x-to-color":[{"mask-x-to":L()}],"mask-image-y-from-pos":[{"mask-y-from":F()}],"mask-image-y-to-pos":[{"mask-y-to":F()}],"mask-image-y-from-color":[{"mask-y-from":L()}],"mask-image-y-to-color":[{"mask-y-to":L()}],"mask-image-radial":[{"mask-radial":[j,D]}],"mask-image-radial-from-pos":[{"mask-radial-from":F()}],"mask-image-radial-to-pos":[{"mask-radial-to":F()}],"mask-image-radial-from-color":[{"mask-radial-from":L()}],"mask-image-radial-to-color":[{"mask-radial-to":L()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":E()}],"mask-image-conic-pos":[{"mask-conic":[G]}],"mask-image-conic-from-pos":[{"mask-conic-from":F()}],"mask-image-conic-to-pos":[{"mask-conic-to":F()}],"mask-image-conic-from-color":[{"mask-conic-from":L()}],"mask-image-conic-to-color":[{"mask-conic-to":L()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Se()}],"mask-repeat":[{mask:Ce()}],"mask-size":[{mask:C()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",j,D]}],filter:[{filter:["","none",j,D]}],blur:[{blur:Ne()}],brightness:[{brightness:[G,j,D]}],contrast:[{contrast:[G,j,D]}],"drop-shadow":[{"drop-shadow":["","none",p,zr,Lr]}],"drop-shadow-color":[{"drop-shadow":L()}],grayscale:[{grayscale:["",G,j,D]}],"hue-rotate":[{"hue-rotate":[G,j,D]}],invert:[{invert:["",G,j,D]}],saturate:[{saturate:[G,j,D]}],sepia:[{sepia:["",G,j,D]}],"backdrop-filter":[{"backdrop-filter":["","none",j,D]}],"backdrop-blur":[{"backdrop-blur":Ne()}],"backdrop-brightness":[{"backdrop-brightness":[G,j,D]}],"backdrop-contrast":[{"backdrop-contrast":[G,j,D]}],"backdrop-grayscale":[{"backdrop-grayscale":["",G,j,D]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[G,j,D]}],"backdrop-invert":[{"backdrop-invert":["",G,j,D]}],"backdrop-opacity":[{"backdrop-opacity":[G,j,D]}],"backdrop-saturate":[{"backdrop-saturate":[G,j,D]}],"backdrop-sepia":[{"backdrop-sepia":["",G,j,D]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":S()}],"border-spacing-x":[{"border-spacing-x":S()}],"border-spacing-y":[{"border-spacing-y":S()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",j,D]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[G,"initial",j,D]}],ease:[{ease:["linear","initial",y,j,D]}],delay:[{delay:[G,j,D]}],animate:[{animate:["none",w,j,D]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,j,D]}],"perspective-origin":[{"perspective-origin":b()}],rotate:[{rotate:je()}],"rotate-x":[{"rotate-x":je()}],"rotate-y":[{"rotate-y":je()}],"rotate-z":[{"rotate-z":je()}],scale:[{scale:Be()}],"scale-x":[{"scale-x":Be()}],"scale-y":[{"scale-y":Be()}],"scale-z":[{"scale-z":Be()}],"scale-3d":["scale-3d"],skew:[{skew:tt()}],"skew-x":[{"skew-x":tt()}],"skew-y":[{"skew-y":tt()}],transform:[{transform:[j,D,"","none","gpu","cpu"]}],"transform-origin":[{origin:b()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ye()}],"translate-x":[{"translate-x":Ye()}],"translate-y":[{"translate-y":Ye()}],"translate-z":[{"translate-z":Ye()}],"translate-none":["translate-none"],accent:[{accent:L()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:L()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",j,D]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":S()}],"scroll-mx":[{"scroll-mx":S()}],"scroll-my":[{"scroll-my":S()}],"scroll-ms":[{"scroll-ms":S()}],"scroll-me":[{"scroll-me":S()}],"scroll-mt":[{"scroll-mt":S()}],"scroll-mr":[{"scroll-mr":S()}],"scroll-mb":[{"scroll-mb":S()}],"scroll-ml":[{"scroll-ml":S()}],"scroll-p":[{"scroll-p":S()}],"scroll-px":[{"scroll-px":S()}],"scroll-py":[{"scroll-py":S()}],"scroll-ps":[{"scroll-ps":S()}],"scroll-pe":[{"scroll-pe":S()}],"scroll-pt":[{"scroll-pt":S()}],"scroll-pr":[{"scroll-pr":S()}],"scroll-pb":[{"scroll-pb":S()}],"scroll-pl":[{"scroll-pl":S()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",j,D]}],fill:[{fill:["none",...L()]}],"stroke-w":[{stroke:[G,Bn,_t,zs]}],stroke:[{stroke:["none",...L()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},ww=Zx(xw);function Cn(...n){return ww(Dx(n))}const kw=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),vw=n=>n.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase()),xc=n=>{const e=vw(n);return e.charAt(0).toUpperCase()+e.slice(1)},Ph=(...n)=>n.filter((e,t,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===t).join(" ").trim(),Sw=n=>{for(const e in n)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Cw={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Mw=z.forwardRef(({color:n="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:i,...a},l)=>z.createElement("svg",{ref:l,...Cw,width:e,height:e,stroke:n,strokeWidth:r?Number(t)*24/Number(e):t,className:Ph("lucide",o),...!s&&!Sw(a)&&{"aria-hidden":"true"},...a},[...i.map(([c,d])=>z.createElement(c,d)),...Array.isArray(s)?s:[s]])),ge=(n,e)=>{const t=z.forwardRef(({className:r,...o},s)=>z.createElement(Mw,{ref:s,iconNode:e,className:Ph(`lucide-${kw(xc(n))}`,`lucide-${n}`,r),...o}));return t.displayName=xc(n),t},Ew=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],Tw=ge("bold",Ew),Nw=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],wc=ge("code",Nw),Aw=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],Ow=ge("heading-1",Aw),Rw=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],Dw=ge("heading-2",Rw),jw=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],Lw=ge("heading-3",jw),zw=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],$w=ge("image",zw),Iw=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],Pw=ge("italic",Iw),Hw=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Bw=ge("list-ordered",Hw),Vw=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],Fw=ge("list",Vw),Ww=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],_w=ge("palette",Ww),Uw=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],qw=ge("pen",Uw),Kw=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],Jw=ge("quote",Kw),Gw=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Xw=ge("rotate-ccw",Gw),Yw=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Qw=ge("rotate-cw",Yw),Zw=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],ek=ge("strikethrough",Zw),tk=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],nk=ge("text-align-center",tk),rk=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],ok=ge("text-align-end",rk),sk=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],ik=ge("text-align-justify",sk),ak=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],lk=ge("text-align-start",ak),ck=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],dk=ge("underline",ck),ua=[{id:"black",cssVar:"var(--editor-text-black)",label:"Black/White"},{id:"gray-600",cssVar:"var(--editor-text-gray-600)",label:"Gray"},{id:"red-500",cssVar:"var(--editor-text-red-500)",label:"Red"},{id:"orange-500",cssVar:"var(--editor-text-orange-500)",label:"Orange"},{id:"yellow-500",cssVar:"var(--editor-text-yellow-500)",label:"Yellow"},{id:"green-500",cssVar:"var(--editor-text-green-500)",label:"Green"},{id:"blue-500",cssVar:"var(--editor-text-blue-500)",label:"Blue"},{id:"purple-500",cssVar:"var(--editor-text-purple-500)",label:"Purple"},{id:"pink-500",cssVar:"var(--editor-text-pink-500)",label:"Pink"}];function kc(n){const e=ua.find(t=>t.id===n);return e?e.cssVar:n}function vc(n){const e=ua.find(t=>t.cssVar===n);return e?e.id:n}function Sc(n){const e=jo.c(15),{currentColor:t,onColorSelect:r,onReset:o,onClose:s,type:i}=n,a=i==="text"?"텍스트 색상":"배경 색상";let l;e[0]!==a?(l=N.jsx("div",{className:"color-picker-label",children:a}),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==t||e[3]!==s||e[4]!==r?(c=ua.map(p=>{const f=t===p.id||t===p.cssVar;return N.jsx("button",{type:"button",onClick:()=>{r(p.id),s()},className:`color-grid-button ${f?"selected":""}`,style:{backgroundColor:p.cssVar},title:`${p.label}`},p.id)}),e[2]=t,e[3]=s,e[4]=r,e[5]=c):c=e[5];let d;e[6]!==c?(d=N.jsx("div",{className:"color-grid",children:c}),e[6]=c,e[7]=d):d=e[7];let u;e[8]!==s||e[9]!==o?(u=N.jsx("button",{type:"button",onClick:()=>{o(),s()},className:"color-picker-reset-button",children:"색상 제거"}),e[8]=s,e[9]=o,e[10]=u):u=e[10];let h;return e[11]!==l||e[12]!==d||e[13]!==u?(h=N.jsxs("div",{className:"color-picker",children:[l,d,u]}),e[11]=l,e[12]=d,e[13]=u,e[14]=h):h=e[14],h}function uk(n){const e=jo.c(179),{editor:t,onAddImage:r,hideMenuButtons:o,classNames:s}=n;let i;e[0]!==o?(i=o===void 0?[]:o,e[0]=o,e[1]=i):i=e[1];const a=i,[l,c]=z.useState(!1),[d,u]=z.useState(!1),h=z.useRef(null),p=z.useRef(null);let f,m;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const nt=mn=>{h.current&&!h.current.contains(mn.target)&&c(!1),p.current&&!p.current.contains(mn.target)&&u(!1)};return document.addEventListener("mousedown",nt),()=>{document.removeEventListener("mousedown",nt)}},m=[],e[2]=f,e[3]=m):(f=e[2],m=e[3]),z.useEffect(f,m);let g;e[4]!==t?(g={editor:t,selector:hk},e[4]=t,e[5]=g):g=e[5];const y=kh(g);let w;e[6]!==s?.button?(w=nt=>Cn("menubar-button",nt&&"active",s?.button),e[6]=s?.button,e[7]=w):w=e[7];const x=w;let E;e[8]!==a?(E=nt=>a.includes(nt),e[8]=a,e[9]=E):E=e[9];const b=E,T=s?.container;let v;e[10]!==T?(v=Cn("menubar-container",T),e[10]=T,e[11]=v):v=e[11];let S;e[12]!==x||e[13]!==t||e[14]!==y||e[15]!==b?(S=!b("bold")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBold().run(),title:"Bold (Ctrl+B)",className:x(y.isBold),children:N.jsx(Tw,{size:14})}),e[12]=x,e[13]=t,e[14]=y,e[15]=b,e[16]=S):S=e[16];let R;e[17]!==x||e[18]!==t||e[19]!==y||e[20]!==b?(R=!b("italic")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleItalic().run(),title:"Italic (Ctrl+I)",className:x(y.isItalic),children:N.jsx(Pw,{size:14})}),e[17]=x,e[18]=t,e[19]=y,e[20]=b,e[21]=R):R=e[21];let _;e[22]!==x||e[23]!==t||e[24]!==y||e[25]!==b?(_=!b("strike")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleStrike().run(),title:"Strikethrough",className:x(y.isStrike),children:N.jsx(ek,{size:14})}),e[22]=x,e[23]=t,e[24]=y,e[25]=b,e[26]=_):_=e[26];let $;e[27]!==x||e[28]!==t||e[29]!==y||e[30]!==b?($=!b("underline")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleUnderline().run(),title:"Underline (Ctrl+U)",className:x(y.isUnderline),children:N.jsx(dk,{size:14})}),e[27]=x,e[28]=t,e[29]=y,e[30]=b,e[31]=$):$=e[31];let Y;e[32]!==b?(Y=(!b("bold")||!b("italic")||!b("strike")||!b("underline")||!b("textColor")||!b("bgColor"))&&N.jsx("div",{className:"menubar-separator"}),e[32]=b,e[33]=Y):Y=e[33];let pe;e[34]!==x||e[35]!==t||e[36]!==y||e[37]!==b||e[38]!==l?(pe=!b("textColor")&&N.jsxs("div",{className:"color-picker-container",ref:h,children:[N.jsx("button",{type:"button",onClick:()=>{c(!l),u(!1)},title:"Text Color",className:Cn(x(!1),"color-button"),children:N.jsxs("div",{className:"color-button",children:[N.jsx(qw,{size:14}),N.jsx("div",{className:"color-display-bar",style:{backgroundColor:y.displayColor}})]})}),l&&N.jsx(Sc,{currentColor:y.currentColor,onColorSelect:nt=>{const mn=kc(nt);t.chain().focus().setColor(mn).run()},onReset:()=>t.chain().focus().unsetColor().run(),onClose:()=>c(!1),type:"text"})]}),e[34]=x,e[35]=t,e[36]=y,e[37]=b,e[38]=l,e[39]=pe):pe=e[39];let Z;e[40]!==x||e[41]!==t||e[42]!==y||e[43]!==b||e[44]!==d?(Z=!b("bgColor")&&N.jsxs("div",{className:"color-picker-container",ref:p,children:[N.jsx("button",{type:"button",onClick:()=>{u(!d),c(!1)},title:"Background Color",className:Cn(x(!1),"color-button"),children:N.jsxs("div",{className:"color-button",children:[N.jsx(_w,{size:14}),N.jsx("div",{className:"color-display-bar",style:{backgroundColor:y.displayHighlight}})]})}),d&&N.jsx(Sc,{currentColor:y.currentHighlight,onColorSelect:nt=>{const mn=kc(nt);t.chain().focus().toggleHighlight({color:mn}).run()},onReset:()=>t.chain().focus().unsetHighlight().run(),onClose:()=>u(!1),type:"background"})]}),e[40]=x,e[41]=t,e[42]=y,e[43]=b,e[44]=d,e[45]=Z):Z=e[45];let q;e[46]!==b?(q=(!b("table")||!b("image"))&&N.jsx("div",{className:"menubar-separator"}),e[46]=b,e[47]=q):q=e[47];let X;e[48]!==x||e[49]!==t||e[50]!==y||e[51]!==b?(X=!b("table")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().insertTable({rows:3,cols:3}).run(),title:"Insert Table",className:x(y.isTable),children:N.jsxs("svg",{className:"menubar-table-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[N.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),N.jsx("path",{d:"M3 9h18M3 15h18M9 21V3M15 21V3"})]})}),e[48]=x,e[49]=t,e[50]=y,e[51]=b,e[52]=X):X=e[52];let ee;e[53]!==x||e[54]!==b||e[55]!==r?(ee=!b("image")&&r&&N.jsx("button",{type:"button",onClick:r,title:"Insert Image",className:x(!1),children:N.jsx($w,{size:14})}),e[53]=x,e[54]=b,e[55]=r,e[56]=ee):ee=e[56];let L;e[57]!==b?(L=(!b("h1")||!b("h2")||!b("h3")||!b("paragraph"))&&N.jsx("div",{className:"menubar-separator"}),e[57]=b,e[58]=L):L=e[58];let Se;e[59]!==x||e[60]!==t||e[61]!==y||e[62]!==b?(Se=!b("h1")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),title:"Heading 1",className:x(y.isHeading1),children:N.jsx(Ow,{size:14})}),e[59]=x,e[60]=t,e[61]=y,e[62]=b,e[63]=Se):Se=e[63];let Ce;e[64]!==x||e[65]!==t||e[66]!==y||e[67]!==b?(Ce=!b("h2")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),title:"Heading 2",className:x(y.isHeading2),children:N.jsx(Dw,{size:14})}),e[64]=x,e[65]=t,e[66]=y,e[67]=b,e[68]=Ce):Ce=e[68];let C;e[69]!==x||e[70]!==t||e[71]!==y||e[72]!==b?(C=!b("h3")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),title:"Heading 3",className:x(y.isHeading3),children:N.jsx(Lw,{size:14})}),e[69]=x,e[70]=t,e[71]=y,e[72]=b,e[73]=C):C=e[73];let B;e[74]!==x||e[75]!==t||e[76]!==y||e[77]!==b?(B=!b("paragraph")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().setParagraph().run(),title:"Paragraph",className:x(y.isParagraph),children:"¶"}),e[74]=x,e[75]=t,e[76]=y,e[77]=b,e[78]=B):B=e[78];let V;e[79]!==b?(V=(!b("bulletList")||!b("orderedList"))&&N.jsx("div",{className:"menubar-separator"}),e[79]=b,e[80]=V):V=e[80];let U;e[81]!==x||e[82]!==t||e[83]!==y||e[84]!==b?(U=!b("bulletList")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBulletList().run(),title:"Bullet List",className:x(y.isBulletList),children:N.jsx(Fw,{size:14})}),e[81]=x,e[82]=t,e[83]=y,e[84]=b,e[85]=U):U=e[85];let J;e[86]!==x||e[87]!==t||e[88]!==y||e[89]!==b?(J=!b("orderedList")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleOrderedList().run(),title:"Ordered List",className:x(y.isOrderedList),children:N.jsx(Bw,{size:14})}),e[86]=x,e[87]=t,e[88]=y,e[89]=b,e[90]=J):J=e[90];let oe;e[91]!==b?(oe=(!b("code")||!b("codeBlock")||!b("blockquote")||!b("horizontalRule"))&&N.jsx("div",{className:"menubar-separator"}),e[91]=b,e[92]=oe):oe=e[92];let F;e[93]!==x||e[94]!==t||e[95]!==y||e[96]!==b?(F=!b("code")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleCode().run(),title:"Code (Ctrl+`)",className:x(y.isCode),children:N.jsx(wc,{size:14})}),e[93]=x,e[94]=t,e[95]=y,e[96]=b,e[97]=F):F=e[97];let Ne;e[98]!==x||e[99]!==t||e[100]!==y||e[101]!==b?(Ne=!b("codeBlock")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleCodeBlock().run(),title:"Code Block",className:x(y.isCodeBlock),children:N.jsx(wc,{size:14})}),e[98]=x,e[99]=t,e[100]=y,e[101]=b,e[102]=Ne):Ne=e[102];let je;e[103]!==x||e[104]!==t||e[105]!==y||e[106]!==b?(je=!b("blockquote")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBlockquote().run(),title:"Blockquote",className:x(y.isBlockquote),children:N.jsx(Jw,{size:14})}),e[103]=x,e[104]=t,e[105]=y,e[106]=b,e[107]=je):je=e[107];let Be;e[108]!==x||e[109]!==t||e[110]!==b?(Be=!b("horizontalRule")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().setHorizontalRule().run(),title:"Horizontal Rule",className:x(!1),children:"—"}),e[108]=x,e[109]=t,e[110]=b,e[111]=Be):Be=e[111];let tt;e[112]!==b?(tt=(!b("alignLeft")||!b("alignCenter")||!b("alignRight")||!b("alignJustify"))&&N.jsx("div",{className:"menubar-separator"}),e[112]=b,e[113]=tt):tt=e[113];let Ye;e[114]!==x||e[115]!==t||e[116]!==y||e[117]!==b?(Ye=!b("alignLeft")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("left").run(),title:"Align Left",className:x(y.alignLeft),children:N.jsx(lk,{size:14})}),e[114]=x,e[115]=t,e[116]=y,e[117]=b,e[118]=Ye):Ye=e[118];let cn;e[119]!==x||e[120]!==t||e[121]!==y||e[122]!==b?(cn=!b("alignCenter")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("center").run(),title:"Align Center",className:x(y.alignCenter),children:N.jsx(nk,{size:14})}),e[119]=x,e[120]=t,e[121]=y,e[122]=b,e[123]=cn):cn=e[123];let dn;e[124]!==x||e[125]!==t||e[126]!==y||e[127]!==b?(dn=!b("alignRight")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("right").run(),title:"Align Right",className:x(y.alignRight),children:N.jsx(ok,{size:14})}),e[124]=x,e[125]=t,e[126]=y,e[127]=b,e[128]=dn):dn=e[128];let un;e[129]!==x||e[130]!==t||e[131]!==y||e[132]!==b?(un=!b("alignJustify")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("justify").run(),title:"Justify",className:x(y.alignJustify),children:N.jsx(ik,{size:14})}),e[129]=x,e[130]=t,e[131]=y,e[132]=b,e[133]=un):un=e[133];let hn;e[134]!==b?(hn=(!b("undo")||!b("redo"))&&N.jsx("div",{className:"menubar-separator"}),e[134]=b,e[135]=hn):hn=e[135];let pn;e[136]!==x||e[137]!==t||e[138]!==y||e[139]!==b?(pn=!b("undo")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().undo().run(),disabled:!y.canUndo,title:"Undo (Ctrl+Z)",className:x(!1),children:N.jsx(Xw,{size:14})}),e[136]=x,e[137]=t,e[138]=y,e[139]=b,e[140]=pn):pn=e[140];let fn;e[141]!==x||e[142]!==t||e[143]!==y||e[144]!==b?(fn=!b("redo")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().redo().run(),disabled:!y.canRedo,title:"Redo (Ctrl+Y)",className:x(!1),children:N.jsx(Qw,{size:14})}),e[141]=x,e[142]=t,e[143]=y,e[144]=b,e[145]=fn):fn=e[145];let yr;return e[146]!==S||e[147]!==R||e[148]!==_||e[149]!==$||e[150]!==Y||e[151]!==pe||e[152]!==Z||e[153]!==q||e[154]!==X||e[155]!==ee||e[156]!==L||e[157]!==Se||e[158]!==Ce||e[159]!==C||e[160]!==B||e[161]!==V||e[162]!==U||e[163]!==J||e[164]!==oe||e[165]!==F||e[166]!==Ne||e[167]!==je||e[168]!==Be||e[169]!==tt||e[170]!==Ye||e[171]!==cn||e[172]!==dn||e[173]!==un||e[174]!==hn||e[175]!==pn||e[176]!==fn||e[177]!==v?(yr=N.jsxs("div",{className:v,children:[S,R,_,$,Y,pe,Z,q,X,ee,L,Se,Ce,C,B,V,U,J,oe,F,Ne,je,Be,tt,Ye,cn,dn,un,hn,pn,fn]}),e[146]=S,e[147]=R,e[148]=_,e[149]=$,e[150]=Y,e[151]=pe,e[152]=Z,e[153]=q,e[154]=X,e[155]=ee,e[156]=L,e[157]=Se,e[158]=Ce,e[159]=C,e[160]=B,e[161]=V,e[162]=U,e[163]=J,e[164]=oe,e[165]=F,e[166]=Ne,e[167]=je,e[168]=Be,e[169]=tt,e[170]=Ye,e[171]=cn,e[172]=dn,e[173]=un,e[174]=hn,e[175]=pn,e[176]=fn,e[177]=v,e[178]=yr):yr=e[178],yr}function hk(n){const e=n.editor.getAttributes("textStyle").color,t=n.editor.getAttributes("highlight").color;return{isBold:n.editor.isActive("bold")??!1,isItalic:n.editor.isActive("italic")??!1,isUnderline:n.editor.isActive("underline")??!1,isStrike:n.editor.isActive("strike")??!1,isCode:n.editor.isActive("code")??!1,canClearMarks:n.editor.can().chain().unsetAllMarks().run()??!1,isParagraph:n.editor.isActive("paragraph")??!1,isHeading1:n.editor.isActive("heading",{level:1})??!1,isHeading2:n.editor.isActive("heading",{level:2})??!1,isHeading3:n.editor.isActive("heading",{level:3})??!1,isBulletList:n.editor.isActive("bulletList")??!1,isOrderedList:n.editor.isActive("orderedList")??!1,isCodeBlock:n.editor.isActive("codeBlock")??!1,isBlockquote:n.editor.isActive("blockquote")??!1,canUndo:n.editor.can().chain().undo().run()??!1,canRedo:n.editor.can().chain().redo().run()??!1,isTable:n.editor.isActive("table")??!1,alignLeft:n.editor.isActive({textAlign:"left"})??!1,alignCenter:n.editor.isActive({textAlign:"center"})??!1,alignRight:n.editor.isActive({textAlign:"right"})??!1,alignJustify:n.editor.isActive({textAlign:"justify"})??!1,currentColor:e?vc(e):"black",currentHighlight:t?vc(t):"#ffffff",displayColor:e||"var(--editor-text-black)",displayHighlight:t||"transparent"}}function Cc(n){if(!n)return"<p></p>";try{return JSON.parse(n)}catch{return n}}function pk({ref:n,className:e,classNames:t,initialContent:r="",hideMenuButtons:o=[]}){const s=wx({extensions:Ch,content:Cc(r),editorProps:{attributes:{class:Cn("tiptap-editor-content",t?.editorContent)},handlePaste(a,l){const c=l.clipboardData?.items;if(!c)return!1;for(let d=0;d<c.length;d++)if(c[d].kind==="file"&&c[d].type.startsWith("image/")){l.preventDefault();const u=c[d].getAsFile();if(!u)continue;const h=new FileReader;return h.onload=p=>{const f=p.target?.result,{state:m}=a,{$from:g}=m.selection,y=m.schema.nodes.image.create({src:f}),w=m.tr.insert(g.pos,y);a.dispatch(w)},h.readAsDataURL(u),!0}return!1},handleDOMEvents:{copy:(a,l)=>{const{state:c}=a,{selection:d}=c,{$from:u,$to:h}=d;return c.doc.nodesBetween(u.pos,h.pos,p=>{if(p.type.name==="image"&&p.attrs.src){if(l.preventDefault(),l.clipboardData){if(p.attrs.src.startsWith("data:image/"))try{const f=p.attrs.src.split(",")[1],m=p.attrs.src.match(/data:([^;]+);/)?.[1]||"image/png",g=atob(f),y=new Array(g.length);for(let b=0;b<g.length;b++)y[b]=g.charCodeAt(b);const w=new Uint8Array(y),x=new Blob([w],{type:m}),E=new ClipboardItem({[m]:x});navigator.clipboard.write([E]).catch(b=>{console.error("Failed to copy image to clipboard:",b)})}catch(f){console.error("Failed to process image for clipboard:",f)}l.clipboardData.setData("text/html",`<img src="${p.attrs.src}" />`),l.clipboardData.setData("text/plain",p.attrs.src)}return!1}}),!1},cut:(a,l)=>{const{state:c}=a,{selection:d}=c,{$from:u,$to:h}=d;return c.doc.nodesBetween(u.pos,h.pos,(p,f)=>{if(p.type.name==="image"&&p.attrs.src){if(l.preventDefault(),l.clipboardData){if(p.attrs.src.startsWith("data:image/"))try{const g=p.attrs.src.split(",")[1],y=p.attrs.src.match(/data:([^;]+);/)?.[1]||"image/png",w=atob(g),x=new Array(w.length);for(let v=0;v<w.length;v++)x[v]=w.charCodeAt(v);const E=new Uint8Array(x),b=new Blob([E],{type:y}),T=new ClipboardItem({[y]:b});navigator.clipboard.write([T]).catch(v=>{console.error("Failed to copy image to clipboard:",v)})}catch(g){console.error("Failed to process image for clipboard:",g)}l.clipboardData.setData("text/html",`<img src="${p.attrs.src}" />`),l.clipboardData.setData("text/plain",p.attrs.src)}const m=c.tr.delete(f,f+p.nodeSize);return a.dispatch(m),!1}}),!1}}}}),i=z.useCallback(()=>{const a=document.createElement("input");a.type="file",a.accept="image/*",a.onchange=l=>{const c=l.target.files?.[0];if(!c||!s)return;const d=new FileReader;d.onload=u=>{const h=u.target?.result;s.chain().focus().insertContent({type:"image",attrs:{src:h}}).run()},d.readAsDataURL(c)},a.click()},[s]);return z.useEffect(()=>{if(s&&r&&r.trim()){const a=Cc(r);s.commands.setContent(a)}},[s,r]),z.useImperativeHandle(n,()=>({getJSON:()=>s?JSON.stringify(s.getJSON()):"{}"}),[s]),s?N.jsxs("div",{className:Cn("tiptap-editor-wrapper",e),children:[N.jsx(uk,{editor:s,onAddImage:i,hideMenuButtons:o,classNames:{container:t?.menubarContainer,button:t?.menubarButton}}),N.jsx(mx,{editor:s})]}):null}function fk(n,e,t){if(typeof window>"u")throw new Error("getHTMLFromFragment can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");const r=Bt.fromSchema(e).serializeFragment(n.content,{document:window.document});return new XMLSerializer().serializeToString(r)}function mk(n,e){if(typeof window>"u")throw new Error("generateHTML can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");const t=qg(e),r=Je.fromJSON(t,n);return fk(r,t)}function gk(n){if(!n)return"<p></p>";try{const e=JSON.parse(n);let t=mk(e,Ch);return t=t.replace(/<p[^>]*><\/p>/g,"<p><br></p>"),t}catch{return n}}const Hh=n=>{const e=jo.c(4),{content:t}=n;let r;e[0]!==t?(r=gk(t),e[0]=t,e[1]=r):r=e[1];let o;return e[2]!==r?(o=N.jsx("div",{className:"content-div",dangerouslySetInnerHTML:{__html:r}}),e[2]=r,e[3]=o):o=e[3],o},Do=n=>{const e=ln.compilerRuntimeExports.c(18),{ref:t,tiptapRef:r,initialContent:o,isSubmitting:s,onSubmit:i,onCancel:a,submitLabel:l,cancelLabel:c,showLabel:d,labelText:u,containerClassName:h}=n,p=o===void 0?"":o,f=s===void 0?!1:s,m=l===void 0?"작성":l,g=c===void 0?"취소":c,y=d===void 0?!0:d,w=u===void 0?"댓글 작성":u,E=`flex flex-col gap-2 rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50 ${h===void 0?"":h}`;let b;e[0]!==g||e[1]!==f||e[2]!==w||e[3]!==a||e[4]!==i||e[5]!==y||e[6]!==m?(b=y&&k.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[k.jsxRuntimeExports.jsx("label",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:w}),k.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[k.jsxRuntimeExports.jsxs(k.Button,{size:"sm",onClick:i,disabled:f,children:[f?k.jsxRuntimeExports.jsx(Pe.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):k.jsxRuntimeExports.jsx(Pe.Send,{className:"mr-2 h-4 w-4"}),m]}),k.jsxRuntimeExports.jsx(k.Button,{size:"sm",variant:"outline",onClick:a,disabled:f,children:g})]})]}),e[0]=g,e[1]=f,e[2]=w,e[3]=a,e[4]=i,e[5]=y,e[6]=m,e[7]=b):b=e[7];let T,v;e[8]===Symbol.for("react.memo_cache_sentinel")?(T={menubarContainer:"dark:bg-background!",editorContent:"dark:bg-card! min-h-[4rem]! max-h-[8rem]! overflow-y-auto"},v=["table","bgColor","undo","redo","alignLeft","alignCenter","alignRight","alignJustify","paragraph"],e[8]=T,e[9]=v):(T=e[8],v=e[9]);let S;e[10]!==p||e[11]!==r?(S=k.jsxRuntimeExports.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900",children:k.jsxRuntimeExports.jsx(pk,{ref:r,initialContent:p,className:"rounded",classNames:T,hideMenuButtons:v})}),e[10]=p,e[11]=r,e[12]=S):S=e[12];let R;return e[13]!==t||e[14]!==S||e[15]!==E||e[16]!==b?(R=k.jsxRuntimeExports.jsxs("div",{ref:t,className:E,children:[b,S]}),e[13]=t,e[14]=S,e[15]=E,e[16]=b,e[17]=R):R=e[17],R},yk=n=>{const e=ln.compilerRuntimeExports.c(10),{onEdit:t,onDelete:r}=n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=k.jsxRuntimeExports.jsx(k.PopoverTrigger,{asChild:!0,children:k.jsxRuntimeExports.jsx(k.Button,{size:"sm",variant:"ghost",className:"h-auto px-2 py-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:k.jsxRuntimeExports.jsx(Pe.MoreHorizontal,{className:"h-5 w-5"})})}),e[0]=o):o=e[0];let s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s=k.jsxRuntimeExports.jsx(Pe.Edit2,{className:"mr-2 h-3 w-3"}),e[1]=s):s=e[1];let i;e[2]!==t?(i=k.jsxRuntimeExports.jsxs(k.Button,{size:"sm",variant:"ghost",onClick:t,className:"justify-start text-xs text-gray-700 dark:text-gray-300",children:[s,"수정"]}),e[2]=t,e[3]=i):i=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=k.jsxRuntimeExports.jsx(Pe.Trash2,{className:"mr-2 h-3 w-3"}),e[4]=a):a=e[4];let l;e[5]!==r?(l=k.jsxRuntimeExports.jsxs(k.Button,{size:"sm",variant:"ghost",onClick:r,className:"justify-start text-xs text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:[a,"삭제"]}),e[5]=r,e[6]=l):l=e[6];let c;return e[7]!==i||e[8]!==l?(c=k.jsxRuntimeExports.jsxs(k.Popover,{children:[o,k.jsxRuntimeExports.jsx(k.PopoverContent,{className:"w-auto p-1",children:k.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-1",children:[i,l]})})]}),e[7]=i,e[8]=l,e[9]=c):c=e[9],c},Bh=n=>{const e=ln.compilerRuntimeExports.c(49),{comment:t,level:r,currentUserId:o,onReplyOpen:s,replyingToId:i,replyEditorRef:a,onSubmitReply:l,isSubmitting:c,onEdit:d,editingId:u,editEditorRef:h,onSubmitEdit:p,onDelete:f,isEditing:m}=n,g=i===t.id,y=u===t.id,w=t.children&&t.children.length>0,x=`reply-editor-${t.id}`,E=r>0&&"ml-4 border-l border-gray-200 pl-4 dark:border-gray-700";let b;e[0]!==E?(b=k.cn("flex flex-col gap-2",E),e[0]=E,e[1]=b):b=e[1];let T;e[2]!==t.body||e[3]!==t.createdAt||e[4]!==t.id||e[5]!==t.isAdmin||e[6]!==t.userId||e[7]!==t.userName||e[8]!==o||e[9]!==h||e[10]!==m||e[11]!==y||e[12]!==g||e[13]!==r||e[14]!==f||e[15]!==d||e[16]!==s||e[17]!==p||e[18]!==x?(T=y?k.jsxRuntimeExports.jsx(Do,{tiptapRef:h,initialContent:t.body,isSubmitting:m,onSubmit:()=>p(t.id),onCancel:()=>d(""),submitLabel:"수정",labelText:"댓글 수정"}):k.jsxRuntimeExports.jsx("div",{className:"py-2",children:k.jsxRuntimeExports.jsxs("div",{className:"flex items-start justify-between gap-3",children:[k.jsxRuntimeExports.jsxs("div",{className:"flex-1",children:[k.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[k.jsxRuntimeExports.jsx("span",{className:"text-xs font-medium text-gray-900 dark:text-gray-100",children:t.userName}),t.isAdmin&&k.jsxRuntimeExports.jsx("span",{className:"inline-flex items-center rounded-full bg-blue-100 px-2 py-0.5 text-xs font-semibold text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",children:"👨‍💼 관리자"}),k.jsxRuntimeExports.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:Ec.format(new Date(t.createdAt),"yyyy-MM-dd HH:mm")})]}),k.jsxRuntimeExports.jsx("div",{className:"mt-2 text-sm text-gray-700 dark:text-gray-300",children:k.jsxRuntimeExports.jsx(Hh,{content:t.body})}),!g&&k.jsxRuntimeExports.jsx("div",{className:"mt-2 flex items-center gap-3",children:r<2&&k.jsxRuntimeExports.jsx(k.Button,{size:"sm",variant:"ghost",onClick:()=>{s(t.id),setTimeout(()=>{const _=document.getElementById(x);_&&(_.scrollIntoView({behavior:"auto",block:"center"}),_.querySelector("[contenteditable]")?.focus())},50)},className:"h-auto px-2 py-1 text-sm font-medium text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-200",children:"💬 답글"})})]}),o===t.userId&&k.jsxRuntimeExports.jsx(yk,{onEdit:()=>d(t.id),onDelete:()=>f(t.id)})]})}),e[2]=t.body,e[3]=t.createdAt,e[4]=t.id,e[5]=t.isAdmin,e[6]=t.userId,e[7]=t.userName,e[8]=o,e[9]=h,e[10]=m,e[11]=y,e[12]=g,e[13]=r,e[14]=f,e[15]=d,e[16]=s,e[17]=p,e[18]=x,e[19]=T):T=e[19];let v;e[20]!==t.id||e[21]!==g||e[22]!==c||e[23]!==s||e[24]!==l||e[25]!==x||e[26]!==a?(v=g&&k.jsxRuntimeExports.jsx(Do,{ref:_=>{_&&(_.id=x)},tiptapRef:a,isSubmitting:c,onSubmit:()=>l(t.id),onCancel:()=>s(""),submitLabel:"작성",labelText:"답글 작성"}),e[20]=t.id,e[21]=g,e[22]=c,e[23]=s,e[24]=l,e[25]=x,e[26]=a,e[27]=v):v=e[27];let S;e[28]!==t.children||e[29]!==o||e[30]!==h||e[31]!==u||e[32]!==w||e[33]!==m||e[34]!==c||e[35]!==r||e[36]!==f||e[37]!==d||e[38]!==s||e[39]!==p||e[40]!==l||e[41]!==a||e[42]!==i?(S=w&&k.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-2",children:t.children.map(_=>k.jsxRuntimeExports.jsx(Bh,{comment:_,level:r+1,currentUserId:o,onReplyOpen:s,replyingToId:i,replyEditorRef:a,onSubmitReply:l,isSubmitting:c,onEdit:d,editingId:u,editEditorRef:h,onSubmitEdit:p,onDelete:f,isEditing:m},_.id))}),e[28]=t.children,e[29]=o,e[30]=h,e[31]=u,e[32]=w,e[33]=m,e[34]=c,e[35]=r,e[36]=f,e[37]=d,e[38]=s,e[39]=p,e[40]=l,e[41]=a,e[42]=i,e[43]=S):S=e[43];let R;return e[44]!==b||e[45]!==T||e[46]!==v||e[47]!==S?(R=k.jsxRuntimeExports.jsxs("div",{className:b,children:[T,v,S]}),e[44]=b,e[45]=T,e[46]=v,e[47]=S,e[48]=R):R=e[48],R},bk=n=>{const e=ln.compilerRuntimeExports.c(33),{comments:t,isLoading:r,isCommentEditOpen:o,onCommentEditOpen:s,commentEditorRef:i,onSubmitComment:a,isSubmitting:l,replyingToId:c,onReplyOpen:d,replyEditorRef:u,onSubmitReply:h,editingId:p,onEdit:f,editEditorRef:m,onSubmitEdit:g,onDelete:y,isEditing:w,currentUserId:x}=n;let E;e[0]!==t.length?(E=k.jsxRuntimeExports.jsxs("h3",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["댓글 (",t.length,")"]}),e[0]=t.length,e[1]=E):E=e[1];let b;e[2]!==o||e[3]!==s?(b=!o&&k.jsxRuntimeExports.jsxs(k.Button,{size:"sm",variant:"outline",onClick:()=>s(!0),children:[k.jsxRuntimeExports.jsx(Pe.Send,{className:"mr-2 h-4 w-4"}),"댓글 작성"]}),e[2]=o,e[3]=s,e[4]=b):b=e[4];let T;e[5]!==E||e[6]!==b?(T=k.jsxRuntimeExports.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[E,b]}),e[5]=E,e[6]=b,e[7]=T):T=e[7];let v;e[8]!==i||e[9]!==o||e[10]!==l||e[11]!==s||e[12]!==a?(v=o&&k.jsxRuntimeExports.jsx(Do,{tiptapRef:i,isSubmitting:l,onSubmit:a,onCancel:()=>s(!1),submitLabel:"작성",labelText:"댓글 작성"}),e[8]=i,e[9]=o,e[10]=l,e[11]=s,e[12]=a,e[13]=v):v=e[13];let S;e[14]!==t||e[15]!==x||e[16]!==m||e[17]!==p||e[18]!==w||e[19]!==r||e[20]!==l||e[21]!==y||e[22]!==f||e[23]!==d||e[24]!==g||e[25]!==h||e[26]!==u||e[27]!==c?(S=k.jsxRuntimeExports.jsx("div",{className:"mt-4",children:r?k.jsxRuntimeExports.jsx("div",{className:"flex justify-center py-4",children:k.jsxRuntimeExports.jsx(Pe.Loader2,{className:"h-4 w-4 animate-spin text-gray-400"})}):t.length===0?k.jsxRuntimeExports.jsx("div",{className:"text-center text-xs text-gray-500 dark:text-gray-400",children:"아직 댓글이 없습니다."}):k.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-0",children:t.map((_,$)=>k.jsxRuntimeExports.jsxs("div",{children:[k.jsxRuntimeExports.jsx(Bh,{comment:_,level:0,currentUserId:x,onReplyOpen:d,replyingToId:c,replyEditorRef:u,onSubmitReply:h,isSubmitting:l,onEdit:f,editingId:p,editEditorRef:m,onSubmitEdit:g,onDelete:y,isEditing:w}),$<t.length-1&&k.jsxRuntimeExports.jsx(k.Separator,{className:"my-3 bg-gray-200 dark:bg-gray-700"})]},_.id))})}),e[14]=t,e[15]=x,e[16]=m,e[17]=p,e[18]=w,e[19]=r,e[20]=l,e[21]=y,e[22]=f,e[23]=d,e[24]=g,e[25]=h,e[26]=u,e[27]=c,e[28]=S):S=e[28];let R;return e[29]!==T||e[30]!==v||e[31]!==S?(R=k.jsxRuntimeExports.jsxs("div",{children:[T,v,S]}),e[29]=T,e[30]=v,e[31]=S,e[32]=R):R=e[32],R},xk=n=>{const e=ln.compilerRuntimeExports.c(35),{feedback:t,currentUserId:r,onEditClick:o,onDeleteClick:s}=n;let i;e[0]!==t.feedbackDetail.title?(i=k.jsxRuntimeExports.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:t.feedbackDetail.title}),e[0]=t.feedbackDetail.title,e[1]=i):i=e[1];let a;e[2]!==t.userName?(a=k.jsxRuntimeExports.jsx("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:t.userName}),e[2]=t.userName,e[3]=a):a=e[3];let l;e[4]!==t.institutionName?(l=t.institutionName&&k.jsxRuntimeExports.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["· ",t.institutionName]}),e[4]=t.institutionName,e[5]=l):l=e[5];let c;e[6]!==a||e[7]!==l?(c=k.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[a,l]}),e[6]=a,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==t.createdAt?(d=Ec.format(new Date(t.createdAt),"yyyy-MM-dd HH:mm"),e[9]=t.createdAt,e[10]=d):d=e[10];let u;e[11]!==d?(u=k.jsxRuntimeExports.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:d}),e[11]=d,e[12]=u):u=e[12];const h=t.status==="pending"?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400":"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400";let p;e[13]!==h?(p=k.cn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",h),e[13]=h,e[14]=p):p=e[14];const f=t.status==="pending"?"미해결":"해결됨";let m;e[15]!==p||e[16]!==f?(m=k.jsxRuntimeExports.jsx("span",{className:p,children:f}),e[15]=p,e[16]=f,e[17]=m):m=e[17];let g;e[18]!==m||e[19]!==u?(g=k.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[u,m]}),e[18]=m,e[19]=u,e[20]=g):g=e[20];let y;e[21]!==g||e[22]!==c?(y=k.jsxRuntimeExports.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[c,g]}),e[21]=g,e[22]=c,e[23]=y):y=e[23];let w;e[24]!==i||e[25]!==y?(w=k.jsxRuntimeExports.jsxs("div",{className:"flex-1",children:[i,y]}),e[24]=i,e[25]=y,e[26]=w):w=e[26];let x;e[27]!==r||e[28]!==t.userId||e[29]!==s||e[30]!==o?(x=r===t.userId&&k.jsxRuntimeExports.jsxs(k.Popover,{children:[k.jsxRuntimeExports.jsx(k.PopoverTrigger,{asChild:!0,children:k.jsxRuntimeExports.jsx(k.Button,{size:"sm",variant:"ghost",className:"h-auto px-2 py-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:k.jsxRuntimeExports.jsx(Pe.MoreHorizontal,{className:"h-5 w-5"})})}),k.jsxRuntimeExports.jsx(k.PopoverContent,{className:"w-auto p-1",children:k.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-1",children:[k.jsxRuntimeExports.jsxs(k.Button,{size:"sm",variant:"ghost",onClick:o,className:"justify-start text-xs text-gray-700 dark:text-gray-300",children:[k.jsxRuntimeExports.jsx(Pe.Edit2,{className:"mr-2 h-3 w-3"}),"수정"]}),k.jsxRuntimeExports.jsxs(k.Button,{size:"sm",variant:"ghost",onClick:s,className:"justify-start text-xs text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:[k.jsxRuntimeExports.jsx(Pe.Trash2,{className:"mr-2 h-3 w-3"}),"삭제"]})]})})]}),e[27]=r,e[28]=t.userId,e[29]=s,e[30]=o,e[31]=x):x=e[31];let E;return e[32]!==w||e[33]!==x?(E=k.jsxRuntimeExports.jsxs("div",{className:"mb-6 flex items-start justify-between",children:[w,x]}),e[32]=w,e[33]=x,e[34]=E):E=e[34],E},wk=n=>{const e=ln.compilerRuntimeExports.c(12),{feedback:t,isEditing:r,isUpdating:o,currentUserRole:s,feedbackEditorRef:i,titleInputRef:a,onEditCancel:l,onEditSave:c,onStatusChange:d}=n;let u;return e[0]!==s||e[1]!==t.feedbackDetail.body||e[2]!==t.feedbackDetail.title||e[3]!==t.status||e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==l||e[8]!==c||e[9]!==d||e[10]!==a?(u=k.jsxRuntimeExports.jsx("div",{className:"mb-6",children:r?k.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[k.jsxRuntimeExports.jsxs("div",{className:"rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50",children:[k.jsxRuntimeExports.jsx("label",{className:"mb-2 block text-xs font-medium text-gray-700 dark:text-gray-300",children:"제목"}),k.jsxRuntimeExports.jsx("input",{ref:a,type:"text",defaultValue:t.feedbackDetail.title,className:"w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm text-gray-900 placeholder-gray-400 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100 dark:placeholder-gray-500",placeholder:"피드백 제목을 입력하세요"})]}),k.jsxRuntimeExports.jsx(Do,{tiptapRef:i,initialContent:t.feedbackDetail.body,isSubmitting:o,onSubmit:c,onCancel:l,submitLabel:"수정",labelText:"피드백 수정",showLabel:!0})]}):k.jsxRuntimeExports.jsxs(k.jsxRuntimeExports.Fragment,{children:[k.jsxRuntimeExports.jsx("div",{className:"prose prose-sm dark:prose-invert mb-6 max-w-none text-gray-900 dark:text-gray-100",children:k.jsxRuntimeExports.jsx(Hh,{content:t.feedbackDetail.body})}),k.jsxRuntimeExports.jsx("div",{className:"w-full",children:k.jsxRuntimeExports.jsxs("div",{className:k.cn("flex items-center justify-between rounded-lg px-4 py-4 font-medium",t.status==="pending"?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400":"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400"),children:[k.jsxRuntimeExports.jsxs("div",{children:[k.jsxRuntimeExports.jsxs("div",{className:"mb-1 text-sm font-semibold",children:[t.status==="pending"?"아직 미해결이에요":"해결되었어요"," ",t.status==="pending"?"⏳":"✓"]}),k.jsxRuntimeExports.jsx("div",{className:"text-xs opacity-90",children:t.status==="pending"?"담당자가 검토하고 있습니다. 조금 더 기다려주세요.":"소중한 피드백 감사합니다!"})]}),s==="admin"&&k.jsxRuntimeExports.jsxs(k.Button,{size:"sm",onClick:d,disabled:o,className:k.cn("shrink-0 gap-1",t.status==="pending"?"bg-yellow-700 hover:bg-yellow-800 dark:bg-yellow-600 dark:hover:bg-yellow-700":"bg-green-700 hover:bg-green-800 dark:bg-green-600 dark:hover:bg-green-700"),children:[o?k.jsxRuntimeExports.jsx(Pe.Loader2,{className:"h-4 w-4 animate-spin"}):k.jsxRuntimeExports.jsx(Pe.RefreshCw,{className:"h-4 w-4"}),t.status==="pending"?"해결":"미해결"]})]})})]})}),e[0]=s,e[1]=t.feedbackDetail.body,e[2]=t.feedbackDetail.title,e[3]=t.status,e[4]=i,e[5]=r,e[6]=o,e[7]=l,e[8]=c,e[9]=d,e[10]=a,e[11]=u):u=e[11],u},kk=()=>{const n=ln.compilerRuntimeExports.c(1),e=z.useRef(null),t=z.useRef(null),r=z.useRef(null),o=z.useRef(null),s=vk,i=Sk,a=Ck;let l;return n[0]===Symbol.for("react.memo_cache_sentinel")?(l={commentEditorRef:e,replyEditorRef:t,editEditorRef:r,feedbackEditorRef:o,clearEditor:s,getEditorContent:i,validateContent:a},n[0]=l):l=n[0],l};function vk(n){n.current?.editor?.commands?.clearContent?.()}function Sk(n){return n.current?.getJSON?.()??""}function Ck(n){return n?typeof n=="string"?n.trim().length>0:!0:!1}const Mk=({feedback:n,isFeedbackLoading:e,feedbackError:t,comments:r,isCommentsLoading:o,currentUser:s,onClose:i,callbacks:a,isDialog:l=!1})=>{const{commentEditorRef:c,replyEditorRef:d,editEditorRef:u,feedbackEditorRef:h,clearEditor:p,getEditorContent:f,validateContent:m}=kk(),[g,y]=z.useState(!1),[w,x]=z.useState(null),[E,b]=z.useState(null),[T,v]=z.useState(!1),S=z.useRef(null),[R,_]=z.useTransition(),[$,Y]=z.useTransition(),[pe,Z]=z.useTransition(),[q,X]=z.useTransition(),ee=r||[],L=async()=>{const J=f(c);if(!m(J))return a.onValidateError("empty");n?.id&&_(async()=>{try{await a.onCommentCreate(n.id,{body:J}),p(c),y(!1),a.onCommentChanged()}catch(oe){a.onError(oe)}})},Se=async J=>{const oe=f(d);if(!m(oe))return a.onValidateError("empty");n?.id&&_(async()=>{try{await a.onCommentCreate(n.id,{body:oe,refId:J}),p(d),x(null),a.onCommentChanged()}catch(F){a.onError(F)}})},Ce=async J=>{const oe=f(u);if(!m(oe))return a.onValidateError("empty");Y(async()=>{try{await a.onCommentUpdate(J,{body:oe}),b(null),p(u),a.onCommentChanged()}catch(F){a.onError(F)}})},C=async J=>{confirm("댓글을 삭제하시겠습니까?")&&Z(async()=>{try{await a.onCommentDelete(J),a.onCommentChanged()}catch(oe){a.onError(oe)}})},B=async()=>{const J=S.current?.value||"",oe=f(h);if(!m(J)){a.onValidateError("empty");return}if(!m(oe)){a.onValidateError("empty");return}n&&X(async()=>{try{await a.onFeedbackUpdate(n.id,{feedbackDetail:{title:J,body:oe}}),v(!1),p(h),a.onFeedbackChanged()}catch(F){a.onError(F)}})},V=async()=>{n&&X(async()=>{try{const J=n.status==="pending"?"resolved":"pending";await a.onFeedbackStatusUpdate?.(n.id,{status:J}),a.onFeedbackChanged()}catch(J){a.onError(J)}})},U=async()=>{if(confirm("피드백을 삭제하시겠습니까?")&&n?.id)try{await a.onDeleteFeedback(n.id),a.onFeedbackChanged(),i?i():window.close()}catch(J){a.onError(J)}};if(e){const J=k.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-center py-8",children:k.jsxRuntimeExports.jsx(Pe.Loader2,{className:"h-6 w-6 animate-spin text-gray-400"})});return l?J:k.jsxRuntimeExports.jsx("div",{className:"bg-background flex min-h-screen items-center justify-center",children:J})}if(t||!n){const J=k.jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center justify-center p-4",children:[k.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-red-50 p-4 text-sm text-red-700 dark:bg-red-900/20 dark:text-red-400",children:[k.jsxRuntimeExports.jsx(Pe.AlertCircle,{className:"h-4 w-4 shrink-0"}),k.jsxRuntimeExports.jsx("span",{children:"피드백을 불러오는데 실패했습니다."})]}),!l&&k.jsxRuntimeExports.jsx(k.Button,{onClick:()=>window.close(),variant:"ghost",size:"sm",className:"mt-4 text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100",children:"닫기"})]});return l?k.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-center py-8",children:J}):k.jsxRuntimeExports.jsx("div",{className:"bg-background flex min-h-screen flex-col items-center justify-center",children:J})}return k.jsxRuntimeExports.jsxs("div",{className:k.cn("bg-background flex flex-col",l?"h-auto":"min-h-screen"),children:[k.jsxRuntimeExports.jsx("div",{className:"shrink-0 border-b border-gray-200 py-4 dark:border-gray-700",children:k.jsxRuntimeExports.jsx("div",{className:"mx-auto max-w-4xl px-6",children:k.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:k.jsxRuntimeExports.jsx("h1",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"피드백 상세"})})})}),k.jsxRuntimeExports.jsx("div",{className:"bg-background flex-1 overflow-y-auto",children:k.jsxRuntimeExports.jsxs("div",{className:"mx-auto max-w-4xl px-6 py-6",children:[k.jsxRuntimeExports.jsx(xk,{feedback:n,currentUserId:s?.id,onEditClick:()=>v(!0),onDeleteClick:U}),k.jsxRuntimeExports.jsx(wk,{feedback:n,isEditing:T,isUpdating:q,currentUserRole:s?.role,feedbackEditorRef:h,titleInputRef:S,onEditCancel:()=>v(!1),onEditSave:B,onStatusChange:V}),k.jsxRuntimeExports.jsx(k.Separator,{className:"mb-6 bg-gray-200 dark:bg-gray-700"}),k.jsxRuntimeExports.jsx(bk,{comments:ee,isLoading:o,isCommentEditOpen:g,onCommentEditOpen:y,commentEditorRef:c,onSubmitComment:L,isSubmitting:R,replyingToId:w,onReplyOpen:x,replyEditorRef:d,onSubmitReply:Se,editingId:E,onEdit:b,editEditorRef:u,onSubmitEdit:Ce,onDelete:C,isEditing:$||pe,currentUserId:s?.id})]})})]})};exports.FeedbackDetailPageContent=Mk;
151
+ `),[s,i]=b1(o);if(s.length===0)return;const a=fh(s,0,t);return a.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:a,raw:o.slice(0,i).join(`
152
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(w1,this.editor.getAttributes(Yl)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Dn({find:Ql,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Dn({find:Ql,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Yl)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),k1=/^\s*(\[([( |x])?\])\s$/,v1=ve.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:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",re(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const r=`- [${(t=n.attrs)!=null&&t.checked?"x":" "}] `;return Xi(n,e,r)},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const o=document.createElement("li"),s=document.createElement("label"),i=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),c=d=>{var u,h;a.ariaLabel=((h=(u=this.options.a11y)==null?void 0:u.checkboxLabel)==null?void 0:h.call(u,d,a.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return c(n),s.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",d=>d.preventDefault()),a.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:u}=d.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const p=t();if(typeof p!="number")return!1;const f=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...f?.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,u)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,u])=>{o.setAttribute(d,u)}),o.dataset.checked=n.attrs.checked,a.checked=n.attrs.checked,s.append(a,i),o.append(s,l),Object.entries(e).forEach(([d,u])=>{o.setAttribute(d,u)}),{dom:o,contentDOM:l,update:d=>d.type!==this.type?!1:(o.dataset.checked=d.attrs.checked,a.checked=d.attrs.checked,c(d),!0)}}},addInputRules(){return[Dn({find:k1,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),S1=ve.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:n}){return["ul",re(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
153
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=s=>{const i=ei(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,l)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:t.inlineTokens(a.mainContent),nestedTokens:l}),customNestedParser:r},t);return i?[{type:"taskList",raw:i.raw,items:i.items}]:t.blockTokens(s)},o=ei(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,i)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:t.inlineTokens(s.mainContent),nestedTokens:i}),customNestedParser:r},t);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});te.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(ih.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(ah.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(ph.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(mh.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(v1.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(S1.configure(this.options.taskList)),n}});var C1=ve.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",re(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];return t.length===1&&t[0].type==="image"?e.parseChildren([t[0]]):e.createNode("paragraph",void 0,e.parseInline(t))},renderMarkdown:(n,e)=>!n||!Array.isArray(n.content)?"":e.renderChildren(n.content),addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),M1=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,E1=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,T1=wt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",re(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[sn({find:M1,type:this.type})]},addPasteRules(){return[Ht({find:E1,type:this.type})]}}),N1=ve.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""});function A1(n={}){return new le({view(e){return new O1(e,n)}})}class O1{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let s=i=>{this[o](i)};return e.dom.addEventListener(o,s),{name:o,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.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),t=!e.parent.inlineContent,r,o=this.editorView.dom,s=o.getBoundingClientRect(),i=s.width/o.offsetWidth,a=s.height/o.offsetHeight;if(t){let u=e.nodeBefore,h=e.nodeAfter;if(u||h){let p=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(p){let f=p.getBoundingClientRect(),m=u?f.bottom:f.top;u&&h&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*a;r={left:f.left,right:f.right,top:m-g,bottom:m+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*i;r={left:u.left-h,right:u.left+h,top:u.top,bottom:u.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.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",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=l.getBoundingClientRect(),h=u.width/l.offsetWidth,p=u.height/l.offsetHeight;c=u.left-l.scrollLeft*h,d=u.top-l.scrollTop*p}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-d)/a+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,s=typeof o=="function"?o(this.editorView,t,e):o;if(t&&!s){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=ed(this.editorView.state.doc,i,this.editorView.dragging.slice);a!=null&&(i=a)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class de extends W{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return de.valid(r)?new de(r):W.near(r)}content(){return O.empty}eq(e){return e instanceof de&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new de(e.resolve(t.pos))}getBookmark(){return new la(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!R1(e)||!D1(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&de.valid(e))return e;let o=e.pos,s=null;for(let i=e.depth;;i--){let a=e.node(i);if(t>0?e.indexAfter(i)<a.childCount:e.index(i)>0){s=a.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;o+=t;let l=e.doc.resolve(o);if(de.valid(l))return l}for(;;){let i=t>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!I.isSelectable(s)){e=e.doc.resolve(o+s.nodeSize*t),r=!1;continue e}break}s=i,o+=t;let a=e.doc.resolve(o);if(de.valid(a))return a}return null}}}de.prototype.visible=!1;de.findFrom=de.findGapCursorFrom;W.jsonID("gapcursor",de);class la{constructor(e){this.pos=e}map(e){return new la(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return de.valid(t)?new de(t):W.near(t)}}function gh(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function R1(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||gh(o.type))return!0;if(o.inlineContent)return!1}}return!0}function D1(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||gh(o.type))return!0;if(o.inlineContent)return!1}}return!0}function j1(){return new le({props:{decorations:I1,createSelectionBetween(n,e,t){return e.pos==t.pos&&de.valid(t)?new de(t):null},handleClick:z1,handleKeyDown:L1,handleDOMEvents:{beforeinput:$1}}})}const L1=Pi({ArrowLeft:jr("horiz",-1),ArrowRight:jr("horiz",1),ArrowUp:jr("vert",-1),ArrowDown:jr("vert",1)});function jr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,a=e>0?i.$to:i.$from,l=i.empty;if(i instanceof H){if(!s.endOfTextblock(t)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=de.findGapCursorFrom(a,e,l);return c?(o&&o(r.tr.setSelection(new de(c))),!0):!1}}function z1(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!de.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&I.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new de(r))),!0)}function $1(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof de))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=M.empty;for(let i=r.length-1;i>=0;i--)o=M.from(r[i].createAndFill(null,o));let s=n.state.tr.replace(t.pos,t.pos,new O(o,0,0));return s.setSelection(H.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function I1(n){if(!(n.selection instanceof de))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",se.create(n.doc,[xe.widget(n.selection.head,e,{key:"gapcursor"})])}var Oo=200,ke=function(){};ke.prototype.append=function(n){return n.length?(n=ke.from(n),!this.length&&n||n.length<Oo&&this.leafAppend(n)||this.length<Oo&&n.leafPrepend(this)||this.appendInner(n)):this};ke.prototype.prepend=function(n){return n.length?ke.from(n).append(this):this};ke.prototype.appendInner=function(n){return new P1(this,n)};ke.prototype.slice=function(n,e){return n===void 0&&(n=0),e===void 0&&(e=this.length),n>=e?ke.empty:this.sliceInner(Math.max(0,n),Math.min(this.length,e))};ke.prototype.get=function(n){if(!(n<0||n>=this.length))return this.getInner(n)};ke.prototype.forEach=function(n,e,t){e===void 0&&(e=0),t===void 0&&(t=this.length),e<=t?this.forEachInner(n,e,t,0):this.forEachInvertedInner(n,e,t,0)};ke.prototype.map=function(n,e,t){e===void 0&&(e=0),t===void 0&&(t=this.length);var r=[];return this.forEach(function(o,s){return r.push(n(o,s))},e,t),r};ke.from=function(n){return n instanceof ke?n:n&&n.length?new yh(n):ke.empty};var yh=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,o){return r==0&&o==this.length?this:new e(this.values.slice(r,o))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,o,s,i){for(var a=o;a<s;a++)if(r(this.values[a],i+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,s,i){for(var a=o-1;a>=s;a--)if(r(this.values[a],i+a)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=Oo)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=Oo)return new e(r.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ke);ke.empty=new yh([]);var P1=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(t){return t<this.left.length?this.left.get(t):this.right.get(t-this.left.length)},e.prototype.forEachInner=function(t,r,o,s){var i=this.left.length;if(r<i&&this.left.forEachInner(t,r,Math.min(o,i),s)===!1||o>i&&this.right.forEachInner(t,Math.max(r-i,0),Math.min(this.length,o)-i,s+i)===!1)return!1},e.prototype.forEachInvertedInner=function(t,r,o,s){var i=this.left.length;if(r>i&&this.right.forEachInvertedInner(t,r-i,Math.max(o,i)-i,s+i)===!1||o<i&&this.left.forEachInvertedInner(t,Math.min(r,i),o,s)===!1)return!1},e.prototype.sliceInner=function(t,r){if(t==0&&r==this.length)return this;var o=this.left.length;return r<=o?this.left.slice(t,r):t>=o?this.right.slice(t-o,r-o):this.left.slice(t,o).append(this.right.slice(0,r-o))},e.prototype.leafAppend=function(t){var r=this.right.leafAppend(t);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(t){var r=this.left.leafPrepend(t);if(r)return new e(r,this.right)},e.prototype.appendInner=function(t){return this.left.depth>=Math.max(this.right.depth,t.depth)+1?new e(this.left,new e(this.right,t)):new e(this,t)},e})(ke);const H1=500;class Qe{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,s;t&&(o=this.remapping(r,this.items.length),s=o.maps.length);let i=e.tr,a,l,c=[],d=[];return this.items.forEach((u,h)=>{if(!u.step){o||(o=this.remapping(r,h+1),s=o.maps.length),s--,d.push(u);return}if(o){d.push(new st(u.map));let p=u.step.map(o.slice(s)),f;p&&i.maybeStep(p).doc&&(f=i.mapping.maps[i.mapping.maps.length-1],c.push(new st(f,void 0,void 0,c.length+d.length))),s--,f&&o.appendMap(f,s)}else i.maybeStep(u.step);if(u.selection)return a=o?u.selection.map(o.slice(s)):u.selection,l=new Qe(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:i,selection:a}}addTransform(e,t,r,o){let s=[],i=this.eventCount,a=this.items,l=!o&&a.length?a.get(a.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),h=new st(e.mapping.maps[d],u,t),p;(p=l&&l.merge(h))&&(h=p,d?s.pop():a=a.slice(0,a.length-1)),s.push(h),t&&(i++,t=void 0),o||(l=h)}let c=i-r.depth;return c>V1&&(a=B1(a,c),i-=c),new Qe(a.append(s),i)}remapping(e,t){let r=new rr;return this.items.forEach((o,s)=>{let i=o.mirrorOffset!=null&&s-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new Qe(this.items.append(e.map(t=>new st(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-t),s=e.mapping,i=e.steps.length,a=this.eventCount;this.items.forEach(h=>{h.selection&&a--},o);let l=t;this.items.forEach(h=>{let p=s.getMirror(--l);if(p==null)return;i=Math.min(i,p);let f=s.maps[p];if(h.step){let m=e.steps[p].invert(e.docs[p]),g=h.selection&&h.selection.map(s.slice(l+1,p));g&&a++,r.push(new st(f,m,g))}else r.push(new st(f))},o);let c=[];for(let h=t;h<i;h++)c.push(new st(s.maps[h]));let d=this.items.slice(0,o).append(c).append(r),u=new Qe(d,a);return u.emptyItemCount()>H1&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],s=0;return this.items.forEach((i,a)=>{if(a>=e)o.push(i),i.selection&&s++;else if(i.step){let l=i.step.map(t.slice(r)),c=l&&l.getMap();if(r--,c&&t.appendMap(c,r),l){let d=i.selection&&i.selection.map(t.slice(r));d&&s++;let u=new st(c.invert(),l,d),h,p=o.length-1;(h=o.length&&o[p].merge(u))?o[p]=h:o.push(u)}}else i.map&&r--},this.items.length,0),new Qe(ke.from(o.reverse()),s)}}Qe.empty=new Qe(ke.empty,0);function B1(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}class st{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new st(t.getMap().invert(),t,this.selection)}}}class Et{constructor(e,t,r,o,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=s}}const V1=20;function F1(n,e,t,r){let o=t.getMeta(en),s;if(o)return o.historyState;t.getMeta(U1)&&(n=new Et(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(en))return i.getMeta(en).redo?new Et(n.done.addTransform(t,void 0,r,Fr(e)),n.undone,Zl(t.mapping.maps),n.prevTime,n.prevComposition):new Et(n.done,n.undone.addTransform(t,void 0,r,Fr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let a=t.getMeta("composition"),l=n.prevTime==0||!i&&n.prevComposition!=a&&(n.prevTime<(t.time||0)-r.newGroupDelay||!W1(t,n.prevRanges)),c=i?Ts(n.prevRanges,t.mapping):Zl(t.mapping.maps);return new Et(n.done.addTransform(t,l?e.selection.getBookmark():void 0,r,Fr(e)),Qe.empty,c,t.time,a??n.prevComposition)}else return(s=t.getMeta("rebased"))?new Et(n.done.rebased(t,s),n.undone.rebased(t,s),Ts(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Et(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Ts(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function W1(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&o>=e[s]&&(t=!0)}),t}function Zl(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,s,i)=>e.push(s,i));return e}function Ts(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),s=e.map(n[r+1],-1);o<=s&&t.push(o,s)}return t}function _1(n,e,t){let r=Fr(e),o=en.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let i=s.selection.resolve(s.transform.doc),a=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),o,r),l=new Et(t?a:s.remaining,t?s.remaining:a,null,0,-1);return s.transform.setSelection(i).setMeta(en,{redo:t,historyState:l})}let Ns=!1,ec=null;function Fr(n){let e=n.plugins;if(ec!=e){Ns=!1,ec=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ns=!0;break}}return Ns}const en=new he("history"),U1=new he("closeHistory");function q1(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new le({key:en,state:{init(){return new Et(Qe.empty,Qe.empty,null,0,-1)},apply(e,t,r){return F1(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?xh:r=="historyRedo"?wh:null;return!o||!e.editable?!1:(t.preventDefault(),o(e.state,e.dispatch))}}}})}function bh(n,e){return(t,r)=>{let o=en.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let s=_1(o,t,n);s&&r(s.scrollIntoView())}return!0}}const xh=bh(!1),wh=bh(!0);te.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const t=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(t)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new le({key:new he("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const o=this.options.limit;if(o==null||o===0){n=!0;return}const s=this.storage.characters({node:r.doc});if(s>o){const i=s-o,a=0,l=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(a,l);return n=!0,c}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const o=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=r||o>r&&s>r&&s<=o)return!0;if(o>r&&s>r&&s>o||!e.getMeta("paste"))return!1;const i=e.selection.$head.pos,a=s-r,l=i-a,c=i;return e.deleteRange(l,c),!(this.storage.characters({node:e.doc})>r)}})]}});var K1=te.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[A1(this.options)]}});te.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new le({key:new he("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:o}=e,s=[];if(!t||!r)return se.create(n,[]);let i=0;this.options.mode==="deepest"&&n.descendants((l,c)=>{if(!l.isText){if(!(o>=c&&o<=c+l.nodeSize-1))return!1;i+=1}});let a=0;return n.descendants((l,c)=>{if(l.isText||!(o>=c&&o<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&i-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";s.push(xe.node(c,c+l.nodeSize,{class:this.options.className}))}),se.create(n,s)}}})]}});var J1=te.create({name:"gapCursor",addProseMirrorPlugins(){return[j1()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=Q(P(n,"allowGapCursor",t)))!=null?e:null}}});te.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new le({key:new he("placeholder"),props:{decorations:({doc:n,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!t)return null;const s=this.editor.isEmpty;return n.descendants((i,a)=>{const l=r>=a&&r<=a+i.nodeSize,c=!i.isLeaf&&qo(i);if((l||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];s&&d.push(this.options.emptyEditorClass);const u=xe.node(a,a+i.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:a,hasAnchor:l}):this.options.placeholder});o.push(u)}return this.options.includeChildren}),se.create(n,o)}}})]}});te.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new le({key:new he("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||yu(t.selection)||n.view.dragging?null:se.create(t.doc,[xe.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function tc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var G1=te.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new he(this.name),t=((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||this.options.node||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(t).includes(o.name));return[new le({key:e,appendTransaction:(o,s,i)=>{const{doc:a,tr:l,schema:c}=i,d=e.getState(i),u=a.content.size,h=c.nodes[t];if(d)return l.insert(u,h.create())},state:{init:(o,s)=>{const i=s.tr.doc.lastChild;return!tc({node:i,types:r})},apply:(o,s)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return s;const i=o.doc.lastChild;return!tc({node:i,types:r})}}})]}}),X1=te.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>xh(n,e),redo:()=>({state:n,dispatch:e})=>wh(n,e)}},addProseMirrorPlugins(){return[q1(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()}}}),Y1=te.create({name:"starterKit",addExtensions(){var n,e,t,r;const o=[];return this.options.bold!==!1&&o.push(M0.configure(this.options.bold)),this.options.blockquote!==!1&&o.push(w0.configure(this.options.blockquote)),this.options.bulletList!==!1&&o.push(ih.configure(this.options.bulletList)),this.options.code!==!1&&o.push(N0.configure(this.options.code)),this.options.codeBlock!==!1&&o.push(R0.configure(this.options.codeBlock)),this.options.document!==!1&&o.push(D0.configure(this.options.document)),this.options.dropcursor!==!1&&o.push(K1.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&o.push(J1.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&o.push(j0.configure(this.options.hardBreak)),this.options.heading!==!1&&o.push(L0.configure(this.options.heading)),this.options.undoRedo!==!1&&o.push(X1.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&o.push(z0.configure(this.options.horizontalRule)),this.options.italic!==!1&&o.push(B0.configure(this.options.italic)),this.options.listItem!==!1&&o.push(ah.configure(this.options.listItem)),this.options.listKeymap!==!1&&o.push(ph.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&o.push(u1.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&o.push(mh.configure(this.options.orderedList)),this.options.paragraph!==!1&&o.push(C1.configure(this.options.paragraph)),this.options.strike!==!1&&o.push(T1.configure(this.options.strike)),this.options.text!==!1&&o.push(N1.configure(this.options.text)),this.options.underline!==!1&&o.push(Xu.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&o.push(G1.configure((r=this.options)==null?void 0:r.trailingNode)),o}}),Q1=Y1,Z1=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,ex=ve.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},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},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",re(this.options.HTMLAttributes,n)]},parseMarkdown:(n,e)=>e.createNode("image",{src:n.href,title:n.title,alt:n.text}),renderMarkdown:n=>{var e,t,r,o,s,i;const a=(t=(e=n.attrs)==null?void 0:e.src)!=null?t:"",l=(o=(r=n.attrs)==null?void 0:r.alt)!=null?o:"",c=(i=(s=n.attrs)==null?void 0:s.title)!=null?i:"";return c?`![${l}](${a} "${c}")`:`![${l}](${a})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:n,minWidth:e,minHeight:t,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:o,getPos:s,HTMLAttributes:i})=>{const a=document.createElement("img");Object.entries(i).forEach(([d,u])=>{if(u!=null)switch(d){case"width":case"height":break;default:a.setAttribute(d,u);break}}),a.src=i.src;const l=new By({element:a,node:o,getPos:s,onResize:(d,u)=>{a.style.width=`${d}px`,a.style.height=`${u}px`},onCommit:(d,u)=>{const h=s();h!==void 0&&this.editor.chain().setNodeSelection(h).updateAttributes(this.name,{width:d,height:u}).run()},onUpdate:(d,u,h)=>d.type===o.type,options:{directions:n,min:{width:e,height:t},preserveAspectRatio:r===!0}}),c=l.dom;return c.style.visibility="hidden",c.style.pointerEvents="none",a.onload=()=>{c.style.visibility="",c.style.pointerEvents=""},l}},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[Du({find:Z1,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}}),tx=ex,As={exports:{}},Os={},nc;function nx(){if(nc)return Os;nc=1;var n=z;function e(u,h){return u===h&&(u!==0||1/u===1/h)||u!==u&&h!==h}var t=typeof Object.is=="function"?Object.is:e,r=n.useState,o=n.useEffect,s=n.useLayoutEffect,i=n.useDebugValue;function a(u,h){var p=h(),f=r({inst:{value:p,getSnapshot:h}}),m=f[0].inst,g=f[1];return s(function(){m.value=p,m.getSnapshot=h,l(m)&&g({inst:m})},[u,p,h]),o(function(){return l(m)&&g({inst:m}),u(function(){l(m)&&g({inst:m})})},[u]),i(p),p}function l(u){var h=u.getSnapshot;u=u.value;try{var p=h();return!t(u,p)}catch{return!0}}function c(u,h){return h()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return Os.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:d,Os}var rc={},oc;function rx(){return oc||(oc=1,process.env.NODE_ENV!=="production"&&(function(){function n(p,f){return p===f&&(p!==0||1/p===1/f)||p!==p&&f!==f}function e(p,f){d||o.startTransition===void 0||(d=!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=f();if(!u){var g=f();s(m,g)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}g=i({inst:{value:m,getSnapshot:f}});var y=g[0].inst,w=g[1];return l(function(){y.value=m,y.getSnapshot=f,t(y)&&w({inst:y})},[p,m,f]),a(function(){return t(y)&&w({inst:y}),p(function(){t(y)&&w({inst:y})})},[p]),c(m),m}function t(p){var f=p.getSnapshot;p=p.value;try{var m=f();return!s(p,m)}catch{return!0}}function r(p,f){return f()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=z,s=typeof Object.is=="function"?Object.is:n,i=o.useState,a=o.useEffect,l=o.useLayoutEffect,c=o.useDebugValue,d=!1,u=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:e;rc.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())})()),rc}var sc;function ca(){return sc||(sc=1,process.env.NODE_ENV==="production"?As.exports=nx():As.exports=rx()),As.exports}var kh=ca(),ic,ac;function ox(){return ac||(ac=1,ic=function n(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var r,o,s;if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(o=r;o--!==0;)if(!n(e[o],t[o]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(o of e.entries())if(!t.has(o[0]))return!1;for(o of e.entries())if(!n(o[1],t.get(o[0])))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(o of e.entries())if(!t.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(r=e.length,r!=t.length)return!1;for(o=r;o--!==0;)if(e[o]!==t[o])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(s=Object.keys(e),r=s.length,r!==Object.keys(t).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(t,s[o]))return!1;for(o=r;o--!==0;){var i=s[o];if(!(i==="_owner"&&e.$$typeof)&&!n(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}),ic}var sx=ox();const ix=Jh(sx);var Rs={exports:{}},Ds={},lc;function ax(){if(lc)return Ds;lc=1;var n=z,e=ca();function t(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:t,o=e.useSyncExternalStore,s=n.useRef,i=n.useEffect,a=n.useMemo,l=n.useDebugValue;return Ds.useSyncExternalStoreWithSelector=function(c,d,u,h,p){var f=s(null);if(f.current===null){var m={hasValue:!1,value:null};f.current=m}else m=f.current;f=a(function(){function y(T){if(!w){if(w=!0,x=T,T=h(T),p!==void 0&&m.hasValue){var v=m.value;if(p(v,T))return E=v}return E=T}if(v=E,r(x,T))return v;var S=h(T);return p!==void 0&&p(v,S)?(x=T,v):(x=T,E=S)}var w=!1,x,E,b=u===void 0?null:u;return[function(){return y(d())},b===null?void 0:function(){return y(b())}]},[d,u,h,p]);var g=o(c,f[0],f[1]);return i(function(){m.hasValue=!0,m.value=g},[g]),l(g),g},Ds}var cc={},dc;function lx(){return dc||(dc=1,process.env.NODE_ENV!=="production"&&(function(){function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=z,t=ca(),r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,i=e.useEffect,a=e.useMemo,l=e.useDebugValue;cc.useSyncExternalStoreWithSelector=function(c,d,u,h,p){var f=s(null);if(f.current===null){var m={hasValue:!1,value:null};f.current=m}else m=f.current;f=a(function(){function y(T){if(!w){if(w=!0,x=T,T=h(T),p!==void 0&&m.hasValue){var v=m.value;if(p(v,T))return E=v}return E=T}if(v=E,r(x,T))return v;var S=h(T);return p!==void 0&&p(v,S)?(x=T,v):(x=T,E=S)}var w=!1,x,E,b=u===void 0?null:u;return[function(){return y(d())},b===null?void 0:function(){return y(b())}]},[d,u,h,p]);var g=o(c,f[0],f[1]);return i(function(){m.hasValue=!0,m.value=g},[g]),l(g),g},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),cc}var uc;function cx(){return uc||(uc=1,process.env.NODE_ENV==="production"?Rs.exports=ax():Rs.exports=lx()),Rs.exports}var dx=cx(),ux=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},hx=({contentComponent:n})=>{const e=kh.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return N.jsx(N.Fragment,{children:Object.values(e)})};function px(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:Ec.createPortal(r.reactElement,r.element,t)},n.forEach(o=>o())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(o=>o())}}}var fx=class extends z.Component{constructor(n){var e;super(n),this.editorContentRef=z.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=n.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const n=this.props.editor;if(n&&!n.isDestroyed&&n.options.element){if(n.contentComponent)return;const e=this.editorContentRef.current;e.append(n.view.dom),n.setOptions({element:e}),n.contentComponent=px(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=n.contentComponent.subscribe(()=>{this.setState(t=>t.hasContentComponentInitialized?t:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),n.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var n;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((n=e.view.dom)!=null&&n.firstChild))return;const t=document.createElement("div");t.append(e.view.dom),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return N.jsxs(N.Fragment,{children:[N.jsx("div",{ref:ux(e,this.editorContentRef),...t}),n?.contentComponent&&N.jsx(hx,{contentComponent:n.contentComponent})]})}},mx=z.forwardRef((n,e)=>{const t=z.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return z.createElement(fx,{key:t,innerRef:e,...n})}),gx=z.memo(mx),yx=typeof window<"u"?z.useLayoutEffect:z.useEffect,bx=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function vh(n){var e;const[t]=z.useState(()=>new bx(n.editor)),r=dx.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:ix);return yx(()=>t.watch(n.editor),[n.editor,t]),z.useDebugValue(r),r}var hc=process.env.NODE_ENV!=="production",yi=typeof window>"u",xx=yi||!!(typeof window<"u"&&window.next),wx=class Sh{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(t=>t())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0){if(yi||xx){if(hc)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&&yi&&hc)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:(...t)=>{var r,o;return(o=(r=this.options.current).onBeforeCreate)==null?void 0:o.call(r,...t)},onBlur:(...t)=>{var r,o;return(o=(r=this.options.current).onBlur)==null?void 0:o.call(r,...t)},onCreate:(...t)=>{var r,o;return(o=(r=this.options.current).onCreate)==null?void 0:o.call(r,...t)},onDestroy:(...t)=>{var r,o;return(o=(r=this.options.current).onDestroy)==null?void 0:o.call(r,...t)},onFocus:(...t)=>{var r,o;return(o=(r=this.options.current).onFocus)==null?void 0:o.call(r,...t)},onSelectionUpdate:(...t)=>{var r,o;return(o=(r=this.options.current).onSelectionUpdate)==null?void 0:o.call(r,...t)},onTransaction:(...t)=>{var r,o;return(o=(r=this.options.current).onTransaction)==null?void 0:o.call(r,...t)},onUpdate:(...t)=>{var r,o;return(o=(r=this.options.current).onUpdate)==null?void 0:o.call(r,...t)},onContentError:(...t)=>{var r,o;return(o=(r=this.options.current).onContentError)==null?void 0:o.call(r,...t)},onDrop:(...t)=>{var r,o;return(o=(r=this.options.current).onDrop)==null?void 0:o.call(r,...t)},onPaste:(...t)=>{var r,o;return(o=(r=this.options.current).onPaste)==null?void 0:o.call(r,...t)},onDelete:(...t)=>{var r,o;return(o=(r=this.options.current).onDelete)==null?void 0:o.call(r,...t)}};return new Py(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((o,s)=>{var i;return o===((i=t.extensions)==null?void 0:i[s])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Sh.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((t,r)=>t===e[r]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function kx(n={},e=[]){const t=z.useRef(n);t.current=n;const[r]=z.useState(()=>new wx(t)),o=kh.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return z.useDebugValue(o),z.useEffect(r.onRender(e)),vh({editor:o,selector:({transactionNumber:s})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&s===0?0:s+1}),o}var vx=z.createContext({editor:null});vx.Consumer;var Ch=z.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Sx=()=>z.useContext(Ch),js=z.forwardRef((n,e)=>{const{onDragStart:t}=Sx(),r=n.as||"div";return N.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function pc(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function fc(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.forward_ref)"||n.$$typeof.description==="react.forward_ref"))}function Cx(n){return!!(typeof n=="object"&&n.$$typeof&&(n.$$typeof.toString()==="Symbol(react.memo)"||n.$$typeof.description==="react.memo"))}function Mx(n){if(pc(n)||fc(n))return!0;if(Cx(n)){const e=n.type;if(e)return pc(e)||fc(e)}return!1}function Ex(){try{if(z.version)return parseInt(z.version.split(".")[0],10)>=19}catch{}return!1}var Tx=class{constructor(n,{editor:e,props:t={},as:r="div",className:o=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=n,this.editor=e,this.props=t,this.element=document.createElement(r),this.element.classList.add("react-renderer"),o&&this.element.classList.add(...o.split(" ")),this.editor.isInitialized?Ec.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var n;const e=this.component,t=this.props,r=this.editor,o=Ex(),s=Mx(e),i={...t};i.ref&&!(o||s)&&delete i.ref,!i.ref&&(o||s)&&(i.ref=a=>{this.ref=a}),this.reactElement=N.jsx(e,{...i}),(n=r?.contentComponent)==null||n.setRenderer(this.id,this)}updateProps(n={}){this.props={...this.props,...n},this.render()}destroy(){var n;(n=this.editor?.contentComponent)==null||n.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(n){Object.keys(n).forEach(e=>{this.element.setAttribute(e,n[e])})}};z.createContext({markViewContentRef:()=>{}});var Nx=class extends Gy{constructor(n,e,t){if(super(n,e,t),!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}mount(){const n={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(i={})=>this.updateAttributes(i),deleteNode:()=>this.deleteNode(),ref:z.createRef()};if(!this.component.displayName){const i=a=>a.charAt(0).toUpperCase()+a.substring(1);this.component.displayName=i(this.extension.name)}const e={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:i=>{i&&this.contentDOMElement&&i.firstChild!==this.contentDOMElement&&(i.hasAttribute("data-node-view-wrapper")&&i.removeAttribute("data-node-view-wrapper"),i.appendChild(this.contentDOMElement))}},t=this.component,r=z.memo(i=>N.jsx(Ch.Provider,{value:e,children:z.createElement(t,i)}));r.displayName="ReactNodeView";let o=this.node.isInline?"span":"div";this.options.as&&(o=this.options.as);const{className:s=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Tx(r,{editor:this.editor,props:n,as:o,className:`node-${this.node.type.name} ${s}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var n;if(this.renderer.element.firstElementChild&&!((n=this.renderer.element.firstElementChild)!=null&&n.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:n,to:e}=this.editor.state.selection,t=this.getPos();if(typeof t=="number")if(n<=t&&e>=t+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(n,e,t){const r=o=>{this.renderer.updateProps(o),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(n.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const o=this.node,s=this.decorations,i=this.innerDecorations;return this.node=n,this.decorations=e,this.innerDecorations=t,this.options.update({oldNode:o,oldDecorations:s,newNode:n,newDecorations:e,oldInnerDecorations:i,innerDecorations:t,updateProps:()=>r({node:n,decorations:e,innerDecorations:t})})}return n===this.node&&this.decorations===e&&this.innerDecorations===t||(this.node=n,this.decorations=e,this.innerDecorations=t,r({node:n,decorations:e,innerDecorations:t})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let n={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,t=cr(this.node,e);n=this.options.attrs({node:this.node,HTMLAttributes:t})}else n=this.options.attrs;this.renderer.updateAttributes(n)}}};function Ax(n,e){return t=>t.editor.contentComponent?new Nx(n,t,e):{}}function Ox(n){const e=jo.c(23),{node:t,updateAttributes:r}=n,o=z.useRef(null),s=z.useRef(null),[i,a]=z.useState(!1),[l,c]=z.useState(!1),[d,u]=z.useState(!1),h=t.attrs.src;if(!h){let $;return e[0]===Symbol.for("react.memo_cache_sentinel")?($=N.jsx(js,{as:"div",className:"resizable-image-error",children:"이미지 소스가 없습니다."}),e[0]=$):$=e[0],$}if(d){let $;e[1]!==h?($=h?.substring(0,50),e[1]=h,e[2]=$):$=e[2];let Y;return e[3]!==$?(Y=N.jsxs(js,{as:"div",className:"resizable-image-error",children:["이미지를 불러올 수 없습니다: ",$,"..."]}),e[3]=$,e[4]=Y):Y=e[4],Y}let p;e[5]!==r?(p=($,Y)=>{if($.button!==0)return;$.preventDefault(),a(!0);const pe=$.clientX,Z=$.clientY,U=o.current?.offsetWidth||0,X=o.current?.offsetHeight||0,ee=X/U,L=Ce=>{const C=Ce.clientX-pe,B=Ce.clientY-Z;let V=U;e:switch(Y){case"se":case"e":{V=Math.max(100,U+C);break e}case"sw":case"w":{V=Math.max(100,U-C);break e}case"ne":case"n":{V=Math.max(100,U+C);break e}case"nw":{V=Math.max(100,U-C);break e}case"s":V=Math.max(100*ee,X+B)/ee}o.current&&(o.current.style.width=`${V}px`,o.current.style.height=`${V*ee}px`)},Se=()=>{a(!1),o.current&&r({width:o.current.offsetWidth,height:o.current.offsetHeight}),document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",Se)};document.addEventListener("mousemove",L),document.addEventListener("mouseup",Se)},e[5]=r,e[6]=p):p=e[6];const f=p;let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{c(!0)},e[7]=m):m=e[7];const g=m;let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=$=>{s.current&&!s.current.contains($.target)&&c(!1)},e[8]=y):y=e[8];const w=y;let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=()=>u(!0),e[9]=x):x=e[9];const E=`resizable-image ${i?"resizing":""} ${l?"selected":""}`,b=t.attrs.width?`${t.attrs.width}px`:"auto",T=t.attrs.height?`${t.attrs.height}px`:"auto";let v;e[10]!==b||e[11]!==T?(v={width:b,height:T},e[10]=b,e[11]=T,e[12]=v):v=e[12];let S;e[13]!==h||e[14]!==E||e[15]!==v?(S=N.jsx("img",{ref:o,src:h,alt:"inserted image",onClick:g,onError:x,className:E,style:v,draggable:"false"}),e[13]=h,e[14]=E,e[15]=v,e[16]=S):S=e[16];let R;e[17]!==f||e[18]!==l?(R=l&&N.jsxs(N.Fragment,{children:[N.jsx("div",{className:"resizable-image-border"}),N.jsx("div",{onMouseDown:$=>f($,"nw"),className:"resize-handle tl"}),N.jsx("div",{onMouseDown:$=>f($,"n"),className:"resize-handle t"}),N.jsx("div",{onMouseDown:$=>f($,"ne"),className:"resize-handle tr"}),N.jsx("div",{onMouseDown:$=>f($,"w"),className:"resize-handle l"}),N.jsx("div",{onMouseDown:$=>f($,"e"),className:"resize-handle r"}),N.jsx("div",{onMouseDown:$=>f($,"sw"),className:"resize-handle bl"}),N.jsx("div",{onMouseDown:$=>f($,"s"),className:"resize-handle b"}),N.jsx("div",{onMouseDown:$=>f($,"se"),className:"resize-handle br"})]}),e[17]=f,e[18]=l,e[19]=R):R=e[19];let K;return e[20]!==R||e[21]!==S?(K=N.jsx(js,{as:"div",onClick:w,className:"resizable-image-wrapper",draggable:"true","data-drag-handle":!0,children:N.jsxs("div",{ref:s,className:"resizable-image-container",onClick:Rx,children:[S,R]})}),e[20]=R,e[21]=S,e[22]=K):K=e[22],K}function Rx(n){return n.stopPropagation()}const Dx=tx.extend({addAttributes(){return{src:{default:null,parseHTML:n=>{const e=n.getAttribute("src");return console.log("Parsing image src:",e),e},renderHTML:n=>({src:n.src})},alt:{default:null,parseHTML:n=>n.getAttribute("alt"),renderHTML:n=>({alt:n.alt||"image"})},title:{default:null,parseHTML:n=>n.getAttribute("title"),renderHTML:n=>({title:n.title})},width:{default:null,parseHTML:n=>{const e=n.getAttribute("width");return e?parseInt(e,10):null},renderHTML:n=>({width:n.width})},height:{default:null,parseHTML:n=>{const e=n.getAttribute("height");return e?parseInt(e,10):null},renderHTML:n=>({height:n.height})}}},addNodeView(){return Ax(Ox)},draggable:!0,addStorage(){return{clipboardTextSerializer:n=>n.attrs.src||""}},renderHTML({HTMLAttributes:n}){return["img",{...n,class:"resizable-image"}]}}),Mh=[Q1.configure({paragraph:{HTMLAttributes:{class:"tiptap-paragraph"}},heading:{levels:[1,2,3]},bulletList:{HTMLAttributes:{class:"tiptap-bullet-list"}},orderedList:{HTMLAttributes:{class:"tiptap-ordered-list"}},codeBlock:{HTMLAttributes:{class:"tiptap-code-block"}},code:{HTMLAttributes:{class:"tiptap-inline-code"}},blockquote:{HTMLAttributes:{class:"tiptap-blockquote"}}}),b0,zu,nb,ib.configure({multicolor:!0}),y0.configure({types:["heading","paragraph"]}),Dx,Gu.configure({resizable:!0}),m0,f0,p0];function Eh(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var o=n.length;for(e=0;e<o;e++)n[e]&&(t=Eh(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function jx(){for(var n,e,t=0,r="",o=arguments.length;t<o;t++)(n=arguments[t])&&(e=Eh(n))&&(r&&(r+=" "),r+=e);return r}const Lx=(n,e)=>{const t=new Array(n.length+e.length);for(let r=0;r<n.length;r++)t[r]=n[r];for(let r=0;r<e.length;r++)t[n.length+r]=e[r];return t},zx=(n,e)=>({classGroupId:n,validator:e}),Th=(n=new Map,e=null,t)=>({nextPart:n,validators:e,classGroupId:t}),Ro="-",mc=[],$x="arbitrary..",Ix=n=>{const e=Hx(n),{conflictingClassGroups:t,conflictingClassGroupModifiers:r}=n;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return Px(o);const s=o.split(Ro),i=s[0]===""&&s.length>1?1:0;return Nh(s,i,e)},getConflictingClassGroupIds:(o,s)=>{if(s){const i=r[o],a=t[o];return i?a?Lx(a,i):i:a||mc}return t[o]||mc}}},Nh=(n,e,t)=>{if(n.length-e===0)return t.classGroupId;const r=n[e],o=t.nextPart.get(r);if(o){const l=Nh(n,e+1,o);if(l)return l}const s=t.validators;if(s===null)return;const i=e===0?n.join(Ro):n.slice(e).join(Ro),a=s.length;for(let l=0;l<a;l++){const c=s[l];if(c.validator(i))return c.classGroupId}},Px=n=>n.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=n.slice(1,-1),t=e.indexOf(":"),r=e.slice(0,t);return r?$x+r:void 0})(),Hx=n=>{const{theme:e,classGroups:t}=n;return Bx(t,e)},Bx=(n,e)=>{const t=Th();for(const r in n){const o=n[r];da(o,t,r,e)}return t},da=(n,e,t,r)=>{const o=n.length;for(let s=0;s<o;s++){const i=n[s];Vx(i,e,t,r)}},Vx=(n,e,t,r)=>{if(typeof n=="string"){Fx(n,e,t);return}if(typeof n=="function"){Wx(n,e,t,r);return}_x(n,e,t,r)},Fx=(n,e,t)=>{const r=n===""?e:Ah(e,n);r.classGroupId=t},Wx=(n,e,t,r)=>{if(Ux(n)){da(n(r),e,t,r);return}e.validators===null&&(e.validators=[]),e.validators.push(zx(t,n))},_x=(n,e,t,r)=>{const o=Object.entries(n),s=o.length;for(let i=0;i<s;i++){const[a,l]=o[i];da(l,Ah(e,a),t,r)}},Ah=(n,e)=>{let t=n;const r=e.split(Ro),o=r.length;for(let s=0;s<o;s++){const i=r[s];let a=t.nextPart.get(i);a||(a=Th(),t.nextPart.set(i,a)),t=a}return t},Ux=n=>"isThemeGetter"in n&&n.isThemeGetter===!0,qx=n=>{if(n<1)return{get:()=>{},set:()=>{}};let e=0,t=Object.create(null),r=Object.create(null);const o=(s,i)=>{t[s]=i,e++,e>n&&(e=0,r=t,t=Object.create(null))};return{get(s){let i=t[s];if(i!==void 0)return i;if((i=r[s])!==void 0)return o(s,i),i},set(s,i){s in t?t[s]=i:o(s,i)}}},bi="!",gc=":",Kx=[],yc=(n,e,t,r,o)=>({modifiers:n,hasImportantModifier:e,baseClassName:t,maybePostfixModifierPosition:r,isExternal:o}),Jx=n=>{const{prefix:e,experimentalParseClassName:t}=n;let r=o=>{const s=[];let i=0,a=0,l=0,c;const d=o.length;for(let m=0;m<d;m++){const g=o[m];if(i===0&&a===0){if(g===gc){s.push(o.slice(l,m)),l=m+1;continue}if(g==="/"){c=m;continue}}g==="["?i++:g==="]"?i--:g==="("?a++:g===")"&&a--}const u=s.length===0?o:o.slice(l);let h=u,p=!1;u.endsWith(bi)?(h=u.slice(0,-1),p=!0):u.startsWith(bi)&&(h=u.slice(1),p=!0);const f=c&&c>l?c-l:void 0;return yc(s,p,h,f)};if(e){const o=e+gc,s=r;r=i=>i.startsWith(o)?s(i.slice(o.length)):yc(Kx,!1,i,void 0,!0)}if(t){const o=r;r=s=>t({className:s,parseClassName:o})}return r},Gx=n=>{const e=new Map;return n.orderSensitiveModifiers.forEach((t,r)=>{e.set(t,1e6+r)}),t=>{const r=[];let o=[];for(let s=0;s<t.length;s++){const i=t[s],a=i[0]==="[",l=e.has(i);a||l?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(i)):o.push(i)}return o.length>0&&(o.sort(),r.push(...o)),r}},Xx=n=>({cache:qx(n.cacheSize),parseClassName:Jx(n),sortModifiers:Gx(n),...Ix(n)}),Yx=/\s+/,Qx=(n,e)=>{const{parseClassName:t,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s}=e,i=[],a=n.trim().split(Yx);let l="";for(let c=a.length-1;c>=0;c-=1){const d=a[c],{isExternal:u,modifiers:h,hasImportantModifier:p,baseClassName:f,maybePostfixModifierPosition:m}=t(d);if(u){l=d+(l.length>0?" "+l:l);continue}let g=!!m,y=r(g?f.substring(0,m):f);if(!y){if(!g){l=d+(l.length>0?" "+l:l);continue}if(y=r(f),!y){l=d+(l.length>0?" "+l:l);continue}g=!1}const w=h.length===0?"":h.length===1?h[0]:s(h).join(":"),x=p?w+bi:w,E=x+y;if(i.indexOf(E)>-1)continue;i.push(E);const b=o(y,g);for(let T=0;T<b.length;++T){const v=b[T];i.push(x+v)}l=d+(l.length>0?" "+l:l)}return l},Zx=(...n)=>{let e=0,t,r,o="";for(;e<n.length;)(t=n[e++])&&(r=Oh(t))&&(o&&(o+=" "),o+=r);return o},Oh=n=>{if(typeof n=="string")return n;let e,t="";for(let r=0;r<n.length;r++)n[r]&&(e=Oh(n[r]))&&(t&&(t+=" "),t+=e);return t},ew=(n,...e)=>{let t,r,o,s;const i=l=>{const c=e.reduce((d,u)=>u(d),n());return t=Xx(c),r=t.cache.get,o=t.cache.set,s=a,a(l)},a=l=>{const c=r(l);if(c)return c;const d=Qx(l,t);return o(l,d),d};return s=i,(...l)=>s(Zx(...l))},tw=[],ye=n=>{const e=t=>t[n]||tw;return e.isThemeGetter=!0,e},Rh=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Dh=/^\((?:(\w[\w-]*):)?(.+)\)$/i,nw=/^\d+\/\d+$/,rw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ow=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,sw=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,iw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,aw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,bn=n=>nw.test(n),G=n=>!!n&&!Number.isNaN(Number(n)),vt=n=>!!n&&Number.isInteger(Number(n)),Ls=n=>n.endsWith("%")&&G(n.slice(0,-1)),ht=n=>rw.test(n),lw=()=>!0,cw=n=>ow.test(n)&&!sw.test(n),jh=()=>!1,dw=n=>iw.test(n),uw=n=>aw.test(n),hw=n=>!D(n)&&!j(n),pw=n=>zn(n,$h,jh),D=n=>Rh.test(n),_t=n=>zn(n,Ih,cw),zs=n=>zn(n,bw,G),bc=n=>zn(n,Lh,jh),fw=n=>zn(n,zh,uw),Lr=n=>zn(n,Ph,dw),j=n=>Dh.test(n),Bn=n=>$n(n,Ih),mw=n=>$n(n,xw),xc=n=>$n(n,Lh),gw=n=>$n(n,$h),yw=n=>$n(n,zh),zr=n=>$n(n,Ph,!0),zn=(n,e,t)=>{const r=Rh.exec(n);return r?r[1]?e(r[1]):t(r[2]):!1},$n=(n,e,t=!1)=>{const r=Dh.exec(n);return r?r[1]?e(r[1]):t:!1},Lh=n=>n==="position"||n==="percentage",zh=n=>n==="image"||n==="url",$h=n=>n==="length"||n==="size"||n==="bg-size",Ih=n=>n==="length",bw=n=>n==="number",xw=n=>n==="family-name",Ph=n=>n==="shadow",ww=()=>{const n=ye("color"),e=ye("font"),t=ye("text"),r=ye("font-weight"),o=ye("tracking"),s=ye("leading"),i=ye("breakpoint"),a=ye("container"),l=ye("spacing"),c=ye("radius"),d=ye("shadow"),u=ye("inset-shadow"),h=ye("text-shadow"),p=ye("drop-shadow"),f=ye("blur"),m=ye("perspective"),g=ye("aspect"),y=ye("ease"),w=ye("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],E=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],b=()=>[...E(),j,D],T=()=>["auto","hidden","clip","visible","scroll"],v=()=>["auto","contain","none"],S=()=>[j,D,l],R=()=>[bn,"full","auto",...S()],K=()=>[vt,"none","subgrid",j,D],$=()=>["auto",{span:["full",vt,j,D]},vt,j,D],Y=()=>[vt,"auto",j,D],pe=()=>["auto","min","max","fr",j,D],Z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],U=()=>["start","end","center","stretch","center-safe","end-safe"],X=()=>["auto",...S()],ee=()=>[bn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...S()],L=()=>[n,j,D],Se=()=>[...E(),xc,bc,{position:[j,D]}],Ce=()=>["no-repeat",{repeat:["","x","y","space","round"]}],C=()=>["auto","cover","contain",gw,pw,{size:[j,D]}],B=()=>[Ls,Bn,_t],V=()=>["","none","full",c,j,D],_=()=>["",G,Bn,_t],J=()=>["solid","dashed","dotted","double"],oe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],F=()=>[G,Ls,xc,bc],Ne=()=>["","none",f,j,D],je=()=>["none",G,j,D],Be=()=>["none",G,j,D],tt=()=>[G,j,D],Ye=()=>[bn,"full",...S()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ht],breakpoint:[ht],color:[lw],container:[ht],"drop-shadow":[ht],ease:["in","out","in-out"],font:[hw],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ht],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ht],shadow:[ht],spacing:["px",G],text:[ht],"text-shadow":[ht],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",bn,D,j,g]}],container:["container"],columns:[{columns:[G,D,j,a]}],"break-after":[{"break-after":x()}],"break-before":[{"break-before":x()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:b()}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:v()}],"overscroll-x":[{"overscroll-x":v()}],"overscroll-y":[{"overscroll-y":v()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{start:R()}],end:[{end:R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[vt,"auto",j,D]}],basis:[{basis:[bn,"full","auto",a,...S()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[G,bn,"auto","initial","none",D]}],grow:[{grow:["",G,j,D]}],shrink:[{shrink:["",G,j,D]}],order:[{order:[vt,"first","last","none",j,D]}],"grid-cols":[{"grid-cols":K()}],"col-start-end":[{col:$()}],"col-start":[{"col-start":Y()}],"col-end":[{"col-end":Y()}],"grid-rows":[{"grid-rows":K()}],"row-start-end":[{row:$()}],"row-start":[{"row-start":Y()}],"row-end":[{"row-end":Y()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":pe()}],"auto-rows":[{"auto-rows":pe()}],gap:[{gap:S()}],"gap-x":[{"gap-x":S()}],"gap-y":[{"gap-y":S()}],"justify-content":[{justify:[...Z(),"normal"]}],"justify-items":[{"justify-items":[...U(),"normal"]}],"justify-self":[{"justify-self":["auto",...U()]}],"align-content":[{content:["normal",...Z()]}],"align-items":[{items:[...U(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...U(),{baseline:["","last"]}]}],"place-content":[{"place-content":Z()}],"place-items":[{"place-items":[...U(),"baseline"]}],"place-self":[{"place-self":["auto",...U()]}],p:[{p:S()}],px:[{px:S()}],py:[{py:S()}],ps:[{ps:S()}],pe:[{pe:S()}],pt:[{pt:S()}],pr:[{pr:S()}],pb:[{pb:S()}],pl:[{pl:S()}],m:[{m:X()}],mx:[{mx:X()}],my:[{my:X()}],ms:[{ms:X()}],me:[{me:X()}],mt:[{mt:X()}],mr:[{mr:X()}],mb:[{mb:X()}],ml:[{ml:X()}],"space-x":[{"space-x":S()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":S()}],"space-y-reverse":["space-y-reverse"],size:[{size:ee()}],w:[{w:[a,"screen",...ee()]}],"min-w":[{"min-w":[a,"screen","none",...ee()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...ee()]}],h:[{h:["screen","lh",...ee()]}],"min-h":[{"min-h":["screen","lh","none",...ee()]}],"max-h":[{"max-h":["screen","lh",...ee()]}],"font-size":[{text:["base",t,Bn,_t]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,j,zs]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ls,D]}],"font-family":[{font:[mw,D,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,j,D]}],"line-clamp":[{"line-clamp":[G,"none",j,zs]}],leading:[{leading:[s,...S()]}],"list-image":[{"list-image":["none",j,D]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",j,D]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:L()}],"text-color":[{text:L()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...J(),"wavy"]}],"text-decoration-thickness":[{decoration:[G,"from-font","auto",j,_t]}],"text-decoration-color":[{decoration:L()}],"underline-offset":[{"underline-offset":[G,"auto",j,D]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:S()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",j,D]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",j,D]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Se()}],"bg-repeat":[{bg:Ce()}],"bg-size":[{bg:C()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},vt,j,D],radial:["",j,D],conic:[vt,j,D]},yw,fw]}],"bg-color":[{bg:L()}],"gradient-from-pos":[{from:B()}],"gradient-via-pos":[{via:B()}],"gradient-to-pos":[{to:B()}],"gradient-from":[{from:L()}],"gradient-via":[{via:L()}],"gradient-to":[{to:L()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:_()}],"border-w-x":[{"border-x":_()}],"border-w-y":[{"border-y":_()}],"border-w-s":[{"border-s":_()}],"border-w-e":[{"border-e":_()}],"border-w-t":[{"border-t":_()}],"border-w-r":[{"border-r":_()}],"border-w-b":[{"border-b":_()}],"border-w-l":[{"border-l":_()}],"divide-x":[{"divide-x":_()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":_()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...J(),"hidden","none"]}],"divide-style":[{divide:[...J(),"hidden","none"]}],"border-color":[{border:L()}],"border-color-x":[{"border-x":L()}],"border-color-y":[{"border-y":L()}],"border-color-s":[{"border-s":L()}],"border-color-e":[{"border-e":L()}],"border-color-t":[{"border-t":L()}],"border-color-r":[{"border-r":L()}],"border-color-b":[{"border-b":L()}],"border-color-l":[{"border-l":L()}],"divide-color":[{divide:L()}],"outline-style":[{outline:[...J(),"none","hidden"]}],"outline-offset":[{"outline-offset":[G,j,D]}],"outline-w":[{outline:["",G,Bn,_t]}],"outline-color":[{outline:L()}],shadow:[{shadow:["","none",d,zr,Lr]}],"shadow-color":[{shadow:L()}],"inset-shadow":[{"inset-shadow":["none",u,zr,Lr]}],"inset-shadow-color":[{"inset-shadow":L()}],"ring-w":[{ring:_()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:L()}],"ring-offset-w":[{"ring-offset":[G,_t]}],"ring-offset-color":[{"ring-offset":L()}],"inset-ring-w":[{"inset-ring":_()}],"inset-ring-color":[{"inset-ring":L()}],"text-shadow":[{"text-shadow":["none",h,zr,Lr]}],"text-shadow-color":[{"text-shadow":L()}],opacity:[{opacity:[G,j,D]}],"mix-blend":[{"mix-blend":[...oe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":oe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[G]}],"mask-image-linear-from-pos":[{"mask-linear-from":F()}],"mask-image-linear-to-pos":[{"mask-linear-to":F()}],"mask-image-linear-from-color":[{"mask-linear-from":L()}],"mask-image-linear-to-color":[{"mask-linear-to":L()}],"mask-image-t-from-pos":[{"mask-t-from":F()}],"mask-image-t-to-pos":[{"mask-t-to":F()}],"mask-image-t-from-color":[{"mask-t-from":L()}],"mask-image-t-to-color":[{"mask-t-to":L()}],"mask-image-r-from-pos":[{"mask-r-from":F()}],"mask-image-r-to-pos":[{"mask-r-to":F()}],"mask-image-r-from-color":[{"mask-r-from":L()}],"mask-image-r-to-color":[{"mask-r-to":L()}],"mask-image-b-from-pos":[{"mask-b-from":F()}],"mask-image-b-to-pos":[{"mask-b-to":F()}],"mask-image-b-from-color":[{"mask-b-from":L()}],"mask-image-b-to-color":[{"mask-b-to":L()}],"mask-image-l-from-pos":[{"mask-l-from":F()}],"mask-image-l-to-pos":[{"mask-l-to":F()}],"mask-image-l-from-color":[{"mask-l-from":L()}],"mask-image-l-to-color":[{"mask-l-to":L()}],"mask-image-x-from-pos":[{"mask-x-from":F()}],"mask-image-x-to-pos":[{"mask-x-to":F()}],"mask-image-x-from-color":[{"mask-x-from":L()}],"mask-image-x-to-color":[{"mask-x-to":L()}],"mask-image-y-from-pos":[{"mask-y-from":F()}],"mask-image-y-to-pos":[{"mask-y-to":F()}],"mask-image-y-from-color":[{"mask-y-from":L()}],"mask-image-y-to-color":[{"mask-y-to":L()}],"mask-image-radial":[{"mask-radial":[j,D]}],"mask-image-radial-from-pos":[{"mask-radial-from":F()}],"mask-image-radial-to-pos":[{"mask-radial-to":F()}],"mask-image-radial-from-color":[{"mask-radial-from":L()}],"mask-image-radial-to-color":[{"mask-radial-to":L()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":E()}],"mask-image-conic-pos":[{"mask-conic":[G]}],"mask-image-conic-from-pos":[{"mask-conic-from":F()}],"mask-image-conic-to-pos":[{"mask-conic-to":F()}],"mask-image-conic-from-color":[{"mask-conic-from":L()}],"mask-image-conic-to-color":[{"mask-conic-to":L()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Se()}],"mask-repeat":[{mask:Ce()}],"mask-size":[{mask:C()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",j,D]}],filter:[{filter:["","none",j,D]}],blur:[{blur:Ne()}],brightness:[{brightness:[G,j,D]}],contrast:[{contrast:[G,j,D]}],"drop-shadow":[{"drop-shadow":["","none",p,zr,Lr]}],"drop-shadow-color":[{"drop-shadow":L()}],grayscale:[{grayscale:["",G,j,D]}],"hue-rotate":[{"hue-rotate":[G,j,D]}],invert:[{invert:["",G,j,D]}],saturate:[{saturate:[G,j,D]}],sepia:[{sepia:["",G,j,D]}],"backdrop-filter":[{"backdrop-filter":["","none",j,D]}],"backdrop-blur":[{"backdrop-blur":Ne()}],"backdrop-brightness":[{"backdrop-brightness":[G,j,D]}],"backdrop-contrast":[{"backdrop-contrast":[G,j,D]}],"backdrop-grayscale":[{"backdrop-grayscale":["",G,j,D]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[G,j,D]}],"backdrop-invert":[{"backdrop-invert":["",G,j,D]}],"backdrop-opacity":[{"backdrop-opacity":[G,j,D]}],"backdrop-saturate":[{"backdrop-saturate":[G,j,D]}],"backdrop-sepia":[{"backdrop-sepia":["",G,j,D]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":S()}],"border-spacing-x":[{"border-spacing-x":S()}],"border-spacing-y":[{"border-spacing-y":S()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",j,D]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[G,"initial",j,D]}],ease:[{ease:["linear","initial",y,j,D]}],delay:[{delay:[G,j,D]}],animate:[{animate:["none",w,j,D]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,j,D]}],"perspective-origin":[{"perspective-origin":b()}],rotate:[{rotate:je()}],"rotate-x":[{"rotate-x":je()}],"rotate-y":[{"rotate-y":je()}],"rotate-z":[{"rotate-z":je()}],scale:[{scale:Be()}],"scale-x":[{"scale-x":Be()}],"scale-y":[{"scale-y":Be()}],"scale-z":[{"scale-z":Be()}],"scale-3d":["scale-3d"],skew:[{skew:tt()}],"skew-x":[{"skew-x":tt()}],"skew-y":[{"skew-y":tt()}],transform:[{transform:[j,D,"","none","gpu","cpu"]}],"transform-origin":[{origin:b()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ye()}],"translate-x":[{"translate-x":Ye()}],"translate-y":[{"translate-y":Ye()}],"translate-z":[{"translate-z":Ye()}],"translate-none":["translate-none"],accent:[{accent:L()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:L()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",j,D]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":S()}],"scroll-mx":[{"scroll-mx":S()}],"scroll-my":[{"scroll-my":S()}],"scroll-ms":[{"scroll-ms":S()}],"scroll-me":[{"scroll-me":S()}],"scroll-mt":[{"scroll-mt":S()}],"scroll-mr":[{"scroll-mr":S()}],"scroll-mb":[{"scroll-mb":S()}],"scroll-ml":[{"scroll-ml":S()}],"scroll-p":[{"scroll-p":S()}],"scroll-px":[{"scroll-px":S()}],"scroll-py":[{"scroll-py":S()}],"scroll-ps":[{"scroll-ps":S()}],"scroll-pe":[{"scroll-pe":S()}],"scroll-pt":[{"scroll-pt":S()}],"scroll-pr":[{"scroll-pr":S()}],"scroll-pb":[{"scroll-pb":S()}],"scroll-pl":[{"scroll-pl":S()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",j,D]}],fill:[{fill:["none",...L()]}],"stroke-w":[{stroke:[G,Bn,_t,zs]}],stroke:[{stroke:["none",...L()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},kw=ew(ww);function Cn(...n){return kw(jx(n))}const vw=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Sw=n=>n.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase()),wc=n=>{const e=Sw(n);return e.charAt(0).toUpperCase()+e.slice(1)},Hh=(...n)=>n.filter((e,t,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===t).join(" ").trim(),Cw=n=>{for(const e in n)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Mw={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Ew=z.forwardRef(({color:n="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:i,...a},l)=>z.createElement("svg",{ref:l,...Mw,width:e,height:e,stroke:n,strokeWidth:r?Number(t)*24/Number(e):t,className:Hh("lucide",o),...!s&&!Cw(a)&&{"aria-hidden":"true"},...a},[...i.map(([c,d])=>z.createElement(c,d)),...Array.isArray(s)?s:[s]])),ge=(n,e)=>{const t=z.forwardRef(({className:r,...o},s)=>z.createElement(Ew,{ref:s,iconNode:e,className:Hh(`lucide-${vw(wc(n))}`,`lucide-${n}`,r),...o}));return t.displayName=wc(n),t},Tw=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],Nw=ge("bold",Tw),Aw=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],kc=ge("code",Aw),Ow=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],Rw=ge("heading-1",Ow),Dw=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],jw=ge("heading-2",Dw),Lw=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],zw=ge("heading-3",Lw),$w=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Iw=ge("image",$w),Pw=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],Hw=ge("italic",Pw),Bw=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Vw=ge("list-ordered",Bw),Fw=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],Ww=ge("list",Fw),_w=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],Uw=ge("palette",_w),qw=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Kw=ge("pen",qw),Jw=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],Gw=ge("quote",Jw),Xw=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Yw=ge("rotate-ccw",Xw),Qw=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Zw=ge("rotate-cw",Qw),ek=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],tk=ge("strikethrough",ek),nk=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],rk=ge("text-align-center",nk),ok=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],sk=ge("text-align-end",ok),ik=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],ak=ge("text-align-justify",ik),lk=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],ck=ge("text-align-start",lk),dk=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],uk=ge("underline",dk),ua=[{id:"black",cssVar:"var(--editor-text-black)",label:"Black/White"},{id:"gray-600",cssVar:"var(--editor-text-gray-600)",label:"Gray"},{id:"red-500",cssVar:"var(--editor-text-red-500)",label:"Red"},{id:"orange-500",cssVar:"var(--editor-text-orange-500)",label:"Orange"},{id:"yellow-500",cssVar:"var(--editor-text-yellow-500)",label:"Yellow"},{id:"green-500",cssVar:"var(--editor-text-green-500)",label:"Green"},{id:"blue-500",cssVar:"var(--editor-text-blue-500)",label:"Blue"},{id:"purple-500",cssVar:"var(--editor-text-purple-500)",label:"Purple"},{id:"pink-500",cssVar:"var(--editor-text-pink-500)",label:"Pink"}];function vc(n){const e=ua.find(t=>t.id===n);return e?e.cssVar:n}function Sc(n){const e=ua.find(t=>t.cssVar===n);return e?e.id:n}function Cc(n){const e=jo.c(15),{currentColor:t,onColorSelect:r,onReset:o,onClose:s,type:i}=n,a=i==="text"?"텍스트 색상":"배경 색상";let l;e[0]!==a?(l=N.jsx("div",{className:"color-picker-label",children:a}),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==t||e[3]!==s||e[4]!==r?(c=ua.map(p=>{const f=t===p.id||t===p.cssVar;return N.jsx("button",{type:"button",onClick:()=>{r(p.id),s()},className:`color-grid-button ${f?"selected":""}`,style:{backgroundColor:p.cssVar},title:`${p.label}`},p.id)}),e[2]=t,e[3]=s,e[4]=r,e[5]=c):c=e[5];let d;e[6]!==c?(d=N.jsx("div",{className:"color-grid",children:c}),e[6]=c,e[7]=d):d=e[7];let u;e[8]!==s||e[9]!==o?(u=N.jsx("button",{type:"button",onClick:()=>{o(),s()},className:"color-picker-reset-button",children:"색상 제거"}),e[8]=s,e[9]=o,e[10]=u):u=e[10];let h;return e[11]!==l||e[12]!==d||e[13]!==u?(h=N.jsxs("div",{className:"color-picker",children:[l,d,u]}),e[11]=l,e[12]=d,e[13]=u,e[14]=h):h=e[14],h}function hk(n){const e=jo.c(179),{editor:t,onAddImage:r,hideMenuButtons:o,classNames:s}=n;let i;e[0]!==o?(i=o===void 0?[]:o,e[0]=o,e[1]=i):i=e[1];const a=i,[l,c]=z.useState(!1),[d,u]=z.useState(!1),h=z.useRef(null),p=z.useRef(null);let f,m;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const nt=mn=>{h.current&&!h.current.contains(mn.target)&&c(!1),p.current&&!p.current.contains(mn.target)&&u(!1)};return document.addEventListener("mousedown",nt),()=>{document.removeEventListener("mousedown",nt)}},m=[],e[2]=f,e[3]=m):(f=e[2],m=e[3]),z.useEffect(f,m);let g;e[4]!==t?(g={editor:t,selector:pk},e[4]=t,e[5]=g):g=e[5];const y=vh(g);let w;e[6]!==s?.button?(w=nt=>Cn("menubar-button",nt&&"active",s?.button),e[6]=s?.button,e[7]=w):w=e[7];const x=w;let E;e[8]!==a?(E=nt=>a.includes(nt),e[8]=a,e[9]=E):E=e[9];const b=E,T=s?.container;let v;e[10]!==T?(v=Cn("menubar-container",T),e[10]=T,e[11]=v):v=e[11];let S;e[12]!==x||e[13]!==t||e[14]!==y||e[15]!==b?(S=!b("bold")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBold().run(),title:"Bold (Ctrl+B)",className:x(y.isBold),children:N.jsx(Nw,{size:14})}),e[12]=x,e[13]=t,e[14]=y,e[15]=b,e[16]=S):S=e[16];let R;e[17]!==x||e[18]!==t||e[19]!==y||e[20]!==b?(R=!b("italic")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleItalic().run(),title:"Italic (Ctrl+I)",className:x(y.isItalic),children:N.jsx(Hw,{size:14})}),e[17]=x,e[18]=t,e[19]=y,e[20]=b,e[21]=R):R=e[21];let K;e[22]!==x||e[23]!==t||e[24]!==y||e[25]!==b?(K=!b("strike")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleStrike().run(),title:"Strikethrough",className:x(y.isStrike),children:N.jsx(tk,{size:14})}),e[22]=x,e[23]=t,e[24]=y,e[25]=b,e[26]=K):K=e[26];let $;e[27]!==x||e[28]!==t||e[29]!==y||e[30]!==b?($=!b("underline")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleUnderline().run(),title:"Underline (Ctrl+U)",className:x(y.isUnderline),children:N.jsx(uk,{size:14})}),e[27]=x,e[28]=t,e[29]=y,e[30]=b,e[31]=$):$=e[31];let Y;e[32]!==b?(Y=(!b("bold")||!b("italic")||!b("strike")||!b("underline")||!b("textColor")||!b("bgColor"))&&N.jsx("div",{className:"menubar-separator"}),e[32]=b,e[33]=Y):Y=e[33];let pe;e[34]!==x||e[35]!==t||e[36]!==y||e[37]!==b||e[38]!==l?(pe=!b("textColor")&&N.jsxs("div",{className:"color-picker-container",ref:h,children:[N.jsx("button",{type:"button",onClick:()=>{c(!l),u(!1)},title:"Text Color",className:Cn(x(!1),"color-button"),children:N.jsxs("div",{className:"color-button",children:[N.jsx(Kw,{size:14}),N.jsx("div",{className:"color-display-bar",style:{backgroundColor:y.displayColor}})]})}),l&&N.jsx(Cc,{currentColor:y.currentColor,onColorSelect:nt=>{const mn=vc(nt);t.chain().focus().setColor(mn).run()},onReset:()=>t.chain().focus().unsetColor().run(),onClose:()=>c(!1),type:"text"})]}),e[34]=x,e[35]=t,e[36]=y,e[37]=b,e[38]=l,e[39]=pe):pe=e[39];let Z;e[40]!==x||e[41]!==t||e[42]!==y||e[43]!==b||e[44]!==d?(Z=!b("bgColor")&&N.jsxs("div",{className:"color-picker-container",ref:p,children:[N.jsx("button",{type:"button",onClick:()=>{u(!d),c(!1)},title:"Background Color",className:Cn(x(!1),"color-button"),children:N.jsxs("div",{className:"color-button",children:[N.jsx(Uw,{size:14}),N.jsx("div",{className:"color-display-bar",style:{backgroundColor:y.displayHighlight}})]})}),d&&N.jsx(Cc,{currentColor:y.currentHighlight,onColorSelect:nt=>{const mn=vc(nt);t.chain().focus().toggleHighlight({color:mn}).run()},onReset:()=>t.chain().focus().unsetHighlight().run(),onClose:()=>u(!1),type:"background"})]}),e[40]=x,e[41]=t,e[42]=y,e[43]=b,e[44]=d,e[45]=Z):Z=e[45];let U;e[46]!==b?(U=(!b("table")||!b("image"))&&N.jsx("div",{className:"menubar-separator"}),e[46]=b,e[47]=U):U=e[47];let X;e[48]!==x||e[49]!==t||e[50]!==y||e[51]!==b?(X=!b("table")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().insertTable({rows:3,cols:3}).run(),title:"Insert Table",className:x(y.isTable),children:N.jsxs("svg",{className:"menubar-table-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[N.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),N.jsx("path",{d:"M3 9h18M3 15h18M9 21V3M15 21V3"})]})}),e[48]=x,e[49]=t,e[50]=y,e[51]=b,e[52]=X):X=e[52];let ee;e[53]!==x||e[54]!==b||e[55]!==r?(ee=!b("image")&&r&&N.jsx("button",{type:"button",onClick:r,title:"Insert Image",className:x(!1),children:N.jsx(Iw,{size:14})}),e[53]=x,e[54]=b,e[55]=r,e[56]=ee):ee=e[56];let L;e[57]!==b?(L=(!b("h1")||!b("h2")||!b("h3")||!b("paragraph"))&&N.jsx("div",{className:"menubar-separator"}),e[57]=b,e[58]=L):L=e[58];let Se;e[59]!==x||e[60]!==t||e[61]!==y||e[62]!==b?(Se=!b("h1")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),title:"Heading 1",className:x(y.isHeading1),children:N.jsx(Rw,{size:14})}),e[59]=x,e[60]=t,e[61]=y,e[62]=b,e[63]=Se):Se=e[63];let Ce;e[64]!==x||e[65]!==t||e[66]!==y||e[67]!==b?(Ce=!b("h2")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),title:"Heading 2",className:x(y.isHeading2),children:N.jsx(jw,{size:14})}),e[64]=x,e[65]=t,e[66]=y,e[67]=b,e[68]=Ce):Ce=e[68];let C;e[69]!==x||e[70]!==t||e[71]!==y||e[72]!==b?(C=!b("h3")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),title:"Heading 3",className:x(y.isHeading3),children:N.jsx(zw,{size:14})}),e[69]=x,e[70]=t,e[71]=y,e[72]=b,e[73]=C):C=e[73];let B;e[74]!==x||e[75]!==t||e[76]!==y||e[77]!==b?(B=!b("paragraph")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().setParagraph().run(),title:"Paragraph",className:x(y.isParagraph),children:"¶"}),e[74]=x,e[75]=t,e[76]=y,e[77]=b,e[78]=B):B=e[78];let V;e[79]!==b?(V=(!b("bulletList")||!b("orderedList"))&&N.jsx("div",{className:"menubar-separator"}),e[79]=b,e[80]=V):V=e[80];let _;e[81]!==x||e[82]!==t||e[83]!==y||e[84]!==b?(_=!b("bulletList")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBulletList().run(),title:"Bullet List",className:x(y.isBulletList),children:N.jsx(Ww,{size:14})}),e[81]=x,e[82]=t,e[83]=y,e[84]=b,e[85]=_):_=e[85];let J;e[86]!==x||e[87]!==t||e[88]!==y||e[89]!==b?(J=!b("orderedList")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleOrderedList().run(),title:"Ordered List",className:x(y.isOrderedList),children:N.jsx(Vw,{size:14})}),e[86]=x,e[87]=t,e[88]=y,e[89]=b,e[90]=J):J=e[90];let oe;e[91]!==b?(oe=(!b("code")||!b("codeBlock")||!b("blockquote")||!b("horizontalRule"))&&N.jsx("div",{className:"menubar-separator"}),e[91]=b,e[92]=oe):oe=e[92];let F;e[93]!==x||e[94]!==t||e[95]!==y||e[96]!==b?(F=!b("code")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleCode().run(),title:"Code (Ctrl+`)",className:x(y.isCode),children:N.jsx(kc,{size:14})}),e[93]=x,e[94]=t,e[95]=y,e[96]=b,e[97]=F):F=e[97];let Ne;e[98]!==x||e[99]!==t||e[100]!==y||e[101]!==b?(Ne=!b("codeBlock")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleCodeBlock().run(),title:"Code Block",className:x(y.isCodeBlock),children:N.jsx(kc,{size:14})}),e[98]=x,e[99]=t,e[100]=y,e[101]=b,e[102]=Ne):Ne=e[102];let je;e[103]!==x||e[104]!==t||e[105]!==y||e[106]!==b?(je=!b("blockquote")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBlockquote().run(),title:"Blockquote",className:x(y.isBlockquote),children:N.jsx(Gw,{size:14})}),e[103]=x,e[104]=t,e[105]=y,e[106]=b,e[107]=je):je=e[107];let Be;e[108]!==x||e[109]!==t||e[110]!==b?(Be=!b("horizontalRule")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().setHorizontalRule().run(),title:"Horizontal Rule",className:x(!1),children:"—"}),e[108]=x,e[109]=t,e[110]=b,e[111]=Be):Be=e[111];let tt;e[112]!==b?(tt=(!b("alignLeft")||!b("alignCenter")||!b("alignRight")||!b("alignJustify"))&&N.jsx("div",{className:"menubar-separator"}),e[112]=b,e[113]=tt):tt=e[113];let Ye;e[114]!==x||e[115]!==t||e[116]!==y||e[117]!==b?(Ye=!b("alignLeft")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("left").run(),title:"Align Left",className:x(y.alignLeft),children:N.jsx(ck,{size:14})}),e[114]=x,e[115]=t,e[116]=y,e[117]=b,e[118]=Ye):Ye=e[118];let cn;e[119]!==x||e[120]!==t||e[121]!==y||e[122]!==b?(cn=!b("alignCenter")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("center").run(),title:"Align Center",className:x(y.alignCenter),children:N.jsx(rk,{size:14})}),e[119]=x,e[120]=t,e[121]=y,e[122]=b,e[123]=cn):cn=e[123];let dn;e[124]!==x||e[125]!==t||e[126]!==y||e[127]!==b?(dn=!b("alignRight")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("right").run(),title:"Align Right",className:x(y.alignRight),children:N.jsx(sk,{size:14})}),e[124]=x,e[125]=t,e[126]=y,e[127]=b,e[128]=dn):dn=e[128];let un;e[129]!==x||e[130]!==t||e[131]!==y||e[132]!==b?(un=!b("alignJustify")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("justify").run(),title:"Justify",className:x(y.alignJustify),children:N.jsx(ak,{size:14})}),e[129]=x,e[130]=t,e[131]=y,e[132]=b,e[133]=un):un=e[133];let hn;e[134]!==b?(hn=(!b("undo")||!b("redo"))&&N.jsx("div",{className:"menubar-separator"}),e[134]=b,e[135]=hn):hn=e[135];let pn;e[136]!==x||e[137]!==t||e[138]!==y||e[139]!==b?(pn=!b("undo")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().undo().run(),disabled:!y.canUndo,title:"Undo (Ctrl+Z)",className:x(!1),children:N.jsx(Yw,{size:14})}),e[136]=x,e[137]=t,e[138]=y,e[139]=b,e[140]=pn):pn=e[140];let fn;e[141]!==x||e[142]!==t||e[143]!==y||e[144]!==b?(fn=!b("redo")&&N.jsx("button",{type:"button",onClick:()=>t.chain().focus().redo().run(),disabled:!y.canRedo,title:"Redo (Ctrl+Y)",className:x(!1),children:N.jsx(Zw,{size:14})}),e[141]=x,e[142]=t,e[143]=y,e[144]=b,e[145]=fn):fn=e[145];let yr;return e[146]!==S||e[147]!==R||e[148]!==K||e[149]!==$||e[150]!==Y||e[151]!==pe||e[152]!==Z||e[153]!==U||e[154]!==X||e[155]!==ee||e[156]!==L||e[157]!==Se||e[158]!==Ce||e[159]!==C||e[160]!==B||e[161]!==V||e[162]!==_||e[163]!==J||e[164]!==oe||e[165]!==F||e[166]!==Ne||e[167]!==je||e[168]!==Be||e[169]!==tt||e[170]!==Ye||e[171]!==cn||e[172]!==dn||e[173]!==un||e[174]!==hn||e[175]!==pn||e[176]!==fn||e[177]!==v?(yr=N.jsxs("div",{className:v,children:[S,R,K,$,Y,pe,Z,U,X,ee,L,Se,Ce,C,B,V,_,J,oe,F,Ne,je,Be,tt,Ye,cn,dn,un,hn,pn,fn]}),e[146]=S,e[147]=R,e[148]=K,e[149]=$,e[150]=Y,e[151]=pe,e[152]=Z,e[153]=U,e[154]=X,e[155]=ee,e[156]=L,e[157]=Se,e[158]=Ce,e[159]=C,e[160]=B,e[161]=V,e[162]=_,e[163]=J,e[164]=oe,e[165]=F,e[166]=Ne,e[167]=je,e[168]=Be,e[169]=tt,e[170]=Ye,e[171]=cn,e[172]=dn,e[173]=un,e[174]=hn,e[175]=pn,e[176]=fn,e[177]=v,e[178]=yr):yr=e[178],yr}function pk(n){const e=n.editor.getAttributes("textStyle").color,t=n.editor.getAttributes("highlight").color;return{isBold:n.editor.isActive("bold")??!1,isItalic:n.editor.isActive("italic")??!1,isUnderline:n.editor.isActive("underline")??!1,isStrike:n.editor.isActive("strike")??!1,isCode:n.editor.isActive("code")??!1,canClearMarks:n.editor.can().chain().unsetAllMarks().run()??!1,isParagraph:n.editor.isActive("paragraph")??!1,isHeading1:n.editor.isActive("heading",{level:1})??!1,isHeading2:n.editor.isActive("heading",{level:2})??!1,isHeading3:n.editor.isActive("heading",{level:3})??!1,isBulletList:n.editor.isActive("bulletList")??!1,isOrderedList:n.editor.isActive("orderedList")??!1,isCodeBlock:n.editor.isActive("codeBlock")??!1,isBlockquote:n.editor.isActive("blockquote")??!1,canUndo:n.editor.can().chain().undo().run()??!1,canRedo:n.editor.can().chain().redo().run()??!1,isTable:n.editor.isActive("table")??!1,alignLeft:n.editor.isActive({textAlign:"left"})??!1,alignCenter:n.editor.isActive({textAlign:"center"})??!1,alignRight:n.editor.isActive({textAlign:"right"})??!1,alignJustify:n.editor.isActive({textAlign:"justify"})??!1,currentColor:e?Sc(e):"black",currentHighlight:t?Sc(t):"#ffffff",displayColor:e||"var(--editor-text-black)",displayHighlight:t||"transparent"}}function Mc(n){if(!n)return"<p></p>";try{return JSON.parse(n)}catch{return n}}function fk({ref:n,className:e,classNames:t,initialContent:r="",hideMenuButtons:o=[]}){const s=kx({extensions:Mh,content:Mc(r),editorProps:{attributes:{class:Cn("tiptap-editor-content",t?.editorContent)},handlePaste(a,l){const c=l.clipboardData?.items;if(!c)return!1;for(let d=0;d<c.length;d++)if(c[d].kind==="file"&&c[d].type.startsWith("image/")){l.preventDefault();const u=c[d].getAsFile();if(!u)continue;const h=new FileReader;return h.onload=p=>{const f=p.target?.result,{state:m}=a,{$from:g}=m.selection,y=m.schema.nodes.image.create({src:f}),w=m.tr.insert(g.pos,y);a.dispatch(w)},h.readAsDataURL(u),!0}return!1},handleDOMEvents:{copy:(a,l)=>{const{state:c}=a,{selection:d}=c,{$from:u,$to:h}=d;return c.doc.nodesBetween(u.pos,h.pos,p=>{if(p.type.name==="image"&&p.attrs.src){if(l.preventDefault(),l.clipboardData){if(p.attrs.src.startsWith("data:image/"))try{const f=p.attrs.src.split(",")[1],m=p.attrs.src.match(/data:([^;]+);/)?.[1]||"image/png",g=atob(f),y=new Array(g.length);for(let b=0;b<g.length;b++)y[b]=g.charCodeAt(b);const w=new Uint8Array(y),x=new Blob([w],{type:m}),E=new ClipboardItem({[m]:x});navigator.clipboard.write([E]).catch(b=>{console.error("Failed to copy image to clipboard:",b)})}catch(f){console.error("Failed to process image for clipboard:",f)}l.clipboardData.setData("text/html",`<img src="${p.attrs.src}" />`),l.clipboardData.setData("text/plain",p.attrs.src)}return!1}}),!1},cut:(a,l)=>{const{state:c}=a,{selection:d}=c,{$from:u,$to:h}=d;return c.doc.nodesBetween(u.pos,h.pos,(p,f)=>{if(p.type.name==="image"&&p.attrs.src){if(l.preventDefault(),l.clipboardData){if(p.attrs.src.startsWith("data:image/"))try{const g=p.attrs.src.split(",")[1],y=p.attrs.src.match(/data:([^;]+);/)?.[1]||"image/png",w=atob(g),x=new Array(w.length);for(let v=0;v<w.length;v++)x[v]=w.charCodeAt(v);const E=new Uint8Array(x),b=new Blob([E],{type:y}),T=new ClipboardItem({[y]:b});navigator.clipboard.write([T]).catch(v=>{console.error("Failed to copy image to clipboard:",v)})}catch(g){console.error("Failed to process image for clipboard:",g)}l.clipboardData.setData("text/html",`<img src="${p.attrs.src}" />`),l.clipboardData.setData("text/plain",p.attrs.src)}const m=c.tr.delete(f,f+p.nodeSize);return a.dispatch(m),!1}}),!1}}}}),i=z.useCallback(()=>{const a=document.createElement("input");a.type="file",a.accept="image/*",a.onchange=l=>{const c=l.target.files?.[0];if(!c||!s)return;const d=new FileReader;d.onload=u=>{const h=u.target?.result;s.chain().focus().insertContent({type:"image",attrs:{src:h}}).run()},d.readAsDataURL(c)},a.click()},[s]);return z.useEffect(()=>{if(s&&r&&r.trim()){const a=Mc(r);s.commands.setContent(a)}},[s,r]),z.useImperativeHandle(n,()=>({getJSON:()=>s?JSON.stringify(s.getJSON()):"{}"}),[s]),s?N.jsxs("div",{className:Cn("tiptap-editor-wrapper",e),children:[N.jsx(hk,{editor:s,onAddImage:i,hideMenuButtons:o,classNames:{container:t?.menubarContainer,button:t?.menubarButton}}),N.jsx(gx,{editor:s})]}):null}function mk(n,e,t){if(typeof window>"u")throw new Error("getHTMLFromFragment can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");const r=Bt.fromSchema(e).serializeFragment(n.content,{document:window.document});return new XMLSerializer().serializeToString(r)}function gk(n,e){if(typeof window>"u")throw new Error("generateHTML can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");const t=Kg(e),r=Je.fromJSON(t,n);return mk(r,t)}function yk(n){if(!n)return"<p></p>";try{const e=JSON.parse(n);let t=gk(e,Mh);return t=t.replace(/<p[^>]*><\/p>/g,"<p><br></p>"),t}catch{return n}}const Bh=n=>{const e=jo.c(4),{content:t}=n;let r;e[0]!==t?(r=yk(t),e[0]=t,e[1]=r):r=e[1];let o;return e[2]!==r?(o=N.jsx("div",{className:"content-div",dangerouslySetInnerHTML:{__html:r}}),e[2]=r,e[3]=o):o=e[3],o},Do=n=>{const e=ln.compilerRuntimeExports.c(18),{ref:t,tiptapRef:r,initialContent:o,isSubmitting:s,onSubmit:i,onCancel:a,submitLabel:l,cancelLabel:c,showLabel:d,labelText:u,containerClassName:h}=n,p=o===void 0?"":o,f=s===void 0?!1:s,m=l===void 0?"작성":l,g=c===void 0?"취소":c,y=d===void 0?!0:d,w=u===void 0?"댓글 작성":u,E=`flex flex-col gap-2 rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50 ${h===void 0?"":h}`;let b;e[0]!==g||e[1]!==f||e[2]!==w||e[3]!==a||e[4]!==i||e[5]!==y||e[6]!==m?(b=y&&k.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[k.jsxRuntimeExports.jsx("label",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:w}),k.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[k.jsxRuntimeExports.jsxs(k.Button,{size:"sm",onClick:i,disabled:f,children:[f?k.jsxRuntimeExports.jsx(Pe.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):k.jsxRuntimeExports.jsx(Pe.Send,{className:"mr-2 h-4 w-4"}),m]}),k.jsxRuntimeExports.jsx(k.Button,{size:"sm",variant:"outline",onClick:a,disabled:f,children:g})]})]}),e[0]=g,e[1]=f,e[2]=w,e[3]=a,e[4]=i,e[5]=y,e[6]=m,e[7]=b):b=e[7];let T,v;e[8]===Symbol.for("react.memo_cache_sentinel")?(T={menubarContainer:"dark:bg-background!",editorContent:"dark:bg-card! min-h-[4rem]! max-h-[8rem]! overflow-y-auto"},v=["table","bgColor","undo","redo","alignLeft","alignCenter","alignRight","alignJustify","paragraph"],e[8]=T,e[9]=v):(T=e[8],v=e[9]);let S;e[10]!==p||e[11]!==r?(S=k.jsxRuntimeExports.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900",children:k.jsxRuntimeExports.jsx(fk,{ref:r,initialContent:p,className:"rounded",classNames:T,hideMenuButtons:v})}),e[10]=p,e[11]=r,e[12]=S):S=e[12];let R;return e[13]!==t||e[14]!==S||e[15]!==E||e[16]!==b?(R=k.jsxRuntimeExports.jsxs("div",{ref:t,className:E,children:[b,S]}),e[13]=t,e[14]=S,e[15]=E,e[16]=b,e[17]=R):R=e[17],R},ha=(n,e=100)=>{setTimeout(()=>{let t=null;if(n){const r=document.getElementById(n);t=r?.querySelector("[contenteditable]"),r?.scrollIntoView({behavior:"auto",block:"center"})}else{const r=document.querySelectorAll("[contenteditable]");t=r[r.length-1]}t?.focus()},e)},bk=n=>{const e=ln.compilerRuntimeExports.c(12),{onEdit:t,onDelete:r}=n;let o;e[0]!==t?(o=()=>{t(),ha()},e[0]=t,e[1]=o):o=e[1];const s=o;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsxRuntimeExports.jsx(k.PopoverTrigger,{asChild:!0,children:k.jsxRuntimeExports.jsx(k.Button,{size:"sm",variant:"ghost",className:"h-auto px-2 py-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:k.jsxRuntimeExports.jsx(Pe.MoreHorizontal,{className:"h-5 w-5"})})}),e[2]=i):i=e[2];let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=k.jsxRuntimeExports.jsx(Pe.Edit2,{className:"mr-2 h-3 w-3"}),e[3]=a):a=e[3];let l;e[4]!==s?(l=k.jsxRuntimeExports.jsxs(k.Button,{size:"sm",variant:"ghost",onClick:s,className:"justify-start text-xs text-gray-700 dark:text-gray-300",children:[a,"수정"]}),e[4]=s,e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsxRuntimeExports.jsx(Pe.Trash2,{className:"mr-2 h-3 w-3"}),e[6]=c):c=e[6];let d;e[7]!==r?(d=k.jsxRuntimeExports.jsxs(k.Button,{size:"sm",variant:"ghost",onClick:r,className:"justify-start text-xs text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:[c,"삭제"]}),e[7]=r,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==d?(u=k.jsxRuntimeExports.jsxs(k.Popover,{children:[i,k.jsxRuntimeExports.jsx(k.PopoverContent,{className:"w-auto p-1 pointer-events-auto",children:k.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-1",children:[l,d]})})]}),e[9]=l,e[10]=d,e[11]=u):u=e[11],u},Vh=n=>{const e=ln.compilerRuntimeExports.c(49),{comment:t,level:r,currentUserId:o,onReplyOpen:s,replyingToId:i,replyEditorRef:a,onSubmitReply:l,isSubmitting:c,onEdit:d,editingId:u,editEditorRef:h,onSubmitEdit:p,onDelete:f,isEditing:m}=n,g=i===t.id,y=u===t.id,w=t.children&&t.children.length>0,x=`reply-editor-${t.id}`,E=r>0&&"ml-4 border-l border-gray-200 pl-4 dark:border-gray-700";let b;e[0]!==E?(b=k.cn("flex flex-col gap-2",E),e[0]=E,e[1]=b):b=e[1];let T;e[2]!==t.body||e[3]!==t.createdAt||e[4]!==t.id||e[5]!==t.isAdmin||e[6]!==t.userId||e[7]!==t.userName||e[8]!==o||e[9]!==h||e[10]!==m||e[11]!==y||e[12]!==g||e[13]!==r||e[14]!==f||e[15]!==d||e[16]!==s||e[17]!==p||e[18]!==x?(T=y?k.jsxRuntimeExports.jsx(Do,{tiptapRef:h,initialContent:t.body,isSubmitting:m,onSubmit:()=>p(t.id),onCancel:()=>d(""),submitLabel:"수정",labelText:"댓글 수정"}):k.jsxRuntimeExports.jsx("div",{className:"py-2",children:k.jsxRuntimeExports.jsxs("div",{className:"flex items-start justify-between gap-3",children:[k.jsxRuntimeExports.jsxs("div",{className:"flex-1",children:[k.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[k.jsxRuntimeExports.jsx("span",{className:"text-xs font-medium text-gray-900 dark:text-gray-100",children:t.userName}),t.isAdmin&&k.jsxRuntimeExports.jsx("span",{className:"inline-flex items-center rounded-full bg-blue-100 px-2 py-0.5 text-xs font-semibold text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",children:"👨‍💼 관리자"}),k.jsxRuntimeExports.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:Tc.format(new Date(t.createdAt),"yyyy-MM-dd HH:mm")})]}),k.jsxRuntimeExports.jsx("div",{className:"mt-2 text-sm text-gray-700 dark:text-gray-300",children:k.jsxRuntimeExports.jsx(Bh,{content:t.body})}),!g&&k.jsxRuntimeExports.jsx("div",{className:"mt-2 flex items-center gap-3",children:r<2&&k.jsxRuntimeExports.jsx(k.Button,{size:"sm",variant:"ghost",onClick:()=>{s(t.id),ha(x,50)},className:"h-auto px-2 py-1 text-sm font-medium text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-200",children:"💬 답글"})})]}),o===t.userId&&k.jsxRuntimeExports.jsx(bk,{onEdit:()=>d(t.id),onDelete:()=>f(t.id)})]})}),e[2]=t.body,e[3]=t.createdAt,e[4]=t.id,e[5]=t.isAdmin,e[6]=t.userId,e[7]=t.userName,e[8]=o,e[9]=h,e[10]=m,e[11]=y,e[12]=g,e[13]=r,e[14]=f,e[15]=d,e[16]=s,e[17]=p,e[18]=x,e[19]=T):T=e[19];let v;e[20]!==t.id||e[21]!==g||e[22]!==c||e[23]!==s||e[24]!==l||e[25]!==x||e[26]!==a?(v=g&&k.jsxRuntimeExports.jsx(Do,{ref:K=>{K&&(K.id=x)},tiptapRef:a,isSubmitting:c,onSubmit:()=>l(t.id),onCancel:()=>s(""),submitLabel:"작성",labelText:"답글 작성"}),e[20]=t.id,e[21]=g,e[22]=c,e[23]=s,e[24]=l,e[25]=x,e[26]=a,e[27]=v):v=e[27];let S;e[28]!==t.children||e[29]!==o||e[30]!==h||e[31]!==u||e[32]!==w||e[33]!==m||e[34]!==c||e[35]!==r||e[36]!==f||e[37]!==d||e[38]!==s||e[39]!==p||e[40]!==l||e[41]!==a||e[42]!==i?(S=w&&k.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-2",children:t.children.map(K=>k.jsxRuntimeExports.jsx(Vh,{comment:K,level:r+1,currentUserId:o,onReplyOpen:s,replyingToId:i,replyEditorRef:a,onSubmitReply:l,isSubmitting:c,onEdit:d,editingId:u,editEditorRef:h,onSubmitEdit:p,onDelete:f,isEditing:m},K.id))}),e[28]=t.children,e[29]=o,e[30]=h,e[31]=u,e[32]=w,e[33]=m,e[34]=c,e[35]=r,e[36]=f,e[37]=d,e[38]=s,e[39]=p,e[40]=l,e[41]=a,e[42]=i,e[43]=S):S=e[43];let R;return e[44]!==b||e[45]!==T||e[46]!==v||e[47]!==S?(R=k.jsxRuntimeExports.jsxs("div",{className:b,children:[T,v,S]}),e[44]=b,e[45]=T,e[46]=v,e[47]=S,e[48]=R):R=e[48],R},xk=n=>{const e=ln.compilerRuntimeExports.c(33),{comments:t,isLoading:r,isCommentEditOpen:o,onCommentEditOpen:s,commentEditorRef:i,onSubmitComment:a,isSubmitting:l,replyingToId:c,onReplyOpen:d,replyEditorRef:u,onSubmitReply:h,editingId:p,onEdit:f,editEditorRef:m,onSubmitEdit:g,onDelete:y,isEditing:w,currentUserId:x}=n;let E;e[0]!==t.length?(E=k.jsxRuntimeExports.jsxs("h3",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["댓글 (",t.length,")"]}),e[0]=t.length,e[1]=E):E=e[1];let b;e[2]!==o||e[3]!==s?(b=!o&&k.jsxRuntimeExports.jsxs(k.Button,{size:"sm",variant:"outline",onClick:()=>{s(!0),ha()},children:[k.jsxRuntimeExports.jsx(Pe.Send,{className:"mr-2 h-4 w-4"}),"댓글 작성"]}),e[2]=o,e[3]=s,e[4]=b):b=e[4];let T;e[5]!==E||e[6]!==b?(T=k.jsxRuntimeExports.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[E,b]}),e[5]=E,e[6]=b,e[7]=T):T=e[7];let v;e[8]!==i||e[9]!==o||e[10]!==l||e[11]!==s||e[12]!==a?(v=o&&k.jsxRuntimeExports.jsx(Do,{tiptapRef:i,isSubmitting:l,onSubmit:a,onCancel:()=>s(!1),submitLabel:"작성",labelText:"댓글 작성"}),e[8]=i,e[9]=o,e[10]=l,e[11]=s,e[12]=a,e[13]=v):v=e[13];let S;e[14]!==t||e[15]!==x||e[16]!==m||e[17]!==p||e[18]!==w||e[19]!==r||e[20]!==l||e[21]!==y||e[22]!==f||e[23]!==d||e[24]!==g||e[25]!==h||e[26]!==u||e[27]!==c?(S=k.jsxRuntimeExports.jsx("div",{className:"mt-4",children:r?k.jsxRuntimeExports.jsx("div",{className:"flex justify-center py-4",children:k.jsxRuntimeExports.jsx(Pe.Loader2,{className:"h-4 w-4 animate-spin text-gray-400"})}):t.length===0?k.jsxRuntimeExports.jsx("div",{className:"text-center text-xs text-gray-500 dark:text-gray-400",children:"아직 댓글이 없습니다."}):k.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-0",children:t.map((K,$)=>k.jsxRuntimeExports.jsxs("div",{children:[k.jsxRuntimeExports.jsx(Vh,{comment:K,level:0,currentUserId:x,onReplyOpen:d,replyingToId:c,replyEditorRef:u,onSubmitReply:h,isSubmitting:l,onEdit:f,editingId:p,editEditorRef:m,onSubmitEdit:g,onDelete:y,isEditing:w}),$<t.length-1&&k.jsxRuntimeExports.jsx(k.Separator,{className:"my-3 bg-gray-200 dark:bg-gray-700"})]},K.id))})}),e[14]=t,e[15]=x,e[16]=m,e[17]=p,e[18]=w,e[19]=r,e[20]=l,e[21]=y,e[22]=f,e[23]=d,e[24]=g,e[25]=h,e[26]=u,e[27]=c,e[28]=S):S=e[28];let R;return e[29]!==T||e[30]!==v||e[31]!==S?(R=k.jsxRuntimeExports.jsxs("div",{children:[T,v,S]}),e[29]=T,e[30]=v,e[31]=S,e[32]=R):R=e[32],R},wk=n=>{const e=ln.compilerRuntimeExports.c(35),{feedback:t,currentUserId:r,onEditClick:o,onDeleteClick:s}=n;let i;e[0]!==t.feedbackDetail.title?(i=k.jsxRuntimeExports.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:t.feedbackDetail.title}),e[0]=t.feedbackDetail.title,e[1]=i):i=e[1];let a;e[2]!==t.userName?(a=k.jsxRuntimeExports.jsx("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:t.userName}),e[2]=t.userName,e[3]=a):a=e[3];let l;e[4]!==t.institutionName?(l=t.institutionName&&k.jsxRuntimeExports.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["· ",t.institutionName]}),e[4]=t.institutionName,e[5]=l):l=e[5];let c;e[6]!==a||e[7]!==l?(c=k.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[a,l]}),e[6]=a,e[7]=l,e[8]=c):c=e[8];let d;e[9]!==t.createdAt?(d=Tc.format(new Date(t.createdAt),"yyyy-MM-dd HH:mm"),e[9]=t.createdAt,e[10]=d):d=e[10];let u;e[11]!==d?(u=k.jsxRuntimeExports.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:d}),e[11]=d,e[12]=u):u=e[12];const h=t.status==="pending"?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400":"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400";let p;e[13]!==h?(p=k.cn("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",h),e[13]=h,e[14]=p):p=e[14];const f=t.status==="pending"?"미해결":"해결됨";let m;e[15]!==p||e[16]!==f?(m=k.jsxRuntimeExports.jsx("span",{className:p,children:f}),e[15]=p,e[16]=f,e[17]=m):m=e[17];let g;e[18]!==m||e[19]!==u?(g=k.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[u,m]}),e[18]=m,e[19]=u,e[20]=g):g=e[20];let y;e[21]!==g||e[22]!==c?(y=k.jsxRuntimeExports.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[c,g]}),e[21]=g,e[22]=c,e[23]=y):y=e[23];let w;e[24]!==i||e[25]!==y?(w=k.jsxRuntimeExports.jsxs("div",{className:"flex-1",children:[i,y]}),e[24]=i,e[25]=y,e[26]=w):w=e[26];let x;e[27]!==r||e[28]!==t.userId||e[29]!==s||e[30]!==o?(x=r===t.userId&&k.jsxRuntimeExports.jsxs(k.Popover,{children:[k.jsxRuntimeExports.jsx(k.PopoverTrigger,{asChild:!0,children:k.jsxRuntimeExports.jsx(k.Button,{size:"sm",variant:"ghost",className:"h-auto px-2 py-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:k.jsxRuntimeExports.jsx(Pe.MoreHorizontal,{className:"h-5 w-5"})})}),k.jsxRuntimeExports.jsx(k.PopoverContent,{className:"w-auto p-1 pointer-events-auto",children:k.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-1",children:[k.jsxRuntimeExports.jsxs(k.Button,{size:"sm",variant:"ghost",onClick:o,className:"justify-start text-xs text-gray-700 dark:text-gray-300",children:[k.jsxRuntimeExports.jsx(Pe.Edit2,{className:"mr-2 h-3 w-3"}),"수정"]}),k.jsxRuntimeExports.jsxs(k.Button,{size:"sm",variant:"ghost",onClick:s,className:"justify-start text-xs text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:[k.jsxRuntimeExports.jsx(Pe.Trash2,{className:"mr-2 h-3 w-3"}),"삭제"]})]})})]}),e[27]=r,e[28]=t.userId,e[29]=s,e[30]=o,e[31]=x):x=e[31];let E;return e[32]!==w||e[33]!==x?(E=k.jsxRuntimeExports.jsxs("div",{className:"mb-6 flex items-start justify-between",children:[w,x]}),e[32]=w,e[33]=x,e[34]=E):E=e[34],E},kk=n=>{const e=ln.compilerRuntimeExports.c(12),{feedback:t,isEditing:r,isUpdating:o,currentUserRole:s,feedbackEditorRef:i,titleInputRef:a,onEditCancel:l,onEditSave:c,onStatusChange:d}=n;let u;return e[0]!==s||e[1]!==t.feedbackDetail.body||e[2]!==t.feedbackDetail.title||e[3]!==t.status||e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==l||e[8]!==c||e[9]!==d||e[10]!==a?(u=k.jsxRuntimeExports.jsx("div",{className:"mb-6",children:r?k.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[k.jsxRuntimeExports.jsxs("div",{className:"rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50",children:[k.jsxRuntimeExports.jsx("label",{className:"mb-2 block text-xs font-medium text-gray-700 dark:text-gray-300",children:"제목"}),k.jsxRuntimeExports.jsx("input",{ref:a,type:"text",defaultValue:t.feedbackDetail.title,className:"w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm text-gray-900 placeholder-gray-400 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100 dark:placeholder-gray-500",placeholder:"피드백 제목을 입력하세요"})]}),k.jsxRuntimeExports.jsx(Do,{tiptapRef:i,initialContent:t.feedbackDetail.body,isSubmitting:o,onSubmit:c,onCancel:l,submitLabel:"수정",labelText:"피드백 수정",showLabel:!0})]}):k.jsxRuntimeExports.jsxs(k.jsxRuntimeExports.Fragment,{children:[k.jsxRuntimeExports.jsx("div",{className:"prose prose-sm dark:prose-invert mb-6 max-w-none text-gray-900 dark:text-gray-100",children:k.jsxRuntimeExports.jsx(Bh,{content:t.feedbackDetail.body})}),k.jsxRuntimeExports.jsx("div",{className:"w-full",children:k.jsxRuntimeExports.jsxs("div",{className:k.cn("flex items-center justify-between rounded-lg px-4 py-4 font-medium",t.status==="pending"?"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400":"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400"),children:[k.jsxRuntimeExports.jsxs("div",{children:[k.jsxRuntimeExports.jsxs("div",{className:"mb-1 text-sm font-semibold",children:[t.status==="pending"?"아직 미해결이에요":"해결되었어요"," ",t.status==="pending"?"⏳":"✓"]}),k.jsxRuntimeExports.jsx("div",{className:"text-xs opacity-90",children:t.status==="pending"?"담당자가 검토하고 있습니다. 조금 더 기다려주세요.":"소중한 피드백 감사합니다!"})]}),s==="admin"&&k.jsxRuntimeExports.jsxs(k.Button,{size:"sm",onClick:d,disabled:o,className:k.cn("shrink-0 gap-1",t.status==="pending"?"bg-yellow-700 hover:bg-yellow-800 dark:bg-yellow-600 dark:hover:bg-yellow-700":"bg-green-700 hover:bg-green-800 dark:bg-green-600 dark:hover:bg-green-700"),children:[o?k.jsxRuntimeExports.jsx(Pe.Loader2,{className:"h-4 w-4 animate-spin"}):k.jsxRuntimeExports.jsx(Pe.RefreshCw,{className:"h-4 w-4"}),t.status==="pending"?"해결":"미해결"]})]})})]})}),e[0]=s,e[1]=t.feedbackDetail.body,e[2]=t.feedbackDetail.title,e[3]=t.status,e[4]=i,e[5]=r,e[6]=o,e[7]=l,e[8]=c,e[9]=d,e[10]=a,e[11]=u):u=e[11],u},vk=()=>{const n=ln.compilerRuntimeExports.c(1),e=z.useRef(null),t=z.useRef(null),r=z.useRef(null),o=z.useRef(null),s=Sk,i=Ck,a=Mk;let l;return n[0]===Symbol.for("react.memo_cache_sentinel")?(l={commentEditorRef:e,replyEditorRef:t,editEditorRef:r,feedbackEditorRef:o,clearEditor:s,getEditorContent:i,validateContent:a},n[0]=l):l=n[0],l};function Sk(n){n.current?.editor?.commands?.clearContent?.()}function Ck(n){return n.current?.getJSON?.()??""}function Mk(n){return n?typeof n=="string"?n.trim().length>0:!0:!1}const Ek=({feedback:n,isFeedbackLoading:e,feedbackError:t,comments:r,isCommentsLoading:o,currentUser:s,onClose:i,callbacks:a,isDialog:l=!1})=>{const{commentEditorRef:c,replyEditorRef:d,editEditorRef:u,feedbackEditorRef:h,clearEditor:p,getEditorContent:f,validateContent:m}=vk(),[g,y]=z.useState(!1),[w,x]=z.useState(null),[E,b]=z.useState(null),[T,v]=z.useState(!1),S=z.useRef(null),[R,K]=z.useTransition(),[$,Y]=z.useTransition(),[pe,Z]=z.useTransition(),[U,X]=z.useTransition(),ee=r||[],L=async()=>{const J=f(c);if(!m(J))return a.onValidateError("empty");n?.id&&K(async()=>{try{await a.onCommentCreate(n.id,{body:J}),p(c),y(!1),a.onCommentChanged()}catch(oe){a.onError(oe)}})},Se=async J=>{const oe=f(d);if(!m(oe))return a.onValidateError("empty");n?.id&&K(async()=>{try{await a.onCommentCreate(n.id,{body:oe,refId:J}),p(d),x(null),a.onCommentChanged()}catch(F){a.onError(F)}})},Ce=async J=>{const oe=f(u);if(!m(oe))return a.onValidateError("empty");Y(async()=>{try{await a.onCommentUpdate(J,{body:oe}),b(null),p(u),a.onCommentChanged()}catch(F){a.onError(F)}})},C=async J=>{confirm("댓글을 삭제하시겠습니까?")&&Z(async()=>{try{await a.onCommentDelete(J),a.onCommentChanged()}catch(oe){a.onError(oe)}})},B=async()=>{const J=S.current?.value||"",oe=f(h);if(!m(J)){a.onValidateError("empty");return}if(!m(oe)){a.onValidateError("empty");return}n&&X(async()=>{try{await a.onFeedbackUpdate(n.id,{feedbackDetail:{title:J,body:oe}}),v(!1),p(h),a.onFeedbackChanged()}catch(F){a.onError(F)}})},V=async()=>{n&&X(async()=>{try{const J=n.status==="pending"?"resolved":"pending";await a.onFeedbackStatusUpdate?.(n.id,{status:J}),a.onFeedbackChanged()}catch(J){a.onError(J)}})},_=async()=>{if(confirm("피드백을 삭제하시겠습니까?")&&n?.id)try{await a.onDeleteFeedback(n.id),a.onFeedbackChanged(),i?i():window.close()}catch(J){a.onError(J)}};if(e){const J=k.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-center py-8",children:k.jsxRuntimeExports.jsx(Pe.Loader2,{className:"h-6 w-6 animate-spin text-gray-400"})});return l?J:k.jsxRuntimeExports.jsx("div",{className:"bg-background flex min-h-screen items-center justify-center",children:J})}if(t||!n){const J=k.jsxRuntimeExports.jsxs("div",{className:"flex flex-col items-center justify-center p-4",children:[k.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-red-50 p-4 text-sm text-red-700 dark:bg-red-900/20 dark:text-red-400",children:[k.jsxRuntimeExports.jsx(Pe.AlertCircle,{className:"h-4 w-4 shrink-0"}),k.jsxRuntimeExports.jsx("span",{children:"피드백을 불러오는데 실패했습니다."})]}),!l&&k.jsxRuntimeExports.jsx(k.Button,{onClick:()=>window.close(),variant:"ghost",size:"sm",className:"mt-4 text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100",children:"닫기"})]});return l?k.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-center py-8",children:J}):k.jsxRuntimeExports.jsx("div",{className:"bg-background flex min-h-screen flex-col items-center justify-center",children:J})}return k.jsxRuntimeExports.jsxs("div",{className:k.cn("bg-background flex flex-col",l?"h-auto":"min-h-screen"),children:[k.jsxRuntimeExports.jsx("div",{className:"shrink-0 border-b border-gray-200 py-4 dark:border-gray-700",children:k.jsxRuntimeExports.jsx("div",{className:"mx-auto max-w-4xl px-6",children:k.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between",children:k.jsxRuntimeExports.jsx("h1",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"피드백 상세"})})})}),k.jsxRuntimeExports.jsx("div",{className:"bg-background flex-1 overflow-y-auto",children:k.jsxRuntimeExports.jsxs("div",{className:"mx-auto max-w-4xl px-6 py-6",children:[k.jsxRuntimeExports.jsx(wk,{feedback:n,currentUserId:s?.id,onEditClick:()=>v(!0),onDeleteClick:_}),k.jsxRuntimeExports.jsx(kk,{feedback:n,isEditing:T,isUpdating:U,currentUserRole:s?.role,feedbackEditorRef:h,titleInputRef:S,onEditCancel:()=>v(!1),onEditSave:B,onStatusChange:V}),k.jsxRuntimeExports.jsx(k.Separator,{className:"mb-6 bg-gray-200 dark:bg-gray-700"}),k.jsxRuntimeExports.jsx(xk,{comments:ee,isLoading:o,isCommentEditOpen:g,onCommentEditOpen:y,commentEditorRef:c,onSubmitComment:L,isSubmitting:R,replyingToId:w,onReplyOpen:x,replyEditorRef:d,onSubmitReply:Se,editingId:E,onEdit:b,editEditorRef:u,onSubmitEdit:Ce,onDelete:C,isEditing:$||pe,currentUserId:s?.id})]})})]})};exports.FeedbackDetailPageContent=Ek;
154
154
  //# sourceMappingURL=index.js.map