@bigbinary/neeto-editor 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/index.js +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as e from"react";import t,{createContext as n,useContext as i,useState as r,useEffect as o,forwardRef as s,cloneElement as a,useLayoutEffect as l,useRef as c,Children as u,isValidElement as p,useCallback as d,useImperativeHandle as h}from"react";import f,{flushSync as m,createPortal as g}from"react-dom";import b from"http";import v from"https";import y from"url";import x from"stream";import w from"assert";import _ from"tty";import k from"util";import E from"os";import C from"zlib";import M from"path";import O from"fs";import{Field as D}from"formik";import{renderToString as T}from"react-dom/server";var S="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function N(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}function A(e){var t=e.default;if("function"==typeof t){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})})),n}var j=function(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]},L=j;var z=function(e){return function t(n){return 0===arguments.length||L(n)?t:e.apply(this,arguments)}};var I=function(e,t){return Object.prototype.hasOwnProperty.call(t,e)},R=I,F=Object.prototype.toString,B=function(){return"[object Arguments]"===F.call(arguments)?function(e){return"[object Arguments]"===F.call(e)}:function(e){return R("callee",e)}}(),P=B,U=Array.isArray||function(e){return null!=e&&e.length>=0&&"[object Array]"===Object.prototype.toString.call(e)};var H=function(e){return"[object Object]"===Object.prototype.toString.call(e)};var $=function(e){return"[object String]"===Object.prototype.toString.call(e)};var W=function(e){var t=Object.prototype.toString.call(e);return"[object Uint8ClampedArray]"===t||"[object Int8Array]"===t||"[object Uint8Array]"===t||"[object Int16Array]"===t||"[object Uint16Array]"===t||"[object Int32Array]"===t||"[object Uint32Array]"===t||"[object Float32Array]"===t||"[object Float64Array]"===t||"[object BigInt64Array]"===t||"[object BigUint64Array]"===t},q=P,V=U,K=H,G=$,Y=W,Q=z((function(e){return null!=e&&"function"==typeof e["fantasy-land/empty"]?e["fantasy-land/empty"]():null!=e&&null!=e.constructor&&"function"==typeof e.constructor["fantasy-land/empty"]?e.constructor["fantasy-land/empty"]():null!=e&&"function"==typeof e.empty?e.empty():null!=e&&null!=e.constructor&&"function"==typeof e.constructor.empty?e.constructor.empty():V(e)?[]:G(e)?"":K(e)?{}:q(e)?function(){return arguments}():Y(e)?e.constructor.from(""):void 0})),Z=Q,J=z,X=j;var ee=function(e){return function t(n,i){switch(arguments.length){case 0:return t;case 1:return X(n)?t:J((function(t){return e(n,t)}));default:return X(n)&&X(i)?t:X(n)?J((function(t){return e(t,i)})):X(i)?J((function(t){return e(n,t)})):e(n,i)}}};var te=function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n};var ne=function(e,t,n){for(var i=0,r=n.length;i<r;){if(e(t,n[i]))return!0;i+=1}return!1};var ie=function(e){var t=String(e).match(/^function (\w*)/);return null==t?"":t[1]};var re="function"==typeof Object.is?Object.is:function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},oe=z,se=I,ae=P,le=!{toString:null}.propertyIsEnumerable("toString"),ce=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],ue=function(){return arguments.propertyIsEnumerable("length")}(),pe=function(e,t){for(var n=0;n<e.length;){if(e[n]===t)return!0;n+=1}return!1},de="function"!=typeof Object.keys||ue?oe((function(e){if(Object(e)!==e)return[];var t,n,i=[],r=ue&&ae(e);for(t in e)!se(t,e)||r&&"length"===t||(i[i.length]=t);if(le)for(n=ce.length-1;n>=0;)se(t=ce[n],e)&&!pe(i,t)&&(i[i.length]=t),n-=1;return i})):oe((function(e){return Object(e)!==e?[]:Object.keys(e)})),he=te,fe=ne,me=ie,ge=I,be=re,ve=de,ye=z((function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)}));function xe(e,t,n,i){var r=he(e),o=he(t);function s(e,t){return we(e,t,n.slice(),i.slice())}return!fe((function(e,t){return!fe(s,t,e)}),o,r)}function we(e,t,n,i){if(be(e,t))return!0;var r=ye(e);if(r!==ye(t))return!1;if("function"==typeof e["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e);if("function"==typeof e.equals||"function"==typeof t.equals)return"function"==typeof e.equals&&e.equals(t)&&"function"==typeof t.equals&&t.equals(e);switch(r){case"Arguments":case"Array":case"Object":if("function"==typeof e.constructor&&"Promise"===me(e.constructor))return e===t;break;case"Boolean":case"Number":case"String":if(typeof e!=typeof t||!be(e.valueOf(),t.valueOf()))return!1;break;case"Date":if(!be(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(e.source!==t.source||e.global!==t.global||e.ignoreCase!==t.ignoreCase||e.multiline!==t.multiline||e.sticky!==t.sticky||e.unicode!==t.unicode)return!1}for(var o=n.length-1;o>=0;){if(n[o]===e)return i[o]===t;o-=1}switch(r){case"Map":return e.size===t.size&&xe(e.entries(),t.entries(),n.concat([e]),i.concat([t]));case"Set":return e.size===t.size&&xe(e.values(),t.values(),n.concat([e]),i.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var s=ve(e);if(s.length!==ve(t).length)return!1;var a=n.concat([e]),l=i.concat([t]);for(o=s.length-1;o>=0;){var c=s[o];if(!ge(c,t)||!we(t[c],e[c],a,l))return!1;o-=1}return!0}var _e=we,ke=ee((function(e,t){return _e(e,t,[],[])})),Ee=Z,Ce=ke,Me=z((function(e){return null!=e&&Ce(e,Ee(e))})),Oe=Me,De=z((function(e){return null==e})),Te=De;const Se=["img","iframe"],Ne=e=>e.toString().toLowerCase().replace(/\s+/g,"-").replace(/&/g,"-and-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""),Ae=e=>e=(e=e.replace(/[_-]+/g," ").replace(/\s{2,}/g," ").replace(/([a-z\d])([A-Z])/g,"$1"+" "+"$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g,"$1"+" "+"$2").toLowerCase().trim()).charAt(0).toUpperCase()+e.slice(1),je=e=>Te(e)||Oe(e),Le=()=>{},ze=e=>{if(je(e))return!0;if(Se.some((t=>e.includes(t))))return!1;const t=document.createElement("div");t.innerHTML=e;const n=je(t.textContent);return t.remove(),n};function Ie(){return Ie=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},Ie.apply(this,arguments)}function Re(e){this.content=e}function Fe(e,t,n){for(let i=0;;i++){if(i==e.childCount||i==t.childCount)return e.childCount==t.childCount?null:n;let r=e.child(i),o=t.child(i);if(r!=o){if(!r.sameMarkup(o))return n;if(r.isText&&r.text!=o.text){for(let e=0;r.text[e]==o.text[e];e++)n++;return n}if(r.content.size||o.content.size){let e=Fe(r.content,o.content,n+1);if(null!=e)return e}n+=r.nodeSize}else n+=r.nodeSize}}function Be(e,t,n,i){for(let r=e.childCount,o=t.childCount;;){if(0==r||0==o)return r==o?null:{a:n,b:i};let s=e.child(--r),a=t.child(--o),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:i};if(s.isText&&s.text!=a.text){let e=0,t=Math.min(s.text.length,a.text.length);for(;e<t&&s.text[s.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,i--;return{a:n,b:i}}if(s.content.size||a.content.size){let e=Be(s.content,a.content,n-1,i-1);if(e)return e}n-=l,i-=l}else n-=l,i-=l}}Re.prototype={constructor:Re,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var i=n&&n!=e?this.remove(n):this,r=i.find(e),o=i.content.slice();return-1==r?o.push(n||e,t):(o[r+1]=t,n&&(o[r]=n)),new Re(o)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new Re(n)},addToStart:function(e,t){return new Re([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Re(n)},addBefore:function(e,t,n){var i=this.remove(t),r=i.content.slice(),o=i.find(e);return r.splice(-1==o?r.length:o,0,t,n),new Re(r)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=Re.from(e)).size?new Re(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=Re.from(e)).size?new Re(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Re.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach((function(t,n){e[t]=n})),e},get size(){return this.content.length>>1}},Re.from=function(e){if(e instanceof Re)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Re(t)};class Pe{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,i=0,r){for(let o=0,s=0;s<t;o++){let a=this.content[o],l=s+a.nodeSize;if(l>e&&!1!==n(a,i+s,r||null,o)&&a.content.size){let r=s+1;a.nodesBetween(Math.max(0,e-r),Math.min(a.content.size,t-r),n,i+r)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let r="",o=!0;return this.nodesBetween(e,t,((s,a)=>{s.isText?(r+=s.text.slice(Math.max(e,a)-a,t-a),o=!n):s.isLeaf?(i?r+="function"==typeof i?i(s):i:s.type.spec.leafText&&(r+=s.type.spec.leafText(s)),o=!n):!o&&s.isBlock&&(r+=n,o=!0)}),0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),r=1);r<e.content.length;r++)i.push(e.content[r]);return new Pe(i,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],i=0;if(t>e)for(let r=0,o=0;o<t;r++){let s=this.content[r],a=o+s.nodeSize;a>e&&((o<e||a>t)&&(s=s.isText?s.cut(Math.max(0,e-o),Math.min(s.text.length,t-o)):s.cut(Math.max(0,e-o-1),Math.min(s.content.size,t-o-1))),n.push(s),i+=s.nodeSize),o=a}return new Pe(n,i)}cutByIndex(e,t){return e==t?Pe.empty:0==e&&t==this.content.length?this:new Pe(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),r=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new Pe(i,r)}addToStart(e){return new Pe([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Pe(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,n=0;t<this.content.length;t++){let i=this.content[t];e(i,n,t),n+=i.nodeSize}}findDiffStart(e,t=0){return Fe(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Be(this,e,t,n)}findIndex(e,t=-1){if(0==e)return He(0,e);if(e==this.size)return He(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,i=0;;n++){let r=i+this.child(n).nodeSize;if(r>=e)return r==e||t>0?He(n+1,r):He(n,i);i=r}}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 Pe.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new Pe(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Pe.empty;let t,n=0;for(let i=0;i<e.length;i++){let r=e[i];n+=r.nodeSize,i&&r.isText&&e[i-1].sameMarkup(r)?(t||(t=e.slice(0,i)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new Pe(t||e,n)}static from(e){if(!e)return Pe.empty;if(e instanceof Pe)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Pe([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Pe.empty=new Pe([],0);const Ue={index:0,offset:0};function He(e,t){return Ue.index=e,Ue.offset=t,Ue}function $e(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!$e(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!$e(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class We{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let i=0;i<e.length;i++){let r=e[i];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,i));else{if(r.type.excludes(this.type))return e;!n&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(r)}}return t||(t=e.slice()),n||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&&$e(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 n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return We.none;if(e instanceof We)return[e];let t=e.slice();return t.sort(((e,t)=>e.type.rank-t.type.rank)),t}}We.none=[];class qe extends Error{}class Ve{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Ge(this.content,e+this.openStart,t);return n&&new Ve(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Ve(Ke(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 Ve.empty;let n=t.openStart||0,i=t.openEnd||0;if("number"!=typeof n||"number"!=typeof i)throw new RangeError("Invalid input for Slice.fromJSON");return new Ve(Pe.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)i++;return new Ve(e,n,i)}}function Ke(e,t,n){let{index:i,offset:r}=e.findIndex(t),o=e.maybeChild(i),{index:s,offset:a}=e.findIndex(n);if(r==t||o.isText){if(a!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(i!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(i,o.copy(Ke(o.content,t-r-1,n-r-1)))}function Ge(e,t,n,i){let{index:r,offset:o}=e.findIndex(t),s=e.maybeChild(r);if(o==t||s.isText)return i&&!i.canReplace(r,r,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=Ge(s.content,t-o-1,n);return a&&e.replaceChild(r,s.copy(a))}function Ye(e,t,n){if(n.openStart>e.depth)throw new qe("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new qe("Inconsistent open depths");return Qe(e,t,n,0)}function Qe(e,t,n,i){let r=e.index(i),o=e.node(i);if(r==t.index(i)&&i<e.depth-n.openStart){let s=Qe(e,t,n,i+1);return o.copy(o.content.replaceChild(r,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=i||t.depth!=i){let{start:r,end:s}=function(e,t){let n=t.depth-e.openStart,i=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)i=t.node(e).copy(Pe.from(i));return{start:i.resolveNoCache(e.openStart+n),end:i.resolveNoCache(i.content.size-e.openEnd-n)}}(n,e);return tt(o,nt(e,r,s,t,i))}{let i=e.parent,r=i.content;return tt(i,r.cut(0,e.parentOffset).append(n.content).append(r.cut(t.parentOffset)))}}return tt(o,it(e,t,i))}function Ze(e,t){if(!t.type.compatibleContent(e.type))throw new qe("Cannot join "+t.type.name+" onto "+e.type.name)}function Je(e,t,n){let i=e.node(n);return Ze(i,t.node(n)),i}function Xe(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function et(e,t,n,i){let r=(t||e).node(n),o=0,s=t?t.index(n):r.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(Xe(e.nodeAfter,i),o++));for(let e=o;e<s;e++)Xe(r.child(e),i);t&&t.depth==n&&t.textOffset&&Xe(t.nodeBefore,i)}function tt(e,t){if(!e.type.validContent(t))throw new qe("Invalid content for node "+e.type.name);return e.copy(t)}function nt(e,t,n,i,r){let o=e.depth>r&&Je(e,t,r+1),s=i.depth>r&&Je(n,i,r+1),a=[];return et(null,e,r,a),o&&s&&t.index(r)==n.index(r)?(Ze(o,s),Xe(tt(o,nt(e,t,n,i,r+1)),a)):(o&&Xe(tt(o,it(e,t,r+1)),a),et(t,n,r,a),s&&Xe(tt(s,it(n,i,r+1)),a)),et(i,null,r,a),new Pe(a)}function it(e,t,n){let i=[];if(et(null,e,n,i),e.depth>n){Xe(tt(Je(e,t,n+1),it(e,t,n+1)),i)}return et(t,null,n,i),new Pe(i)}Ve.empty=new Ve(Pe.empty,0,0);class rt{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?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[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):i}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):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],i=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)i+=n.child(t).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return We.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),i=e.maybeChild(t);if(!n){let e=n;n=i,i=e}let r=n.marks;for(var o=0;o<r.length;o++)!1!==r[o].type.spec.inclusive||i&&r[o].isInSet(i.marks)||(r=r[o--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,i=e.parent.maybeChild(e.index());for(var r=0;r<n.length;r++)!1!==n[r].type.spec.inclusive||i&&n[r].isInSet(i.marks)||(n=n[r--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new lt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],i=0,r=t;for(let t=e;;){let{index:e,offset:o}=t.content.findIndex(r),s=r-o;if(n.push(t,e,i+o),!s)break;if(t=t.child(e),t.isText)break;r=s-1,i+=o+1}return new rt(t,n,r)}static resolveCached(e,t){for(let n=0;n<ot.length;n++){let i=ot[n];if(i.pos==t&&i.doc==e)return i}let n=ot[st]=rt.resolve(e,t);return st=(st+1)%at,n}}let ot=[],st=0,at=12;class lt{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const ct=Object.create(null);class ut{constructor(e,t,n,i=We.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||Pe.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,i=0){this.content.nodesBetween(e,t,n,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,i){return this.content.textBetween(e,t,n,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&$e(this.attrs,t||e.defaultAttrs||ct)&&We.sameSet(this.marks,n||We.none)}copy(e=null){return e==this.content?this:new ut(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ut(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Ve.empty;let i=this.resolve(e),r=this.resolve(t),o=n?0:i.sharedDepth(t),s=i.start(o),a=i.node(o).content.cut(i.pos-s,r.pos-s);return new Ve(a,i.depth-o,r.depth-o)}replace(e,t,n){return Ye(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let i=this.content.child(t-1);return{node:i,index:t-1,offset:n-i.nodeSize}}resolve(e){return rt.resolveCached(this,e)}resolveNoCache(e){return rt.resolve(this,e)}rangeHasMark(e,t,n){let i=!1;return t>e&&this.nodesBetween(e,t,(e=>(n.isInSet(e.marks)&&(i=!0),!i))),i}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()+")"),dt(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,n=Pe.empty,i=0,r=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,i,r),s=o&&o.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=i;e<r;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,i){if(i&&!this.type.allowsMarks(i))return!1;let r=this.contentMatchAt(e).matchType(n),o=r&&r.matchFragment(this.content,t);return!!o&&o.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){if(!this.type.validContent(this.content))throw new RangeError(`Invalid content for node ${this.type.name}: ${this.content.toString().slice(0,50)}`);let e=We.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!We.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e=>e.type.name))}`);this.content.forEach((e=>e.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((e=>e.toJSON()))),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let i=Pe.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,n)}}ut.prototype.text=void 0;class pt extends ut{constructor(e,t,n,i){if(super(e,t,null,i),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):dt(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 pt(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new pt(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&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 dt(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class ht{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new ft(e,t);if(null==n.next)return ht.empty;let i=mt(n);n.next&&n.err("Unexpected trailing text");let r=function(e){let t=Object.create(null);return n(wt(e,0));function n(i){let r=[];i.forEach((t=>{e[t].forEach((({term:t,to:n})=>{if(!t)return;let i;for(let e=0;e<r.length;e++)r[e][0]==t&&(i=r[e][1]);wt(e,n).forEach((e=>{i||r.push([t,i=[]]),-1==i.indexOf(e)&&i.push(e)}))}))}));let o=t[i.join(",")]=new ht(i.indexOf(e.length-1)>-1);for(let e=0;e<r.length;e++){let i=r[e][1].sort(xt);o.next.push({type:r[e][0],next:t[i.join(",")]||n(i)})}return o}}(function(e){let t=[[]];return r(o(e,0),n()),t;function n(){return t.push([])-1}function i(e,n,i){let r={term:i,to:n};return t[e].push(r),r}function r(e,t){e.forEach((e=>e.to=t))}function o(e,t){if("choice"==e.type)return e.exprs.reduce(((e,n)=>e.concat(o(n,t))),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return i(t,s),r(o(e.expr,s),s),[i(s)]}if("plus"==e.type){let s=n();return r(o(e.expr,t),s),r(o(e.expr,s),s),[i(s)]}if("opt"==e.type)return[i(t)].concat(o(e.expr,t));if("range"==e.type){let s=t;for(let t=0;t<e.min;t++){let t=n();r(o(e.expr,s),t),s=t}if(-1==e.max)r(o(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=n();i(s,t),r(o(e.expr,s),t),s=t}return[i(s)]}if("name"==e.type)return[i(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let i=0;;i++){let s=o(e.exprs[i],t);if(i==e.exprs.length-1)return s;r(s,t=n())}}}(i));return function(e,t){for(let n=0,i=[e];n<i.length;n++){let e=i[n],r=!e.validEnd,o=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];o.push(n.name),!r||n.isText||n.hasRequiredAttrs()||(r=!1),-1==i.indexOf(s)&&i.push(s)}r&&t.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(r,n),r}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let i=this;for(let r=t;i&&r<n;r++)i=i.matchType(e.child(r).type);return i}get inlineContent(){return this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let i=[this];return function r(o,s){let a=o.matchFragment(e,n);if(a&&(!t||a.validEnd))return Pe.from(s.map((e=>e.createAndFill())));for(let e=0;e<o.next.length;e++){let{type:t,next:n}=o.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==i.indexOf(n)){i.push(n);let e=r(n,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let i=n.shift(),r=i.match;if(r.matchType(e)){let e=[];for(let t=i;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<r.next.length;e++){let{type:o,next:s}=r.next[e];o.isLeaf||o.hasRequiredAttrs()||o.name in t||i.type&&!s.validEnd||(n.push({match:o.contentMatch,type:o,via:i}),t[o.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=[];return function t(n){e.push(n);for(let i=0;i<n.next.length;i++)-1==e.indexOf(n.next[i].next)&&t(n.next[i].next)}(this),e.map(((t,n)=>{let i=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)i+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return i})).join("\n")}}ht.empty=new ht(!0);class ft{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 mt(e){let t=[];do{t.push(gt(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function gt(e){let t=[];do{t.push(bt(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function bt(e){let t=function(e){if(e.eat("(")){let t=mt(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,i=n[t];if(i)return[i];let r=[];for(let e in n){let i=n[e];i.groups.indexOf(t)>-1&&r.push(i)}0==r.length&&e.err("No node type or group '"+t+"' found");return r}(e,e.next).map((t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t})));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=yt(e,t)}return t}function vt(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function yt(e,t){let n=vt(e),i=n;return e.eat(",")&&(i="}"!=e.next?vt(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:i,expr:t}}function xt(e,t){return t-e}function wt(e,t){let n=[];return function t(i){let r=e[i];if(1==r.length&&!r[0].term)return t(r[0].to);n.push(i);for(let e=0;e<r.length;e++){let{term:i,to:o}=r[e];i||-1!=n.indexOf(o)||t(o)}}(t),n.sort(xt)}function _t(e){let t=Object.create(null);for(let n in e){let i=e[n];if(!i.hasDefault)return null;t[n]=i.default}return t}function kt(e,t){let n=Object.create(null);for(let i in e){let r=t&&t[i];if(void 0===r){let t=e[i];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+i);r=t.default}n[i]=r}return n}function Et(e){let t=Object.create(null);if(e)for(let n in e)t[n]=new Mt(e[n]);return t}class Ct{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=Et(n.attrs),this.defaultAttrs=_t(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ht.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}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:kt(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ut(this,this.computeAttrs(e),Pe.from(t),We.setFrom(n))}createChecked(e=null,t,n){if(t=Pe.from(t),!this.validContent(t))throw new RangeError("Invalid content for node "+this.name);return new ut(this,this.computeAttrs(e),t,We.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=Pe.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let i=this.contentMatch.matchFragment(t),r=i&&i.fillBefore(Pe.empty,!0);return r?new ut(this,e,t.append(r),We.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:We.none:e}static compile(e,t){let n=Object.create(null);e.forEach(((e,i)=>n[e]=new Ct(e,t,i)));let i=t.spec.topNode||"doc";if(!n[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class Mt{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class Ot{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=Et(i.attrs),this.excluded=null;let r=_t(this.attrs);this.instance=r?new We(this,r):null}create(e=null){return!e&&this.instance?this.instance:new We(this,kt(this.attrs,e))}static compile(e,t){let n=Object.create(null),i=0;return e.forEach(((e,r)=>n[e]=new Ot(e,i++,t,r))),n}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]}excludes(e){return this.excluded.indexOf(e)>-1}}class Dt{constructor(e){this.cached=Object.create(null),this.spec={nodes:Re.from(e.nodes),marks:Re.from(e.marks||{}),topNode:e.topNode},this.nodes=Ct.compile(this.spec.nodes,this),this.marks=Ot.compile(this.spec.marks,this);let t=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let n=this.nodes[e],i=n.spec.content||"",r=n.spec.marks;n.contentMatch=t[i]||(t[i]=ht.parse(i,this.nodes)),n.inlineContent=n.contentMatch.inlineContent,n.markSet="_"==r?null:r?Tt(this,r.split(" ")):""!=r&&n.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:Tt(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,i){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Ct))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,i)}text(e,t){let n=this.nodes.text;return new pt(n,n.defaultAttrs,e,We.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return ut.fromJSON(this,e)}markFromJSON(e){return We.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Tt(e,t){let n=[];for(let i=0;i<t.length;i++){let r=t[i],o=e.marks[r],s=o;if(o)n.push(o);else for(let t in e.marks){let i=e.marks[t];("_"==r||i.spec.group&&i.spec.group.split(" ").indexOf(r)>-1)&&n.push(s=i)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[i]+"'")}return n}class St{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach((e=>{e.tag?this.tags.push(e):e.style&&this.styles.push(e)})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)}))}parse(e,t={}){let n=new Bt(this,t,!1);return n.addAll(e,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Bt(this,t,!0);return n.addAll(e,t.from,t.to),Ve.maxOpen(n.finish())}matchTag(e,t,n){for(let i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){let n=this.tags[i];if(Pt(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,i){for(let r=i?this.styles.indexOf(i)+1:0;r<this.styles.length;r++){let i=this.styles[r],o=i.style;if(!(0!=o.indexOf(e)||i.context&&!n.matchesContext(i.context)||o.length>e.length&&(61!=o.charCodeAt(e.length)||o.slice(e.length+1)!=t))){if(i.getAttrs){let e=i.getAttrs(t);if(!1===e)continue;i.attrs=e||void 0}return i}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,i=0;for(;i<t.length;i++){let e=t[i];if((null==e.priority?50:e.priority)<n)break}t.splice(i,0,e)}for(let t in e.marks){let i=e.marks[t].spec.parseDOM;i&&i.forEach((e=>{n(e=Ut(e)),e.mark=t}))}for(let t in e.nodes){let i=e.nodes[t].spec.parseDOM;i&&i.forEach((e=>{n(e=Ut(e)),e.node=t}))}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new St(e,St.schemaRules(e)))}}const Nt={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},At={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},jt={ol:!0,ul:!0},Lt=1,zt=2,It=4;function Rt(e,t,n){return null!=t?(t?Lt:0)|("full"===t?zt:0):e&&"pre"==e.whitespace?Lt|zt:n&~It}class Ft{constructor(e,t,n,i,r,o,s){this.type=e,this.attrs=t,this.marks=n,this.pendingMarks=i,this.solid=r,this.options=s,this.content=[],this.activeMarks=We.none,this.stashMarks=[],this.match=o||(s&It?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(Pe.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Lt)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=Pe.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(Pe.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,n=this.pendingMarks;t<n.length;t++){let i=n[t];(this.type?this.type.allowsMarkType(i.type):Ht(i.type,e))&&!i.isInSet(this.activeMarks)&&(this.activeMarks=i.addToSet(this.activeMarks),this.pendingMarks=i.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Nt.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Bt{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0;let i,r=t.topNode,o=Rt(null,t.preserveWhitespace,0)|(n?It:0);i=r?new Ft(r.type,r.attrs,We.none,We.none,!0,t.topMatch||r.type.contentMatch,o):new Ft(n?null:e.schema.topNodeType,null,We.none,We.none,!0,null,o),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){if(3==e.nodeType)this.addTextNode(e);else if(1==e.nodeType){let t=e.getAttribute("style"),n=t?this.readStyles(function(e){let t,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,i=[];for(;t=n.exec(e);)i.push(t[1],t[2].trim());return i}(t)):null,i=this.top;if(null!=n)for(let e=0;e<n.length;e++)this.addPendingMark(n[e]);if(this.addElement(e),null!=n)for(let e=0;e<n.length;e++)this.removePendingMark(n[e],i)}}addTextNode(e){let t=e.nodeValue,n=this.top;if(n.options&zt||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(n.options&Lt)t=n.options&zt?t.replace(/\r\n?/g,"\n"):t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){let i=n.content[n.content.length-1],r=e.previousSibling;(!i||r&&"BR"==r.nodeName||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let n,i=e.nodeName.toLowerCase();jt.hasOwnProperty(i)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&jt.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let r=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(n=this.parser.matchTag(e,this,t));if(r?r.ignore:At.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e);else if(!r||r.skip||r.closeParent){r&&r.closeParent?this.open=Math.max(0,this.open-1):r&&r.skip.nodeType&&(e=r.skip);let t,n=this.top,o=this.needsBlock;if(Nt.hasOwnProperty(i))t=!0,n.type||(this.needsBlock=!0);else if(!e.firstChild)return void this.leafFallback(e);this.addAll(e),t&&this.sync(n),this.needsBlock=o}else this.addElementByRule(e,r,!1===r.consuming?n:void 0)}leafFallback(e){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"))}ignoreFallback(e){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=We.none;e:for(let n=0;n<e.length;n+=2)for(let i;;){let r=this.parser.matchStyle(e[n],e[n+1],this,i);if(!r)continue e;if(r.ignore)return null;if(t=this.parser.schema.marks[r.mark].create(r.attrs).addToSet(t),!1!==r.consuming)break;i=r}return t}addElementByRule(e,t,n){let i,r,o;if(t.node)r=this.parser.schema.nodes[t.node],r.isLeaf?this.insertNode(r.create(t.attrs))||this.leafFallback(e):i=this.enter(r,t.attrs||null,t.preserveWhitespace);else{o=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(o)}let s=this.top;if(r&&r.isLeaf)this.findInside(e);else if(n)this.addElement(e,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((e=>this.insertNode(e)));else{let n=e;"string"==typeof t.contentElement?n=e.querySelector(t.contentElement):"function"==typeof t.contentElement?n=t.contentElement(e):t.contentElement&&(n=t.contentElement),this.findAround(e,n,!0),this.addAll(n)}i&&this.sync(s)&&this.open--,o&&this.removePendingMark(o,s)}addAll(e,t,n){let i=t||0;for(let r=t?e.childNodes[t]:e.firstChild,o=null==n?null:e.childNodes[n];r!=o;r=r.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(r);this.findAtPoint(e,i)}findPlace(e){let t,n;for(let i=this.open;i>=0;i--){let r=this.nodes[i],o=r.findWrapping(e);if(o&&(!t||t.length>o.length)&&(t=o,n=r,!o.length))break;if(r.solid)break}if(!t)return!1;this.sync(n);for(let e=0;e<t.length;e++)this.enterInner(t[e],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let n=t.activeMarks;for(let i=0;i<e.marks.length;i++)t.type&&!t.type.allowsMarkType(e.marks[i].type)||(n=e.marks[i].addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n){let i=this.findPlace(e.create(t));return i&&this.enterInner(e,t,!0,n),i}enterInner(e,t=null,n=!1,i){this.closeExtra();let r=this.top;r.applyPending(e),r.match=r.match&&r.match.matchType(e);let o=Rt(e,i,r.options);r.options&It&&0==r.content.length&&(o|=It),this.nodes.push(new Ft(e,t,r.activeMarks,r.pendingMarks,n,null,o)),this.open++}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;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)if(null==this.find[i].pos&&1==e.nodeType&&e.contains(this.find[i].node)){t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),r=-(n?n.depth+1:0)+(i?0:1),o=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=r;s--)if(o(e-1,s))return!0;return!1}{let e=s>0||0==s&&i?this.nodes[s].type:n&&s>=r?n.node(s-r).type:null;if(!e||e.name!=a&&-1==e.groups.indexOf(a))return!1;s--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}addPendingMark(e){let t=function(e,t){for(let n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let n=this.open;n>=0;n--){let i=this.nodes[n];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let t=i.popFromStashMark(e);t&&i.type&&i.type.allowsMarkType(t.type)&&(i.activeMarks=t.addToSet(i.activeMarks))}if(i==t)break}}}function Pt(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Ut(e){let t={};for(let n in e)t[n]=e[n];return t}function Ht(e,t){let n=t.schema.nodes;for(let i in n){let r=n[i];if(!r.allowsMarkType(e))continue;let o=[],s=e=>{o.push(e);for(let n=0;n<e.edgeCount;n++){let{type:i,next:r}=e.edge(n);if(i==t)return!0;if(o.indexOf(r)<0&&s(r))return!0}};if(s(r.contentMatch))return!0}}class $t{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=qt(t).createDocumentFragment());let i=n,r=[];return e.forEach((e=>{if(r.length||e.marks.length){let n=0,o=0;for(;n<r.length&&o<e.marks.length;){let t=e.marks[o];if(this.marks[t.type.name]){if(!t.eq(r[n][0])||!1===t.type.spec.spanning)break;n++,o++}else o++}for(;n<r.length;)i=r.pop()[1];for(;o<e.marks.length;){let n=e.marks[o++],s=this.serializeMark(n,e.isInline,t);s&&(r.push([n,i]),i.appendChild(s.dom),i=s.contentDOM||s.dom)}}i.appendChild(this.serializeNodeInner(e,t))})),n}serializeNodeInner(e,t){let{dom:n,contentDOM:i}=$t.renderSpec(qt(t),this.nodes[e.type.name](e));if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let r=this.serializeMark(e.marks[i],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&$t.renderSpec(qt(n),i(e,t))}static renderSpec(e,t,n=null){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let i,r=t[0],o=r.indexOf(" ");o>0&&(n=r.slice(0,o),r=r.slice(o+1));let s=n?e.createElementNS(n,r):e.createElement(r),a=t[1],l=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a)){l=2;for(let e in a)if(null!=a[e]){let t=e.indexOf(" ");t>0?s.setAttributeNS(e.slice(0,t),e.slice(t+1),a[e]):s.setAttribute(e,a[e])}}for(let r=l;r<t.length;r++){let o=t[r];if(0===o){if(r<t.length-1||r>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}{let{dom:t,contentDOM:r}=$t.renderSpec(e,o,n);if(s.appendChild(t),r){if(i)throw new RangeError("Multiple content holes");i=r}}}return{dom:s,contentDOM:i}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new $t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Wt(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return Wt(e.marks)}}function Wt(e){let t={};for(let n in e){let i=e[n].spec.toDOM;i&&(t[n]=i)}return t}function qt(e){return e.document||window.document}const Vt=65535,Kt=Math.pow(2,16);function Gt(e,t){return e+t*Kt}function Yt(e){return e&Vt}const Qt=1,Zt=2,Jt=4,Xt=8;class en{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Xt)>0}get deletedBefore(){return(this.delInfo&(Qt|Jt))>0}get deletedAfter(){return(this.delInfo&(Zt|Jt))>0}get deletedAcross(){return(this.delInfo&Jt)>0}}class tn{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&tn.empty)return tn.empty}recover(e){let t=0,n=Yt(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(e&Vt))/Kt}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,r=this.inverted?2:1,o=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?i:0);if(a>e)break;let l=this.ranges[s+r],c=this.ranges[s+o],u=a+l;if(e<=u){let r=a+i+((l?e==a?-1:e==u?1:t:t)<0?0:c);if(n)return r;let o=e==(t<0?a:u)?null:Gt(s/3,e-a),p=e==a?Zt:e==u?Qt:Jt;return(t<0?e!=a:e!=u)&&(p|=Xt),new en(r,p,o)}i+=c-l}return n?e+i:new en(e+i,0,null)}touches(e,t){let n=0,i=Yt(t),r=this.inverted?2:1,o=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let a=this.ranges[t+r];if(e<=s+a&&t==3*i)return!0;n+=this.ranges[t+o]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,r=0;i<this.ranges.length;i+=3){let o=this.ranges[i],s=o-(this.inverted?r:0),a=o+(this.inverted?0:r),l=this.ranges[i+t],c=this.ranges[i+n];e(s,s+l,a,a+c),r+=c-l}}invert(){return new tn(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?tn.empty:new tn(e<0?[0,-e,0]:[0,0,e])}}tn.empty=new tn([]);class nn{constructor(e=[],t,n=0,i=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=i}slice(e=0,t=this.maps.length){return new nn(this.maps,this.mirror,e,t)}copy(){return new nn(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,n=this.maps.length;t<e.maps.length;t++){let i=e.getMirror(t);this.appendMap(e.maps[t],null!=i&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=i&&i>t?n-i-1:void 0)}}invert(){let e=new nn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let n=this.from;n<this.to;n++){let r=this.maps[n].mapResult(e,t);if(null!=r.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this.maps[t].recover(r.recover);continue}}i|=r.delInfo,e=r.pos}return n?e:new en(e,i,null)}}const rn=Object.create(null);class on{getMap(){return tn.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=rn[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in rn)throw new RangeError("Duplicate use of step JSON ID "+e);return rn[e]=t,t.prototype.jsonID=e,t}}class sn{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new sn(e,null)}static fail(e){return new sn(null,e)}static fromReplace(e,t,n,i){try{return sn.ok(e.replace(t,n,i))}catch(e){if(e instanceof qe)return sn.fail(e.message);throw e}}}function an(e,t,n){let i=[];for(let r=0;r<e.childCount;r++){let o=e.child(r);o.content.size&&(o=o.copy(an(o.content,t,o))),o.isInline&&(o=t(o,n,r)),i.push(o)}return Pe.fromArray(i)}class ln extends on{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),r=new Ve(an(t.content,((e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),i),t.openStart,t.openEnd);return sn.fromReplace(e,this.from,this.to,r)}invert(){return new cn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ln(t.pos,n.pos,this.mark)}merge(e){return e instanceof ln&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ln(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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ln(t.from,t.to,e.markFromJSON(t.mark))}}on.jsonID("addMark",ln);class cn extends on{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Ve(an(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return sn.fromReplace(e,this.from,this.to,n)}invert(){return new ln(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new cn(t.pos,n.pos,this.mark)}merge(e){return e instanceof cn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new cn(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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new cn(t.from,t.to,e.markFromJSON(t.mark))}}on.jsonID("removeMark",cn);class un extends on{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return sn.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return sn.fromReplace(e,this.pos,this.pos+1,new Ve(Pe.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new un(this.pos,t.marks[n]);return new un(this.pos,this.mark)}}return new pn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new un(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new un(t.pos,e.markFromJSON(t.mark))}}on.jsonID("addNodeMark",un);class pn extends on{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return sn.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return sn.fromReplace(e,this.pos,this.pos+1,new Ve(Pe.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new un(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new pn(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new pn(t.pos,e.markFromJSON(t.mark))}}on.jsonID("removeNodeMark",pn);class dn extends on{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&fn(e,this.from,this.to)?sn.fail("Structure replace would overwrite content"):sn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new tn([this.from,this.to-this.from,this.slice.size])}invert(e){return new dn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new dn(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof dn)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?Ve.empty:new Ve(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new dn(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Ve.empty:new Ve(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new dn(this.from,this.to+(e.to-e.from),t,this.structure)}}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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new dn(t.from,t.to,Ve.fromJSON(e,t.slice),!!t.structure)}}on.jsonID("replace",dn);class hn extends on{constructor(e,t,n,i,r,o,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=r,this.insert=o,this.structure=s}apply(e){if(this.structure&&(fn(e,this.from,this.gapFrom)||fn(e,this.gapTo,this.to)))return sn.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return sn.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?sn.fromReplace(e,this.from,this.to,n):sn.fail("Content does not fit in gap")}getMap(){return new tn([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 hn(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=e.map(this.gapFrom,-1),r=e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||r>n.pos?null:new hn(t.pos,n.pos,i,r,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("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new hn(t.from,t.to,t.gapFrom,t.gapTo,Ve.fromJSON(e,t.slice),t.insert,!!t.structure)}}function fn(e,t,n){let i=e.resolve(t),r=n-t,o=i.depth;for(;r>0&&o>0&&i.indexAfter(o)==i.node(o).childCount;)o--,r--;if(r>0){let e=i.node(o).maybeChild(i.indexAfter(o));for(;r>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,r--}}return!1}function mn(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function gn(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let i=e.$from.node(n),r=e.$from.index(n),o=e.$to.indexAfter(n);if(n<e.depth&&i.canReplace(r,o,t))return n;if(0==n||i.type.spec.isolating||!mn(i,r,o))break}return null}function bn(e,t,n=null,i=e){let r=function(e,t){let{parent:n,startIndex:i,endIndex:r}=e,o=n.contentMatchAt(i).findWrapping(t);if(!o)return null;let s=o.length?o[0]:t;return n.canReplaceWith(i,r,s)?o:null}(e,t),o=r&&function(e,t){let{parent:n,startIndex:i,endIndex:r}=e,o=n.child(i),s=t.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:t).contentMatch;for(let e=i;a&&e<r;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?s:null}(i,t);return o?r.map(vn).concat({type:t,attrs:n}).concat(o.map(vn)):null}function vn(e){return{type:e,attrs:null}}function yn(e,t,n=1,i){let r=e.resolve(t),o=r.depth-n,s=i&&i[i.length-1]||r.parent;if(o<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let e=r.depth-1,t=n-2;e>o;e--,t--){let n=r.node(e),o=r.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(o,n.childCount),a=i&&i[t]||n;if(a!=n&&(s=s.replaceChild(0,a.type.create(a.attrs))),!n.canReplace(o+1,n.childCount)||!a.type.validContent(s))return!1}let a=r.indexAfter(o),l=i&&i[0];return r.node(o).canReplaceWith(a,a,l?l.type:r.node(o+1).type)}function xn(e,t){let n=e.resolve(t),i=n.index();return function(e,t){return!(!e||!t||e.isLeaf||!e.canAppend(t))}(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(i,i+1)}function wn(e,t,n){let i=e.resolve(t);if(!n.content.size)return t;let r=n.content;for(let e=0;e<n.openStart;e++)r=r.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=i.depth;t>=0;t--){let n=t==i.depth?0:i.pos<=(i.start(t+1)+i.end(t+1))/2?-1:1,o=i.index(t)+(n>0?1:0),s=i.node(t),a=!1;if(1==e)a=s.canReplace(o,o,r);else{let e=s.contentMatchAt(o).findWrapping(r.firstChild.type);a=e&&s.canReplaceWith(o,o,e[0])}if(a)return 0==n?i.pos:n<0?i.before(t+1):i.after(t+1)}return null}function _n(e,t,n=t,i=Ve.empty){if(t==n&&!i.size)return null;let r=e.resolve(t),o=e.resolve(n);return kn(r,o,i)?new dn(t,n,i):new En(r,o,i).fit()}function kn(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}on.jsonID("replaceAround",hn);class En{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=Pe.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=Pe.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let r=this.placed,o=n.depth,s=i.depth;for(;o&&s&&1==r.childCount;)r=r.firstChild.content,o--,s--;let a=new Ve(r,o,s);return e>-1?new hn(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new dn(n.pos,i.pos,a):null}findFittable(){for(let e=1;e<=2;e++)for(let t=this.unplaced.openStart;t>=0;t--){let n,i=null;t?(i=On(this.unplaced.content,t-1).firstChild,n=i.content):n=this.unplaced.content;let r=n.firstChild;for(let n=this.depth;n>=0;n--){let o,{type:s,match:a}=this.frontier[n],l=null;if(1==e&&(r?a.matchType(r.type)||(l=a.fillBefore(Pe.from(r),!1)):i&&s.compatibleContent(i.type)))return{sliceDepth:t,frontierDepth:n,parent:i,inject:l};if(2==e&&r&&(o=a.findWrapping(r.type)))return{sliceDepth:t,frontierDepth:n,parent:i,wrap:o};if(i&&a.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=On(e,t);return!(!i.childCount||i.firstChild.isLeaf)&&(this.unplaced=new Ve(e,t+1,Math.max(n,i.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=On(e,t);if(i.childCount<=1&&t>0){let r=e.size-t<=t+i.size;this.unplaced=new Ve(Cn(e,t-1,1),t-1,r?t-1:n)}else this.unplaced=new Ve(Cn(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let e=0;e<r.length;e++)this.openFrontierNode(r[e]);let o=this.unplaced,s=n?n.content:o.content,a=o.openStart-e,l=0,c=[],{match:u,type:p}=this.frontier[t];if(i){for(let e=0;e<i.childCount;e++)c.push(i.child(e));u=u.matchFragment(i)}let d=s.size+e-(o.content.size-o.openEnd);for(;l<s.childCount;){let e=s.child(l),t=u.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(u=t,c.push(Dn(e.mark(p.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?d:-1)))}let h=l==s.childCount;h||(d=-1),this.placed=Mn(this.placed,t,Pe.from(c)),this.frontier[t].match=u,h&&d<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<d;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=h?0==e?Ve.empty:new Ve(Cn(o.content,e-1,1),e-1,d<0?o.openEnd:e-1):new Ve(Cn(o.content,e,l),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Tn(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Tn(e,t,i,n,r);if(o){for(let n=t-1;n>=0;n--){let{match:t,type:i}=this.frontier[n],r=Tn(e,n,i,t,!0);if(!r||r.childCount)continue e}return{depth:t,fit:o,move:r?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=Mn(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),i=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,i)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Mn(this.placed,this.depth,Pe.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(Pe.empty,!0);e.childCount&&(this.placed=Mn(this.placed,this.frontier.length,e))}}function Cn(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Cn(e.firstChild.content,t-1,n)))}function Mn(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Mn(e.lastChild.content,t-1,n)))}function On(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Dn(e,t,n){if(t<=0)return e;let i=e.content;return t>1&&(i=i.replaceChild(0,Dn(i.firstChild,t-1,1==i.childCount?n-1:0))),t>0&&(i=e.type.contentMatch.fillBefore(i).append(i),n<=0&&(i=i.append(e.type.contentMatch.matchFragment(i).fillBefore(Pe.empty,!0)))),e.copy(i)}function Tn(e,t,n,i,r){let o=e.node(t),s=r?e.indexAfter(t):e.index(t);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let a=i.fillBefore(o.content,!0,s);return a&&!function(e,t,n){for(let i=n;i<t.childCount;i++)if(!e.allowsMarks(t.child(i).marks))return!0;return!1}(n,o.content,s)?a:null}function Sn(e){return e.spec.defining||e.spec.definingForContent}function Nn(e,t,n,i,r){if(t<n){let r=e.firstChild;e=e.replaceChild(0,r.copy(Nn(r.content,t+1,n,i,r)))}if(t>i){let t=r.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(Pe.empty,!0))}return e}function An(e,t){let n=[];for(let i=Math.min(e.depth,t.depth);i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}class jn extends on{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return sn.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return sn.fromReplace(e,this.pos,this.pos+1,new Ve(Pe.from(i),0,t.isLeaf?0:1))}getMap(){return tn.empty}invert(e){return new jn(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 jn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new jn(t.pos,t.attr,t.value)}}on.jsonID("attr",jn);let Ln=class extends Error{};Ln=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(Ln.prototype=Object.create(Error.prototype)).constructor=Ln,Ln.prototype.name="TransformError";class zn{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new nn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Ln(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,n=Ve.empty){let i=_n(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new Ve(Pe.from(n),0,0))}delete(e,t){return this.replace(e,t,Ve.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,i){if(!i.size)return e.deleteRange(t,n);let r=e.doc.resolve(t),o=e.doc.resolve(n);if(kn(r,o,i))return e.step(new dn(t,n,i));let s=An(r,e.doc.resolve(n));0==s[s.length-1]&&s.pop();let a=-(r.depth+1);s.unshift(a);for(let e=r.depth,t=r.pos-1;e>0;e--,t--){let n=r.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?a=e:r.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),c=[],u=i.openStart;for(let e=i.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==i.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=c[e].type,n=Sn(t);if(n&&r.node(l).type!=t)u=e;else if(n||!t.isTextblock)break}for(let t=i.openStart;t>=0;t--){let a=(t+u+1)%(i.openStart+1),p=c[a];if(p)for(let t=0;t<s.length;t++){let c=s[(t+l)%s.length],u=!0;c<0&&(u=!1,c=-c);let d=r.node(c-1),h=r.index(c-1);if(d.canReplaceWith(h,h,p.type,p.marks))return e.replace(r.before(c),u?o.after(c):n,new Ve(Nn(i.content,0,i.openStart,a),a,i.openEnd))}}let p=e.steps.length;for(let a=s.length-1;a>=0&&(e.replace(t,n,i),!(e.steps.length>p));a--){let e=s[a];e<0||(t=r.before(e),n=o.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,i){if(!i.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let r=function(e,t,n){let i=e.resolve(t);if(i.parent.canReplaceWith(i.index(),i.index(),n))return t;if(0==i.parentOffset)for(let e=i.depth-1;e>=0;e--){let t=i.index(e);if(i.node(e).canReplaceWith(t,t,n))return i.before(e+1);if(t>0)return null}if(i.parentOffset==i.parent.content.size)for(let e=i.depth-1;e>=0;e--){let t=i.indexAfter(e);if(i.node(e).canReplaceWith(t,t,n))return i.after(e+1);if(t<i.node(e).childCount)return null}return null}(e.doc,t,i.type);null!=r&&(t=n=r)}e.replaceRange(t,n,new Ve(Pe.from(i),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let i=e.doc.resolve(t),r=e.doc.resolve(n),o=An(i,r);for(let t=0;t<o.length;t++){let n=o[t],s=t==o.length-1;if(s&&0==n||i.node(n).type.contentMatch.validEnd)return e.delete(i.start(n),r.end(n));if(n>0&&(s||i.node(n-1).canReplace(i.index(n-1),r.indexAfter(n-1))))return e.delete(i.before(n),r.after(n))}for(let o=1;o<=i.depth&&o<=r.depth;o++)if(t-i.start(o)==i.depth-o&&n>i.end(o)&&r.end(o)-n!=r.depth-o)return e.delete(i.before(o),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:i,$to:r,depth:o}=t,s=i.before(o+1),a=r.after(o+1),l=s,c=a,u=Pe.empty,p=0;for(let e=o,t=!1;e>n;e--)t||i.index(e)>0?(t=!0,u=Pe.from(i.node(e).copy(u)),p++):l--;let d=Pe.empty,h=0;for(let e=o,t=!1;e>n;e--)t||r.after(e+1)<r.end(e)?(t=!0,d=Pe.from(r.node(e).copy(d)),h++):c++;e.step(new hn(l,c,s,a,new Ve(u.append(d),p,h),u.size-p,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let i=new dn(t-n,t+n,Ve.empty,!0);e.step(i)}(this,e,t),this}wrap(e,t){return function(e,t,n){let i=Pe.empty;for(let e=n.length-1;e>=0;e--){if(i.size){let t=n[e].type.contentMatch.matchFragment(i);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=Pe.from(n[e].type.create(n[e].attrs,i))}let r=t.start,o=t.end;e.step(new hn(r,o,r,o,new Ve(i,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,i=null){return function(e,t,n,i,r){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=e.steps.length;e.doc.nodesBetween(t,n,((t,n)=>{if(t.isTextblock&&!t.hasMarkup(i,r)&&function(e,t,n){let i=e.resolve(t),r=i.index();return i.parent.canReplaceWith(r,r+1,n)}(e.doc,e.mapping.slice(o).map(n),i)){e.clearIncompatible(e.mapping.slice(o).map(n,1),i);let s=e.mapping.slice(o),a=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new hn(a,l,a+1,l-1,new Ve(Pe.from(i.create(r,null,t.marks)),0,0),1,!0)),!1}}))}(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i=[]){return function(e,t,n,i,r){let o=e.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(i,null,r||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new hn(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new Ve(Pe.from(s),0,0),1,!0))}(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new jn(e,t,n)),this}addNodeMark(e,t){return this.step(new un(e,t)),this}removeNodeMark(e,t){if(!(t instanceof We)){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t=t.isInSet(n.marks),!t)return this}return this.step(new pn(e,t)),this}split(e,t=1,n){return function(e,t,n=1,i){let r=e.doc.resolve(t),o=Pe.empty,s=Pe.empty;for(let e=r.depth,t=r.depth-n,a=n-1;e>t;e--,a--){o=Pe.from(r.node(e).copy(o));let t=i&&i[a];s=Pe.from(t?t.type.create(t.attrs,s):r.node(e).copy(s))}e.step(new dn(t,t,new Ve(o.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,i){let r,o,s=[],a=[];e.doc.nodesBetween(t,n,((e,l,c)=>{if(!e.isInline)return;let u=e.marks;if(!i.isInSet(u)&&c.type.allowsMarkType(i.type)){let c=Math.max(l,t),p=Math.min(l+e.nodeSize,n),d=i.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(d)||(r&&r.to==c&&r.mark.eq(u[e])?r.to=p:s.push(r=new cn(c,p,u[e])));o&&o.to==c?o.to=p:a.push(o=new ln(c,p,i))}})),s.forEach((t=>e.step(t))),a.forEach((t=>e.step(t)))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,i){let r=[],o=0;e.doc.nodesBetween(t,n,((e,s)=>{if(!e.isInline)return;o++;let a=null;if(i instanceof Ot){let t,n=e.marks;for(;t=i.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else i?i.isInSet(e.marks)&&(a=[i]):a=e.marks;if(a&&a.length){let i=Math.min(s+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<r.length;e++){let t=r[e];t.step==o-1&&l.eq(r[e].style)&&(n=t)}n?(n.to=i,n.step=o):r.push({style:l,from:Math.max(s,t),to:i,step:o})}}})),r.forEach((t=>e.step(new cn(t.from,t.to,t.style))))}(this,e,t,n),this}clearIncompatible(e,t,n){return function(e,t,n,i=n.contentMatch){let r=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<r.childCount;t++){let a=r.child(t),l=s+a.nodeSize,c=i.matchType(a.type);if(c){i=c;for(let t=0;t<a.marks.length;t++)n.allowsMarkType(a.marks[t].type)||e.step(new cn(s,l,a.marks[t]))}else o.push(new dn(s,l,Ve.empty));s=l}if(!i.validEnd){let t=i.fillBefore(Pe.empty,!0);e.replace(s,s,new Ve(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}(this,e,t,n),this}}const In=Object.create(null);class Rn{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Fn(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=Ve.empty){let n=t.content.lastChild,i=null;for(let e=0;e<t.openEnd;e++)i=n,n=n.lastChild;let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:a,$to:l}=o[s],c=e.mapping.slice(r);e.replaceRange(c.map(a.pos),c.map(l.pos),s?Ve.empty:t),0==s&&Gn(e,r,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let r=0;r<i.length;r++){let{$from:o,$to:s}=i[r],a=e.mapping.slice(n),l=a.map(o.pos),c=a.map(s.pos);r?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),Gn(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new Un(e):Kn(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let i=e.depth-1;i>=0;i--){let r=t<0?Kn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,n):Kn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,n);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new qn(e.node(0))}static atStart(e){return Kn(e,e,0,0,1)||new qn(e)}static atEnd(e){return Kn(e,e,e.content.size,e.childCount,-1)||new qn(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=In[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in In)throw new RangeError("Duplicate use of selection JSON ID "+e);return In[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Un.between(this.$anchor,this.$head).getBookmark()}}Rn.prototype.visible=!0;class Fn{constructor(e,t){this.$from=e,this.$to=t}}let Bn=!1;function Pn(e){Bn||e.parent.inlineContent||(Bn=!0,console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Un extends Rn{constructor(e,t=e){Pn(e),Pn(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return Rn.near(n);let i=e.resolve(t.map(this.anchor));return new Un(i.parent.inlineContent?i:n,n)}replace(e,t=Ve.empty){if(super.replace(e,t),t==Ve.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof Un&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Hn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Un(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if(n&&!i||(n=i>=0?1:-1),!t.parent.inlineContent){let e=Rn.findFrom(t,n,!0)||Rn.findFrom(t,-n,!0);if(!e)return Rn.near(t,n);t=e.$head}return e.parent.inlineContent||(0==i||(e=(Rn.findFrom(e,-n,!0)||Rn.findFrom(e,n,!0)).$anchor).pos<t.pos!=i<0)&&(e=t),new Un(e,t)}}Rn.jsonID("text",Un);class Hn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Hn(e.map(this.anchor),e.map(this.head))}resolve(e){return Un.between(e.resolve(this.anchor),e.resolve(this.head))}}class $n extends Rn{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),r=e.resolve(i);return n?Rn.near(r):new $n(r)}content(){return new Ve(Pe.from(this.node),0,0)}eq(e){return e instanceof $n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Wn(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new $n(e.resolve(t.anchor))}static create(e,t){return new $n(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}$n.prototype.visible=!1,Rn.jsonID("node",$n);class Wn{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Hn(n,n):new Wn(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&$n.isSelectable(n)?new $n(t):Rn.near(t)}}class qn extends Rn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Ve.empty){if(t==Ve.empty){e.delete(0,e.doc.content.size);let t=Rn.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new qn(e)}map(e){return new qn(e)}eq(e){return e instanceof qn}getBookmark(){return Vn}}Rn.jsonID("all",qn);const Vn={map(){return this},resolve:e=>new qn(e)};function Kn(e,t,n,i,r,o=!1){if(t.inlineContent)return Un.create(e,n);for(let s=i-(r>0?0:1);r>0?s<t.childCount:s>=0;s+=r){let i=t.child(s);if(i.isAtom){if(!o&&$n.isSelectable(i))return $n.create(e,n-(r<0?i.nodeSize:0))}else{let t=Kn(e,i,n+r,r<0?i.childCount:0,r,o);if(t)return t}n+=i.nodeSize*r}return null}function Gn(e,t,n){let i=e.steps.length-1;if(i<t)return;let r,o=e.steps[i];(o instanceof dn||o instanceof hn)&&(e.mapping.maps[i].forEach(((e,t,n,i)=>{null==r&&(r=i)})),e.setSelection(Rn.near(e.doc.resolve(r),n)))}const Yn=1,Qn=2,Zn=4;class Jn extends zn{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|Yn)&~Qn,this.storedMarks=null,this}get selectionSet(){return(this.updated&Yn)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Qn,this}ensureMarks(e){return We.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&Qn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Qn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||We.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let r=this.storedMarks;if(!r){let e=this.doc.resolve(t);r=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,r)),this.selection.empty||this.setSelection(Rn.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Zn,this}get scrolledIntoView(){return(this.updated&Zn)>0}}function Xn(e,t){return t&&e?e.bind(t):e}class ei{constructor(e,t,n){this.name=e,this.init=Xn(t.init,n),this.apply=Xn(t.apply,n)}}const ti=[new ei("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new ei("selection",{init:(e,t)=>e.selection||Rn.atStart(t.doc),apply:e=>e.selection}),new ei("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,i)=>i.selection.$cursor?e.storedMarks:null}),new ei("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class ni{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ti.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new ei(e.key,e.spec.state,e))}))}}class ii{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),i=null;for(;;){let r=!1;for(let o=0;o<this.config.plugins.length;o++){let s=this.config.plugins[o];if(s.spec.appendTransaction){let a=i?i[o].n:0,l=i?i[o].state:this,c=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,o)){if(c.setMeta("appendedTransaction",e),!i){i=[];for(let e=0;e<this.config.plugins.length;e++)i.push(e<o?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),r=!0}i&&(i[o]={state:n,n:t.length})}}if(!r)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new ii(this.config),n=this.config.fields;for(let i=0;i<n.length;i++){let r=n[i];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new Jn(this)}static create(e){let t=new ni(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new ii(t);for(let i=0;i<t.fields.length;i++)n[t.fields[i].name]=t.fields[i].init(e,n);return n}reconfigure(e){let t=new ni(this.schema,e.plugins),n=t.fields,i=new ii(t);for(let t=0;t<n.length;t++){let r=n[t].name;i[r]=this.hasOwnProperty(r)?this[r]:n[t].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((e=>e.toJSON()))),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],r=i.spec.state;r&&r.toJSON&&(t[n]=r.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new ni(e.schema,e.plugins),r=new ii(i);return i.fields.forEach((i=>{if("doc"==i.name)r.doc=ut.fromJSON(e.schema,t.doc);else if("selection"==i.name)r.selection=Rn.fromJSON(r.doc,t.selection);else if("storedMarks"==i.name)t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let o in n){let s=n[o],a=s.spec.state;if(s.key==i.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,o))return void(r[i.name]=a.fromJSON.call(s,e,t[o],r))}r[i.name]=i.init(e,r)}})),r}}function ri(e,t,n){for(let i in e){let r=e[i];r instanceof Function?r=r.bind(t):"handleDOMEvents"==i&&(r=ri(r,t,{})),n[i]=r}return n}class oi{constructor(e){this.spec=e,this.props={},e.props&&ri(e.props,this,this.props),this.key=e.key?e.key.key:ai("plugin")}getState(e){return e[this.key]}}const si=Object.create(null);function ai(e){return e in si?e+"$"+ ++si[e]:(si[e]=0,e+"$")}class li{constructor(e="key"){this.key=ai(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ci="undefined"!=typeof navigator?navigator:null,ui="undefined"!=typeof document?document:null,pi=ci&&ci.userAgent||"",di=/Edge\/(\d+)/.exec(pi),hi=/MSIE \d/.exec(pi),fi=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(pi),mi=!!(hi||fi||di),gi=hi?document.documentMode:fi?+fi[1]:di?+di[1]:0,bi=!mi&&/gecko\/(\d+)/i.test(pi);bi&&(/Firefox\/(\d+)/.exec(pi)||[0,0])[1];const vi=!mi&&/Chrome\/(\d+)/.exec(pi),yi=!!vi,xi=vi?+vi[1]:0,wi=!mi&&!!ci&&/Apple Computer/.test(ci.vendor),_i=wi&&(/Mobile\/\w+/.test(pi)||!!ci&&ci.maxTouchPoints>2),ki=_i||!!ci&&/Mac/.test(ci.platform),Ei=/Android \d/.test(pi),Ci=!!ui&&"webkitFontSmoothing"in ui.documentElement.style,Mi=Ci?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,Oi=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Di=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let Ti=null;const Si=function(e,t,n){let i=Ti||(Ti=document.createRange());return i.setEnd(e,null==n?e.nodeValue.length:n),i.setStart(e,t||0),i},Ni=function(e,t,n,i){return n&&(ji(e,t,n,i,-1)||ji(e,t,n,i,1))},Ai=/^(img|br|input|textarea|hr)$/i;function ji(e,t,n,i,r){for(;;){if(e==n&&t==i)return!0;if(t==(r<0?0:Li(e))){let n=e.parentNode;if(!n||1!=n.nodeType||zi(e)||Ai.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Oi(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(r<0?-1:0)]).contentEditable)return!1;t=r<0?Li(e):0}}}function Li(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function zi(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Ii=function(e){let t=e.isCollapsed;return t&&yi&&e.rangeCount&&!e.getRangeAt(0).collapsed&&(t=!1),t};function Ri(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function Fi(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Bi(e,t){return"number"==typeof e?e:e[t]}function Pi(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,i=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*i}}function Ui(e,t,n){let i=e.someProp("scrollThreshold")||0,r=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let s=n||e.dom;s;s=Di(s)){if(1!=s.nodeType)continue;let e=s,n=e==o.body,a=n?Fi(o):Pi(e),l=0,c=0;if(t.top<a.top+Bi(i,"top")?c=-(a.top-t.top+Bi(r,"top")):t.bottom>a.bottom-Bi(i,"bottom")&&(c=t.bottom-a.bottom+Bi(r,"bottom")),t.left<a.left+Bi(i,"left")?l=-(a.left-t.left+Bi(r,"left")):t.right>a.right-Bi(i,"right")&&(l=t.right-a.right+Bi(r,"right")),l||c)if(n)o.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,i=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let r=e.scrollLeft-n,o=e.scrollTop-i;t={left:t.left-r,top:t.top-o,right:t.right-r,bottom:t.bottom-o}}if(n)break}}function Hi(e){let t=[],n=e.ownerDocument;for(let i=e;i&&(t.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),e!=n);i=Di(i));return t}function $i(e,t){for(let n=0;n<e.length;n++){let{dom:i,top:r,left:o}=e[n];i.scrollTop!=r+t&&(i.scrollTop=r+t),i.scrollLeft!=o&&(i.scrollLeft=o)}}let Wi=null;function qi(e,t){let n,i,r=2e8,o=0,s=t.top,a=t.top;for(let l=e.firstChild,c=0;l;l=l.nextSibling,c++){let e;if(1==l.nodeType)e=l.getClientRects();else{if(3!=l.nodeType)continue;e=Si(l).getClientRects()}for(let u=0;u<e.length;u++){let p=e[u];if(p.top<=s&&p.bottom>=a){s=Math.max(p.bottom,s),a=Math.min(p.top,a);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=l,r=e,i=e&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==l.nodeType&&e&&(o=c+(t.left>=(p.left+p.right)/2?1:0));continue}}!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(o=c+1)}}return n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,i=document.createRange();for(let r=0;r<n;r++){i.setEnd(e,r+1),i.setStart(e,r);let n=Yi(i,1);if(n.top!=n.bottom&&Vi(t,n))return{node:e,offset:r+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,i):!n||r&&1==n.nodeType?{node:e,offset:o}:qi(n,i)}function Vi(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Ki(e,t,n){let i=e.childNodes.length;if(i&&n.top<n.bottom)for(let r=Math.max(0,Math.min(i-1,Math.floor(i*(t.top-n.top)/(n.bottom-n.top))-2)),o=r;;){let n=e.childNodes[o];if(1==n.nodeType){let e=n.getClientRects();for(let i=0;i<e.length;i++){let r=e[i];if(Vi(t,r))return Ki(n,t,r)}}if((o=(o+1)%i)==r)break}return e}function Gi(e,t){let n,i=e.dom.ownerDocument,r=0;if(i.caretPositionFromPoint)try{let e=i.caretPositionFromPoint(t.left,t.top);e&&({offsetNode:n,offset:r}=e)}catch(e){}if(!n&&i.caretRangeFromPoint){let e=i.caretRangeFromPoint(t.left,t.top);e&&({startContainer:n,startOffset:r}=e)}let o,s=(e.root.elementFromPoint?e.root:i).elementFromPoint(t.left,t.top);if(!s||!e.dom.contains(1!=s.nodeType?s.parentNode:s)){let n=e.dom.getBoundingClientRect();if(!Vi(t,n))return null;if(s=Ki(e.dom,t,n),!s)return null}if(wi)for(let e=s;n&&e;e=Di(e))e.draggable&&(n=void 0);if(s=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(s,t),n){if(bi&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let e,i=n.childNodes[r];"IMG"==i.nodeName&&(e=i.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&r++}n==e.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?o=e.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(o=function(e,t,n,i){let r=-1;for(let n=t;n!=e.dom;){let t=e.docView.nearestDesc(n,!0);if(!t)return null;if(t.node.isBlock&&t.parent){let e=t.dom.getBoundingClientRect();if(e.left>i.left||e.top>i.top)r=t.posBefore;else{if(!(e.right<i.left||e.bottom<i.top))break;r=t.posAfter}}n=t.dom.parentNode}return r>-1?r:e.docView.posFromDOM(t,n,1)}(e,n,r,t))}null==o&&(o=function(e,t,n){let{node:i,offset:r}=qi(t,n),o=-1;if(1==i.nodeType&&!i.firstChild){let e=i.getBoundingClientRect();o=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(i,r,o)}(e,s,t));let a=e.docView.nearestDesc(s,!0);return{pos:o,inside:a?a.posAtStart-a.border:-1}}function Yi(e,t){let n=e.getClientRects();return n.length?n[t<0?0:n.length-1]:e.getBoundingClientRect()}const Qi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Zi(e,t,n){let{node:i,offset:r,atom:o}=e.docView.domFromPos(t,n<0?-1:1),s=Ci||bi;if(3==i.nodeType){if(!s||!Qi.test(i.nodeValue)&&(n<0?r:r!=i.nodeValue.length)){let e=r,t=r,o=n<0?1:-1;return n<0&&!r?(t++,o=-1):n>=0&&r==i.nodeValue.length?(e--,o=1):n<0?e--:t++,Ji(Yi(Si(i,e,t),1),o<0)}{let e=Yi(Si(i,r,r),n);if(bi&&r&&/\s/.test(i.nodeValue[r-1])&&r<i.nodeValue.length){let t=Yi(Si(i,r-1,r-1),-1);if(t.top==e.top){let n=Yi(Si(i,r,r+1),-1);if(n.top!=e.top)return Ji(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(null==o&&r&&(n<0||r==Li(i))){let e=i.childNodes[r-1];if(1==e.nodeType)return Xi(e.getBoundingClientRect(),!1)}if(null==o&&r<Li(i)){let e=i.childNodes[r];if(1==e.nodeType)return Xi(e.getBoundingClientRect(),!0)}return Xi(i.getBoundingClientRect(),n>=0)}if(null==o&&r&&(n<0||r==Li(i))){let e=i.childNodes[r-1],t=3==e.nodeType?Si(e,Li(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Ji(Yi(t,1),!1)}if(null==o&&r<Li(i)){let e=i.childNodes[r];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?Si(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return Ji(Yi(t,-1),!0)}return Ji(Yi(3==i.nodeType?Si(i):i,-n),n>=0)}function Ji(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Xi(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function er(e,t,n){let i=e.state,r=e.root.activeElement;i!=t&&e.updateState(t),r!=e.dom&&e.focus();try{return n()}finally{i!=t&&e.updateState(i),r!=e.dom&&r&&r.focus()}}const tr=/[\u0590-\u08ac]/;let nr=null,ir=null,rr=!1;function or(e,t,n){return nr==t&&ir==n?rr:(nr=t,ir=n,rr="up"==n||"down"==n?function(e,t,n){let i=t.selection,r="up"==n?i.$from:i.$to;return er(e,t,(()=>{let{node:t}=e.docView.domFromPos(r.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.dom;break}t=n.dom.parentNode}let i=Zi(e,r.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=Si(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let r=t[e];if(r.bottom>r.top+1&&("up"==n?i.top-r.top>2*(r.bottom-i.top):r.bottom-i.bottom>2*(i.bottom-r.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){let{$head:i}=t.selection;if(!i.parent.isTextblock)return!1;let r=i.parentOffset,o=!r,s=r==i.parent.content.size,a=e.domSelection();return tr.test(i.parent.textContent)&&a.modify?er(e,t,(()=>{let t=a.getRangeAt(0),r=a.focusNode,o=a.focusOffset,s=a.caretBidiLevel;a.modify("move",n,"character");let l=!(i.depth?e.docView.domAfterPos(i.before()):e.dom).contains(1==a.focusNode.nodeType?a.focusNode:a.focusNode.parentNode)||r==a.focusNode&&o==a.focusOffset;return a.removeAllRanges(),a.addRange(t),null!=s&&(a.caretBidiLevel=s),l})):"left"==n||"backward"==n?o:s}(e,t,n))}const sr=0,ar=1,lr=2,cr=3;class ur{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=sr,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){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,n=this.posAtStart;;t++){let i=this.children[t];if(i==e)return n;n+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,i;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(i=n.pmViewDesc)||i.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(i)+i.size:this.posAtStart}{let n,i;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(i=n.pmViewDesc)||i.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(i):this.posAtEnd}}let i;if(e==this.dom&&this.contentDOM)i=t>Oi(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){i=!1;break}if(t.previousSibling)break}if(null==i&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){i=!0;break}if(t.nextSibling)break}}return(null==i?n>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let r,o=this.getDesc(i);if(o&&(!t||o.node)){if(!n||!(r=o.nodeDOM)||(1==r.nodeType?r.contains(1==e.nodeType?e:e.parentNode):r==e))return o;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let r=this.getDesc(i);if(r)return r.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],r=n+i.size;if(n==e&&r!=n){for(;!i.border&&i.children.length;)i=i.children[0];return i}if(e<r)return i.descAt(e-n-i.border);n=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n,i=0,r=0;for(let t=0;i<this.children.length;i++){let n=this.children[i],o=t+n.size;if(o>e||n instanceof br){r=e-t;break}t=o}if(r)return this.children[i].domFromPos(r-this.children[i].border,t);for(;i&&!(n=this.children[i-1]).size&&n instanceof pr&&n.side>=0;i--);if(t<=0){let e,n=!0;for(;e=i?this.children[i-1]:null,e&&e.dom.parentNode!=this.contentDOM;i--,n=!1);return e&&t&&n&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?Oi(e.dom)+1:0}}{let e,n=!0;for(;e=i<this.children.length?this.children[i]:null,e&&e.dom.parentNode!=this.contentDOM;i++,n=!1);return e&&n&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Oi(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,r=-1;for(let o=n,s=0;;s++){let n=this.children[s],a=o+n.size;if(-1==i&&e<=a){let r=o+n.border;if(e>=r&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,r);e=o;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){i=Oi(n.dom)+1;break}e-=n.size}-1==i&&(i=0)}if(i>-1&&(a>t||s==this.children.length-1)){t=a;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){r=Oi(n.dom);break}t+=n.size}-1==r&&(r=this.contentDOM.childNodes.length);break}o=a}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:r}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let r=Math.min(e,t),o=Math.max(e,t);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],c=a+l.size;if(r>a&&o<c)return l.setSelection(e-a-l.border,t-a-l.border,n,i);a=c}let s=this.domFromPos(e,e?-1:1),a=t==e?s:this.domFromPos(t,t?-1:1),l=n.getSelection(),c=!1;if((bi||wi)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(c=!(!t||"\n"!=e.nodeValue[t-1]),c&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=a={node:t.parentNode,offset:Oi(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];c=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(bi&&l.focusNode&&l.focusNode!=a.node&&1==l.focusNode.nodeType){let e=l.focusNode.childNodes[l.focusOffset];e&&"false"==e.contentEditable&&(i=!0)}if(!(i||c&&wi)&&Ni(s.node,s.offset,l.anchorNode,l.anchorOffset)&&Ni(a.node,a.offset,l.focusNode,l.focusOffset))return;let u=!1;if((l.extend||e==t)&&!c){l.collapse(s.node,s.offset);try{if(e!=t)try{l.extend(a.node,a.offset)}catch(e){}u=!0}catch(e){if(!(e instanceof DOMException))throw e}}if(!u){if(e>t){let e=s;s=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i<this.children.length;i++){let r=this.children[i],o=n+r.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let i=n+r.border,s=o-r.border;if(e>=i&&t<=s)return this.dirty=e==n||t==o?lr:ar,void(e!=i||t!=s||!r.contentLost&&r.dom.parentNode==this.contentDOM?r.markDirty(e-i,t-i):r.dirty=cr);r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?cr:lr}n=o}this.dirty=lr}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?lr:ar;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class pr extends ur{constructor(e,t,n,i){let r,o=t.type.toDOM;if("function"==typeof o&&(o=o(n,(()=>r?r.parent?r.parent.posBeforeChild(r):void 0:i))),!t.type.spec.raw){if(1!=o.nodeType){let e=document.createElement("span");e.appendChild(o),o=e}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==sr&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class dr extends ur{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}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"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class hr extends ur{constructor(e,t,n,i){super(e,[],n,i),this.mark=t}static create(e,t,n,i){let r=i.nodeViews[t.type.name],o=r&&r(t,i,n);return o&&o.dom||(o=$t.renderSpec(document,t.type.spec.toDOM(t,n))),new hr(e,t,o.dom,o.contentDOM||o.dom)}parseRule(){return this.dirty&cr||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}matchesMark(e){return this.dirty!=cr&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=sr){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=sr}}slice(e,t,n){let i=hr.create(this.parent,this.mark,!0,n),r=this.children,o=this.size;t<o&&(r=Sr(r,t,o,n)),e>0&&(r=Sr(r,0,e,n));for(let e=0;e<r.length;e++)r[e].parent=i;return i.children=r,i}}class fr extends ur{constructor(e,t,n,i,r,o,s,a,l){super(e,[],r,o),this.node=t,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=s,o&&this.updateChildren(a,l)}static create(e,t,n,i,r,o){let s,a=r.nodeViews[t.type.name],l=a&&a(t,r,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:o),n,i),c=l&&l.dom,u=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else c||({dom:c,contentDOM:u}=$t.renderSpec(document,t.type.spec.toDOM(t)));u||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let p=c;return c=Cr(c,n,t),l?s=new vr(e,t,n,i,c,u||null,p,l,r,o+1):t.isText?new gr(e,t,n,i,c,p,r):new fr(e,t,n,i,c,u||null,p,r,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Pe.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return this.dirty==sr&&e.eq(this.node)&&Mr(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,r=e.composing?this.localCompositionInfo(e,t):null,o=r&&r.pos>-1?r:null,s=r&&r.pos<0,a=new Dr(this,o&&o.node,e);!function(e,t,n,i){let r=t.locals(e),o=0;if(0==r.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);i(s,r,t.forChild(o,s),n),o+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){if(s<r.length&&r[s].to==o){let e,t=r[s++];for(;s<r.length&&r[s].to==o;)(e||(e=[t])).push(r[s++]);if(e){e.sort(Tr);for(let t=0;t<e.length;t++)n(e[t],c,!!l)}else n(t,c,!!l)}let u,p;if(l)p=-1,u=l,l=null;else{if(!(c<e.childCount))break;p=c,u=e.child(c++)}for(let e=0;e<a.length;e++)a[e].to<=o&&a.splice(e--,1);for(;s<r.length&&r[s].from<=o&&r[s].to>o;)a.push(r[s++]);let d=o+u.nodeSize;if(u.isText){let e=d;s<r.length&&r[s].from<e&&(e=r[s].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<d&&(l=u.cut(e-o),u=u.cut(0,e-o),d=e,p=-1)}let h=u.isInline&&!u.isLeaf?a.filter((e=>!e.inline)):a.slice();i(u,h,t.forChild(o,u),p),o=d}}(this.node,this.innerDeco,((t,r,o)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!o&&a.syncToMarks(r==this.node.childCount?We.none:this.node.child(r).marks,n,e),a.placeWidget(t,e,i)}),((t,o,l,c)=>{let u;a.syncToMarks(t.marks,n,e),a.findNodeMatch(t,o,l,c)||s&&e.state.selection.from>i&&e.state.selection.to<i+t.nodeSize&&(u=a.findIndexWithChild(r.node))>-1&&a.updateNodeAt(t,o,l,u,e)||a.updateNextNode(t,o,l,e,c)||a.addNode(t,o,l,e,i),i+=t.nodeSize})),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==lr)&&(o&&this.protectLocalComposition(e,o),yr(this.contentDOM,this.children,e),_i&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof Un)||n<t||i>t+this.node.content.size)return null;let r=e.domSelection(),o=function(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&t>0){if(e.childNodes.length>t&&3==e.childNodes[t].nodeType)return e.childNodes[t];t=Li(e=e.childNodes[t-1])}else{if(!(1==e.nodeType&&t<e.childNodes.length))return null;e=e.childNodes[t],t=0}}}(r.focusNode,r.focusOffset);if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let e=o.nodeValue,r=function(e,t,n,i){for(let r=0,o=0;r<e.childCount&&o<=i;){let s=e.child(r++),a=o;if(o+=s.nodeSize,!s.isText)continue;let l=s.text;for(;r<e.childCount;){let t=e.child(r++);if(o+=t.nodeSize,!t.isText)break;l+=t.text}if(o>=n){let e=a<i?l.lastIndexOf(t,i-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==i&&l.length>=i+t.length-a&&l.slice(i-a,i-a+t.length)==t)return i}}return-1}(this.node.content,e,n-t,i-t);return r<0?null:{node:o,pos:r,text:e}}return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let o=new dr(this,r,t,i);e.input.compositionNodes.push(o),this.children=Sr(this.children,n,n+i.length,e,o)}update(e,t,n,i){return!(this.dirty==cr||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=sr}updateOuterDeco(e){if(Mr(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=kr(this.dom,this.nodeDOM,_r(this.outerDeco,this.node,t),_r(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function mr(e,t,n,i,r){return Cr(i,t,e),new fr(void 0,e,t,n,i,i,i,r,0)}class gr extends fr{constructor(e,t,n,i,r,o,s){super(e,t,n,i,r,null,o,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return!(this.dirty==cr||this.dirty!=sr&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),this.dirty==sr&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=sr,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let i=this.node.cut(e,t),r=document.createTextNode(i.text);return new gr(this.parent,i,this.outerDeco,this.innerDeco,r,r,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=cr)}get domAtom(){return!1}}class br extends ur{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==sr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class vr extends fr{constructor(e,t,n,i,r,o,s,a,l,c){super(e,t,n,i,r,o,s,l,c),this.spec=a}update(e,t,n,i){if(this.dirty==cr)return!1;if(this.spec.update){let r=this.spec.update(e,t,n);return r&&this.updateInner(e,t,n,i),r}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function yr(e,t,n){let i=e.firstChild,r=!1;for(let o=0;o<t.length;o++){let s=t[o],a=s.dom;if(a.parentNode==e){for(;a!=i;)i=Or(i),r=!0;i=i.nextSibling}else r=!0,e.insertBefore(a,i);if(s instanceof hr){let t=i?i.previousSibling:e.lastChild;yr(s.contentDOM,s.children,n),i=t?t.nextSibling:e.firstChild}}for(;i;)i=Or(i),r=!0;r&&n.trackWrites==e&&(n.trackWrites=null)}const xr=function(e){e&&(this.nodeName=e)};xr.prototype=Object.create(null);const wr=[new xr];function _r(e,t,n){if(0==e.length)return wr;let i=n?wr[0]:new xr,r=[i];for(let o=0;o<e.length;o++){let s=e[o].type.attrs;if(s){s.nodeName&&r.push(i=new xr(s.nodeName));for(let e in s){let o=s[e];null!=o&&(n&&1==r.length&&r.push(i=new xr(t.isInline?"span":"div")),"class"==e?i.class=(i.class?i.class+" ":"")+o:"style"==e?i.style=(i.style?i.style+";":"")+o:"nodeName"!=e&&(i[e]=o))}}}return r}function kr(e,t,n,i){if(n==wr&&i==wr)return t;let r=t;for(let t=0;t<i.length;t++){let o=i[t],s=n[t];if(t){let t;s&&s.nodeName==o.nodeName&&r!=e&&(t=r.parentNode)&&t.nodeName.toLowerCase()==o.nodeName||(t=document.createElement(o.nodeName),t.pmIsDeco=!0,t.appendChild(r),s=wr[0]),r=t}Er(r,s||wr[0],o)}return r}function Er(e,t,n){for(let i in t)"class"==i||"style"==i||"nodeName"==i||i in n||e.removeAttribute(i);for(let i in n)"class"!=i&&"style"!=i&&"nodeName"!=i&&n[i]!=t[i]&&e.setAttribute(i,n[i]);if(t.class!=n.class){let i=t.class?t.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<i.length;t++)-1==r.indexOf(i[t])&&e.classList.remove(i[t]);for(let t=0;t<r.length;t++)-1==i.indexOf(r[t])&&e.classList.add(r[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=i.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function Cr(e,t,n){return kr(e,e,wr,_r(t,n,1!=e.nodeType))}function Mr(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Or(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Dr{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,i=n.children.length,r=e.childCount,o=new Map,s=[];e:for(;r>0;){let a;for(;;)if(i){let e=n.children[i-1];if(!(e instanceof hr)){a=e,i--;break}n=e,i=e.children.length}else{if(n==t)break e;i=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(r-1))break;--r,o.set(a,r),s.push(a)}}return{index:r,matched:o,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let i=0,r=this.stack.length>>1,o=Math.min(r,e.length);for(;i<o&&(i==r-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&!1!==e[i].type.spec.spanning;)i++;for(;i<r;)this.destroyRest(),this.top.dirty=sr,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let i=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++)if(this.top.children[t].matchesMark(e[r])){i=t;break}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let i=hr.create(this.top,e[r],t,n);this.top.children.splice(this.index,0,i),this.top=i,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,n,i){let r,o=-1;if(i>=this.preMatch.index&&(r=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,n))o=this.top.children.indexOf(r,this.index);else for(let i=this.index,r=Math.min(this.top.children.length,i+5);i<r;i++){let r=this.top.children[i];if(r.matchesNode(e,t,n)&&!this.preMatch.matched.has(r)){o=i;break}}return!(o<0)&&(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,n,i,r){let o=this.top.children[i];return o.dirty==cr&&o.dom==o.contentDOM&&(o.dirty=lr),!!o.update(e,t,n,r)&&(this.destroyBetween(this.index,i),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,i,r){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof fr){let a=this.preMatch.matched.get(s);if(null!=a&&a!=r)return!1;let l=s.dom;if(!(this.lock&&(l==this.lock||1==l.nodeType&&l.contains(this.lock.parentNode))&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=cr&&Mr(t,s.outerDeco)))&&s.update(e,t,n,i))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;break}}return!1}addNode(e,t,n,i,r){this.top.children.splice(this.index++,0,fr.create(this.top,e,t,n,i,r)),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(!i||!i.matchesWidget(e)||e!=i.widget&&i.widget.type.toDOM.parentNode){let i=new pr(this.top,e,t,n);this.top.children.splice(this.index++,0,i),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof hr;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof gr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((wi||yi)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let i=new br(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}}function Tr(e,t){return e.type.side-t.type.side}function Sr(e,t,n,i,r){let o=[];for(let s=0,a=0;s<e.length;s++){let l=e[s],c=a,u=a+=l.size;c>=n||u<=t?o.push(l):(c<t&&o.push(l.slice(0,t-c,i)),r&&(o.push(r),r=void 0),u>n&&o.push(l.slice(n-c,l.size,i)))}return o}function Nr(e,t=null){let n=e.domSelection(),i=e.state.doc;if(!n.focusNode)return null;let r=e.docView.nearestDesc(n.focusNode),o=r&&0==r.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a,l,c=i.resolve(s);if(Ii(n)){for(a=c;r&&!r.node;)r=r.parent;let e=r.node;if(r&&e.isAtom&&$n.isSelectable(e)&&r.parent&&(!e.isInline||!function(e,t,n){for(let i=0==t,r=t==Li(e);i||r;){if(e==n)return!0;let t=Oi(e);if(!(e=e.parentNode))return!1;i=i&&0==t,r=r&&t==Li(e)}}(n.focusNode,n.focusOffset,r.dom))){let e=r.posBefore;l=new $n(s==e?c:i.resolve(e))}}else{let t=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(t<0)return null;a=i.resolve(t)}if(!l){l=Pr(e,a,c,"pointer"==t||e.state.selection.head<c.pos&&!o?1:-1)}return l}function Ar(e){return e.editable?e.hasFocus():Hr(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function jr(e,t=!1){let n=e.state.selection;if(Fr(e,n),Ar(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&yi){let t=e.domSelection(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Ni(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection(),n=document.createRange(),i=e.cursorWrapper.dom,r="IMG"==i.nodeName;r?n.setEnd(i.parentNode,Oi(i)+1):n.setEnd(i,0);n.collapse(!1),t.removeAllRanges(),t.addRange(n),!r&&!e.state.selection.visible&&mi&&gi<=11&&(i.disabled=!0,i.disabled=!1)}(e);else{let i,r,{anchor:o,head:s}=n;!Lr||n instanceof Un||(n.$from.parent.inlineContent||(i=zr(e,n.from)),n.empty||n.$from.parent.inlineContent||(r=zr(e,n.to))),e.docView.setSelection(o,s,e.root,t),Lr&&(i&&Rr(i),r&&Rr(r)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelection(),i=n.anchorNode,r=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==i&&n.anchorOffset==r||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{Ar(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Lr=wi||yi&&xi<63;function zr(e,t){let{node:n,offset:i}=e.docView.domFromPos(t,0),r=i<n.childNodes.length?n.childNodes[i]:null,o=i?n.childNodes[i-1]:null;if(wi&&r&&"false"==r.contentEditable)return Ir(r);if(!(r&&"false"!=r.contentEditable||o&&"false"!=o.contentEditable)){if(r)return Ir(r);if(o)return Ir(o)}}function Ir(e){return e.contentEditable="true",wi&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Rr(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Fr(e,t){if(t instanceof $n){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Br(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Br(e)}function Br(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Pr(e,t,n,i){return e.someProp("createSelectionBetween",(i=>i(e,t,n)))||Un.between(t,n,i)}function Ur(e){return!(e.editable&&!e.hasFocus())&&Hr(e)}function Hr(e){let t=e.domSelection();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function $r(e,t){let{$anchor:n,$head:i}=e.selection,r=t>0?n.max(i):n.min(i),o=r.parent.inlineContent?r.depth?e.doc.resolve(t>0?r.after():r.before()):null:r;return o&&Rn.findFrom(o,t)}function Wr(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function qr(e,t,n){let i=e.state.selection;if(!(i instanceof Un)){if(i instanceof $n&&i.node.isInline)return Wr(e,new Un(t>0?i.$to:i.$from));{let n=$r(e.state,t);return!!n&&Wr(e,n)}}if(!i.empty||n.indexOf("s")>-1)return!1;if(e.endOfTextblock(t>0?"right":"left")){let n=$r(e.state,t);return!!(n&&n instanceof $n)&&Wr(e,n)}if(!(ki&&n.indexOf("m")>-1)){let n,r=i.$head,o=r.textOffset?null:t<0?r.nodeBefore:r.nodeAfter;if(!o||o.isText)return!1;let s=t<0?r.pos-o.nodeSize:r.pos;return!!(o.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&($n.isSelectable(o)?Wr(e,new $n(t<0?e.state.doc.resolve(r.pos-o.nodeSize):r)):!!Ci&&Wr(e,new Un(e.state.doc.resolve(t<0?s:s+o.nodeSize))))}}function Vr(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Kr(e){let t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function Gr(e){let t=e.domSelection(),n=t.focusNode,i=t.focusOffset;if(!n)return;let r,o,s=!1;for(bi&&1==n.nodeType&&i<Vr(n)&&Kr(n.childNodes[i])&&(s=!0);;)if(i>0){if(1!=n.nodeType)break;{let e=n.childNodes[i-1];if(Kr(e))r=n,o=--i;else{if(3!=e.nodeType)break;n=e,i=n.nodeValue.length}}}else{if(Qr(n))break;{let t=n.previousSibling;for(;t&&Kr(t);)r=n.parentNode,o=Oi(t),t=t.previousSibling;if(t)n=t,i=Vr(n);else{if(n=n.parentNode,n==e.dom)break;i=0}}}s?Zr(e,t,n,i):r&&Zr(e,t,r,o)}function Yr(e){let t=e.domSelection(),n=t.focusNode,i=t.focusOffset;if(!n)return;let r,o,s=Vr(n);for(;;)if(i<s){if(1!=n.nodeType)break;if(!Kr(n.childNodes[i]))break;r=n,o=++i}else{if(Qr(n))break;{let t=n.nextSibling;for(;t&&Kr(t);)r=t.parentNode,o=Oi(t)+1,t=t.nextSibling;if(t)n=t,i=0,s=Vr(n);else{if(n=n.parentNode,n==e.dom)break;i=s=0}}}r&&Zr(e,t,r,o)}function Qr(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Zr(e,t,n,i){if(Ii(t)){let e=document.createRange();e.setEnd(n,i),e.setStart(n,i),t.removeAllRanges(),t.addRange(e)}else t.extend&&t.extend(n,i);e.domObserver.setCurSelection();let{state:r}=e;setTimeout((()=>{e.state==r&&jr(e)}),50)}function Jr(e,t,n){let i=e.state.selection;if(i instanceof Un&&!i.empty||n.indexOf("s")>-1)return!1;if(ki&&n.indexOf("m")>-1)return!1;let{$from:r,$to:o}=i;if(!r.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=$r(e.state,t);if(n&&n instanceof $n)return Wr(e,n)}if(!r.parent.inlineContent){let n=t<0?r:o,s=i instanceof qn?Rn.near(n,t):Rn.findFrom(n,t);return!!s&&Wr(e,s)}return!1}function Xr(e,t){if(!(e.state.selection instanceof Un))return!0;let{$head:n,$anchor:i,empty:r}=e.state.selection;if(!n.sameParent(i))return!0;if(!r)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let o=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let i=e.state.tr;return t<0?i.delete(n.pos-o.nodeSize,n.pos):i.delete(n.pos,n.pos+o.nodeSize),e.dispatch(i),!0}return!1}function eo(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function to(e,t){let n=t.keyCode,i=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);return 8==n||ki&&72==n&&"c"==i?Xr(e,-1)||Gr(e):46==n||ki&&68==n&&"c"==i?Xr(e,1)||Yr(e):13==n||27==n||(37==n||ki&&66==n&&"c"==i?qr(e,-1,i)||Gr(e):39==n||ki&&70==n&&"c"==i?qr(e,1,i)||Yr(e):38==n||ki&&80==n&&"c"==i?Jr(e,-1,i)||Gr(e):40==n||ki&&78==n&&"c"==i?function(e){if(!wi||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelection();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;eo(e,n,"true"),setTimeout((()=>eo(e,n,"false")),20)}return!1}(e)||Jr(e,1,i)||Yr(e):i==(ki?"m":"c")&&(66==n||73==n||89==n||90==n))}function no(e,t){e.someProp("transformCopied",(e=>{t=e(t)}));let n=[],{content:i,openStart:r,openEnd:o}=t;for(;r>1&&o>1&&1==i.childCount&&1==i.firstChild.childCount;){r--,o--;let e=i.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),i=e.content}let s=e.someProp("clipboardSerializer")||$t.fromSchema(e.state.schema),a=ho(),l=a.createElement("div");l.appendChild(s.serializeFragment(i,{document:a}));let c,u=l.firstChild,p=0;for(;u&&1==u.nodeType&&(c=uo[u.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=a.createElement(c[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),p++}u=l.firstChild}u&&1==u.nodeType&&u.setAttribute("data-pm-slice",`${r} ${o}${p?` -${p}`:""} ${JSON.stringify(n)}`);let d=e.someProp("clipboardTextSerializer",(e=>e(t)))||t.content.textBetween(0,t.content.size,"\n\n");return{dom:l,text:d}}function io(e,t,n,i,r){let o,s,a=r.parent.type.spec.code;if(!n&&!t)return null;let l=t&&(i||a||!n);if(l){if(e.someProp("transformPastedText",(e=>{t=e(t,a||i)})),a)return t?new Ve(Pe.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):Ve.empty;let n=e.someProp("clipboardTextParser",(e=>e(t,r,i)));if(n)s=n;else{let n=r.marks(),{schema:i}=e.state,s=$t.fromSchema(i);o=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=o.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(i.text(e,n)))}))}}else e.someProp("transformPastedHTML",(e=>{n=e(n)})),o=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,i=ho().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e);(n=r&&uo[r[1].toLowerCase()])&&(e=n.map((e=>"<"+e+">")).join("")+e+n.map((e=>"</"+e+">")).reverse().join(""));if(i.innerHTML=e,n)for(let e=0;e<n.length;e++)i=i.querySelector(n[e])||i;return i}(n),Ci&&function(e){let t=e.querySelectorAll(yi?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let i=t[n];1==i.childNodes.length&&" "==i.textContent&&i.parentNode&&i.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),i)}}(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let e=+u[3];e>0&&o.firstChild;e--)o=o.firstChild;if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||St.fromSchema(e.state.schema);s=t.parseSlice(o,{preserveWhitespace:!(!l&&!u),context:r,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||ro.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(u)s=function(e,t){if(!e.size)return e;let n,i=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:r,openStart:o,openEnd:s}=e;for(let e=n.length-2;e>=0;e-=2){let t=i.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;r=Pe.from(t.create(n[e+1],r)),o++,s++}return new Ve(r,o,s)}(co(s,+u[1],+u[2]),u[4]);else if(s=Ve.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let i,r=t.node(n).contentMatchAt(t.index(n)),o=[];if(e.forEach((e=>{if(!o)return;let t,n=r.findWrapping(e.type);if(!n)return o=null;if(t=o.length&&i.length&&so(n,i,e,o[o.length-1],0))o[o.length-1]=t;else{o.length&&(o[o.length-1]=ao(o[o.length-1],i.length));let t=oo(e,n);o.push(t),r=r.matchType(t.type),i=n}})),o)return Pe.from(o)}return e}(s.content,r),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=co(s,e,t)}return e.someProp("transformPasted",(e=>{s=e(s)})),s}const ro=/^(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 oo(e,t,n=0){for(let i=t.length-1;i>=n;i--)e=t[i].create(null,Pe.from(e));return e}function so(e,t,n,i,r){if(r<e.length&&r<t.length&&e[r]==t[r]){let o=so(e,t,n,i.lastChild,r+1);if(o)return i.copy(i.content.replaceChild(i.childCount-1,o));if(i.contentMatchAt(i.childCount).matchType(r==e.length-1?n.type:e[r+1]))return i.copy(i.content.append(Pe.from(oo(n,e,r+1))))}}function ao(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,ao(e.lastChild,t-1)),i=e.contentMatchAt(e.childCount).fillBefore(Pe.empty,!0);return e.copy(n.append(i))}function lo(e,t,n,i,r,o){let s=t<0?e.firstChild:e.lastChild,a=s.content;return r<i-1&&(a=lo(a,t,n,i,r+1,o)),r>=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,e.childCount>1||o<=r).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(Pe.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function co(e,t,n){return t<e.openStart&&(e=new Ve(lo(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Ve(lo(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const uo={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 po=null;function ho(){return po||(po=document.implementation.createHTMLDocument("title"))}const fo={},mo={},go={touchstart:!0,touchmove:!0};class bo{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function vo(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function yo(e){e.someProp("handleDOMEvents",(t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>xo(e,t))}))}function xo(e,t){return e.someProp("handleDOMEvents",(n=>{let i=n[t.type];return!!i&&(i(e,t)||t.defaultPrevented)}))}function wo(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function _o(e){return{left:e.clientX,top:e.clientY}}function ko(e,t,n,i,r){if(-1==i)return!1;let o=e.state.doc.resolve(i);for(let i=o.depth+1;i>0;i--)if(e.someProp(t,(t=>i>o.depth?t(e,n,o.nodeAfter,o.before(i),r,!0):t(e,n,o.node(i),o.before(i),r,!1))))return!0;return!1}function Eo(e,t,n){e.focused||e.focus();let i=e.state.tr.setSelection(t);"pointer"==n&&i.setMeta("pointer",!0),e.dispatch(i)}function Co(e,t,n,i,r){return ko(e,"handleClickOn",t,n,i)||e.someProp("handleClick",(n=>n(e,t,i)))||(r?function(e,t){if(-1==t)return!1;let n,i,r=e.state.selection;r instanceof $n&&(n=r.node);let o=e.state.doc.resolve(t);for(let e=o.depth+1;e>0;e--){let t=e>o.depth?o.nodeAfter:o.node(e);if($n.isSelectable(t)){i=n&&r.$from.depth>0&&e>=r.$from.depth&&o.before(r.$from.depth+1)==r.$from.pos?o.before(r.$from.depth):o.before(e);break}}return null!=i&&(Eo(e,$n.create(e.state.doc,i),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),i=n.nodeAfter;return!!(i&&i.isAtom&&$n.isSelectable(i))&&(Eo(e,new $n(n),"pointer"),!0)}(e,n))}function Mo(e,t,n,i){return ko(e,"handleDoubleClickOn",t,n,i)||e.someProp("handleDoubleClick",(n=>n(e,t,i)))}function Oo(e,t,n,i){return ko(e,"handleTripleClickOn",t,n,i)||e.someProp("handleTripleClick",(n=>n(e,t,i)))||function(e,t,n){if(0!=n.button)return!1;let i=e.state.doc;if(-1==t)return!!i.inlineContent&&(Eo(e,Un.create(i,0,i.content.size),"pointer"),!0);let r=i.resolve(t);for(let t=r.depth+1;t>0;t--){let n=t>r.depth?r.nodeAfter:r.node(t),o=r.before(t);if(n.inlineContent)Eo(e,Un.create(i,o+1,o+1+n.content.size),"pointer");else{if(!$n.isSelectable(n))continue;Eo(e,$n.create(i,o),"pointer")}return!0}}(e,n,i)}function Do(e){return zo(e)}mo.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!No(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!Ei||!yi||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!_i||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",(t=>t(e,n)))||to(e,n)?n.preventDefault():vo(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,Ri(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},mo.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},mo.keypress=(e,t)=>{let n=t;if(No(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||ki&&n.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,n))))return void n.preventDefault();let i=e.state.selection;if(!(i instanceof Un&&i.$from.sameParent(i.$to))){let t=String.fromCharCode(n.charCode);e.someProp("handleTextInput",(n=>n(e,i.$from.pos,i.$to.pos,t)))||e.dispatch(e.state.tr.insertText(t).scrollIntoView()),n.preventDefault()}};const To=ki?"metaKey":"ctrlKey";fo.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let i=Do(e),r=Date.now(),o="singleClick";r-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,i=t.y-e.clientY;return n*n+i*i<100}(n,e.input.lastClick)&&!n[To]&&("singleClick"==e.input.lastClick.type?o="doubleClick":"doubleClick"==e.input.lastClick.type&&(o="tripleClick")),e.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:o};let s=e.posAtCoords(_o(n));s&&("singleClick"==o?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new So(e,s,n,!!i)):("doubleClick"==o?Mo:Oo)(e,s.pos,s.inside,n)?n.preventDefault():vo(e,"pointer"))};class So{constructor(e,t,n,i){let r,o;if(this.view=e,this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[To],this.allowDefault=n.shiftKey,t.inside>-1)r=e.state.doc.nodeAt(t.inside),o=t.inside;else{let n=e.state.doc.resolve(t.pos);r=n.parent,o=n.depth?n.before():0}const s=i?null:n.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a?a.dom:null;let{selection:l}=e.state;(0==n.button&&r.type.spec.draggable&&!1!==r.type.spec.selectable||l instanceof $n&&l.from<=o&&l.to>o)&&(this.mightDrag={node:r,pos:o,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!bi||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)),vo(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((()=>jr(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(_o(e))),this.updateAllowDefault(e),this.allowDefault||!t?vo(this.view,"pointer"):Co(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||wi&&this.mightDrag&&!this.mightDrag.node.isAtom||yi&&!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)?(Eo(this.view,Rn.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):vo(this.view,"pointer")}move(e){this.updateAllowDefault(e),vo(this.view,"pointer"),0==e.buttons&&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)}}function No(e,t){return!!e.composing||!!(wi&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}fo.touchstart=e=>{e.input.lastTouch=Date.now(),Do(e),vo(e,"pointer")},fo.touchmove=e=>{e.input.lastTouch=Date.now(),vo(e,"pointer")},fo.contextmenu=e=>Do(e);const Ao=Ei?5e3:-1;function jo(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>zo(e)),t))}function Lo(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function zo(e,t=!1){if(!(Ei&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Lo(e),t||e.docView&&e.docView.dirty){let t=Nr(e);return t&&!t.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(t)):e.updateState(e.state),!0}return!1}}mo.compositionstart=mo.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))))e.markCursor=e.state.storedMarks||n.marks(),zo(e,!0),e.markCursor=null;else if(zo(e),bi&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelection();for(let e=t.focusNode,n=t.focusOffset;e&&1==e.nodeType&&0!=n;){let i=n<0?e.lastChild:e.childNodes[n-1];if(!i)break;if(3==i.nodeType){t.collapse(i,i.nodeValue.length);break}e=i,n=-1}}e.input.composing=!0}jo(e,Ao)},mo.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,jo(e,20))};const Io=mi&&gi<15||_i&&Mi<604;function Ro(e,t,n,i){let r=io(e,t,n,e.input.shiftKey,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,i,r||Ve.empty))))return!0;if(!r)return!1;let o=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(r),s=o?e.state.tr.replaceSelectionWith(o,e.input.shiftKey):e.state.tr.replaceSelection(r);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}fo.copy=mo.cut=(e,t)=>{let n=t,i=e.state.selection,r="cut"==n.type;if(i.empty)return;let o=Io?null:n.clipboardData,s=i.content(),{dom:a,text:l}=no(e,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),r=document.createRange();r.selectNodeContents(t),e.dom.blur(),i.removeAllRanges(),i.addRange(r),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}(e,a),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},mo.paste=(e,t)=>{let n=t;if(e.composing&&!Ei)return;let i=Io?null:n.clipboardData;i&&Ro(e,i.getData("text/plain"),i.getData("text/html"),n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,i=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{e.focus(),i.parentNode&&i.parentNode.removeChild(i),n?Ro(e,i.value,null,t):Ro(e,i.textContent,i.innerHTML,t)}),50)}(e,n)};class Fo{constructor(e,t){this.slice=e,this.move=t}}const Bo=ki?"altKey":"ctrlKey";fo.dragstart=(e,t)=>{let n=t,i=e.input.mouseDown;if(i&&i.done(),!n.dataTransfer)return;let r=e.state.selection,o=r.empty?null:e.posAtCoords(_o(n));if(o&&o.pos>=r.from&&o.pos<=(r instanceof $n?r.to-1:r.to));else if(i&&i.mightDrag)e.dispatch(e.state.tr.setSelection($n.create(e.state.doc,i.mightDrag.pos)));else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&e.dispatch(e.state.tr.setSelection($n.create(e.state.doc,t.posBefore)))}let s=e.state.selection.content(),{dom:a,text:l}=no(e,s);n.dataTransfer.clearData(),n.dataTransfer.setData(Io?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Io||n.dataTransfer.setData("text/plain",l),e.dragging=new Fo(s,!n[Bo])},fo.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},mo.dragover=mo.dragenter=(e,t)=>t.preventDefault(),mo.drop=(e,t)=>{let n=t,i=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let r=e.posAtCoords(_o(n));if(!r)return;let o=e.state.doc.resolve(r.pos),s=i&&i.slice;s?e.someProp("transformPasted",(e=>{s=e(s)})):s=io(e,n.dataTransfer.getData(Io?"Text":"text/plain"),Io?null:n.dataTransfer.getData("text/html"),!1,o);let a=!(!i||n[Bo]);if(e.someProp("handleDrop",(t=>t(e,n,s||Ve.empty,a))))return void n.preventDefault();if(!s)return;n.preventDefault();let l=s?wn(e.state.doc,o.pos,s):o.pos;null==l&&(l=o.pos);let c=e.state.tr;a&&c.deleteSelection();let u=c.mapping.map(l),p=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,d=c.doc;if(p?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(d))return;let h=c.doc.resolve(u);if(p&&$n.isSelectable(s.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new $n(h));else{let t=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach(((e,n,i,r)=>t=r)),c.setSelection(Pr(e,h,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},fo.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelection())&&jr(e)}),20))},fo.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},fo.beforeinput=(e,t)=>{if(yi&&Ei&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,Ri(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let e in mo)fo[e]=mo[e];function Po(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class Uo{constructor(e,t){this.toDOM=e,this.spec=t||Vo,this.side=this.spec.side||0}map(e,t,n,i){let{pos:r,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new Wo(r-n,r-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Uo&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Po(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ho{constructor(e,t){this.attrs=e,this.spec=t||Vo}map(e,t,n,i){let r=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return r>=o?null:new Wo(r,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ho&&Po(this.attrs,e.attrs)&&Po(this.spec,e.spec)}static is(e){return e.type instanceof Ho}destroy(){}}class $o{constructor(e,t){this.attrs=e,this.spec=t||Vo}map(e,t,n,i){let r=e.mapResult(t.from+i,1);if(r.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=r.pos?null:new Wo(r.pos-n,o.pos-n,this)}valid(e,t){let n,{index:i,offset:r}=e.content.findIndex(t.from);return r==t.from&&!(n=e.child(i)).isText&&r+n.nodeSize==t.to}eq(e){return this==e||e instanceof $o&&Po(this.attrs,e.attrs)&&Po(this.spec,e.spec)}destroy(){}}class Wo{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Wo(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Wo(e,e,new Uo(t,n))}static inline(e,t,n,i){return new Wo(e,t,new Ho(n,i))}static node(e,t,n,i){return new Wo(e,t,new $o(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ho}}const qo=[],Vo={};class Ko{constructor(e,t){this.local=e.length?e:qo,this.children=t.length?t:qo}static create(e,t){return t.length?Xo(t,e,0,Vo):Go}find(e,t,n){let i=[];return this.findInner(null==e?0:e,null==t?1e9:t,i,0,n),i}findInner(e,t,n,i,r){for(let o=0;o<this.local.length;o++){let s=this.local[o];s.from<=t&&s.to>=e&&(!r||r(s.spec))&&n.push(s.copy(s.from+i,s.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let s=this.children[o]+1;this.children[o+2].findInner(e-s,t-s,n,i+s,r)}}map(e,t,n){return this==Go||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Vo)}mapInner(e,t,n,i,r){let o;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(e,n,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):r.onRemove&&r.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,i,r,o,s){let a=e.slice();for(let e=0,t=o;e<n.maps.length;e++){let i=0;n.maps[e].forEach(((e,n,o,s)=>{let l=s-o-(n-e);for(let s=0;s<a.length;s+=3){let c=a[s+1];if(c<0||e>c+t-i)continue;let u=a[s]+t-i;n>=u?a[s+1]=e<=u?-2:-1:o>=r&&l&&(a[s]+=l,a[s+1]+=l)}i+=l})),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let c=n.map(e[t]+o),u=c-r;if(u<0||u>=i.content.size){l=!0;continue}let p=n.map(e[t+1]+o,-1)-r,{index:d,offset:h}=i.content.findIndex(u),f=i.maybeChild(d);if(f&&h==u&&h+f.nodeSize==p){let i=a[t+2].mapInner(n,f,c+1,e[t]+o+1,s);i!=Go?(a[t]=u,a[t+1]=p,a[t+2]=i):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,n,i,r,o,s){function a(e,t){for(let o=0;o<e.local.length;o++){let a=e.local[o].map(i,r,t);a?n.push(a):s.onRemove&&s.onRemove(e.local[o].spec)}for(let n=0;n<e.children.length;n+=3)a(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&a(e[n+2],t[n]+o+1);return n}(a,e,t,n,r,o,s),c=Xo(l,i,0,s);t=c.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new Ko(t.sort(es),a)}(this.children,o||[],e,t,n,i,r):o?new Ko(o.sort(es),qo):Go}add(e,t){return t.length?this==Go?Ko.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,r=0;e.forEach(((e,o)=>{let s,a=o+n;if(s=Zo(t,e,a)){for(i||(i=this.children.slice());r<i.length&&i[r]<o;)r+=3;i[r]==o?i[r+2]=i[r+2].addInner(e,s,a+1):i.splice(r,0,o,o+e.nodeSize,Xo(s,e,a+1,Vo)),r+=3}}));let o=Qo(r?Jo(t):t,-n);for(let t=0;t<o.length;t++)o[t].type.valid(e,o[t])||o.splice(t--,1);return new Ko(o.length?this.local.concat(o).sort(es):this.local,i||this.children)}remove(e){return 0==e.length||this==Go?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let i=0;i<n.length;i+=3){let r,o=n[i]+t,s=n[i+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>o&&t.to<s&&(e[n]=null,(r||(r=[])).push(t));if(!r)continue;n==this.children&&(n=this.children.slice());let a=n[i+2].removeInner(r,o+1);a!=Go?n[i+2]=a:(n.splice(i,3),i-=3)}if(i.length)for(let n,r=0;r<e.length;r++)if(n=e[r])for(let e=0;e<i.length;e++)i[e].eq(n,t)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1));return n==this.children&&i==this.local?this:i.length||n.length?new Ko(i,n):Go}forChild(e,t){if(this==Go)return this;if(t.isLeaf)return Ko.empty;let n,i;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let r=e+1,o=r+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>r&&t.type instanceof Ho){let e=Math.max(r,t.from)-r,n=Math.min(o,t.to)-r;e<n&&(i||(i=[])).push(t.copy(e,n))}}if(i){let e=new Ko(i.sort(es),qo);return n?new Yo([e,n]):e}return n||Go}eq(e){if(this==e)return!0;if(!(e instanceof Ko)||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 ts(this.localsInner(e))}localsInner(e){if(this==Go)return qo;if(e.inlineContent||!this.local.some(Ho.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof Ho||t.push(this.local[e]);return t}}Ko.empty=new Ko([],[]),Ko.removeOverlap=ts;const Go=Ko.empty;class Yo{constructor(e){this.members=e}map(e,t){const n=this.members.map((n=>n.map(e,t,Vo)));return Yo.from(n)}forChild(e,t){if(t.isLeaf)return Ko.empty;let n=[];for(let i=0;i<this.members.length;i++){let r=this.members[i].forChild(e,t);r!=Go&&(r instanceof Yo?n=n.concat(r.members):n.push(r))}return Yo.from(n)}eq(e){if(!(e instanceof Yo)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let i=0;i<this.members.length;i++){let r=this.members[i].localsInner(e);if(r.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<r.length;e++)t.push(r[e])}else t=r}return t?ts(n?t:t.sort(es)):qo}static from(e){switch(e.length){case 0:return Go;case 1:return e[0];default:return new Yo(e)}}}function Qo(e,t){if(!t||!e.length)return e;let n=[];for(let i=0;i<e.length;i++){let r=e[i];n.push(new Wo(r.from+t,r.to+t,r.type))}return n}function Zo(e,t,n){if(t.isLeaf)return null;let i=n+t.nodeSize,r=null;for(let t,o=0;o<e.length;o++)(t=e[o])&&t.from>n&&t.to<i&&((r||(r=[])).push(t),e[o]=null);return r}function Jo(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Xo(e,t,n,i){let r=[],o=!1;t.forEach(((t,s)=>{let a=Zo(e,t,s+n);if(a){o=!0;let e=Xo(a,t,n+s+1,i);e!=Go&&r.push(s,s+t.nodeSize,e)}}));let s=Qo(o?Jo(e):e,-n).sort(es);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(i.onRemove&&i.onRemove(s[e].spec),s.splice(e--,1));return s.length||r.length?new Ko(s,r):Go}function es(e,t){return e.from-t.from||e.to-t.to}function ts(e){let t=e;for(let n=0;n<t.length-1;n++){let i=t[n];if(i.from!=i.to)for(let r=n+1;r<t.length;r++){let o=t[r];if(o.from!=i.from){o.from<i.to&&(t==e&&(t=e.slice()),t[n]=i.copy(i.from,o.from),ns(t,r,i.copy(o.from,i.to)));break}o.to!=i.to&&(t==e&&(t=e.slice()),t[r]=o.copy(o.from,i.to),ns(t,r+1,o.copy(i.to,o.to)))}}return t}function ns(e,t,n){for(;t<e.length&&es(n,e[t])>0;)t++;e.splice(t,0,n)}function is(e){let t=[];return e.someProp("decorations",(n=>{let i=n(e.state);i&&i!=Go&&t.push(i)})),e.cursorWrapper&&t.push(Ko.create(e.state.doc,[e.cursorWrapper.deco])),Yo.from(t)}const rs={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ss=mi&&gi<=11;class as{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 ls{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new as,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver((e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);mi&&gi<=11&&e.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),ss&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,rs)),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(Ur(this.view)){if(this.suppressingSelectionUpdates)return jr(this.view);if(mi&&gi<=11&&!this.view.state.selection.empty){let e=this.view.domSelection();if(e.focusNode&&Ni(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelection())}ignoreSelectionChange(e){if(0==e.rangeCount)return!0;let t=e.getRangeAt(0).commonAncestorContainer,n=this.view.docView.nearestDesc(t);return n&&n.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);let n=e.domSelection(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Ur(e)&&!this.ignoreSelectionChange(n),r=-1,o=-1,s=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],a);n&&(r=r<0?n.from:Math.min(n.from,r),o=o<0?n.to:Math.max(n.to,o),n.typeOver&&(s=!0))}if(bi&&a.length>1){let e=a.filter((e=>"BR"==e.nodeName));if(2==e.length){let t=e[0],n=e[1];t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}}let l=null;r<0&&i&&e.input.lastFocus>Date.now()-200&&e.input.lastTouch<Date.now()-300&&Ii(n)&&(l=Nr(e))&&l.eq(Rn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,jr(e),this.currentSelection.set(n),e.scrollToSelection()):(r>-1||i)&&(r>-1&&(e.docView.markDirty(r,o),function(e){if(cs.has(e))return;if(cs.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=bi,us)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."),us=!0}}(e)),this.handleDOMChange(r,o,s,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||jr(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++)t.push(e.addedNodes[n]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,r=e.nextSibling;if(mi&&gi<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:o}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(i=n),(!o||Array.prototype.indexOf.call(e.addedNodes,o)<0)&&(r=o)}let o=i&&i.parentNode==e.target?Oi(i)+1:0,s=n.localPosFromDOM(e.target,o,-1),a=r&&r.parentNode==e.target?Oi(r):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}let cs=new WeakMap,us=!1;function ps(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(wi&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||wi&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}function ds(e,t,n,i,r){if(t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=Nr(e,t);if(n&&!e.state.selection.eq(n)){let i=e.state.tr.setSelection(n);"pointer"==t?i.setMeta("pointer",!0):"key"==t&&i.scrollIntoView(),e.dispatch(i)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let a,l,c=e.state.selection,u=function(e,t,n){let i,{node:r,fromOffset:o,toOffset:s,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelection(),u=c.anchorNode;if(u&&e.dom.contains(1==u.nodeType?u:u.parentNode)&&(i=[{node:u,offset:c.anchorOffset}],Ii(c)||i.push({node:c.focusNode,offset:c.focusOffset})),yi&&8===e.input.lastKeyCode)for(let e=s;e>o;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let p=e.state.doc,d=e.someProp("domParser")||St.fromSchema(e.state.schema),h=p.resolve(a),f=null,m=d.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:o,to:s,preserveWhitespace:"pre"!=h.parent.type.whitespace||"full",findPositions:i,ruleFromNode:ps,context:h});if(i&&null!=i[0].pos){let e=i[0].pos,t=i[1]&&i[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n),p=e.state.doc,d=p.slice(u.from,u.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(a=e.state.selection.to,l="end"):(a=e.state.selection.from,l="start"),e.input.lastKeyCode=null;let h=function(e,t,n,i,r){let o=e.findDiffStart(t,n);if(null==o)return null;let{a:s,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==r){i-=s+Math.max(0,o-Math.min(s,a))-o}if(s<o&&e.size<t.size){o-=i<=o&&i>=s?o-i:0,a=o+(a-s),s=o}else if(a<o){o-=i<=o&&i>=a?o-i:0,s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}(d.content,u.doc.content,u.from,a,l);if((_i&&e.input.lastIOSEnter>Date.now()-225||Ei)&&r.some((e=>"DIV"==e.nodeName||"P"==e.nodeName))&&(!h||h.endA>=h.endB)&&e.someProp("handleKeyDown",(t=>t(e,Ri(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!h){if(!(i&&c instanceof Un&&!c.empty&&c.$head.sameParent(c.$anchor))||e.composing||u.sel&&u.sel.anchor!=u.sel.head){if(u.sel){let t=hs(e,e.state.doc,u.sel);t&&!t.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(t))}return}h={start:c.from,endA:c.to,endB:c.to}}if(yi&&e.cursorWrapper&&u.sel&&u.sel.anchor==e.cursorWrapper.deco.from&&u.sel.head==u.sel.anchor){let e=h.endB-h.start;u.sel={anchor:u.sel.anchor+e,head:u.sel.anchor+e}}e.input.domChangeCount++,e.state.selection.from<e.state.selection.to&&h.start==h.endB&&e.state.selection instanceof Un&&(h.start>e.state.selection.from&&h.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?h.start=e.state.selection.from:h.endA<e.state.selection.to&&h.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(h.endB+=e.state.selection.to-h.endA,h.endA=e.state.selection.to)),mi&&gi<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>u.from&&" "==u.doc.textBetween(h.start-u.from-1,h.start-u.from+1)&&(h.start--,h.endA--,h.endB--);let f,m=u.doc.resolveNoCache(h.start-u.from),g=u.doc.resolveNoCache(h.endB-u.from),b=p.resolve(h.start),v=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=h.endA;if((_i&&e.input.lastIOSEnter>Date.now()-225&&(!v||r.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!v&&m.pos<u.doc.content.size&&(f=Rn.findFrom(u.doc.resolve(m.pos+1),1,!0))&&f.head==g.pos)&&e.someProp("handleKeyDown",(t=>t(e,Ri(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>h.start&&function(e,t,n,i,r){if(!i.parent.isTextblock||n-t<=r.pos-i.pos||fs(i,!0,!1)<r.pos)return!1;let o=e.resolve(t);if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=e.resolve(fs(o,!0,!0));return!(!s.parent.isTextblock||s.pos>n||fs(s,!0,!1)<n)&&i.parent.content.cut(i.parentOffset).eq(s.parent.content)}(p,h.start,h.endA,m,g)&&e.someProp("handleKeyDown",(t=>t(e,Ri(8,"Backspace")))))return void(Ei&&yi&&e.domObserver.suppressSelectionUpdates());yi&&Ei&&h.endB==h.start&&(e.input.lastAndroidDelete=Date.now()),Ei&&!v&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==h.endA&&(h.endB-=2,g=u.doc.resolveNoCache(h.endB-u.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,Ri(13,"Enter"))}))}),20));let y,x,w,_=h.start,k=h.endA;if(v)if(m.pos==g.pos)mi&&gi<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>jr(e)),20)),y=e.state.tr.delete(_,k),x=p.resolve(h.start).marksAcross(p.resolve(h.endA));else if(h.endA==h.endB&&(w=function(e,t){let n,i,r,o=e.firstChild.marks,s=t.firstChild.marks,a=o,l=s;for(let e=0;e<s.length;e++)a=s[e].removeFromSet(a);for(let e=0;e<o.length;e++)l=o[e].removeFromSet(l);if(1==a.length&&0==l.length)i=a[0],n="add",r=e=>e.mark(i.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;i=l[0],n="remove",r=e=>e.mark(i.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(r(t.child(e)));if(Pe.from(c).eq(e))return{mark:i,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,h.endA-b.start()))))y=e.state.tr,"add"==w.type?y.addMark(_,k,w.mark):y.removeMark(_,k,w.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let t=m.parent.textBetween(m.parentOffset,g.parentOffset);if(e.someProp("handleTextInput",(n=>n(e,_,k,t))))return;y=e.state.tr.insertText(t,_,k)}if(y||(y=e.state.tr.replace(_,k,u.doc.slice(h.start-u.from,h.endB-u.from))),u.sel){let t=hs(e,y.doc,u.sel);t&&!(yi&&Ei&&e.composing&&t.empty&&(h.start!=h.endB||e.input.lastAndroidDelete<Date.now()-100)&&(t.head==_||t.head==y.mapping.map(k)-1)||mi&&t.empty&&t.head==_)&&y.setSelection(t)}x&&y.ensureMarks(x),e.dispatch(y.scrollIntoView())}function hs(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Pr(e,t.resolve(n.anchor),t.resolve(n.head))}function fs(e,t,n){let i=e.depth,r=t?e.end():e.pos;for(;i>0&&(t||e.indexAfter(i)==e.node(i).childCount);)i--,r++,t=!1;if(n){let t=e.node(i).maybeChild(e.indexAfter(i));for(;t&&!t.isLeaf;)t=t.firstChild,r++}return r}class ms{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 bo,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(xs),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=vs(this),bs(this),this.nodeViews=ys(this),this.docView=mr(this.state.doc,gs(this),is(this),this.dom,this),this.domObserver=new ls(this,((e,t,n,i)=>ds(this,e,t,n,i))),this.domObserver.start(),function(e){for(let t in fo){let n=fo[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!wo(e,t)||xo(e,t)||!e.editable&&t.type in mo||n(e,t)},go[t]?{passive:!0}:void 0)}wi&&e.dom.addEventListener("input",(()=>null)),yo(e)}(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&&yo(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(xs),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,i=!1,r=!1;e.storedMarks&&this.composing&&(Lo(this),r=!0),this.state=e;let o=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(o||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=ys(this);(function(e,t){let n=0,i=0;for(let i in e){if(e[i]!=t[i])return!0;n++}for(let e in t)i++;return n!=i})(e,this.nodeViews)&&(this.nodeViews=e,i=!0)}(o||t.handleDOMEvents!=this._props.handleDOMEvents)&&yo(this),this.editable=vs(this),bs(this);let s=is(this),a=gs(this),l=n.plugins==e.plugins||n.doc.eq(e.doc)?e.scrollToSelection>n.scrollToSelection?"to selection":"preserve":"reset",c=i||!this.docView.matchesNode(e.doc,a,s);!c&&e.selection.eq(n.selection)||(r=!0);let u="preserve"==l&&r&&null==this.dom.style.overflowAnchor&&function(e){let t,n,i=e.dom.getBoundingClientRect(),r=Math.max(0,i.top);for(let o=(i.left+i.right)/2,s=r+1;s<Math.min(innerHeight,i.bottom);s+=5){let i=e.root.elementFromPoint(o,s);if(!i||i==e.dom||!e.dom.contains(i))continue;let a=i.getBoundingClientRect();if(a.top>=r-20){t=i,n=a.top;break}}return{refDOM:t,refTop:n,stack:Hi(e.dom)}}(this);if(r){this.domObserver.stop();let t=c&&(mi||yi)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(n.selection,e.selection);if(c){let n=yi?this.trackWrites=this.domSelection().focusNode:null;!i&&this.docView.update(e.doc,a,s,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=mr(e.doc,a,s,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelection())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelection();return Ni(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?jr(this,t):(Fr(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():u&&function({refDOM:e,refTop:t,stack:n}){let i=e?e.getBoundingClientRect().top:0;$i(n,0==i?0:i-t)}(u)}scrollToSelection(){let e=this.domSelection().focusNode;if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(this.state.selection instanceof $n){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&Ui(this,t.getBoundingClientRect(),e)}else Ui(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)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}someProp(e,t){let n,i=this._props&&this._props[e];if(null!=i&&(n=t?t(i):i))return n;for(let i=0;i<this.directPlugins.length;i++){let r=this.directPlugins[i].props[e];if(null!=r&&(n=t?t(r):r))return n}let r=this.state.plugins;if(r)for(let i=0;i<r.length;i++){let o=r[i].props[e];if(null!=o&&(n=t?t(o):o))return n}}hasFocus(){if(mi){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("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Wi)return e.focus(Wi);let t=Hi(e);e.focus(null==Wi?{get preventScroll(){return Wi={preventScroll:!0},!0}}:void 0),Wi||(Wi=!1,$i(t,0))}(this.dom),jr(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}posAtCoords(e){return Gi(this,e)}coordsAtPos(e,t=1){return Zi(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(null==i)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return or(this,t||this.state,e)}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],is(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){xo(e,t)||!fo[t.type]||!e.editable&&t.type in mo||fo[t.type](e,t)}(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelection(){return this.root.getSelection()}}function gs(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),t.translate="no",e.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e&&(t.class+=" "+n[e]),"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))})),[Wo.node(0,e.state.doc.content.size,t)]}function bs(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Wo.widget(e.state.selection.head,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function vs(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function ys(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function xs(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var ws={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:"'"},_s={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ks="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent);"undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent);for(var Es="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Cs="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ms=Es||ks&&+ks[1]<57,Os=0;Os<10;Os++)ws[48+Os]=ws[96+Os]=String(Os);for(Os=1;Os<=24;Os++)ws[Os+111]="F"+Os;for(Os=65;Os<=90;Os++)ws[Os]=String.fromCharCode(Os+32),_s[Os]=String.fromCharCode(Os);for(var Ds in ws)_s.hasOwnProperty(Ds)||(_s[Ds]=ws[Ds]);const Ts="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function Ss(e){let t,n,i,r,o=e.split(/-(?!$)/),s=o[o.length-1];"Space"==s&&(s=" ");for(let e=0;e<o.length-1;e++){let s=o[e];if(/^(cmd|meta|m)$/i.test(s))r=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))i=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);Ts?r=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),r&&(s="Meta-"+s),i&&(s="Shift-"+s),s}function Ns(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}function As(e){let t=function(e){let t=Object.create(null);for(let n in e)t[Ss(n)]=e[n];return t}(e);return function(e,n){let i,r=function(e){var t=!(Ms&&(e.ctrlKey||e.altKey||e.metaKey)||Cs&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?_s:ws)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),o=1==r.length&&" "!=r,s=t[Ns(r,n,!o)];if(s&&s(e.state,e.dispatch,e))return!0;if(o&&(n.shiftKey||n.altKey||n.metaKey||r.charCodeAt(0)>127)&&(i=ws[n.keyCode])&&i!=r){let r=t[Ns(i,n,!0)];if(r&&r(e.state,e.dispatch,e))return!0}else if(o&&n.shiftKey){let i=t[Ns(r,n,!0)];if(i&&i(e.state,e.dispatch,e))return!0}return!1}}function js(e,t,n=!1){for(let i=e;i;i="start"==t?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(n&&1!=i.childCount)return!1}return!1}function Ls(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function zs(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function Is(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Rs(e,t,n){let i,r,o=t.nodeBefore,s=t.nodeAfter;if(o.type.spec.isolating||s.type.spec.isolating)return!1;if(function(e,t,n){let i=t.nodeBefore,r=t.nodeAfter,o=t.index();return!(!(i&&r&&i.type.compatibleContent(r.type))||(!i.content.size&&t.parent.canReplace(o-1,o)?(n&&n(e.tr.delete(t.pos-i.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(o,o+1)||!r.isTextblock&&!xn(e.doc,t.pos)||(n&&n(e.tr.clearIncompatible(t.pos,i.type,i.contentMatchAt(i.childCount)).join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let a=t.parent.canReplace(t.index(),t.index()+1);if(a&&(i=(r=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&r.matchType(i[0]||s.type).validEnd){if(n){let r=t.pos+s.nodeSize,a=Pe.empty;for(let e=i.length-1;e>=0;e--)a=Pe.from(i[e].create(null,a));a=Pe.from(o.copy(a));let l=e.tr.step(new hn(t.pos-1,r,t.pos,r,new Ve(a,1,0),i.length,!0)),c=r+2*i.length;xn(l.doc,c)&&l.join(c),n(l.scrollIntoView())}return!0}let l=Rn.findFrom(t,1),c=l&&l.$from.blockRange(l.$to),u=c&&gn(c);if(null!=u&&u>=t.depth)return n&&n(e.tr.lift(c,u).scrollIntoView()),!0;if(a&&js(s,"start",!0)&&js(o,"end")){let i=o,r=[];for(;r.push(i),!i.isTextblock;)i=i.lastChild;let a=s,l=1;for(;!a.isTextblock;a=a.firstChild)l++;if(i.canReplace(i.childCount,i.childCount,a.content)){if(n){let i=Pe.empty;for(let e=r.length-1;e>=0;e--)i=Pe.from(r[e].copy(i));n(e.tr.step(new hn(t.pos-r.length,t.pos+s.nodeSize,t.pos+l,t.pos+s.nodeSize-l,new Ve(i,r.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Fs(e){return function(t,n){let i=t.selection,r=e<0?i.$from:i.$to,o=r.depth;for(;r.node(o).isInline;){if(!o)return!1;o--}return!!r.node(o).isTextblock&&(n&&n(t.tr.setSelection(Un.create(t.doc,e<0?r.start(o):r.end(o)))),!0)}}const Bs=Fs(-1),Ps=Fs(1);function Us(e,t=null){return function(n,i){let{from:r,to:o}=n.selection,s=!1;return n.doc.nodesBetween(r,o,((i,r)=>{if(s)return!1;if(i.isTextblock&&!i.hasMarkup(e,t))if(i.type==e)s=!0;else{let t=n.doc.resolve(r),i=t.index();s=t.parent.canReplaceWith(i,i+1,e)}})),!!s&&(i&&i(n.tr.setBlockType(r,o,e,t).scrollIntoView()),!0)}}function Hs(e,t=null){return function(n,i){let{$from:r,$to:o}=n.selection,s=r.blockRange(o),a=!1,l=s;if(!s)return!1;if(s.depth>=2&&r.node(s.depth-1).type.compatibleContent(e)&&0==s.startIndex){if(0==r.index(s.depth-1))return!1;let e=n.doc.resolve(s.start-2);l=new lt(e,e,s.depth),s.endIndex<s.parent.childCount&&(s=new lt(r,n.doc.resolve(o.end(s.depth)),s.depth)),a=!0}let c=bn(l,e,t,s);return!!c&&(i&&i(function(e,t,n,i,r){let o=Pe.empty;for(let e=n.length-1;e>=0;e--)o=Pe.from(n[e].type.create(n[e].attrs,o));e.step(new hn(t.start-(i?2:0),t.end,t.start,t.end,new Ve(o,0,0),n.length,!0));let s=0;for(let e=0;e<n.length;e++)n[e].type==r&&(s=e+1);let a=n.length-s,l=t.start+n.length-(i?2:0),c=t.parent;for(let n=t.startIndex,i=t.endIndex,r=!0;n<i;n++,r=!1)!r&&yn(e.doc,l,a)&&(e.split(l,a),l+=2*a),l+=c.child(n).nodeSize;return e}(n.tr,s,c,a,e).scrollIntoView()),!0)}}function $s(e){return function(t,n){let{$from:i,$to:r}=t.selection,o=i.blockRange(r,(t=>t.childCount>0&&t.firstChild.type==e));return!!o&&(!n||(i.node(o.depth-1).type==e?function(e,t,n,i){let r=e.tr,o=i.end,s=i.$to.end(i.depth);o<s&&(r.step(new hn(o-1,s,o,s,new Ve(Pe.from(n.create(null,i.parent.copy())),1,0),1,!0)),i=new lt(r.doc.resolve(i.$from.pos),r.doc.resolve(s),i.depth));const a=gn(i);if(null==a)return!1;r.lift(i,a);let l=r.mapping.map(o,-1)-1;xn(r.doc,l)&&r.join(l);return t(r.scrollIntoView()),!0}(t,n,e,o):function(e,t,n){let i=e.tr,r=n.parent;for(let e=n.end,t=n.endIndex-1,o=n.startIndex;t>o;t--)e-=r.child(t).nodeSize,i.delete(e-1,e+1);let o=i.doc.resolve(n.start),s=o.nodeAfter;if(i.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==r.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(a?0:1),u+1,s.content.append(l?Pe.empty:Pe.from(r))))return!1;let p=o.pos,d=p+s.nodeSize;return i.step(new hn(p-(a?1:0),d+(l?1:0),p+1,d-1,new Ve((a?Pe.empty:Pe.from(r.copy(Pe.empty))).append(l?Pe.empty:Pe.from(r.copy(Pe.empty))),a?0:1,l?0:1),a?0:1)),t(i.scrollIntoView()),!0}(t,n,o)))}}function Ws(e){const{state:t,transaction:n}=e;let{selection:i}=n,{doc:r}=n,{storedMarks:o}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),filterTransaction:t.filterTransaction,plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return o},get selection(){return i},get doc(){return r},get tr(){return i=n.selection,r=n.doc,o=n.storedMarks,n}}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();class qs{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:n}=this,{view:i}=t,{tr:r}=n,o=this.buildProps(r);return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,(...e)=>{const n=t(...e)(o);return r.getMeta("preventDispatch")||this.hasCustomState||i.dispatch(r),n}])))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:i,state:r}=this,{view:o}=i,s=[],a=!!e,l=e||r.tr,c={...Object.fromEntries(Object.entries(n).map((([e,n])=>[e,(...e)=>{const i=this.buildProps(l,t),r=n(...e)(i);return s.push(r),c}]))),run:()=>(a||!t||l.getMeta("preventDispatch")||this.hasCustomState||o.dispatch(l),s.every((e=>!0===e)))};return c}createCan(e){const{rawCommands:t,state:n}=this,i=!1,r=e||n.tr,o=this.buildProps(r,i),s=Object.fromEntries(Object.entries(t).map((([e,t])=>[e,(...e)=>t(...e)({...o,dispatch:void 0})])));return{...s,chain:()=>this.createChain(r,i)}}buildProps(e,t=!0){const{rawCommands:n,editor:i,state:r}=this,{view:o}=i;r.storedMarks&&e.setStoredMarks(r.storedMarks);const s={tr:e,editor:i,view:o,state:Ws({state:r,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map((([e,t])=>[e,(...e)=>t(...e)(s)])))}};return s}}function Vs(e,t,n){if(void 0===e.config[t]&&e.parent)return Vs(e.parent,t,n);if("function"==typeof e.config[t]){return e.config[t].bind({...n,parent:e.parent?Vs(e.parent,t,n):null})}return e.config[t]}function Ks(e){return{baseExtensions:e.filter((e=>"extension"===e.type)),nodeExtensions:e.filter((e=>"node"===e.type)),markExtensions:e.filter((e=>"mark"===e.type))}}function Gs(e){const t=[],{nodeExtensions:n,markExtensions:i}=Ks(e),r=[...n,...i],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach((e=>{const n=Vs(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage});if(!n)return;n().forEach((e=>{e.types.forEach((n=>{Object.entries(e.attributes).forEach((([e,i])=>{t.push({type:n,name:e,attribute:{...o,...i}})}))}))}))})),r.forEach((e=>{const n={name:e.name,options:e.options,storage:e.storage},i=Vs(e,"addAttributes",n);if(!i)return;const r=i();Object.entries(r).forEach((([n,i])=>{const r={...o,...i};(null==i?void 0:i.isRequired)&&void 0===(null==i?void 0:i.default)&&delete r.default,t.push({type:e.name,name:n,attribute:r})}))})),t}function Ys(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function Qs(...e){return e.filter((e=>!!e)).reduce(((e,t)=>{const n={...e};return Object.entries(t).forEach((([e,t])=>{n[e]?n[e]="class"===e?[n[e],t].join(" "):"style"===e?[n[e],t].join("; "):t:n[e]=t})),n}),{})}function Zs(e,t){return t.filter((e=>e.attribute.rendered)).map((t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]})).reduce(((e,t)=>Qs(e,t)),{})}function Js(e){return"function"==typeof e}function Xs(e,t=void 0,...n){return Js(e)?t?e.bind(t)(...n):e(...n):e}function ea(e,t){return e.style?e:{...e,getAttrs:n=>{const i=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===i)return!1;const r=t.reduce(((e,t)=>{const i=t.attribute.parseHTML?t.attribute.parseHTML(n):function(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}(n.getAttribute(t.name));return null==i?e:{...e,[t.name]:i}}),{});return{...i,...r}}}}function ta(e){return Object.fromEntries(Object.entries(e).filter((([e,t])=>("attrs"!==e||!function(e={}){return 0===Object.keys(e).length&&e.constructor===Object}(t))&&null!=t)))}function na(e,t){return t.nodes[e]||t.marks[e]||null}function ia(e,t){return Array.isArray(t)?t.some((t=>("string"==typeof t?t:t.name)===e.name)):t}function ra(e){return"[object RegExp]"===Object.prototype.toString.call(e)}class oa{constructor(e){this.find=e.find,this.handler=e.handler}}function sa(e){var t;const{editor:n,from:i,to:r,text:o,rules:s,plugin:a}=e,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(i);if(c.parent.type.spec.code||(null===(t=c.nodeBefore||c.nodeAfter)||void 0===t?void 0:t.marks.find((e=>e.type.spec.code))))return!1;let u=!1;const p=((e,t=500)=>{let n="";const i=e.parentOffset;return e.parent.nodesBetween(Math.max(0,i-t),i,((e,t,r,o)=>{var s,a;const l=(null===(a=(s=e.type.spec).toText)||void 0===a?void 0:a.call(s,{node:e,pos:t,parent:r,index:o}))||e.textContent||"%leaf%";n+=l.slice(0,Math.max(0,i-t))})),n})(c)+o;return s.forEach((e=>{if(u)return;const t=((e,t)=>{if(ra(t))return t.exec(e);const n=t(e);if(!n)return null;const i=[];return i.push(n.text),i.index=n.index,i.input=e,i.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),i.push(n.replaceWith)),i})(p,e.find);if(!t)return;const s=l.state.tr,c=Ws({state:l.state,transaction:s}),d={from:i-(t[0].length-o.length),to:r},{commands:h,chain:f,can:m}=new qs({editor:n,state:c});null!==e.handler({state:c,range:d,match:t,commands:h,chain:f,can:m})&&s.steps.length&&(s.setMeta(a,{transform:s,from:i,to:r,text:o}),l.dispatch(s),u=!0)})),u}function aa(e){const{editor:t,rules:n}=e,i=new oi({state:{init:()=>null,apply(e,t){const n=e.getMeta(i);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(e,r,o,s)=>sa({editor:t,from:r,to:o,text:s,rules:n,plugin:i}),handleDOMEvents:{compositionend:e=>(setTimeout((()=>{const{$cursor:r}=e.state.selection;r&&sa({editor:t,from:r.pos,to:r.pos,text:"",rules:n,plugin:i})})),!1)},handleKeyDown(e,r){if("Enter"!==r.key)return!1;const{$cursor:o}=e.state.selection;return!!o&&sa({editor:t,from:o.pos,to:o.pos,text:"\n",rules:n,plugin:i})}},isInputRules:!0});return i}class la{constructor(e){this.find=e.find,this.handler=e.handler}}function ca(e){const{editor:t,state:n,from:i,to:r,rule:o}=e,{commands:s,chain:a,can:l}=new qs({editor:t,state:n}),c=[];n.doc.nodesBetween(i,r,((e,t)=>{if(!e.isTextblock||e.type.spec.code)return;const u=Math.max(i,t),p=Math.min(r,t+e.content.size),d=((e,t)=>{if(ra(t))return[...e.matchAll(t)];const n=t(e);return n?n.map((t=>{const n=[];return n.push(t.text),n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n})):[]})(e.textBetween(u-t,p-t,void 0,""),o.find);d.forEach((e=>{if(void 0===e.index)return;const t=u+e.index+1,i=t+e[0].length,r={from:n.tr.mapping.map(t),to:n.tr.mapping.map(i)},p=o.handler({state:n,range:r,match:e,commands:s,chain:a,can:l});c.push(p)}))}));return c.every((e=>null!==e))}function ua(e){const{editor:t,rules:n}=e;let i=null,r=!1,o=!1;const s=n.map((e=>new oi({view(e){const t=t=>{var n;i=(null===(n=e.dom.parentElement)||void 0===n?void 0:n.contains(t.target))?e.dom.parentElement:null};return window.addEventListener("dragstart",t),{destroy(){window.removeEventListener("dragstart",t)}}},props:{handleDOMEvents:{drop:e=>(o=i===e.dom.parentElement,!1),paste:(e,t)=>{var n;const i=null===(n=t.clipboardData)||void 0===n?void 0:n.getData("text/html");return r=!!(null==i?void 0:i.includes("data-pm-slice")),!1}}},appendTransaction:(n,i,s)=>{const a=n[0],l="paste"===a.getMeta("uiEvent")&&!r,c="drop"===a.getMeta("uiEvent")&&!o;if(!l&&!c)return;const u=i.doc.content.findDiffStart(s.doc.content),p=i.doc.content.findDiffEnd(s.doc.content);if("number"!=typeof u||!p||u===p.b)return;const d=s.tr,h=Ws({state:s,transaction:d});return ca({editor:t,state:h,from:Math.max(u-1,0),to:p.b-1,rule:e})&&d.steps.length?d:void 0}})));return s}class pa{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=pa.resolve(e),this.schema=function(e){var t;const n=Gs(e),{nodeExtensions:i,markExtensions:r}=Ks(e),o=null===(t=i.find((e=>Vs(e,"topNode"))))||void 0===t?void 0:t.name,s=Object.fromEntries(i.map((t=>{const i=n.filter((e=>e.type===t.name)),r={name:t.name,options:t.options,storage:t.storage},o=e.reduce(((e,n)=>{const i=Vs(n,"extendNodeSchema",r);return{...e,...i?i(t):{}}}),{}),s=ta({...o,content:Xs(Vs(t,"content",r)),marks:Xs(Vs(t,"marks",r)),group:Xs(Vs(t,"group",r)),inline:Xs(Vs(t,"inline",r)),atom:Xs(Vs(t,"atom",r)),selectable:Xs(Vs(t,"selectable",r)),draggable:Xs(Vs(t,"draggable",r)),code:Xs(Vs(t,"code",r)),defining:Xs(Vs(t,"defining",r)),isolating:Xs(Vs(t,"isolating",r)),attrs:Object.fromEntries(i.map((e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))}),a=Xs(Vs(t,"parseHTML",r));a&&(s.parseDOM=a.map((e=>ea(e,i))));const l=Vs(t,"renderHTML",r);l&&(s.toDOM=e=>l({node:e,HTMLAttributes:Zs(e,i)}));const c=Vs(t,"renderText",r);return c&&(s.toText=c),[t.name,s]}))),a=Object.fromEntries(r.map((t=>{const i=n.filter((e=>e.type===t.name)),r={name:t.name,options:t.options,storage:t.storage},o=e.reduce(((e,n)=>{const i=Vs(n,"extendMarkSchema",r);return{...e,...i?i(t):{}}}),{}),s=ta({...o,inclusive:Xs(Vs(t,"inclusive",r)),excludes:Xs(Vs(t,"excludes",r)),group:Xs(Vs(t,"group",r)),spanning:Xs(Vs(t,"spanning",r)),code:Xs(Vs(t,"code",r)),attrs:Object.fromEntries(i.map((e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))}),a=Xs(Vs(t,"parseHTML",r));a&&(s.parseDOM=a.map((e=>ea(e,i))));const l=Vs(t,"renderHTML",r);return l&&(s.toDOM=e=>l({mark:e,HTMLAttributes:Zs(e,i)})),[t.name,s]})));return new Dt({topNode:o,nodes:s,marks:a})}(this.extensions),this.extensions.forEach((e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const n={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:na(e.name,this.schema)};if("mark"===e.type){(null===(t=Xs(Vs(e,"keepOnSplit",n)))||void 0===t||t)&&this.splittableMarks.push(e.name)}const i=Vs(e,"onBeforeCreate",n);i&&this.editor.on("beforeCreate",i);const r=Vs(e,"onCreate",n);r&&this.editor.on("create",r);const o=Vs(e,"onUpdate",n);o&&this.editor.on("update",o);const s=Vs(e,"onSelectionUpdate",n);s&&this.editor.on("selectionUpdate",s);const a=Vs(e,"onTransaction",n);a&&this.editor.on("transaction",a);const l=Vs(e,"onFocus",n);l&&this.editor.on("focus",l);const c=Vs(e,"onBlur",n);c&&this.editor.on("blur",c);const u=Vs(e,"onDestroy",n);u&&this.editor.on("destroy",u)}))}static resolve(e){const t=pa.sort(pa.flatten(e)),n=function(e){const t=e.filter(((t,n)=>e.indexOf(t)!==n));return[...new Set(t)]}(t.map((e=>e.name)));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((e=>`'${e}'`)).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map((e=>{const t=Vs(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...this.flatten(t())]:e})).flat(10)}static sort(e){const t=100;return e.sort(((e,n)=>{const i=Vs(e,"priority")||t,r=Vs(n,"priority")||t;return i>r?-1:i<r?1:0}))}get commands(){return this.extensions.reduce(((e,t)=>{const n=Vs(t,"addCommands",{name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:na(t.name,this.schema)});return n?{...e,...n()}:e}),{})}get plugins(){const{editor:e}=this,t=pa.sort([...this.extensions].reverse()),n=[],i=[],r=t.map((t=>{const r={name:t.name,options:t.options,storage:t.storage,editor:e,type:na(t.name,this.schema)},o=[],s=Vs(t,"addKeyboardShortcuts",r);let a={};if("mark"===t.type&&t.config.exitable&&(a.ArrowRight=()=>ol.handleExit({editor:e,mark:t})),s){const t=Object.fromEntries(Object.entries(s()).map((([t,n])=>[t,()=>n({editor:e})])));a={...a,...t}}const l=new oi({props:{handleKeyDown:As(a)}});o.push(l);const c=Vs(t,"addInputRules",r);ia(t,e.options.enableInputRules)&&c&&n.push(...c());const u=Vs(t,"addPasteRules",r);ia(t,e.options.enablePasteRules)&&u&&i.push(...u());const p=Vs(t,"addProseMirrorPlugins",r);if(p){const e=p();o.push(...e)}return o})).flat();return[aa({editor:e,rules:n}),...ua({editor:e,rules:i}),...r]}get attributes(){return Gs(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Ks(this.extensions);return Object.fromEntries(t.filter((e=>!!Vs(e,"addNodeView"))).map((t=>{const n=this.attributes.filter((e=>e.type===t.name)),i={name:t.name,options:t.options,storage:t.storage,editor:e,type:Ys(t.name,this.schema)},r=Vs(t,"addNodeView",i);if(!r)return[];return[t.name,(i,o,s,a)=>{const l=Zs(i,n);return r()({editor:e,node:i,getPos:s,decorations:a,HTMLAttributes:l,extension:t})}]})))}}function da(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function ha(e,t){const n={...e};return da(e)&&da(t)&&Object.keys(t).forEach((i=>{da(t[i])?i in e?n[i]=ha(e[i],t[i]):Object.assign(n,{[i]:t[i]}):Object.assign(n,{[i]:t[i]})})),n}class fa{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Xs(Vs(this,"addOptions",{name:this.name}))),this.storage=Xs(Vs(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new fa(e)}configure(e={}){const t=this.extend();return t.options=ha(this.options,e),t.storage=Xs(Vs(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new fa(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Xs(Vs(t,"addOptions",{name:t.name})),t.storage=Xs(Vs(t,"addStorage",{name:t.name,options:t.options})),t}}function ma(e,t,n){const{from:i,to:r}=t,{blockSeparator:o="\n\n",textSerializers:s={}}=n||{};let a="",l=!0;return e.nodesBetween(i,r,((e,n,c,u)=>{var p;const d=null==s?void 0:s[e.type.name];d?(e.isBlock&&!l&&(a+=o,l=!0),c&&(a+=d({node:e,pos:n,parent:c,index:u,range:t}))):e.isText?(a+=null===(p=null==e?void 0:e.text)||void 0===p?void 0:p.slice(Math.max(i,n)-n,r-n),l=!1):e.isBlock&&!l&&(a+=o,l=!0)})),a}function ga(e){return Object.fromEntries(Object.entries(e.nodes).filter((([,e])=>e.spec.toText)).map((([e,t])=>[e,t.spec.toText])))}const ba=fa.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new oi({key:new li("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:i,selection:r}=t,{ranges:o}=r,s=Math.min(...o.map((e=>e.$from.pos))),a=Math.max(...o.map((e=>e.$to.pos)));return ma(i,{from:s,to:a},{textSerializers:ga(n)})}}})]}});function va(e,t,n={strict:!0}){const i=Object.keys(t);return!i.length||i.every((i=>n.strict?t[i]===e[i]:ra(t[i])?t[i].test(e[i]):t[i]===e[i]))}function ya(e,t,n={}){return e.find((e=>e.type===t&&va(e.attrs,n)))}function xa(e,t,n={}){return!!ya(e,t,n)}function wa(e,t,n={}){if(!e||!t)return;let i=e.parent.childAfter(e.parentOffset);if(e.parentOffset===i.offset&&0!==i.offset&&(i=e.parent.childBefore(e.parentOffset)),!i.node)return;const r=ya([...i.node.marks],t,n);if(!r)return;let o=i.index,s=e.start()+i.offset,a=o+1,l=s+i.node.nodeSize;for(ya([...i.node.marks],t,n);o>0&&r.isInSet(e.parent.child(o-1).marks);)o-=1,s-=e.parent.child(o).nodeSize;for(;a<e.parent.childCount&&xa([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:s,to:l}}function _a(e,t){if("string"==typeof e){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}function ka(e){return e instanceof Un}function Ea(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function Ca(e,t=null){if(!t)return null;const n=Rn.atStart(e),i=Rn.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return i;const r=n.from,o=i.to;return"all"===t?Un.create(e,Ea(0,r,o),Ea(e.content.size,r,o)):Un.create(e,Ea(t,r,o),Ea(t,r,o))}function Ma(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Oa(e){const t=`<body>${e}</body>`;return(new window.DOMParser).parseFromString(t,"text/html").body}function Da(e,t,n){if(n={slice:!0,parseOptions:{},...n},"object"==typeof e&&null!==e)try{return Array.isArray(e)?Pe.fromArray(e.map((e=>t.nodeFromJSON(e)))):t.nodeFromJSON(e)}catch(i){return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",i),Da("",t,n)}if("string"==typeof e){const i=St.fromSchema(t);return n.slice?i.parseSlice(Oa(e),n.parseOptions).content:i.parse(Oa(e),n.parseOptions)}return Da("",t,n)}function Ta(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}function Sa(e,t,n={}){const{from:i,to:r,empty:o}=e.selection,s=t?Ys(t,e.schema):null,a=[];e.doc.nodesBetween(i,r,((e,t)=>{if(e.isText)return;const n=Math.max(i,t),o=Math.min(r,t+e.nodeSize);a.push({node:e,from:n,to:o})}));const l=r-i,c=a.filter((e=>!s||s.name===e.node.type.name)).filter((e=>va(e.node.attrs,n,{strict:!1})));if(o)return!!c.length;return c.reduce(((e,t)=>e+t.to-t.from),0)>=l}function Na(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Aa(e,t){const n="string"==typeof t?[t]:t;return Object.keys(e).reduce(((t,i)=>(n.includes(i)||(t[i]=e[i]),t)),{})}function ja(e,t,n={}){return Da(e,t,{slice:!1,parseOptions:n})}function La(e,t){const n=[];return e.descendants(((e,i)=>{t(e)&&n.push({node:e,pos:i})})),n}function za(e){return t=>function(e,t){for(let n=e.depth;n>0;n-=1){const i=e.node(n);if(t(i))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:i}}}(t.$from,e)}function Ia(e,t){const n=_a(t,e.schema),{from:i,to:r,empty:o}=e.selection,s=[];o?(e.storedMarks&&s.push(...e.storedMarks),s.push(...e.selection.$head.marks())):e.doc.nodesBetween(i,r,(e=>{s.push(...e.marks)}));const a=s.find((e=>e.type.name===n.name));return a?{...a.attrs}:{}}function Ra(e,t){const n=Na("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){const n=Ys(t,e.schema),{from:i,to:r}=e.selection,o=[];e.doc.nodesBetween(i,r,(e=>{o.push(e)}));const s=o.reverse().find((e=>e.type.name===n.name));return s?{...s.attrs}:{}}(e,t):"mark"===n?Ia(e,t):{}}function Fa(e){const t=function(e,t=JSON.stringify){const n={};return e.filter((e=>{const i=t(e);return!Object.prototype.hasOwnProperty.call(n,i)&&(n[i]=!0)}))}(e);return 1===t.length?t:t.filter(((e,n)=>{const i=t.filter(((e,t)=>t!==n));return!i.some((t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}))}function Ba(e,t,n){const i=[];return e===t?n.resolve(e).marks().forEach((t=>{const r=wa(n.resolve(e-1),t.type);r&&i.push({mark:t,...r})})):n.nodesBetween(e,t,((e,t)=>{i.push(...e.marks.map((n=>({from:t,to:t+e.nodeSize,mark:n}))))})),i}function Pa(e,t,n={}){const{empty:i,ranges:r}=e.selection,o=t?_a(t,e.schema):null;if(i)return!!(e.storedMarks||e.selection.$from.marks()).filter((e=>!o||o.name===e.type.name)).find((e=>va(e.attrs,n,{strict:!1})));let s=0;const a=[];if(r.forEach((({$from:t,$to:n})=>{const i=t.pos,r=n.pos;e.doc.nodesBetween(i,r,((e,t)=>{if(!e.isText&&!e.marks.length)return;const n=Math.max(i,t),o=Math.min(r,t+e.nodeSize);s+=o-n,a.push(...e.marks.map((e=>({mark:e,from:n,to:o}))))}))})),0===s)return!1;const l=a.filter((e=>!o||o.name===e.mark.type.name)).filter((e=>va(e.mark.attrs,n,{strict:!1}))).reduce(((e,t)=>e+t.to-t.from),0),c=a.filter((e=>!o||e.mark.type!==o&&e.mark.type.excludes(o))).reduce(((e,t)=>e+t.to-t.from),0);return(l>0?l+c:l)>=s}function Ua(e,t){const{nodeExtensions:n}=Ks(t),i=n.find((t=>t.name===e));if(!i)return!1;const r=Xs(Vs(i,"group",{name:i.name,options:i.options,storage:i.storage}));return"string"==typeof r&&r.split(" ").includes("list")}function Ha(e,t,n){const i=0,r=e.state.doc.content.size,o=Ea(t,i,r),s=Ea(n,i,r),a=e.coordsAtPos(o),l=e.coordsAtPos(s,-1),c=Math.min(a.top,l.top),u=Math.max(a.bottom,l.bottom),p=Math.min(a.left,l.left),d=Math.max(a.right,l.right),h={top:c,bottom:u,left:p,right:d,width:d-p,height:u-c,x:p,y:c};return{...h,toJSON:()=>h}}function $a(e,t,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const i=e.find((e=>e.type===t&&e.name===n));return!!i&&i.attribute.keepOnSplit})))}function Wa(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const i=n.filter((e=>null==t?void 0:t.includes(e.type.name)));e.tr.ensureMarks(i)}}const qa=(e,t)=>{const n=za((e=>e.type===t))(e.selection);if(!n)return!0;const i=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===i)return!0;const r=e.doc.nodeAt(i);return n.node.type!==(null==r?void 0:r.type)||!xn(e.doc,n.pos)||(e.join(n.pos),!0)},Va=(e,t)=>{const n=za((e=>e.type===t))(e.selection);if(!n)return!0;const i=e.doc.resolve(n.start).after(n.depth);if(void 0===i)return!0;const r=e.doc.nodeAt(i);return n.node.type!==(null==r?void 0:r.type)||!xn(e.doc,i)||(e.join(i),!0)};var Ka=Object.freeze({__proto__:null,blur:()=>({editor:e,view:t})=>(requestAnimationFrame((()=>{var n;e.isDestroyed||(t.dom.blur(),null===(n=null===window||void 0===window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())})),!0),clearContent:(e=!1)=>({commands:t})=>t.setContent("",e),clearNodes:()=>({state:e,tr:t,dispatch:n})=>{const{selection:i}=t,{ranges:r}=i;return!n||(r.forEach((({$from:n,$to:i})=>{e.doc.nodesBetween(n.pos,i.pos,((e,n)=>{if(e.type.isText)return;const{doc:i,mapping:r}=t,o=i.resolve(r.map(n)),s=i.resolve(r.map(n+e.nodeSize)),a=o.blockRange(s);if(!a)return;const l=gn(a);if(e.type.isTextblock){const{defaultType:e}=o.parent.contentMatchAt(o.index());t.setNodeMarkup(a.start,e)}(l||0===l)&&t.lift(a,l)}))})),!0)},command:e=>t=>e(t),createParagraphNear:()=>({state:e,dispatch:t})=>((e,t)=>{let n=e.selection,{$from:i,$to:r}=n;if(n instanceof qn||i.parent.inlineContent||r.parent.inlineContent)return!1;let o=Is(r.parent.contentMatchAt(r.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){let n=(!i.parentOffset&&r.index()<r.parent.childCount?i:r).pos,s=e.tr.insert(n,o.createAndFill());s.setSelection(Un.create(s.doc,n+1)),t(s.scrollIntoView())}return!0})(e,t),deleteNode:e=>({tr:t,state:n,dispatch:i})=>{const r=Ys(e,n.schema),o=t.selection.$anchor;for(let e=o.depth;e>0;e-=1){if(o.node(e).type===r){if(i){const n=o.before(e),i=o.after(e);t.delete(n,i).scrollIntoView()}return!0}}return!1},deleteRange:e=>({tr:t,dispatch:n})=>{const{from:i,to:r}=e;return n&&t.delete(i,r),!0},deleteSelection:()=>({state:e,dispatch:t})=>((e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0))(e,t),enter:()=>({commands:e})=>e.keyboardShortcut("Enter"),exitCode:()=>({state:e,dispatch:t})=>((e,t)=>{let{$head:n,$anchor:i}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(i))return!1;let r=n.node(-1),o=n.indexAfter(-1),s=Is(r.contentMatchAt(o));if(!s||!r.canReplaceWith(o,o,s))return!1;if(t){let i=n.after(),r=e.tr.replaceWith(i,i,s.createAndFill());r.setSelection(Rn.near(r.doc.resolve(i),1)),t(r.scrollIntoView())}return!0})(e,t),extendMarkRange:(e,t={})=>({tr:n,state:i,dispatch:r})=>{const o=_a(e,i.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:u}=a;if(r){const e=wa(l,o,t);if(e&&e.from<=c&&e.to>=u){const t=Un.create(s,e.from,e.to);n.setSelection(t)}}return!0},first:e=>t=>{const n="function"==typeof e?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1},focus:(e=null,t={})=>({editor:n,view:i,tr:r,dispatch:o})=>{t={scrollIntoView:!0,...t};const s=()=>{Ma()&&i.dom.focus(),requestAnimationFrame((()=>{n.isDestroyed||(i.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())}))};if(i.hasFocus()&&null===e||!1===e)return!0;if(o&&null===e&&!ka(n.state.selection))return s(),!0;const a=Ca(r.doc,e)||n.state.selection,l=n.state.selection.eq(a);return o&&(l||r.setSelection(a),l&&r.storedMarks&&r.setStoredMarks(r.storedMarks),s()),!0},forEach:(e,t)=>n=>e.every(((e,i)=>t(e,{...n,index:i}))),insertContent:(e,t)=>({tr:n,commands:i})=>i.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),insertContentAt:(e,t,n)=>({tr:i,dispatch:r,editor:o})=>{if(r){n={parseOptions:{},updateSelection:!0,...n};const r=Da(t,o.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if("<>"===r.toString())return!0;let{from:s,to:a}="number"==typeof e?{from:e,to:e}:e,l=!0,c=!0;if((r.toString().startsWith("<")?r:[r]).forEach((e=>{e.check(),l=!!l&&(e.isText&&0===e.marks.length),c=!!c&&e.isBlock})),s===a&&c){const{parent:e}=i.doc.resolve(s);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(s-=1,a+=1)}l?i.insertText(t,s,a):i.replaceWith(s,a,r),n.updateSelection&&function(e,t,n){const i=e.steps.length-1;if(i<t)return;const r=e.steps[i];if(!(r instanceof dn||r instanceof hn))return;const o=e.mapping.maps[i];let s=0;o.forEach(((e,t,n,i)=>{0===s&&(s=i)})),e.setSelection(Rn.near(e.doc.resolve(s),n))}(i,i.steps.length-1,-1)}return!0},joinBackward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$cursor:i}=e.selection;if(!i||(n?!n.endOfTextblock("backward",e):i.parentOffset>0))return!1;let r=Ls(i);if(!r){let n=i.blockRange(),r=n&&gn(n);return null!=r&&(t&&t(e.tr.lift(n,r).scrollIntoView()),!0)}let o=r.nodeBefore;if(!o.type.spec.isolating&&Rs(e,r,t))return!0;if(0==i.parent.content.size&&(js(o,"end")||$n.isSelectable(o))){let n=_n(e.doc,i.before(),i.after(),Ve.empty);if(n&&n.slice.size<n.to-n.from){if(t){let i=e.tr.step(n);i.setSelection(js(o,"end")?Rn.findFrom(i.doc.resolve(i.mapping.map(r.pos,-1)),-1):$n.create(i.doc,r.pos-o.nodeSize)),t(i.scrollIntoView())}return!0}}return!(!o.isAtom||r.depth!=i.depth-1||(t&&t(e.tr.delete(r.pos-o.nodeSize,r.pos).scrollIntoView()),0))})(e,t),joinForward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$cursor:i}=e.selection;if(!i||(n?!n.endOfTextblock("forward",e):i.parentOffset<i.parent.content.size))return!1;let r=zs(i);if(!r)return!1;let o=r.nodeAfter;if(Rs(e,r,t))return!0;if(0==i.parent.content.size&&(js(o,"start")||$n.isSelectable(o))){let n=_n(e.doc,i.before(),i.after(),Ve.empty);if(n&&n.slice.size<n.to-n.from){if(t){let i=e.tr.step(n);i.setSelection(js(o,"start")?Rn.findFrom(i.doc.resolve(i.mapping.map(r.pos)),1):$n.create(i.doc,i.mapping.map(r.pos))),t(i.scrollIntoView())}return!0}}return!(!o.isAtom||r.depth!=i.depth-1||(t&&t(e.tr.delete(r.pos,r.pos+o.nodeSize).scrollIntoView()),0))})(e,t),keyboardShortcut:e=>({editor:t,view:n,tr:i,dispatch:r})=>{const o=function(e){const t=e.split(/-(?!$)/);let n,i,r,o,s=t[t.length-1];"Space"===s&&(s=" ");for(let e=0;e<t.length-1;e+=1){const s=t[e];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))i=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error(`Unrecognized modifier name: ${s}`);Ma()||Ta()?o=!0:i=!0}}return n&&(s=`Alt-${s}`),i&&(s=`Ctrl-${s}`),o&&(s=`Meta-${s}`),r&&(s=`Shift-${s}`),s}(e).split(/-(?!$)/),s=o.find((e=>!["Alt","Ctrl","Meta","Shift"].includes(e))),a=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction((()=>{n.someProp("handleKeyDown",(e=>e(n,a)))}));return null==l||l.steps.forEach((e=>{const t=e.map(i.mapping);t&&r&&i.maybeStep(t)})),!0},lift:(e,t={})=>({state:n,dispatch:i})=>!!Sa(n,Ys(e,n.schema),t)&&((e,t)=>{let{$from:n,$to:i}=e.selection,r=n.blockRange(i),o=r&&gn(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)})(n,i),liftEmptyBlock:()=>({state:e,dispatch:t})=>((e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(yn(e.doc,i))return t&&t(e.tr.split(i).scrollIntoView()),!0}let i=n.blockRange(),r=i&&gn(i);return null!=r&&(t&&t(e.tr.lift(i,r).scrollIntoView()),!0)})(e,t),liftListItem:e=>({state:t,dispatch:n})=>$s(Ys(e,t.schema))(t,n),newlineInCode:()=>({state:e,dispatch:t})=>((e,t)=>{let{$head:n,$anchor:i}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(i)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))})(e,t),resetAttributes:(e,t)=>({tr:n,state:i,dispatch:r})=>{let o=null,s=null;const a=Na("string"==typeof e?e:e.name,i.schema);return!!a&&("node"===a&&(o=Ys(e,i.schema)),"mark"===a&&(s=_a(e,i.schema)),r&&n.selection.ranges.forEach((e=>{i.doc.nodesBetween(e.$from.pos,e.$to.pos,((e,i)=>{o&&o===e.type&&n.setNodeMarkup(i,void 0,Aa(e.attrs,t)),s&&e.marks.length&&e.marks.forEach((r=>{s===r.type&&n.addMark(i,i+e.nodeSize,s.create(Aa(r.attrs,t)))}))}))})),!0)},scrollIntoView:()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),selectAll:()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),selectNodeBackward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$head:i,empty:r}=e.selection,o=i;if(!r)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):i.parentOffset>0)return!1;o=Ls(i)}let s=o&&o.nodeBefore;return!(!s||!$n.isSelectable(s)||(t&&t(e.tr.setSelection($n.create(e.doc,o.pos-s.nodeSize)).scrollIntoView()),0))})(e,t),selectNodeForward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$head:i,empty:r}=e.selection,o=i;if(!r)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):i.parentOffset<i.parent.content.size)return!1;o=zs(i)}let s=o&&o.nodeAfter;return!(!s||!$n.isSelectable(s)||(t&&t(e.tr.setSelection($n.create(e.doc,o.pos)).scrollIntoView()),0))})(e,t),selectParentNode:()=>({state:e,dispatch:t})=>((e,t)=>{let n,{$from:i,to:r}=e.selection,o=i.sharedDepth(r);return 0!=o&&(n=i.before(o),t&&t(e.tr.setSelection($n.create(e.doc,n))),!0)})(e,t),selectTextblockEnd:()=>({state:e,dispatch:t})=>Ps(e,t),selectTextblockStart:()=>({state:e,dispatch:t})=>Bs(e,t),setContent:(e,t=!1,n={})=>({tr:i,editor:r,dispatch:o})=>{const{doc:s}=i,a=ja(e,r.schema,n);return o&&i.replaceWith(0,s.content.size,a).setMeta("preventUpdate",!t),!0},setMark:(e,t={})=>({tr:n,state:i,dispatch:r})=>{const{selection:o}=n,{empty:s,ranges:a}=o,l=_a(e,i.schema);if(r)if(s){const e=Ia(i,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach((e=>{const r=e.$from.pos,o=e.$to.pos;i.doc.nodesBetween(r,o,((e,i)=>{const s=Math.max(i,r),a=Math.min(i+e.nodeSize,o);e.marks.find((e=>e.type===l))?e.marks.forEach((e=>{l===e.type&&n.addMark(s,a,l.create({...e.attrs,...t}))})):n.addMark(s,a,l.create(t))}))}));return function(e,t,n){var i;const{selection:r}=t;let o=null;if(ka(r)&&(o=r.$cursor),o){const t=null!==(i=e.storedMarks)&&void 0!==i?i:o.marks();return!!n.isInSet(t)||!t.some((e=>e.type.excludes(n)))}const{ranges:s}=r;return s.some((({$from:t,$to:i})=>{let r=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,i.pos,((e,t,i)=>{if(r)return!1;if(e.isInline){const t=!i||i.type.allowsMarkType(n),o=!!n.isInSet(e.marks)||!e.marks.some((e=>e.type.excludes(n)));r=t&&o}return!r})),r}))}(i,n,l)},setMeta:(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),setNode:(e,t={})=>({state:n,dispatch:i,chain:r})=>{const o=Ys(e,n.schema);return o.isTextblock?r().command((({commands:e})=>!!Us(o,t)(n)||e.clearNodes())).command((({state:e})=>Us(o,t)(e,i))).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection:e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,i=Ea(e,0,n.content.size),r=$n.create(n,i);t.setSelection(r)}return!0},setTextSelection:e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:i,to:r}="number"==typeof e?{from:e,to:e}:e,o=Un.atStart(n).from,s=Un.atEnd(n).to,a=Ea(i,o,s),l=Ea(r,o,s),c=Un.create(n,a,l);t.setSelection(c)}return!0},sinkListItem:e=>({state:t,dispatch:n})=>{const i=Ys(e,t.schema);return(r=i,function(e,t){let{$from:n,$to:i}=e.selection,o=n.blockRange(i,(e=>e.childCount>0&&e.firstChild.type==r));if(!o)return!1;let s=o.startIndex;if(0==s)return!1;let a=o.parent,l=a.child(s-1);if(l.type!=r)return!1;if(t){let n=l.lastChild&&l.lastChild.type==a.type,i=Pe.from(n?r.create():null),s=new Ve(Pe.from(r.create(null,Pe.from(a.type.create(null,i)))),n?3:1,0),c=o.start,u=o.end;t(e.tr.step(new hn(c-(n?3:1),u,c,u,s,1,!0)).scrollIntoView())}return!0})(t,n);var r},splitBlock:({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:i,editor:r})=>{const{selection:o,doc:s}=t,{$from:a,$to:l}=o,c=$a(r.extensionManager.attributes,a.node().type.name,a.node().attrs);if(o instanceof $n&&o.node.isBlock)return!(!a.parentOffset||!yn(s,a.pos))&&(i&&(e&&Wa(n,r.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;if(i){const i=l.parentOffset===l.parent.content.size;o instanceof Un&&t.deleteSelection();const s=0===a.depth?void 0:function(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let u=i&&s?[{type:s,attrs:c}]:void 0,p=yn(t.doc,t.mapping.map(a.pos),1,u);if(u||p||!yn(t.doc,t.mapping.map(a.pos),1,s?[{type:s}]:void 0)||(p=!0,u=s?[{type:s,attrs:c}]:void 0),p&&(t.split(t.mapping.map(a.pos),1,u),s&&!i&&!a.parentOffset&&a.parent.type!==s)){const e=t.mapping.map(a.before()),n=t.doc.resolve(e);a.node(-1).canReplaceWith(n.index(),n.index()+1,s)&&t.setNodeMarkup(t.mapping.map(a.before()),s)}e&&Wa(n,r.extensionManager.splittableMarks),t.scrollIntoView()}return!0},splitListItem:e=>({tr:t,state:n,dispatch:i,editor:r})=>{var o;const s=Ys(e,n.schema),{$from:a,$to:l}=n.selection,c=n.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(l))return!1;const u=a.node(-1);if(u.type!==s)return!1;const p=r.extensionManager.attributes;if(0===a.parent.content.size&&a.node(-1).childCount===a.indexAfter(-1)){if(2===a.depth||a.node(-3).type!==s||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let e=Pe.empty;const n=a.index(-1)?1:a.index(-2)?2:3;for(let t=a.depth-n;t>=a.depth-3;t-=1)e=Pe.from(a.node(t).copy(e));const i=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,r=$a(p,a.node().type.name,a.node().attrs),l=(null===(o=s.contentMatch.defaultType)||void 0===o?void 0:o.createAndFill(r))||void 0;e=e.append(Pe.from(s.createAndFill(null,l)||void 0));const c=a.before(a.depth-(n-1));t.replace(c,a.after(-i),new Ve(e,4-n,0));let u=-1;t.doc.nodesBetween(c,t.doc.content.size,((e,t)=>{if(u>-1)return!1;e.isTextblock&&0===e.content.size&&(u=t+1)})),u>-1&&t.setSelection(Un.near(t.doc.resolve(u))),t.scrollIntoView()}return!0}const d=l.pos===a.end()?u.contentMatchAt(0).defaultType:null,h=$a(p,u.type.name,u.attrs),f=$a(p,a.node().type.name,a.node().attrs);t.delete(a.pos,l.pos);const m=d?[{type:s,attrs:h},{type:d,attrs:f}]:[{type:s,attrs:h}];return!!yn(t.doc,a.pos,2)&&(i&&t.split(a.pos,2,m).scrollIntoView(),!0)},toggleList:(e,t)=>({editor:n,tr:i,state:r,dispatch:o,chain:s,commands:a,can:l})=>{const{extensions:c}=n.extensionManager,u=Ys(e,r.schema),p=Ys(t,r.schema),{selection:d}=r,{$from:h,$to:f}=d,m=h.blockRange(f);if(!m)return!1;const g=za((e=>Ua(e.type.name,c)))(d);if(m.depth>=1&&g&&m.depth-g.depth<=1){if(g.node.type===u)return a.liftListItem(p);if(Ua(g.node.type.name,c)&&u.validContent(g.node.content)&&o)return s().command((()=>(i.setNodeMarkup(g.pos,u),!0))).command((()=>qa(i,u))).command((()=>Va(i,u))).run()}return s().command((()=>!!l().wrapInList(u)||a.clearNodes())).wrapInList(u).command((()=>qa(i,u))).command((()=>Va(i,u))).run()},toggleMark:(e,t={},n={})=>({state:i,commands:r})=>{const{extendEmptyMarkRange:o=!1}=n,s=_a(e,i.schema);return Pa(i,s,t)?r.unsetMark(s,{extendEmptyMarkRange:o}):r.setMark(s,t)},toggleNode:(e,t,n={})=>({state:i,commands:r})=>{const o=Ys(e,i.schema),s=Ys(t,i.schema);return Sa(i,o,n)?r.setNode(s):r.setNode(o,n)},toggleWrap:(e,t={})=>({state:n,commands:i})=>{const r=Ys(e,n.schema);return Sa(n,r,t)?i.lift(r):i.wrapIn(r,t)},undoInputRule:()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let i=0;i<n.length;i+=1){const r=n[i];let o;if(r.spec.isInputRules&&(o=r.getState(e))){if(t){const t=e.tr,n=o.transform;for(let e=n.steps.length-1;e>=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(o.text){const n=t.doc.resolve(o.from).marks();t.replaceWith(o.from,o.to,e.schema.text(o.text,n))}else t.delete(o.from,o.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:i,ranges:r}=n;return i||t&&r.forEach((t=>{e.removeMark(t.$from.pos,t.$to.pos)})),!0},unsetMark:(e,t={})=>({tr:n,state:i,dispatch:r})=>{var o;const{extendEmptyMarkRange:s=!1}=t,{selection:a}=n,l=_a(e,i.schema),{$from:c,empty:u,ranges:p}=a;if(!r)return!0;if(u&&s){let{from:e,to:t}=a;const i=null===(o=c.marks().find((e=>e.type===l)))||void 0===o?void 0:o.attrs,r=wa(c,l,i);r&&(e=r.from,t=r.to),n.removeMark(e,t,l)}else p.forEach((e=>{n.removeMark(e.$from.pos,e.$to.pos,l)}));return n.removeStoredMark(l),!0},updateAttributes:(e,t={})=>({tr:n,state:i,dispatch:r})=>{let o=null,s=null;const a=Na("string"==typeof e?e:e.name,i.schema);return!!a&&("node"===a&&(o=Ys(e,i.schema)),"mark"===a&&(s=_a(e,i.schema)),r&&n.selection.ranges.forEach((e=>{const r=e.$from.pos,a=e.$to.pos;i.doc.nodesBetween(r,a,((e,i)=>{o&&o===e.type&&n.setNodeMarkup(i,void 0,{...e.attrs,...t}),s&&e.marks.length&&e.marks.forEach((o=>{if(s===o.type){const l=Math.max(i,r),c=Math.min(i+e.nodeSize,a);n.addMark(l,c,s.create({...o.attrs,...t}))}}))}))})),!0)},wrapIn:(e,t={})=>({state:n,dispatch:i})=>function(e,t=null){return function(n,i){let{$from:r,$to:o}=n.selection,s=r.blockRange(o),a=s&&bn(s,e,t);return!!a&&(i&&i(n.tr.wrap(s,a).scrollIntoView()),!0)}}(Ys(e,n.schema),t)(n,i),wrapInList:(e,t={})=>({state:n,dispatch:i})=>Hs(Ys(e,n.schema),t)(n,i)});const Ga=fa.create({name:"commands",addCommands:()=>({...Ka})}),Ya=fa.create({name:"editable",addProseMirrorPlugins(){return[new oi({key:new li("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Qa=fa.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new oi({key:new li("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const i=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(i),!1},blur:(t,n)=>{e.isFocused=!1;const i=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(i),!1}}}})]}}),Za=fa.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first((({commands:e})=>[()=>e.undoInputRule(),()=>e.command((({tr:t})=>{const{selection:n,doc:i}=t,{empty:r,$anchor:o}=n,{pos:s,parent:a}=o,l=Rn.atStart(i).from===s;return!(!(r&&l&&a.type.isTextblock)||a.textContent.length)&&e.clearNodes()})),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()])),t=()=>this.editor.commands.first((({commands:e})=>[()=>e.deleteSelection(),()=>e.joinForward(),()=>e.selectNodeForward()])),n={Enter:()=>this.editor.commands.first((({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},i={...n},r={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ma()||Ta()?r:i},addProseMirrorPlugins(){return[new oi({key:new li("clearDocument"),appendTransaction:(e,t,n)=>{if(!(e.some((e=>e.docChanged))&&!t.doc.eq(n.doc)))return;const{empty:i,from:r,to:o}=t.selection,s=Rn.atStart(t.doc).from,a=Rn.atEnd(t.doc).to,l=r===s&&o===a,c=0===n.doc.textBetween(0,n.doc.content.size," "," ").length;if(i||!l||!c)return;const u=n.tr,p=Ws({state:n,transaction:u}),{commands:d}=new qs({editor:this.editor,state:p});return d.clearNodes(),u.steps.length?u:void 0}})]}}),Ja=fa.create({name:"tabindex",addProseMirrorPlugins(){return[new oi({key:new li("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});var Xa=Object.freeze({__proto__:null,ClipboardTextSerializer:ba,Commands:Ga,Editable:Ya,FocusEvents:Qa,Keymap:Za,Tabindex:Ja});const el=`.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}`;function tl(e){return new oa({find:e.find,handler:({state:t,range:n,match:i})=>{const r=Xs(e.getAttributes,void 0,i);if(!1===r||null===r)return null;const{tr:o}=t,s=i[i.length-1],a=i[0];let l=n.to;if(s){const i=a.search(/\S/),c=n.from+a.indexOf(s),u=c+s.length,p=Ba(n.from,n.to,t.doc).filter((t=>t.mark.type.excluded.find((n=>n===e.type&&n!==t.mark.type)))).filter((e=>e.to>c));if(p.length)return null;u<n.to&&o.delete(u,n.to),c>n.from&&o.delete(n.from+i,c),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(r||{})),o.removeStoredMark(e.type)}}})}function nl(e){return new oa({find:e.find,handler:({state:t,range:n,match:i})=>{const r=Xs(e.getAttributes,void 0,i)||{},{tr:o}=t,s=n.from;let a=n.to;if(i[1]){let t=s+i[0].lastIndexOf(i[1]);t>a?t=a:a=t+i[1].length;const n=i[0][i[0].length-1];o.insertText(n,s+i[0].length-1),o.replaceWith(t,a,e.type.create(r))}else i[0]&&o.replaceWith(s,a,e.type.create(r))}})}function il(e){return new oa({find:e.find,handler:({state:t,range:n,match:i})=>{const r=t.doc.resolve(n.from),o=Xs(e.getAttributes,void 0,i)||{};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,o)}})}function rl(e){return new oa({find:e.find,handler:({state:t,range:n,match:i})=>{const r=Xs(e.getAttributes,void 0,i)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),a=s&&bn(s,e.type,r);if(!a)return null;o.wrap(s,a);const l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&xn(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(i,l))&&o.join(n.from-1)}})}class ol{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Xs(Vs(this,"addOptions",{name:this.name}))),this.storage=Xs(Vs(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new ol(e)}configure(e={}){const t=this.extend();return t.options=ha(this.options,e),t.storage=Xs(Vs(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new ol(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Xs(Vs(t,"addOptions",{name:t.name})),t.storage=Xs(Vs(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const r=i.marks(),o=!!r.find((e=>(null==e?void 0:e.type.name)===t.name));if(!o)return!1;const s=r.find((e=>(null==e?void 0:e.type.name)===t.name));return s&&n.removeStoredMark(s),n.insertText(" ",i.pos),e.view.dispatch(n),!0}return!1}}class sl{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Xs(Vs(this,"addOptions",{name:this.name}))),this.storage=Xs(Vs(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new sl(e)}configure(e={}){const t=this.extend();return t.options=ha(this.options,e),t.storage=Xs(Vs(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new sl(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Xs(Vs(t,"addOptions",{name:t.name})),t.storage=Xs(Vs(t,"addStorage",{name:t.name,options:t.options})),t}}function al(e){return new la({find:e.find,handler:({state:t,range:n,match:i})=>{const r=Xs(e.getAttributes,void 0,i);if(!1===r||null===r)return null;const{tr:o}=t,s=i[i.length-1],a=i[0];let l=n.to;if(s){const i=a.search(/\S/),c=n.from+a.indexOf(s),u=c+s.length,p=Ba(n.from,n.to,t.doc).filter((t=>t.mark.type.excluded.find((n=>n===e.type&&n!==t.mark.type)))).filter((e=>e.to>c));if(p.length)return null;u<n.to&&o.delete(u,n.to),c>n.from&&o.delete(n.from+i,c),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(r||{})),o.removeStoredMark(e.type)}}})}var ll="top",cl="bottom",ul="right",pl="left",dl="auto",hl=[ll,cl,ul,pl],fl="start",ml="end",gl="clippingParents",bl="viewport",vl="popper",yl="reference",xl=hl.reduce((function(e,t){return e.concat([t+"-"+fl,t+"-"+ml])}),[]),wl=[].concat(hl,[dl]).reduce((function(e,t){return e.concat([t,t+"-"+fl,t+"-"+ml])}),[]),_l=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function kl(e){return e?(e.nodeName||"").toLowerCase():null}function El(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Cl(e){return e instanceof El(e).Element||e instanceof Element}function Ml(e){return e instanceof El(e).HTMLElement||e instanceof HTMLElement}function Ol(e){return"undefined"!=typeof ShadowRoot&&(e instanceof El(e).ShadowRoot||e instanceof ShadowRoot)}var Dl={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var n=t.styles[e]||{},i=t.attributes[e]||{},r=t.elements[e];Ml(r)&&kl(r)&&(Object.assign(r.style,n),Object.keys(i).forEach((function(e){var t=i[e];!1===t?r.removeAttribute(e):r.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach((function(e){var i=t.elements[e],r=t.attributes[e]||{},o=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce((function(e,t){return e[t]="",e}),{});Ml(i)&&kl(i)&&(Object.assign(i.style,o),Object.keys(r).forEach((function(e){i.removeAttribute(e)})))}))}},requires:["computeStyles"]};function Tl(e){return e.split("-")[0]}var Sl=Math.max,Nl=Math.min,Al=Math.round;function jl(){var e=navigator.userAgentData;return null!=e&&e.brands?e.brands.map((function(e){return e.brand+"/"+e.version})).join(" "):navigator.userAgent}function Ll(){return!/^((?!chrome|android).)*safari/i.test(jl())}function zl(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1);var i=e.getBoundingClientRect(),r=1,o=1;t&&Ml(e)&&(r=e.offsetWidth>0&&Al(i.width)/e.offsetWidth||1,o=e.offsetHeight>0&&Al(i.height)/e.offsetHeight||1);var s=(Cl(e)?El(e):window).visualViewport,a=!Ll()&&n,l=(i.left+(a&&s?s.offsetLeft:0))/r,c=(i.top+(a&&s?s.offsetTop:0))/o,u=i.width/r,p=i.height/o;return{width:u,height:p,top:c,right:l+u,bottom:c+p,left:l,x:l,y:c}}function Il(e){var t=zl(e),n=e.offsetWidth,i=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:i}}function Rl(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Ol(n)){var i=t;do{if(i&&e.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function Fl(e){return El(e).getComputedStyle(e)}function Bl(e){return["table","td","th"].indexOf(kl(e))>=0}function Pl(e){return((Cl(e)?e.ownerDocument:e.document)||window.document).documentElement}function Ul(e){return"html"===kl(e)?e:e.assignedSlot||e.parentNode||(Ol(e)?e.host:null)||Pl(e)}function Hl(e){return Ml(e)&&"fixed"!==Fl(e).position?e.offsetParent:null}function $l(e){for(var t=El(e),n=Hl(e);n&&Bl(n)&&"static"===Fl(n).position;)n=Hl(n);return n&&("html"===kl(n)||"body"===kl(n)&&"static"===Fl(n).position)?t:n||function(e){var t=/firefox/i.test(jl());if(/Trident/i.test(jl())&&Ml(e)&&"fixed"===Fl(e).position)return null;var n=Ul(e);for(Ol(n)&&(n=n.host);Ml(n)&&["html","body"].indexOf(kl(n))<0;){var i=Fl(n);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return n;n=n.parentNode}return null}(e)||t}function Wl(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function ql(e,t,n){return Sl(e,Nl(t,n))}function Vl(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function Kl(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}var Gl={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,i=e.name,r=e.options,o=n.elements.arrow,s=n.modifiersData.popperOffsets,a=Tl(n.placement),l=Wl(a),c=[pl,ul].indexOf(a)>=0?"height":"width";if(o&&s){var u=function(e,t){return Vl("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:Kl(e,hl))}(r.padding,n),p=Il(o),d="y"===l?ll:pl,h="y"===l?cl:ul,f=n.rects.reference[c]+n.rects.reference[l]-s[l]-n.rects.popper[c],m=s[l]-n.rects.reference[l],g=$l(o),b=g?"y"===l?g.clientHeight||0:g.clientWidth||0:0,v=f/2-m/2,y=u[d],x=b-p[c]-u[h],w=b/2-p[c]/2+v,_=ql(y,w,x),k=l;n.modifiersData[i]=((t={})[k]=_,t.centerOffset=_-w,t)}},effect:function(e){var t=e.state,n=e.options.element,i=void 0===n?"[data-popper-arrow]":n;null!=i&&("string"!=typeof i||(i=t.elements.popper.querySelector(i)))&&Rl(t.elements.popper,i)&&(t.elements.arrow=i)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Yl(e){return e.split("-")[1]}var Ql={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Zl(e){var t,n=e.popper,i=e.popperRect,r=e.placement,o=e.variation,s=e.offsets,a=e.position,l=e.gpuAcceleration,c=e.adaptive,u=e.roundOffsets,p=e.isFixed,d=s.x,h=void 0===d?0:d,f=s.y,m=void 0===f?0:f,g="function"==typeof u?u({x:h,y:m}):{x:h,y:m};h=g.x,m=g.y;var b=s.hasOwnProperty("x"),v=s.hasOwnProperty("y"),y=pl,x=ll,w=window;if(c){var _=$l(n),k="clientHeight",E="clientWidth";if(_===El(n)&&"static"!==Fl(_=Pl(n)).position&&"absolute"===a&&(k="scrollHeight",E="scrollWidth"),r===ll||(r===pl||r===ul)&&o===ml)x=cl,m-=(p&&_===w&&w.visualViewport?w.visualViewport.height:_[k])-i.height,m*=l?1:-1;if(r===pl||(r===ll||r===cl)&&o===ml)y=ul,h-=(p&&_===w&&w.visualViewport?w.visualViewport.width:_[E])-i.width,h*=l?1:-1}var C,M=Object.assign({position:a},c&&Ql),O=!0===u?function(e){var t=e.x,n=e.y,i=window.devicePixelRatio||1;return{x:Al(t*i)/i||0,y:Al(n*i)/i||0}}({x:h,y:m}):{x:h,y:m};return h=O.x,m=O.y,l?Object.assign({},M,((C={})[x]=v?"0":"",C[y]=b?"0":"",C.transform=(w.devicePixelRatio||1)<=1?"translate("+h+"px, "+m+"px)":"translate3d("+h+"px, "+m+"px, 0)",C)):Object.assign({},M,((t={})[x]=v?m+"px":"",t[y]=b?h+"px":"",t.transform="",t))}var Jl={passive:!0};var Xl={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,i=e.options,r=i.scroll,o=void 0===r||r,s=i.resize,a=void 0===s||s,l=El(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&c.forEach((function(e){e.addEventListener("scroll",n.update,Jl)})),a&&l.addEventListener("resize",n.update,Jl),function(){o&&c.forEach((function(e){e.removeEventListener("scroll",n.update,Jl)})),a&&l.removeEventListener("resize",n.update,Jl)}},data:{}},ec={left:"right",right:"left",bottom:"top",top:"bottom"};function tc(e){return e.replace(/left|right|bottom|top/g,(function(e){return ec[e]}))}var nc={start:"end",end:"start"};function ic(e){return e.replace(/start|end/g,(function(e){return nc[e]}))}function rc(e){var t=El(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function oc(e){return zl(Pl(e)).left+rc(e).scrollLeft}function sc(e){var t=Fl(e),n=t.overflow,i=t.overflowX,r=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+r+i)}function ac(e){return["html","body","#document"].indexOf(kl(e))>=0?e.ownerDocument.body:Ml(e)&&sc(e)?e:ac(Ul(e))}function lc(e,t){var n;void 0===t&&(t=[]);var i=ac(e),r=i===(null==(n=e.ownerDocument)?void 0:n.body),o=El(i),s=r?[o].concat(o.visualViewport||[],sc(i)?i:[]):i,a=t.concat(s);return r?a:a.concat(lc(Ul(s)))}function cc(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function uc(e,t,n){return t===bl?cc(function(e,t){var n=El(e),i=Pl(e),r=n.visualViewport,o=i.clientWidth,s=i.clientHeight,a=0,l=0;if(r){o=r.width,s=r.height;var c=Ll();(c||!c&&"fixed"===t)&&(a=r.offsetLeft,l=r.offsetTop)}return{width:o,height:s,x:a+oc(e),y:l}}(e,n)):Cl(t)?function(e,t){var n=zl(e,!1,"fixed"===t);return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}(t,n):cc(function(e){var t,n=Pl(e),i=rc(e),r=null==(t=e.ownerDocument)?void 0:t.body,o=Sl(n.scrollWidth,n.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),s=Sl(n.scrollHeight,n.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),a=-i.scrollLeft+oc(e),l=-i.scrollTop;return"rtl"===Fl(r||n).direction&&(a+=Sl(n.clientWidth,r?r.clientWidth:0)-o),{width:o,height:s,x:a,y:l}}(Pl(e)))}function pc(e,t,n,i){var r="clippingParents"===t?function(e){var t=lc(Ul(e)),n=["absolute","fixed"].indexOf(Fl(e).position)>=0&&Ml(e)?$l(e):e;return Cl(n)?t.filter((function(e){return Cl(e)&&Rl(e,n)&&"body"!==kl(e)})):[]}(e):[].concat(t),o=[].concat(r,[n]),s=o[0],a=o.reduce((function(t,n){var r=uc(e,n,i);return t.top=Sl(r.top,t.top),t.right=Nl(r.right,t.right),t.bottom=Nl(r.bottom,t.bottom),t.left=Sl(r.left,t.left),t}),uc(e,s,i));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function dc(e){var t,n=e.reference,i=e.element,r=e.placement,o=r?Tl(r):null,s=r?Yl(r):null,a=n.x+n.width/2-i.width/2,l=n.y+n.height/2-i.height/2;switch(o){case ll:t={x:a,y:n.y-i.height};break;case cl:t={x:a,y:n.y+n.height};break;case ul:t={x:n.x+n.width,y:l};break;case pl:t={x:n.x-i.width,y:l};break;default:t={x:n.x,y:n.y}}var c=o?Wl(o):null;if(null!=c){var u="y"===c?"height":"width";switch(s){case fl:t[c]=t[c]-(n[u]/2-i[u]/2);break;case ml:t[c]=t[c]+(n[u]/2-i[u]/2)}}return t}function hc(e,t){void 0===t&&(t={});var n=t,i=n.placement,r=void 0===i?e.placement:i,o=n.strategy,s=void 0===o?e.strategy:o,a=n.boundary,l=void 0===a?gl:a,c=n.rootBoundary,u=void 0===c?bl:c,p=n.elementContext,d=void 0===p?vl:p,h=n.altBoundary,f=void 0!==h&&h,m=n.padding,g=void 0===m?0:m,b=Vl("number"!=typeof g?g:Kl(g,hl)),v=d===vl?yl:vl,y=e.rects.popper,x=e.elements[f?v:d],w=pc(Cl(x)?x:x.contextElement||Pl(e.elements.popper),l,u,s),_=zl(e.elements.reference),k=dc({reference:_,element:y,strategy:"absolute",placement:r}),E=cc(Object.assign({},y,k)),C=d===vl?E:_,M={top:w.top-C.top+b.top,bottom:C.bottom-w.bottom+b.bottom,left:w.left-C.left+b.left,right:C.right-w.right+b.right},O=e.modifiersData.offset;if(d===vl&&O){var D=O[r];Object.keys(M).forEach((function(e){var t=[ul,cl].indexOf(e)>=0?1:-1,n=[ll,cl].indexOf(e)>=0?"y":"x";M[e]+=D[n]*t}))}return M}function fc(e,t){void 0===t&&(t={});var n=t,i=n.placement,r=n.boundary,o=n.rootBoundary,s=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=void 0===l?wl:l,u=Yl(i),p=u?a?xl:xl.filter((function(e){return Yl(e)===u})):hl,d=p.filter((function(e){return c.indexOf(e)>=0}));0===d.length&&(d=p);var h=d.reduce((function(t,n){return t[n]=hc(e,{placement:n,boundary:r,rootBoundary:o,padding:s})[Tl(n)],t}),{});return Object.keys(h).sort((function(e,t){return h[e]-h[t]}))}var mc={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,i=e.name;if(!t.modifiersData[i]._skip){for(var r=n.mainAxis,o=void 0===r||r,s=n.altAxis,a=void 0===s||s,l=n.fallbackPlacements,c=n.padding,u=n.boundary,p=n.rootBoundary,d=n.altBoundary,h=n.flipVariations,f=void 0===h||h,m=n.allowedAutoPlacements,g=t.options.placement,b=Tl(g),v=l||(b===g||!f?[tc(g)]:function(e){if(Tl(e)===dl)return[];var t=tc(e);return[ic(e),t,ic(t)]}(g)),y=[g].concat(v).reduce((function(e,n){return e.concat(Tl(n)===dl?fc(t,{placement:n,boundary:u,rootBoundary:p,padding:c,flipVariations:f,allowedAutoPlacements:m}):n)}),[]),x=t.rects.reference,w=t.rects.popper,_=new Map,k=!0,E=y[0],C=0;C<y.length;C++){var M=y[C],O=Tl(M),D=Yl(M)===fl,T=[ll,cl].indexOf(O)>=0,S=T?"width":"height",N=hc(t,{placement:M,boundary:u,rootBoundary:p,altBoundary:d,padding:c}),A=T?D?ul:pl:D?cl:ll;x[S]>w[S]&&(A=tc(A));var j=tc(A),L=[];if(o&&L.push(N[O]<=0),a&&L.push(N[A]<=0,N[j]<=0),L.every((function(e){return e}))){E=M,k=!1;break}_.set(M,L)}if(k)for(var z=function(e){var t=y.find((function(t){var n=_.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return E=t,"break"},I=f?3:1;I>0;I--){if("break"===z(I))break}t.placement!==E&&(t.modifiersData[i]._skip=!0,t.placement=E,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function gc(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function bc(e){return[ll,ul,cl,pl].some((function(t){return e[t]>=0}))}var vc={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,i=t.rects.reference,r=t.rects.popper,o=t.modifiersData.preventOverflow,s=hc(t,{elementContext:"reference"}),a=hc(t,{altBoundary:!0}),l=gc(s,i),c=gc(a,r,o),u=bc(l),p=bc(c);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:p},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":p})}};var yc={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.options,i=e.name,r=n.offset,o=void 0===r?[0,0]:r,s=wl.reduce((function(e,n){return e[n]=function(e,t,n){var i=Tl(e),r=[pl,ll].indexOf(i)>=0?-1:1,o="function"==typeof n?n(Object.assign({},t,{placement:e})):n,s=o[0],a=o[1];return s=s||0,a=(a||0)*r,[pl,ul].indexOf(i)>=0?{x:a,y:s}:{x:s,y:a}}(n,t.rects,o),e}),{}),a=s[t.placement],l=a.x,c=a.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[i]=s}};var xc={name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=dc({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}};var wc={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,i=e.name,r=n.mainAxis,o=void 0===r||r,s=n.altAxis,a=void 0!==s&&s,l=n.boundary,c=n.rootBoundary,u=n.altBoundary,p=n.padding,d=n.tether,h=void 0===d||d,f=n.tetherOffset,m=void 0===f?0:f,g=hc(t,{boundary:l,rootBoundary:c,padding:p,altBoundary:u}),b=Tl(t.placement),v=Yl(t.placement),y=!v,x=Wl(b),w="x"===x?"y":"x",_=t.modifiersData.popperOffsets,k=t.rects.reference,E=t.rects.popper,C="function"==typeof m?m(Object.assign({},t.rects,{placement:t.placement})):m,M="number"==typeof C?{mainAxis:C,altAxis:C}:Object.assign({mainAxis:0,altAxis:0},C),O=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,D={x:0,y:0};if(_){if(o){var T,S="y"===x?ll:pl,N="y"===x?cl:ul,A="y"===x?"height":"width",j=_[x],L=j+g[S],z=j-g[N],I=h?-E[A]/2:0,R=v===fl?k[A]:E[A],F=v===fl?-E[A]:-k[A],B=t.elements.arrow,P=h&&B?Il(B):{width:0,height:0},U=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},H=U[S],$=U[N],W=ql(0,k[A],P[A]),q=y?k[A]/2-I-W-H-M.mainAxis:R-W-H-M.mainAxis,V=y?-k[A]/2+I+W+$+M.mainAxis:F+W+$+M.mainAxis,K=t.elements.arrow&&$l(t.elements.arrow),G=K?"y"===x?K.clientTop||0:K.clientLeft||0:0,Y=null!=(T=null==O?void 0:O[x])?T:0,Q=j+V-Y,Z=ql(h?Nl(L,j+q-Y-G):L,j,h?Sl(z,Q):z);_[x]=Z,D[x]=Z-j}if(a){var J,X="x"===x?ll:pl,ee="x"===x?cl:ul,te=_[w],ne="y"===w?"height":"width",ie=te+g[X],re=te-g[ee],oe=-1!==[ll,pl].indexOf(b),se=null!=(J=null==O?void 0:O[w])?J:0,ae=oe?ie:te-k[ne]-E[ne]-se+M.altAxis,le=oe?te+k[ne]+E[ne]-se-M.altAxis:re,ce=h&&oe?function(e,t,n){var i=ql(e,t,n);return i>n?n:i}(ae,te,le):ql(h?ae:ie,te,h?le:re);_[w]=ce,D[w]=ce-te}t.modifiersData[i]=D}},requiresIfExists:["offset"]};function _c(e,t,n){void 0===n&&(n=!1);var i=Ml(t),r=Ml(t)&&function(e){var t=e.getBoundingClientRect(),n=Al(t.width)/e.offsetWidth||1,i=Al(t.height)/e.offsetHeight||1;return 1!==n||1!==i}(t),o=Pl(t),s=zl(e,r,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(i||!i&&!n)&&(("body"!==kl(t)||sc(o))&&(a=function(e){return e!==El(e)&&Ml(e)?{scrollLeft:(t=e).scrollLeft,scrollTop:t.scrollTop}:rc(e);var t}(t)),Ml(t)?((l=zl(t,!0)).x+=t.clientLeft,l.y+=t.clientTop):o&&(l.x=oc(o))),{x:s.left+a.scrollLeft-l.x,y:s.top+a.scrollTop-l.y,width:s.width,height:s.height}}function kc(e){var t=new Map,n=new Set,i=[];function r(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var i=t.get(e);i&&r(i)}})),i.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||r(e)})),i}var Ec={placement:"bottom",modifiers:[],strategy:"absolute"};function Cc(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some((function(e){return!(e&&"function"==typeof e.getBoundingClientRect)}))}function Mc(e){void 0===e&&(e={});var t=e,n=t.defaultModifiers,i=void 0===n?[]:n,r=t.defaultOptions,o=void 0===r?Ec:r;return function(e,t,n){void 0===n&&(n=o);var r,s,a={placement:"bottom",orderedModifiers:[],options:Object.assign({},Ec,o),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},l=[],c=!1,u={state:a,setOptions:function(n){var r="function"==typeof n?n(a.options):n;p(),a.options=Object.assign({},o,a.options,r),a.scrollParents={reference:Cl(e)?lc(e):e.contextElement?lc(e.contextElement):[],popper:lc(t)};var s=function(e){var t=kc(e);return _l.reduce((function(e,n){return e.concat(t.filter((function(e){return e.phase===n})))}),[])}(function(e){var t=e.reduce((function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e}),{});return Object.keys(t).map((function(e){return t[e]}))}([].concat(i,a.options.modifiers)));return a.orderedModifiers=s.filter((function(e){return e.enabled})),a.orderedModifiers.forEach((function(e){var t=e.name,n=e.options,i=void 0===n?{}:n,r=e.effect;if("function"==typeof r){var o=r({state:a,name:t,instance:u,options:i}),s=function(){};l.push(o||s)}})),u.update()},forceUpdate:function(){if(!c){var e=a.elements,t=e.reference,n=e.popper;if(Cc(t,n)){a.rects={reference:_c(t,$l(n),"fixed"===a.options.strategy),popper:Il(n)},a.reset=!1,a.placement=a.options.placement,a.orderedModifiers.forEach((function(e){return a.modifiersData[e.name]=Object.assign({},e.data)}));for(var i=0;i<a.orderedModifiers.length;i++)if(!0!==a.reset){var r=a.orderedModifiers[i],o=r.fn,s=r.options,l=void 0===s?{}:s,p=r.name;"function"==typeof o&&(a=o({state:a,options:l,name:p,instance:u})||a)}else a.reset=!1,i=-1}}},update:(r=function(){return new Promise((function(e){u.forceUpdate(),e(a)}))},function(){return s||(s=new Promise((function(e){Promise.resolve().then((function(){s=void 0,e(r())}))}))),s}),destroy:function(){p(),c=!0}};if(!Cc(e,t))return u;function p(){l.forEach((function(e){return e()})),l=[]}return u.setOptions(n).then((function(e){!c&&n.onFirstUpdate&&n.onFirstUpdate(e)})),u}}var Oc=Mc({defaultModifiers:[Xl,xc,{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,n=e.options,i=n.gpuAcceleration,r=void 0===i||i,o=n.adaptive,s=void 0===o||o,a=n.roundOffsets,l=void 0===a||a,c={placement:Tl(t.placement),variation:Yl(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:r,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,Zl(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:s,roundOffsets:l})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,Zl(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},Dl,yc,mc,wc,Gl,vc]}),Dc='<svg width="16" height="6" xmlns="http://www.w3.org/2000/svg"><path d="M0 6s1.796-.013 4.67-3.615C5.851.9 6.93.006 8 0c1.07-.006 2.148.887 3.343 2.385C14.233 6.005 16 6 16 6H0z"></svg>',Tc="tippy-box",Sc="tippy-content",Nc="tippy-backdrop",Ac="tippy-arrow",jc="tippy-svg-arrow",Lc={passive:!0,capture:!0},zc=function(){return document.body};function Ic(e,t,n){if(Array.isArray(e)){var i=e[t];return null==i?Array.isArray(n)?n[t]:n:i}return e}function Rc(e,t){var n={}.toString.call(e);return 0===n.indexOf("[object")&&n.indexOf(t+"]")>-1}function Fc(e,t){return"function"==typeof e?e.apply(void 0,t):e}function Bc(e,t){return 0===t?e:function(i){clearTimeout(n),n=setTimeout((function(){e(i)}),t)};var n}function Pc(e){return[].concat(e)}function Uc(e,t){-1===e.indexOf(t)&&e.push(t)}function Hc(e){return[].slice.call(e)}function $c(e){return Object.keys(e).reduce((function(t,n){return void 0!==e[n]&&(t[n]=e[n]),t}),{})}function Wc(){return document.createElement("div")}function qc(e){return["Element","Fragment"].some((function(t){return Rc(e,t)}))}function Vc(e){return Rc(e,"MouseEvent")}function Kc(e){return qc(e)?[e]:function(e){return Rc(e,"NodeList")}(e)?Hc(e):Array.isArray(e)?e:Hc(document.querySelectorAll(e))}function Gc(e,t){e.forEach((function(e){e&&(e.style.transitionDuration=t+"ms")}))}function Yc(e,t){e.forEach((function(e){e&&e.setAttribute("data-state",t)}))}function Qc(e){var t,n=Pc(e)[0];return null!=n&&null!=(t=n.ownerDocument)&&t.body?n.ownerDocument:document}function Zc(e,t,n){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach((function(t){e[i](t,n)}))}function Jc(e,t){for(var n=t;n;){var i;if(e.contains(n))return!0;n=null==n.getRootNode||null==(i=n.getRootNode())?void 0:i.host}return!1}var Xc={isTouch:!1},eu=0;function tu(){Xc.isTouch||(Xc.isTouch=!0,window.performance&&document.addEventListener("mousemove",nu))}function nu(){var e=performance.now();e-eu<20&&(Xc.isTouch=!1,document.removeEventListener("mousemove",nu)),eu=e}function iu(){var e,t=document.activeElement;if((e=t)&&e._tippy&&e._tippy.reference===e){var n=t._tippy;t.blur&&!n.state.isVisible&&t.blur()}}var ru=!!("undefined"!=typeof window&&"undefined"!=typeof document)&&!!window.msCrypto,ou=Object.assign({appendTo:zc,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},{animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},{allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999}),su=Object.keys(ou);function au(e){var t=(e.plugins||[]).reduce((function(t,n){var i,r=n.name,o=n.defaultValue;r&&(t[r]=void 0!==e[r]?e[r]:null!=(i=ou[r])?i:o);return t}),{});return Object.assign({},e,t)}function lu(e,t){var n=Object.assign({},t,{content:Fc(t.content,[e])},t.ignoreAttributes?{}:function(e,t){return(t?Object.keys(au(Object.assign({},ou,{plugins:t}))):su).reduce((function(t,n){var i=(e.getAttribute("data-tippy-"+n)||"").trim();if(!i)return t;if("content"===n)t[n]=i;else try{t[n]=JSON.parse(i)}catch(e){t[n]=i}return t}),{})}(e,t.plugins));return n.aria=Object.assign({},ou.aria,n.aria),n.aria={expanded:"auto"===n.aria.expanded?t.interactive:n.aria.expanded,content:"auto"===n.aria.content?t.interactive?null:"describedby":n.aria.content},n}function cu(e,t){e["innerHTML"]=t}function uu(e){var t=Wc();return!0===e?t.className=Ac:(t.className=jc,qc(e)?t.appendChild(e):cu(t,e)),t}function pu(e,t){qc(t.content)?(cu(e,""),e.appendChild(t.content)):"function"!=typeof t.content&&(t.allowHTML?cu(e,t.content):e.textContent=t.content)}function du(e){var t=e.firstElementChild,n=Hc(t.children);return{box:t,content:n.find((function(e){return e.classList.contains(Sc)})),arrow:n.find((function(e){return e.classList.contains(Ac)||e.classList.contains(jc)})),backdrop:n.find((function(e){return e.classList.contains(Nc)}))}}function hu(e){var t=Wc(),n=Wc();n.className=Tc,n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var i=Wc();function r(n,i){var r=du(t),o=r.box,s=r.content,a=r.arrow;i.theme?o.setAttribute("data-theme",i.theme):o.removeAttribute("data-theme"),"string"==typeof i.animation?o.setAttribute("data-animation",i.animation):o.removeAttribute("data-animation"),i.inertia?o.setAttribute("data-inertia",""):o.removeAttribute("data-inertia"),o.style.maxWidth="number"==typeof i.maxWidth?i.maxWidth+"px":i.maxWidth,i.role?o.setAttribute("role",i.role):o.removeAttribute("role"),n.content===i.content&&n.allowHTML===i.allowHTML||pu(s,e.props),i.arrow?a?n.arrow!==i.arrow&&(o.removeChild(a),o.appendChild(uu(i.arrow))):o.appendChild(uu(i.arrow)):a&&o.removeChild(a)}return i.className=Sc,i.setAttribute("data-state","hidden"),pu(i,e.props),t.appendChild(n),n.appendChild(i),r(e.props,e.props),{popper:t,onUpdate:r}}hu.$$tippy=!0;var fu=1,mu=[],gu=[];function bu(e,t){var n,i,r,o,s,a,l,c,u=lu(e,Object.assign({},ou,au($c(t)))),p=!1,d=!1,h=!1,f=!1,m=[],g=Bc(K,u.interactiveDebounce),b=fu++,v=(c=u.plugins).filter((function(e,t){return c.indexOf(e)===t})),y={id:b,reference:e,popper:Wc(),popperInstance:null,props:u,state:{isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},plugins:v,clearDelayTimeouts:function(){clearTimeout(n),clearTimeout(i),cancelAnimationFrame(r)},setProps:function(t){if(y.state.isDestroyed)return;j("onBeforeUpdate",[y,t]),q();var n=y.props,i=lu(e,Object.assign({},n,$c(t),{ignoreAttributes:!0}));y.props=i,W(),n.interactiveDebounce!==i.interactiveDebounce&&(I(),g=Bc(K,i.interactiveDebounce));n.triggerTarget&&!i.triggerTarget?Pc(n.triggerTarget).forEach((function(e){e.removeAttribute("aria-expanded")})):i.triggerTarget&&e.removeAttribute("aria-expanded");z(),A(),_&&_(n,i);y.popperInstance&&(Z(),X().forEach((function(e){requestAnimationFrame(e._tippy.popperInstance.forceUpdate)})));j("onAfterUpdate",[y,t])},setContent:function(e){y.setProps({content:e})},show:function(){var e=y.state.isVisible,t=y.state.isDestroyed,n=!y.state.isEnabled,i=Xc.isTouch&&!y.props.touch,r=Ic(y.props.duration,0,ou.duration);if(e||t||n||i)return;if(D().hasAttribute("disabled"))return;if(j("onShow",[y],!1),!1===y.props.onShow(y))return;y.state.isVisible=!0,O()&&(w.style.visibility="visible");A(),P(),y.state.isMounted||(w.style.transition="none");if(O()){var o=S(),s=o.box,l=o.content;Gc([s,l],0)}a=function(){var e;if(y.state.isVisible&&!f){if(f=!0,w.offsetHeight,w.style.transition=y.props.moveTransition,O()&&y.props.animation){var t=S(),n=t.box,i=t.content;Gc([n,i],r),Yc([n,i],"visible")}L(),z(),Uc(gu,y),null==(e=y.popperInstance)||e.forceUpdate(),j("onMount",[y]),y.props.animation&&O()&&function(e,t){H(e,t)}(r,(function(){y.state.isShown=!0,j("onShown",[y])}))}},function(){var e,t=y.props.appendTo,n=D();e=y.props.interactive&&t===zc||"parent"===t?n.parentNode:Fc(t,[n]);e.contains(w)||e.appendChild(w);y.state.isMounted=!0,Z()}()},hide:function(){var e=!y.state.isVisible,t=y.state.isDestroyed,n=!y.state.isEnabled,i=Ic(y.props.duration,1,ou.duration);if(e||t||n)return;if(j("onHide",[y],!1),!1===y.props.onHide(y))return;y.state.isVisible=!1,y.state.isShown=!1,f=!1,p=!1,O()&&(w.style.visibility="hidden");if(I(),U(),A(!0),O()){var r=S(),o=r.box,s=r.content;y.props.animation&&(Gc([o,s],i),Yc([o,s],"hidden"))}L(),z(),y.props.animation?O()&&function(e,t){H(e,(function(){!y.state.isVisible&&w.parentNode&&w.parentNode.contains(w)&&t()}))}(i,y.unmount):y.unmount()},hideWithInteractivity:function(e){T().addEventListener("mousemove",g),Uc(mu,g),g(e)},enable:function(){y.state.isEnabled=!0},disable:function(){y.hide(),y.state.isEnabled=!1},unmount:function(){y.state.isVisible&&y.hide();if(!y.state.isMounted)return;J(),X().forEach((function(e){e._tippy.unmount()})),w.parentNode&&w.parentNode.removeChild(w);gu=gu.filter((function(e){return e!==y})),y.state.isMounted=!1,j("onHidden",[y])},destroy:function(){if(y.state.isDestroyed)return;y.clearDelayTimeouts(),y.unmount(),q(),delete e._tippy,y.state.isDestroyed=!0,j("onDestroy",[y])}};if(!u.render)return y;var x=u.render(y),w=x.popper,_=x.onUpdate;w.setAttribute("data-tippy-root",""),w.id="tippy-"+y.id,y.popper=w,e._tippy=y,w._tippy=y;var k=v.map((function(e){return e.fn(y)})),E=e.hasAttribute("aria-expanded");return W(),z(),A(),j("onCreate",[y]),u.showOnCreate&&ee(),w.addEventListener("mouseenter",(function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()})),w.addEventListener("mouseleave",(function(){y.props.interactive&&y.props.trigger.indexOf("mouseenter")>=0&&T().addEventListener("mousemove",g)})),y;function C(){var e=y.props.touch;return Array.isArray(e)?e:[e,0]}function M(){return"hold"===C()[0]}function O(){var e;return!(null==(e=y.props.render)||!e.$$tippy)}function D(){return l||e}function T(){var e=D().parentNode;return e?Qc(e):document}function S(){return du(w)}function N(e){return y.state.isMounted&&!y.state.isVisible||Xc.isTouch||o&&"focus"===o.type?0:Ic(y.props.delay,e?0:1,ou.delay)}function A(e){void 0===e&&(e=!1),w.style.pointerEvents=y.props.interactive&&!e?"":"none",w.style.zIndex=""+y.props.zIndex}function j(e,t,n){var i;(void 0===n&&(n=!0),k.forEach((function(n){n[e]&&n[e].apply(n,t)})),n)&&(i=y.props)[e].apply(i,t)}function L(){var t=y.props.aria;if(t.content){var n="aria-"+t.content,i=w.id;Pc(y.props.triggerTarget||e).forEach((function(e){var t=e.getAttribute(n);if(y.state.isVisible)e.setAttribute(n,t?t+" "+i:i);else{var r=t&&t.replace(i,"").trim();r?e.setAttribute(n,r):e.removeAttribute(n)}}))}}function z(){!E&&y.props.aria.expanded&&Pc(y.props.triggerTarget||e).forEach((function(e){y.props.interactive?e.setAttribute("aria-expanded",y.state.isVisible&&e===D()?"true":"false"):e.removeAttribute("aria-expanded")}))}function I(){T().removeEventListener("mousemove",g),mu=mu.filter((function(e){return e!==g}))}function R(t){if(!Xc.isTouch||!h&&"mousedown"!==t.type){var n=t.composedPath&&t.composedPath()[0]||t.target;if(!y.props.interactive||!Jc(w,n)){if(Pc(y.props.triggerTarget||e).some((function(e){return Jc(e,n)}))){if(Xc.isTouch)return;if(y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else j("onClickOutside",[y,t]);!0===y.props.hideOnClick&&(y.clearDelayTimeouts(),y.hide(),d=!0,setTimeout((function(){d=!1})),y.state.isMounted||U())}}}function F(){h=!0}function B(){h=!1}function P(){var e=T();e.addEventListener("mousedown",R,!0),e.addEventListener("touchend",R,Lc),e.addEventListener("touchstart",B,Lc),e.addEventListener("touchmove",F,Lc)}function U(){var e=T();e.removeEventListener("mousedown",R,!0),e.removeEventListener("touchend",R,Lc),e.removeEventListener("touchstart",B,Lc),e.removeEventListener("touchmove",F,Lc)}function H(e,t){var n=S().box;function i(e){e.target===n&&(Zc(n,"remove",i),t())}if(0===e)return t();Zc(n,"remove",s),Zc(n,"add",i),s=i}function $(t,n,i){void 0===i&&(i=!1),Pc(y.props.triggerTarget||e).forEach((function(e){e.addEventListener(t,n,i),m.push({node:e,eventType:t,handler:n,options:i})}))}function W(){var e;M()&&($("touchstart",V,{passive:!0}),$("touchend",G,{passive:!0})),(e=y.props.trigger,e.split(/\s+/).filter(Boolean)).forEach((function(e){if("manual"!==e)switch($(e,V),e){case"mouseenter":$("mouseleave",G);break;case"focus":$(ru?"focusout":"blur",Y);break;case"focusin":$("focusout",Y)}}))}function q(){m.forEach((function(e){var t=e.node,n=e.eventType,i=e.handler,r=e.options;t.removeEventListener(n,i,r)})),m=[]}function V(e){var t,n=!1;if(y.state.isEnabled&&!Q(e)&&!d){var i="focus"===(null==(t=o)?void 0:t.type);o=e,l=e.currentTarget,z(),!y.state.isVisible&&Vc(e)&&mu.forEach((function(t){return t(e)})),"click"===e.type&&(y.props.trigger.indexOf("mouseenter")<0||p)&&!1!==y.props.hideOnClick&&y.state.isVisible?n=!0:ee(e),"click"===e.type&&(p=!n),n&&!i&&te(e)}}function K(e){var t=e.target,n=D().contains(t)||w.contains(t);if("mousemove"!==e.type||!n){var i=X().concat(w).map((function(e){var t,n=null==(t=e._tippy.popperInstance)?void 0:t.state;return n?{popperRect:e.getBoundingClientRect(),popperState:n,props:u}:null})).filter(Boolean);(function(e,t){var n=t.clientX,i=t.clientY;return e.every((function(e){var t=e.popperRect,r=e.popperState,o=e.props.interactiveBorder,s=r.placement.split("-")[0],a=r.modifiersData.offset;if(!a)return!0;var l="bottom"===s?a.top.y:0,c="top"===s?a.bottom.y:0,u="right"===s?a.left.x:0,p="left"===s?a.right.x:0,d=t.top-i+l>o,h=i-t.bottom-c>o,f=t.left-n+u>o,m=n-t.right-p>o;return d||h||f||m}))})(i,e)&&(I(),te(e))}}function G(e){Q(e)||y.props.trigger.indexOf("click")>=0&&p||(y.props.interactive?y.hideWithInteractivity(e):te(e))}function Y(e){y.props.trigger.indexOf("focusin")<0&&e.target!==D()||y.props.interactive&&e.relatedTarget&&w.contains(e.relatedTarget)||te(e)}function Q(e){return!!Xc.isTouch&&M()!==e.type.indexOf("touch")>=0}function Z(){J();var t=y.props,n=t.popperOptions,i=t.placement,r=t.offset,o=t.getReferenceClientRect,s=t.moveTransition,l=O()?du(w).arrow:null,c=o?{getBoundingClientRect:o,contextElement:o.contextElement||D()}:e,u={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(e){var t=e.state;if(O()){var n=S().box;["placement","reference-hidden","escaped"].forEach((function(e){"placement"===e?n.setAttribute("data-placement",t.placement):t.attributes.popper["data-popper-"+e]?n.setAttribute("data-"+e,""):n.removeAttribute("data-"+e)})),t.attributes.popper={}}}},p=[{name:"offset",options:{offset:r}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!s}},u];O()&&l&&p.push({name:"arrow",options:{element:l,padding:3}}),p.push.apply(p,(null==n?void 0:n.modifiers)||[]),y.popperInstance=Oc(c,w,Object.assign({},n,{placement:i,onFirstUpdate:a,modifiers:p}))}function J(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function X(){return Hc(w.querySelectorAll("[data-tippy-root]"))}function ee(e){y.clearDelayTimeouts(),e&&j("onTrigger",[y,e]),P();var t=N(!0),i=C(),r=i[0],o=i[1];Xc.isTouch&&"hold"===r&&o&&(t=o),t?n=setTimeout((function(){y.show()}),t):y.show()}function te(e){if(y.clearDelayTimeouts(),j("onUntrigger",[y,e]),y.state.isVisible){if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(e.type)>=0&&p)){var t=N(!1);t?i=setTimeout((function(){y.state.isVisible&&y.hide()}),t):r=requestAnimationFrame((function(){y.hide()}))}}else U()}}function vu(e,t){void 0===t&&(t={});var n=ou.plugins.concat(t.plugins||[]);document.addEventListener("touchstart",tu,Lc),window.addEventListener("blur",iu);var i=Object.assign({},t,{plugins:n}),r=Kc(e).reduce((function(e,t){var n=t&&bu(t,i);return n&&e.push(n),e}),[]);return qc(e)?r[0]:r}vu.defaultProps=ou,vu.setDefaultProps=function(e){Object.keys(e).forEach((function(t){ou[t]=e[t]}))},vu.currentInput=Xc,Object.assign({},Dl,{effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow)}});var yu={clientX:0,clientY:0},xu=[];function wu(e){var t=e.clientX,n=e.clientY;yu={clientX:t,clientY:n}}var _u={name:"followCursor",defaultValue:!1,fn:function(e){var t=e.reference,n=Qc(e.props.triggerTarget||t),i=!1,r=!1,o=!0,s=e.props;function a(){return"initial"===e.props.followCursor&&e.state.isVisible}function l(){n.addEventListener("mousemove",p)}function c(){n.removeEventListener("mousemove",p)}function u(){i=!0,e.setProps({getReferenceClientRect:null}),i=!1}function p(n){var i=!n.target||t.contains(n.target),r=e.props.followCursor,o=n.clientX,s=n.clientY,a=t.getBoundingClientRect(),l=o-a.left,c=s-a.top;!i&&e.props.interactive||e.setProps({getReferenceClientRect:function(){var e=t.getBoundingClientRect(),n=o,i=s;"initial"===r&&(n=e.left+l,i=e.top+c);var a="horizontal"===r?e.top:i,u="vertical"===r?e.right:n,p="horizontal"===r?e.bottom:i,d="vertical"===r?e.left:n;return{width:u-d,height:p-a,top:a,right:u,bottom:p,left:d}}})}function d(){e.props.followCursor&&(xu.push({instance:e,doc:n}),function(e){e.addEventListener("mousemove",wu)}(n))}function h(){xu=xu.filter((function(t){return t.instance!==e})),0===xu.filter((function(e){return e.doc===n})).length&&function(e){e.removeEventListener("mousemove",wu)}(n)}return{onCreate:d,onDestroy:h,onBeforeUpdate:function(){s=e.props},onAfterUpdate:function(t,n){var o=n.followCursor;i||void 0!==o&&s.followCursor!==o&&(h(),o?(d(),!e.state.isMounted||r||a()||l()):(c(),u()))},onMount:function(){e.props.followCursor&&!r&&(o&&(p(yu),o=!1),a()||l())},onTrigger:function(e,t){Vc(t)&&(yu={clientX:t.clientX,clientY:t.clientY}),r="focus"===t.type},onHidden:function(){e.props.followCursor&&(u(),c(),o=!0)}}}};vu.setDefaultProps({render:hu});class ku{constructor({editor:e,element:t,view:n,tippyOptions:i={},shouldShow:r}){this.preventHide=!1,this.shouldShow=({view:e,state:t,from:n,to:i})=>{const{doc:r,selection:o}=t,{empty:s}=o,a=!r.textBetween(n,i).length&&ka(t.selection),l=this.element.contains(document.activeElement);return!(!e.hasFocus()&&!l||s||a||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout((()=>this.update(this.editor.view)))},this.blurHandler=({event:e})=>{var t;this.preventHide?this.preventHide=!1:(null==e?void 0:e.relatedTarget)&&(null===(t=this.element.parentNode)||void 0===t?void 0:t.contains(e.relatedTarget))||this.hide()},this.editor=e,this.element=t,this.view=n,r&&(this.shouldShow=r),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=i,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:e}=this.editor.options,t=!!e.parentElement;!this.tippy&&t&&(this.tippy=vu(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",(e=>{this.blurHandler({event:e})})))}update(e,t){var n,i,r;const{state:o,composing:s}=e,{doc:a,selection:l}=o,c=t&&t.doc.eq(a)&&t.selection.eq(l);if(s||c)return;this.createTooltip();const{ranges:u}=l,p=Math.min(...u.map((e=>e.$from.pos))),d=Math.max(...u.map((e=>e.$to.pos)));(null===(n=this.shouldShow)||void 0===n?void 0:n.call(this,{editor:this.editor,view:e,state:o,oldState:t,from:p,to:d}))?(null===(i=this.tippy)||void 0===i||i.setProps({getReferenceClientRect:(null===(r=this.tippyOptions)||void 0===r?void 0:r.getReferenceClientRect)||(()=>{if(o.selection instanceof $n){const t=e.nodeDOM(p);if(t)return t.getBoundingClientRect()}return Ha(e,p,d)})}),this.show()):this.hide()}show(){var e;null===(e=this.tippy)||void 0===e||e.show()}hide(){var e;null===(e=this.tippy)||void 0===e||e.hide()}destroy(){var e;null===(e=this.tippy)||void 0===e||e.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const Eu=e=>new oi({key:"string"==typeof e.pluginKey?new li(e.pluginKey):e.pluginKey,view:t=>new ku({view:t,...e})});fa.create({name:"bubbleMenu",addOptions:()=>({element:null,tippyOptions:{},pluginKey:"bubbleMenu",shouldShow:null}),addProseMirrorPlugins(){return this.options.element?[Eu({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,shouldShow:this.options.shouldShow})]:[]}});class Cu{constructor({editor:e,element:t,view:n,tippyOptions:i={},shouldShow:r}){this.preventHide=!1,this.shouldShow=({view:e,state:t})=>{const{selection:n}=t,{$anchor:i,empty:r}=n,o=1===i.depth,s=i.parent.isTextblock&&!i.parent.type.spec.code&&!i.parent.textContent;return!!(e.hasFocus()&&r&&o&&s&&this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout((()=>this.update(this.editor.view)))},this.blurHandler=({event:e})=>{var t;this.preventHide?this.preventHide=!1:(null==e?void 0:e.relatedTarget)&&(null===(t=this.element.parentNode)||void 0===t?void 0:t.contains(e.relatedTarget))||this.hide()},this.editor=e,this.element=t,this.view=n,r&&(this.shouldShow=r),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=i,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:e}=this.editor.options,t=!!e.parentElement;!this.tippy&&t&&(this.tippy=vu(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"right",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",(e=>{this.blurHandler({event:e})})))}update(e,t){var n,i,r;const{state:o}=e,{doc:s,selection:a}=o,{from:l,to:c}=a;if(t&&t.doc.eq(s)&&t.selection.eq(a))return;this.createTooltip();(null===(n=this.shouldShow)||void 0===n?void 0:n.call(this,{editor:this.editor,view:e,state:o,oldState:t}))?(null===(i=this.tippy)||void 0===i||i.setProps({getReferenceClientRect:(null===(r=this.tippyOptions)||void 0===r?void 0:r.getReferenceClientRect)||(()=>Ha(e,l,c))}),this.show()):this.hide()}show(){var e;null===(e=this.tippy)||void 0===e||e.show()}hide(){var e;null===(e=this.tippy)||void 0===e||e.hide()}destroy(){var e;null===(e=this.tippy)||void 0===e||e.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}fa.create({name:"floatingMenu",addOptions:()=>({element:null,tippyOptions:{},pluginKey:"floatingMenu",shouldShow:null}),addProseMirrorPlugins(){return this.options.element?[(e={pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,shouldShow:this.options.shouldShow},new oi({key:"string"==typeof e.pluginKey?new li(e.pluginKey):e.pluginKey,view:t=>new Cu({view:t,...e})}))]:[];var e}});const Mu=e=>{const[n,i]=r(null);return o((()=>{if(!n)return;if(e.editor.isDestroyed)return;const{pluginKey:t="bubbleMenu",editor:i,tippyOptions:r={},shouldShow:o=null}=e,s=Eu({pluginKey:t,editor:i,element:n,tippyOptions:r,shouldShow:o});return i.registerPlugin(s),()=>i.unregisterPlugin(t)}),[e.editor,n]),t.createElement("div",{ref:i,className:e.className,style:{visibility:"hidden"}},e.children)};class Ou extends class extends class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach((e=>e.apply(this,t))),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter((e=>e!==t)):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),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),window.setTimeout((()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))}),0)}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&&document&&(this.css=function(e,t){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const i=document.createElement("style");return t&&i.setAttribute("nonce",t),i.setAttribute("data-tiptap-style",""),i.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(i),i}(el,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.view&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e){this.setOptions({editable:e}),this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const n=Js(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:n});this.view.updateState(i)}unregisterPlugin(e){if(this.isDestroyed)return;const t="string"==typeof e?`${e}$`:e.key,n=this.state.reconfigure({plugins:this.state.plugins.filter((e=>!e.key.startsWith(t)))});this.view.updateState(n)}createExtensionManager(){const e=[...this.options.enableCoreExtensions?Object.values(Xa):[],...this.options.extensions].filter((e=>["extension","node","mark"].includes(null==e?void 0:e.type)));this.extensionManager=new pa(e,this)}createCommandManager(){this.commandManager=new qs({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=ja(this.options.content,this.schema,this.options.parseOptions),t=Ca(e,this.options.autofocus);this.view=new ms(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:ii.create({doc:e,selection:t||void 0})});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews();this.view.dom.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach((e=>{var t;return null===(t=this.capturedTransaction)||void 0===t?void 0:t.step(e)})):void(this.capturedTransaction=e);const t=this.state.apply(e),n=!this.state.selection.eq(t.selection);this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),n&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),r=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),r&&this.emit("blur",{editor:this,event:r.event,transaction:e}),e.docChanged&&!e.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return Ra(this.state,e)}isActive(e,t){const n="string"==typeof e?e:null,i="string"==typeof e?t:e;return function(e,t,n={}){if(!t)return Sa(e,null,n)||Pa(e,null,n);const i=Na(t,e.schema);return"node"===i?Sa(e,t,n):"mark"===i&&Pa(e,t,n)}(this.state,n,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return function(e,t){const n=$t.fromSchema(t).serializeFragment(e),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t="\n\n",textSerializers:n={}}=e||{};return function(e,t){return ma(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:t,textSerializers:{...n,...ga(this.schema)}})}get isEmpty(){return function(e){var t;const n=null===(t=e.type.createAndFill())||void 0===t?void 0:t.toJSON(),i=e.toJSON();return JSON.stringify(n)===JSON.stringify(i)}(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(null===(e=this.view)||void 0===e?void 0:e.docView)}}{constructor(){super(...arguments),this.contentComponent=null}}const Du=({renderers:e})=>t.createElement(t.Fragment,null,Array.from(e).map((([e,t])=>f.createPortal(t.reactElement,t.element,e))));class Tu extends t.Component{constructor(e){super(e),this.editorContentRef=t.createRef(),this.state={renderers:new Map}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const{editor:e}=this.props;if(e&&e.options.element){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.options.element.childNodes),e.setOptions({element:t}),e.contentComponent=this,e.createNodeViews()}}componentWillUnmount(){const{editor:e}=this.props;if(!e)return;if(e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null,!e.options.element.firstChild)return;const t=document.createElement("div");t.append(...e.options.element.childNodes),e.setOptions({element:t})}render(){const{editor:e,...n}=this.props;return t.createElement(t.Fragment,null,t.createElement("div",{ref:this.editorContentRef,...n}),t.createElement(Du,{renderers:this.state.renderers}))}}const Su=t.memo(Tu),Nu=n({onDragStart:void 0}),Au=()=>i(Nu),ju=e=>{const n=e.as||"div",{nodeViewContentRef:i}=Au();return t.createElement(n,{...e,ref:i,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...e.style}})},Lu=t.forwardRef(((e,n)=>{const{onDragStart:i}=Au(),r=e.as||"div";return t.createElement(r,{...e,ref:n,"data-node-view-wrapper":"",onDragStart:i,style:{whiteSpace:"normal",...e.style}})}));class zu{constructor(e,{editor:t,props:n={},as:i="div",className:r=""}){this.ref=null,this.id=Math.floor(4294967295*Math.random()).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(i),this.element.classList.add("react-renderer"),r&&this.element.classList.add(...r.split(" ")),this.render()}render(){const e=this.component,n=this.props;(function(e){return!("function"!=typeof e||!e.prototype||!e.prototype.isReactComponent)}(e)||function(e){var t;return!("object"!=typeof e||"Symbol(react.forward_ref)"!==(null===(t=e.$$typeof)||void 0===t?void 0:t.toString()))}(e))&&(n.ref=e=>{this.ref=e}),this.reactElement=t.createElement(e,{...n}),queueMicrotask((()=>{m((()=>{var e;(null===(e=this.editor)||void 0===e?void 0:e.contentComponent)&&this.editor.contentComponent.setState({renderers:this.editor.contentComponent.state.renderers.set(this.id,this)})}))}))}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){queueMicrotask((()=>{m((()=>{var e;if(null===(e=this.editor)||void 0===e?void 0:e.contentComponent){const{renderers:e}=this.editor.contentComponent.state;e.delete(this.id),this.editor.contentComponent.setState({renderers:e})}}))}))}}class Iu extends class{constructor(e,t,n){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,n,i,r,o,s,a;const{view:l}=this.editor,c=e.target,u=3===c.nodeType?null===(t=c.parentElement)||void 0===t?void 0:t.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(null===(n=this.contentDOM)||void 0===n?void 0:n.contains(c))||!u)return;let p=0,d=0;if(this.dom!==u){const t=this.dom.getBoundingClientRect(),n=u.getBoundingClientRect(),a=null!==(i=e.offsetX)&&void 0!==i?i:null===(r=e.nativeEvent)||void 0===r?void 0:r.offsetX,l=null!==(o=e.offsetY)&&void 0!==o?o:null===(s=e.nativeEvent)||void 0===s?void 0:s.offsetY;p=n.x-t.x+a,d=n.y-t.y+l}null===(a=e.dataTransfer)||void 0===a||a.setDragImage(this.dom,p,d);const h=$n.create(l.state.doc,this.getPos()),f=l.state.tr.setSelection(h);l.dispatch(f)}stopEvent(e){var t;if(!this.dom)return!1;if("function"==typeof this.options.stopEvent)return this.options.stopEvent({event:e});const n=e.target;if(!(this.dom.contains(n)&&!(null===(t=this.contentDOM)||void 0===t?void 0:t.contains(n))))return!1;const i="drop"===e.type;if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i)return!0;const{isEditable:r}=this.editor,{isDragging:o}=this,s=!!this.node.type.spec.draggable,a=$n.isSelectable(this.node),l="copy"===e.type,c="paste"===e.type,u="cut"===e.type,p="mousedown"===e.type,d=e.type.startsWith("drag");if(!s&&a&&d&&e.preventDefault(),s&&d&&!o)return e.preventDefault(),!1;if(s&&r&&!o&&p){const e=n.closest("[data-drag-handle]");e&&(this.dom===e||this.dom.contains(e))&&(this.isDragging=!0,document.addEventListener("dragend",(()=>{this.isDragging=!1}),{once:!0}),document.addEventListener("mouseup",(()=>{this.isDragging=!1}),{once:!0}))}return!(o||i||l||c||u||p&&a)}ignoreMutation(e){if(!this.dom||!this.contentDOM)return!0;if("function"==typeof this.options.ignoreMutation)return this.options.ignoreMutation({mutation:e});if(this.node.isLeaf||this.node.isAtom)return!0;if("selection"===e.type)return!1;if(this.dom.contains(e.target)&&"childList"===e.type&&Ma()&&this.editor.isFocused){if([...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every((e=>e.isContentEditable)))return!1}return this.contentDOM===e.target&&"attributes"===e.type||!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command((({tr:t})=>{const n=this.getPos();return t.setNodeMarkup(n,void 0,{...this.node.attrs,...e}),!0}))}deleteNode(){const e=this.getPos(),t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}}{mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,selected:!1,extension:this.extension,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode()};if(!this.component.displayName){const e=e=>e.charAt(0).toUpperCase()+e.substring(1);this.component.displayName=e(this.extension.name)}const n=e=>{const n=this.component,i=this.onDragStart.bind(this);return t.createElement(Nu.Provider,{value:{onDragStart:i,nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&e.appendChild(this.contentDOMElement)}}},t.createElement(n,{...e}))};n.displayName="ReactNodeView",this.contentDOMElement=this.node.isLeaf?null:document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement&&(this.contentDOMElement.style.whiteSpace="inherit");let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);const{className:r=""}=this.options;this.renderer=new zu(n,{editor:this.editor,props:e,as:i,className:`node-${this.node.type.name} ${r}`.trim()})}get dom(){var e;if(this.renderer.element.firstElementChild&&!(null===(e=this.renderer.element.firstElementChild)||void 0===e?void 0:e.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}update(e,t){const n=e=>{this.renderer.updateProps(e)};if(e.type!==this.node.type)return!1;if("function"==typeof this.options.update){const i=this.node,r=this.decorations;return this.node=e,this.decorations=t,this.options.update({oldNode:i,oldDecorations:r,newNode:e,newDecorations:t,updateProps:()=>n({node:e,decorations:t})})}return e===this.node&&this.decorations===t||(this.node=e,this.decorations=t,n({node:e,decorations:t})),!0}selectNode(){this.renderer.updateProps({selected:!0})}deselectNode(){this.renderer.updateProps({selected:!1})}destroy(){this.renderer.destroy(),this.contentDOMElement=null}}function Ru(e,t){return n=>n.editor.contentComponent?new Iu(e,n,t):{}}const Fu=(e={},t=[])=>{const[n,i]=r(null),s=function(){const[,e]=r(0);return()=>e((e=>e+1))}();return o((()=>{let t=!0;const n=new Ou(e);return i(n),n.on("transaction",(()=>{requestAnimationFrame((()=>{requestAnimationFrame((()=>{t&&s()}))}))})),()=>{n.destroy(),t=!1}}),t),n};var Bu,Pu={exports:{}};
|
|
1
|
+
import*as e from"react";import t,{createContext as n,useContext as i,useState as r,useEffect as o,forwardRef as s,cloneElement as a,useLayoutEffect as l,useRef as c,Children as u,isValidElement as p,useCallback as d,useImperativeHandle as h}from"react";import f,{flushSync as m,createPortal as g}from"react-dom";import b from"http";import v from"https";import y from"url";import x from"stream";import w from"assert";import _ from"tty";import k from"util";import E from"os";import C from"zlib";import M from"path";import O from"fs";import{Field as D}from"formik";import{renderToString as T}from"react-dom/server";var S="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function N(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}function A(e){var t=e.default;if("function"==typeof t){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})})),n}var j=function(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]},L=j;var z=function(e){return function t(n){return 0===arguments.length||L(n)?t:e.apply(this,arguments)}};var I=function(e,t){return Object.prototype.hasOwnProperty.call(t,e)},R=I,F=Object.prototype.toString,B=function(){return"[object Arguments]"===F.call(arguments)?function(e){return"[object Arguments]"===F.call(e)}:function(e){return R("callee",e)}}(),P=B,U=Array.isArray||function(e){return null!=e&&e.length>=0&&"[object Array]"===Object.prototype.toString.call(e)};var H=function(e){return"[object Object]"===Object.prototype.toString.call(e)};var $=function(e){return"[object String]"===Object.prototype.toString.call(e)};var W=function(e){var t=Object.prototype.toString.call(e);return"[object Uint8ClampedArray]"===t||"[object Int8Array]"===t||"[object Uint8Array]"===t||"[object Int16Array]"===t||"[object Uint16Array]"===t||"[object Int32Array]"===t||"[object Uint32Array]"===t||"[object Float32Array]"===t||"[object Float64Array]"===t||"[object BigInt64Array]"===t||"[object BigUint64Array]"===t},q=P,V=U,K=H,G=$,Y=W,Q=z((function(e){return null!=e&&"function"==typeof e["fantasy-land/empty"]?e["fantasy-land/empty"]():null!=e&&null!=e.constructor&&"function"==typeof e.constructor["fantasy-land/empty"]?e.constructor["fantasy-land/empty"]():null!=e&&"function"==typeof e.empty?e.empty():null!=e&&null!=e.constructor&&"function"==typeof e.constructor.empty?e.constructor.empty():V(e)?[]:G(e)?"":K(e)?{}:q(e)?function(){return arguments}():Y(e)?e.constructor.from(""):void 0})),Z=Q,J=z,X=j;var ee=function(e){return function t(n,i){switch(arguments.length){case 0:return t;case 1:return X(n)?t:J((function(t){return e(n,t)}));default:return X(n)&&X(i)?t:X(n)?J((function(t){return e(t,i)})):X(i)?J((function(t){return e(n,t)})):e(n,i)}}};var te=function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n};var ne=function(e,t,n){for(var i=0,r=n.length;i<r;){if(e(t,n[i]))return!0;i+=1}return!1};var ie=function(e){var t=String(e).match(/^function (\w*)/);return null==t?"":t[1]};var re="function"==typeof Object.is?Object.is:function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},oe=z,se=I,ae=P,le=!{toString:null}.propertyIsEnumerable("toString"),ce=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],ue=function(){return arguments.propertyIsEnumerable("length")}(),pe=function(e,t){for(var n=0;n<e.length;){if(e[n]===t)return!0;n+=1}return!1},de="function"!=typeof Object.keys||ue?oe((function(e){if(Object(e)!==e)return[];var t,n,i=[],r=ue&&ae(e);for(t in e)!se(t,e)||r&&"length"===t||(i[i.length]=t);if(le)for(n=ce.length-1;n>=0;)se(t=ce[n],e)&&!pe(i,t)&&(i[i.length]=t),n-=1;return i})):oe((function(e){return Object(e)!==e?[]:Object.keys(e)})),he=te,fe=ne,me=ie,ge=I,be=re,ve=de,ye=z((function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)}));function xe(e,t,n,i){var r=he(e),o=he(t);function s(e,t){return we(e,t,n.slice(),i.slice())}return!fe((function(e,t){return!fe(s,t,e)}),o,r)}function we(e,t,n,i){if(be(e,t))return!0;var r=ye(e);if(r!==ye(t))return!1;if("function"==typeof e["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e);if("function"==typeof e.equals||"function"==typeof t.equals)return"function"==typeof e.equals&&e.equals(t)&&"function"==typeof t.equals&&t.equals(e);switch(r){case"Arguments":case"Array":case"Object":if("function"==typeof e.constructor&&"Promise"===me(e.constructor))return e===t;break;case"Boolean":case"Number":case"String":if(typeof e!=typeof t||!be(e.valueOf(),t.valueOf()))return!1;break;case"Date":if(!be(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(e.source!==t.source||e.global!==t.global||e.ignoreCase!==t.ignoreCase||e.multiline!==t.multiline||e.sticky!==t.sticky||e.unicode!==t.unicode)return!1}for(var o=n.length-1;o>=0;){if(n[o]===e)return i[o]===t;o-=1}switch(r){case"Map":return e.size===t.size&&xe(e.entries(),t.entries(),n.concat([e]),i.concat([t]));case"Set":return e.size===t.size&&xe(e.values(),t.values(),n.concat([e]),i.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var s=ve(e);if(s.length!==ve(t).length)return!1;var a=n.concat([e]),l=i.concat([t]);for(o=s.length-1;o>=0;){var c=s[o];if(!ge(c,t)||!we(t[c],e[c],a,l))return!1;o-=1}return!0}var _e=we,ke=ee((function(e,t){return _e(e,t,[],[])})),Ee=Z,Ce=ke,Me=z((function(e){return null!=e&&Ce(e,Ee(e))})),Oe=Me,De=z((function(e){return null==e})),Te=De;const Se=["img","iframe"],Ne=e=>e.toString().toLowerCase().replace(/\s+/g,"-").replace(/&/g,"-and-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""),Ae=e=>e=(e=e.replace(/[_-]+/g," ").replace(/\s{2,}/g," ").replace(/([a-z\d])([A-Z])/g,"$1"+" "+"$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g,"$1"+" "+"$2").toLowerCase().trim()).charAt(0).toUpperCase()+e.slice(1),je=e=>Te(e)||Oe(e),Le=()=>{},ze=e=>{var t;if(je(e))return!0;if(Se.some((t=>e.includes(t))))return!1;const n=document.createElement("div");n.innerHTML=e;const i=je(null===(t=n.textContent)||void 0===t?void 0:t.trim());return n.remove(),i};function Ie(){return Ie=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},Ie.apply(this,arguments)}function Re(e){this.content=e}function Fe(e,t,n){for(let i=0;;i++){if(i==e.childCount||i==t.childCount)return e.childCount==t.childCount?null:n;let r=e.child(i),o=t.child(i);if(r!=o){if(!r.sameMarkup(o))return n;if(r.isText&&r.text!=o.text){for(let e=0;r.text[e]==o.text[e];e++)n++;return n}if(r.content.size||o.content.size){let e=Fe(r.content,o.content,n+1);if(null!=e)return e}n+=r.nodeSize}else n+=r.nodeSize}}function Be(e,t,n,i){for(let r=e.childCount,o=t.childCount;;){if(0==r||0==o)return r==o?null:{a:n,b:i};let s=e.child(--r),a=t.child(--o),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:i};if(s.isText&&s.text!=a.text){let e=0,t=Math.min(s.text.length,a.text.length);for(;e<t&&s.text[s.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,i--;return{a:n,b:i}}if(s.content.size||a.content.size){let e=Be(s.content,a.content,n-1,i-1);if(e)return e}n-=l,i-=l}else n-=l,i-=l}}Re.prototype={constructor:Re,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var i=n&&n!=e?this.remove(n):this,r=i.find(e),o=i.content.slice();return-1==r?o.push(n||e,t):(o[r+1]=t,n&&(o[r]=n)),new Re(o)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new Re(n)},addToStart:function(e,t){return new Re([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new Re(n)},addBefore:function(e,t,n){var i=this.remove(t),r=i.content.slice(),o=i.find(e);return r.splice(-1==o?r.length:o,0,t,n),new Re(r)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=Re.from(e)).size?new Re(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=Re.from(e)).size?new Re(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=Re.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach((function(t,n){e[t]=n})),e},get size(){return this.content.length>>1}},Re.from=function(e){if(e instanceof Re)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new Re(t)};class Pe{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,i=0,r){for(let o=0,s=0;s<t;o++){let a=this.content[o],l=s+a.nodeSize;if(l>e&&!1!==n(a,i+s,r||null,o)&&a.content.size){let r=s+1;a.nodesBetween(Math.max(0,e-r),Math.min(a.content.size,t-r),n,i+r)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let r="",o=!0;return this.nodesBetween(e,t,((s,a)=>{s.isText?(r+=s.text.slice(Math.max(e,a)-a,t-a),o=!n):s.isLeaf?(i?r+="function"==typeof i?i(s):i:s.type.spec.leafText&&(r+=s.type.spec.leafText(s)),o=!n):!o&&s.isBlock&&(r+=n,o=!0)}),0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),r=1);r<e.content.length;r++)i.push(e.content[r]);return new Pe(i,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],i=0;if(t>e)for(let r=0,o=0;o<t;r++){let s=this.content[r],a=o+s.nodeSize;a>e&&((o<e||a>t)&&(s=s.isText?s.cut(Math.max(0,e-o),Math.min(s.text.length,t-o)):s.cut(Math.max(0,e-o-1),Math.min(s.content.size,t-o-1))),n.push(s),i+=s.nodeSize),o=a}return new Pe(n,i)}cutByIndex(e,t){return e==t?Pe.empty:0==e&&t==this.content.length?this:new Pe(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),r=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new Pe(i,r)}addToStart(e){return new Pe([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Pe(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,n=0;t<this.content.length;t++){let i=this.content[t];e(i,n,t),n+=i.nodeSize}}findDiffStart(e,t=0){return Fe(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Be(this,e,t,n)}findIndex(e,t=-1){if(0==e)return He(0,e);if(e==this.size)return He(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,i=0;;n++){let r=i+this.child(n).nodeSize;if(r>=e)return r==e||t>0?He(n+1,r):He(n,i);i=r}}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 Pe.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new Pe(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Pe.empty;let t,n=0;for(let i=0;i<e.length;i++){let r=e[i];n+=r.nodeSize,i&&r.isText&&e[i-1].sameMarkup(r)?(t||(t=e.slice(0,i)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new Pe(t||e,n)}static from(e){if(!e)return Pe.empty;if(e instanceof Pe)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Pe([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Pe.empty=new Pe([],0);const Ue={index:0,offset:0};function He(e,t){return Ue.index=e,Ue.offset=t,Ue}function $e(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!$e(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!$e(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class We{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let i=0;i<e.length;i++){let r=e[i];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,i));else{if(r.type.excludes(this.type))return e;!n&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(r)}}return t||(t=e.slice()),n||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&&$e(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 n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return We.none;if(e instanceof We)return[e];let t=e.slice();return t.sort(((e,t)=>e.type.rank-t.type.rank)),t}}We.none=[];class qe extends Error{}class Ve{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Ge(this.content,e+this.openStart,t);return n&&new Ve(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Ve(Ke(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 Ve.empty;let n=t.openStart||0,i=t.openEnd||0;if("number"!=typeof n||"number"!=typeof i)throw new RangeError("Invalid input for Slice.fromJSON");return new Ve(Pe.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)i++;return new Ve(e,n,i)}}function Ke(e,t,n){let{index:i,offset:r}=e.findIndex(t),o=e.maybeChild(i),{index:s,offset:a}=e.findIndex(n);if(r==t||o.isText){if(a!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(i!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(i,o.copy(Ke(o.content,t-r-1,n-r-1)))}function Ge(e,t,n,i){let{index:r,offset:o}=e.findIndex(t),s=e.maybeChild(r);if(o==t||s.isText)return i&&!i.canReplace(r,r,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=Ge(s.content,t-o-1,n);return a&&e.replaceChild(r,s.copy(a))}function Ye(e,t,n){if(n.openStart>e.depth)throw new qe("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new qe("Inconsistent open depths");return Qe(e,t,n,0)}function Qe(e,t,n,i){let r=e.index(i),o=e.node(i);if(r==t.index(i)&&i<e.depth-n.openStart){let s=Qe(e,t,n,i+1);return o.copy(o.content.replaceChild(r,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=i||t.depth!=i){let{start:r,end:s}=function(e,t){let n=t.depth-e.openStart,i=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)i=t.node(e).copy(Pe.from(i));return{start:i.resolveNoCache(e.openStart+n),end:i.resolveNoCache(i.content.size-e.openEnd-n)}}(n,e);return tt(o,nt(e,r,s,t,i))}{let i=e.parent,r=i.content;return tt(i,r.cut(0,e.parentOffset).append(n.content).append(r.cut(t.parentOffset)))}}return tt(o,it(e,t,i))}function Ze(e,t){if(!t.type.compatibleContent(e.type))throw new qe("Cannot join "+t.type.name+" onto "+e.type.name)}function Je(e,t,n){let i=e.node(n);return Ze(i,t.node(n)),i}function Xe(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function et(e,t,n,i){let r=(t||e).node(n),o=0,s=t?t.index(n):r.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(Xe(e.nodeAfter,i),o++));for(let e=o;e<s;e++)Xe(r.child(e),i);t&&t.depth==n&&t.textOffset&&Xe(t.nodeBefore,i)}function tt(e,t){if(!e.type.validContent(t))throw new qe("Invalid content for node "+e.type.name);return e.copy(t)}function nt(e,t,n,i,r){let o=e.depth>r&&Je(e,t,r+1),s=i.depth>r&&Je(n,i,r+1),a=[];return et(null,e,r,a),o&&s&&t.index(r)==n.index(r)?(Ze(o,s),Xe(tt(o,nt(e,t,n,i,r+1)),a)):(o&&Xe(tt(o,it(e,t,r+1)),a),et(t,n,r,a),s&&Xe(tt(s,it(n,i,r+1)),a)),et(i,null,r,a),new Pe(a)}function it(e,t,n){let i=[];if(et(null,e,n,i),e.depth>n){Xe(tt(Je(e,t,n+1),it(e,t,n+1)),i)}return et(t,null,n,i),new Pe(i)}Ve.empty=new Ve(Pe.empty,0,0);class rt{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?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[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):i}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):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],i=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)i+=n.child(t).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return We.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),i=e.maybeChild(t);if(!n){let e=n;n=i,i=e}let r=n.marks;for(var o=0;o<r.length;o++)!1!==r[o].type.spec.inclusive||i&&r[o].isInSet(i.marks)||(r=r[o--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,i=e.parent.maybeChild(e.index());for(var r=0;r<n.length;r++)!1!==n[r].type.spec.inclusive||i&&n[r].isInSet(i.marks)||(n=n[r--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new lt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],i=0,r=t;for(let t=e;;){let{index:e,offset:o}=t.content.findIndex(r),s=r-o;if(n.push(t,e,i+o),!s)break;if(t=t.child(e),t.isText)break;r=s-1,i+=o+1}return new rt(t,n,r)}static resolveCached(e,t){for(let n=0;n<ot.length;n++){let i=ot[n];if(i.pos==t&&i.doc==e)return i}let n=ot[st]=rt.resolve(e,t);return st=(st+1)%at,n}}let ot=[],st=0,at=12;class lt{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const ct=Object.create(null);class ut{constructor(e,t,n,i=We.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||Pe.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,i=0){this.content.nodesBetween(e,t,n,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,i){return this.content.textBetween(e,t,n,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&$e(this.attrs,t||e.defaultAttrs||ct)&&We.sameSet(this.marks,n||We.none)}copy(e=null){return e==this.content?this:new ut(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ut(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Ve.empty;let i=this.resolve(e),r=this.resolve(t),o=n?0:i.sharedDepth(t),s=i.start(o),a=i.node(o).content.cut(i.pos-s,r.pos-s);return new Ve(a,i.depth-o,r.depth-o)}replace(e,t,n){return Ye(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let i=this.content.child(t-1);return{node:i,index:t-1,offset:n-i.nodeSize}}resolve(e){return rt.resolveCached(this,e)}resolveNoCache(e){return rt.resolve(this,e)}rangeHasMark(e,t,n){let i=!1;return t>e&&this.nodesBetween(e,t,(e=>(n.isInSet(e.marks)&&(i=!0),!i))),i}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()+")"),dt(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,n=Pe.empty,i=0,r=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,i,r),s=o&&o.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=i;e<r;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,i){if(i&&!this.type.allowsMarks(i))return!1;let r=this.contentMatchAt(e).matchType(n),o=r&&r.matchFragment(this.content,t);return!!o&&o.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){if(!this.type.validContent(this.content))throw new RangeError(`Invalid content for node ${this.type.name}: ${this.content.toString().slice(0,50)}`);let e=We.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!We.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e=>e.type.name))}`);this.content.forEach((e=>e.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((e=>e.toJSON()))),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let i=Pe.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,n)}}ut.prototype.text=void 0;class pt extends ut{constructor(e,t,n,i){if(super(e,t,null,i),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):dt(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 pt(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new pt(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&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 dt(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class ht{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new ft(e,t);if(null==n.next)return ht.empty;let i=mt(n);n.next&&n.err("Unexpected trailing text");let r=function(e){let t=Object.create(null);return n(wt(e,0));function n(i){let r=[];i.forEach((t=>{e[t].forEach((({term:t,to:n})=>{if(!t)return;let i;for(let e=0;e<r.length;e++)r[e][0]==t&&(i=r[e][1]);wt(e,n).forEach((e=>{i||r.push([t,i=[]]),-1==i.indexOf(e)&&i.push(e)}))}))}));let o=t[i.join(",")]=new ht(i.indexOf(e.length-1)>-1);for(let e=0;e<r.length;e++){let i=r[e][1].sort(xt);o.next.push({type:r[e][0],next:t[i.join(",")]||n(i)})}return o}}(function(e){let t=[[]];return r(o(e,0),n()),t;function n(){return t.push([])-1}function i(e,n,i){let r={term:i,to:n};return t[e].push(r),r}function r(e,t){e.forEach((e=>e.to=t))}function o(e,t){if("choice"==e.type)return e.exprs.reduce(((e,n)=>e.concat(o(n,t))),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return i(t,s),r(o(e.expr,s),s),[i(s)]}if("plus"==e.type){let s=n();return r(o(e.expr,t),s),r(o(e.expr,s),s),[i(s)]}if("opt"==e.type)return[i(t)].concat(o(e.expr,t));if("range"==e.type){let s=t;for(let t=0;t<e.min;t++){let t=n();r(o(e.expr,s),t),s=t}if(-1==e.max)r(o(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=n();i(s,t),r(o(e.expr,s),t),s=t}return[i(s)]}if("name"==e.type)return[i(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let i=0;;i++){let s=o(e.exprs[i],t);if(i==e.exprs.length-1)return s;r(s,t=n())}}}(i));return function(e,t){for(let n=0,i=[e];n<i.length;n++){let e=i[n],r=!e.validEnd,o=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];o.push(n.name),!r||n.isText||n.hasRequiredAttrs()||(r=!1),-1==i.indexOf(s)&&i.push(s)}r&&t.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(r,n),r}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let i=this;for(let r=t;i&&r<n;r++)i=i.matchType(e.child(r).type);return i}get inlineContent(){return this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let i=[this];return function r(o,s){let a=o.matchFragment(e,n);if(a&&(!t||a.validEnd))return Pe.from(s.map((e=>e.createAndFill())));for(let e=0;e<o.next.length;e++){let{type:t,next:n}=o.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==i.indexOf(n)){i.push(n);let e=r(n,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let i=n.shift(),r=i.match;if(r.matchType(e)){let e=[];for(let t=i;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<r.next.length;e++){let{type:o,next:s}=r.next[e];o.isLeaf||o.hasRequiredAttrs()||o.name in t||i.type&&!s.validEnd||(n.push({match:o.contentMatch,type:o,via:i}),t[o.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=[];return function t(n){e.push(n);for(let i=0;i<n.next.length;i++)-1==e.indexOf(n.next[i].next)&&t(n.next[i].next)}(this),e.map(((t,n)=>{let i=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)i+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return i})).join("\n")}}ht.empty=new ht(!0);class ft{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 mt(e){let t=[];do{t.push(gt(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function gt(e){let t=[];do{t.push(bt(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function bt(e){let t=function(e){if(e.eat("(")){let t=mt(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,i=n[t];if(i)return[i];let r=[];for(let e in n){let i=n[e];i.groups.indexOf(t)>-1&&r.push(i)}0==r.length&&e.err("No node type or group '"+t+"' found");return r}(e,e.next).map((t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t})));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=yt(e,t)}return t}function vt(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function yt(e,t){let n=vt(e),i=n;return e.eat(",")&&(i="}"!=e.next?vt(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:i,expr:t}}function xt(e,t){return t-e}function wt(e,t){let n=[];return function t(i){let r=e[i];if(1==r.length&&!r[0].term)return t(r[0].to);n.push(i);for(let e=0;e<r.length;e++){let{term:i,to:o}=r[e];i||-1!=n.indexOf(o)||t(o)}}(t),n.sort(xt)}function _t(e){let t=Object.create(null);for(let n in e){let i=e[n];if(!i.hasDefault)return null;t[n]=i.default}return t}function kt(e,t){let n=Object.create(null);for(let i in e){let r=t&&t[i];if(void 0===r){let t=e[i];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+i);r=t.default}n[i]=r}return n}function Et(e){let t=Object.create(null);if(e)for(let n in e)t[n]=new Mt(e[n]);return t}class Ct{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=Et(n.attrs),this.defaultAttrs=_t(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ht.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}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:kt(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ut(this,this.computeAttrs(e),Pe.from(t),We.setFrom(n))}createChecked(e=null,t,n){if(t=Pe.from(t),!this.validContent(t))throw new RangeError("Invalid content for node "+this.name);return new ut(this,this.computeAttrs(e),t,We.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=Pe.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let i=this.contentMatch.matchFragment(t),r=i&&i.fillBefore(Pe.empty,!0);return r?new ut(this,e,t.append(r),We.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:We.none:e}static compile(e,t){let n=Object.create(null);e.forEach(((e,i)=>n[e]=new Ct(e,t,i)));let i=t.spec.topNode||"doc";if(!n[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class Mt{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class Ot{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=Et(i.attrs),this.excluded=null;let r=_t(this.attrs);this.instance=r?new We(this,r):null}create(e=null){return!e&&this.instance?this.instance:new We(this,kt(this.attrs,e))}static compile(e,t){let n=Object.create(null),i=0;return e.forEach(((e,r)=>n[e]=new Ot(e,i++,t,r))),n}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]}excludes(e){return this.excluded.indexOf(e)>-1}}class Dt{constructor(e){this.cached=Object.create(null),this.spec={nodes:Re.from(e.nodes),marks:Re.from(e.marks||{}),topNode:e.topNode},this.nodes=Ct.compile(this.spec.nodes,this),this.marks=Ot.compile(this.spec.marks,this);let t=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let n=this.nodes[e],i=n.spec.content||"",r=n.spec.marks;n.contentMatch=t[i]||(t[i]=ht.parse(i,this.nodes)),n.inlineContent=n.contentMatch.inlineContent,n.markSet="_"==r?null:r?Tt(this,r.split(" ")):""!=r&&n.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:Tt(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,i){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Ct))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,i)}text(e,t){let n=this.nodes.text;return new pt(n,n.defaultAttrs,e,We.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return ut.fromJSON(this,e)}markFromJSON(e){return We.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Tt(e,t){let n=[];for(let i=0;i<t.length;i++){let r=t[i],o=e.marks[r],s=o;if(o)n.push(o);else for(let t in e.marks){let i=e.marks[t];("_"==r||i.spec.group&&i.spec.group.split(" ").indexOf(r)>-1)&&n.push(s=i)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[i]+"'")}return n}class St{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach((e=>{e.tag?this.tags.push(e):e.style&&this.styles.push(e)})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)}))}parse(e,t={}){let n=new Bt(this,t,!1);return n.addAll(e,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Bt(this,t,!0);return n.addAll(e,t.from,t.to),Ve.maxOpen(n.finish())}matchTag(e,t,n){for(let i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){let n=this.tags[i];if(Pt(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,i){for(let r=i?this.styles.indexOf(i)+1:0;r<this.styles.length;r++){let i=this.styles[r],o=i.style;if(!(0!=o.indexOf(e)||i.context&&!n.matchesContext(i.context)||o.length>e.length&&(61!=o.charCodeAt(e.length)||o.slice(e.length+1)!=t))){if(i.getAttrs){let e=i.getAttrs(t);if(!1===e)continue;i.attrs=e||void 0}return i}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,i=0;for(;i<t.length;i++){let e=t[i];if((null==e.priority?50:e.priority)<n)break}t.splice(i,0,e)}for(let t in e.marks){let i=e.marks[t].spec.parseDOM;i&&i.forEach((e=>{n(e=Ut(e)),e.mark=t}))}for(let t in e.nodes){let i=e.nodes[t].spec.parseDOM;i&&i.forEach((e=>{n(e=Ut(e)),e.node=t}))}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new St(e,St.schemaRules(e)))}}const Nt={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},At={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},jt={ol:!0,ul:!0},Lt=1,zt=2,It=4;function Rt(e,t,n){return null!=t?(t?Lt:0)|("full"===t?zt:0):e&&"pre"==e.whitespace?Lt|zt:n&~It}class Ft{constructor(e,t,n,i,r,o,s){this.type=e,this.attrs=t,this.marks=n,this.pendingMarks=i,this.solid=r,this.options=s,this.content=[],this.activeMarks=We.none,this.stashMarks=[],this.match=o||(s&It?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(Pe.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Lt)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=Pe.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(Pe.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,n=this.pendingMarks;t<n.length;t++){let i=n[t];(this.type?this.type.allowsMarkType(i.type):Ht(i.type,e))&&!i.isInSet(this.activeMarks)&&(this.activeMarks=i.addToSet(this.activeMarks),this.pendingMarks=i.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Nt.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Bt{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0;let i,r=t.topNode,o=Rt(null,t.preserveWhitespace,0)|(n?It:0);i=r?new Ft(r.type,r.attrs,We.none,We.none,!0,t.topMatch||r.type.contentMatch,o):new Ft(n?null:e.schema.topNodeType,null,We.none,We.none,!0,null,o),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){if(3==e.nodeType)this.addTextNode(e);else if(1==e.nodeType){let t=e.getAttribute("style"),n=t?this.readStyles(function(e){let t,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,i=[];for(;t=n.exec(e);)i.push(t[1],t[2].trim());return i}(t)):null,i=this.top;if(null!=n)for(let e=0;e<n.length;e++)this.addPendingMark(n[e]);if(this.addElement(e),null!=n)for(let e=0;e<n.length;e++)this.removePendingMark(n[e],i)}}addTextNode(e){let t=e.nodeValue,n=this.top;if(n.options&zt||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(n.options&Lt)t=n.options&zt?t.replace(/\r\n?/g,"\n"):t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){let i=n.content[n.content.length-1],r=e.previousSibling;(!i||r&&"BR"==r.nodeName||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let n,i=e.nodeName.toLowerCase();jt.hasOwnProperty(i)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&jt.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let r=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(n=this.parser.matchTag(e,this,t));if(r?r.ignore:At.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e);else if(!r||r.skip||r.closeParent){r&&r.closeParent?this.open=Math.max(0,this.open-1):r&&r.skip.nodeType&&(e=r.skip);let t,n=this.top,o=this.needsBlock;if(Nt.hasOwnProperty(i))t=!0,n.type||(this.needsBlock=!0);else if(!e.firstChild)return void this.leafFallback(e);this.addAll(e),t&&this.sync(n),this.needsBlock=o}else this.addElementByRule(e,r,!1===r.consuming?n:void 0)}leafFallback(e){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"))}ignoreFallback(e){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=We.none;e:for(let n=0;n<e.length;n+=2)for(let i;;){let r=this.parser.matchStyle(e[n],e[n+1],this,i);if(!r)continue e;if(r.ignore)return null;if(t=this.parser.schema.marks[r.mark].create(r.attrs).addToSet(t),!1!==r.consuming)break;i=r}return t}addElementByRule(e,t,n){let i,r,o;if(t.node)r=this.parser.schema.nodes[t.node],r.isLeaf?this.insertNode(r.create(t.attrs))||this.leafFallback(e):i=this.enter(r,t.attrs||null,t.preserveWhitespace);else{o=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(o)}let s=this.top;if(r&&r.isLeaf)this.findInside(e);else if(n)this.addElement(e,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((e=>this.insertNode(e)));else{let n=e;"string"==typeof t.contentElement?n=e.querySelector(t.contentElement):"function"==typeof t.contentElement?n=t.contentElement(e):t.contentElement&&(n=t.contentElement),this.findAround(e,n,!0),this.addAll(n)}i&&this.sync(s)&&this.open--,o&&this.removePendingMark(o,s)}addAll(e,t,n){let i=t||0;for(let r=t?e.childNodes[t]:e.firstChild,o=null==n?null:e.childNodes[n];r!=o;r=r.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(r);this.findAtPoint(e,i)}findPlace(e){let t,n;for(let i=this.open;i>=0;i--){let r=this.nodes[i],o=r.findWrapping(e);if(o&&(!t||t.length>o.length)&&(t=o,n=r,!o.length))break;if(r.solid)break}if(!t)return!1;this.sync(n);for(let e=0;e<t.length;e++)this.enterInner(t[e],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let n=t.activeMarks;for(let i=0;i<e.marks.length;i++)t.type&&!t.type.allowsMarkType(e.marks[i].type)||(n=e.marks[i].addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n){let i=this.findPlace(e.create(t));return i&&this.enterInner(e,t,!0,n),i}enterInner(e,t=null,n=!1,i){this.closeExtra();let r=this.top;r.applyPending(e),r.match=r.match&&r.match.matchType(e);let o=Rt(e,i,r.options);r.options&It&&0==r.content.length&&(o|=It),this.nodes.push(new Ft(e,t,r.activeMarks,r.pendingMarks,n,null,o)),this.open++}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;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)if(null==this.find[i].pos&&1==e.nodeType&&e.contains(this.find[i].node)){t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),r=-(n?n.depth+1:0)+(i?0:1),o=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=r;s--)if(o(e-1,s))return!0;return!1}{let e=s>0||0==s&&i?this.nodes[s].type:n&&s>=r?n.node(s-r).type:null;if(!e||e.name!=a&&-1==e.groups.indexOf(a))return!1;s--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}addPendingMark(e){let t=function(e,t){for(let n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let n=this.open;n>=0;n--){let i=this.nodes[n];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let t=i.popFromStashMark(e);t&&i.type&&i.type.allowsMarkType(t.type)&&(i.activeMarks=t.addToSet(i.activeMarks))}if(i==t)break}}}function Pt(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Ut(e){let t={};for(let n in e)t[n]=e[n];return t}function Ht(e,t){let n=t.schema.nodes;for(let i in n){let r=n[i];if(!r.allowsMarkType(e))continue;let o=[],s=e=>{o.push(e);for(let n=0;n<e.edgeCount;n++){let{type:i,next:r}=e.edge(n);if(i==t)return!0;if(o.indexOf(r)<0&&s(r))return!0}};if(s(r.contentMatch))return!0}}class $t{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=qt(t).createDocumentFragment());let i=n,r=[];return e.forEach((e=>{if(r.length||e.marks.length){let n=0,o=0;for(;n<r.length&&o<e.marks.length;){let t=e.marks[o];if(this.marks[t.type.name]){if(!t.eq(r[n][0])||!1===t.type.spec.spanning)break;n++,o++}else o++}for(;n<r.length;)i=r.pop()[1];for(;o<e.marks.length;){let n=e.marks[o++],s=this.serializeMark(n,e.isInline,t);s&&(r.push([n,i]),i.appendChild(s.dom),i=s.contentDOM||s.dom)}}i.appendChild(this.serializeNodeInner(e,t))})),n}serializeNodeInner(e,t){let{dom:n,contentDOM:i}=$t.renderSpec(qt(t),this.nodes[e.type.name](e));if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let r=this.serializeMark(e.marks[i],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&$t.renderSpec(qt(n),i(e,t))}static renderSpec(e,t,n=null){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let i,r=t[0],o=r.indexOf(" ");o>0&&(n=r.slice(0,o),r=r.slice(o+1));let s=n?e.createElementNS(n,r):e.createElement(r),a=t[1],l=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a)){l=2;for(let e in a)if(null!=a[e]){let t=e.indexOf(" ");t>0?s.setAttributeNS(e.slice(0,t),e.slice(t+1),a[e]):s.setAttribute(e,a[e])}}for(let r=l;r<t.length;r++){let o=t[r];if(0===o){if(r<t.length-1||r>l)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}{let{dom:t,contentDOM:r}=$t.renderSpec(e,o,n);if(s.appendChild(t),r){if(i)throw new RangeError("Multiple content holes");i=r}}}return{dom:s,contentDOM:i}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new $t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Wt(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return Wt(e.marks)}}function Wt(e){let t={};for(let n in e){let i=e[n].spec.toDOM;i&&(t[n]=i)}return t}function qt(e){return e.document||window.document}const Vt=65535,Kt=Math.pow(2,16);function Gt(e,t){return e+t*Kt}function Yt(e){return e&Vt}const Qt=1,Zt=2,Jt=4,Xt=8;class en{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Xt)>0}get deletedBefore(){return(this.delInfo&(Qt|Jt))>0}get deletedAfter(){return(this.delInfo&(Zt|Jt))>0}get deletedAcross(){return(this.delInfo&Jt)>0}}class tn{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&tn.empty)return tn.empty}recover(e){let t=0,n=Yt(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(e&Vt))/Kt}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,r=this.inverted?2:1,o=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?i:0);if(a>e)break;let l=this.ranges[s+r],c=this.ranges[s+o],u=a+l;if(e<=u){let r=a+i+((l?e==a?-1:e==u?1:t:t)<0?0:c);if(n)return r;let o=e==(t<0?a:u)?null:Gt(s/3,e-a),p=e==a?Zt:e==u?Qt:Jt;return(t<0?e!=a:e!=u)&&(p|=Xt),new en(r,p,o)}i+=c-l}return n?e+i:new en(e+i,0,null)}touches(e,t){let n=0,i=Yt(t),r=this.inverted?2:1,o=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let a=this.ranges[t+r];if(e<=s+a&&t==3*i)return!0;n+=this.ranges[t+o]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,r=0;i<this.ranges.length;i+=3){let o=this.ranges[i],s=o-(this.inverted?r:0),a=o+(this.inverted?0:r),l=this.ranges[i+t],c=this.ranges[i+n];e(s,s+l,a,a+c),r+=c-l}}invert(){return new tn(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?tn.empty:new tn(e<0?[0,-e,0]:[0,0,e])}}tn.empty=new tn([]);class nn{constructor(e=[],t,n=0,i=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=i}slice(e=0,t=this.maps.length){return new nn(this.maps,this.mirror,e,t)}copy(){return new nn(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,n=this.maps.length;t<e.maps.length;t++){let i=e.getMirror(t);this.appendMap(e.maps[t],null!=i&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=i&&i>t?n-i-1:void 0)}}invert(){let e=new nn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let n=this.from;n<this.to;n++){let r=this.maps[n].mapResult(e,t);if(null!=r.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this.maps[t].recover(r.recover);continue}}i|=r.delInfo,e=r.pos}return n?e:new en(e,i,null)}}const rn=Object.create(null);class on{getMap(){return tn.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=rn[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in rn)throw new RangeError("Duplicate use of step JSON ID "+e);return rn[e]=t,t.prototype.jsonID=e,t}}class sn{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new sn(e,null)}static fail(e){return new sn(null,e)}static fromReplace(e,t,n,i){try{return sn.ok(e.replace(t,n,i))}catch(e){if(e instanceof qe)return sn.fail(e.message);throw e}}}function an(e,t,n){let i=[];for(let r=0;r<e.childCount;r++){let o=e.child(r);o.content.size&&(o=o.copy(an(o.content,t,o))),o.isInline&&(o=t(o,n,r)),i.push(o)}return Pe.fromArray(i)}class ln extends on{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),r=new Ve(an(t.content,((e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),i),t.openStart,t.openEnd);return sn.fromReplace(e,this.from,this.to,r)}invert(){return new cn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ln(t.pos,n.pos,this.mark)}merge(e){return e instanceof ln&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ln(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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ln(t.from,t.to,e.markFromJSON(t.mark))}}on.jsonID("addMark",ln);class cn extends on{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Ve(an(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return sn.fromReplace(e,this.from,this.to,n)}invert(){return new ln(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new cn(t.pos,n.pos,this.mark)}merge(e){return e instanceof cn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new cn(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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new cn(t.from,t.to,e.markFromJSON(t.mark))}}on.jsonID("removeMark",cn);class un extends on{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return sn.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return sn.fromReplace(e,this.pos,this.pos+1,new Ve(Pe.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new un(this.pos,t.marks[n]);return new un(this.pos,this.mark)}}return new pn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new un(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new un(t.pos,e.markFromJSON(t.mark))}}on.jsonID("addNodeMark",un);class pn extends on{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return sn.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return sn.fromReplace(e,this.pos,this.pos+1,new Ve(Pe.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new un(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new pn(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new pn(t.pos,e.markFromJSON(t.mark))}}on.jsonID("removeNodeMark",pn);class dn extends on{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&fn(e,this.from,this.to)?sn.fail("Structure replace would overwrite content"):sn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new tn([this.from,this.to-this.from,this.slice.size])}invert(e){return new dn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new dn(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof dn)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?Ve.empty:new Ve(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new dn(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Ve.empty:new Ve(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new dn(this.from,this.to+(e.to-e.from),t,this.structure)}}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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new dn(t.from,t.to,Ve.fromJSON(e,t.slice),!!t.structure)}}on.jsonID("replace",dn);class hn extends on{constructor(e,t,n,i,r,o,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=r,this.insert=o,this.structure=s}apply(e){if(this.structure&&(fn(e,this.from,this.gapFrom)||fn(e,this.gapTo,this.to)))return sn.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return sn.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?sn.fromReplace(e,this.from,this.to,n):sn.fail("Content does not fit in gap")}getMap(){return new tn([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 hn(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=e.map(this.gapFrom,-1),r=e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||r>n.pos?null:new hn(t.pos,n.pos,i,r,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("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new hn(t.from,t.to,t.gapFrom,t.gapTo,Ve.fromJSON(e,t.slice),t.insert,!!t.structure)}}function fn(e,t,n){let i=e.resolve(t),r=n-t,o=i.depth;for(;r>0&&o>0&&i.indexAfter(o)==i.node(o).childCount;)o--,r--;if(r>0){let e=i.node(o).maybeChild(i.indexAfter(o));for(;r>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,r--}}return!1}function mn(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function gn(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let i=e.$from.node(n),r=e.$from.index(n),o=e.$to.indexAfter(n);if(n<e.depth&&i.canReplace(r,o,t))return n;if(0==n||i.type.spec.isolating||!mn(i,r,o))break}return null}function bn(e,t,n=null,i=e){let r=function(e,t){let{parent:n,startIndex:i,endIndex:r}=e,o=n.contentMatchAt(i).findWrapping(t);if(!o)return null;let s=o.length?o[0]:t;return n.canReplaceWith(i,r,s)?o:null}(e,t),o=r&&function(e,t){let{parent:n,startIndex:i,endIndex:r}=e,o=n.child(i),s=t.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:t).contentMatch;for(let e=i;a&&e<r;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?s:null}(i,t);return o?r.map(vn).concat({type:t,attrs:n}).concat(o.map(vn)):null}function vn(e){return{type:e,attrs:null}}function yn(e,t,n=1,i){let r=e.resolve(t),o=r.depth-n,s=i&&i[i.length-1]||r.parent;if(o<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let e=r.depth-1,t=n-2;e>o;e--,t--){let n=r.node(e),o=r.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(o,n.childCount),a=i&&i[t]||n;if(a!=n&&(s=s.replaceChild(0,a.type.create(a.attrs))),!n.canReplace(o+1,n.childCount)||!a.type.validContent(s))return!1}let a=r.indexAfter(o),l=i&&i[0];return r.node(o).canReplaceWith(a,a,l?l.type:r.node(o+1).type)}function xn(e,t){let n=e.resolve(t),i=n.index();return function(e,t){return!(!e||!t||e.isLeaf||!e.canAppend(t))}(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(i,i+1)}function wn(e,t,n){let i=e.resolve(t);if(!n.content.size)return t;let r=n.content;for(let e=0;e<n.openStart;e++)r=r.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=i.depth;t>=0;t--){let n=t==i.depth?0:i.pos<=(i.start(t+1)+i.end(t+1))/2?-1:1,o=i.index(t)+(n>0?1:0),s=i.node(t),a=!1;if(1==e)a=s.canReplace(o,o,r);else{let e=s.contentMatchAt(o).findWrapping(r.firstChild.type);a=e&&s.canReplaceWith(o,o,e[0])}if(a)return 0==n?i.pos:n<0?i.before(t+1):i.after(t+1)}return null}function _n(e,t,n=t,i=Ve.empty){if(t==n&&!i.size)return null;let r=e.resolve(t),o=e.resolve(n);return kn(r,o,i)?new dn(t,n,i):new En(r,o,i).fit()}function kn(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}on.jsonID("replaceAround",hn);class En{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=Pe.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=Pe.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let r=this.placed,o=n.depth,s=i.depth;for(;o&&s&&1==r.childCount;)r=r.firstChild.content,o--,s--;let a=new Ve(r,o,s);return e>-1?new hn(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new dn(n.pos,i.pos,a):null}findFittable(){for(let e=1;e<=2;e++)for(let t=this.unplaced.openStart;t>=0;t--){let n,i=null;t?(i=On(this.unplaced.content,t-1).firstChild,n=i.content):n=this.unplaced.content;let r=n.firstChild;for(let n=this.depth;n>=0;n--){let o,{type:s,match:a}=this.frontier[n],l=null;if(1==e&&(r?a.matchType(r.type)||(l=a.fillBefore(Pe.from(r),!1)):i&&s.compatibleContent(i.type)))return{sliceDepth:t,frontierDepth:n,parent:i,inject:l};if(2==e&&r&&(o=a.findWrapping(r.type)))return{sliceDepth:t,frontierDepth:n,parent:i,wrap:o};if(i&&a.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=On(e,t);return!(!i.childCount||i.firstChild.isLeaf)&&(this.unplaced=new Ve(e,t+1,Math.max(n,i.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=On(e,t);if(i.childCount<=1&&t>0){let r=e.size-t<=t+i.size;this.unplaced=new Ve(Cn(e,t-1,1),t-1,r?t-1:n)}else this.unplaced=new Ve(Cn(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let e=0;e<r.length;e++)this.openFrontierNode(r[e]);let o=this.unplaced,s=n?n.content:o.content,a=o.openStart-e,l=0,c=[],{match:u,type:p}=this.frontier[t];if(i){for(let e=0;e<i.childCount;e++)c.push(i.child(e));u=u.matchFragment(i)}let d=s.size+e-(o.content.size-o.openEnd);for(;l<s.childCount;){let e=s.child(l),t=u.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(u=t,c.push(Dn(e.mark(p.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?d:-1)))}let h=l==s.childCount;h||(d=-1),this.placed=Mn(this.placed,t,Pe.from(c)),this.frontier[t].match=u,h&&d<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<d;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=h?0==e?Ve.empty:new Ve(Cn(o.content,e-1,1),e-1,d<0?o.openEnd:e-1):new Ve(Cn(o.content,e,l),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Tn(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Tn(e,t,i,n,r);if(o){for(let n=t-1;n>=0;n--){let{match:t,type:i}=this.frontier[n],r=Tn(e,n,i,t,!0);if(!r||r.childCount)continue e}return{depth:t,fit:o,move:r?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=Mn(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),i=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,i)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Mn(this.placed,this.depth,Pe.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(Pe.empty,!0);e.childCount&&(this.placed=Mn(this.placed,this.frontier.length,e))}}function Cn(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Cn(e.firstChild.content,t-1,n)))}function Mn(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Mn(e.lastChild.content,t-1,n)))}function On(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Dn(e,t,n){if(t<=0)return e;let i=e.content;return t>1&&(i=i.replaceChild(0,Dn(i.firstChild,t-1,1==i.childCount?n-1:0))),t>0&&(i=e.type.contentMatch.fillBefore(i).append(i),n<=0&&(i=i.append(e.type.contentMatch.matchFragment(i).fillBefore(Pe.empty,!0)))),e.copy(i)}function Tn(e,t,n,i,r){let o=e.node(t),s=r?e.indexAfter(t):e.index(t);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let a=i.fillBefore(o.content,!0,s);return a&&!function(e,t,n){for(let i=n;i<t.childCount;i++)if(!e.allowsMarks(t.child(i).marks))return!0;return!1}(n,o.content,s)?a:null}function Sn(e){return e.spec.defining||e.spec.definingForContent}function Nn(e,t,n,i,r){if(t<n){let r=e.firstChild;e=e.replaceChild(0,r.copy(Nn(r.content,t+1,n,i,r)))}if(t>i){let t=r.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(Pe.empty,!0))}return e}function An(e,t){let n=[];for(let i=Math.min(e.depth,t.depth);i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}class jn extends on{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return sn.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return sn.fromReplace(e,this.pos,this.pos+1,new Ve(Pe.from(i),0,t.isLeaf?0:1))}getMap(){return tn.empty}invert(e){return new jn(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 jn(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new jn(t.pos,t.attr,t.value)}}on.jsonID("attr",jn);let Ln=class extends Error{};Ln=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(Ln.prototype=Object.create(Error.prototype)).constructor=Ln,Ln.prototype.name="TransformError";class zn{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new nn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Ln(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,n=Ve.empty){let i=_n(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new Ve(Pe.from(n),0,0))}delete(e,t){return this.replace(e,t,Ve.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,i){if(!i.size)return e.deleteRange(t,n);let r=e.doc.resolve(t),o=e.doc.resolve(n);if(kn(r,o,i))return e.step(new dn(t,n,i));let s=An(r,e.doc.resolve(n));0==s[s.length-1]&&s.pop();let a=-(r.depth+1);s.unshift(a);for(let e=r.depth,t=r.pos-1;e>0;e--,t--){let n=r.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?a=e:r.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),c=[],u=i.openStart;for(let e=i.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==i.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=c[e].type,n=Sn(t);if(n&&r.node(l).type!=t)u=e;else if(n||!t.isTextblock)break}for(let t=i.openStart;t>=0;t--){let a=(t+u+1)%(i.openStart+1),p=c[a];if(p)for(let t=0;t<s.length;t++){let c=s[(t+l)%s.length],u=!0;c<0&&(u=!1,c=-c);let d=r.node(c-1),h=r.index(c-1);if(d.canReplaceWith(h,h,p.type,p.marks))return e.replace(r.before(c),u?o.after(c):n,new Ve(Nn(i.content,0,i.openStart,a),a,i.openEnd))}}let p=e.steps.length;for(let a=s.length-1;a>=0&&(e.replace(t,n,i),!(e.steps.length>p));a--){let e=s[a];e<0||(t=r.before(e),n=o.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,i){if(!i.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let r=function(e,t,n){let i=e.resolve(t);if(i.parent.canReplaceWith(i.index(),i.index(),n))return t;if(0==i.parentOffset)for(let e=i.depth-1;e>=0;e--){let t=i.index(e);if(i.node(e).canReplaceWith(t,t,n))return i.before(e+1);if(t>0)return null}if(i.parentOffset==i.parent.content.size)for(let e=i.depth-1;e>=0;e--){let t=i.indexAfter(e);if(i.node(e).canReplaceWith(t,t,n))return i.after(e+1);if(t<i.node(e).childCount)return null}return null}(e.doc,t,i.type);null!=r&&(t=n=r)}e.replaceRange(t,n,new Ve(Pe.from(i),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let i=e.doc.resolve(t),r=e.doc.resolve(n),o=An(i,r);for(let t=0;t<o.length;t++){let n=o[t],s=t==o.length-1;if(s&&0==n||i.node(n).type.contentMatch.validEnd)return e.delete(i.start(n),r.end(n));if(n>0&&(s||i.node(n-1).canReplace(i.index(n-1),r.indexAfter(n-1))))return e.delete(i.before(n),r.after(n))}for(let o=1;o<=i.depth&&o<=r.depth;o++)if(t-i.start(o)==i.depth-o&&n>i.end(o)&&r.end(o)-n!=r.depth-o)return e.delete(i.before(o),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:i,$to:r,depth:o}=t,s=i.before(o+1),a=r.after(o+1),l=s,c=a,u=Pe.empty,p=0;for(let e=o,t=!1;e>n;e--)t||i.index(e)>0?(t=!0,u=Pe.from(i.node(e).copy(u)),p++):l--;let d=Pe.empty,h=0;for(let e=o,t=!1;e>n;e--)t||r.after(e+1)<r.end(e)?(t=!0,d=Pe.from(r.node(e).copy(d)),h++):c++;e.step(new hn(l,c,s,a,new Ve(u.append(d),p,h),u.size-p,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let i=new dn(t-n,t+n,Ve.empty,!0);e.step(i)}(this,e,t),this}wrap(e,t){return function(e,t,n){let i=Pe.empty;for(let e=n.length-1;e>=0;e--){if(i.size){let t=n[e].type.contentMatch.matchFragment(i);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=Pe.from(n[e].type.create(n[e].attrs,i))}let r=t.start,o=t.end;e.step(new hn(r,o,r,o,new Ve(i,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,i=null){return function(e,t,n,i,r){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=e.steps.length;e.doc.nodesBetween(t,n,((t,n)=>{if(t.isTextblock&&!t.hasMarkup(i,r)&&function(e,t,n){let i=e.resolve(t),r=i.index();return i.parent.canReplaceWith(r,r+1,n)}(e.doc,e.mapping.slice(o).map(n),i)){e.clearIncompatible(e.mapping.slice(o).map(n,1),i);let s=e.mapping.slice(o),a=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new hn(a,l,a+1,l-1,new Ve(Pe.from(i.create(r,null,t.marks)),0,0),1,!0)),!1}}))}(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i=[]){return function(e,t,n,i,r){let o=e.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(i,null,r||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new hn(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new Ve(Pe.from(s),0,0),1,!0))}(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new jn(e,t,n)),this}addNodeMark(e,t){return this.step(new un(e,t)),this}removeNodeMark(e,t){if(!(t instanceof We)){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t=t.isInSet(n.marks),!t)return this}return this.step(new pn(e,t)),this}split(e,t=1,n){return function(e,t,n=1,i){let r=e.doc.resolve(t),o=Pe.empty,s=Pe.empty;for(let e=r.depth,t=r.depth-n,a=n-1;e>t;e--,a--){o=Pe.from(r.node(e).copy(o));let t=i&&i[a];s=Pe.from(t?t.type.create(t.attrs,s):r.node(e).copy(s))}e.step(new dn(t,t,new Ve(o.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,i){let r,o,s=[],a=[];e.doc.nodesBetween(t,n,((e,l,c)=>{if(!e.isInline)return;let u=e.marks;if(!i.isInSet(u)&&c.type.allowsMarkType(i.type)){let c=Math.max(l,t),p=Math.min(l+e.nodeSize,n),d=i.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(d)||(r&&r.to==c&&r.mark.eq(u[e])?r.to=p:s.push(r=new cn(c,p,u[e])));o&&o.to==c?o.to=p:a.push(o=new ln(c,p,i))}})),s.forEach((t=>e.step(t))),a.forEach((t=>e.step(t)))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,i){let r=[],o=0;e.doc.nodesBetween(t,n,((e,s)=>{if(!e.isInline)return;o++;let a=null;if(i instanceof Ot){let t,n=e.marks;for(;t=i.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else i?i.isInSet(e.marks)&&(a=[i]):a=e.marks;if(a&&a.length){let i=Math.min(s+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<r.length;e++){let t=r[e];t.step==o-1&&l.eq(r[e].style)&&(n=t)}n?(n.to=i,n.step=o):r.push({style:l,from:Math.max(s,t),to:i,step:o})}}})),r.forEach((t=>e.step(new cn(t.from,t.to,t.style))))}(this,e,t,n),this}clearIncompatible(e,t,n){return function(e,t,n,i=n.contentMatch){let r=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<r.childCount;t++){let a=r.child(t),l=s+a.nodeSize,c=i.matchType(a.type);if(c){i=c;for(let t=0;t<a.marks.length;t++)n.allowsMarkType(a.marks[t].type)||e.step(new cn(s,l,a.marks[t]))}else o.push(new dn(s,l,Ve.empty));s=l}if(!i.validEnd){let t=i.fillBefore(Pe.empty,!0);e.replace(s,s,new Ve(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}(this,e,t,n),this}}const In=Object.create(null);class Rn{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Fn(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=Ve.empty){let n=t.content.lastChild,i=null;for(let e=0;e<t.openEnd;e++)i=n,n=n.lastChild;let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:a,$to:l}=o[s],c=e.mapping.slice(r);e.replaceRange(c.map(a.pos),c.map(l.pos),s?Ve.empty:t),0==s&&Gn(e,r,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let r=0;r<i.length;r++){let{$from:o,$to:s}=i[r],a=e.mapping.slice(n),l=a.map(o.pos),c=a.map(s.pos);r?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),Gn(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new Un(e):Kn(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let i=e.depth-1;i>=0;i--){let r=t<0?Kn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,n):Kn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,n);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new qn(e.node(0))}static atStart(e){return Kn(e,e,0,0,1)||new qn(e)}static atEnd(e){return Kn(e,e,e.content.size,e.childCount,-1)||new qn(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=In[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in In)throw new RangeError("Duplicate use of selection JSON ID "+e);return In[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Un.between(this.$anchor,this.$head).getBookmark()}}Rn.prototype.visible=!0;class Fn{constructor(e,t){this.$from=e,this.$to=t}}let Bn=!1;function Pn(e){Bn||e.parent.inlineContent||(Bn=!0,console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Un extends Rn{constructor(e,t=e){Pn(e),Pn(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return Rn.near(n);let i=e.resolve(t.map(this.anchor));return new Un(i.parent.inlineContent?i:n,n)}replace(e,t=Ve.empty){if(super.replace(e,t),t==Ve.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof Un&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Hn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Un(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if(n&&!i||(n=i>=0?1:-1),!t.parent.inlineContent){let e=Rn.findFrom(t,n,!0)||Rn.findFrom(t,-n,!0);if(!e)return Rn.near(t,n);t=e.$head}return e.parent.inlineContent||(0==i||(e=(Rn.findFrom(e,-n,!0)||Rn.findFrom(e,n,!0)).$anchor).pos<t.pos!=i<0)&&(e=t),new Un(e,t)}}Rn.jsonID("text",Un);class Hn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Hn(e.map(this.anchor),e.map(this.head))}resolve(e){return Un.between(e.resolve(this.anchor),e.resolve(this.head))}}class $n extends Rn{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),r=e.resolve(i);return n?Rn.near(r):new $n(r)}content(){return new Ve(Pe.from(this.node),0,0)}eq(e){return e instanceof $n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Wn(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new $n(e.resolve(t.anchor))}static create(e,t){return new $n(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}$n.prototype.visible=!1,Rn.jsonID("node",$n);class Wn{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Hn(n,n):new Wn(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&$n.isSelectable(n)?new $n(t):Rn.near(t)}}class qn extends Rn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Ve.empty){if(t==Ve.empty){e.delete(0,e.doc.content.size);let t=Rn.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new qn(e)}map(e){return new qn(e)}eq(e){return e instanceof qn}getBookmark(){return Vn}}Rn.jsonID("all",qn);const Vn={map(){return this},resolve:e=>new qn(e)};function Kn(e,t,n,i,r,o=!1){if(t.inlineContent)return Un.create(e,n);for(let s=i-(r>0?0:1);r>0?s<t.childCount:s>=0;s+=r){let i=t.child(s);if(i.isAtom){if(!o&&$n.isSelectable(i))return $n.create(e,n-(r<0?i.nodeSize:0))}else{let t=Kn(e,i,n+r,r<0?i.childCount:0,r,o);if(t)return t}n+=i.nodeSize*r}return null}function Gn(e,t,n){let i=e.steps.length-1;if(i<t)return;let r,o=e.steps[i];(o instanceof dn||o instanceof hn)&&(e.mapping.maps[i].forEach(((e,t,n,i)=>{null==r&&(r=i)})),e.setSelection(Rn.near(e.doc.resolve(r),n)))}const Yn=1,Qn=2,Zn=4;class Jn extends zn{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|Yn)&~Qn,this.storedMarks=null,this}get selectionSet(){return(this.updated&Yn)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Qn,this}ensureMarks(e){return We.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&Qn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Qn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||We.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let r=this.storedMarks;if(!r){let e=this.doc.resolve(t);r=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,r)),this.selection.empty||this.setSelection(Rn.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Zn,this}get scrolledIntoView(){return(this.updated&Zn)>0}}function Xn(e,t){return t&&e?e.bind(t):e}class ei{constructor(e,t,n){this.name=e,this.init=Xn(t.init,n),this.apply=Xn(t.apply,n)}}const ti=[new ei("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new ei("selection",{init:(e,t)=>e.selection||Rn.atStart(t.doc),apply:e=>e.selection}),new ei("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,i)=>i.selection.$cursor?e.storedMarks:null}),new ei("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class ni{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ti.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new ei(e.key,e.spec.state,e))}))}}class ii{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),i=null;for(;;){let r=!1;for(let o=0;o<this.config.plugins.length;o++){let s=this.config.plugins[o];if(s.spec.appendTransaction){let a=i?i[o].n:0,l=i?i[o].state:this,c=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,o)){if(c.setMeta("appendedTransaction",e),!i){i=[];for(let e=0;e<this.config.plugins.length;e++)i.push(e<o?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),r=!0}i&&(i[o]={state:n,n:t.length})}}if(!r)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new ii(this.config),n=this.config.fields;for(let i=0;i<n.length;i++){let r=n[i];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new Jn(this)}static create(e){let t=new ni(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new ii(t);for(let i=0;i<t.fields.length;i++)n[t.fields[i].name]=t.fields[i].init(e,n);return n}reconfigure(e){let t=new ni(this.schema,e.plugins),n=t.fields,i=new ii(t);for(let t=0;t<n.length;t++){let r=n[t].name;i[r]=this.hasOwnProperty(r)?this[r]:n[t].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((e=>e.toJSON()))),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],r=i.spec.state;r&&r.toJSON&&(t[n]=r.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new ni(e.schema,e.plugins),r=new ii(i);return i.fields.forEach((i=>{if("doc"==i.name)r.doc=ut.fromJSON(e.schema,t.doc);else if("selection"==i.name)r.selection=Rn.fromJSON(r.doc,t.selection);else if("storedMarks"==i.name)t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let o in n){let s=n[o],a=s.spec.state;if(s.key==i.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,o))return void(r[i.name]=a.fromJSON.call(s,e,t[o],r))}r[i.name]=i.init(e,r)}})),r}}function ri(e,t,n){for(let i in e){let r=e[i];r instanceof Function?r=r.bind(t):"handleDOMEvents"==i&&(r=ri(r,t,{})),n[i]=r}return n}class oi{constructor(e){this.spec=e,this.props={},e.props&&ri(e.props,this,this.props),this.key=e.key?e.key.key:ai("plugin")}getState(e){return e[this.key]}}const si=Object.create(null);function ai(e){return e in si?e+"$"+ ++si[e]:(si[e]=0,e+"$")}class li{constructor(e="key"){this.key=ai(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ci="undefined"!=typeof navigator?navigator:null,ui="undefined"!=typeof document?document:null,pi=ci&&ci.userAgent||"",di=/Edge\/(\d+)/.exec(pi),hi=/MSIE \d/.exec(pi),fi=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(pi),mi=!!(hi||fi||di),gi=hi?document.documentMode:fi?+fi[1]:di?+di[1]:0,bi=!mi&&/gecko\/(\d+)/i.test(pi);bi&&(/Firefox\/(\d+)/.exec(pi)||[0,0])[1];const vi=!mi&&/Chrome\/(\d+)/.exec(pi),yi=!!vi,xi=vi?+vi[1]:0,wi=!mi&&!!ci&&/Apple Computer/.test(ci.vendor),_i=wi&&(/Mobile\/\w+/.test(pi)||!!ci&&ci.maxTouchPoints>2),ki=_i||!!ci&&/Mac/.test(ci.platform),Ei=/Android \d/.test(pi),Ci=!!ui&&"webkitFontSmoothing"in ui.documentElement.style,Mi=Ci?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,Oi=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Di=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let Ti=null;const Si=function(e,t,n){let i=Ti||(Ti=document.createRange());return i.setEnd(e,null==n?e.nodeValue.length:n),i.setStart(e,t||0),i},Ni=function(e,t,n,i){return n&&(ji(e,t,n,i,-1)||ji(e,t,n,i,1))},Ai=/^(img|br|input|textarea|hr)$/i;function ji(e,t,n,i,r){for(;;){if(e==n&&t==i)return!0;if(t==(r<0?0:Li(e))){let n=e.parentNode;if(!n||1!=n.nodeType||zi(e)||Ai.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Oi(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if("false"==(e=e.childNodes[t+(r<0?-1:0)]).contentEditable)return!1;t=r<0?Li(e):0}}}function Li(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function zi(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Ii=function(e){let t=e.isCollapsed;return t&&yi&&e.rangeCount&&!e.getRangeAt(0).collapsed&&(t=!1),t};function Ri(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function Fi(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Bi(e,t){return"number"==typeof e?e:e[t]}function Pi(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,i=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*i}}function Ui(e,t,n){let i=e.someProp("scrollThreshold")||0,r=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let s=n||e.dom;s;s=Di(s)){if(1!=s.nodeType)continue;let e=s,n=e==o.body,a=n?Fi(o):Pi(e),l=0,c=0;if(t.top<a.top+Bi(i,"top")?c=-(a.top-t.top+Bi(r,"top")):t.bottom>a.bottom-Bi(i,"bottom")&&(c=t.bottom-a.bottom+Bi(r,"bottom")),t.left<a.left+Bi(i,"left")?l=-(a.left-t.left+Bi(r,"left")):t.right>a.right-Bi(i,"right")&&(l=t.right-a.right+Bi(r,"right")),l||c)if(n)o.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,i=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let r=e.scrollLeft-n,o=e.scrollTop-i;t={left:t.left-r,top:t.top-o,right:t.right-r,bottom:t.bottom-o}}if(n)break}}function Hi(e){let t=[],n=e.ownerDocument;for(let i=e;i&&(t.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),e!=n);i=Di(i));return t}function $i(e,t){for(let n=0;n<e.length;n++){let{dom:i,top:r,left:o}=e[n];i.scrollTop!=r+t&&(i.scrollTop=r+t),i.scrollLeft!=o&&(i.scrollLeft=o)}}let Wi=null;function qi(e,t){let n,i,r=2e8,o=0,s=t.top,a=t.top;for(let l=e.firstChild,c=0;l;l=l.nextSibling,c++){let e;if(1==l.nodeType)e=l.getClientRects();else{if(3!=l.nodeType)continue;e=Si(l).getClientRects()}for(let u=0;u<e.length;u++){let p=e[u];if(p.top<=s&&p.bottom>=a){s=Math.max(p.bottom,s),a=Math.min(p.top,a);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=l,r=e,i=e&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==l.nodeType&&e&&(o=c+(t.left>=(p.left+p.right)/2?1:0));continue}}!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(o=c+1)}}return n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,i=document.createRange();for(let r=0;r<n;r++){i.setEnd(e,r+1),i.setStart(e,r);let n=Yi(i,1);if(n.top!=n.bottom&&Vi(t,n))return{node:e,offset:r+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,i):!n||r&&1==n.nodeType?{node:e,offset:o}:qi(n,i)}function Vi(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Ki(e,t,n){let i=e.childNodes.length;if(i&&n.top<n.bottom)for(let r=Math.max(0,Math.min(i-1,Math.floor(i*(t.top-n.top)/(n.bottom-n.top))-2)),o=r;;){let n=e.childNodes[o];if(1==n.nodeType){let e=n.getClientRects();for(let i=0;i<e.length;i++){let r=e[i];if(Vi(t,r))return Ki(n,t,r)}}if((o=(o+1)%i)==r)break}return e}function Gi(e,t){let n,i=e.dom.ownerDocument,r=0;if(i.caretPositionFromPoint)try{let e=i.caretPositionFromPoint(t.left,t.top);e&&({offsetNode:n,offset:r}=e)}catch(e){}if(!n&&i.caretRangeFromPoint){let e=i.caretRangeFromPoint(t.left,t.top);e&&({startContainer:n,startOffset:r}=e)}let o,s=(e.root.elementFromPoint?e.root:i).elementFromPoint(t.left,t.top);if(!s||!e.dom.contains(1!=s.nodeType?s.parentNode:s)){let n=e.dom.getBoundingClientRect();if(!Vi(t,n))return null;if(s=Ki(e.dom,t,n),!s)return null}if(wi)for(let e=s;n&&e;e=Di(e))e.draggable&&(n=void 0);if(s=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(s,t),n){if(bi&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let e,i=n.childNodes[r];"IMG"==i.nodeName&&(e=i.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&r++}n==e.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?o=e.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(o=function(e,t,n,i){let r=-1;for(let n=t;n!=e.dom;){let t=e.docView.nearestDesc(n,!0);if(!t)return null;if(t.node.isBlock&&t.parent){let e=t.dom.getBoundingClientRect();if(e.left>i.left||e.top>i.top)r=t.posBefore;else{if(!(e.right<i.left||e.bottom<i.top))break;r=t.posAfter}}n=t.dom.parentNode}return r>-1?r:e.docView.posFromDOM(t,n,1)}(e,n,r,t))}null==o&&(o=function(e,t,n){let{node:i,offset:r}=qi(t,n),o=-1;if(1==i.nodeType&&!i.firstChild){let e=i.getBoundingClientRect();o=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(i,r,o)}(e,s,t));let a=e.docView.nearestDesc(s,!0);return{pos:o,inside:a?a.posAtStart-a.border:-1}}function Yi(e,t){let n=e.getClientRects();return n.length?n[t<0?0:n.length-1]:e.getBoundingClientRect()}const Qi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Zi(e,t,n){let{node:i,offset:r,atom:o}=e.docView.domFromPos(t,n<0?-1:1),s=Ci||bi;if(3==i.nodeType){if(!s||!Qi.test(i.nodeValue)&&(n<0?r:r!=i.nodeValue.length)){let e=r,t=r,o=n<0?1:-1;return n<0&&!r?(t++,o=-1):n>=0&&r==i.nodeValue.length?(e--,o=1):n<0?e--:t++,Ji(Yi(Si(i,e,t),1),o<0)}{let e=Yi(Si(i,r,r),n);if(bi&&r&&/\s/.test(i.nodeValue[r-1])&&r<i.nodeValue.length){let t=Yi(Si(i,r-1,r-1),-1);if(t.top==e.top){let n=Yi(Si(i,r,r+1),-1);if(n.top!=e.top)return Ji(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(null==o&&r&&(n<0||r==Li(i))){let e=i.childNodes[r-1];if(1==e.nodeType)return Xi(e.getBoundingClientRect(),!1)}if(null==o&&r<Li(i)){let e=i.childNodes[r];if(1==e.nodeType)return Xi(e.getBoundingClientRect(),!0)}return Xi(i.getBoundingClientRect(),n>=0)}if(null==o&&r&&(n<0||r==Li(i))){let e=i.childNodes[r-1],t=3==e.nodeType?Si(e,Li(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Ji(Yi(t,1),!1)}if(null==o&&r<Li(i)){let e=i.childNodes[r];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?Si(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return Ji(Yi(t,-1),!0)}return Ji(Yi(3==i.nodeType?Si(i):i,-n),n>=0)}function Ji(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Xi(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function er(e,t,n){let i=e.state,r=e.root.activeElement;i!=t&&e.updateState(t),r!=e.dom&&e.focus();try{return n()}finally{i!=t&&e.updateState(i),r!=e.dom&&r&&r.focus()}}const tr=/[\u0590-\u08ac]/;let nr=null,ir=null,rr=!1;function or(e,t,n){return nr==t&&ir==n?rr:(nr=t,ir=n,rr="up"==n||"down"==n?function(e,t,n){let i=t.selection,r="up"==n?i.$from:i.$to;return er(e,t,(()=>{let{node:t}=e.docView.domFromPos(r.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.dom;break}t=n.dom.parentNode}let i=Zi(e,r.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=Si(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let r=t[e];if(r.bottom>r.top+1&&("up"==n?i.top-r.top>2*(r.bottom-i.top):r.bottom-i.bottom>2*(i.bottom-r.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){let{$head:i}=t.selection;if(!i.parent.isTextblock)return!1;let r=i.parentOffset,o=!r,s=r==i.parent.content.size,a=e.domSelection();return tr.test(i.parent.textContent)&&a.modify?er(e,t,(()=>{let t=a.getRangeAt(0),r=a.focusNode,o=a.focusOffset,s=a.caretBidiLevel;a.modify("move",n,"character");let l=!(i.depth?e.docView.domAfterPos(i.before()):e.dom).contains(1==a.focusNode.nodeType?a.focusNode:a.focusNode.parentNode)||r==a.focusNode&&o==a.focusOffset;return a.removeAllRanges(),a.addRange(t),null!=s&&(a.caretBidiLevel=s),l})):"left"==n||"backward"==n?o:s}(e,t,n))}const sr=0,ar=1,lr=2,cr=3;class ur{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=sr,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){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,n=this.posAtStart;;t++){let i=this.children[t];if(i==e)return n;n+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,i;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(i=n.pmViewDesc)||i.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(i)+i.size:this.posAtStart}{let n,i;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(i=n.pmViewDesc)||i.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(i):this.posAtEnd}}let i;if(e==this.dom&&this.contentDOM)i=t>Oi(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){i=!1;break}if(t.previousSibling)break}if(null==i&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){i=!0;break}if(t.nextSibling)break}}return(null==i?n>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let r,o=this.getDesc(i);if(o&&(!t||o.node)){if(!n||!(r=o.nodeDOM)||(1==r.nodeType?r.contains(1==e.nodeType?e:e.parentNode):r==e))return o;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let r=this.getDesc(i);if(r)return r.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],r=n+i.size;if(n==e&&r!=n){for(;!i.border&&i.children.length;)i=i.children[0];return i}if(e<r)return i.descAt(e-n-i.border);n=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n,i=0,r=0;for(let t=0;i<this.children.length;i++){let n=this.children[i],o=t+n.size;if(o>e||n instanceof br){r=e-t;break}t=o}if(r)return this.children[i].domFromPos(r-this.children[i].border,t);for(;i&&!(n=this.children[i-1]).size&&n instanceof pr&&n.side>=0;i--);if(t<=0){let e,n=!0;for(;e=i?this.children[i-1]:null,e&&e.dom.parentNode!=this.contentDOM;i--,n=!1);return e&&t&&n&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?Oi(e.dom)+1:0}}{let e,n=!0;for(;e=i<this.children.length?this.children[i]:null,e&&e.dom.parentNode!=this.contentDOM;i++,n=!1);return e&&n&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Oi(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,r=-1;for(let o=n,s=0;;s++){let n=this.children[s],a=o+n.size;if(-1==i&&e<=a){let r=o+n.border;if(e>=r&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,r);e=o;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){i=Oi(n.dom)+1;break}e-=n.size}-1==i&&(i=0)}if(i>-1&&(a>t||s==this.children.length-1)){t=a;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){r=Oi(n.dom);break}t+=n.size}-1==r&&(r=this.contentDOM.childNodes.length);break}o=a}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:r}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let r=Math.min(e,t),o=Math.max(e,t);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],c=a+l.size;if(r>a&&o<c)return l.setSelection(e-a-l.border,t-a-l.border,n,i);a=c}let s=this.domFromPos(e,e?-1:1),a=t==e?s:this.domFromPos(t,t?-1:1),l=n.getSelection(),c=!1;if((bi||wi)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(c=!(!t||"\n"!=e.nodeValue[t-1]),c&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=a={node:t.parentNode,offset:Oi(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];c=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(bi&&l.focusNode&&l.focusNode!=a.node&&1==l.focusNode.nodeType){let e=l.focusNode.childNodes[l.focusOffset];e&&"false"==e.contentEditable&&(i=!0)}if(!(i||c&&wi)&&Ni(s.node,s.offset,l.anchorNode,l.anchorOffset)&&Ni(a.node,a.offset,l.focusNode,l.focusOffset))return;let u=!1;if((l.extend||e==t)&&!c){l.collapse(s.node,s.offset);try{if(e!=t)try{l.extend(a.node,a.offset)}catch(e){}u=!0}catch(e){if(!(e instanceof DOMException))throw e}}if(!u){if(e>t){let e=s;s=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i<this.children.length;i++){let r=this.children[i],o=n+r.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let i=n+r.border,s=o-r.border;if(e>=i&&t<=s)return this.dirty=e==n||t==o?lr:ar,void(e!=i||t!=s||!r.contentLost&&r.dom.parentNode==this.contentDOM?r.markDirty(e-i,t-i):r.dirty=cr);r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?cr:lr}n=o}this.dirty=lr}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?lr:ar;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class pr extends ur{constructor(e,t,n,i){let r,o=t.type.toDOM;if("function"==typeof o&&(o=o(n,(()=>r?r.parent?r.parent.posBeforeChild(r):void 0:i))),!t.type.spec.raw){if(1!=o.nodeType){let e=document.createElement("span");e.appendChild(o),o=e}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return this.dirty==sr&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class dr extends ur{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}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"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class hr extends ur{constructor(e,t,n,i){super(e,[],n,i),this.mark=t}static create(e,t,n,i){let r=i.nodeViews[t.type.name],o=r&&r(t,i,n);return o&&o.dom||(o=$t.renderSpec(document,t.type.spec.toDOM(t,n))),new hr(e,t,o.dom,o.contentDOM||o.dom)}parseRule(){return this.dirty&cr||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}matchesMark(e){return this.dirty!=cr&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=sr){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=sr}}slice(e,t,n){let i=hr.create(this.parent,this.mark,!0,n),r=this.children,o=this.size;t<o&&(r=Sr(r,t,o,n)),e>0&&(r=Sr(r,0,e,n));for(let e=0;e<r.length;e++)r[e].parent=i;return i.children=r,i}}class fr extends ur{constructor(e,t,n,i,r,o,s,a,l){super(e,[],r,o),this.node=t,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=s,o&&this.updateChildren(a,l)}static create(e,t,n,i,r,o){let s,a=r.nodeViews[t.type.name],l=a&&a(t,r,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:o),n,i),c=l&&l.dom,u=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else c||({dom:c,contentDOM:u}=$t.renderSpec(document,t.type.spec.toDOM(t)));u||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let p=c;return c=Cr(c,n,t),l?s=new vr(e,t,n,i,c,u||null,p,l,r,o+1):t.isText?new gr(e,t,n,i,c,p,r):new fr(e,t,n,i,c,u||null,p,r,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Pe.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return this.dirty==sr&&e.eq(this.node)&&Mr(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,r=e.composing?this.localCompositionInfo(e,t):null,o=r&&r.pos>-1?r:null,s=r&&r.pos<0,a=new Dr(this,o&&o.node,e);!function(e,t,n,i){let r=t.locals(e),o=0;if(0==r.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);i(s,r,t.forChild(o,s),n),o+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){if(s<r.length&&r[s].to==o){let e,t=r[s++];for(;s<r.length&&r[s].to==o;)(e||(e=[t])).push(r[s++]);if(e){e.sort(Tr);for(let t=0;t<e.length;t++)n(e[t],c,!!l)}else n(t,c,!!l)}let u,p;if(l)p=-1,u=l,l=null;else{if(!(c<e.childCount))break;p=c,u=e.child(c++)}for(let e=0;e<a.length;e++)a[e].to<=o&&a.splice(e--,1);for(;s<r.length&&r[s].from<=o&&r[s].to>o;)a.push(r[s++]);let d=o+u.nodeSize;if(u.isText){let e=d;s<r.length&&r[s].from<e&&(e=r[s].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<d&&(l=u.cut(e-o),u=u.cut(0,e-o),d=e,p=-1)}let h=u.isInline&&!u.isLeaf?a.filter((e=>!e.inline)):a.slice();i(u,h,t.forChild(o,u),p),o=d}}(this.node,this.innerDeco,((t,r,o)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!o&&a.syncToMarks(r==this.node.childCount?We.none:this.node.child(r).marks,n,e),a.placeWidget(t,e,i)}),((t,o,l,c)=>{let u;a.syncToMarks(t.marks,n,e),a.findNodeMatch(t,o,l,c)||s&&e.state.selection.from>i&&e.state.selection.to<i+t.nodeSize&&(u=a.findIndexWithChild(r.node))>-1&&a.updateNodeAt(t,o,l,u,e)||a.updateNextNode(t,o,l,e,c)||a.addNode(t,o,l,e,i),i+=t.nodeSize})),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==lr)&&(o&&this.protectLocalComposition(e,o),yr(this.contentDOM,this.children,e),_i&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof Un)||n<t||i>t+this.node.content.size)return null;let r=e.domSelection(),o=function(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&t>0){if(e.childNodes.length>t&&3==e.childNodes[t].nodeType)return e.childNodes[t];t=Li(e=e.childNodes[t-1])}else{if(!(1==e.nodeType&&t<e.childNodes.length))return null;e=e.childNodes[t],t=0}}}(r.focusNode,r.focusOffset);if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let e=o.nodeValue,r=function(e,t,n,i){for(let r=0,o=0;r<e.childCount&&o<=i;){let s=e.child(r++),a=o;if(o+=s.nodeSize,!s.isText)continue;let l=s.text;for(;r<e.childCount;){let t=e.child(r++);if(o+=t.nodeSize,!t.isText)break;l+=t.text}if(o>=n){let e=a<i?l.lastIndexOf(t,i-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==i&&l.length>=i+t.length-a&&l.slice(i-a,i-a+t.length)==t)return i}}return-1}(this.node.content,e,n-t,i-t);return r<0?null:{node:o,pos:r,text:e}}return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let o=new dr(this,r,t,i);e.input.compositionNodes.push(o),this.children=Sr(this.children,n,n+i.length,e,o)}update(e,t,n,i){return!(this.dirty==cr||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=sr}updateOuterDeco(e){if(Mr(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=kr(this.dom,this.nodeDOM,_r(this.outerDeco,this.node,t),_r(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function mr(e,t,n,i,r){return Cr(i,t,e),new fr(void 0,e,t,n,i,i,i,r,0)}class gr extends fr{constructor(e,t,n,i,r,o,s){super(e,t,n,i,r,null,o,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return!(this.dirty==cr||this.dirty!=sr&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),this.dirty==sr&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=sr,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let i=this.node.cut(e,t),r=document.createTextNode(i.text);return new gr(this.parent,i,this.outerDeco,this.innerDeco,r,r,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=cr)}get domAtom(){return!1}}class br extends ur{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==sr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class vr extends fr{constructor(e,t,n,i,r,o,s,a,l,c){super(e,t,n,i,r,o,s,l,c),this.spec=a}update(e,t,n,i){if(this.dirty==cr)return!1;if(this.spec.update){let r=this.spec.update(e,t,n);return r&&this.updateInner(e,t,n,i),r}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function yr(e,t,n){let i=e.firstChild,r=!1;for(let o=0;o<t.length;o++){let s=t[o],a=s.dom;if(a.parentNode==e){for(;a!=i;)i=Or(i),r=!0;i=i.nextSibling}else r=!0,e.insertBefore(a,i);if(s instanceof hr){let t=i?i.previousSibling:e.lastChild;yr(s.contentDOM,s.children,n),i=t?t.nextSibling:e.firstChild}}for(;i;)i=Or(i),r=!0;r&&n.trackWrites==e&&(n.trackWrites=null)}const xr=function(e){e&&(this.nodeName=e)};xr.prototype=Object.create(null);const wr=[new xr];function _r(e,t,n){if(0==e.length)return wr;let i=n?wr[0]:new xr,r=[i];for(let o=0;o<e.length;o++){let s=e[o].type.attrs;if(s){s.nodeName&&r.push(i=new xr(s.nodeName));for(let e in s){let o=s[e];null!=o&&(n&&1==r.length&&r.push(i=new xr(t.isInline?"span":"div")),"class"==e?i.class=(i.class?i.class+" ":"")+o:"style"==e?i.style=(i.style?i.style+";":"")+o:"nodeName"!=e&&(i[e]=o))}}}return r}function kr(e,t,n,i){if(n==wr&&i==wr)return t;let r=t;for(let t=0;t<i.length;t++){let o=i[t],s=n[t];if(t){let t;s&&s.nodeName==o.nodeName&&r!=e&&(t=r.parentNode)&&t.nodeName.toLowerCase()==o.nodeName||(t=document.createElement(o.nodeName),t.pmIsDeco=!0,t.appendChild(r),s=wr[0]),r=t}Er(r,s||wr[0],o)}return r}function Er(e,t,n){for(let i in t)"class"==i||"style"==i||"nodeName"==i||i in n||e.removeAttribute(i);for(let i in n)"class"!=i&&"style"!=i&&"nodeName"!=i&&n[i]!=t[i]&&e.setAttribute(i,n[i]);if(t.class!=n.class){let i=t.class?t.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<i.length;t++)-1==r.indexOf(i[t])&&e.classList.remove(i[t]);for(let t=0;t<r.length;t++)-1==i.indexOf(r[t])&&e.classList.add(r[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=i.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function Cr(e,t,n){return kr(e,e,wr,_r(t,n,1!=e.nodeType))}function Mr(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Or(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Dr{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,i=n.children.length,r=e.childCount,o=new Map,s=[];e:for(;r>0;){let a;for(;;)if(i){let e=n.children[i-1];if(!(e instanceof hr)){a=e,i--;break}n=e,i=e.children.length}else{if(n==t)break e;i=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(r-1))break;--r,o.set(a,r),s.push(a)}}return{index:r,matched:o,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let i=0,r=this.stack.length>>1,o=Math.min(r,e.length);for(;i<o&&(i==r-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&!1!==e[i].type.spec.spanning;)i++;for(;i<r;)this.destroyRest(),this.top.dirty=sr,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let i=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++)if(this.top.children[t].matchesMark(e[r])){i=t;break}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let i=hr.create(this.top,e[r],t,n);this.top.children.splice(this.index,0,i),this.top=i,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,n,i){let r,o=-1;if(i>=this.preMatch.index&&(r=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,n))o=this.top.children.indexOf(r,this.index);else for(let i=this.index,r=Math.min(this.top.children.length,i+5);i<r;i++){let r=this.top.children[i];if(r.matchesNode(e,t,n)&&!this.preMatch.matched.has(r)){o=i;break}}return!(o<0)&&(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,n,i,r){let o=this.top.children[i];return o.dirty==cr&&o.dom==o.contentDOM&&(o.dirty=lr),!!o.update(e,t,n,r)&&(this.destroyBetween(this.index,i),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,i,r){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof fr){let a=this.preMatch.matched.get(s);if(null!=a&&a!=r)return!1;let l=s.dom;if(!(this.lock&&(l==this.lock||1==l.nodeType&&l.contains(this.lock.parentNode))&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=cr&&Mr(t,s.outerDeco)))&&s.update(e,t,n,i))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;break}}return!1}addNode(e,t,n,i,r){this.top.children.splice(this.index++,0,fr.create(this.top,e,t,n,i,r)),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(!i||!i.matchesWidget(e)||e!=i.widget&&i.widget.type.toDOM.parentNode){let i=new pr(this.top,e,t,n);this.top.children.splice(this.index++,0,i),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof hr;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof gr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((wi||yi)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let i=new br(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}}function Tr(e,t){return e.type.side-t.type.side}function Sr(e,t,n,i,r){let o=[];for(let s=0,a=0;s<e.length;s++){let l=e[s],c=a,u=a+=l.size;c>=n||u<=t?o.push(l):(c<t&&o.push(l.slice(0,t-c,i)),r&&(o.push(r),r=void 0),u>n&&o.push(l.slice(n-c,l.size,i)))}return o}function Nr(e,t=null){let n=e.domSelection(),i=e.state.doc;if(!n.focusNode)return null;let r=e.docView.nearestDesc(n.focusNode),o=r&&0==r.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a,l,c=i.resolve(s);if(Ii(n)){for(a=c;r&&!r.node;)r=r.parent;let e=r.node;if(r&&e.isAtom&&$n.isSelectable(e)&&r.parent&&(!e.isInline||!function(e,t,n){for(let i=0==t,r=t==Li(e);i||r;){if(e==n)return!0;let t=Oi(e);if(!(e=e.parentNode))return!1;i=i&&0==t,r=r&&t==Li(e)}}(n.focusNode,n.focusOffset,r.dom))){let e=r.posBefore;l=new $n(s==e?c:i.resolve(e))}}else{let t=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(t<0)return null;a=i.resolve(t)}if(!l){l=Pr(e,a,c,"pointer"==t||e.state.selection.head<c.pos&&!o?1:-1)}return l}function Ar(e){return e.editable?e.hasFocus():Hr(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function jr(e,t=!1){let n=e.state.selection;if(Fr(e,n),Ar(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&yi){let t=e.domSelection(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Ni(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection(),n=document.createRange(),i=e.cursorWrapper.dom,r="IMG"==i.nodeName;r?n.setEnd(i.parentNode,Oi(i)+1):n.setEnd(i,0);n.collapse(!1),t.removeAllRanges(),t.addRange(n),!r&&!e.state.selection.visible&&mi&&gi<=11&&(i.disabled=!0,i.disabled=!1)}(e);else{let i,r,{anchor:o,head:s}=n;!Lr||n instanceof Un||(n.$from.parent.inlineContent||(i=zr(e,n.from)),n.empty||n.$from.parent.inlineContent||(r=zr(e,n.to))),e.docView.setSelection(o,s,e.root,t),Lr&&(i&&Rr(i),r&&Rr(r)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelection(),i=n.anchorNode,r=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==i&&n.anchorOffset==r||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{Ar(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Lr=wi||yi&&xi<63;function zr(e,t){let{node:n,offset:i}=e.docView.domFromPos(t,0),r=i<n.childNodes.length?n.childNodes[i]:null,o=i?n.childNodes[i-1]:null;if(wi&&r&&"false"==r.contentEditable)return Ir(r);if(!(r&&"false"!=r.contentEditable||o&&"false"!=o.contentEditable)){if(r)return Ir(r);if(o)return Ir(o)}}function Ir(e){return e.contentEditable="true",wi&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function Rr(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Fr(e,t){if(t instanceof $n){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Br(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Br(e)}function Br(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Pr(e,t,n,i){return e.someProp("createSelectionBetween",(i=>i(e,t,n)))||Un.between(t,n,i)}function Ur(e){return!(e.editable&&!e.hasFocus())&&Hr(e)}function Hr(e){let t=e.domSelection();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function $r(e,t){let{$anchor:n,$head:i}=e.selection,r=t>0?n.max(i):n.min(i),o=r.parent.inlineContent?r.depth?e.doc.resolve(t>0?r.after():r.before()):null:r;return o&&Rn.findFrom(o,t)}function Wr(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function qr(e,t,n){let i=e.state.selection;if(!(i instanceof Un)){if(i instanceof $n&&i.node.isInline)return Wr(e,new Un(t>0?i.$to:i.$from));{let n=$r(e.state,t);return!!n&&Wr(e,n)}}if(!i.empty||n.indexOf("s")>-1)return!1;if(e.endOfTextblock(t>0?"right":"left")){let n=$r(e.state,t);return!!(n&&n instanceof $n)&&Wr(e,n)}if(!(ki&&n.indexOf("m")>-1)){let n,r=i.$head,o=r.textOffset?null:t<0?r.nodeBefore:r.nodeAfter;if(!o||o.isText)return!1;let s=t<0?r.pos-o.nodeSize:r.pos;return!!(o.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&($n.isSelectable(o)?Wr(e,new $n(t<0?e.state.doc.resolve(r.pos-o.nodeSize):r)):!!Ci&&Wr(e,new Un(e.state.doc.resolve(t<0?s:s+o.nodeSize))))}}function Vr(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Kr(e){let t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function Gr(e){let t=e.domSelection(),n=t.focusNode,i=t.focusOffset;if(!n)return;let r,o,s=!1;for(bi&&1==n.nodeType&&i<Vr(n)&&Kr(n.childNodes[i])&&(s=!0);;)if(i>0){if(1!=n.nodeType)break;{let e=n.childNodes[i-1];if(Kr(e))r=n,o=--i;else{if(3!=e.nodeType)break;n=e,i=n.nodeValue.length}}}else{if(Qr(n))break;{let t=n.previousSibling;for(;t&&Kr(t);)r=n.parentNode,o=Oi(t),t=t.previousSibling;if(t)n=t,i=Vr(n);else{if(n=n.parentNode,n==e.dom)break;i=0}}}s?Zr(e,t,n,i):r&&Zr(e,t,r,o)}function Yr(e){let t=e.domSelection(),n=t.focusNode,i=t.focusOffset;if(!n)return;let r,o,s=Vr(n);for(;;)if(i<s){if(1!=n.nodeType)break;if(!Kr(n.childNodes[i]))break;r=n,o=++i}else{if(Qr(n))break;{let t=n.nextSibling;for(;t&&Kr(t);)r=t.parentNode,o=Oi(t)+1,t=t.nextSibling;if(t)n=t,i=0,s=Vr(n);else{if(n=n.parentNode,n==e.dom)break;i=s=0}}}r&&Zr(e,t,r,o)}function Qr(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Zr(e,t,n,i){if(Ii(t)){let e=document.createRange();e.setEnd(n,i),e.setStart(n,i),t.removeAllRanges(),t.addRange(e)}else t.extend&&t.extend(n,i);e.domObserver.setCurSelection();let{state:r}=e;setTimeout((()=>{e.state==r&&jr(e)}),50)}function Jr(e,t,n){let i=e.state.selection;if(i instanceof Un&&!i.empty||n.indexOf("s")>-1)return!1;if(ki&&n.indexOf("m")>-1)return!1;let{$from:r,$to:o}=i;if(!r.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=$r(e.state,t);if(n&&n instanceof $n)return Wr(e,n)}if(!r.parent.inlineContent){let n=t<0?r:o,s=i instanceof qn?Rn.near(n,t):Rn.findFrom(n,t);return!!s&&Wr(e,s)}return!1}function Xr(e,t){if(!(e.state.selection instanceof Un))return!0;let{$head:n,$anchor:i,empty:r}=e.state.selection;if(!n.sameParent(i))return!0;if(!r)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let o=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let i=e.state.tr;return t<0?i.delete(n.pos-o.nodeSize,n.pos):i.delete(n.pos,n.pos+o.nodeSize),e.dispatch(i),!0}return!1}function eo(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function to(e,t){let n=t.keyCode,i=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);return 8==n||ki&&72==n&&"c"==i?Xr(e,-1)||Gr(e):46==n||ki&&68==n&&"c"==i?Xr(e,1)||Yr(e):13==n||27==n||(37==n||ki&&66==n&&"c"==i?qr(e,-1,i)||Gr(e):39==n||ki&&70==n&&"c"==i?qr(e,1,i)||Yr(e):38==n||ki&&80==n&&"c"==i?Jr(e,-1,i)||Gr(e):40==n||ki&&78==n&&"c"==i?function(e){if(!wi||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelection();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;eo(e,n,"true"),setTimeout((()=>eo(e,n,"false")),20)}return!1}(e)||Jr(e,1,i)||Yr(e):i==(ki?"m":"c")&&(66==n||73==n||89==n||90==n))}function no(e,t){e.someProp("transformCopied",(e=>{t=e(t)}));let n=[],{content:i,openStart:r,openEnd:o}=t;for(;r>1&&o>1&&1==i.childCount&&1==i.firstChild.childCount;){r--,o--;let e=i.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),i=e.content}let s=e.someProp("clipboardSerializer")||$t.fromSchema(e.state.schema),a=ho(),l=a.createElement("div");l.appendChild(s.serializeFragment(i,{document:a}));let c,u=l.firstChild,p=0;for(;u&&1==u.nodeType&&(c=uo[u.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=a.createElement(c[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),p++}u=l.firstChild}u&&1==u.nodeType&&u.setAttribute("data-pm-slice",`${r} ${o}${p?` -${p}`:""} ${JSON.stringify(n)}`);let d=e.someProp("clipboardTextSerializer",(e=>e(t)))||t.content.textBetween(0,t.content.size,"\n\n");return{dom:l,text:d}}function io(e,t,n,i,r){let o,s,a=r.parent.type.spec.code;if(!n&&!t)return null;let l=t&&(i||a||!n);if(l){if(e.someProp("transformPastedText",(e=>{t=e(t,a||i)})),a)return t?new Ve(Pe.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):Ve.empty;let n=e.someProp("clipboardTextParser",(e=>e(t,r,i)));if(n)s=n;else{let n=r.marks(),{schema:i}=e.state,s=$t.fromSchema(i);o=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=o.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(i.text(e,n)))}))}}else e.someProp("transformPastedHTML",(e=>{n=e(n)})),o=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,i=ho().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e);(n=r&&uo[r[1].toLowerCase()])&&(e=n.map((e=>"<"+e+">")).join("")+e+n.map((e=>"</"+e+">")).reverse().join(""));if(i.innerHTML=e,n)for(let e=0;e<n.length;e++)i=i.querySelector(n[e])||i;return i}(n),Ci&&function(e){let t=e.querySelectorAll(yi?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let i=t[n];1==i.childNodes.length&&" "==i.textContent&&i.parentNode&&i.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),i)}}(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let e=+u[3];e>0&&o.firstChild;e--)o=o.firstChild;if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||St.fromSchema(e.state.schema);s=t.parseSlice(o,{preserveWhitespace:!(!l&&!u),context:r,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||ro.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(u)s=function(e,t){if(!e.size)return e;let n,i=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:r,openStart:o,openEnd:s}=e;for(let e=n.length-2;e>=0;e-=2){let t=i.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;r=Pe.from(t.create(n[e+1],r)),o++,s++}return new Ve(r,o,s)}(co(s,+u[1],+u[2]),u[4]);else if(s=Ve.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let i,r=t.node(n).contentMatchAt(t.index(n)),o=[];if(e.forEach((e=>{if(!o)return;let t,n=r.findWrapping(e.type);if(!n)return o=null;if(t=o.length&&i.length&&so(n,i,e,o[o.length-1],0))o[o.length-1]=t;else{o.length&&(o[o.length-1]=ao(o[o.length-1],i.length));let t=oo(e,n);o.push(t),r=r.matchType(t.type),i=n}})),o)return Pe.from(o)}return e}(s.content,r),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=co(s,e,t)}return e.someProp("transformPasted",(e=>{s=e(s)})),s}const ro=/^(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 oo(e,t,n=0){for(let i=t.length-1;i>=n;i--)e=t[i].create(null,Pe.from(e));return e}function so(e,t,n,i,r){if(r<e.length&&r<t.length&&e[r]==t[r]){let o=so(e,t,n,i.lastChild,r+1);if(o)return i.copy(i.content.replaceChild(i.childCount-1,o));if(i.contentMatchAt(i.childCount).matchType(r==e.length-1?n.type:e[r+1]))return i.copy(i.content.append(Pe.from(oo(n,e,r+1))))}}function ao(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,ao(e.lastChild,t-1)),i=e.contentMatchAt(e.childCount).fillBefore(Pe.empty,!0);return e.copy(n.append(i))}function lo(e,t,n,i,r,o){let s=t<0?e.firstChild:e.lastChild,a=s.content;return r<i-1&&(a=lo(a,t,n,i,r+1,o)),r>=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,e.childCount>1||o<=r).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(Pe.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function co(e,t,n){return t<e.openStart&&(e=new Ve(lo(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Ve(lo(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const uo={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 po=null;function ho(){return po||(po=document.implementation.createHTMLDocument("title"))}const fo={},mo={},go={touchstart:!0,touchmove:!0};class bo{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function vo(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function yo(e){e.someProp("handleDOMEvents",(t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>xo(e,t))}))}function xo(e,t){return e.someProp("handleDOMEvents",(n=>{let i=n[t.type];return!!i&&(i(e,t)||t.defaultPrevented)}))}function wo(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function _o(e){return{left:e.clientX,top:e.clientY}}function ko(e,t,n,i,r){if(-1==i)return!1;let o=e.state.doc.resolve(i);for(let i=o.depth+1;i>0;i--)if(e.someProp(t,(t=>i>o.depth?t(e,n,o.nodeAfter,o.before(i),r,!0):t(e,n,o.node(i),o.before(i),r,!1))))return!0;return!1}function Eo(e,t,n){e.focused||e.focus();let i=e.state.tr.setSelection(t);"pointer"==n&&i.setMeta("pointer",!0),e.dispatch(i)}function Co(e,t,n,i,r){return ko(e,"handleClickOn",t,n,i)||e.someProp("handleClick",(n=>n(e,t,i)))||(r?function(e,t){if(-1==t)return!1;let n,i,r=e.state.selection;r instanceof $n&&(n=r.node);let o=e.state.doc.resolve(t);for(let e=o.depth+1;e>0;e--){let t=e>o.depth?o.nodeAfter:o.node(e);if($n.isSelectable(t)){i=n&&r.$from.depth>0&&e>=r.$from.depth&&o.before(r.$from.depth+1)==r.$from.pos?o.before(r.$from.depth):o.before(e);break}}return null!=i&&(Eo(e,$n.create(e.state.doc,i),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),i=n.nodeAfter;return!!(i&&i.isAtom&&$n.isSelectable(i))&&(Eo(e,new $n(n),"pointer"),!0)}(e,n))}function Mo(e,t,n,i){return ko(e,"handleDoubleClickOn",t,n,i)||e.someProp("handleDoubleClick",(n=>n(e,t,i)))}function Oo(e,t,n,i){return ko(e,"handleTripleClickOn",t,n,i)||e.someProp("handleTripleClick",(n=>n(e,t,i)))||function(e,t,n){if(0!=n.button)return!1;let i=e.state.doc;if(-1==t)return!!i.inlineContent&&(Eo(e,Un.create(i,0,i.content.size),"pointer"),!0);let r=i.resolve(t);for(let t=r.depth+1;t>0;t--){let n=t>r.depth?r.nodeAfter:r.node(t),o=r.before(t);if(n.inlineContent)Eo(e,Un.create(i,o+1,o+1+n.content.size),"pointer");else{if(!$n.isSelectable(n))continue;Eo(e,$n.create(i,o),"pointer")}return!0}}(e,n,i)}function Do(e){return zo(e)}mo.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!No(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!Ei||!yi||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!_i||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",(t=>t(e,n)))||to(e,n)?n.preventDefault():vo(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,Ri(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},mo.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},mo.keypress=(e,t)=>{let n=t;if(No(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||ki&&n.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,n))))return void n.preventDefault();let i=e.state.selection;if(!(i instanceof Un&&i.$from.sameParent(i.$to))){let t=String.fromCharCode(n.charCode);e.someProp("handleTextInput",(n=>n(e,i.$from.pos,i.$to.pos,t)))||e.dispatch(e.state.tr.insertText(t).scrollIntoView()),n.preventDefault()}};const To=ki?"metaKey":"ctrlKey";fo.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let i=Do(e),r=Date.now(),o="singleClick";r-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,i=t.y-e.clientY;return n*n+i*i<100}(n,e.input.lastClick)&&!n[To]&&("singleClick"==e.input.lastClick.type?o="doubleClick":"doubleClick"==e.input.lastClick.type&&(o="tripleClick")),e.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:o};let s=e.posAtCoords(_o(n));s&&("singleClick"==o?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new So(e,s,n,!!i)):("doubleClick"==o?Mo:Oo)(e,s.pos,s.inside,n)?n.preventDefault():vo(e,"pointer"))};class So{constructor(e,t,n,i){let r,o;if(this.view=e,this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[To],this.allowDefault=n.shiftKey,t.inside>-1)r=e.state.doc.nodeAt(t.inside),o=t.inside;else{let n=e.state.doc.resolve(t.pos);r=n.parent,o=n.depth?n.before():0}const s=i?null:n.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a?a.dom:null;let{selection:l}=e.state;(0==n.button&&r.type.spec.draggable&&!1!==r.type.spec.selectable||l instanceof $n&&l.from<=o&&l.to>o)&&(this.mightDrag={node:r,pos:o,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!bi||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)),vo(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((()=>jr(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(_o(e))),this.updateAllowDefault(e),this.allowDefault||!t?vo(this.view,"pointer"):Co(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||wi&&this.mightDrag&&!this.mightDrag.node.isAtom||yi&&!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)?(Eo(this.view,Rn.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):vo(this.view,"pointer")}move(e){this.updateAllowDefault(e),vo(this.view,"pointer"),0==e.buttons&&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)}}function No(e,t){return!!e.composing||!!(wi&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}fo.touchstart=e=>{e.input.lastTouch=Date.now(),Do(e),vo(e,"pointer")},fo.touchmove=e=>{e.input.lastTouch=Date.now(),vo(e,"pointer")},fo.contextmenu=e=>Do(e);const Ao=Ei?5e3:-1;function jo(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>zo(e)),t))}function Lo(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function zo(e,t=!1){if(!(Ei&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Lo(e),t||e.docView&&e.docView.dirty){let t=Nr(e);return t&&!t.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(t)):e.updateState(e.state),!0}return!1}}mo.compositionstart=mo.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))))e.markCursor=e.state.storedMarks||n.marks(),zo(e,!0),e.markCursor=null;else if(zo(e),bi&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelection();for(let e=t.focusNode,n=t.focusOffset;e&&1==e.nodeType&&0!=n;){let i=n<0?e.lastChild:e.childNodes[n-1];if(!i)break;if(3==i.nodeType){t.collapse(i,i.nodeValue.length);break}e=i,n=-1}}e.input.composing=!0}jo(e,Ao)},mo.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,jo(e,20))};const Io=mi&&gi<15||_i&&Mi<604;function Ro(e,t,n,i){let r=io(e,t,n,e.input.shiftKey,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,i,r||Ve.empty))))return!0;if(!r)return!1;let o=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(r),s=o?e.state.tr.replaceSelectionWith(o,e.input.shiftKey):e.state.tr.replaceSelection(r);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}fo.copy=mo.cut=(e,t)=>{let n=t,i=e.state.selection,r="cut"==n.type;if(i.empty)return;let o=Io?null:n.clipboardData,s=i.content(),{dom:a,text:l}=no(e,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),r=document.createRange();r.selectNodeContents(t),e.dom.blur(),i.removeAllRanges(),i.addRange(r),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}(e,a),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},mo.paste=(e,t)=>{let n=t;if(e.composing&&!Ei)return;let i=Io?null:n.clipboardData;i&&Ro(e,i.getData("text/plain"),i.getData("text/html"),n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,i=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{e.focus(),i.parentNode&&i.parentNode.removeChild(i),n?Ro(e,i.value,null,t):Ro(e,i.textContent,i.innerHTML,t)}),50)}(e,n)};class Fo{constructor(e,t){this.slice=e,this.move=t}}const Bo=ki?"altKey":"ctrlKey";fo.dragstart=(e,t)=>{let n=t,i=e.input.mouseDown;if(i&&i.done(),!n.dataTransfer)return;let r=e.state.selection,o=r.empty?null:e.posAtCoords(_o(n));if(o&&o.pos>=r.from&&o.pos<=(r instanceof $n?r.to-1:r.to));else if(i&&i.mightDrag)e.dispatch(e.state.tr.setSelection($n.create(e.state.doc,i.mightDrag.pos)));else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&e.dispatch(e.state.tr.setSelection($n.create(e.state.doc,t.posBefore)))}let s=e.state.selection.content(),{dom:a,text:l}=no(e,s);n.dataTransfer.clearData(),n.dataTransfer.setData(Io?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Io||n.dataTransfer.setData("text/plain",l),e.dragging=new Fo(s,!n[Bo])},fo.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},mo.dragover=mo.dragenter=(e,t)=>t.preventDefault(),mo.drop=(e,t)=>{let n=t,i=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let r=e.posAtCoords(_o(n));if(!r)return;let o=e.state.doc.resolve(r.pos),s=i&&i.slice;s?e.someProp("transformPasted",(e=>{s=e(s)})):s=io(e,n.dataTransfer.getData(Io?"Text":"text/plain"),Io?null:n.dataTransfer.getData("text/html"),!1,o);let a=!(!i||n[Bo]);if(e.someProp("handleDrop",(t=>t(e,n,s||Ve.empty,a))))return void n.preventDefault();if(!s)return;n.preventDefault();let l=s?wn(e.state.doc,o.pos,s):o.pos;null==l&&(l=o.pos);let c=e.state.tr;a&&c.deleteSelection();let u=c.mapping.map(l),p=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,d=c.doc;if(p?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(d))return;let h=c.doc.resolve(u);if(p&&$n.isSelectable(s.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new $n(h));else{let t=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach(((e,n,i,r)=>t=r)),c.setSelection(Pr(e,h,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},fo.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelection())&&jr(e)}),20))},fo.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},fo.beforeinput=(e,t)=>{if(yi&&Ei&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,Ri(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let e in mo)fo[e]=mo[e];function Po(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class Uo{constructor(e,t){this.toDOM=e,this.spec=t||Vo,this.side=this.spec.side||0}map(e,t,n,i){let{pos:r,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new Wo(r-n,r-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Uo&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Po(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ho{constructor(e,t){this.attrs=e,this.spec=t||Vo}map(e,t,n,i){let r=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return r>=o?null:new Wo(r,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ho&&Po(this.attrs,e.attrs)&&Po(this.spec,e.spec)}static is(e){return e.type instanceof Ho}destroy(){}}class $o{constructor(e,t){this.attrs=e,this.spec=t||Vo}map(e,t,n,i){let r=e.mapResult(t.from+i,1);if(r.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=r.pos?null:new Wo(r.pos-n,o.pos-n,this)}valid(e,t){let n,{index:i,offset:r}=e.content.findIndex(t.from);return r==t.from&&!(n=e.child(i)).isText&&r+n.nodeSize==t.to}eq(e){return this==e||e instanceof $o&&Po(this.attrs,e.attrs)&&Po(this.spec,e.spec)}destroy(){}}class Wo{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Wo(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Wo(e,e,new Uo(t,n))}static inline(e,t,n,i){return new Wo(e,t,new Ho(n,i))}static node(e,t,n,i){return new Wo(e,t,new $o(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ho}}const qo=[],Vo={};class Ko{constructor(e,t){this.local=e.length?e:qo,this.children=t.length?t:qo}static create(e,t){return t.length?Xo(t,e,0,Vo):Go}find(e,t,n){let i=[];return this.findInner(null==e?0:e,null==t?1e9:t,i,0,n),i}findInner(e,t,n,i,r){for(let o=0;o<this.local.length;o++){let s=this.local[o];s.from<=t&&s.to>=e&&(!r||r(s.spec))&&n.push(s.copy(s.from+i,s.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let s=this.children[o]+1;this.children[o+2].findInner(e-s,t-s,n,i+s,r)}}map(e,t,n){return this==Go||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Vo)}mapInner(e,t,n,i,r){let o;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(e,n,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):r.onRemove&&r.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,i,r,o,s){let a=e.slice();for(let e=0,t=o;e<n.maps.length;e++){let i=0;n.maps[e].forEach(((e,n,o,s)=>{let l=s-o-(n-e);for(let s=0;s<a.length;s+=3){let c=a[s+1];if(c<0||e>c+t-i)continue;let u=a[s]+t-i;n>=u?a[s+1]=e<=u?-2:-1:o>=r&&l&&(a[s]+=l,a[s+1]+=l)}i+=l})),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let c=n.map(e[t]+o),u=c-r;if(u<0||u>=i.content.size){l=!0;continue}let p=n.map(e[t+1]+o,-1)-r,{index:d,offset:h}=i.content.findIndex(u),f=i.maybeChild(d);if(f&&h==u&&h+f.nodeSize==p){let i=a[t+2].mapInner(n,f,c+1,e[t]+o+1,s);i!=Go?(a[t]=u,a[t+1]=p,a[t+2]=i):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,n,i,r,o,s){function a(e,t){for(let o=0;o<e.local.length;o++){let a=e.local[o].map(i,r,t);a?n.push(a):s.onRemove&&s.onRemove(e.local[o].spec)}for(let n=0;n<e.children.length;n+=3)a(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&a(e[n+2],t[n]+o+1);return n}(a,e,t,n,r,o,s),c=Xo(l,i,0,s);t=c.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new Ko(t.sort(es),a)}(this.children,o||[],e,t,n,i,r):o?new Ko(o.sort(es),qo):Go}add(e,t){return t.length?this==Go?Ko.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,r=0;e.forEach(((e,o)=>{let s,a=o+n;if(s=Zo(t,e,a)){for(i||(i=this.children.slice());r<i.length&&i[r]<o;)r+=3;i[r]==o?i[r+2]=i[r+2].addInner(e,s,a+1):i.splice(r,0,o,o+e.nodeSize,Xo(s,e,a+1,Vo)),r+=3}}));let o=Qo(r?Jo(t):t,-n);for(let t=0;t<o.length;t++)o[t].type.valid(e,o[t])||o.splice(t--,1);return new Ko(o.length?this.local.concat(o).sort(es):this.local,i||this.children)}remove(e){return 0==e.length||this==Go?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let i=0;i<n.length;i+=3){let r,o=n[i]+t,s=n[i+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>o&&t.to<s&&(e[n]=null,(r||(r=[])).push(t));if(!r)continue;n==this.children&&(n=this.children.slice());let a=n[i+2].removeInner(r,o+1);a!=Go?n[i+2]=a:(n.splice(i,3),i-=3)}if(i.length)for(let n,r=0;r<e.length;r++)if(n=e[r])for(let e=0;e<i.length;e++)i[e].eq(n,t)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1));return n==this.children&&i==this.local?this:i.length||n.length?new Ko(i,n):Go}forChild(e,t){if(this==Go)return this;if(t.isLeaf)return Ko.empty;let n,i;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let r=e+1,o=r+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>r&&t.type instanceof Ho){let e=Math.max(r,t.from)-r,n=Math.min(o,t.to)-r;e<n&&(i||(i=[])).push(t.copy(e,n))}}if(i){let e=new Ko(i.sort(es),qo);return n?new Yo([e,n]):e}return n||Go}eq(e){if(this==e)return!0;if(!(e instanceof Ko)||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 ts(this.localsInner(e))}localsInner(e){if(this==Go)return qo;if(e.inlineContent||!this.local.some(Ho.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof Ho||t.push(this.local[e]);return t}}Ko.empty=new Ko([],[]),Ko.removeOverlap=ts;const Go=Ko.empty;class Yo{constructor(e){this.members=e}map(e,t){const n=this.members.map((n=>n.map(e,t,Vo)));return Yo.from(n)}forChild(e,t){if(t.isLeaf)return Ko.empty;let n=[];for(let i=0;i<this.members.length;i++){let r=this.members[i].forChild(e,t);r!=Go&&(r instanceof Yo?n=n.concat(r.members):n.push(r))}return Yo.from(n)}eq(e){if(!(e instanceof Yo)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let i=0;i<this.members.length;i++){let r=this.members[i].localsInner(e);if(r.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<r.length;e++)t.push(r[e])}else t=r}return t?ts(n?t:t.sort(es)):qo}static from(e){switch(e.length){case 0:return Go;case 1:return e[0];default:return new Yo(e)}}}function Qo(e,t){if(!t||!e.length)return e;let n=[];for(let i=0;i<e.length;i++){let r=e[i];n.push(new Wo(r.from+t,r.to+t,r.type))}return n}function Zo(e,t,n){if(t.isLeaf)return null;let i=n+t.nodeSize,r=null;for(let t,o=0;o<e.length;o++)(t=e[o])&&t.from>n&&t.to<i&&((r||(r=[])).push(t),e[o]=null);return r}function Jo(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Xo(e,t,n,i){let r=[],o=!1;t.forEach(((t,s)=>{let a=Zo(e,t,s+n);if(a){o=!0;let e=Xo(a,t,n+s+1,i);e!=Go&&r.push(s,s+t.nodeSize,e)}}));let s=Qo(o?Jo(e):e,-n).sort(es);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(i.onRemove&&i.onRemove(s[e].spec),s.splice(e--,1));return s.length||r.length?new Ko(s,r):Go}function es(e,t){return e.from-t.from||e.to-t.to}function ts(e){let t=e;for(let n=0;n<t.length-1;n++){let i=t[n];if(i.from!=i.to)for(let r=n+1;r<t.length;r++){let o=t[r];if(o.from!=i.from){o.from<i.to&&(t==e&&(t=e.slice()),t[n]=i.copy(i.from,o.from),ns(t,r,i.copy(o.from,i.to)));break}o.to!=i.to&&(t==e&&(t=e.slice()),t[r]=o.copy(o.from,i.to),ns(t,r+1,o.copy(i.to,o.to)))}}return t}function ns(e,t,n){for(;t<e.length&&es(n,e[t])>0;)t++;e.splice(t,0,n)}function is(e){let t=[];return e.someProp("decorations",(n=>{let i=n(e.state);i&&i!=Go&&t.push(i)})),e.cursorWrapper&&t.push(Ko.create(e.state.doc,[e.cursorWrapper.deco])),Yo.from(t)}const rs={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ss=mi&&gi<=11;class as{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 ls{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new as,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver((e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);mi&&gi<=11&&e.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),ss&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,rs)),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(Ur(this.view)){if(this.suppressingSelectionUpdates)return jr(this.view);if(mi&&gi<=11&&!this.view.state.selection.empty){let e=this.view.domSelection();if(e.focusNode&&Ni(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelection())}ignoreSelectionChange(e){if(0==e.rangeCount)return!0;let t=e.getRangeAt(0).commonAncestorContainer,n=this.view.docView.nearestDesc(t);return n&&n.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);let n=e.domSelection(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Ur(e)&&!this.ignoreSelectionChange(n),r=-1,o=-1,s=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],a);n&&(r=r<0?n.from:Math.min(n.from,r),o=o<0?n.to:Math.max(n.to,o),n.typeOver&&(s=!0))}if(bi&&a.length>1){let e=a.filter((e=>"BR"==e.nodeName));if(2==e.length){let t=e[0],n=e[1];t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}}let l=null;r<0&&i&&e.input.lastFocus>Date.now()-200&&e.input.lastTouch<Date.now()-300&&Ii(n)&&(l=Nr(e))&&l.eq(Rn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,jr(e),this.currentSelection.set(n),e.scrollToSelection()):(r>-1||i)&&(r>-1&&(e.docView.markDirty(r,o),function(e){if(cs.has(e))return;if(cs.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=bi,us)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."),us=!0}}(e)),this.handleDOMChange(r,o,s,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||jr(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++)t.push(e.addedNodes[n]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,r=e.nextSibling;if(mi&&gi<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:o}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(i=n),(!o||Array.prototype.indexOf.call(e.addedNodes,o)<0)&&(r=o)}let o=i&&i.parentNode==e.target?Oi(i)+1:0,s=n.localPosFromDOM(e.target,o,-1),a=r&&r.parentNode==e.target?Oi(r):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}let cs=new WeakMap,us=!1;function ps(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(wi&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||wi&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}function ds(e,t,n,i,r){if(t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=Nr(e,t);if(n&&!e.state.selection.eq(n)){let i=e.state.tr.setSelection(n);"pointer"==t?i.setMeta("pointer",!0):"key"==t&&i.scrollIntoView(),e.dispatch(i)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let a,l,c=e.state.selection,u=function(e,t,n){let i,{node:r,fromOffset:o,toOffset:s,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelection(),u=c.anchorNode;if(u&&e.dom.contains(1==u.nodeType?u:u.parentNode)&&(i=[{node:u,offset:c.anchorOffset}],Ii(c)||i.push({node:c.focusNode,offset:c.focusOffset})),yi&&8===e.input.lastKeyCode)for(let e=s;e>o;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let p=e.state.doc,d=e.someProp("domParser")||St.fromSchema(e.state.schema),h=p.resolve(a),f=null,m=d.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:o,to:s,preserveWhitespace:"pre"!=h.parent.type.whitespace||"full",findPositions:i,ruleFromNode:ps,context:h});if(i&&null!=i[0].pos){let e=i[0].pos,t=i[1]&&i[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n),p=e.state.doc,d=p.slice(u.from,u.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(a=e.state.selection.to,l="end"):(a=e.state.selection.from,l="start"),e.input.lastKeyCode=null;let h=function(e,t,n,i,r){let o=e.findDiffStart(t,n);if(null==o)return null;let{a:s,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==r){i-=s+Math.max(0,o-Math.min(s,a))-o}if(s<o&&e.size<t.size){o-=i<=o&&i>=s?o-i:0,a=o+(a-s),s=o}else if(a<o){o-=i<=o&&i>=a?o-i:0,s=o+(s-a),a=o}return{start:o,endA:s,endB:a}}(d.content,u.doc.content,u.from,a,l);if((_i&&e.input.lastIOSEnter>Date.now()-225||Ei)&&r.some((e=>"DIV"==e.nodeName||"P"==e.nodeName))&&(!h||h.endA>=h.endB)&&e.someProp("handleKeyDown",(t=>t(e,Ri(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!h){if(!(i&&c instanceof Un&&!c.empty&&c.$head.sameParent(c.$anchor))||e.composing||u.sel&&u.sel.anchor!=u.sel.head){if(u.sel){let t=hs(e,e.state.doc,u.sel);t&&!t.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(t))}return}h={start:c.from,endA:c.to,endB:c.to}}if(yi&&e.cursorWrapper&&u.sel&&u.sel.anchor==e.cursorWrapper.deco.from&&u.sel.head==u.sel.anchor){let e=h.endB-h.start;u.sel={anchor:u.sel.anchor+e,head:u.sel.anchor+e}}e.input.domChangeCount++,e.state.selection.from<e.state.selection.to&&h.start==h.endB&&e.state.selection instanceof Un&&(h.start>e.state.selection.from&&h.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?h.start=e.state.selection.from:h.endA<e.state.selection.to&&h.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(h.endB+=e.state.selection.to-h.endA,h.endA=e.state.selection.to)),mi&&gi<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>u.from&&" "==u.doc.textBetween(h.start-u.from-1,h.start-u.from+1)&&(h.start--,h.endA--,h.endB--);let f,m=u.doc.resolveNoCache(h.start-u.from),g=u.doc.resolveNoCache(h.endB-u.from),b=p.resolve(h.start),v=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=h.endA;if((_i&&e.input.lastIOSEnter>Date.now()-225&&(!v||r.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!v&&m.pos<u.doc.content.size&&(f=Rn.findFrom(u.doc.resolve(m.pos+1),1,!0))&&f.head==g.pos)&&e.someProp("handleKeyDown",(t=>t(e,Ri(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>h.start&&function(e,t,n,i,r){if(!i.parent.isTextblock||n-t<=r.pos-i.pos||fs(i,!0,!1)<r.pos)return!1;let o=e.resolve(t);if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=e.resolve(fs(o,!0,!0));return!(!s.parent.isTextblock||s.pos>n||fs(s,!0,!1)<n)&&i.parent.content.cut(i.parentOffset).eq(s.parent.content)}(p,h.start,h.endA,m,g)&&e.someProp("handleKeyDown",(t=>t(e,Ri(8,"Backspace")))))return void(Ei&&yi&&e.domObserver.suppressSelectionUpdates());yi&&Ei&&h.endB==h.start&&(e.input.lastAndroidDelete=Date.now()),Ei&&!v&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==h.endA&&(h.endB-=2,g=u.doc.resolveNoCache(h.endB-u.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,Ri(13,"Enter"))}))}),20));let y,x,w,_=h.start,k=h.endA;if(v)if(m.pos==g.pos)mi&&gi<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>jr(e)),20)),y=e.state.tr.delete(_,k),x=p.resolve(h.start).marksAcross(p.resolve(h.endA));else if(h.endA==h.endB&&(w=function(e,t){let n,i,r,o=e.firstChild.marks,s=t.firstChild.marks,a=o,l=s;for(let e=0;e<s.length;e++)a=s[e].removeFromSet(a);for(let e=0;e<o.length;e++)l=o[e].removeFromSet(l);if(1==a.length&&0==l.length)i=a[0],n="add",r=e=>e.mark(i.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;i=l[0],n="remove",r=e=>e.mark(i.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(r(t.child(e)));if(Pe.from(c).eq(e))return{mark:i,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,h.endA-b.start()))))y=e.state.tr,"add"==w.type?y.addMark(_,k,w.mark):y.removeMark(_,k,w.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let t=m.parent.textBetween(m.parentOffset,g.parentOffset);if(e.someProp("handleTextInput",(n=>n(e,_,k,t))))return;y=e.state.tr.insertText(t,_,k)}if(y||(y=e.state.tr.replace(_,k,u.doc.slice(h.start-u.from,h.endB-u.from))),u.sel){let t=hs(e,y.doc,u.sel);t&&!(yi&&Ei&&e.composing&&t.empty&&(h.start!=h.endB||e.input.lastAndroidDelete<Date.now()-100)&&(t.head==_||t.head==y.mapping.map(k)-1)||mi&&t.empty&&t.head==_)&&y.setSelection(t)}x&&y.ensureMarks(x),e.dispatch(y.scrollIntoView())}function hs(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Pr(e,t.resolve(n.anchor),t.resolve(n.head))}function fs(e,t,n){let i=e.depth,r=t?e.end():e.pos;for(;i>0&&(t||e.indexAfter(i)==e.node(i).childCount);)i--,r++,t=!1;if(n){let t=e.node(i).maybeChild(e.indexAfter(i));for(;t&&!t.isLeaf;)t=t.firstChild,r++}return r}class ms{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 bo,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(xs),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=vs(this),bs(this),this.nodeViews=ys(this),this.docView=mr(this.state.doc,gs(this),is(this),this.dom,this),this.domObserver=new ls(this,((e,t,n,i)=>ds(this,e,t,n,i))),this.domObserver.start(),function(e){for(let t in fo){let n=fo[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!wo(e,t)||xo(e,t)||!e.editable&&t.type in mo||n(e,t)},go[t]?{passive:!0}:void 0)}wi&&e.dom.addEventListener("input",(()=>null)),yo(e)}(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&&yo(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(xs),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,i=!1,r=!1;e.storedMarks&&this.composing&&(Lo(this),r=!0),this.state=e;let o=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(o||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=ys(this);(function(e,t){let n=0,i=0;for(let i in e){if(e[i]!=t[i])return!0;n++}for(let e in t)i++;return n!=i})(e,this.nodeViews)&&(this.nodeViews=e,i=!0)}(o||t.handleDOMEvents!=this._props.handleDOMEvents)&&yo(this),this.editable=vs(this),bs(this);let s=is(this),a=gs(this),l=n.plugins==e.plugins||n.doc.eq(e.doc)?e.scrollToSelection>n.scrollToSelection?"to selection":"preserve":"reset",c=i||!this.docView.matchesNode(e.doc,a,s);!c&&e.selection.eq(n.selection)||(r=!0);let u="preserve"==l&&r&&null==this.dom.style.overflowAnchor&&function(e){let t,n,i=e.dom.getBoundingClientRect(),r=Math.max(0,i.top);for(let o=(i.left+i.right)/2,s=r+1;s<Math.min(innerHeight,i.bottom);s+=5){let i=e.root.elementFromPoint(o,s);if(!i||i==e.dom||!e.dom.contains(i))continue;let a=i.getBoundingClientRect();if(a.top>=r-20){t=i,n=a.top;break}}return{refDOM:t,refTop:n,stack:Hi(e.dom)}}(this);if(r){this.domObserver.stop();let t=c&&(mi||yi)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(n.selection,e.selection);if(c){let n=yi?this.trackWrites=this.domSelection().focusNode:null;!i&&this.docView.update(e.doc,a,s,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=mr(e.doc,a,s,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelection())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelection();return Ni(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?jr(this,t):(Fr(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),"reset"==l?this.dom.scrollTop=0:"to selection"==l?this.scrollToSelection():u&&function({refDOM:e,refTop:t,stack:n}){let i=e?e.getBoundingClientRect().top:0;$i(n,0==i?0:i-t)}(u)}scrollToSelection(){let e=this.domSelection().focusNode;if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(this.state.selection instanceof $n){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&Ui(this,t.getBoundingClientRect(),e)}else Ui(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)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}someProp(e,t){let n,i=this._props&&this._props[e];if(null!=i&&(n=t?t(i):i))return n;for(let i=0;i<this.directPlugins.length;i++){let r=this.directPlugins[i].props[e];if(null!=r&&(n=t?t(r):r))return n}let r=this.state.plugins;if(r)for(let i=0;i<r.length;i++){let o=r[i].props[e];if(null!=o&&(n=t?t(o):o))return n}}hasFocus(){if(mi){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("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Wi)return e.focus(Wi);let t=Hi(e);e.focus(null==Wi?{get preventScroll(){return Wi={preventScroll:!0},!0}}:void 0),Wi||(Wi=!1,$i(t,0))}(this.dom),jr(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}posAtCoords(e){return Gi(this,e)}coordsAtPos(e,t=1){return Zi(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(null==i)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return or(this,t||this.state,e)}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],is(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){xo(e,t)||!fo[t.type]||!e.editable&&t.type in mo||fo[t.type](e,t)}(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelection(){return this.root.getSelection()}}function gs(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),t.translate="no",e.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e&&(t.class+=" "+n[e]),"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))})),[Wo.node(0,e.state.doc.content.size,t)]}function bs(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Wo.widget(e.state.selection.head,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function vs(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function ys(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function xs(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var ws={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:"'"},_s={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ks="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent);"undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent);for(var Es="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Cs="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ms=Es||ks&&+ks[1]<57,Os=0;Os<10;Os++)ws[48+Os]=ws[96+Os]=String(Os);for(Os=1;Os<=24;Os++)ws[Os+111]="F"+Os;for(Os=65;Os<=90;Os++)ws[Os]=String.fromCharCode(Os+32),_s[Os]=String.fromCharCode(Os);for(var Ds in ws)_s.hasOwnProperty(Ds)||(_s[Ds]=ws[Ds]);const Ts="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function Ss(e){let t,n,i,r,o=e.split(/-(?!$)/),s=o[o.length-1];"Space"==s&&(s=" ");for(let e=0;e<o.length-1;e++){let s=o[e];if(/^(cmd|meta|m)$/i.test(s))r=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))i=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);Ts?r=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),r&&(s="Meta-"+s),i&&(s="Shift-"+s),s}function Ns(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}function As(e){let t=function(e){let t=Object.create(null);for(let n in e)t[Ss(n)]=e[n];return t}(e);return function(e,n){let i,r=function(e){var t=!(Ms&&(e.ctrlKey||e.altKey||e.metaKey)||Cs&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?_s:ws)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),o=1==r.length&&" "!=r,s=t[Ns(r,n,!o)];if(s&&s(e.state,e.dispatch,e))return!0;if(o&&(n.shiftKey||n.altKey||n.metaKey||r.charCodeAt(0)>127)&&(i=ws[n.keyCode])&&i!=r){let r=t[Ns(i,n,!0)];if(r&&r(e.state,e.dispatch,e))return!0}else if(o&&n.shiftKey){let i=t[Ns(r,n,!0)];if(i&&i(e.state,e.dispatch,e))return!0}return!1}}function js(e,t,n=!1){for(let i=e;i;i="start"==t?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(n&&1!=i.childCount)return!1}return!1}function Ls(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function zs(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function Is(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Rs(e,t,n){let i,r,o=t.nodeBefore,s=t.nodeAfter;if(o.type.spec.isolating||s.type.spec.isolating)return!1;if(function(e,t,n){let i=t.nodeBefore,r=t.nodeAfter,o=t.index();return!(!(i&&r&&i.type.compatibleContent(r.type))||(!i.content.size&&t.parent.canReplace(o-1,o)?(n&&n(e.tr.delete(t.pos-i.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(o,o+1)||!r.isTextblock&&!xn(e.doc,t.pos)||(n&&n(e.tr.clearIncompatible(t.pos,i.type,i.contentMatchAt(i.childCount)).join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let a=t.parent.canReplace(t.index(),t.index()+1);if(a&&(i=(r=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&r.matchType(i[0]||s.type).validEnd){if(n){let r=t.pos+s.nodeSize,a=Pe.empty;for(let e=i.length-1;e>=0;e--)a=Pe.from(i[e].create(null,a));a=Pe.from(o.copy(a));let l=e.tr.step(new hn(t.pos-1,r,t.pos,r,new Ve(a,1,0),i.length,!0)),c=r+2*i.length;xn(l.doc,c)&&l.join(c),n(l.scrollIntoView())}return!0}let l=Rn.findFrom(t,1),c=l&&l.$from.blockRange(l.$to),u=c&&gn(c);if(null!=u&&u>=t.depth)return n&&n(e.tr.lift(c,u).scrollIntoView()),!0;if(a&&js(s,"start",!0)&&js(o,"end")){let i=o,r=[];for(;r.push(i),!i.isTextblock;)i=i.lastChild;let a=s,l=1;for(;!a.isTextblock;a=a.firstChild)l++;if(i.canReplace(i.childCount,i.childCount,a.content)){if(n){let i=Pe.empty;for(let e=r.length-1;e>=0;e--)i=Pe.from(r[e].copy(i));n(e.tr.step(new hn(t.pos-r.length,t.pos+s.nodeSize,t.pos+l,t.pos+s.nodeSize-l,new Ve(i,r.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Fs(e){return function(t,n){let i=t.selection,r=e<0?i.$from:i.$to,o=r.depth;for(;r.node(o).isInline;){if(!o)return!1;o--}return!!r.node(o).isTextblock&&(n&&n(t.tr.setSelection(Un.create(t.doc,e<0?r.start(o):r.end(o)))),!0)}}const Bs=Fs(-1),Ps=Fs(1);function Us(e,t=null){return function(n,i){let{from:r,to:o}=n.selection,s=!1;return n.doc.nodesBetween(r,o,((i,r)=>{if(s)return!1;if(i.isTextblock&&!i.hasMarkup(e,t))if(i.type==e)s=!0;else{let t=n.doc.resolve(r),i=t.index();s=t.parent.canReplaceWith(i,i+1,e)}})),!!s&&(i&&i(n.tr.setBlockType(r,o,e,t).scrollIntoView()),!0)}}function Hs(e,t=null){return function(n,i){let{$from:r,$to:o}=n.selection,s=r.blockRange(o),a=!1,l=s;if(!s)return!1;if(s.depth>=2&&r.node(s.depth-1).type.compatibleContent(e)&&0==s.startIndex){if(0==r.index(s.depth-1))return!1;let e=n.doc.resolve(s.start-2);l=new lt(e,e,s.depth),s.endIndex<s.parent.childCount&&(s=new lt(r,n.doc.resolve(o.end(s.depth)),s.depth)),a=!0}let c=bn(l,e,t,s);return!!c&&(i&&i(function(e,t,n,i,r){let o=Pe.empty;for(let e=n.length-1;e>=0;e--)o=Pe.from(n[e].type.create(n[e].attrs,o));e.step(new hn(t.start-(i?2:0),t.end,t.start,t.end,new Ve(o,0,0),n.length,!0));let s=0;for(let e=0;e<n.length;e++)n[e].type==r&&(s=e+1);let a=n.length-s,l=t.start+n.length-(i?2:0),c=t.parent;for(let n=t.startIndex,i=t.endIndex,r=!0;n<i;n++,r=!1)!r&&yn(e.doc,l,a)&&(e.split(l,a),l+=2*a),l+=c.child(n).nodeSize;return e}(n.tr,s,c,a,e).scrollIntoView()),!0)}}function $s(e){return function(t,n){let{$from:i,$to:r}=t.selection,o=i.blockRange(r,(t=>t.childCount>0&&t.firstChild.type==e));return!!o&&(!n||(i.node(o.depth-1).type==e?function(e,t,n,i){let r=e.tr,o=i.end,s=i.$to.end(i.depth);o<s&&(r.step(new hn(o-1,s,o,s,new Ve(Pe.from(n.create(null,i.parent.copy())),1,0),1,!0)),i=new lt(r.doc.resolve(i.$from.pos),r.doc.resolve(s),i.depth));const a=gn(i);if(null==a)return!1;r.lift(i,a);let l=r.mapping.map(o,-1)-1;xn(r.doc,l)&&r.join(l);return t(r.scrollIntoView()),!0}(t,n,e,o):function(e,t,n){let i=e.tr,r=n.parent;for(let e=n.end,t=n.endIndex-1,o=n.startIndex;t>o;t--)e-=r.child(t).nodeSize,i.delete(e-1,e+1);let o=i.doc.resolve(n.start),s=o.nodeAfter;if(i.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==r.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(a?0:1),u+1,s.content.append(l?Pe.empty:Pe.from(r))))return!1;let p=o.pos,d=p+s.nodeSize;return i.step(new hn(p-(a?1:0),d+(l?1:0),p+1,d-1,new Ve((a?Pe.empty:Pe.from(r.copy(Pe.empty))).append(l?Pe.empty:Pe.from(r.copy(Pe.empty))),a?0:1,l?0:1),a?0:1)),t(i.scrollIntoView()),!0}(t,n,o)))}}function Ws(e){const{state:t,transaction:n}=e;let{selection:i}=n,{doc:r}=n,{storedMarks:o}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),filterTransaction:t.filterTransaction,plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return o},get selection(){return i},get doc(){return r},get tr(){return i=n.selection,r=n.doc,o=n.storedMarks,n}}}"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();class qs{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:n}=this,{view:i}=t,{tr:r}=n,o=this.buildProps(r);return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,(...e)=>{const n=t(...e)(o);return r.getMeta("preventDispatch")||this.hasCustomState||i.dispatch(r),n}])))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:i,state:r}=this,{view:o}=i,s=[],a=!!e,l=e||r.tr,c={...Object.fromEntries(Object.entries(n).map((([e,n])=>[e,(...e)=>{const i=this.buildProps(l,t),r=n(...e)(i);return s.push(r),c}]))),run:()=>(a||!t||l.getMeta("preventDispatch")||this.hasCustomState||o.dispatch(l),s.every((e=>!0===e)))};return c}createCan(e){const{rawCommands:t,state:n}=this,i=!1,r=e||n.tr,o=this.buildProps(r,i),s=Object.fromEntries(Object.entries(t).map((([e,t])=>[e,(...e)=>t(...e)({...o,dispatch:void 0})])));return{...s,chain:()=>this.createChain(r,i)}}buildProps(e,t=!0){const{rawCommands:n,editor:i,state:r}=this,{view:o}=i;r.storedMarks&&e.setStoredMarks(r.storedMarks);const s={tr:e,editor:i,view:o,state:Ws({state:r,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map((([e,t])=>[e,(...e)=>t(...e)(s)])))}};return s}}function Vs(e,t,n){if(void 0===e.config[t]&&e.parent)return Vs(e.parent,t,n);if("function"==typeof e.config[t]){return e.config[t].bind({...n,parent:e.parent?Vs(e.parent,t,n):null})}return e.config[t]}function Ks(e){return{baseExtensions:e.filter((e=>"extension"===e.type)),nodeExtensions:e.filter((e=>"node"===e.type)),markExtensions:e.filter((e=>"mark"===e.type))}}function Gs(e){const t=[],{nodeExtensions:n,markExtensions:i}=Ks(e),r=[...n,...i],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach((e=>{const n=Vs(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage});if(!n)return;n().forEach((e=>{e.types.forEach((n=>{Object.entries(e.attributes).forEach((([e,i])=>{t.push({type:n,name:e,attribute:{...o,...i}})}))}))}))})),r.forEach((e=>{const n={name:e.name,options:e.options,storage:e.storage},i=Vs(e,"addAttributes",n);if(!i)return;const r=i();Object.entries(r).forEach((([n,i])=>{const r={...o,...i};(null==i?void 0:i.isRequired)&&void 0===(null==i?void 0:i.default)&&delete r.default,t.push({type:e.name,name:n,attribute:r})}))})),t}function Ys(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function Qs(...e){return e.filter((e=>!!e)).reduce(((e,t)=>{const n={...e};return Object.entries(t).forEach((([e,t])=>{n[e]?n[e]="class"===e?[n[e],t].join(" "):"style"===e?[n[e],t].join("; "):t:n[e]=t})),n}),{})}function Zs(e,t){return t.filter((e=>e.attribute.rendered)).map((t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]})).reduce(((e,t)=>Qs(e,t)),{})}function Js(e){return"function"==typeof e}function Xs(e,t=void 0,...n){return Js(e)?t?e.bind(t)(...n):e(...n):e}function ea(e,t){return e.style?e:{...e,getAttrs:n=>{const i=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===i)return!1;const r=t.reduce(((e,t)=>{const i=t.attribute.parseHTML?t.attribute.parseHTML(n):function(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}(n.getAttribute(t.name));return null==i?e:{...e,[t.name]:i}}),{});return{...i,...r}}}}function ta(e){return Object.fromEntries(Object.entries(e).filter((([e,t])=>("attrs"!==e||!function(e={}){return 0===Object.keys(e).length&&e.constructor===Object}(t))&&null!=t)))}function na(e,t){return t.nodes[e]||t.marks[e]||null}function ia(e,t){return Array.isArray(t)?t.some((t=>("string"==typeof t?t:t.name)===e.name)):t}function ra(e){return"[object RegExp]"===Object.prototype.toString.call(e)}class oa{constructor(e){this.find=e.find,this.handler=e.handler}}function sa(e){var t;const{editor:n,from:i,to:r,text:o,rules:s,plugin:a}=e,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(i);if(c.parent.type.spec.code||(null===(t=c.nodeBefore||c.nodeAfter)||void 0===t?void 0:t.marks.find((e=>e.type.spec.code))))return!1;let u=!1;const p=((e,t=500)=>{let n="";const i=e.parentOffset;return e.parent.nodesBetween(Math.max(0,i-t),i,((e,t,r,o)=>{var s,a;const l=(null===(a=(s=e.type.spec).toText)||void 0===a?void 0:a.call(s,{node:e,pos:t,parent:r,index:o}))||e.textContent||"%leaf%";n+=l.slice(0,Math.max(0,i-t))})),n})(c)+o;return s.forEach((e=>{if(u)return;const t=((e,t)=>{if(ra(t))return t.exec(e);const n=t(e);if(!n)return null;const i=[];return i.push(n.text),i.index=n.index,i.input=e,i.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),i.push(n.replaceWith)),i})(p,e.find);if(!t)return;const s=l.state.tr,c=Ws({state:l.state,transaction:s}),d={from:i-(t[0].length-o.length),to:r},{commands:h,chain:f,can:m}=new qs({editor:n,state:c});null!==e.handler({state:c,range:d,match:t,commands:h,chain:f,can:m})&&s.steps.length&&(s.setMeta(a,{transform:s,from:i,to:r,text:o}),l.dispatch(s),u=!0)})),u}function aa(e){const{editor:t,rules:n}=e,i=new oi({state:{init:()=>null,apply(e,t){const n=e.getMeta(i);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(e,r,o,s)=>sa({editor:t,from:r,to:o,text:s,rules:n,plugin:i}),handleDOMEvents:{compositionend:e=>(setTimeout((()=>{const{$cursor:r}=e.state.selection;r&&sa({editor:t,from:r.pos,to:r.pos,text:"",rules:n,plugin:i})})),!1)},handleKeyDown(e,r){if("Enter"!==r.key)return!1;const{$cursor:o}=e.state.selection;return!!o&&sa({editor:t,from:o.pos,to:o.pos,text:"\n",rules:n,plugin:i})}},isInputRules:!0});return i}class la{constructor(e){this.find=e.find,this.handler=e.handler}}function ca(e){const{editor:t,state:n,from:i,to:r,rule:o}=e,{commands:s,chain:a,can:l}=new qs({editor:t,state:n}),c=[];n.doc.nodesBetween(i,r,((e,t)=>{if(!e.isTextblock||e.type.spec.code)return;const u=Math.max(i,t),p=Math.min(r,t+e.content.size),d=((e,t)=>{if(ra(t))return[...e.matchAll(t)];const n=t(e);return n?n.map((t=>{const n=[];return n.push(t.text),n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n})):[]})(e.textBetween(u-t,p-t,void 0,""),o.find);d.forEach((e=>{if(void 0===e.index)return;const t=u+e.index+1,i=t+e[0].length,r={from:n.tr.mapping.map(t),to:n.tr.mapping.map(i)},p=o.handler({state:n,range:r,match:e,commands:s,chain:a,can:l});c.push(p)}))}));return c.every((e=>null!==e))}function ua(e){const{editor:t,rules:n}=e;let i=null,r=!1,o=!1;const s=n.map((e=>new oi({view(e){const t=t=>{var n;i=(null===(n=e.dom.parentElement)||void 0===n?void 0:n.contains(t.target))?e.dom.parentElement:null};return window.addEventListener("dragstart",t),{destroy(){window.removeEventListener("dragstart",t)}}},props:{handleDOMEvents:{drop:e=>(o=i===e.dom.parentElement,!1),paste:(e,t)=>{var n;const i=null===(n=t.clipboardData)||void 0===n?void 0:n.getData("text/html");return r=!!(null==i?void 0:i.includes("data-pm-slice")),!1}}},appendTransaction:(n,i,s)=>{const a=n[0],l="paste"===a.getMeta("uiEvent")&&!r,c="drop"===a.getMeta("uiEvent")&&!o;if(!l&&!c)return;const u=i.doc.content.findDiffStart(s.doc.content),p=i.doc.content.findDiffEnd(s.doc.content);if("number"!=typeof u||!p||u===p.b)return;const d=s.tr,h=Ws({state:s,transaction:d});return ca({editor:t,state:h,from:Math.max(u-1,0),to:p.b-1,rule:e})&&d.steps.length?d:void 0}})));return s}class pa{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=pa.resolve(e),this.schema=function(e){var t;const n=Gs(e),{nodeExtensions:i,markExtensions:r}=Ks(e),o=null===(t=i.find((e=>Vs(e,"topNode"))))||void 0===t?void 0:t.name,s=Object.fromEntries(i.map((t=>{const i=n.filter((e=>e.type===t.name)),r={name:t.name,options:t.options,storage:t.storage},o=e.reduce(((e,n)=>{const i=Vs(n,"extendNodeSchema",r);return{...e,...i?i(t):{}}}),{}),s=ta({...o,content:Xs(Vs(t,"content",r)),marks:Xs(Vs(t,"marks",r)),group:Xs(Vs(t,"group",r)),inline:Xs(Vs(t,"inline",r)),atom:Xs(Vs(t,"atom",r)),selectable:Xs(Vs(t,"selectable",r)),draggable:Xs(Vs(t,"draggable",r)),code:Xs(Vs(t,"code",r)),defining:Xs(Vs(t,"defining",r)),isolating:Xs(Vs(t,"isolating",r)),attrs:Object.fromEntries(i.map((e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))}),a=Xs(Vs(t,"parseHTML",r));a&&(s.parseDOM=a.map((e=>ea(e,i))));const l=Vs(t,"renderHTML",r);l&&(s.toDOM=e=>l({node:e,HTMLAttributes:Zs(e,i)}));const c=Vs(t,"renderText",r);return c&&(s.toText=c),[t.name,s]}))),a=Object.fromEntries(r.map((t=>{const i=n.filter((e=>e.type===t.name)),r={name:t.name,options:t.options,storage:t.storage},o=e.reduce(((e,n)=>{const i=Vs(n,"extendMarkSchema",r);return{...e,...i?i(t):{}}}),{}),s=ta({...o,inclusive:Xs(Vs(t,"inclusive",r)),excludes:Xs(Vs(t,"excludes",r)),group:Xs(Vs(t,"group",r)),spanning:Xs(Vs(t,"spanning",r)),code:Xs(Vs(t,"code",r)),attrs:Object.fromEntries(i.map((e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]})))}),a=Xs(Vs(t,"parseHTML",r));a&&(s.parseDOM=a.map((e=>ea(e,i))));const l=Vs(t,"renderHTML",r);return l&&(s.toDOM=e=>l({mark:e,HTMLAttributes:Zs(e,i)})),[t.name,s]})));return new Dt({topNode:o,nodes:s,marks:a})}(this.extensions),this.extensions.forEach((e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const n={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:na(e.name,this.schema)};if("mark"===e.type){(null===(t=Xs(Vs(e,"keepOnSplit",n)))||void 0===t||t)&&this.splittableMarks.push(e.name)}const i=Vs(e,"onBeforeCreate",n);i&&this.editor.on("beforeCreate",i);const r=Vs(e,"onCreate",n);r&&this.editor.on("create",r);const o=Vs(e,"onUpdate",n);o&&this.editor.on("update",o);const s=Vs(e,"onSelectionUpdate",n);s&&this.editor.on("selectionUpdate",s);const a=Vs(e,"onTransaction",n);a&&this.editor.on("transaction",a);const l=Vs(e,"onFocus",n);l&&this.editor.on("focus",l);const c=Vs(e,"onBlur",n);c&&this.editor.on("blur",c);const u=Vs(e,"onDestroy",n);u&&this.editor.on("destroy",u)}))}static resolve(e){const t=pa.sort(pa.flatten(e)),n=function(e){const t=e.filter(((t,n)=>e.indexOf(t)!==n));return[...new Set(t)]}(t.map((e=>e.name)));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((e=>`'${e}'`)).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map((e=>{const t=Vs(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...this.flatten(t())]:e})).flat(10)}static sort(e){const t=100;return e.sort(((e,n)=>{const i=Vs(e,"priority")||t,r=Vs(n,"priority")||t;return i>r?-1:i<r?1:0}))}get commands(){return this.extensions.reduce(((e,t)=>{const n=Vs(t,"addCommands",{name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:na(t.name,this.schema)});return n?{...e,...n()}:e}),{})}get plugins(){const{editor:e}=this,t=pa.sort([...this.extensions].reverse()),n=[],i=[],r=t.map((t=>{const r={name:t.name,options:t.options,storage:t.storage,editor:e,type:na(t.name,this.schema)},o=[],s=Vs(t,"addKeyboardShortcuts",r);let a={};if("mark"===t.type&&t.config.exitable&&(a.ArrowRight=()=>ol.handleExit({editor:e,mark:t})),s){const t=Object.fromEntries(Object.entries(s()).map((([t,n])=>[t,()=>n({editor:e})])));a={...a,...t}}const l=new oi({props:{handleKeyDown:As(a)}});o.push(l);const c=Vs(t,"addInputRules",r);ia(t,e.options.enableInputRules)&&c&&n.push(...c());const u=Vs(t,"addPasteRules",r);ia(t,e.options.enablePasteRules)&&u&&i.push(...u());const p=Vs(t,"addProseMirrorPlugins",r);if(p){const e=p();o.push(...e)}return o})).flat();return[aa({editor:e,rules:n}),...ua({editor:e,rules:i}),...r]}get attributes(){return Gs(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Ks(this.extensions);return Object.fromEntries(t.filter((e=>!!Vs(e,"addNodeView"))).map((t=>{const n=this.attributes.filter((e=>e.type===t.name)),i={name:t.name,options:t.options,storage:t.storage,editor:e,type:Ys(t.name,this.schema)},r=Vs(t,"addNodeView",i);if(!r)return[];return[t.name,(i,o,s,a)=>{const l=Zs(i,n);return r()({editor:e,node:i,getPos:s,decorations:a,HTMLAttributes:l,extension:t})}]})))}}function da(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function ha(e,t){const n={...e};return da(e)&&da(t)&&Object.keys(t).forEach((i=>{da(t[i])?i in e?n[i]=ha(e[i],t[i]):Object.assign(n,{[i]:t[i]}):Object.assign(n,{[i]:t[i]})})),n}class fa{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Xs(Vs(this,"addOptions",{name:this.name}))),this.storage=Xs(Vs(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new fa(e)}configure(e={}){const t=this.extend();return t.options=ha(this.options,e),t.storage=Xs(Vs(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new fa(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Xs(Vs(t,"addOptions",{name:t.name})),t.storage=Xs(Vs(t,"addStorage",{name:t.name,options:t.options})),t}}function ma(e,t,n){const{from:i,to:r}=t,{blockSeparator:o="\n\n",textSerializers:s={}}=n||{};let a="",l=!0;return e.nodesBetween(i,r,((e,n,c,u)=>{var p;const d=null==s?void 0:s[e.type.name];d?(e.isBlock&&!l&&(a+=o,l=!0),c&&(a+=d({node:e,pos:n,parent:c,index:u,range:t}))):e.isText?(a+=null===(p=null==e?void 0:e.text)||void 0===p?void 0:p.slice(Math.max(i,n)-n,r-n),l=!1):e.isBlock&&!l&&(a+=o,l=!0)})),a}function ga(e){return Object.fromEntries(Object.entries(e.nodes).filter((([,e])=>e.spec.toText)).map((([e,t])=>[e,t.spec.toText])))}const ba=fa.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new oi({key:new li("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:i,selection:r}=t,{ranges:o}=r,s=Math.min(...o.map((e=>e.$from.pos))),a=Math.max(...o.map((e=>e.$to.pos)));return ma(i,{from:s,to:a},{textSerializers:ga(n)})}}})]}});function va(e,t,n={strict:!0}){const i=Object.keys(t);return!i.length||i.every((i=>n.strict?t[i]===e[i]:ra(t[i])?t[i].test(e[i]):t[i]===e[i]))}function ya(e,t,n={}){return e.find((e=>e.type===t&&va(e.attrs,n)))}function xa(e,t,n={}){return!!ya(e,t,n)}function wa(e,t,n={}){if(!e||!t)return;let i=e.parent.childAfter(e.parentOffset);if(e.parentOffset===i.offset&&0!==i.offset&&(i=e.parent.childBefore(e.parentOffset)),!i.node)return;const r=ya([...i.node.marks],t,n);if(!r)return;let o=i.index,s=e.start()+i.offset,a=o+1,l=s+i.node.nodeSize;for(ya([...i.node.marks],t,n);o>0&&r.isInSet(e.parent.child(o-1).marks);)o-=1,s-=e.parent.child(o).nodeSize;for(;a<e.parent.childCount&&xa([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:s,to:l}}function _a(e,t){if("string"==typeof e){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}function ka(e){return e instanceof Un}function Ea(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function Ca(e,t=null){if(!t)return null;const n=Rn.atStart(e),i=Rn.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return i;const r=n.from,o=i.to;return"all"===t?Un.create(e,Ea(0,r,o),Ea(e.content.size,r,o)):Un.create(e,Ea(t,r,o),Ea(t,r,o))}function Ma(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Oa(e){const t=`<body>${e}</body>`;return(new window.DOMParser).parseFromString(t,"text/html").body}function Da(e,t,n){if(n={slice:!0,parseOptions:{},...n},"object"==typeof e&&null!==e)try{return Array.isArray(e)?Pe.fromArray(e.map((e=>t.nodeFromJSON(e)))):t.nodeFromJSON(e)}catch(i){return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",i),Da("",t,n)}if("string"==typeof e){const i=St.fromSchema(t);return n.slice?i.parseSlice(Oa(e),n.parseOptions).content:i.parse(Oa(e),n.parseOptions)}return Da("",t,n)}function Ta(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}function Sa(e,t,n={}){const{from:i,to:r,empty:o}=e.selection,s=t?Ys(t,e.schema):null,a=[];e.doc.nodesBetween(i,r,((e,t)=>{if(e.isText)return;const n=Math.max(i,t),o=Math.min(r,t+e.nodeSize);a.push({node:e,from:n,to:o})}));const l=r-i,c=a.filter((e=>!s||s.name===e.node.type.name)).filter((e=>va(e.node.attrs,n,{strict:!1})));if(o)return!!c.length;return c.reduce(((e,t)=>e+t.to-t.from),0)>=l}function Na(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Aa(e,t){const n="string"==typeof t?[t]:t;return Object.keys(e).reduce(((t,i)=>(n.includes(i)||(t[i]=e[i]),t)),{})}function ja(e,t,n={}){return Da(e,t,{slice:!1,parseOptions:n})}function La(e,t){const n=[];return e.descendants(((e,i)=>{t(e)&&n.push({node:e,pos:i})})),n}function za(e){return t=>function(e,t){for(let n=e.depth;n>0;n-=1){const i=e.node(n);if(t(i))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:i}}}(t.$from,e)}function Ia(e,t){const n=_a(t,e.schema),{from:i,to:r,empty:o}=e.selection,s=[];o?(e.storedMarks&&s.push(...e.storedMarks),s.push(...e.selection.$head.marks())):e.doc.nodesBetween(i,r,(e=>{s.push(...e.marks)}));const a=s.find((e=>e.type.name===n.name));return a?{...a.attrs}:{}}function Ra(e,t){const n=Na("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){const n=Ys(t,e.schema),{from:i,to:r}=e.selection,o=[];e.doc.nodesBetween(i,r,(e=>{o.push(e)}));const s=o.reverse().find((e=>e.type.name===n.name));return s?{...s.attrs}:{}}(e,t):"mark"===n?Ia(e,t):{}}function Fa(e){const t=function(e,t=JSON.stringify){const n={};return e.filter((e=>{const i=t(e);return!Object.prototype.hasOwnProperty.call(n,i)&&(n[i]=!0)}))}(e);return 1===t.length?t:t.filter(((e,n)=>{const i=t.filter(((e,t)=>t!==n));return!i.some((t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}))}function Ba(e,t,n){const i=[];return e===t?n.resolve(e).marks().forEach((t=>{const r=wa(n.resolve(e-1),t.type);r&&i.push({mark:t,...r})})):n.nodesBetween(e,t,((e,t)=>{i.push(...e.marks.map((n=>({from:t,to:t+e.nodeSize,mark:n}))))})),i}function Pa(e,t,n={}){const{empty:i,ranges:r}=e.selection,o=t?_a(t,e.schema):null;if(i)return!!(e.storedMarks||e.selection.$from.marks()).filter((e=>!o||o.name===e.type.name)).find((e=>va(e.attrs,n,{strict:!1})));let s=0;const a=[];if(r.forEach((({$from:t,$to:n})=>{const i=t.pos,r=n.pos;e.doc.nodesBetween(i,r,((e,t)=>{if(!e.isText&&!e.marks.length)return;const n=Math.max(i,t),o=Math.min(r,t+e.nodeSize);s+=o-n,a.push(...e.marks.map((e=>({mark:e,from:n,to:o}))))}))})),0===s)return!1;const l=a.filter((e=>!o||o.name===e.mark.type.name)).filter((e=>va(e.mark.attrs,n,{strict:!1}))).reduce(((e,t)=>e+t.to-t.from),0),c=a.filter((e=>!o||e.mark.type!==o&&e.mark.type.excludes(o))).reduce(((e,t)=>e+t.to-t.from),0);return(l>0?l+c:l)>=s}function Ua(e,t){const{nodeExtensions:n}=Ks(t),i=n.find((t=>t.name===e));if(!i)return!1;const r=Xs(Vs(i,"group",{name:i.name,options:i.options,storage:i.storage}));return"string"==typeof r&&r.split(" ").includes("list")}function Ha(e,t,n){const i=0,r=e.state.doc.content.size,o=Ea(t,i,r),s=Ea(n,i,r),a=e.coordsAtPos(o),l=e.coordsAtPos(s,-1),c=Math.min(a.top,l.top),u=Math.max(a.bottom,l.bottom),p=Math.min(a.left,l.left),d=Math.max(a.right,l.right),h={top:c,bottom:u,left:p,right:d,width:d-p,height:u-c,x:p,y:c};return{...h,toJSON:()=>h}}function $a(e,t,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const i=e.find((e=>e.type===t&&e.name===n));return!!i&&i.attribute.keepOnSplit})))}function Wa(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const i=n.filter((e=>null==t?void 0:t.includes(e.type.name)));e.tr.ensureMarks(i)}}const qa=(e,t)=>{const n=za((e=>e.type===t))(e.selection);if(!n)return!0;const i=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===i)return!0;const r=e.doc.nodeAt(i);return n.node.type!==(null==r?void 0:r.type)||!xn(e.doc,n.pos)||(e.join(n.pos),!0)},Va=(e,t)=>{const n=za((e=>e.type===t))(e.selection);if(!n)return!0;const i=e.doc.resolve(n.start).after(n.depth);if(void 0===i)return!0;const r=e.doc.nodeAt(i);return n.node.type!==(null==r?void 0:r.type)||!xn(e.doc,i)||(e.join(i),!0)};var Ka=Object.freeze({__proto__:null,blur:()=>({editor:e,view:t})=>(requestAnimationFrame((()=>{var n;e.isDestroyed||(t.dom.blur(),null===(n=null===window||void 0===window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())})),!0),clearContent:(e=!1)=>({commands:t})=>t.setContent("",e),clearNodes:()=>({state:e,tr:t,dispatch:n})=>{const{selection:i}=t,{ranges:r}=i;return!n||(r.forEach((({$from:n,$to:i})=>{e.doc.nodesBetween(n.pos,i.pos,((e,n)=>{if(e.type.isText)return;const{doc:i,mapping:r}=t,o=i.resolve(r.map(n)),s=i.resolve(r.map(n+e.nodeSize)),a=o.blockRange(s);if(!a)return;const l=gn(a);if(e.type.isTextblock){const{defaultType:e}=o.parent.contentMatchAt(o.index());t.setNodeMarkup(a.start,e)}(l||0===l)&&t.lift(a,l)}))})),!0)},command:e=>t=>e(t),createParagraphNear:()=>({state:e,dispatch:t})=>((e,t)=>{let n=e.selection,{$from:i,$to:r}=n;if(n instanceof qn||i.parent.inlineContent||r.parent.inlineContent)return!1;let o=Is(r.parent.contentMatchAt(r.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){let n=(!i.parentOffset&&r.index()<r.parent.childCount?i:r).pos,s=e.tr.insert(n,o.createAndFill());s.setSelection(Un.create(s.doc,n+1)),t(s.scrollIntoView())}return!0})(e,t),deleteNode:e=>({tr:t,state:n,dispatch:i})=>{const r=Ys(e,n.schema),o=t.selection.$anchor;for(let e=o.depth;e>0;e-=1){if(o.node(e).type===r){if(i){const n=o.before(e),i=o.after(e);t.delete(n,i).scrollIntoView()}return!0}}return!1},deleteRange:e=>({tr:t,dispatch:n})=>{const{from:i,to:r}=e;return n&&t.delete(i,r),!0},deleteSelection:()=>({state:e,dispatch:t})=>((e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0))(e,t),enter:()=>({commands:e})=>e.keyboardShortcut("Enter"),exitCode:()=>({state:e,dispatch:t})=>((e,t)=>{let{$head:n,$anchor:i}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(i))return!1;let r=n.node(-1),o=n.indexAfter(-1),s=Is(r.contentMatchAt(o));if(!s||!r.canReplaceWith(o,o,s))return!1;if(t){let i=n.after(),r=e.tr.replaceWith(i,i,s.createAndFill());r.setSelection(Rn.near(r.doc.resolve(i),1)),t(r.scrollIntoView())}return!0})(e,t),extendMarkRange:(e,t={})=>({tr:n,state:i,dispatch:r})=>{const o=_a(e,i.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:u}=a;if(r){const e=wa(l,o,t);if(e&&e.from<=c&&e.to>=u){const t=Un.create(s,e.from,e.to);n.setSelection(t)}}return!0},first:e=>t=>{const n="function"==typeof e?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1},focus:(e=null,t={})=>({editor:n,view:i,tr:r,dispatch:o})=>{t={scrollIntoView:!0,...t};const s=()=>{Ma()&&i.dom.focus(),requestAnimationFrame((()=>{n.isDestroyed||(i.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())}))};if(i.hasFocus()&&null===e||!1===e)return!0;if(o&&null===e&&!ka(n.state.selection))return s(),!0;const a=Ca(r.doc,e)||n.state.selection,l=n.state.selection.eq(a);return o&&(l||r.setSelection(a),l&&r.storedMarks&&r.setStoredMarks(r.storedMarks),s()),!0},forEach:(e,t)=>n=>e.every(((e,i)=>t(e,{...n,index:i}))),insertContent:(e,t)=>({tr:n,commands:i})=>i.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),insertContentAt:(e,t,n)=>({tr:i,dispatch:r,editor:o})=>{if(r){n={parseOptions:{},updateSelection:!0,...n};const r=Da(t,o.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if("<>"===r.toString())return!0;let{from:s,to:a}="number"==typeof e?{from:e,to:e}:e,l=!0,c=!0;if((r.toString().startsWith("<")?r:[r]).forEach((e=>{e.check(),l=!!l&&(e.isText&&0===e.marks.length),c=!!c&&e.isBlock})),s===a&&c){const{parent:e}=i.doc.resolve(s);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(s-=1,a+=1)}l?i.insertText(t,s,a):i.replaceWith(s,a,r),n.updateSelection&&function(e,t,n){const i=e.steps.length-1;if(i<t)return;const r=e.steps[i];if(!(r instanceof dn||r instanceof hn))return;const o=e.mapping.maps[i];let s=0;o.forEach(((e,t,n,i)=>{0===s&&(s=i)})),e.setSelection(Rn.near(e.doc.resolve(s),n))}(i,i.steps.length-1,-1)}return!0},joinBackward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$cursor:i}=e.selection;if(!i||(n?!n.endOfTextblock("backward",e):i.parentOffset>0))return!1;let r=Ls(i);if(!r){let n=i.blockRange(),r=n&&gn(n);return null!=r&&(t&&t(e.tr.lift(n,r).scrollIntoView()),!0)}let o=r.nodeBefore;if(!o.type.spec.isolating&&Rs(e,r,t))return!0;if(0==i.parent.content.size&&(js(o,"end")||$n.isSelectable(o))){let n=_n(e.doc,i.before(),i.after(),Ve.empty);if(n&&n.slice.size<n.to-n.from){if(t){let i=e.tr.step(n);i.setSelection(js(o,"end")?Rn.findFrom(i.doc.resolve(i.mapping.map(r.pos,-1)),-1):$n.create(i.doc,r.pos-o.nodeSize)),t(i.scrollIntoView())}return!0}}return!(!o.isAtom||r.depth!=i.depth-1||(t&&t(e.tr.delete(r.pos-o.nodeSize,r.pos).scrollIntoView()),0))})(e,t),joinForward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$cursor:i}=e.selection;if(!i||(n?!n.endOfTextblock("forward",e):i.parentOffset<i.parent.content.size))return!1;let r=zs(i);if(!r)return!1;let o=r.nodeAfter;if(Rs(e,r,t))return!0;if(0==i.parent.content.size&&(js(o,"start")||$n.isSelectable(o))){let n=_n(e.doc,i.before(),i.after(),Ve.empty);if(n&&n.slice.size<n.to-n.from){if(t){let i=e.tr.step(n);i.setSelection(js(o,"start")?Rn.findFrom(i.doc.resolve(i.mapping.map(r.pos)),1):$n.create(i.doc,i.mapping.map(r.pos))),t(i.scrollIntoView())}return!0}}return!(!o.isAtom||r.depth!=i.depth-1||(t&&t(e.tr.delete(r.pos,r.pos+o.nodeSize).scrollIntoView()),0))})(e,t),keyboardShortcut:e=>({editor:t,view:n,tr:i,dispatch:r})=>{const o=function(e){const t=e.split(/-(?!$)/);let n,i,r,o,s=t[t.length-1];"Space"===s&&(s=" ");for(let e=0;e<t.length-1;e+=1){const s=t[e];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))i=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error(`Unrecognized modifier name: ${s}`);Ma()||Ta()?o=!0:i=!0}}return n&&(s=`Alt-${s}`),i&&(s=`Ctrl-${s}`),o&&(s=`Meta-${s}`),r&&(s=`Shift-${s}`),s}(e).split(/-(?!$)/),s=o.find((e=>!["Alt","Ctrl","Meta","Shift"].includes(e))),a=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction((()=>{n.someProp("handleKeyDown",(e=>e(n,a)))}));return null==l||l.steps.forEach((e=>{const t=e.map(i.mapping);t&&r&&i.maybeStep(t)})),!0},lift:(e,t={})=>({state:n,dispatch:i})=>!!Sa(n,Ys(e,n.schema),t)&&((e,t)=>{let{$from:n,$to:i}=e.selection,r=n.blockRange(i),o=r&&gn(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)})(n,i),liftEmptyBlock:()=>({state:e,dispatch:t})=>((e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(yn(e.doc,i))return t&&t(e.tr.split(i).scrollIntoView()),!0}let i=n.blockRange(),r=i&&gn(i);return null!=r&&(t&&t(e.tr.lift(i,r).scrollIntoView()),!0)})(e,t),liftListItem:e=>({state:t,dispatch:n})=>$s(Ys(e,t.schema))(t,n),newlineInCode:()=>({state:e,dispatch:t})=>((e,t)=>{let{$head:n,$anchor:i}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(i)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))})(e,t),resetAttributes:(e,t)=>({tr:n,state:i,dispatch:r})=>{let o=null,s=null;const a=Na("string"==typeof e?e:e.name,i.schema);return!!a&&("node"===a&&(o=Ys(e,i.schema)),"mark"===a&&(s=_a(e,i.schema)),r&&n.selection.ranges.forEach((e=>{i.doc.nodesBetween(e.$from.pos,e.$to.pos,((e,i)=>{o&&o===e.type&&n.setNodeMarkup(i,void 0,Aa(e.attrs,t)),s&&e.marks.length&&e.marks.forEach((r=>{s===r.type&&n.addMark(i,i+e.nodeSize,s.create(Aa(r.attrs,t)))}))}))})),!0)},scrollIntoView:()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),selectAll:()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),selectNodeBackward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$head:i,empty:r}=e.selection,o=i;if(!r)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):i.parentOffset>0)return!1;o=Ls(i)}let s=o&&o.nodeBefore;return!(!s||!$n.isSelectable(s)||(t&&t(e.tr.setSelection($n.create(e.doc,o.pos-s.nodeSize)).scrollIntoView()),0))})(e,t),selectNodeForward:()=>({state:e,dispatch:t})=>((e,t,n)=>{let{$head:i,empty:r}=e.selection,o=i;if(!r)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):i.parentOffset<i.parent.content.size)return!1;o=zs(i)}let s=o&&o.nodeAfter;return!(!s||!$n.isSelectable(s)||(t&&t(e.tr.setSelection($n.create(e.doc,o.pos)).scrollIntoView()),0))})(e,t),selectParentNode:()=>({state:e,dispatch:t})=>((e,t)=>{let n,{$from:i,to:r}=e.selection,o=i.sharedDepth(r);return 0!=o&&(n=i.before(o),t&&t(e.tr.setSelection($n.create(e.doc,n))),!0)})(e,t),selectTextblockEnd:()=>({state:e,dispatch:t})=>Ps(e,t),selectTextblockStart:()=>({state:e,dispatch:t})=>Bs(e,t),setContent:(e,t=!1,n={})=>({tr:i,editor:r,dispatch:o})=>{const{doc:s}=i,a=ja(e,r.schema,n);return o&&i.replaceWith(0,s.content.size,a).setMeta("preventUpdate",!t),!0},setMark:(e,t={})=>({tr:n,state:i,dispatch:r})=>{const{selection:o}=n,{empty:s,ranges:a}=o,l=_a(e,i.schema);if(r)if(s){const e=Ia(i,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach((e=>{const r=e.$from.pos,o=e.$to.pos;i.doc.nodesBetween(r,o,((e,i)=>{const s=Math.max(i,r),a=Math.min(i+e.nodeSize,o);e.marks.find((e=>e.type===l))?e.marks.forEach((e=>{l===e.type&&n.addMark(s,a,l.create({...e.attrs,...t}))})):n.addMark(s,a,l.create(t))}))}));return function(e,t,n){var i;const{selection:r}=t;let o=null;if(ka(r)&&(o=r.$cursor),o){const t=null!==(i=e.storedMarks)&&void 0!==i?i:o.marks();return!!n.isInSet(t)||!t.some((e=>e.type.excludes(n)))}const{ranges:s}=r;return s.some((({$from:t,$to:i})=>{let r=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,i.pos,((e,t,i)=>{if(r)return!1;if(e.isInline){const t=!i||i.type.allowsMarkType(n),o=!!n.isInSet(e.marks)||!e.marks.some((e=>e.type.excludes(n)));r=t&&o}return!r})),r}))}(i,n,l)},setMeta:(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),setNode:(e,t={})=>({state:n,dispatch:i,chain:r})=>{const o=Ys(e,n.schema);return o.isTextblock?r().command((({commands:e})=>!!Us(o,t)(n)||e.clearNodes())).command((({state:e})=>Us(o,t)(e,i))).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection:e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,i=Ea(e,0,n.content.size),r=$n.create(n,i);t.setSelection(r)}return!0},setTextSelection:e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:i,to:r}="number"==typeof e?{from:e,to:e}:e,o=Un.atStart(n).from,s=Un.atEnd(n).to,a=Ea(i,o,s),l=Ea(r,o,s),c=Un.create(n,a,l);t.setSelection(c)}return!0},sinkListItem:e=>({state:t,dispatch:n})=>{const i=Ys(e,t.schema);return(r=i,function(e,t){let{$from:n,$to:i}=e.selection,o=n.blockRange(i,(e=>e.childCount>0&&e.firstChild.type==r));if(!o)return!1;let s=o.startIndex;if(0==s)return!1;let a=o.parent,l=a.child(s-1);if(l.type!=r)return!1;if(t){let n=l.lastChild&&l.lastChild.type==a.type,i=Pe.from(n?r.create():null),s=new Ve(Pe.from(r.create(null,Pe.from(a.type.create(null,i)))),n?3:1,0),c=o.start,u=o.end;t(e.tr.step(new hn(c-(n?3:1),u,c,u,s,1,!0)).scrollIntoView())}return!0})(t,n);var r},splitBlock:({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:i,editor:r})=>{const{selection:o,doc:s}=t,{$from:a,$to:l}=o,c=$a(r.extensionManager.attributes,a.node().type.name,a.node().attrs);if(o instanceof $n&&o.node.isBlock)return!(!a.parentOffset||!yn(s,a.pos))&&(i&&(e&&Wa(n,r.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;if(i){const i=l.parentOffset===l.parent.content.size;o instanceof Un&&t.deleteSelection();const s=0===a.depth?void 0:function(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let u=i&&s?[{type:s,attrs:c}]:void 0,p=yn(t.doc,t.mapping.map(a.pos),1,u);if(u||p||!yn(t.doc,t.mapping.map(a.pos),1,s?[{type:s}]:void 0)||(p=!0,u=s?[{type:s,attrs:c}]:void 0),p&&(t.split(t.mapping.map(a.pos),1,u),s&&!i&&!a.parentOffset&&a.parent.type!==s)){const e=t.mapping.map(a.before()),n=t.doc.resolve(e);a.node(-1).canReplaceWith(n.index(),n.index()+1,s)&&t.setNodeMarkup(t.mapping.map(a.before()),s)}e&&Wa(n,r.extensionManager.splittableMarks),t.scrollIntoView()}return!0},splitListItem:e=>({tr:t,state:n,dispatch:i,editor:r})=>{var o;const s=Ys(e,n.schema),{$from:a,$to:l}=n.selection,c=n.selection.node;if(c&&c.isBlock||a.depth<2||!a.sameParent(l))return!1;const u=a.node(-1);if(u.type!==s)return!1;const p=r.extensionManager.attributes;if(0===a.parent.content.size&&a.node(-1).childCount===a.indexAfter(-1)){if(2===a.depth||a.node(-3).type!==s||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let e=Pe.empty;const n=a.index(-1)?1:a.index(-2)?2:3;for(let t=a.depth-n;t>=a.depth-3;t-=1)e=Pe.from(a.node(t).copy(e));const i=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,r=$a(p,a.node().type.name,a.node().attrs),l=(null===(o=s.contentMatch.defaultType)||void 0===o?void 0:o.createAndFill(r))||void 0;e=e.append(Pe.from(s.createAndFill(null,l)||void 0));const c=a.before(a.depth-(n-1));t.replace(c,a.after(-i),new Ve(e,4-n,0));let u=-1;t.doc.nodesBetween(c,t.doc.content.size,((e,t)=>{if(u>-1)return!1;e.isTextblock&&0===e.content.size&&(u=t+1)})),u>-1&&t.setSelection(Un.near(t.doc.resolve(u))),t.scrollIntoView()}return!0}const d=l.pos===a.end()?u.contentMatchAt(0).defaultType:null,h=$a(p,u.type.name,u.attrs),f=$a(p,a.node().type.name,a.node().attrs);t.delete(a.pos,l.pos);const m=d?[{type:s,attrs:h},{type:d,attrs:f}]:[{type:s,attrs:h}];return!!yn(t.doc,a.pos,2)&&(i&&t.split(a.pos,2,m).scrollIntoView(),!0)},toggleList:(e,t)=>({editor:n,tr:i,state:r,dispatch:o,chain:s,commands:a,can:l})=>{const{extensions:c}=n.extensionManager,u=Ys(e,r.schema),p=Ys(t,r.schema),{selection:d}=r,{$from:h,$to:f}=d,m=h.blockRange(f);if(!m)return!1;const g=za((e=>Ua(e.type.name,c)))(d);if(m.depth>=1&&g&&m.depth-g.depth<=1){if(g.node.type===u)return a.liftListItem(p);if(Ua(g.node.type.name,c)&&u.validContent(g.node.content)&&o)return s().command((()=>(i.setNodeMarkup(g.pos,u),!0))).command((()=>qa(i,u))).command((()=>Va(i,u))).run()}return s().command((()=>!!l().wrapInList(u)||a.clearNodes())).wrapInList(u).command((()=>qa(i,u))).command((()=>Va(i,u))).run()},toggleMark:(e,t={},n={})=>({state:i,commands:r})=>{const{extendEmptyMarkRange:o=!1}=n,s=_a(e,i.schema);return Pa(i,s,t)?r.unsetMark(s,{extendEmptyMarkRange:o}):r.setMark(s,t)},toggleNode:(e,t,n={})=>({state:i,commands:r})=>{const o=Ys(e,i.schema),s=Ys(t,i.schema);return Sa(i,o,n)?r.setNode(s):r.setNode(o,n)},toggleWrap:(e,t={})=>({state:n,commands:i})=>{const r=Ys(e,n.schema);return Sa(n,r,t)?i.lift(r):i.wrapIn(r,t)},undoInputRule:()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let i=0;i<n.length;i+=1){const r=n[i];let o;if(r.spec.isInputRules&&(o=r.getState(e))){if(t){const t=e.tr,n=o.transform;for(let e=n.steps.length-1;e>=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(o.text){const n=t.doc.resolve(o.from).marks();t.replaceWith(o.from,o.to,e.schema.text(o.text,n))}else t.delete(o.from,o.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:i,ranges:r}=n;return i||t&&r.forEach((t=>{e.removeMark(t.$from.pos,t.$to.pos)})),!0},unsetMark:(e,t={})=>({tr:n,state:i,dispatch:r})=>{var o;const{extendEmptyMarkRange:s=!1}=t,{selection:a}=n,l=_a(e,i.schema),{$from:c,empty:u,ranges:p}=a;if(!r)return!0;if(u&&s){let{from:e,to:t}=a;const i=null===(o=c.marks().find((e=>e.type===l)))||void 0===o?void 0:o.attrs,r=wa(c,l,i);r&&(e=r.from,t=r.to),n.removeMark(e,t,l)}else p.forEach((e=>{n.removeMark(e.$from.pos,e.$to.pos,l)}));return n.removeStoredMark(l),!0},updateAttributes:(e,t={})=>({tr:n,state:i,dispatch:r})=>{let o=null,s=null;const a=Na("string"==typeof e?e:e.name,i.schema);return!!a&&("node"===a&&(o=Ys(e,i.schema)),"mark"===a&&(s=_a(e,i.schema)),r&&n.selection.ranges.forEach((e=>{const r=e.$from.pos,a=e.$to.pos;i.doc.nodesBetween(r,a,((e,i)=>{o&&o===e.type&&n.setNodeMarkup(i,void 0,{...e.attrs,...t}),s&&e.marks.length&&e.marks.forEach((o=>{if(s===o.type){const l=Math.max(i,r),c=Math.min(i+e.nodeSize,a);n.addMark(l,c,s.create({...o.attrs,...t}))}}))}))})),!0)},wrapIn:(e,t={})=>({state:n,dispatch:i})=>function(e,t=null){return function(n,i){let{$from:r,$to:o}=n.selection,s=r.blockRange(o),a=s&&bn(s,e,t);return!!a&&(i&&i(n.tr.wrap(s,a).scrollIntoView()),!0)}}(Ys(e,n.schema),t)(n,i),wrapInList:(e,t={})=>({state:n,dispatch:i})=>Hs(Ys(e,n.schema),t)(n,i)});const Ga=fa.create({name:"commands",addCommands:()=>({...Ka})}),Ya=fa.create({name:"editable",addProseMirrorPlugins(){return[new oi({key:new li("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Qa=fa.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new oi({key:new li("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const i=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(i),!1},blur:(t,n)=>{e.isFocused=!1;const i=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(i),!1}}}})]}}),Za=fa.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first((({commands:e})=>[()=>e.undoInputRule(),()=>e.command((({tr:t})=>{const{selection:n,doc:i}=t,{empty:r,$anchor:o}=n,{pos:s,parent:a}=o,l=Rn.atStart(i).from===s;return!(!(r&&l&&a.type.isTextblock)||a.textContent.length)&&e.clearNodes()})),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()])),t=()=>this.editor.commands.first((({commands:e})=>[()=>e.deleteSelection(),()=>e.joinForward(),()=>e.selectNodeForward()])),n={Enter:()=>this.editor.commands.first((({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},i={...n},r={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ma()||Ta()?r:i},addProseMirrorPlugins(){return[new oi({key:new li("clearDocument"),appendTransaction:(e,t,n)=>{if(!(e.some((e=>e.docChanged))&&!t.doc.eq(n.doc)))return;const{empty:i,from:r,to:o}=t.selection,s=Rn.atStart(t.doc).from,a=Rn.atEnd(t.doc).to,l=r===s&&o===a,c=0===n.doc.textBetween(0,n.doc.content.size," "," ").length;if(i||!l||!c)return;const u=n.tr,p=Ws({state:n,transaction:u}),{commands:d}=new qs({editor:this.editor,state:p});return d.clearNodes(),u.steps.length?u:void 0}})]}}),Ja=fa.create({name:"tabindex",addProseMirrorPlugins(){return[new oi({key:new li("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});var Xa=Object.freeze({__proto__:null,ClipboardTextSerializer:ba,Commands:Ga,Editable:Ya,FocusEvents:Qa,Keymap:Za,Tabindex:Ja});const el=`.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}`;function tl(e){return new oa({find:e.find,handler:({state:t,range:n,match:i})=>{const r=Xs(e.getAttributes,void 0,i);if(!1===r||null===r)return null;const{tr:o}=t,s=i[i.length-1],a=i[0];let l=n.to;if(s){const i=a.search(/\S/),c=n.from+a.indexOf(s),u=c+s.length,p=Ba(n.from,n.to,t.doc).filter((t=>t.mark.type.excluded.find((n=>n===e.type&&n!==t.mark.type)))).filter((e=>e.to>c));if(p.length)return null;u<n.to&&o.delete(u,n.to),c>n.from&&o.delete(n.from+i,c),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(r||{})),o.removeStoredMark(e.type)}}})}function nl(e){return new oa({find:e.find,handler:({state:t,range:n,match:i})=>{const r=Xs(e.getAttributes,void 0,i)||{},{tr:o}=t,s=n.from;let a=n.to;if(i[1]){let t=s+i[0].lastIndexOf(i[1]);t>a?t=a:a=t+i[1].length;const n=i[0][i[0].length-1];o.insertText(n,s+i[0].length-1),o.replaceWith(t,a,e.type.create(r))}else i[0]&&o.replaceWith(s,a,e.type.create(r))}})}function il(e){return new oa({find:e.find,handler:({state:t,range:n,match:i})=>{const r=t.doc.resolve(n.from),o=Xs(e.getAttributes,void 0,i)||{};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,o)}})}function rl(e){return new oa({find:e.find,handler:({state:t,range:n,match:i})=>{const r=Xs(e.getAttributes,void 0,i)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),a=s&&bn(s,e.type,r);if(!a)return null;o.wrap(s,a);const l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&xn(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(i,l))&&o.join(n.from-1)}})}class ol{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Xs(Vs(this,"addOptions",{name:this.name}))),this.storage=Xs(Vs(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new ol(e)}configure(e={}){const t=this.extend();return t.options=ha(this.options,e),t.storage=Xs(Vs(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new ol(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Xs(Vs(t,"addOptions",{name:t.name})),t.storage=Xs(Vs(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const r=i.marks(),o=!!r.find((e=>(null==e?void 0:e.type.name)===t.name));if(!o)return!1;const s=r.find((e=>(null==e?void 0:e.type.name)===t.name));return s&&n.removeStoredMark(s),n.insertText(" ",i.pos),e.view.dispatch(n),!0}return!1}}class sl{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Xs(Vs(this,"addOptions",{name:this.name}))),this.storage=Xs(Vs(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new sl(e)}configure(e={}){const t=this.extend();return t.options=ha(this.options,e),t.storage=Xs(Vs(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new sl(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=Xs(Vs(t,"addOptions",{name:t.name})),t.storage=Xs(Vs(t,"addStorage",{name:t.name,options:t.options})),t}}function al(e){return new la({find:e.find,handler:({state:t,range:n,match:i})=>{const r=Xs(e.getAttributes,void 0,i);if(!1===r||null===r)return null;const{tr:o}=t,s=i[i.length-1],a=i[0];let l=n.to;if(s){const i=a.search(/\S/),c=n.from+a.indexOf(s),u=c+s.length,p=Ba(n.from,n.to,t.doc).filter((t=>t.mark.type.excluded.find((n=>n===e.type&&n!==t.mark.type)))).filter((e=>e.to>c));if(p.length)return null;u<n.to&&o.delete(u,n.to),c>n.from&&o.delete(n.from+i,c),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(r||{})),o.removeStoredMark(e.type)}}})}var ll="top",cl="bottom",ul="right",pl="left",dl="auto",hl=[ll,cl,ul,pl],fl="start",ml="end",gl="clippingParents",bl="viewport",vl="popper",yl="reference",xl=hl.reduce((function(e,t){return e.concat([t+"-"+fl,t+"-"+ml])}),[]),wl=[].concat(hl,[dl]).reduce((function(e,t){return e.concat([t,t+"-"+fl,t+"-"+ml])}),[]),_l=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function kl(e){return e?(e.nodeName||"").toLowerCase():null}function El(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Cl(e){return e instanceof El(e).Element||e instanceof Element}function Ml(e){return e instanceof El(e).HTMLElement||e instanceof HTMLElement}function Ol(e){return"undefined"!=typeof ShadowRoot&&(e instanceof El(e).ShadowRoot||e instanceof ShadowRoot)}var Dl={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var n=t.styles[e]||{},i=t.attributes[e]||{},r=t.elements[e];Ml(r)&&kl(r)&&(Object.assign(r.style,n),Object.keys(i).forEach((function(e){var t=i[e];!1===t?r.removeAttribute(e):r.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach((function(e){var i=t.elements[e],r=t.attributes[e]||{},o=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce((function(e,t){return e[t]="",e}),{});Ml(i)&&kl(i)&&(Object.assign(i.style,o),Object.keys(r).forEach((function(e){i.removeAttribute(e)})))}))}},requires:["computeStyles"]};function Tl(e){return e.split("-")[0]}var Sl=Math.max,Nl=Math.min,Al=Math.round;function jl(){var e=navigator.userAgentData;return null!=e&&e.brands?e.brands.map((function(e){return e.brand+"/"+e.version})).join(" "):navigator.userAgent}function Ll(){return!/^((?!chrome|android).)*safari/i.test(jl())}function zl(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1);var i=e.getBoundingClientRect(),r=1,o=1;t&&Ml(e)&&(r=e.offsetWidth>0&&Al(i.width)/e.offsetWidth||1,o=e.offsetHeight>0&&Al(i.height)/e.offsetHeight||1);var s=(Cl(e)?El(e):window).visualViewport,a=!Ll()&&n,l=(i.left+(a&&s?s.offsetLeft:0))/r,c=(i.top+(a&&s?s.offsetTop:0))/o,u=i.width/r,p=i.height/o;return{width:u,height:p,top:c,right:l+u,bottom:c+p,left:l,x:l,y:c}}function Il(e){var t=zl(e),n=e.offsetWidth,i=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:i}}function Rl(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Ol(n)){var i=t;do{if(i&&e.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function Fl(e){return El(e).getComputedStyle(e)}function Bl(e){return["table","td","th"].indexOf(kl(e))>=0}function Pl(e){return((Cl(e)?e.ownerDocument:e.document)||window.document).documentElement}function Ul(e){return"html"===kl(e)?e:e.assignedSlot||e.parentNode||(Ol(e)?e.host:null)||Pl(e)}function Hl(e){return Ml(e)&&"fixed"!==Fl(e).position?e.offsetParent:null}function $l(e){for(var t=El(e),n=Hl(e);n&&Bl(n)&&"static"===Fl(n).position;)n=Hl(n);return n&&("html"===kl(n)||"body"===kl(n)&&"static"===Fl(n).position)?t:n||function(e){var t=/firefox/i.test(jl());if(/Trident/i.test(jl())&&Ml(e)&&"fixed"===Fl(e).position)return null;var n=Ul(e);for(Ol(n)&&(n=n.host);Ml(n)&&["html","body"].indexOf(kl(n))<0;){var i=Fl(n);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return n;n=n.parentNode}return null}(e)||t}function Wl(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function ql(e,t,n){return Sl(e,Nl(t,n))}function Vl(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function Kl(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}var Gl={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,i=e.name,r=e.options,o=n.elements.arrow,s=n.modifiersData.popperOffsets,a=Tl(n.placement),l=Wl(a),c=[pl,ul].indexOf(a)>=0?"height":"width";if(o&&s){var u=function(e,t){return Vl("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:Kl(e,hl))}(r.padding,n),p=Il(o),d="y"===l?ll:pl,h="y"===l?cl:ul,f=n.rects.reference[c]+n.rects.reference[l]-s[l]-n.rects.popper[c],m=s[l]-n.rects.reference[l],g=$l(o),b=g?"y"===l?g.clientHeight||0:g.clientWidth||0:0,v=f/2-m/2,y=u[d],x=b-p[c]-u[h],w=b/2-p[c]/2+v,_=ql(y,w,x),k=l;n.modifiersData[i]=((t={})[k]=_,t.centerOffset=_-w,t)}},effect:function(e){var t=e.state,n=e.options.element,i=void 0===n?"[data-popper-arrow]":n;null!=i&&("string"!=typeof i||(i=t.elements.popper.querySelector(i)))&&Rl(t.elements.popper,i)&&(t.elements.arrow=i)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Yl(e){return e.split("-")[1]}var Ql={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Zl(e){var t,n=e.popper,i=e.popperRect,r=e.placement,o=e.variation,s=e.offsets,a=e.position,l=e.gpuAcceleration,c=e.adaptive,u=e.roundOffsets,p=e.isFixed,d=s.x,h=void 0===d?0:d,f=s.y,m=void 0===f?0:f,g="function"==typeof u?u({x:h,y:m}):{x:h,y:m};h=g.x,m=g.y;var b=s.hasOwnProperty("x"),v=s.hasOwnProperty("y"),y=pl,x=ll,w=window;if(c){var _=$l(n),k="clientHeight",E="clientWidth";if(_===El(n)&&"static"!==Fl(_=Pl(n)).position&&"absolute"===a&&(k="scrollHeight",E="scrollWidth"),r===ll||(r===pl||r===ul)&&o===ml)x=cl,m-=(p&&_===w&&w.visualViewport?w.visualViewport.height:_[k])-i.height,m*=l?1:-1;if(r===pl||(r===ll||r===cl)&&o===ml)y=ul,h-=(p&&_===w&&w.visualViewport?w.visualViewport.width:_[E])-i.width,h*=l?1:-1}var C,M=Object.assign({position:a},c&&Ql),O=!0===u?function(e){var t=e.x,n=e.y,i=window.devicePixelRatio||1;return{x:Al(t*i)/i||0,y:Al(n*i)/i||0}}({x:h,y:m}):{x:h,y:m};return h=O.x,m=O.y,l?Object.assign({},M,((C={})[x]=v?"0":"",C[y]=b?"0":"",C.transform=(w.devicePixelRatio||1)<=1?"translate("+h+"px, "+m+"px)":"translate3d("+h+"px, "+m+"px, 0)",C)):Object.assign({},M,((t={})[x]=v?m+"px":"",t[y]=b?h+"px":"",t.transform="",t))}var Jl={passive:!0};var Xl={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,i=e.options,r=i.scroll,o=void 0===r||r,s=i.resize,a=void 0===s||s,l=El(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&c.forEach((function(e){e.addEventListener("scroll",n.update,Jl)})),a&&l.addEventListener("resize",n.update,Jl),function(){o&&c.forEach((function(e){e.removeEventListener("scroll",n.update,Jl)})),a&&l.removeEventListener("resize",n.update,Jl)}},data:{}},ec={left:"right",right:"left",bottom:"top",top:"bottom"};function tc(e){return e.replace(/left|right|bottom|top/g,(function(e){return ec[e]}))}var nc={start:"end",end:"start"};function ic(e){return e.replace(/start|end/g,(function(e){return nc[e]}))}function rc(e){var t=El(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function oc(e){return zl(Pl(e)).left+rc(e).scrollLeft}function sc(e){var t=Fl(e),n=t.overflow,i=t.overflowX,r=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+r+i)}function ac(e){return["html","body","#document"].indexOf(kl(e))>=0?e.ownerDocument.body:Ml(e)&&sc(e)?e:ac(Ul(e))}function lc(e,t){var n;void 0===t&&(t=[]);var i=ac(e),r=i===(null==(n=e.ownerDocument)?void 0:n.body),o=El(i),s=r?[o].concat(o.visualViewport||[],sc(i)?i:[]):i,a=t.concat(s);return r?a:a.concat(lc(Ul(s)))}function cc(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function uc(e,t,n){return t===bl?cc(function(e,t){var n=El(e),i=Pl(e),r=n.visualViewport,o=i.clientWidth,s=i.clientHeight,a=0,l=0;if(r){o=r.width,s=r.height;var c=Ll();(c||!c&&"fixed"===t)&&(a=r.offsetLeft,l=r.offsetTop)}return{width:o,height:s,x:a+oc(e),y:l}}(e,n)):Cl(t)?function(e,t){var n=zl(e,!1,"fixed"===t);return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}(t,n):cc(function(e){var t,n=Pl(e),i=rc(e),r=null==(t=e.ownerDocument)?void 0:t.body,o=Sl(n.scrollWidth,n.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),s=Sl(n.scrollHeight,n.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),a=-i.scrollLeft+oc(e),l=-i.scrollTop;return"rtl"===Fl(r||n).direction&&(a+=Sl(n.clientWidth,r?r.clientWidth:0)-o),{width:o,height:s,x:a,y:l}}(Pl(e)))}function pc(e,t,n,i){var r="clippingParents"===t?function(e){var t=lc(Ul(e)),n=["absolute","fixed"].indexOf(Fl(e).position)>=0&&Ml(e)?$l(e):e;return Cl(n)?t.filter((function(e){return Cl(e)&&Rl(e,n)&&"body"!==kl(e)})):[]}(e):[].concat(t),o=[].concat(r,[n]),s=o[0],a=o.reduce((function(t,n){var r=uc(e,n,i);return t.top=Sl(r.top,t.top),t.right=Nl(r.right,t.right),t.bottom=Nl(r.bottom,t.bottom),t.left=Sl(r.left,t.left),t}),uc(e,s,i));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function dc(e){var t,n=e.reference,i=e.element,r=e.placement,o=r?Tl(r):null,s=r?Yl(r):null,a=n.x+n.width/2-i.width/2,l=n.y+n.height/2-i.height/2;switch(o){case ll:t={x:a,y:n.y-i.height};break;case cl:t={x:a,y:n.y+n.height};break;case ul:t={x:n.x+n.width,y:l};break;case pl:t={x:n.x-i.width,y:l};break;default:t={x:n.x,y:n.y}}var c=o?Wl(o):null;if(null!=c){var u="y"===c?"height":"width";switch(s){case fl:t[c]=t[c]-(n[u]/2-i[u]/2);break;case ml:t[c]=t[c]+(n[u]/2-i[u]/2)}}return t}function hc(e,t){void 0===t&&(t={});var n=t,i=n.placement,r=void 0===i?e.placement:i,o=n.strategy,s=void 0===o?e.strategy:o,a=n.boundary,l=void 0===a?gl:a,c=n.rootBoundary,u=void 0===c?bl:c,p=n.elementContext,d=void 0===p?vl:p,h=n.altBoundary,f=void 0!==h&&h,m=n.padding,g=void 0===m?0:m,b=Vl("number"!=typeof g?g:Kl(g,hl)),v=d===vl?yl:vl,y=e.rects.popper,x=e.elements[f?v:d],w=pc(Cl(x)?x:x.contextElement||Pl(e.elements.popper),l,u,s),_=zl(e.elements.reference),k=dc({reference:_,element:y,strategy:"absolute",placement:r}),E=cc(Object.assign({},y,k)),C=d===vl?E:_,M={top:w.top-C.top+b.top,bottom:C.bottom-w.bottom+b.bottom,left:w.left-C.left+b.left,right:C.right-w.right+b.right},O=e.modifiersData.offset;if(d===vl&&O){var D=O[r];Object.keys(M).forEach((function(e){var t=[ul,cl].indexOf(e)>=0?1:-1,n=[ll,cl].indexOf(e)>=0?"y":"x";M[e]+=D[n]*t}))}return M}function fc(e,t){void 0===t&&(t={});var n=t,i=n.placement,r=n.boundary,o=n.rootBoundary,s=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=void 0===l?wl:l,u=Yl(i),p=u?a?xl:xl.filter((function(e){return Yl(e)===u})):hl,d=p.filter((function(e){return c.indexOf(e)>=0}));0===d.length&&(d=p);var h=d.reduce((function(t,n){return t[n]=hc(e,{placement:n,boundary:r,rootBoundary:o,padding:s})[Tl(n)],t}),{});return Object.keys(h).sort((function(e,t){return h[e]-h[t]}))}var mc={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,i=e.name;if(!t.modifiersData[i]._skip){for(var r=n.mainAxis,o=void 0===r||r,s=n.altAxis,a=void 0===s||s,l=n.fallbackPlacements,c=n.padding,u=n.boundary,p=n.rootBoundary,d=n.altBoundary,h=n.flipVariations,f=void 0===h||h,m=n.allowedAutoPlacements,g=t.options.placement,b=Tl(g),v=l||(b===g||!f?[tc(g)]:function(e){if(Tl(e)===dl)return[];var t=tc(e);return[ic(e),t,ic(t)]}(g)),y=[g].concat(v).reduce((function(e,n){return e.concat(Tl(n)===dl?fc(t,{placement:n,boundary:u,rootBoundary:p,padding:c,flipVariations:f,allowedAutoPlacements:m}):n)}),[]),x=t.rects.reference,w=t.rects.popper,_=new Map,k=!0,E=y[0],C=0;C<y.length;C++){var M=y[C],O=Tl(M),D=Yl(M)===fl,T=[ll,cl].indexOf(O)>=0,S=T?"width":"height",N=hc(t,{placement:M,boundary:u,rootBoundary:p,altBoundary:d,padding:c}),A=T?D?ul:pl:D?cl:ll;x[S]>w[S]&&(A=tc(A));var j=tc(A),L=[];if(o&&L.push(N[O]<=0),a&&L.push(N[A]<=0,N[j]<=0),L.every((function(e){return e}))){E=M,k=!1;break}_.set(M,L)}if(k)for(var z=function(e){var t=y.find((function(t){var n=_.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return E=t,"break"},I=f?3:1;I>0;I--){if("break"===z(I))break}t.placement!==E&&(t.modifiersData[i]._skip=!0,t.placement=E,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function gc(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function bc(e){return[ll,ul,cl,pl].some((function(t){return e[t]>=0}))}var vc={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,i=t.rects.reference,r=t.rects.popper,o=t.modifiersData.preventOverflow,s=hc(t,{elementContext:"reference"}),a=hc(t,{altBoundary:!0}),l=gc(s,i),c=gc(a,r,o),u=bc(l),p=bc(c);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:p},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":p})}};var yc={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.options,i=e.name,r=n.offset,o=void 0===r?[0,0]:r,s=wl.reduce((function(e,n){return e[n]=function(e,t,n){var i=Tl(e),r=[pl,ll].indexOf(i)>=0?-1:1,o="function"==typeof n?n(Object.assign({},t,{placement:e})):n,s=o[0],a=o[1];return s=s||0,a=(a||0)*r,[pl,ul].indexOf(i)>=0?{x:a,y:s}:{x:s,y:a}}(n,t.rects,o),e}),{}),a=s[t.placement],l=a.x,c=a.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[i]=s}};var xc={name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=dc({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}};var wc={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,i=e.name,r=n.mainAxis,o=void 0===r||r,s=n.altAxis,a=void 0!==s&&s,l=n.boundary,c=n.rootBoundary,u=n.altBoundary,p=n.padding,d=n.tether,h=void 0===d||d,f=n.tetherOffset,m=void 0===f?0:f,g=hc(t,{boundary:l,rootBoundary:c,padding:p,altBoundary:u}),b=Tl(t.placement),v=Yl(t.placement),y=!v,x=Wl(b),w="x"===x?"y":"x",_=t.modifiersData.popperOffsets,k=t.rects.reference,E=t.rects.popper,C="function"==typeof m?m(Object.assign({},t.rects,{placement:t.placement})):m,M="number"==typeof C?{mainAxis:C,altAxis:C}:Object.assign({mainAxis:0,altAxis:0},C),O=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,D={x:0,y:0};if(_){if(o){var T,S="y"===x?ll:pl,N="y"===x?cl:ul,A="y"===x?"height":"width",j=_[x],L=j+g[S],z=j-g[N],I=h?-E[A]/2:0,R=v===fl?k[A]:E[A],F=v===fl?-E[A]:-k[A],B=t.elements.arrow,P=h&&B?Il(B):{width:0,height:0},U=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},H=U[S],$=U[N],W=ql(0,k[A],P[A]),q=y?k[A]/2-I-W-H-M.mainAxis:R-W-H-M.mainAxis,V=y?-k[A]/2+I+W+$+M.mainAxis:F+W+$+M.mainAxis,K=t.elements.arrow&&$l(t.elements.arrow),G=K?"y"===x?K.clientTop||0:K.clientLeft||0:0,Y=null!=(T=null==O?void 0:O[x])?T:0,Q=j+V-Y,Z=ql(h?Nl(L,j+q-Y-G):L,j,h?Sl(z,Q):z);_[x]=Z,D[x]=Z-j}if(a){var J,X="x"===x?ll:pl,ee="x"===x?cl:ul,te=_[w],ne="y"===w?"height":"width",ie=te+g[X],re=te-g[ee],oe=-1!==[ll,pl].indexOf(b),se=null!=(J=null==O?void 0:O[w])?J:0,ae=oe?ie:te-k[ne]-E[ne]-se+M.altAxis,le=oe?te+k[ne]+E[ne]-se-M.altAxis:re,ce=h&&oe?function(e,t,n){var i=ql(e,t,n);return i>n?n:i}(ae,te,le):ql(h?ae:ie,te,h?le:re);_[w]=ce,D[w]=ce-te}t.modifiersData[i]=D}},requiresIfExists:["offset"]};function _c(e,t,n){void 0===n&&(n=!1);var i=Ml(t),r=Ml(t)&&function(e){var t=e.getBoundingClientRect(),n=Al(t.width)/e.offsetWidth||1,i=Al(t.height)/e.offsetHeight||1;return 1!==n||1!==i}(t),o=Pl(t),s=zl(e,r,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(i||!i&&!n)&&(("body"!==kl(t)||sc(o))&&(a=function(e){return e!==El(e)&&Ml(e)?{scrollLeft:(t=e).scrollLeft,scrollTop:t.scrollTop}:rc(e);var t}(t)),Ml(t)?((l=zl(t,!0)).x+=t.clientLeft,l.y+=t.clientTop):o&&(l.x=oc(o))),{x:s.left+a.scrollLeft-l.x,y:s.top+a.scrollTop-l.y,width:s.width,height:s.height}}function kc(e){var t=new Map,n=new Set,i=[];function r(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var i=t.get(e);i&&r(i)}})),i.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||r(e)})),i}var Ec={placement:"bottom",modifiers:[],strategy:"absolute"};function Cc(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some((function(e){return!(e&&"function"==typeof e.getBoundingClientRect)}))}function Mc(e){void 0===e&&(e={});var t=e,n=t.defaultModifiers,i=void 0===n?[]:n,r=t.defaultOptions,o=void 0===r?Ec:r;return function(e,t,n){void 0===n&&(n=o);var r,s,a={placement:"bottom",orderedModifiers:[],options:Object.assign({},Ec,o),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},l=[],c=!1,u={state:a,setOptions:function(n){var r="function"==typeof n?n(a.options):n;p(),a.options=Object.assign({},o,a.options,r),a.scrollParents={reference:Cl(e)?lc(e):e.contextElement?lc(e.contextElement):[],popper:lc(t)};var s=function(e){var t=kc(e);return _l.reduce((function(e,n){return e.concat(t.filter((function(e){return e.phase===n})))}),[])}(function(e){var t=e.reduce((function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e}),{});return Object.keys(t).map((function(e){return t[e]}))}([].concat(i,a.options.modifiers)));return a.orderedModifiers=s.filter((function(e){return e.enabled})),a.orderedModifiers.forEach((function(e){var t=e.name,n=e.options,i=void 0===n?{}:n,r=e.effect;if("function"==typeof r){var o=r({state:a,name:t,instance:u,options:i}),s=function(){};l.push(o||s)}})),u.update()},forceUpdate:function(){if(!c){var e=a.elements,t=e.reference,n=e.popper;if(Cc(t,n)){a.rects={reference:_c(t,$l(n),"fixed"===a.options.strategy),popper:Il(n)},a.reset=!1,a.placement=a.options.placement,a.orderedModifiers.forEach((function(e){return a.modifiersData[e.name]=Object.assign({},e.data)}));for(var i=0;i<a.orderedModifiers.length;i++)if(!0!==a.reset){var r=a.orderedModifiers[i],o=r.fn,s=r.options,l=void 0===s?{}:s,p=r.name;"function"==typeof o&&(a=o({state:a,options:l,name:p,instance:u})||a)}else a.reset=!1,i=-1}}},update:(r=function(){return new Promise((function(e){u.forceUpdate(),e(a)}))},function(){return s||(s=new Promise((function(e){Promise.resolve().then((function(){s=void 0,e(r())}))}))),s}),destroy:function(){p(),c=!0}};if(!Cc(e,t))return u;function p(){l.forEach((function(e){return e()})),l=[]}return u.setOptions(n).then((function(e){!c&&n.onFirstUpdate&&n.onFirstUpdate(e)})),u}}var Oc=Mc({defaultModifiers:[Xl,xc,{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,n=e.options,i=n.gpuAcceleration,r=void 0===i||i,o=n.adaptive,s=void 0===o||o,a=n.roundOffsets,l=void 0===a||a,c={placement:Tl(t.placement),variation:Yl(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:r,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,Zl(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:s,roundOffsets:l})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,Zl(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},Dl,yc,mc,wc,Gl,vc]}),Dc='<svg width="16" height="6" xmlns="http://www.w3.org/2000/svg"><path d="M0 6s1.796-.013 4.67-3.615C5.851.9 6.93.006 8 0c1.07-.006 2.148.887 3.343 2.385C14.233 6.005 16 6 16 6H0z"></svg>',Tc="tippy-box",Sc="tippy-content",Nc="tippy-backdrop",Ac="tippy-arrow",jc="tippy-svg-arrow",Lc={passive:!0,capture:!0},zc=function(){return document.body};function Ic(e,t,n){if(Array.isArray(e)){var i=e[t];return null==i?Array.isArray(n)?n[t]:n:i}return e}function Rc(e,t){var n={}.toString.call(e);return 0===n.indexOf("[object")&&n.indexOf(t+"]")>-1}function Fc(e,t){return"function"==typeof e?e.apply(void 0,t):e}function Bc(e,t){return 0===t?e:function(i){clearTimeout(n),n=setTimeout((function(){e(i)}),t)};var n}function Pc(e){return[].concat(e)}function Uc(e,t){-1===e.indexOf(t)&&e.push(t)}function Hc(e){return[].slice.call(e)}function $c(e){return Object.keys(e).reduce((function(t,n){return void 0!==e[n]&&(t[n]=e[n]),t}),{})}function Wc(){return document.createElement("div")}function qc(e){return["Element","Fragment"].some((function(t){return Rc(e,t)}))}function Vc(e){return Rc(e,"MouseEvent")}function Kc(e){return qc(e)?[e]:function(e){return Rc(e,"NodeList")}(e)?Hc(e):Array.isArray(e)?e:Hc(document.querySelectorAll(e))}function Gc(e,t){e.forEach((function(e){e&&(e.style.transitionDuration=t+"ms")}))}function Yc(e,t){e.forEach((function(e){e&&e.setAttribute("data-state",t)}))}function Qc(e){var t,n=Pc(e)[0];return null!=n&&null!=(t=n.ownerDocument)&&t.body?n.ownerDocument:document}function Zc(e,t,n){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach((function(t){e[i](t,n)}))}function Jc(e,t){for(var n=t;n;){var i;if(e.contains(n))return!0;n=null==n.getRootNode||null==(i=n.getRootNode())?void 0:i.host}return!1}var Xc={isTouch:!1},eu=0;function tu(){Xc.isTouch||(Xc.isTouch=!0,window.performance&&document.addEventListener("mousemove",nu))}function nu(){var e=performance.now();e-eu<20&&(Xc.isTouch=!1,document.removeEventListener("mousemove",nu)),eu=e}function iu(){var e,t=document.activeElement;if((e=t)&&e._tippy&&e._tippy.reference===e){var n=t._tippy;t.blur&&!n.state.isVisible&&t.blur()}}var ru=!!("undefined"!=typeof window&&"undefined"!=typeof document)&&!!window.msCrypto,ou=Object.assign({appendTo:zc,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},{animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},{allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999}),su=Object.keys(ou);function au(e){var t=(e.plugins||[]).reduce((function(t,n){var i,r=n.name,o=n.defaultValue;r&&(t[r]=void 0!==e[r]?e[r]:null!=(i=ou[r])?i:o);return t}),{});return Object.assign({},e,t)}function lu(e,t){var n=Object.assign({},t,{content:Fc(t.content,[e])},t.ignoreAttributes?{}:function(e,t){return(t?Object.keys(au(Object.assign({},ou,{plugins:t}))):su).reduce((function(t,n){var i=(e.getAttribute("data-tippy-"+n)||"").trim();if(!i)return t;if("content"===n)t[n]=i;else try{t[n]=JSON.parse(i)}catch(e){t[n]=i}return t}),{})}(e,t.plugins));return n.aria=Object.assign({},ou.aria,n.aria),n.aria={expanded:"auto"===n.aria.expanded?t.interactive:n.aria.expanded,content:"auto"===n.aria.content?t.interactive?null:"describedby":n.aria.content},n}function cu(e,t){e["innerHTML"]=t}function uu(e){var t=Wc();return!0===e?t.className=Ac:(t.className=jc,qc(e)?t.appendChild(e):cu(t,e)),t}function pu(e,t){qc(t.content)?(cu(e,""),e.appendChild(t.content)):"function"!=typeof t.content&&(t.allowHTML?cu(e,t.content):e.textContent=t.content)}function du(e){var t=e.firstElementChild,n=Hc(t.children);return{box:t,content:n.find((function(e){return e.classList.contains(Sc)})),arrow:n.find((function(e){return e.classList.contains(Ac)||e.classList.contains(jc)})),backdrop:n.find((function(e){return e.classList.contains(Nc)}))}}function hu(e){var t=Wc(),n=Wc();n.className=Tc,n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var i=Wc();function r(n,i){var r=du(t),o=r.box,s=r.content,a=r.arrow;i.theme?o.setAttribute("data-theme",i.theme):o.removeAttribute("data-theme"),"string"==typeof i.animation?o.setAttribute("data-animation",i.animation):o.removeAttribute("data-animation"),i.inertia?o.setAttribute("data-inertia",""):o.removeAttribute("data-inertia"),o.style.maxWidth="number"==typeof i.maxWidth?i.maxWidth+"px":i.maxWidth,i.role?o.setAttribute("role",i.role):o.removeAttribute("role"),n.content===i.content&&n.allowHTML===i.allowHTML||pu(s,e.props),i.arrow?a?n.arrow!==i.arrow&&(o.removeChild(a),o.appendChild(uu(i.arrow))):o.appendChild(uu(i.arrow)):a&&o.removeChild(a)}return i.className=Sc,i.setAttribute("data-state","hidden"),pu(i,e.props),t.appendChild(n),n.appendChild(i),r(e.props,e.props),{popper:t,onUpdate:r}}hu.$$tippy=!0;var fu=1,mu=[],gu=[];function bu(e,t){var n,i,r,o,s,a,l,c,u=lu(e,Object.assign({},ou,au($c(t)))),p=!1,d=!1,h=!1,f=!1,m=[],g=Bc(K,u.interactiveDebounce),b=fu++,v=(c=u.plugins).filter((function(e,t){return c.indexOf(e)===t})),y={id:b,reference:e,popper:Wc(),popperInstance:null,props:u,state:{isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},plugins:v,clearDelayTimeouts:function(){clearTimeout(n),clearTimeout(i),cancelAnimationFrame(r)},setProps:function(t){if(y.state.isDestroyed)return;j("onBeforeUpdate",[y,t]),q();var n=y.props,i=lu(e,Object.assign({},n,$c(t),{ignoreAttributes:!0}));y.props=i,W(),n.interactiveDebounce!==i.interactiveDebounce&&(I(),g=Bc(K,i.interactiveDebounce));n.triggerTarget&&!i.triggerTarget?Pc(n.triggerTarget).forEach((function(e){e.removeAttribute("aria-expanded")})):i.triggerTarget&&e.removeAttribute("aria-expanded");z(),A(),_&&_(n,i);y.popperInstance&&(Z(),X().forEach((function(e){requestAnimationFrame(e._tippy.popperInstance.forceUpdate)})));j("onAfterUpdate",[y,t])},setContent:function(e){y.setProps({content:e})},show:function(){var e=y.state.isVisible,t=y.state.isDestroyed,n=!y.state.isEnabled,i=Xc.isTouch&&!y.props.touch,r=Ic(y.props.duration,0,ou.duration);if(e||t||n||i)return;if(D().hasAttribute("disabled"))return;if(j("onShow",[y],!1),!1===y.props.onShow(y))return;y.state.isVisible=!0,O()&&(w.style.visibility="visible");A(),P(),y.state.isMounted||(w.style.transition="none");if(O()){var o=S(),s=o.box,l=o.content;Gc([s,l],0)}a=function(){var e;if(y.state.isVisible&&!f){if(f=!0,w.offsetHeight,w.style.transition=y.props.moveTransition,O()&&y.props.animation){var t=S(),n=t.box,i=t.content;Gc([n,i],r),Yc([n,i],"visible")}L(),z(),Uc(gu,y),null==(e=y.popperInstance)||e.forceUpdate(),j("onMount",[y]),y.props.animation&&O()&&function(e,t){H(e,t)}(r,(function(){y.state.isShown=!0,j("onShown",[y])}))}},function(){var e,t=y.props.appendTo,n=D();e=y.props.interactive&&t===zc||"parent"===t?n.parentNode:Fc(t,[n]);e.contains(w)||e.appendChild(w);y.state.isMounted=!0,Z()}()},hide:function(){var e=!y.state.isVisible,t=y.state.isDestroyed,n=!y.state.isEnabled,i=Ic(y.props.duration,1,ou.duration);if(e||t||n)return;if(j("onHide",[y],!1),!1===y.props.onHide(y))return;y.state.isVisible=!1,y.state.isShown=!1,f=!1,p=!1,O()&&(w.style.visibility="hidden");if(I(),U(),A(!0),O()){var r=S(),o=r.box,s=r.content;y.props.animation&&(Gc([o,s],i),Yc([o,s],"hidden"))}L(),z(),y.props.animation?O()&&function(e,t){H(e,(function(){!y.state.isVisible&&w.parentNode&&w.parentNode.contains(w)&&t()}))}(i,y.unmount):y.unmount()},hideWithInteractivity:function(e){T().addEventListener("mousemove",g),Uc(mu,g),g(e)},enable:function(){y.state.isEnabled=!0},disable:function(){y.hide(),y.state.isEnabled=!1},unmount:function(){y.state.isVisible&&y.hide();if(!y.state.isMounted)return;J(),X().forEach((function(e){e._tippy.unmount()})),w.parentNode&&w.parentNode.removeChild(w);gu=gu.filter((function(e){return e!==y})),y.state.isMounted=!1,j("onHidden",[y])},destroy:function(){if(y.state.isDestroyed)return;y.clearDelayTimeouts(),y.unmount(),q(),delete e._tippy,y.state.isDestroyed=!0,j("onDestroy",[y])}};if(!u.render)return y;var x=u.render(y),w=x.popper,_=x.onUpdate;w.setAttribute("data-tippy-root",""),w.id="tippy-"+y.id,y.popper=w,e._tippy=y,w._tippy=y;var k=v.map((function(e){return e.fn(y)})),E=e.hasAttribute("aria-expanded");return W(),z(),A(),j("onCreate",[y]),u.showOnCreate&&ee(),w.addEventListener("mouseenter",(function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()})),w.addEventListener("mouseleave",(function(){y.props.interactive&&y.props.trigger.indexOf("mouseenter")>=0&&T().addEventListener("mousemove",g)})),y;function C(){var e=y.props.touch;return Array.isArray(e)?e:[e,0]}function M(){return"hold"===C()[0]}function O(){var e;return!(null==(e=y.props.render)||!e.$$tippy)}function D(){return l||e}function T(){var e=D().parentNode;return e?Qc(e):document}function S(){return du(w)}function N(e){return y.state.isMounted&&!y.state.isVisible||Xc.isTouch||o&&"focus"===o.type?0:Ic(y.props.delay,e?0:1,ou.delay)}function A(e){void 0===e&&(e=!1),w.style.pointerEvents=y.props.interactive&&!e?"":"none",w.style.zIndex=""+y.props.zIndex}function j(e,t,n){var i;(void 0===n&&(n=!0),k.forEach((function(n){n[e]&&n[e].apply(n,t)})),n)&&(i=y.props)[e].apply(i,t)}function L(){var t=y.props.aria;if(t.content){var n="aria-"+t.content,i=w.id;Pc(y.props.triggerTarget||e).forEach((function(e){var t=e.getAttribute(n);if(y.state.isVisible)e.setAttribute(n,t?t+" "+i:i);else{var r=t&&t.replace(i,"").trim();r?e.setAttribute(n,r):e.removeAttribute(n)}}))}}function z(){!E&&y.props.aria.expanded&&Pc(y.props.triggerTarget||e).forEach((function(e){y.props.interactive?e.setAttribute("aria-expanded",y.state.isVisible&&e===D()?"true":"false"):e.removeAttribute("aria-expanded")}))}function I(){T().removeEventListener("mousemove",g),mu=mu.filter((function(e){return e!==g}))}function R(t){if(!Xc.isTouch||!h&&"mousedown"!==t.type){var n=t.composedPath&&t.composedPath()[0]||t.target;if(!y.props.interactive||!Jc(w,n)){if(Pc(y.props.triggerTarget||e).some((function(e){return Jc(e,n)}))){if(Xc.isTouch)return;if(y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else j("onClickOutside",[y,t]);!0===y.props.hideOnClick&&(y.clearDelayTimeouts(),y.hide(),d=!0,setTimeout((function(){d=!1})),y.state.isMounted||U())}}}function F(){h=!0}function B(){h=!1}function P(){var e=T();e.addEventListener("mousedown",R,!0),e.addEventListener("touchend",R,Lc),e.addEventListener("touchstart",B,Lc),e.addEventListener("touchmove",F,Lc)}function U(){var e=T();e.removeEventListener("mousedown",R,!0),e.removeEventListener("touchend",R,Lc),e.removeEventListener("touchstart",B,Lc),e.removeEventListener("touchmove",F,Lc)}function H(e,t){var n=S().box;function i(e){e.target===n&&(Zc(n,"remove",i),t())}if(0===e)return t();Zc(n,"remove",s),Zc(n,"add",i),s=i}function $(t,n,i){void 0===i&&(i=!1),Pc(y.props.triggerTarget||e).forEach((function(e){e.addEventListener(t,n,i),m.push({node:e,eventType:t,handler:n,options:i})}))}function W(){var e;M()&&($("touchstart",V,{passive:!0}),$("touchend",G,{passive:!0})),(e=y.props.trigger,e.split(/\s+/).filter(Boolean)).forEach((function(e){if("manual"!==e)switch($(e,V),e){case"mouseenter":$("mouseleave",G);break;case"focus":$(ru?"focusout":"blur",Y);break;case"focusin":$("focusout",Y)}}))}function q(){m.forEach((function(e){var t=e.node,n=e.eventType,i=e.handler,r=e.options;t.removeEventListener(n,i,r)})),m=[]}function V(e){var t,n=!1;if(y.state.isEnabled&&!Q(e)&&!d){var i="focus"===(null==(t=o)?void 0:t.type);o=e,l=e.currentTarget,z(),!y.state.isVisible&&Vc(e)&&mu.forEach((function(t){return t(e)})),"click"===e.type&&(y.props.trigger.indexOf("mouseenter")<0||p)&&!1!==y.props.hideOnClick&&y.state.isVisible?n=!0:ee(e),"click"===e.type&&(p=!n),n&&!i&&te(e)}}function K(e){var t=e.target,n=D().contains(t)||w.contains(t);if("mousemove"!==e.type||!n){var i=X().concat(w).map((function(e){var t,n=null==(t=e._tippy.popperInstance)?void 0:t.state;return n?{popperRect:e.getBoundingClientRect(),popperState:n,props:u}:null})).filter(Boolean);(function(e,t){var n=t.clientX,i=t.clientY;return e.every((function(e){var t=e.popperRect,r=e.popperState,o=e.props.interactiveBorder,s=r.placement.split("-")[0],a=r.modifiersData.offset;if(!a)return!0;var l="bottom"===s?a.top.y:0,c="top"===s?a.bottom.y:0,u="right"===s?a.left.x:0,p="left"===s?a.right.x:0,d=t.top-i+l>o,h=i-t.bottom-c>o,f=t.left-n+u>o,m=n-t.right-p>o;return d||h||f||m}))})(i,e)&&(I(),te(e))}}function G(e){Q(e)||y.props.trigger.indexOf("click")>=0&&p||(y.props.interactive?y.hideWithInteractivity(e):te(e))}function Y(e){y.props.trigger.indexOf("focusin")<0&&e.target!==D()||y.props.interactive&&e.relatedTarget&&w.contains(e.relatedTarget)||te(e)}function Q(e){return!!Xc.isTouch&&M()!==e.type.indexOf("touch")>=0}function Z(){J();var t=y.props,n=t.popperOptions,i=t.placement,r=t.offset,o=t.getReferenceClientRect,s=t.moveTransition,l=O()?du(w).arrow:null,c=o?{getBoundingClientRect:o,contextElement:o.contextElement||D()}:e,u={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(e){var t=e.state;if(O()){var n=S().box;["placement","reference-hidden","escaped"].forEach((function(e){"placement"===e?n.setAttribute("data-placement",t.placement):t.attributes.popper["data-popper-"+e]?n.setAttribute("data-"+e,""):n.removeAttribute("data-"+e)})),t.attributes.popper={}}}},p=[{name:"offset",options:{offset:r}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!s}},u];O()&&l&&p.push({name:"arrow",options:{element:l,padding:3}}),p.push.apply(p,(null==n?void 0:n.modifiers)||[]),y.popperInstance=Oc(c,w,Object.assign({},n,{placement:i,onFirstUpdate:a,modifiers:p}))}function J(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function X(){return Hc(w.querySelectorAll("[data-tippy-root]"))}function ee(e){y.clearDelayTimeouts(),e&&j("onTrigger",[y,e]),P();var t=N(!0),i=C(),r=i[0],o=i[1];Xc.isTouch&&"hold"===r&&o&&(t=o),t?n=setTimeout((function(){y.show()}),t):y.show()}function te(e){if(y.clearDelayTimeouts(),j("onUntrigger",[y,e]),y.state.isVisible){if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(e.type)>=0&&p)){var t=N(!1);t?i=setTimeout((function(){y.state.isVisible&&y.hide()}),t):r=requestAnimationFrame((function(){y.hide()}))}}else U()}}function vu(e,t){void 0===t&&(t={});var n=ou.plugins.concat(t.plugins||[]);document.addEventListener("touchstart",tu,Lc),window.addEventListener("blur",iu);var i=Object.assign({},t,{plugins:n}),r=Kc(e).reduce((function(e,t){var n=t&&bu(t,i);return n&&e.push(n),e}),[]);return qc(e)?r[0]:r}vu.defaultProps=ou,vu.setDefaultProps=function(e){Object.keys(e).forEach((function(t){ou[t]=e[t]}))},vu.currentInput=Xc,Object.assign({},Dl,{effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow)}});var yu={clientX:0,clientY:0},xu=[];function wu(e){var t=e.clientX,n=e.clientY;yu={clientX:t,clientY:n}}var _u={name:"followCursor",defaultValue:!1,fn:function(e){var t=e.reference,n=Qc(e.props.triggerTarget||t),i=!1,r=!1,o=!0,s=e.props;function a(){return"initial"===e.props.followCursor&&e.state.isVisible}function l(){n.addEventListener("mousemove",p)}function c(){n.removeEventListener("mousemove",p)}function u(){i=!0,e.setProps({getReferenceClientRect:null}),i=!1}function p(n){var i=!n.target||t.contains(n.target),r=e.props.followCursor,o=n.clientX,s=n.clientY,a=t.getBoundingClientRect(),l=o-a.left,c=s-a.top;!i&&e.props.interactive||e.setProps({getReferenceClientRect:function(){var e=t.getBoundingClientRect(),n=o,i=s;"initial"===r&&(n=e.left+l,i=e.top+c);var a="horizontal"===r?e.top:i,u="vertical"===r?e.right:n,p="horizontal"===r?e.bottom:i,d="vertical"===r?e.left:n;return{width:u-d,height:p-a,top:a,right:u,bottom:p,left:d}}})}function d(){e.props.followCursor&&(xu.push({instance:e,doc:n}),function(e){e.addEventListener("mousemove",wu)}(n))}function h(){xu=xu.filter((function(t){return t.instance!==e})),0===xu.filter((function(e){return e.doc===n})).length&&function(e){e.removeEventListener("mousemove",wu)}(n)}return{onCreate:d,onDestroy:h,onBeforeUpdate:function(){s=e.props},onAfterUpdate:function(t,n){var o=n.followCursor;i||void 0!==o&&s.followCursor!==o&&(h(),o?(d(),!e.state.isMounted||r||a()||l()):(c(),u()))},onMount:function(){e.props.followCursor&&!r&&(o&&(p(yu),o=!1),a()||l())},onTrigger:function(e,t){Vc(t)&&(yu={clientX:t.clientX,clientY:t.clientY}),r="focus"===t.type},onHidden:function(){e.props.followCursor&&(u(),c(),o=!0)}}}};vu.setDefaultProps({render:hu});class ku{constructor({editor:e,element:t,view:n,tippyOptions:i={},shouldShow:r}){this.preventHide=!1,this.shouldShow=({view:e,state:t,from:n,to:i})=>{const{doc:r,selection:o}=t,{empty:s}=o,a=!r.textBetween(n,i).length&&ka(t.selection),l=this.element.contains(document.activeElement);return!(!e.hasFocus()&&!l||s||a||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout((()=>this.update(this.editor.view)))},this.blurHandler=({event:e})=>{var t;this.preventHide?this.preventHide=!1:(null==e?void 0:e.relatedTarget)&&(null===(t=this.element.parentNode)||void 0===t?void 0:t.contains(e.relatedTarget))||this.hide()},this.editor=e,this.element=t,this.view=n,r&&(this.shouldShow=r),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=i,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:e}=this.editor.options,t=!!e.parentElement;!this.tippy&&t&&(this.tippy=vu(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",(e=>{this.blurHandler({event:e})})))}update(e,t){var n,i,r;const{state:o,composing:s}=e,{doc:a,selection:l}=o,c=t&&t.doc.eq(a)&&t.selection.eq(l);if(s||c)return;this.createTooltip();const{ranges:u}=l,p=Math.min(...u.map((e=>e.$from.pos))),d=Math.max(...u.map((e=>e.$to.pos)));(null===(n=this.shouldShow)||void 0===n?void 0:n.call(this,{editor:this.editor,view:e,state:o,oldState:t,from:p,to:d}))?(null===(i=this.tippy)||void 0===i||i.setProps({getReferenceClientRect:(null===(r=this.tippyOptions)||void 0===r?void 0:r.getReferenceClientRect)||(()=>{if(o.selection instanceof $n){const t=e.nodeDOM(p);if(t)return t.getBoundingClientRect()}return Ha(e,p,d)})}),this.show()):this.hide()}show(){var e;null===(e=this.tippy)||void 0===e||e.show()}hide(){var e;null===(e=this.tippy)||void 0===e||e.hide()}destroy(){var e;null===(e=this.tippy)||void 0===e||e.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const Eu=e=>new oi({key:"string"==typeof e.pluginKey?new li(e.pluginKey):e.pluginKey,view:t=>new ku({view:t,...e})});fa.create({name:"bubbleMenu",addOptions:()=>({element:null,tippyOptions:{},pluginKey:"bubbleMenu",shouldShow:null}),addProseMirrorPlugins(){return this.options.element?[Eu({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,shouldShow:this.options.shouldShow})]:[]}});class Cu{constructor({editor:e,element:t,view:n,tippyOptions:i={},shouldShow:r}){this.preventHide=!1,this.shouldShow=({view:e,state:t})=>{const{selection:n}=t,{$anchor:i,empty:r}=n,o=1===i.depth,s=i.parent.isTextblock&&!i.parent.type.spec.code&&!i.parent.textContent;return!!(e.hasFocus()&&r&&o&&s&&this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout((()=>this.update(this.editor.view)))},this.blurHandler=({event:e})=>{var t;this.preventHide?this.preventHide=!1:(null==e?void 0:e.relatedTarget)&&(null===(t=this.element.parentNode)||void 0===t?void 0:t.contains(e.relatedTarget))||this.hide()},this.editor=e,this.element=t,this.view=n,r&&(this.shouldShow=r),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=i,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:e}=this.editor.options,t=!!e.parentElement;!this.tippy&&t&&(this.tippy=vu(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"right",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",(e=>{this.blurHandler({event:e})})))}update(e,t){var n,i,r;const{state:o}=e,{doc:s,selection:a}=o,{from:l,to:c}=a;if(t&&t.doc.eq(s)&&t.selection.eq(a))return;this.createTooltip();(null===(n=this.shouldShow)||void 0===n?void 0:n.call(this,{editor:this.editor,view:e,state:o,oldState:t}))?(null===(i=this.tippy)||void 0===i||i.setProps({getReferenceClientRect:(null===(r=this.tippyOptions)||void 0===r?void 0:r.getReferenceClientRect)||(()=>Ha(e,l,c))}),this.show()):this.hide()}show(){var e;null===(e=this.tippy)||void 0===e||e.show()}hide(){var e;null===(e=this.tippy)||void 0===e||e.hide()}destroy(){var e;null===(e=this.tippy)||void 0===e||e.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}fa.create({name:"floatingMenu",addOptions:()=>({element:null,tippyOptions:{},pluginKey:"floatingMenu",shouldShow:null}),addProseMirrorPlugins(){return this.options.element?[(e={pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,shouldShow:this.options.shouldShow},new oi({key:"string"==typeof e.pluginKey?new li(e.pluginKey):e.pluginKey,view:t=>new Cu({view:t,...e})}))]:[];var e}});const Mu=e=>{const[n,i]=r(null);return o((()=>{if(!n)return;if(e.editor.isDestroyed)return;const{pluginKey:t="bubbleMenu",editor:i,tippyOptions:r={},shouldShow:o=null}=e,s=Eu({pluginKey:t,editor:i,element:n,tippyOptions:r,shouldShow:o});return i.registerPlugin(s),()=>i.unregisterPlugin(t)}),[e.editor,n]),t.createElement("div",{ref:i,className:e.className,style:{visibility:"hidden"}},e.children)};class Ou extends class extends class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach((e=>e.apply(this,t))),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter((e=>e!==t)):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),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),window.setTimeout((()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))}),0)}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&&document&&(this.css=function(e,t){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const i=document.createElement("style");return t&&i.setAttribute("nonce",t),i.setAttribute("data-tiptap-style",""),i.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(i),i}(el,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.view&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e){this.setOptions({editable:e}),this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const n=Js(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:n});this.view.updateState(i)}unregisterPlugin(e){if(this.isDestroyed)return;const t="string"==typeof e?`${e}$`:e.key,n=this.state.reconfigure({plugins:this.state.plugins.filter((e=>!e.key.startsWith(t)))});this.view.updateState(n)}createExtensionManager(){const e=[...this.options.enableCoreExtensions?Object.values(Xa):[],...this.options.extensions].filter((e=>["extension","node","mark"].includes(null==e?void 0:e.type)));this.extensionManager=new pa(e,this)}createCommandManager(){this.commandManager=new qs({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=ja(this.options.content,this.schema,this.options.parseOptions),t=Ca(e,this.options.autofocus);this.view=new ms(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:ii.create({doc:e,selection:t||void 0})});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews();this.view.dom.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach((e=>{var t;return null===(t=this.capturedTransaction)||void 0===t?void 0:t.step(e)})):void(this.capturedTransaction=e);const t=this.state.apply(e),n=!this.state.selection.eq(t.selection);this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),n&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),r=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),r&&this.emit("blur",{editor:this,event:r.event,transaction:e}),e.docChanged&&!e.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return Ra(this.state,e)}isActive(e,t){const n="string"==typeof e?e:null,i="string"==typeof e?t:e;return function(e,t,n={}){if(!t)return Sa(e,null,n)||Pa(e,null,n);const i=Na(t,e.schema);return"node"===i?Sa(e,t,n):"mark"===i&&Pa(e,t,n)}(this.state,n,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return function(e,t){const n=$t.fromSchema(t).serializeFragment(e),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t="\n\n",textSerializers:n={}}=e||{};return function(e,t){return ma(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:t,textSerializers:{...n,...ga(this.schema)}})}get isEmpty(){return function(e){var t;const n=null===(t=e.type.createAndFill())||void 0===t?void 0:t.toJSON(),i=e.toJSON();return JSON.stringify(n)===JSON.stringify(i)}(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(null===(e=this.view)||void 0===e?void 0:e.docView)}}{constructor(){super(...arguments),this.contentComponent=null}}const Du=({renderers:e})=>t.createElement(t.Fragment,null,Array.from(e).map((([e,t])=>f.createPortal(t.reactElement,t.element,e))));class Tu extends t.Component{constructor(e){super(e),this.editorContentRef=t.createRef(),this.state={renderers:new Map}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const{editor:e}=this.props;if(e&&e.options.element){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.options.element.childNodes),e.setOptions({element:t}),e.contentComponent=this,e.createNodeViews()}}componentWillUnmount(){const{editor:e}=this.props;if(!e)return;if(e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null,!e.options.element.firstChild)return;const t=document.createElement("div");t.append(...e.options.element.childNodes),e.setOptions({element:t})}render(){const{editor:e,...n}=this.props;return t.createElement(t.Fragment,null,t.createElement("div",{ref:this.editorContentRef,...n}),t.createElement(Du,{renderers:this.state.renderers}))}}const Su=t.memo(Tu),Nu=n({onDragStart:void 0}),Au=()=>i(Nu),ju=e=>{const n=e.as||"div",{nodeViewContentRef:i}=Au();return t.createElement(n,{...e,ref:i,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...e.style}})},Lu=t.forwardRef(((e,n)=>{const{onDragStart:i}=Au(),r=e.as||"div";return t.createElement(r,{...e,ref:n,"data-node-view-wrapper":"",onDragStart:i,style:{whiteSpace:"normal",...e.style}})}));class zu{constructor(e,{editor:t,props:n={},as:i="div",className:r=""}){this.ref=null,this.id=Math.floor(4294967295*Math.random()).toString(),this.component=e,this.editor=t,this.props=n,this.element=document.createElement(i),this.element.classList.add("react-renderer"),r&&this.element.classList.add(...r.split(" ")),this.render()}render(){const e=this.component,n=this.props;(function(e){return!("function"!=typeof e||!e.prototype||!e.prototype.isReactComponent)}(e)||function(e){var t;return!("object"!=typeof e||"Symbol(react.forward_ref)"!==(null===(t=e.$$typeof)||void 0===t?void 0:t.toString()))}(e))&&(n.ref=e=>{this.ref=e}),this.reactElement=t.createElement(e,{...n}),queueMicrotask((()=>{m((()=>{var e;(null===(e=this.editor)||void 0===e?void 0:e.contentComponent)&&this.editor.contentComponent.setState({renderers:this.editor.contentComponent.state.renderers.set(this.id,this)})}))}))}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){queueMicrotask((()=>{m((()=>{var e;if(null===(e=this.editor)||void 0===e?void 0:e.contentComponent){const{renderers:e}=this.editor.contentComponent.state;e.delete(this.id),this.editor.contentComponent.setState({renderers:e})}}))}))}}class Iu extends class{constructor(e,t,n){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,n,i,r,o,s,a;const{view:l}=this.editor,c=e.target,u=3===c.nodeType?null===(t=c.parentElement)||void 0===t?void 0:t.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(null===(n=this.contentDOM)||void 0===n?void 0:n.contains(c))||!u)return;let p=0,d=0;if(this.dom!==u){const t=this.dom.getBoundingClientRect(),n=u.getBoundingClientRect(),a=null!==(i=e.offsetX)&&void 0!==i?i:null===(r=e.nativeEvent)||void 0===r?void 0:r.offsetX,l=null!==(o=e.offsetY)&&void 0!==o?o:null===(s=e.nativeEvent)||void 0===s?void 0:s.offsetY;p=n.x-t.x+a,d=n.y-t.y+l}null===(a=e.dataTransfer)||void 0===a||a.setDragImage(this.dom,p,d);const h=$n.create(l.state.doc,this.getPos()),f=l.state.tr.setSelection(h);l.dispatch(f)}stopEvent(e){var t;if(!this.dom)return!1;if("function"==typeof this.options.stopEvent)return this.options.stopEvent({event:e});const n=e.target;if(!(this.dom.contains(n)&&!(null===(t=this.contentDOM)||void 0===t?void 0:t.contains(n))))return!1;const i="drop"===e.type;if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i)return!0;const{isEditable:r}=this.editor,{isDragging:o}=this,s=!!this.node.type.spec.draggable,a=$n.isSelectable(this.node),l="copy"===e.type,c="paste"===e.type,u="cut"===e.type,p="mousedown"===e.type,d=e.type.startsWith("drag");if(!s&&a&&d&&e.preventDefault(),s&&d&&!o)return e.preventDefault(),!1;if(s&&r&&!o&&p){const e=n.closest("[data-drag-handle]");e&&(this.dom===e||this.dom.contains(e))&&(this.isDragging=!0,document.addEventListener("dragend",(()=>{this.isDragging=!1}),{once:!0}),document.addEventListener("mouseup",(()=>{this.isDragging=!1}),{once:!0}))}return!(o||i||l||c||u||p&&a)}ignoreMutation(e){if(!this.dom||!this.contentDOM)return!0;if("function"==typeof this.options.ignoreMutation)return this.options.ignoreMutation({mutation:e});if(this.node.isLeaf||this.node.isAtom)return!0;if("selection"===e.type)return!1;if(this.dom.contains(e.target)&&"childList"===e.type&&Ma()&&this.editor.isFocused){if([...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every((e=>e.isContentEditable)))return!1}return this.contentDOM===e.target&&"attributes"===e.type||!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command((({tr:t})=>{const n=this.getPos();return t.setNodeMarkup(n,void 0,{...this.node.attrs,...e}),!0}))}deleteNode(){const e=this.getPos(),t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}}{mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,selected:!1,extension:this.extension,getPos:()=>this.getPos(),updateAttributes:(e={})=>this.updateAttributes(e),deleteNode:()=>this.deleteNode()};if(!this.component.displayName){const e=e=>e.charAt(0).toUpperCase()+e.substring(1);this.component.displayName=e(this.extension.name)}const n=e=>{const n=this.component,i=this.onDragStart.bind(this);return t.createElement(Nu.Provider,{value:{onDragStart:i,nodeViewContentRef:e=>{e&&this.contentDOMElement&&e.firstChild!==this.contentDOMElement&&e.appendChild(this.contentDOMElement)}}},t.createElement(n,{...e}))};n.displayName="ReactNodeView",this.contentDOMElement=this.node.isLeaf?null:document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement&&(this.contentDOMElement.style.whiteSpace="inherit");let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);const{className:r=""}=this.options;this.renderer=new zu(n,{editor:this.editor,props:e,as:i,className:`node-${this.node.type.name} ${r}`.trim()})}get dom(){var e;if(this.renderer.element.firstElementChild&&!(null===(e=this.renderer.element.firstElementChild)||void 0===e?void 0:e.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}update(e,t){const n=e=>{this.renderer.updateProps(e)};if(e.type!==this.node.type)return!1;if("function"==typeof this.options.update){const i=this.node,r=this.decorations;return this.node=e,this.decorations=t,this.options.update({oldNode:i,oldDecorations:r,newNode:e,newDecorations:t,updateProps:()=>n({node:e,decorations:t})})}return e===this.node&&this.decorations===t||(this.node=e,this.decorations=t,n({node:e,decorations:t})),!0}selectNode(){this.renderer.updateProps({selected:!0})}deselectNode(){this.renderer.updateProps({selected:!1})}destroy(){this.renderer.destroy(),this.contentDOMElement=null}}function Ru(e,t){return n=>n.editor.contentComponent?new Iu(e,n,t):{}}const Fu=(e={},t=[])=>{const[n,i]=r(null),s=function(){const[,e]=r(0);return()=>e((e=>e+1))}();return o((()=>{let t=!0;const n=new Ou(e);return i(n),n.on("transaction",(()=>{requestAnimationFrame((()=>{requestAnimationFrame((()=>{t&&s()}))}))})),()=>{n.destroy(),t=!1}}),t),n};var Bu,Pu={exports:{}};
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2018 Jed Watson.
|
|
4
4
|
Licensed under the MIT License (MIT), see
|