File: /mnt/data/smarthr-co-in/demo/angular/template/chunk-NQLUFTVK.js
import{a as wo,b as _o,d as ki,f as St,h as Ci,i as wi,j as _i,l as Qe,n as Si,o as Mi,p as vi,z as So}from"./chunk-7PPOABPU.js";import{d as Co}from"./chunk-WA2UGD5L.js";import{$a as Ct,$b as fo,Ad as xo,Bb as co,Bd as bo,Cd as Xe,Ea as so,Eb as H,Ec as yi,Fd as ko,Gc as xi,Ha as kt,Hc as wn,Hd as bi,Jb as uo,Kb as po,Oc as E,Pc as O,Sb as k,Tb as N,Ub as M,Vb as j,Zb as wt,_ as to,_b as _t,ab as lo,ac as je,cc as R,ea as no,eb as Jt,ec as _,f as Kt,fa as kn,fb as C,fc as ho,ga as pi,gc as mo,ia as io,ic as hi,ja as ro,jc as mi,jd as yo,kb as Cn,kc as gi,pa as K,pc as go,q as ui,qa as J,qc as Ue,rb as ao,s as eo,sa as oo,sb as P,sc as Se,tc as Y,uc as Pe,ud as jt,vc as Re,vd as _n,wd as Ge,yb as me,zb as fi}from"./chunk-AQ27DSQO.js";import{a as L,b as _e}from"./chunk-EQDQRRRY.js";var Mo=i=>typeof i>"u"||i===null,Ma=i=>i.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),va=i=>{let e={};return Object.keys(i).forEach(t=>{i[t]&&(e[t]=i[t])}),e},Sn=i=>{let e=va(i);return Object.entries(e).map(([t,n])=>`${Ma(t)}:${n}`).join(";")},Mt=class extends Error{constructor(e){super(e),this.name=this.constructor.name}},Ni=()=>{let i=Date.now().toString(36),e=Math.random().toString(36).substring(2,7);return`${i}${e}`},vo=(i,e,t)=>Math.min(Math.max(i,e),t);function U(i){this.content=i}U.prototype={constructor:U,find:function(i){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===i)return e;return-1},get:function(i){var e=this.find(i);return e==-1?void 0:this.content[e+1]},update:function(i,e,t){var n=t&&t!=i?this.remove(t):this,r=n.find(i),o=n.content.slice();return r==-1?o.push(t||i,e):(o[r+1]=e,t&&(o[r]=t)),new U(o)},remove:function(i){var e=this.find(i);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new U(t)},addToStart:function(i,e){return new U([i,e].concat(this.remove(i).content))},addToEnd:function(i,e){var t=this.remove(i).content.slice();return t.push(i,e),new U(t)},addBefore:function(i,e,t){var n=this.remove(e),r=n.content.slice(),o=n.find(i);return r.splice(o==-1?r.length:o,0,e,t),new U(r)},forEach:function(i){for(var e=0;e<this.content.length;e+=2)i(this.content[e],this.content[e+1])},prepend:function(i){return i=U.from(i),i.size?new U(i.content.concat(this.subtract(i).content)):this},append:function(i){return i=U.from(i),i.size?new U(this.subtract(i).content.concat(i.content)):this},subtract:function(i){var e=this;i=U.from(i);for(var t=0;t<i.content.length;t+=2)e=e.remove(i.content[t]);return e},toObject:function(){var i={};return this.forEach(function(e,t){i[e]=t}),i},get size(){return this.content.length>>1}};U.from=function(i){if(i instanceof U)return i;var e=[];if(i)for(var t in i)e.push(t,i[t]);return new U(e)};var Ei=U;function zo(i,e,t){for(let n=0;;n++){if(n==i.childCount||n==e.childCount)return i.childCount==e.childCount?null:t;let r=i.child(n),o=e.child(n);if(r==o){t+=r.nodeSize;continue}if(!r.sameMarkup(o))return t;if(r.isText&&r.text!=o.text){for(let s=0;r.text[s]==o.text[s];s++)t++;return t}if(r.content.size||o.content.size){let s=zo(r.content,o.content,t+1);if(s!=null)return s}t+=r.nodeSize}}function Bo(i,e,t,n){for(let r=i.childCount,o=e.childCount;;){if(r==0||o==0)return r==o?null:{a:t,b:n};let s=i.child(--r),l=e.child(--o),a=s.nodeSize;if(s==l){t-=a,n-=a;continue}if(!s.sameMarkup(l))return{a:t,b:n};if(s.isText&&s.text!=l.text){let c=0,d=Math.min(s.text.length,l.text.length);for(;c<d&&s.text[s.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,n--;return{a:t,b:n}}if(s.content.size||l.content.size){let c=Bo(s.content,l.content,t-1,n-1);if(c)return c}t-=a,n-=a}}var y=class i{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,r=0,o){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&n(a,r+l,o||null,s)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),n,r+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let o="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?r?typeof r=="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&n&&(s?s=!1:o+=n),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)r.push(e.content[o]);return new i(r,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],r=0;if(t>e)for(let o=0,s=0;s<t;o++){let l=this.content[o],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),n.push(l),r+=l.nodeSize),s=a}return new i(n,r)}cutByIndex(e,t){return e==t?i.empty:e==0&&t==this.content.length?this:new i(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new i(r,o)}addToStart(e){return new i([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new i(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 r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return zo(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Bo(this,e,t,n)}findIndex(e){if(e==0)return Mn(0,e);if(e==this.size)return Mn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),o=n+r.nodeSize;if(o>=e)return o==e?Mn(t+1,o):Mn(t,n);n=o}}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 i.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new i(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return i.empty;let t,n=0;for(let r=0;r<e.length;r++){let o=e[r];n+=o.nodeSize,r&&o.isText&&e[r-1].sameMarkup(o)?(t||(t=e.slice(0,r)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new i(t||e,n)}static from(e){if(!e)return i.empty;if(e instanceof i)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new i([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};y.empty=new y([],0);var Oi={index:0,offset:0};function Mn(i,e){return Oi.index=i,Oi.offset=e,Oi}function Nn(i,e){if(i===e)return!0;if(!(i&&typeof i=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(i);if(Array.isArray(e)!=t)return!1;if(t){if(i.length!=e.length)return!1;for(let n=0;n<i.length;n++)if(!Nn(i[n],e[n]))return!1}else{for(let n in i)if(!(n in e)||!Nn(i[n],e[n]))return!1;for(let n in e)if(!(n in i))return!1}return!0}var I=(()=>{class i{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,r=!1;for(let o=0;o<t.length;o++){let s=t[o];if(this.eq(s))return t;if(this.type.excludes(s.type))n||(n=t.slice(0,o));else{if(s.type.excludes(this.type))return t;!r&&s.type.rank>this.type.rank&&(n||(n=t.slice(0,o)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=t.slice()),r||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&Nn(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let o=r.create(n.attrs);return r.checkAttrs(o.attrs),o}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(n[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return i.none;if(t instanceof i)return[t];let n=t.slice();return n.sort((r,o)=>r.type.rank-o.type.rank),n}}return i.none=[],i})(),et=class extends Error{},x=class i{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=Fo(this.content,e+this.openStart,t);return n&&new i(n,this.openStart,this.openEnd)}removeBetween(e,t){return new i(Lo(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 i.empty;let n=t.openStart||0,r=t.openEnd||0;if(typeof n!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new i(y.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)r++;return new i(e,n,r)}};x.empty=new x(y.empty,0,0);function Lo(i,e,t){let{index:n,offset:r}=i.findIndex(e),o=i.maybeChild(n),{index:s,offset:l}=i.findIndex(t);if(r==e||o.isText){if(l!=t&&!i.child(s).isText)throw new RangeError("Removing non-flat range");return i.cut(0,e).append(i.cut(t))}if(n!=s)throw new RangeError("Removing non-flat range");return i.replaceChild(n,o.copy(Lo(o.content,e-r-1,t-r-1)))}function Fo(i,e,t,n){let{index:r,offset:o}=i.findIndex(e),s=i.maybeChild(r);if(o==e||s.isText)return n&&!n.canReplace(r,r,t)?null:i.cut(0,e).append(t).append(i.cut(e));let l=Fo(s.content,e-o-1,t,s);return l&&i.replaceChild(r,s.copy(l))}function Na(i,e,t){if(t.openStart>i.depth)throw new et("Inserted content deeper than insertion position");if(i.depth-t.openStart!=e.depth-t.openEnd)throw new et("Inconsistent open depths");return Vo(i,e,t,0)}function Vo(i,e,t,n){let r=i.index(n),o=i.node(n);if(r==e.index(n)&&n<i.depth-t.openStart){let s=Vo(i,e,t,n+1);return o.copy(o.content.replaceChild(r,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&i.depth==n&&e.depth==n){let s=i.parent,l=s.content;return Ze(s,l.cut(0,i.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Ea(t,i);return Ze(o,$o(i,s,l,e,n))}else return Ze(o,En(i,e,n))}function Ho(i,e){if(!e.type.compatibleContent(i.type))throw new et("Cannot join "+e.type.name+" onto "+i.type.name)}function Ii(i,e,t){let n=i.node(t);return Ho(n,e.node(t)),n}function Ye(i,e){let t=e.length-1;t>=0&&i.isText&&i.sameMarkup(e[t])?e[t]=i.withText(e[t].text+i.text):e.push(i)}function Ut(i,e,t,n){let r=(e||i).node(t),o=0,s=e?e.index(t):r.childCount;i&&(o=i.index(t),i.depth>t?o++:i.textOffset&&(Ye(i.nodeAfter,n),o++));for(let l=o;l<s;l++)Ye(r.child(l),n);e&&e.depth==t&&e.textOffset&&Ye(e.nodeBefore,n)}function Ze(i,e){return i.type.checkContent(e),i.copy(e)}function $o(i,e,t,n,r){let o=i.depth>r&&Ii(i,e,r+1),s=n.depth>r&&Ii(t,n,r+1),l=[];return Ut(null,i,r,l),o&&s&&e.index(r)==t.index(r)?(Ho(o,s),Ye(Ze(o,$o(i,e,t,n,r+1)),l)):(o&&Ye(Ze(o,En(i,e,r+1)),l),Ut(e,t,r,l),s&&Ye(Ze(s,En(t,n,r+1)),l)),Ut(n,null,r,l),new y(l)}function En(i,e,t){let n=[];if(Ut(null,i,t,n),i.depth>t){let r=Ii(i,e,t+1);Ye(Ze(r,En(i,e,t+1)),n)}return Ut(e,null,t,n),new y(n)}function Ea(i,e){let t=e.depth-i.openStart,r=e.node(t).copy(i.content);for(let o=t-1;o>=0;o--)r=e.node(o).copy(y.from(r));return{start:r.resolveNoCache(i.openStart+t),end:r.resolveNoCache(r.content.size-i.openEnd-t)}}var On=class i{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let o=0;o<e;o++)r+=n.child(o).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return I.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let l=n;n=r,r=l}let o=n.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!r||!o[s].isInSet(r.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)n[o].type.spec.inclusive===!1&&(!r||!n[o].isInSet(r.marks))&&(n=n[o--].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 tt(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=[],r=0,o=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),c=o-a;if(n.push(s,l,r+a),!c||(s=s.child(l),s.isText))break;o=c-1,r+=a+1}return new i(t,n,o)}static resolveCached(e,t){let n=No.get(e);if(n)for(let o=0;o<n.elts.length;o++){let s=n.elts[o];if(s.pos==t)return s}else No.set(e,n=new Di);let r=n.elts[n.i]=i.resolve(e,t);return n.i=(n.i+1)%Oa,r}},Di=class{constructor(){this.elts=[],this.i=0}},Oa=12,No=new WeakMap,tt=class{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)}},Ta=Object.create(null),ge=class i{constructor(e,t,n,r=I.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||y.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,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,r){return this.content.textBetween(e,t,n,r)}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&&Nn(this.attrs,t||e.defaultAttrs||Ta)&&I.sameSet(this.marks,n||I.none)}copy(e=null){return e==this.content?this:new i(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new i(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return x.empty;let r=this.resolve(e),o=this.resolve(t),s=n?0:r.sharedDepth(t),l=r.start(s),c=r.node(s).content.cut(r.pos-l,o.pos-l);return new x(c,r.depth-s,o.depth-s)}replace(e,t,n){return Na(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+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(e==0)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 r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return On.resolveCached(this,e)}resolveNoCache(e){return On.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,o=>(n.isInSet(o.marks)&&(r=!0),!r)),r}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()+")"),Wo(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=y.empty,r=0,o=n.childCount){let s=this.contentMatchAt(e).matchFragment(n,r,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=r;a<o;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(e).matchType(n),s=o&&o.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=I.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!I.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=y.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,r,n);return o.type.checkAttrs(o.attrs),o}};ge.prototype.text=void 0;var Ai=class i extends ge{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Wo(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 i(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new i(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Wo(i,e){for(let t=i.length-1;t>=0;t--)e=i[t].type.name+"("+e+")";return e}var nt=class i{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new Pi(e,t);if(n.next==null)return i.empty;let r=qo(n);n.next&&n.err("Unexpected trailing text");let o=Ba(za(r));return La(o,n),o}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 r=this;for(let o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let 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 r=[this];function o(s,l){let a=s.matchFragment(e,n);if(a&&(!t||a.validEnd))return y.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:d,next:u}=s.next[c];if(!(d.isText||d.hasRequiredAttrs())&&r.indexOf(u)==-1){r.push(u);let p=o(u,l.concat(d));if(p)return p}}return null}return o(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+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 r=n.shift(),o=r.match;if(o.matchType(e)){let s=[];for(let l=r;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:l,next:a}=o.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!r.type||a.validEnd)&&(n.push({match:l.contentMatch,type:l,via:r}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((n,r)=>{let o=r+(n.validEnd?"*":" ")+" ";for(let s=0;s<n.next.length;s++)o+=(s?", ":"")+n.next[s].type.name+"->"+e.indexOf(n.next[s].next);return o}).join(`
`)}};nt.empty=new nt(!0);var Pi=class{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 qo(i){let e=[];do e.push(Ia(i));while(i.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Ia(i){let e=[];do e.push(Da(i));while(i.next&&i.next!=")"&&i.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Da(i){let e=Ra(i);for(;;)if(i.eat("+"))e={type:"plus",expr:e};else if(i.eat("*"))e={type:"star",expr:e};else if(i.eat("?"))e={type:"opt",expr:e};else if(i.eat("{"))e=Aa(i,e);else break;return e}function Eo(i){/\D/.test(i.next)&&i.err("Expected number, got '"+i.next+"'");let e=Number(i.next);return i.pos++,e}function Aa(i,e){let t=Eo(i),n=t;return i.eat(",")&&(i.next!="}"?n=Eo(i):n=-1),i.eat("}")||i.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function Pa(i,e){let t=i.nodeTypes,n=t[e];if(n)return[n];let r=[];for(let o in t){let s=t[o];s.isInGroup(e)&&r.push(s)}return r.length==0&&i.err("No node type or group '"+e+"' found"),r}function Ra(i){if(i.eat("(")){let e=qo(i);return i.eat(")")||i.err("Missing closing paren"),e}else if(/\W/.test(i.next))i.err("Unexpected token '"+i.next+"'");else{let e=Pa(i,i.next).map(t=>(i.inline==null?i.inline=t.isInline:i.inline!=t.isInline&&i.err("Mixing inline and block content"),{type:"name",value:t}));return i.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function za(i){let e=[[]];return r(o(i,0),t()),e;function t(){return e.push([])-1}function n(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function r(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=o(s.exprs[a],l);if(a==s.exprs.length-1)return c;r(c,l=t())}else if(s.type=="star"){let a=t();return n(l,a),r(o(s.expr,a),a),[n(a)]}else if(s.type=="plus"){let a=t();return r(o(s.expr,l),a),r(o(s.expr,a),a),[n(a)]}else{if(s.type=="opt")return[n(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let d=t();r(o(s.expr,a),d),a=d}if(s.max==-1)r(o(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let d=t();n(a,d),r(o(s.expr,a),d),a=d}return[n(a)]}else{if(s.type=="name")return[n(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Ko(i,e){return e-i}function Oo(i,e){let t=[];return n(e),t.sort(Ko);function n(r){let o=i[r];if(o.length==1&&!o[0].term)return n(o[0].to);t.push(r);for(let s=0;s<o.length;s++){let{term:l,to:a}=o[s];!l&&t.indexOf(a)==-1&&n(a)}}}function Ba(i){let e=Object.create(null);return t(Oo(i,0));function t(n){let r=[];n.forEach(s=>{i[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<r.length;d++)r[d][0]==l&&(c=r[d][1]);Oo(i,a).forEach(d=>{c||r.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let o=e[n.join(",")]=new nt(n.indexOf(i.length-1)>-1);for(let s=0;s<r.length;s++){let l=r[s][1].sort(Ko);o.next.push({type:r[s][0],next:e[l.join(",")]||t(l)})}return o}}function La(i,e){for(let t=0,n=[i];t<n.length;t++){let r=n[t],o=!r.validEnd,s=[];for(let l=0;l<r.next.length;l++){let{type:a,next:c}=r.next[l];s.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),n.indexOf(c)==-1&&n.push(c)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Jo(i){let e=Object.create(null);for(let t in i){let n=i[t];if(!n.hasDefault)return null;e[t]=n.default}return e}function jo(i,e){let t=Object.create(null);for(let n in i){let r=e&&e[n];if(r===void 0){let o=i[n];if(o.hasDefault)r=o.default;else throw new RangeError("No value supplied for attribute "+n)}t[n]=r}return t}function Uo(i,e,t,n){for(let r in e)if(!(r in i))throw new RangeError(`Unsupported attribute ${r} for ${t} of type ${r}`);for(let r in i){let o=i[r];o.validate&&o.validate(e[r])}}function Go(i,e){let t=Object.create(null);if(e)for(let n in e)t[n]=new Ri(i,n,e[n]);return t}var Tn=class i{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=Go(e,n.attrs),this.defaultAttrs=Jo(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==nt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:jo(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ge(this,this.computeAttrs(e),y.from(t),I.setFrom(n))}createChecked(e=null,t,n){return t=y.from(t),this.checkContent(t),new ge(this,this.computeAttrs(e),t,I.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=y.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore(y.empty,!0);return o?new ge(this,e,t.append(o),I.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Uo(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let 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:I.none:e}static compile(e,t){let n=Object.create(null);e.forEach((o,s)=>n[o]=new i(o,t,s));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function Fa(i,e,t){let n=t.split("|");return r=>{let o=r===null?"null":typeof r;if(n.indexOf(o)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${i}, got ${o}`)}}var Ri=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Fa(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Xt=class i{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Go(e,r.attrs),this.excluded=null;let o=Jo(this.attrs);this.instance=o?new I(this,o):null}create(e=null){return!e&&this.instance?this.instance:new I(this,jo(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((o,s)=>n[o]=new i(o,r++,t,s)),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]}checkAttrs(e){Uo(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},In=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=Ei.from(e.nodes),t.marks=Ei.from(e.marks||{}),this.nodes=Tn.compile(this.spec.nodes,this),this.marks=Xt.compile(this.spec.marks,this);let n=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let o=this.nodes[r],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=n[s]||(n[s]=nt.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?To(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let r in this.marks){let o=this.marks[r],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:To(this,s.split(" "))}this.nodeFromJSON=r=>ge.fromJSON(this,r),this.markFromJSON=r=>I.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Tn){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new Ai(n,n.defaultAttrs,e,I.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function To(i,e){let t=[];for(let n=0;n<e.length;n++){let r=e[n],o=i.marks[r],s=o;if(o)t.push(o);else for(let l in i.marks){let a=i.marks[l];(r=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(r)>-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return t}function Va(i){return i.tag!=null}function Ha(i){return i.style!=null}var ze=class i{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(r=>{if(Va(r))this.tags.push(r);else if(Ha(r)){let o=/[^=]*/.exec(r.style)[0];n.indexOf(o)<0&&n.push(o),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let o=e.nodes[r.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let n=new Dn(this,t,!1);return n.addAll(e,I.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Dn(this,t,!0);return n.addAll(e,I.none,t.from,t.to),x.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let o=this.tags[r];if(qa(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||t.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,t,n,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let s=this.styles[o],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!n.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function n(r){let o=r.priority==null?50:r.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<o)break}t.splice(s,0,r)}for(let r in e.marks){let o=e.marks[r].spec.parseDOM;o&&o.forEach(s=>{n(s=Do(s)),s.mark||s.ignore||s.clearMark||(s.mark=r)})}for(let r in e.nodes){let o=e.nodes[r].spec.parseDOM;o&&o.forEach(s=>{n(s=Do(s)),s.node||s.ignore||s.mark||(s.node=r)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new i(e,i.schemaRules(e)))}},Xo={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},$a={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Qo={ol:!0,ul:!0},Qt=1,zi=2,Gt=4;function Io(i,e,t){return e!=null?(e?Qt:0)|(e==="full"?zi:0):i&&i.whitespace=="pre"?Qt|zi:t&~Gt}var vt=class{constructor(e,t,n,r,o,s){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=s,this.content=[],this.activeMarks=I.none,this.match=o||(s&Gt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(y.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,r;return(r=n.findWrapping(e.type))?(this.match=n,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Qt)){let n=this.content[this.content.length-1],r;if(n&&n.isText&&(r=/[ \t\r\n\u000c]+$/.exec(n.text))){let o=n;n.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-r[0].length))}}let t=y.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(y.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Xo.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Dn=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,o,s=Io(null,t.preserveWhitespace,0)|(n?Gt:0);r?o=new vt(r.type,r.attrs,I.none,!0,t.topMatch||r.type.contentMatch,s):n?o=new vt(null,null,I.none,!0,null,s):o=new vt(e.schema.topNodeType,null,I.none,!0,null,s),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,o=r.options&zi?"full":this.localPreserveWS||(r.options&Qt)>0,{schema:s}=this.parser;if(o==="full"||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)if(o==="full")n=n.replace(/\r\n?/g,`
`);else if(s.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=n.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(s.text(l[a]),t,!/\S/.test(l[a]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let l=r.content[r.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(n=n.slice(1))}n&&this.insertNode(s.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Qo.hasOwnProperty(s)&&this.parser.normalizeLists&&Wa(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,n));e:if(a?a.ignore:$a.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(Xo.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(o),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let o=this.parser.matchedStyles[r],s=n.getPropertyValue(o);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(o,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,n,r){let o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let a=this.enter(s,t.attrs||null,n,t.preserveWhitespace);a&&(o=!0,n=a)}else{let a=this.parser.schema.marks[t.mark];n=n.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,n,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,n),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,n,r){let o=n||0;for(let s=n?e.childNodes[n]:e.firstChild,l=r==null?null:e.childNodes[r];s!=l;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t,n){let r,o;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!r||r.length>c.length+l)&&(r=c,o=a,!c.length))break;if(a.solid){if(n)break;l+=2}}if(!r)return null;this.sync(o);for(let s=0;s<r.length;s++)t=this.enterInner(r[s],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=I.none;for(let l of r.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):Ao(l.type,e.type))&&(s=l.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,n,r){let o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,r)),o}enterInner(e,t,n,r=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=Io(e,o,s.options);s.options&Gt&&s.content.length==0&&(l|=Gt);let a=I.none;return n=n.filter(c=>(s.type?s.type.allowsMarkType(c.type):Ao(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new vt(e,t,a,r,null,l)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Qt)}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 r=n.length-1;r>=0;r--)e+=n[r].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++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].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,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(r?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let d=a>0||a==0&&r?this.nodes[a].type:n&&a>=o?n.node(a-o).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return s(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 t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}};function Wa(i){for(let e=i.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&Qo.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function qa(i,e){return(i.matches||i.msMatchesSelector||i.webkitMatchesSelector||i.mozMatchesSelector).call(i,e)}function Do(i){let e={};for(let t in i)e[t]=i[t];return e}function Ao(i,e){let t=e.schema.nodes;for(let n in t){let r=t[n];if(!r.allowsMarkType(i))continue;let o=[],s=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||o.indexOf(d)<0&&s(d))return!0}};if(s(r.contentMatch))return!0}}var Me=class i{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Ti(t).createDocumentFragment());let r=n,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let l=0,a=0;for(;l<o.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)r=o.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],d=this.serializeMark(c,s.isInline,t);d&&(o.push([c,r]),r.appendChild(d.dom),r=d.contentDOM||d.dom)}}r.appendChild(this.serializeNodeInner(s,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=vn(Ti(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&vn(Ti(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return vn(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new i(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Po(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return Po(e.marks)}};function Po(i){let e={};for(let t in i){let n=i[t].spec.toDOM;n&&(e[t]=n)}return e}function Ti(i){return i.document||window.document}var Ro=new WeakMap;function Ka(i){let e=Ro.get(i);return e===void 0&&Ro.set(i,e=Ja(i)),e}function Ja(i){let e=null;function t(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let r=0;r<n.length;r++)t(n[r]);else for(let r in n)t(n[r])}return t(i),e}function vn(i,e,t,n){if(typeof e=="string")return{dom:i.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let r=e[0],o;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(o=Ka(n))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=r.indexOf(" ");s>0&&(t=r.slice(0,s),r=r.slice(s+1));let l,a=t?i.createElementNS(t,r):i.createElement(r),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let p=u.indexOf(" ");p>0?a.setAttributeNS(u.slice(0,p),u.slice(p+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let p=e[u];if(p===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:f}=vn(i,p,t,n);if(a.appendChild(h),f){if(l)throw new RangeError("Multiple content holes");l=f}}}return{dom:a,contentDOM:l}}var es=65535,ts=Math.pow(2,16);function ja(i,e){return i+e*ts}function Yo(i){return i&es}function Ua(i){return(i-(i&es))/ts}var ns=1,is=2,An=4,rs=8,en=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&rs)>0}get deletedBefore(){return(this.delInfo&(ns|An))>0}get deletedAfter(){return(this.delInfo&(is|An))>0}get deletedAcross(){return(this.delInfo&An)>0}},ve=class i{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&i.empty)return i.empty}recover(e){let t=0,n=Yo(e);if(!this.inverted)for(let r=0;r<n;r++)t+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[n*3]+t+Ua(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 r=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],d=this.ranges[l+s],u=a+c;if(e<=u){let p=c?e==a?-1:e==u?1:t:t,h=a+r+(p<0?0:d);if(n)return h;let f=e==(t<0?a:u)?null:ja(l/3,e-a),m=e==a?is:e==u?ns:An;return(t<0?e!=a:e!=u)&&(m|=rs),new en(h,m,f)}r+=d-c}return n?e+r:new en(e+r,0,null)}touches(e,t){let n=0,r=Yo(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?n:0);if(a>e)break;let c=this.ranges[l+o],d=a+c;if(e<=d&&l==r*3)return!0;n+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let s=this.ranges[r],l=s-(this.inverted?o:0),a=s+(this.inverted?0:o),c=this.ranges[r+t],d=this.ranges[r+n];e(l,l+c,a,a+d),o+=d-c}}invert(){return new i(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?i.empty:new i(e<0?[0,-e,0]:[0,0,e])}};ve.empty=new ve([]);var tn=class i{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new i(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r: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 r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let e=new i;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 r=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}r|=l.delInfo,e=l.pos}return n?e:new en(e,r,null)}},Bi=Object.create(null),F=class{getMap(){return ve.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Bi[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 Bi)throw new RangeError("Duplicate use of step JSON ID "+e);return Bi[e]=t,t.prototype.jsonID=e,t}},$=class i{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new i(e,null)}static fail(e){return new i(null,e)}static fromReplace(e,t,n,r){try{return i.ok(e.replace(t,n,r))}catch(o){if(o instanceof et)return i.fail(o.message);throw o}}};function $i(i,e,t){let n=[];for(let r=0;r<i.childCount;r++){let o=i.child(r);o.content.size&&(o=o.copy($i(o.content,e,o))),o.isInline&&(o=e(o,t,r)),n.push(o)}return y.fromArray(n)}var nn=class i extends F{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),r=n.node(n.sharedDepth(this.to)),o=new x($i(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),r),t.openStart,t.openEnd);return $.fromReplace(e,this.from,this.to,o)}invert(){return new it(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 i(t.pos,n.pos,this.mark)}merge(e){return e instanceof i&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new i(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new i(t.from,t.to,e.markFromJSON(t.mark))}};F.jsonID("addMark",nn);var it=class i extends F{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 x($i(t.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),t.openStart,t.openEnd);return $.fromReplace(e,this.from,this.to,n)}invert(){return new nn(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 i(t.pos,n.pos,this.mark)}merge(e){return e instanceof i&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new i(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new i(t.from,t.to,e.markFromJSON(t.mark))}};F.jsonID("removeMark",it);var rn=class i extends F{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return $.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return $.fromReplace(e,this.pos,this.pos+1,new x(y.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let r=0;r<t.marks.length;r++)if(!t.marks[r].isInSet(n))return new i(this.pos,t.marks[r]);return new i(this.pos,this.mark)}}return new Nt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new i(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new i(t.pos,e.markFromJSON(t.mark))}};F.jsonID("addNodeMark",rn);var Nt=class i extends F{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return $.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return $.fromReplace(e,this.pos,this.pos+1,new x(y.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new rn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new i(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new i(t.pos,e.markFromJSON(t.mark))}};F.jsonID("removeNodeMark",Nt);var se=class i extends F{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Vi(e,this.from,this.to)?$.fail("Structure replace would overwrite content"):$.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ve([this.from,this.to-this.from,this.slice.size])}invert(e){return new i(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 i(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof i)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?x.empty:new x(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new i(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?x.empty:new x(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new i(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new i(t.from,t.to,x.fromJSON(e,t.slice),!!t.structure)}};F.jsonID("replace",se);var V=class i extends F{constructor(e,t,n,r,o,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Vi(e,this.from,this.gapFrom)||Vi(e,this.gapTo,this.to)))return $.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return $.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?$.fromReplace(e,this.from,this.to,n):$.fail("Content does not fit in gap")}getMap(){return new ve([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new i(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),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||o>n.pos?null:new i(t.pos,n.pos,r,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new i(t.from,t.to,t.gapFrom,t.gapTo,x.fromJSON(e,t.slice),t.insert,!!t.structure)}};F.jsonID("replaceAround",V);function Vi(i,e,t){let n=i.resolve(e),r=t-e,o=n.depth;for(;r>0&&o>0&&n.indexAfter(o)==n.node(o).childCount;)o--,r--;if(r>0){let s=n.node(o).maybeChild(n.indexAfter(o));for(;r>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,r--}}return!1}function Ga(i,e,t,n){let r=[],o=[],s,l;i.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!n.isInSet(u)&&d.type.allowsMarkType(n.type)){let p=Math.max(c,e),h=Math.min(c+a.nodeSize,t),f=n.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(f)||(s&&s.to==p&&s.mark.eq(u[m])?s.to=h:r.push(s=new it(p,h,u[m])));l&&l.to==p?l.to=h:o.push(l=new nn(p,h,n))}}),r.forEach(a=>i.step(a)),o.forEach(a=>i.step(a))}function Xa(i,e,t,n){let r=[],o=0;i.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(n instanceof Xt){let c=s.marks,d;for(;d=n.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else n?n.isInSet(s.marks)&&(a=[n]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],p;for(let h=0;h<r.length;h++){let f=r[h];f.step==o-1&&u.eq(r[h].style)&&(p=f)}p?(p.to=c,p.step=o):r.push({style:u,from:Math.max(l,e),to:c,step:o})}}}),r.forEach(s=>i.step(new it(s.from,s.to,s.style)))}function Wi(i,e,t,n=t.contentMatch,r=!0){let o=i.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),d=l+c.nodeSize,u=n.matchType(c.type);if(!u)s.push(new se(l,d,x.empty));else{n=u;for(let p=0;p<c.marks.length;p++)t.allowsMarkType(c.marks[p].type)||i.step(new it(l,d,c.marks[p]));if(r&&c.isText&&t.whitespace!="pre"){let p,h=/\r?\n|\r/g,f;for(;p=h.exec(c.text);)f||(f=new x(y.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new se(l+p.index,l+p.index+p[0].length,f))}}l=d}if(!n.validEnd){let a=n.fillBefore(y.empty,!0);i.replace(l,l,new x(a,0,0))}for(let a=s.length-1;a>=0;a--)i.step(s[a])}function Qa(i,e,t){return(e==0||i.canReplace(e,i.childCount))&&(t==i.childCount||i.canReplace(0,t))}function rt(i){let t=i.parent.content.cutByIndex(i.startIndex,i.endIndex);for(let n=i.depth,r=0,o=0;;--n){let s=i.$from.node(n),l=i.$from.index(n)+r,a=i.$to.indexAfter(n)-o;if(n<i.depth&&s.canReplace(l,a,t))return n;if(n==0||s.type.spec.isolating||!Qa(s,l,a))break;l&&(r=1),a<s.childCount&&(o=1)}return null}function Ya(i,e,t){let{$from:n,$to:r,depth:o}=e,s=n.before(o+1),l=r.after(o+1),a=s,c=l,d=y.empty,u=0;for(let f=o,m=!1;f>t;f--)m||n.index(f)>0?(m=!0,d=y.from(n.node(f).copy(d)),u++):a--;let p=y.empty,h=0;for(let f=o,m=!1;f>t;f--)m||r.after(f+1)<r.end(f)?(m=!0,p=y.from(r.node(f).copy(p)),h++):c++;i.step(new V(a,c,s,l,new x(d.append(p),u,h),d.size-u,!0))}function Ot(i,e,t=null,n=i){let r=Za(i,e),o=r&&ec(n,e);return o?r.map(Zo).concat({type:e,attrs:t}).concat(o.map(Zo)):null}function Zo(i){return{type:i,attrs:null}}function Za(i,e){let{parent:t,startIndex:n,endIndex:r}=i,o=t.contentMatchAt(n).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return t.canReplaceWith(n,r,s)?o:null}function ec(i,e){let{parent:t,startIndex:n,endIndex:r}=i,o=t.child(n),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=n;a&&c<r;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function tc(i,e,t){let n=y.empty;for(let s=t.length-1;s>=0;s--){if(n.size){let l=t[s].type.contentMatch.matchFragment(n);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=y.from(t[s].type.create(t[s].attrs,n))}let r=e.start,o=e.end;i.step(new V(r,o,r,o,new x(n,0,0),t.length,!0))}function nc(i,e,t,n,r){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=i.steps.length;i.doc.nodesBetween(e,t,(s,l)=>{let a=typeof r=="function"?r(s):r;if(s.isTextblock&&!s.hasMarkup(n,a)&&ic(i.doc,i.mapping.slice(o).map(l),n)){let c=null;if(n.schema.linebreakReplacement){let h=n.whitespace=="pre",f=!!n.contentMatch.matchType(n.schema.linebreakReplacement);h&&!f?c=!1:!h&&f&&(c=!0)}c===!1&&ls(i,s,l,o),Wi(i,i.mapping.slice(o).map(l,1),n,void 0,c===null);let d=i.mapping.slice(o),u=d.map(l,1),p=d.map(l+s.nodeSize,1);return i.step(new V(u,p,u+1,p-1,new x(y.from(n.create(a,null,s.marks)),0,0),1,!0)),c===!0&&ss(i,s,l,o),!1}})}function ss(i,e,t,n){e.forEach((r,o)=>{if(r.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(r.text);){let a=i.mapping.slice(n).map(t+1+o+s.index);i.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function ls(i,e,t,n){e.forEach((r,o)=>{if(r.type==r.type.schema.linebreakReplacement){let s=i.mapping.slice(n).map(t+1+o);i.replaceWith(s,s+1,e.type.schema.text(`
`))}})}function ic(i,e,t){let n=i.resolve(e),r=n.index();return n.parent.canReplaceWith(r,r+1,t)}function rc(i,e,t,n,r){let o=i.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(n,null,r||o.marks);if(o.isLeaf)return i.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);i.step(new V(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new x(y.from(s),0,0),1,!0))}function Be(i,e,t=1,n){let r=i.resolve(e),o=r.depth-t,s=n&&n[n.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 c=r.depth-1,d=t-2;c>o;c--,d--){let u=r.node(c),p=r.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(p,u.childCount),f=n&&n[d+1];f&&(h=h.replaceChild(0,f.type.create(f.attrs)));let m=n&&n[d]||u;if(!u.canReplace(p+1,u.childCount)||!m.type.validContent(h))return!1}let l=r.indexAfter(o),a=n&&n[0];return r.node(o).canReplaceWith(l,l,a?a.type:r.node(o+1).type)}function oc(i,e,t=1,n){let r=i.doc.resolve(e),o=y.empty,s=y.empty;for(let l=r.depth,a=r.depth-t,c=t-1;l>a;l--,c--){o=y.from(r.node(l).copy(o));let d=n&&n[c];s=y.from(d?d.type.create(d.attrs,s):r.node(l).copy(s))}i.step(new se(e,e,new x(o.append(s),t,t),!0))}function ot(i,e){let t=i.resolve(e),n=t.index();return lc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function sc(i,e){e.content.size||i.type.compatibleContent(e.type);let t=i.contentMatchAt(i.childCount),{linebreakReplacement:n}=i.type.schema;for(let r=0;r<e.childCount;r++){let o=e.child(r),s=o.type==n?i.type.schema.nodes.text:o.type;if(t=t.matchType(s),!t||!i.type.allowsMarks(o.marks))return!1}return t.validEnd}function lc(i,e){return!!(i&&e&&!i.isLeaf&&sc(i,e))}function ac(i,e,t){let n=null,{linebreakReplacement:r}=i.doc.type.schema,o=i.doc.resolve(e-t),s=o.node().type;if(r&&s.inlineContent){let d=s.whitespace=="pre",u=!!s.contentMatch.matchType(r);d&&!u?n=!1:!d&&u&&(n=!0)}let l=i.steps.length;if(n===!1){let d=i.doc.resolve(e+t);ls(i,d.node(),d.before(),l)}s.inlineContent&&Wi(i,e+t-1,s,o.node().contentMatchAt(o.index()),n==null);let a=i.mapping.slice(l),c=a.map(e-t);if(i.step(new se(c,a.map(e+t,-1),x.empty,!0)),n===!0){let d=i.doc.resolve(c);ss(i,d.node(),d.before(),i.steps.length)}return i}function cc(i,e,t){let n=i.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let r=n.depth-1;r>=0;r--){let o=n.index(r);if(n.node(r).canReplaceWith(o,o,t))return n.before(r+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let r=n.depth-1;r>=0;r--){let o=n.indexAfter(r);if(n.node(r).canReplaceWith(o,o,t))return n.after(r+1);if(o<n.node(r).childCount)return null}return null}function as(i,e,t){let n=i.resolve(e);if(!t.content.size)return e;let r=t.content;for(let o=0;o<t.openStart;o++)r=r.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let s=n.depth;s>=0;s--){let l=s==n.depth?0:n.pos<=(n.start(s+1)+n.end(s+1))/2?-1:1,a=n.index(s)+(l>0?1:0),c=n.node(s),d=!1;if(o==1)d=c.canReplace(a,a,r);else{let u=c.contentMatchAt(a).findWrapping(r.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?n.pos:l<0?n.before(s+1):n.after(s+1)}return null}function Bn(i,e,t=e,n=x.empty){if(e==t&&!n.size)return null;let r=i.resolve(e),o=i.resolve(t);return cs(r,o,n)?new se(e,t,n):new Hi(r,o,n).fit()}function cs(i,e,t){return!t.openStart&&!t.openEnd&&i.start()==e.start()&&i.parent.canReplace(i.index(),e.index(),t.content)}var Hi=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=y.empty;for(let r=0;r<=e.depth;r++){let o=e.node(r);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=y.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let o=this.placed,s=n.depth,l=r.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new x(o,s,l);return e>-1?new V(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new se(n.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let r,o=null;n?(o=Li(this.unplaced.content,n-1).firstChild,r=o.content):r=this.unplaced.content;let s=r.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(s?c.matchType(s.type)||(u=c.fillBefore(y.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:l,parent:o,inject:u};if(t==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:l,parent:o,wrap:d};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Li(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new x(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Li(e,t);if(r.childCount<=1&&t>0){let o=e.size-t<=t+r.size;this.unplaced=new x(Yt(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new x(Yt(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m<o.length;m++)this.openFrontierNode(o[m]);let s=this.unplaced,l=n?n.content:s.content,a=s.openStart-e,c=0,d=[],{match:u,type:p}=this.frontier[t];if(r){for(let m=0;m<r.childCount;m++)d.push(r.child(m));u=u.matchFragment(r)}let h=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(ds(m.mark(p.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let f=c==l.childCount;f||(h=-1),this.placed=Zt(this.placed,t,y.from(d)),this.frontier[t].match=u,f&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=f?e==0?x.empty:new x(Yt(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new x(Yt(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Fi(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=Fi(e,t,r,n,o);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Fi(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:s,move:o?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=Zt(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let r=e.node(n),o=r.type.contentMatch.fillBefore(r.content,!0,e.index(n));this.openFrontierNode(r.type,r.attrs,o)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Zt(this.placed,this.depth,y.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(y.empty,!0);t.childCount&&(this.placed=Zt(this.placed,this.frontier.length,t))}};function Yt(i,e,t){return e==0?i.cutByIndex(t,i.childCount):i.replaceChild(0,i.firstChild.copy(Yt(i.firstChild.content,e-1,t)))}function Zt(i,e,t){return e==0?i.append(t):i.replaceChild(i.childCount-1,i.lastChild.copy(Zt(i.lastChild.content,e-1,t)))}function Li(i,e){for(let t=0;t<e;t++)i=i.firstChild.content;return i}function ds(i,e,t){if(e<=0)return i;let n=i.content;return e>1&&(n=n.replaceChild(0,ds(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=i.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(i.type.contentMatch.matchFragment(n).fillBefore(y.empty,!0)))),i.copy(n)}function Fi(i,e,t,n,r){let o=i.node(e),s=r?i.indexAfter(e):i.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=n.fillBefore(o.content,!0,s);return l&&!dc(t,o.content,s)?l:null}function dc(i,e,t){for(let n=t;n<e.childCount;n++)if(!i.allowsMarks(e.child(n).marks))return!0;return!1}function uc(i){return i.spec.defining||i.spec.definingForContent}function pc(i,e,t,n){if(!n.size)return i.deleteRange(e,t);let r=i.doc.resolve(e),o=i.doc.resolve(t);if(cs(r,o,n))return i.step(new se(e,t,n));let s=ps(r,o);s[s.length-1]==0&&s.pop();let l=-(r.depth+1);s.unshift(l);for(let p=r.depth,h=r.pos-1;p>0;p--,h--){let f=r.node(p).type.spec;if(f.defining||f.definingAsContext||f.isolating)break;s.indexOf(p)>-1?l=p:r.before(p)==h&&s.splice(1,0,-p)}let a=s.indexOf(l),c=[],d=n.openStart;for(let p=n.content,h=0;;h++){let f=p.firstChild;if(c.push(f),h==n.openStart)break;p=f.content}for(let p=d-1;p>=0;p--){let h=c[p],f=uc(h.type);if(f&&!h.sameMarkup(r.node(Math.abs(l)-1)))d=p;else if(f||!h.type.isTextblock)break}for(let p=n.openStart;p>=0;p--){let h=(p+d+1)%(n.openStart+1),f=c[h];if(f)for(let m=0;m<s.length;m++){let g=s[(m+a)%s.length],b=!0;g<0&&(b=!1,g=-g);let D=r.node(g-1),A=r.index(g-1);if(D.canReplaceWith(A,A,f.type,f.marks))return i.replace(r.before(g),b?o.after(g):t,new x(us(n.content,0,n.openStart,h),h,n.openEnd))}}let u=i.steps.length;for(let p=s.length-1;p>=0&&(i.replace(e,t,n),!(i.steps.length>u));p--){let h=s[p];h<0||(e=r.before(h),t=o.after(h))}}function us(i,e,t,n,r){if(e<t){let o=i.firstChild;i=i.replaceChild(0,o.copy(us(o.content,e+1,t,n,o)))}if(e>n){let o=r.contentMatchAt(0),s=o.fillBefore(i).append(i);i=s.append(o.matchFragment(s).fillBefore(y.empty,!0))}return i}function fc(i,e,t,n){if(!n.isInline&&e==t&&i.doc.resolve(e).parent.content.size){let r=cc(i.doc,e,n.type);r!=null&&(e=t=r)}i.replaceRange(e,t,new x(y.from(n),0,0))}function hc(i,e,t){let n=i.doc.resolve(e),r=i.doc.resolve(t),o=ps(n,r);for(let s=0;s<o.length;s++){let l=o[s],a=s==o.length-1;if(a&&l==0||n.node(l).type.contentMatch.validEnd)return i.delete(n.start(l),r.end(l));if(l>0&&(a||n.node(l-1).canReplace(n.index(l-1),r.indexAfter(l-1))))return i.delete(n.before(l),r.after(l))}for(let s=1;s<=n.depth&&s<=r.depth;s++)if(e-n.start(s)==n.depth-s&&t>n.end(s)&&r.end(s)-t!=r.depth-s&&n.start(s-1)==r.start(s-1)&&n.node(s-1).canReplace(n.index(s-1),r.index(s-1)))return i.delete(n.before(s),t);i.delete(e,t)}function ps(i,e){let t=[],n=Math.min(i.depth,e.depth);for(let r=n;r>=0;r--){let o=i.start(r);if(o<i.pos-(i.depth-r)||e.end(r)>e.pos+(e.depth-r)||i.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(o==e.start(r)||r==i.depth&&r==e.depth&&i.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==o-1)&&t.push(r)}return t}var Pn=class i extends F{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 $.fail("No node at attribute step's position");let n=Object.create(null);for(let o in t.attrs)n[o]=t.attrs[o];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return $.fromReplace(e,this.pos,this.pos+1,new x(y.from(r),0,t.isLeaf?0:1))}getMap(){return ve.empty}invert(e){return new i(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 i(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new i(t.pos,t.attr,t.value)}};F.jsonID("attr",Pn);var Rn=class i extends F{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return $.ok(n)}getMap(){return ve.empty}invert(e){return new i(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new i(t.attr,t.value)}};F.jsonID("docAttr",Rn);var Et=class extends Error{};Et=function i(e){let t=Error.call(this,e);return t.__proto__=i.prototype,t};Et.prototype=Object.create(Error.prototype);Et.prototype.constructor=Et;Et.prototype.name="TransformError";var zn=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new tn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Et(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=x.empty){let r=Bn(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new x(y.from(n),0,0))}delete(e,t){return this.replace(e,t,x.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return pc(this,e,t,n),this}replaceRangeWith(e,t,n){return fc(this,e,t,n),this}deleteRange(e,t){return hc(this,e,t),this}lift(e,t){return Ya(this,e,t),this}join(e,t=1){return ac(this,e,t),this}wrap(e,t){return tc(this,e,t),this}setBlockType(e,t=e,n,r=null){return nc(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return rc(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Pn(e,t,n)),this}setDocAttribute(e,t){return this.step(new Rn(e,t)),this}addNodeMark(e,t){return this.step(new rn(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof I)t.isInSet(n.marks)&&this.step(new Nt(e,t));else{let r=n.marks,o,s=[];for(;o=t.isInSet(r);)s.push(new Nt(e,o)),r=o.removeFromSet(r);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,n){return oc(this,e,t,n),this}addMark(e,t,n){return Ga(this,e,t,n),this}removeMark(e,t,n){return Xa(this,e,t,n),this}clearIncompatible(e,t,n){return Wi(this,e,t,n),this}};var qi=Object.create(null),S=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new It(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=x.empty){let n=t.content.lastChild,r=null;for(let l=0;l<t.openEnd;l++)r=n,n=n.lastChild;let o=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],d=e.mapping.slice(o);e.replaceRange(d.map(a.pos),d.map(c.pos),l?x.empty:t),l==0&&ms(e,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:s,$to:l}=r[o],a=e.mapping.slice(n),c=a.map(s.pos),d=a.map(l.pos);o?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),ms(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new T(e):Tt(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let o=e.depth-1;o>=0;o--){let s=t<0?Tt(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):Tt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new le(e.node(0))}static atStart(e){return Tt(e,e,0,0,1)||new le(e)}static atEnd(e){return Tt(e,e,e.content.size,e.childCount,-1)||new le(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=qi[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 qi)throw new RangeError("Duplicate use of selection JSON ID "+e);return qi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return T.between(this.$anchor,this.$head).getBookmark()}};S.prototype.visible=!0;var It=class{constructor(e,t){this.$from=e,this.$to=t}},fs=!1;function hs(i){!fs&&!i.parent.inlineContent&&(fs=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+i.parent.type.name+")"))}var T=class i extends S{constructor(e,t=e){hs(e),hs(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 S.near(n);let r=e.resolve(t.map(this.anchor));return new i(r.parent.inlineContent?r:n,n)}replace(e,t=x.empty){if(super.replace(e,t),t==x.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof i&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Fn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new i(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if((!n||r)&&(n=r>=0?1:-1),!t.parent.inlineContent){let o=S.findFrom(t,n,!0)||S.findFrom(t,-n,!0);if(o)t=o.$head;else return S.near(t,n)}return e.parent.inlineContent||(r==0?e=t:(e=(S.findFrom(e,-n,!0)||S.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=r<0&&(e=t))),new i(e,t)}};S.jsonID("text",T);var Fn=class i{constructor(e,t){this.anchor=e,this.head=t}map(e){return new i(e.map(this.anchor),e.map(this.head))}resolve(e){return T.between(e.resolve(this.anchor),e.resolve(this.head))}},w=class i extends S{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:r}=t.mapResult(this.anchor),o=e.resolve(r);return n?S.near(o):new i(o)}content(){return new x(y.from(this.node),0,0)}eq(e){return e instanceof i&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ji(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new i(e.resolve(t.anchor))}static create(e,t){return new i(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};w.prototype.visible=!1;S.jsonID("node",w);var Ji=class i{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Fn(n,n):new i(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&w.isSelectable(n)?new w(t):S.near(t)}},le=class i extends S{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=x.empty){if(t==x.empty){e.delete(0,e.doc.content.size);let n=S.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new i(e)}map(e){return new i(e)}eq(e){return e instanceof i}getBookmark(){return mc}};S.jsonID("all",le);var mc={map(){return this},resolve(i){return new le(i)}};function Tt(i,e,t,n,r,o=!1){if(e.inlineContent)return T.create(i,t);for(let s=n-(r>0?0:1);r>0?s<e.childCount:s>=0;s+=r){let l=e.child(s);if(l.isAtom){if(!o&&w.isSelectable(l))return w.create(i,t-(r<0?l.nodeSize:0))}else{let a=Tt(i,l,t+r,r<0?l.childCount:0,r,o);if(a)return a}t+=l.nodeSize*r}return null}function ms(i,e,t){let n=i.steps.length-1;if(n<e)return;let r=i.steps[n];if(!(r instanceof se||r instanceof V))return;let o=i.mapping.maps[n],s;o.forEach((l,a,c,d)=>{s==null&&(s=d)}),i.setSelection(S.near(i.doc.resolve(s),t))}var gs=1,Ln=2,ys=4,ji=class 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|gs)&~Ln,this.storedMarks=null,this}get selectionSet(){return(this.updated&gs)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ln,this}ensureMarks(e){return I.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&Ln)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Ln,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)||I.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=n==t?s.marks():s.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(S.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ys,this}get scrolledIntoView(){return(this.updated&ys)>0}};function xs(i,e){return!e||!i?i:i.bind(e)}var st=class{constructor(e,t,n){this.name=e,this.init=xs(t.init,n),this.apply=xs(t.apply,n)}},gc=[new st("doc",{init(i){return i.doc||i.schema.topNodeType.createAndFill()},apply(i){return i.doc}}),new st("selection",{init(i,e){return i.selection||S.atStart(e.doc)},apply(i){return i.selection}}),new st("storedMarks",{init(i){return i.storedMarks||null},apply(i,e,t,n){return n.selection.$cursor?i.storedMarks:null}}),new st("scrollToSelection",{init(){return 0},apply(i,e){return i.scrolledIntoView?e+1:e}})],on=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=gc.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new st(n.key,n.spec.state,n))})}},Vn=class i{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 r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=r?r[s].n:0,c=r?r[s].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,n);if(d&&n.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!r){r=[];for(let u=0;u<this.config.plugins.length;u++)r.push(u<s?{state:n,n:t.length}:{state:this,n:0})}t.push(d),n=n.applyInner(d),o=!0}r&&(r[s]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new i(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new ji(this)}static create(e){let t=new on(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new i(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new on(this.schema,e.plugins),n=t.fields,r=new i(t);for(let o=0;o<n.length;o++){let s=n[o].name;r[s]=this.hasOwnProperty(s)?this[s]:n[o].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.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 r=new on(e.schema,e.plugins),o=new i(r);return r.fields.forEach(s=>{if(s.name=="doc")o.doc=ge.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=S.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let l in n){let a=n[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=c.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}};function bs(i,e,t){for(let n in i){let r=i[n];r instanceof Function?r=r.bind(e):n=="handleDOMEvents"&&(r=bs(r,e,{})),t[n]=r}return t}var G=class{constructor(e){this.spec=e,this.props={},e.props&&bs(e.props,this,this.props),this.key=e.key?e.key.key:ks("plugin")}getState(e){return e[this.key]}},Ki=Object.create(null);function ks(i){return i in Ki?i+"$"+ ++Ki[i]:(Ki[i]=0,i+"$")}var ae=class{constructor(e="key"){this.key=ks(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var W=function(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e},zt=function(i){let e=i.assignedSlot||i.parentNode;return e&&e.nodeType==11?e.host:e},Zi=null,Ee=function(i,e,t){let n=Zi||(Zi=document.createRange());return n.setEnd(i,t??i.nodeValue.length),n.setStart(i,e||0),n},yc=function(){Zi=null},ft=function(i,e,t,n){return t&&(Cs(i,e,t,n,-1)||Cs(i,e,t,n,1))},xc=/^(img|br|input|textarea|hr)$/i;function Cs(i,e,t,n,r){for(var o;;){if(i==t&&e==n)return!0;if(e==(r<0?0:de(i))){let s=i.parentNode;if(!s||s.nodeType!=1||fn(i)||xc.test(i.nodeName)||i.contentEditable=="false")return!1;e=W(i)+(r<0?0:1),i=s}else if(i.nodeType==1){let s=i.childNodes[e+(r<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=r;else return!1;else i=s,e=r<0?de(i):0}else return!1}}function de(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function bc(i,e){for(;;){if(i.nodeType==3&&e)return i;if(i.nodeType==1&&e>0){if(i.contentEditable=="false")return null;i=i.childNodes[e-1],e=de(i)}else if(i.parentNode&&!fn(i))e=W(i),i=i.parentNode;else return null}}function kc(i,e){for(;;){if(i.nodeType==3&&e<i.nodeValue.length)return i;if(i.nodeType==1&&e<i.childNodes.length){if(i.contentEditable=="false")return null;i=i.childNodes[e],e=0}else if(i.parentNode&&!fn(i))e=W(i)+1,i=i.parentNode;else return null}}function Cc(i,e,t){for(let n=e==0,r=e==de(i);n||r;){if(i==t)return!0;let o=W(i);if(i=i.parentNode,!i)return!1;n=n&&o==0,r=r&&o==de(i)}}function fn(i){let e;for(let t=i;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==i||e.contentDOM==i)}var Qn=function(i){return i.focusNode&&ft(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)};function lt(i,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=i,t.key=t.code=e,t}function wc(i){let e=i.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function _c(i,e,t){if(i.caretPositionFromPoint)try{let n=i.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(de(n.offsetNode),n.offset)}}catch{}if(i.caretRangeFromPoint){let n=i.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(de(n.startContainer),n.startOffset)}}}var ye=typeof navigator<"u"?navigator:null,ws=typeof document<"u"?document:null,We=ye&&ye.userAgent||"",er=/Edge\/(\d+)/.exec(We),el=/MSIE \d/.exec(We),tr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(We),re=!!(el||tr||er),He=el?document.documentMode:tr?+tr[1]:er?+er[1]:0,ue=!re&&/gecko\/(\d+)/i.test(We);ue&&+(/Firefox\/(\d+)/.exec(We)||[0,0])[1];var nr=!re&&/Chrome\/(\d+)/.exec(We),Q=!!nr,tl=nr?+nr[1]:0,ee=!re&&!!ye&&/Apple Computer/.test(ye.vendor),Bt=ee&&(/Mobile\/\w+/.test(We)||!!ye&&ye.maxTouchPoints>2),ce=Bt||(ye?/Mac/.test(ye.platform):!1),Sc=ye?/Win/.test(ye.platform):!1,Oe=/Android \d/.test(We),hn=!!ws&&"webkitFontSmoothing"in ws.documentElement.style,Mc=hn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function vc(i){let e=i.defaultView&&i.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:i.documentElement.clientWidth,top:0,bottom:i.documentElement.clientHeight}}function Ne(i,e){return typeof i=="number"?i:i[e]}function Nc(i){let e=i.getBoundingClientRect(),t=e.width/i.offsetWidth||1,n=e.height/i.offsetHeight||1;return{left:e.left,right:e.left+i.clientWidth*t,top:e.top,bottom:e.top+i.clientHeight*n}}function _s(i,e,t){let n=i.someProp("scrollThreshold")||0,r=i.someProp("scrollMargin")||5,o=i.dom.ownerDocument;for(let s=t||i.dom;s;){if(s.nodeType!=1){s=zt(s);continue}let l=s,a=l==o.body,c=a?vc(o):Nc(l),d=0,u=0;if(e.top<c.top+Ne(n,"top")?u=-(c.top-e.top+Ne(r,"top")):e.bottom>c.bottom-Ne(n,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Ne(r,"top")-c.top:e.bottom-c.bottom+Ne(r,"bottom")),e.left<c.left+Ne(n,"left")?d=-(c.left-e.left+Ne(r,"left")):e.right>c.right-Ne(n,"right")&&(d=e.right-c.right+Ne(r,"right")),d||u)if(a)o.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,f=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let m=l.scrollLeft-h,g=l.scrollTop-f;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let p=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(p))break;s=p=="absolute"?s.offsetParent:zt(s)}}function Ec(i){let e=i.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,r;for(let o=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=i.root.elementFromPoint(o,s);if(!l||l==i.dom||!i.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){n=l,r=a.top;break}}return{refDOM:n,refTop:r,stack:nl(i.dom)}}function nl(i){let e=[],t=i.ownerDocument;for(let n=i;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),i!=t);n=zt(n));return e}function Oc({refDOM:i,refTop:e,stack:t}){let n=i?i.getBoundingClientRect().top:0;il(t,n==0?0:n-e)}function il(i,e){for(let t=0;t<i.length;t++){let{dom:n,top:r,left:o}=i[t];n.scrollTop!=r+e&&(n.scrollTop=r+e),n.scrollLeft!=o&&(n.scrollLeft=o)}}var Dt=null;function Tc(i){if(i.setActive)return i.setActive();if(Dt)return i.focus(Dt);let e=nl(i);i.focus(Dt==null?{get preventScroll(){return Dt={preventScroll:!0},!0}}:void 0),Dt||(Dt=!1,il(e,0))}function rl(i,e){let t,n=2e8,r,o=0,s=e.top,l=e.top,a,c;for(let d=i.firstChild,u=0;d;d=d.nextSibling,u++){let p;if(d.nodeType==1)p=d.getClientRects();else if(d.nodeType==3)p=Ee(d).getClientRects();else continue;for(let h=0;h<p.length;h++){let f=p[h];if(f.top<=s&&f.bottom>=l){s=Math.max(f.bottom,s),l=Math.min(f.top,l);let m=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(m<n){t=d,n=m,r=m&&t.nodeType==3?{left:f.right<e.left?f.right:f.left,top:e.top}:e,d.nodeType==1&&m&&(o=u+(e.left>=(f.left+f.right)/2?1:0));continue}}else f.top>e.top&&!a&&f.left<=e.left&&f.right>=e.left&&(a=d,c={left:Math.max(f.left,Math.min(f.right,e.left)),top:f.top});!t&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(o=u+1)}}return!t&&a&&(t=a,r=c,n=0),t&&t.nodeType==3?Ic(t,r):!t||n&&t.nodeType==1?{node:i,offset:o}:rl(t,r)}function Ic(i,e){let t=i.nodeValue.length,n=document.createRange();for(let r=0;r<t;r++){n.setEnd(i,r+1),n.setStart(i,r);let o=Le(n,1);if(o.top!=o.bottom&&yr(e,o))return{node:i,offset:r+(e.left>=(o.left+o.right)/2?1:0)}}return{node:i,offset:0}}function yr(i,e){return i.left>=e.left-1&&i.left<=e.right+1&&i.top>=e.top-1&&i.top<=e.bottom+1}function Dc(i,e){let t=i.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<i.getBoundingClientRect().left?t:i}function Ac(i,e,t){let{node:n,offset:r}=rl(e,t),o=-1;if(n.nodeType==1&&!n.firstChild){let s=n.getBoundingClientRect();o=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return i.docView.posFromDOM(n,r,o)}function Pc(i,e,t,n){let r=-1;for(let o=e,s=!1;o!=i.dom;){let l=i.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>n.left||a.top>n.top?r=l.posBefore:(!s&&a.right<n.left||a.bottom<n.top)&&(r=l.posAfter),s=!0),!l.contentDOM&&r<0&&!l.node.isText))return(l.node.isBlock?n.top<(a.top+a.bottom)/2:n.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return r>-1?r:i.docView.posFromDOM(e,t,-1)}function ol(i,e,t){let n=i.childNodes.length;if(n&&t.top<t.bottom)for(let r=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),o=r;;){let s=i.childNodes[o];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(yr(e,c))return ol(s,e,c)}}if((o=(o+1)%n)==r)break}return i}function Rc(i,e){let t=i.dom.ownerDocument,n,r=0,o=_c(t,e.left,e.top);o&&({node:n,offset:r}=o);let s=(i.root.elementFromPoint?i.root:t).elementFromPoint(e.left,e.top),l;if(!s||!i.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=i.dom.getBoundingClientRect();if(!yr(e,c)||(s=ol(i.dom,e,c),!s))return null}if(ee)for(let c=s;n&&c;c=zt(c))c.draggable&&(n=void 0);if(s=Dc(s,e),n){if(ue&&n.nodeType==1&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let d=n.childNodes[r],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&r++}let c;hn&&r&&n.nodeType==1&&(c=n.childNodes[r-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&r--,n==i.dom&&r==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom?l=i.state.doc.content.size:(r==0||n.nodeType!=1||n.childNodes[r-1].nodeName!="BR")&&(l=Pc(i,n,r,e))}l==null&&(l=Ac(i,s,e));let a=i.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ss(i){return i.top<i.bottom||i.left<i.right}function Le(i,e){let t=i.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(Ss(n))return n}return Array.prototype.find.call(t,Ss)||i.getBoundingClientRect()}var zc=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function sl(i,e,t){let{node:n,offset:r,atom:o}=i.docView.domFromPos(e,t<0?-1:1),s=hn||ue;if(n.nodeType==3)if(s&&(zc.test(n.nodeValue)||(t<0?!r:r==n.nodeValue.length))){let a=Le(Ee(n,r,r),t);if(ue&&r&&/\s/.test(n.nodeValue[r-1])&&r<n.nodeValue.length){let c=Le(Ee(n,r-1,r-1),-1);if(c.top==a.top){let d=Le(Ee(n,r,r+1),-1);if(d.top!=a.top)return sn(d,d.left<c.left)}}return a}else{let a=r,c=r,d=t<0?1:-1;return t<0&&!r?(c++,d=-1):t>=0&&r==n.nodeValue.length?(a--,d=1):t<0?a--:c++,sn(Le(Ee(n,a,c),d),d<0)}if(!i.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&r&&(t<0||r==de(n))){let a=n.childNodes[r-1];if(a.nodeType==1)return Ui(a.getBoundingClientRect(),!1)}if(o==null&&r<de(n)){let a=n.childNodes[r];if(a.nodeType==1)return Ui(a.getBoundingClientRect(),!0)}return Ui(n.getBoundingClientRect(),t>=0)}if(o==null&&r&&(t<0||r==de(n))){let a=n.childNodes[r-1],c=a.nodeType==3?Ee(a,de(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return sn(Le(c,1),!1)}if(o==null&&r<de(n)){let a=n.childNodes[r];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ee(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return sn(Le(c,-1),!0)}return sn(Le(n.nodeType==3?Ee(n):n,-t),t>=0)}function sn(i,e){if(i.width==0)return i;let t=e?i.left:i.right;return{top:i.top,bottom:i.bottom,left:t,right:t}}function Ui(i,e){if(i.height==0)return i;let t=e?i.top:i.bottom;return{top:t,bottom:t,left:i.left,right:i.right}}function ll(i,e,t){let n=i.state,r=i.root.activeElement;n!=e&&i.updateState(e),r!=i.dom&&i.focus();try{return t()}finally{n!=e&&i.updateState(n),r!=i.dom&&r&&r.focus()}}function Bc(i,e,t){let n=e.selection,r=t=="up"?n.$from:n.$to;return ll(i,e,()=>{let{node:o}=i.docView.domFromPos(r.pos,t=="up"?-1:1);for(;;){let l=i.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=sl(i,r.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ee(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}var Lc=/[\u0590-\u08ac]/;function Fc(i,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let r=n.parentOffset,o=!r,s=r==n.parent.content.size,l=i.domSelection();return l?!Lc.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:ll(i,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=i.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",t,"character");let h=n.depth?i.docView.domAfterPos(n.before()):i.dom,{focusNode:f,focusOffset:m}=i.domSelectionRange(),g=f&&!h.contains(f.nodeType==1?f:f.parentNode)||a==f&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return p!=null&&(l.caretBidiLevel=p),g}):n.pos==n.start()||n.pos==n.end()}var Ms=null,vs=null,Ns=!1;function Vc(i,e,t){return Ms==e&&vs==t?Ns:(Ms=e,vs=t,Ns=t=="up"||t=="down"?Bc(i,e,t):Fc(i,e,t))}var pe=0,Es=1,at=2,xe=3,ht=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=pe,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 r=this.children[t];if(r==e)return n;n+=r.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(e.nodeType==1?e:e.parentNode))if(n<0){let o,s;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>W(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){r=!1;break}if(o.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){r=!0;break}if(o.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let o=this.getDesc(r),s;if(o&&(!t||o.node))if(n&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))n=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)for(let s=0;s<r.children.length;s++){let l=r.children[s];if(l.size){r=l;break}}return r}if(e<o)return r.descAt(e-n-r.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let o=0;n<this.children.length;n++){let s=this.children[n],l=o+s.size;if(l>e||s instanceof Wn){r=e-o;break}o=l}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof Hn&&o.side>=0;n--);if(t<=0){let o,s=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?W(o.dom)+1:0}}else{let o,s=!0;for(;o=n<this.children.length?this.children[n]:null,!(!o||o.dom.parentNode==this.contentDOM);n++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?W(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,o=-1;for(let s=n,l=0;;l++){let a=this.children[l],c=s+a.size;if(r==-1&&e<=c){let d=s+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=s;for(let u=l;u>0;u--){let p=this.children[u-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){r=W(p.dom)+1;break}e-=p.size}r==-1&&(r=0)}if(r>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){o=W(u.dom);break}t+=u.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let o=Math.min(e,t),s=Math.max(e,t);for(let h=0,f=0;h<this.children.length;h++){let m=this.children[h],g=f+m.size;if(o>f&&s<g)return m.setSelection(e-f-m.border,t-f-m.border,n,r);f=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),d=n.domSelectionRange(),u=!1;if((ue||ee)&&e==t){let{node:h,offset:f}=l;if(h.nodeType==3){if(u=!!(f&&h.nodeValue[f-1]==`
`),u&&f==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:W(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=h.childNodes[f-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(ue&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(r=!0)}if(!(r||u&&ee)&&ft(l.node,l.offset,d.anchorNode,d.anchorOffset)&&ft(a.node,a.offset,d.focusNode,d.focusOffset))return;let p=!1;if((c.extend||e==t)&&!(u&&ue)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),p=!0}catch{}}if(!p){if(e>t){let f=l;l=a,a=f}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let o=this.children[r],s=n+o.size;if(n==s?e<=s&&t>=n:e<s&&t>n){let l=n+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==n||t==s?at:Es,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=xe:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?at:xe}n=s}this.dirty=at}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?at:Es;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Hn=class extends ht{constructor(e,t,n,r){let o,s=t.type.toDOM;if(typeof s=="function"&&(s=s(n,()=>{if(!o)return r;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==pe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},ir=class extends ht{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Lt=class i extends ht{constructor(e,t,n,r,o){super(e,[],n,r),this.mark=t,this.spec=o}static create(e,t,n,r){let o=r.nodeViews[t.type.name],s=o&&o(t,r,n);return(!s||!s.dom)&&(s=Me.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new i(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&xe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=xe&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=pe){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=pe}}slice(e,t,n){let r=i.create(this.parent,this.mark,!0,n),o=this.children,s=this.size;t<s&&(o=lr(o,t,s,n)),e>0&&(o=lr(o,0,e,n));for(let l=0;l<o.length;l++)o[l].parent=r;return r.children=o,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},$e=class i extends ht{constructor(e,t,n,r,o,s,l,a,c){super(e,[],o,s),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=l}static create(e,t,n,r,o,s){let l=o.nodeViews[t.type.name],a,c=l&&l(t,o,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},n,r),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Me.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let p=d;return d=dl(d,n,t),c?a=new rr(e,t,n,r,d,u||null,p,c,o,s+1):t.isText?new $n(e,t,n,r,d,p,o):new i(e,t,n,r,d,u||null,p,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let 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=()=>y.empty)}return e}matchesNode(e,t,n){return this.dirty==pe&&e.eq(this.node)&&qn(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,r=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new sr(this,s&&s.node,e);qc(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,n,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?I.none:this.node.child(d).marks,n,e),a.placeWidget(c,e,r)},(c,d,u,p)=>{a.syncToMarks(c.marks,n,e);let h;a.findNodeMatch(c,d,u,p)||l&&e.state.selection.from>r&&e.state.selection.to<r+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,p,r)||a.addNode(c,d,u,e,r),r+=c.nodeSize}),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==at)&&(s&&this.protectLocalComposition(e,s),al(this.contentDOM,this.children,e),Bt&&Kc(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof T)||n<t||r>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=Jc(this.node.content,s,n-t,r-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new ir(this,o,t,r);e.input.compositionNodes.push(s),this.children=lr(this.children,n,n+r.length,e,s)}update(e,t,n,r){return this.dirty==xe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=pe}updateOuterDeco(e){if(qn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=cl(this.dom,this.nodeDOM,or(this.outerDeco,this.node,t),or(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Os(i,e,t,n,r){dl(n,e,i);let o=new $e(void 0,i,e,t,n,n,n,r,0);return o.contentDOM&&o.updateChildren(r,0),o}var $n=class i extends $e{constructor(e,t,n,r,o,s,l){super(e,t,n,r,o,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==xe||this.dirty!=pe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=pe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=pe,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let r=this.node.cut(e,t),o=document.createTextNode(r.text);return new i(this.parent,r,this.outerDeco,this.innerDeco,o,o,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=xe)}get domAtom(){return!1}isText(e){return this.node.text==e}},Wn=class extends ht{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==pe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},rr=class extends $e{constructor(e,t,n,r,o,s,l,a,c,d){super(e,t,n,r,o,s,l,c,d),this.spec=a}update(e,t,n,r){if(this.dirty==xe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,r),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function al(i,e,t){let n=i.firstChild,r=!1;for(let o=0;o<e.length;o++){let s=e[o],l=s.dom;if(l.parentNode==i){for(;l!=n;)n=Ts(n),r=!0;n=n.nextSibling}else r=!0,i.insertBefore(l,n);if(s instanceof Lt){let a=n?n.previousSibling:i.lastChild;al(s.contentDOM,s.children,t),n=a?a.nextSibling:i.firstChild}}for(;n;)n=Ts(n),r=!0;r&&t.trackWrites==i&&(t.trackWrites=null)}var ln=function(i){i&&(this.nodeName=i)};ln.prototype=Object.create(null);var ct=[new ln];function or(i,e,t){if(i.length==0)return ct;let n=t?ct[0]:new ln,r=[n];for(let o=0;o<i.length;o++){let s=i[o].type.attrs;if(s){s.nodeName&&r.push(n=new ln(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&r.length==1&&r.push(n=new ln(e.isInline?"span":"div")),l=="class"?n.class=(n.class?n.class+" ":"")+a:l=="style"?n.style=(n.style?n.style+";":"")+a:l!="nodeName"&&(n[l]=a))}}}return r}function cl(i,e,t,n){if(t==ct&&n==ct)return e;let r=e;for(let o=0;o<n.length;o++){let s=n[o],l=t[o];if(o){let a;l&&l.nodeName==s.nodeName&&r!=i&&(a=r.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(r),l=ct[0]),r=a}Hc(r,l||ct[0],s)}return r}function Hc(i,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&i.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&i.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],r=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<n.length;o++)r.indexOf(n[o])==-1&&i.classList.remove(n[o]);for(let o=0;o<r.length;o++)n.indexOf(r[o])==-1&&i.classList.add(r[o]);i.classList.length==0&&i.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(e.style);)i.style.removeProperty(r[1])}t.style&&(i.style.cssText+=t.style)}}function dl(i,e,t){return cl(i,i,ct,or(e,t,i.nodeType!=1))}function qn(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(!i[t].type.eq(e[t].type))return!1;return!0}function Ts(i){let e=i.nextSibling;return i.parentNode.removeChild(i),e}var sr=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=$c(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 r=0,o=this.stack.length>>1,s=Math.min(o,e.length);for(;r<s&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&e[r].type.spec.spanning!==!1;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=pe,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[o])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Lt.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let o=-1,s;if(r>=this.preMatch.index&&(s=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,n))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,n,r,o){let s=this.top.children[r];return s.dirty==xe&&s.dom==s.contentDOM&&(s.dirty=at),s.update(e,t,n,o)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==n)return r}return-1}e=t}}updateNextNode(e,t,n,r,o,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof $e){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let d=a.dom,u,p=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=xe&&qn(t,a.outerDeco));if(!p&&a.update(e,t,n,r))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!p&&(u=this.recreateWrapper(a,e,t,n,r,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=at,u.updateChildren(r,s+1),u.dirty=pe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,o,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!qn(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let l=$e.create(this.top,t,n,r,o,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,n,r,o){let s=$e.create(this.top,e,t,n,r,o);s.contentDOM&&s.updateChildren(r,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let o=new Hn(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Lt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof $n)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ee||Q)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let r=new Wn(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function $c(i,e){let t=e,n=t.children.length,r=i.childCount,o=new Map,s=[];e:for(;r>0;){let l;for(;;)if(n){let c=t.children[n-1];if(c instanceof Lt)t=c,n=c.children.length;else{l=c,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=i.child(r-1))break;--r,o.set(l,r),s.push(l)}}return{index:r,matched:o,matches:s.reverse()}}function Wc(i,e){return i.type.side-e.type.side}function qc(i,e,t,n){let r=e.locals(i),o=0;if(r.length==0){for(let c=0;c<i.childCount;c++){let d=i.child(c);n(d,r,e.forChild(o,d),c),o+=d.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,u;for(;s<r.length&&r[s].to==o;){let g=r[s++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(Wc);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let p,h;if(a)h=-1,p=a,a=null;else if(c<i.childCount)h=c,p=i.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=o&&l.splice(g--,1);for(;s<r.length&&r[s].from<=o&&r[s].to>o;)l.push(r[s++]);let f=o+p.nodeSize;if(p.isText){let g=f;s<r.length&&r[s].from<g&&(g=r[s].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<f&&(a=p.cut(g-o),p=p.cut(0,g-o),f=g,h=-1)}else for(;s<r.length&&r[s].to<f;)s++;let m=p.isInline&&!p.isLeaf?l.filter(g=>!g.inline):l.slice();n(p,m,e.forChild(o,p),h),o=f}}function Kc(i){if(i.nodeName=="UL"||i.nodeName=="OL"){let e=i.style.cssText;i.style.cssText=e+"; list-style: square !important",window.getComputedStyle(i).listStyle,i.style.cssText=e}}function Jc(i,e,t,n){for(let r=0,o=0;r<i.childCount&&o<=n;){let s=i.child(r++),l=o;if(o+=s.nodeSize,!s.isText)continue;let a=s.text;for(;r<i.childCount;){let c=i.child(r++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=t){if(o>=n&&a.slice(n-e.length-l,n-l)==e)return n-e.length;let c=l<n?a.lastIndexOf(e,n-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==n&&a.length>=n+e.length-l&&a.slice(n-l,n-l+e.length)==e)return n}}return-1}function lr(i,e,t,n,r){let o=[];for(let s=0,l=0;s<i.length;s++){let a=i[s],c=l,d=l+=a.size;c>=t||d<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,n)),r&&(o.push(r),r=void 0),d>t&&o.push(a.slice(t-c,a.size,n)))}return o}function xr(i,e=null){let t=i.domSelectionRange(),n=i.state.doc;if(!t.focusNode)return null;let r=i.docView.nearestDesc(t.focusNode),o=r&&r.size==0,s=i.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=n.resolve(s),a,c;if(Qn(t)){for(a=s;r&&!r.node;)r=r.parent;let u=r.node;if(r&&u.isAtom&&w.isSelectable(u)&&r.parent&&!(u.isInline&&Cc(t.focusNode,t.focusOffset,r.dom))){let p=r.posBefore;c=new w(s==p?l:n.resolve(p))}}else{if(t instanceof i.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=s,p=s;for(let h=0;h<t.rangeCount;h++){let f=t.getRangeAt(h);u=Math.min(u,i.docView.posFromDOM(f.startContainer,f.startOffset,1)),p=Math.max(p,i.docView.posFromDOM(f.endContainer,f.endOffset,-1))}if(u<0)return null;[a,s]=p==i.state.selection.anchor?[p,u]:[u,p],l=n.resolve(s)}else a=i.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=n.resolve(a);if(!c){let u=e=="pointer"||i.state.selection.head<l.pos&&!o?1:-1;c=br(i,d,l,u)}return c}function ul(i){return i.editable?i.hasFocus():fl(i)&&document.activeElement&&document.activeElement.contains(i.dom)}function Te(i,e=!1){let t=i.state.selection;if(pl(i,t),!!ul(i)){if(!e&&i.input.mouseDown&&i.input.mouseDown.allowDefault&&Q){let n=i.domSelectionRange(),r=i.domObserver.currentSelection;if(n.anchorNode&&r.anchorNode&&ft(n.anchorNode,n.anchorOffset,r.anchorNode,r.anchorOffset)){i.input.mouseDown.delayedSelectionSync=!0,i.domObserver.setCurSelection();return}}if(i.domObserver.disconnectSelection(),i.cursorWrapper)Uc(i);else{let{anchor:n,head:r}=t,o,s;Is&&!(t instanceof T)&&(t.$from.parent.inlineContent||(o=Ds(i,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=Ds(i,t.to))),i.docView.setSelection(n,r,i,e),Is&&(o&&As(o),s&&As(s)),t.visible?i.dom.classList.remove("ProseMirror-hideselection"):(i.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&jc(i))}i.domObserver.setCurSelection(),i.domObserver.connectSelection()}}var Is=ee||Q&&tl<63;function Ds(i,e){let{node:t,offset:n}=i.docView.domFromPos(e,0),r=n<t.childNodes.length?t.childNodes[n]:null,o=n?t.childNodes[n-1]:null;if(ee&&r&&r.contentEditable=="false")return Gi(r);if((!r||r.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(r)return Gi(r);if(o)return Gi(o)}}function Gi(i){return i.contentEditable="true",ee&&i.draggable&&(i.draggable=!1,i.wasDraggable=!0),i}function As(i){i.contentEditable="false",i.wasDraggable&&(i.draggable=!0,i.wasDraggable=null)}function jc(i){let e=i.dom.ownerDocument;e.removeEventListener("selectionchange",i.input.hideSelectionGuard);let t=i.domSelectionRange(),n=t.anchorNode,r=t.anchorOffset;e.addEventListener("selectionchange",i.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=r)&&(e.removeEventListener("selectionchange",i.input.hideSelectionGuard),setTimeout(()=>{(!ul(i)||i.state.selection.visible)&&i.dom.classList.remove("ProseMirror-hideselection")},20))})}function Uc(i){let e=i.domSelection();if(!e)return;let t=i.cursorWrapper.dom,n=t.nodeName=="IMG";n?e.collapse(t.parentNode,W(t)+1):e.collapse(t,0),!n&&!i.state.selection.visible&&re&&He<=11&&(t.disabled=!0,t.disabled=!1)}function pl(i,e){if(e instanceof w){let t=i.docView.descAt(e.from);t!=i.lastSelectedViewDesc&&(Ps(i),t&&t.selectNode(),i.lastSelectedViewDesc=t)}else Ps(i)}function Ps(i){i.lastSelectedViewDesc&&(i.lastSelectedViewDesc.parent&&i.lastSelectedViewDesc.deselectNode(),i.lastSelectedViewDesc=void 0)}function br(i,e,t,n){return i.someProp("createSelectionBetween",r=>r(i,e,t))||T.between(e,t,n)}function Rs(i){return i.editable&&!i.hasFocus()?!1:fl(i)}function fl(i){let e=i.domSelectionRange();if(!e.anchorNode)return!1;try{return i.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(i.editable||i.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Gc(i){let e=i.docView.domFromPos(i.state.selection.anchor,0),t=i.domSelectionRange();return ft(e.node,e.offset,t.anchorNode,t.anchorOffset)}function ar(i,e){let{$anchor:t,$head:n}=i.selection,r=e>0?t.max(n):t.min(n),o=r.parent.inlineContent?r.depth?i.doc.resolve(e>0?r.after():r.before()):null:r;return o&&S.findFrom(o,e)}function Fe(i,e){return i.dispatch(i.state.tr.setSelection(e).scrollIntoView()),!0}function zs(i,e,t){let n=i.state.selection;if(n instanceof T)if(t.indexOf("s")>-1){let{$head:r}=n,o=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=i.state.doc.resolve(r.pos+o.nodeSize*(e<0?-1:1));return Fe(i,new T(n.$anchor,s))}else if(n.empty){if(i.endOfTextblock(e>0?"forward":"backward")){let r=ar(i.state,e);return r&&r instanceof w?Fe(i,r):!1}else if(!(ce&&t.indexOf("m")>-1)){let r=n.$head,o=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?r.pos-o.nodeSize:r.pos;return o.isAtom||(s=i.docView.descAt(l))&&!s.contentDOM?w.isSelectable(o)?Fe(i,new w(e<0?i.state.doc.resolve(r.pos-o.nodeSize):r)):hn?Fe(i,new T(i.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof w&&n.node.isInline)return Fe(i,new T(e>0?n.$to:n.$from));{let r=ar(i.state,e);return r?Fe(i,r):!1}}}function Kn(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function an(i,e){let t=i.pmViewDesc;return t&&t.size==0&&(e<0||i.nextSibling||i.nodeName!="BR")}function At(i,e){return e<0?Xc(i):Qc(i)}function Xc(i){let e=i.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let r,o,s=!1;for(ue&&t.nodeType==1&&n<Kn(t)&&an(t.childNodes[n],-1)&&(s=!0);;)if(n>0){if(t.nodeType!=1)break;{let l=t.childNodes[n-1];if(an(l,-1))r=t,o=--n;else if(l.nodeType==3)t=l,n=t.nodeValue.length;else break}}else{if(hl(t))break;{let l=t.previousSibling;for(;l&&an(l,-1);)r=t.parentNode,o=W(l),l=l.previousSibling;if(l)t=l,n=Kn(t);else{if(t=t.parentNode,t==i.dom)break;n=0}}}s?cr(i,t,n):r&&cr(i,r,o)}function Qc(i){let e=i.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let r=Kn(t),o,s;for(;;)if(n<r){if(t.nodeType!=1)break;let l=t.childNodes[n];if(an(l,1))o=t,s=++n;else break}else{if(hl(t))break;{let l=t.nextSibling;for(;l&&an(l,1);)o=l.parentNode,s=W(l)+1,l=l.nextSibling;if(l)t=l,n=0,r=Kn(t);else{if(t=t.parentNode,t==i.dom)break;n=r=0}}}o&&cr(i,o,s)}function hl(i){let e=i.pmViewDesc;return e&&e.node&&e.node.isBlock}function Yc(i,e){for(;i&&e==i.childNodes.length&&!fn(i);)e=W(i)+1,i=i.parentNode;for(;i&&e<i.childNodes.length;){let t=i.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;i=t,e=0}}function Zc(i,e){for(;i&&!e&&!fn(i);)e=W(i),i=i.parentNode;for(;i&&e;){let t=i.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;i=t,e=i.childNodes.length}}function cr(i,e,t){if(e.nodeType!=3){let o,s;(s=Yc(e,t))?(e=s,t=0):(o=Zc(e,t))&&(e=o,t=o.nodeValue.length)}let n=i.domSelection();if(!n)return;if(Qn(n)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),n.removeAllRanges(),n.addRange(o)}else n.extend&&n.extend(e,t);i.domObserver.setCurSelection();let{state:r}=i;setTimeout(()=>{i.state==r&&Te(i)},50)}function Bs(i,e){let t=i.state.doc.resolve(e);if(!(Q||Sc)&&t.parent.inlineContent){let r=i.coordsAtPos(e);if(e>t.start()){let o=i.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(o.left-r.left)>1)return o.left<r.left?"ltr":"rtl"}if(e<t.end()){let o=i.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(o.left-r.left)>1)return o.left>r.left?"ltr":"rtl"}}return getComputedStyle(i.dom).direction=="rtl"?"rtl":"ltr"}function Ls(i,e,t){let n=i.state.selection;if(n instanceof T&&!n.empty||t.indexOf("s")>-1||ce&&t.indexOf("m")>-1)return!1;let{$from:r,$to:o}=n;if(!r.parent.inlineContent||i.endOfTextblock(e<0?"up":"down")){let s=ar(i.state,e);if(s&&s instanceof w)return Fe(i,s)}if(!r.parent.inlineContent){let s=e<0?r:o,l=n instanceof le?S.near(s,e):S.findFrom(s,e);return l?Fe(i,l):!1}return!1}function Fs(i,e){if(!(i.state.selection instanceof T))return!0;let{$head:t,$anchor:n,empty:r}=i.state.selection;if(!t.sameParent(n))return!0;if(!r)return!1;if(i.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=i.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),i.dispatch(s),!0}return!1}function Vs(i,e,t){i.domObserver.stop(),e.contentEditable=t,i.domObserver.start()}function ed(i){if(!ee||i.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=i.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;Vs(i,n,"true"),setTimeout(()=>Vs(i,n,"false"),20)}return!1}function td(i){let e="";return i.ctrlKey&&(e+="c"),i.metaKey&&(e+="m"),i.altKey&&(e+="a"),i.shiftKey&&(e+="s"),e}function nd(i,e){let t=e.keyCode,n=td(e);if(t==8||ce&&t==72&&n=="c")return Fs(i,-1)||At(i,-1);if(t==46&&!e.shiftKey||ce&&t==68&&n=="c")return Fs(i,1)||At(i,1);if(t==13||t==27)return!0;if(t==37||ce&&t==66&&n=="c"){let r=t==37?Bs(i,i.state.selection.from)=="ltr"?-1:1:-1;return zs(i,r,n)||At(i,r)}else if(t==39||ce&&t==70&&n=="c"){let r=t==39?Bs(i,i.state.selection.from)=="ltr"?1:-1:1;return zs(i,r,n)||At(i,r)}else{if(t==38||ce&&t==80&&n=="c")return Ls(i,-1,n)||At(i,-1);if(t==40||ce&&t==78&&n=="c")return ed(i)||Ls(i,1,n)||At(i,1);if(n==(ce?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function kr(i,e){i.someProp("transformCopied",h=>{e=h(e,i)});let t=[],{content:n,openStart:r,openEnd:o}=e;for(;r>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){r--,o--;let h=n.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),n=h.content}let s=i.someProp("clipboardSerializer")||Me.fromSchema(i.state.schema),l=kl(),a=l.createElement("div");a.appendChild(s.serializeFragment(n,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=bl[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let f=l.createElement(d[h]);for(;a.firstChild;)f.appendChild(a.firstChild);a.appendChild(f),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${r} ${o}${u?` -${u}`:""} ${JSON.stringify(t)}`);let p=i.someProp("clipboardTextSerializer",h=>h(e,i))||e.content.textBetween(0,e.content.size,`
`);return{dom:a,text:p,slice:e}}function ml(i,e,t,n,r){let o=r.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=!!e&&(n||o||!t);if(a){if(i.someProp("transformPastedText",p=>{e=p(e,o||n,i)}),o)return l=new x(y.from(i.state.schema.text(e.replace(/\r\n?/g,`
`))),0,0),i.someProp("transformPasted",p=>{l=p(l,i,!0)}),l;let u=i.someProp("clipboardTextParser",p=>p(e,r,n,i));if(u)l=u;else{let p=r.marks(),{schema:h}=i.state,f=Me.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(f.serializeNode(h.text(m,p)))})}}else i.someProp("transformPastedHTML",u=>{t=u(t,i)}),s=sd(t),hn&&ld(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let p=s.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;s=p}if(l||(l=(i.someProp("clipboardParser")||i.someProp("domParser")||ze.fromSchema(i.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||d),context:r,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!id.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=ad(Hs(l,+d[1],+d[2]),d[4]);else if(l=x.maxOpen(rd(l.content,r),!0),l.openStart||l.openEnd){let u=0,p=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;p<l.openEnd&&!h.type.spec.isolating;p++,h=h.lastChild);l=Hs(l,u,p)}return i.someProp("transformPasted",u=>{l=u(l,i,a)}),l}var id=/^(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 rd(i,e){if(i.childCount<2)return i;for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(i.forEach(l=>{if(!s)return;let a=r.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&yl(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=xl(s[s.length-1],o.length));let d=gl(l,a);s.push(d),r=r.matchType(d.type),o=a}}),s)return y.from(s)}return i}function gl(i,e,t=0){for(let n=e.length-1;n>=t;n--)i=e[n].create(null,y.from(i));return i}function yl(i,e,t,n,r){if(r<i.length&&r<e.length&&i[r]==e[r]){let o=yl(i,e,t,n.lastChild,r+1);if(o)return n.copy(n.content.replaceChild(n.childCount-1,o));if(n.contentMatchAt(n.childCount).matchType(r==i.length-1?t.type:i[r+1]))return n.copy(n.content.append(y.from(gl(t,i,r+1))))}}function xl(i,e){if(e==0)return i;let t=i.content.replaceChild(i.childCount-1,xl(i.lastChild,e-1)),n=i.contentMatchAt(i.childCount).fillBefore(y.empty,!0);return i.copy(t.append(n))}function dr(i,e,t,n,r,o){let s=e<0?i.firstChild:i.lastChild,l=s.content;return i.childCount>1&&(o=0),r<n-1&&(l=dr(l,e,t,n,r+1,o)),r>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=r).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(y.empty,!0))),i.replaceChild(e<0?0:i.childCount-1,s.copy(l))}function Hs(i,e,t){return e<i.openStart&&(i=new x(dr(i.content,-1,e,i.openStart,0,i.openEnd),e,i.openEnd)),t<i.openEnd&&(i=new x(dr(i.content,1,t,i.openEnd,0,0),i.openStart,t)),i}var bl={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},$s=null;function kl(){return $s||($s=document.implementation.createHTMLDocument("title"))}var Xi=null;function od(i){let e=window.trustedTypes;return e?(Xi||(Xi=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Xi.createHTML(i)):i}function sd(i){let e=/^(\s*<meta [^>]*>)*/.exec(i);e&&(i=i.slice(e[0].length));let t=kl().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(i),r;if((r=n&&bl[n[1].toLowerCase()])&&(i=r.map(o=>"<"+o+">").join("")+i+r.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=od(i),r)for(let o=0;o<r.length;o++)t=t.querySelector(r[o])||t;return t}function ld(i){let e=i.querySelectorAll(Q?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent=="\xA0"&&n.parentNode&&n.parentNode.replaceChild(i.ownerDocument.createTextNode(" "),n)}}function ad(i,e){if(!i.size)return i;let t=i.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return i}let{content:r,openStart:o,openEnd:s}=i;for(let l=n.length-2;l>=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;r=y.from(a.create(n[l+1],r)),o++,s++}return new x(r,o,s)}var te={},ne={},cd={touchstart:!0,touchmove:!0},ur=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function dd(i){for(let e in te){let t=te[e];i.dom.addEventListener(e,i.input.eventHandlers[e]=n=>{pd(i,n)&&!Cr(i,n)&&(i.editable||!(n.type in ne))&&t(i,n)},cd[e]?{passive:!0}:void 0)}ee&&i.dom.addEventListener("input",()=>null),pr(i)}function Ve(i,e){i.input.lastSelectionOrigin=e,i.input.lastSelectionTime=Date.now()}function ud(i){i.domObserver.stop();for(let e in i.input.eventHandlers)i.dom.removeEventListener(e,i.input.eventHandlers[e]);clearTimeout(i.input.composingTimeout),clearTimeout(i.input.lastIOSEnterFallbackTimeout)}function pr(i){i.someProp("handleDOMEvents",e=>{for(let t in e)i.input.eventHandlers[t]||i.dom.addEventListener(t,i.input.eventHandlers[t]=n=>Cr(i,n))})}function Cr(i,e){return i.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(i,e)||e.defaultPrevented:!1})}function pd(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=i.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function fd(i,e){!Cr(i,e)&&te[e.type]&&(i.editable||!(e.type in ne))&&te[e.type](i,e)}ne.keydown=(i,e)=>{let t=e;if(i.input.shiftKey=t.keyCode==16||t.shiftKey,!wl(i,t)&&(i.input.lastKeyCode=t.keyCode,i.input.lastKeyCodeTime=Date.now(),!(Oe&&Q&&t.keyCode==13)))if(t.keyCode!=229&&i.domObserver.forceFlush(),Bt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();i.input.lastIOSEnter=n,i.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{i.input.lastIOSEnter==n&&(i.someProp("handleKeyDown",r=>r(i,lt(13,"Enter"))),i.input.lastIOSEnter=0)},200)}else i.someProp("handleKeyDown",n=>n(i,t))||nd(i,t)?t.preventDefault():Ve(i,"key")};ne.keyup=(i,e)=>{e.keyCode==16&&(i.input.shiftKey=!1)};ne.keypress=(i,e)=>{let t=e;if(wl(i,t)||!t.charCode||t.ctrlKey&&!t.altKey||ce&&t.metaKey)return;if(i.someProp("handleKeyPress",r=>r(i,t))){t.preventDefault();return}let n=i.state.selection;if(!(n instanceof T)||!n.$from.sameParent(n.$to)){let r=String.fromCharCode(t.charCode),o=()=>i.state.tr.insertText(r).scrollIntoView();!/[\r\n]/.test(r)&&!i.someProp("handleTextInput",s=>s(i,n.$from.pos,n.$to.pos,r,o))&&i.dispatch(o()),t.preventDefault()}};function Yn(i){return{left:i.clientX,top:i.clientY}}function hd(i,e){let t=e.x-i.clientX,n=e.y-i.clientY;return t*t+n*n<100}function wr(i,e,t,n,r){if(n==-1)return!1;let o=i.state.doc.resolve(n);for(let s=o.depth+1;s>0;s--)if(i.someProp(e,l=>s>o.depth?l(i,t,o.nodeAfter,o.before(s),r,!0):l(i,t,o.node(s),o.before(s),r,!1)))return!0;return!1}function Rt(i,e,t){if(i.focused||i.focus(),i.state.selection.eq(e))return;let n=i.state.tr.setSelection(e);t=="pointer"&&n.setMeta("pointer",!0),i.dispatch(n)}function md(i,e){if(e==-1)return!1;let t=i.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&w.isSelectable(n)?(Rt(i,new w(t),"pointer"),!0):!1}function gd(i,e){if(e==-1)return!1;let t=i.state.selection,n,r;t instanceof w&&(n=t.node);let o=i.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(w.isSelectable(l)){n&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?r=o.before(t.$from.depth):r=o.before(s);break}}return r!=null?(Rt(i,w.create(i.state.doc,r),"pointer"),!0):!1}function yd(i,e,t,n,r){return wr(i,"handleClickOn",e,t,n)||i.someProp("handleClick",o=>o(i,e,n))||(r?gd(i,t):md(i,t))}function xd(i,e,t,n){return wr(i,"handleDoubleClickOn",e,t,n)||i.someProp("handleDoubleClick",r=>r(i,e,n))}function bd(i,e,t,n){return wr(i,"handleTripleClickOn",e,t,n)||i.someProp("handleTripleClick",r=>r(i,e,n))||kd(i,t,n)}function kd(i,e,t){if(t.button!=0)return!1;let n=i.state.doc;if(e==-1)return n.inlineContent?(Rt(i,T.create(n,0,n.content.size),"pointer"),!0):!1;let r=n.resolve(e);for(let o=r.depth+1;o>0;o--){let s=o>r.depth?r.nodeAfter:r.node(o),l=r.before(o);if(s.inlineContent)Rt(i,T.create(n,l+1,l+1+s.content.size),"pointer");else if(w.isSelectable(s))Rt(i,w.create(n,l),"pointer");else continue;return!0}}function _r(i){return Jn(i)}var Cl=ce?"metaKey":"ctrlKey";te.mousedown=(i,e)=>{let t=e;i.input.shiftKey=t.shiftKey;let n=_r(i),r=Date.now(),o="singleClick";r-i.input.lastClick.time<500&&hd(t,i.input.lastClick)&&!t[Cl]&&i.input.lastClick.button==t.button&&(i.input.lastClick.type=="singleClick"?o="doubleClick":i.input.lastClick.type=="doubleClick"&&(o="tripleClick")),i.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:o,button:t.button};let s=i.posAtCoords(Yn(t));s&&(o=="singleClick"?(i.input.mouseDown&&i.input.mouseDown.done(),i.input.mouseDown=new fr(i,s,t,!!n)):(o=="doubleClick"?xd:bd)(i,s.pos,s.inside,t)?t.preventDefault():Ve(i,"pointer"))};var fr=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Cl],this.allowDefault=n.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let d=e.state.doc.resolve(t.pos);o=d.parent,s=d.depth?d.before():0}let l=r?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(n.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof w&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ue&&!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)),Ve(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(()=>Te(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(Yn(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ve(this.view,"pointer"):yd(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ee&&this.mightDrag&&!this.mightDrag.node.isAtom||Q&&!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)?(Rt(this.view,S.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ve(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ve(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};te.touchstart=i=>{i.input.lastTouch=Date.now(),_r(i),Ve(i,"pointer")};te.touchmove=i=>{i.input.lastTouch=Date.now(),Ve(i,"pointer")};te.contextmenu=i=>_r(i);function wl(i,e){return i.composing?!0:ee&&Math.abs(e.timeStamp-i.input.compositionEndedAt)<500?(i.input.compositionEndedAt=-2e8,!0):!1}var Cd=Oe?5e3:-1;ne.compositionstart=ne.compositionupdate=i=>{if(!i.composing){i.domObserver.flush();let{state:e}=i,t=e.selection.$to;if(e.selection instanceof T&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)))i.markCursor=i.state.storedMarks||t.marks(),Jn(i,!0),i.markCursor=null;else if(Jn(i,!e.selection.empty),ue&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=i.domSelectionRange();for(let r=n.focusNode,o=n.focusOffset;r&&r.nodeType==1&&o!=0;){let s=o<0?r.lastChild:r.childNodes[o-1];if(!s)break;if(s.nodeType==3){let l=i.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else r=s,o=-1}}i.input.composing=!0}_l(i,Cd)};ne.compositionend=(i,e)=>{i.composing&&(i.input.composing=!1,i.input.compositionEndedAt=e.timeStamp,i.input.compositionPendingChanges=i.domObserver.pendingRecords().length?i.input.compositionID:0,i.input.compositionNode=null,i.input.compositionPendingChanges&&Promise.resolve().then(()=>i.domObserver.flush()),i.input.compositionID++,_l(i,20))};function _l(i,e){clearTimeout(i.input.composingTimeout),e>-1&&(i.input.composingTimeout=setTimeout(()=>Jn(i),e))}function Sl(i){for(i.composing&&(i.input.composing=!1,i.input.compositionEndedAt=_d());i.input.compositionNodes.length>0;)i.input.compositionNodes.pop().markParentsDirty()}function wd(i){let e=i.domSelectionRange();if(!e.focusNode)return null;let t=bc(e.focusNode,e.focusOffset),n=kc(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let r=n.pmViewDesc,o=i.domObserver.lastChangedTextNode;if(t==o||n==o)return o;if(!r||!r.isText(n.nodeValue))return n;if(i.input.compositionNode==n){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return n}}return t||n}function _d(){let i=document.createEvent("Event");return i.initEvent("event",!0,!0),i.timeStamp}function Jn(i,e=!1){if(!(Oe&&i.domObserver.flushingSoon>=0)){if(i.domObserver.forceFlush(),Sl(i),e||i.docView&&i.docView.dirty){let t=xr(i),n=i.state.selection;return t&&!t.eq(n)?i.dispatch(i.state.tr.setSelection(t)):(i.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?i.dispatch(i.state.tr.deleteSelection()):i.updateState(i.state),!0}return!1}}function Sd(i,e){if(!i.dom.parentNode)return;let t=i.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),r=document.createRange();r.selectNodeContents(e),i.dom.blur(),n.removeAllRanges(),n.addRange(r),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),i.focus()},50)}var cn=re&&He<15||Bt&&Mc<604;te.copy=ne.cut=(i,e)=>{let t=e,n=i.state.selection,r=t.type=="cut";if(n.empty)return;let o=cn?null:t.clipboardData,s=n.content(),{dom:l,text:a}=kr(i,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Sd(i,l),r&&i.dispatch(i.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Md(i){return i.openStart==0&&i.openEnd==0&&i.content.childCount==1?i.content.firstChild:null}function vd(i,e){if(!i.dom.parentNode)return;let t=i.input.shiftKey||i.state.selection.$from.parent.type.spec.code,n=i.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let r=i.input.shiftKey&&i.input.lastKeyCode!=45;setTimeout(()=>{i.focus(),n.parentNode&&n.parentNode.removeChild(n),t?dn(i,n.value,null,r,e):dn(i,n.textContent,n.innerHTML,r,e)},50)}function dn(i,e,t,n,r){let o=ml(i,e,t,n,i.state.selection.$from);if(i.someProp("handlePaste",a=>a(i,r,o||x.empty)))return!0;if(!o)return!1;let s=Md(o),l=s?i.state.tr.replaceSelectionWith(s,n):i.state.tr.replaceSelection(o);return i.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ml(i){let e=i.getData("text/plain")||i.getData("Text");if(e)return e;let t=i.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ne.paste=(i,e)=>{let t=e;if(i.composing&&!Oe)return;let n=cn?null:t.clipboardData,r=i.input.shiftKey&&i.input.lastKeyCode!=45;n&&dn(i,Ml(n),n.getData("text/html"),r,t)?t.preventDefault():vd(i,t)};var jn=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Nd=ce?"altKey":"ctrlKey";function vl(i,e){let t=i.someProp("dragCopies",n=>!n(e));return t??!e[Nd]}te.dragstart=(i,e)=>{let t=e,n=i.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let r=i.state.selection,o=r.empty?null:i.posAtCoords(Yn(t)),s;if(!(o&&o.pos>=r.from&&o.pos<=(r instanceof w?r.to-1:r.to))){if(n&&n.mightDrag)s=w.create(i.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=i.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=i.docView&&(s=w.create(i.state.doc,u.posBefore))}}let l=(s||i.state.selection).content(),{dom:a,text:c,slice:d}=kr(i,l);(!t.dataTransfer.files.length||!Q||tl>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(cn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",cn||t.dataTransfer.setData("text/plain",c),i.dragging=new jn(d,vl(i,t),s)};te.dragend=i=>{let e=i.dragging;window.setTimeout(()=>{i.dragging==e&&(i.dragging=null)},50)};ne.dragover=ne.dragenter=(i,e)=>e.preventDefault();ne.drop=(i,e)=>{let t=e,n=i.dragging;if(i.dragging=null,!t.dataTransfer)return;let r=i.posAtCoords(Yn(t));if(!r)return;let o=i.state.doc.resolve(r.pos),s=n&&n.slice;s?i.someProp("transformPasted",f=>{s=f(s,i,!1)}):s=ml(i,Ml(t.dataTransfer),cn?null:t.dataTransfer.getData("text/html"),!1,o);let l=!!(n&&vl(i,t));if(i.someProp("handleDrop",f=>f(i,t,s||x.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?as(i.state.doc,o.pos,s):o.pos;a==null&&(a=o.pos);let c=i.state.tr;if(l){let{node:f}=n;f?f.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,p=c.doc;if(u?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(p))return;let h=c.doc.resolve(d);if(u&&w.isSelectable(s.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new w(h));else{let f=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,D)=>f=D),c.setSelection(br(i,h,c.doc.resolve(f)))}i.focus(),i.dispatch(c.setMeta("uiEvent","drop"))};te.focus=i=>{i.input.lastFocus=Date.now(),i.focused||(i.domObserver.stop(),i.dom.classList.add("ProseMirror-focused"),i.domObserver.start(),i.focused=!0,setTimeout(()=>{i.docView&&i.hasFocus()&&!i.domObserver.currentSelection.eq(i.domSelectionRange())&&Te(i)},20))};te.blur=(i,e)=>{let t=e;i.focused&&(i.domObserver.stop(),i.dom.classList.remove("ProseMirror-focused"),i.domObserver.start(),t.relatedTarget&&i.dom.contains(t.relatedTarget)&&i.domObserver.currentSelection.clear(),i.focused=!1)};te.beforeinput=(i,e)=>{if(Q&&Oe&&e.inputType=="deleteContentBackward"){i.domObserver.flushSoon();let{domChangeCount:n}=i.input;setTimeout(()=>{if(i.input.domChangeCount!=n||(i.dom.blur(),i.focus(),i.someProp("handleKeyDown",o=>o(i,lt(8,"Backspace")))))return;let{$cursor:r}=i.state.selection;r&&r.pos>0&&i.dispatch(i.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let i in ne)te[i]=ne[i];function un(i,e){if(i==e)return!0;for(let t in i)if(i[t]!==e[t])return!1;for(let t in e)if(!(t in i))return!1;return!0}var Un=class i{constructor(e,t){this.toDOM=e,this.spec=t||ut,this.side=this.spec.side||0}map(e,t,n,r){let{pos:o,deleted:s}=e.mapResult(t.from+r,this.side<0?-1:1);return s?null:new be(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof i&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&un(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},dt=class i{constructor(e,t){this.attrs=e,this.spec=t||ut}map(e,t,n,r){let o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,s=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=s?null:new be(o,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof i&&un(this.attrs,e.attrs)&&un(this.spec,e.spec)}static is(e){return e.type instanceof i}destroy(){}},hr=class i{constructor(e,t){this.attrs=e,this.spec=t||ut}map(e,t,n,r){let o=e.mapResult(t.from+r,1);if(o.deleted)return null;let s=e.mapResult(t.to+r,-1);return s.deleted||s.pos<=o.pos?null:new be(o.pos-n,s.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),o;return r==t.from&&!(o=e.child(n)).isText&&r+o.nodeSize==t.to}eq(e){return this==e||e instanceof i&&un(this.attrs,e.attrs)&&un(this.spec,e.spec)}destroy(){}},be=class i{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new i(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 i(e,e,new Un(t,n))}static inline(e,t,n,r){return new i(e,t,new dt(n,r))}static node(e,t,n,r){return new i(e,t,new hr(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof dt}get widget(){return this.type instanceof Un}},Pt=[],ut={},Z=class i{constructor(e,t){this.local=e.length?e:Pt,this.children=t.length?t:Pt}static create(e,t){return t.length?Xn(t,e,0,ut):X}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,o){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&n.push(l.copy(l.from+r,l.to+r))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,n,r+l,o)}}map(e,t,n){return this==X||e.maps.length==0?this:this.mapInner(e,t,0,0,n||ut)}mapInner(e,t,n,r,o){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,n,r);a&&a.type.valid(t,a)?(s||(s=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?Ed(this.children,s||[],e,t,n,r,o):s?new i(s.sort(pt),Pt):X}add(e,t){return t.length?this==X?i.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,o=0;e.forEach((l,a)=>{let c=a+n,d;if(d=El(t,l,c)){for(r||(r=this.children.slice());o<r.length&&r[o]<a;)o+=3;r[o]==a?r[o+2]=r[o+2].addInner(l,d,c+1):r.splice(o,0,a,a+l.nodeSize,Xn(d,l,c+1,ut)),o+=3}});let s=Nl(o?Ol(t):t,-n);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new i(s.length?this.local.concat(s).sort(pt):this.local,r||this.children)}remove(e){return e.length==0||this==X?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let o=0;o<n.length;o+=3){let s,l=n[o]+t,a=n[o+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(s||(s=[])).push(u));if(!s)continue;n==this.children&&(n=this.children.slice());let c=n[o+2].removeInner(s,l+1);c!=X?n[o+2]=c:(n.splice(o,3),o-=3)}if(r.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let l=0;l<r.length;l++)r[l].eq(s,t)&&(r==this.local&&(r=this.local.slice()),r.splice(l--,1))}return n==this.children&&r==this.local?this:r.length||n.length?new i(r,n):X}forChild(e,t){if(this==X)return this;if(t.isLeaf)return i.empty;let n,r;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(n=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>o&&a.type instanceof dt){let c=Math.max(o,a.from)-o,d=Math.min(s,a.to)-o;c<d&&(r||(r=[])).push(a.copy(c,d))}}if(r){let l=new i(r.sort(pt),Pt);return n?new Gn([l,n]):l}return n||X}eq(e){if(this==e)return!0;if(!(e instanceof i)||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 Sr(this.localsInner(e))}localsInner(e){if(this==X)return Pt;if(e.inlineContent||!this.local.some(dt.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof dt||t.push(this.local[n]);return t}forEachSet(e){e(this)}};Z.empty=new Z([],[]);Z.removeOverlap=Sr;var X=Z.empty,Gn=class i{constructor(e){this.members=e}map(e,t){let n=this.members.map(r=>r.map(e,t,ut));return i.from(n)}forChild(e,t){if(t.isLeaf)return Z.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(e,t);o!=X&&(o instanceof i?n=n.concat(o.members):n.push(o))}return i.from(n)}eq(e){if(!(e instanceof i)||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 r=0;r<this.members.length;r++){let o=this.members[r].localsInner(e);if(o.length)if(!t)t=o;else{n&&(t=t.slice(),n=!1);for(let s=0;s<o.length;s++)t.push(o[s])}}return t?Sr(n?t:t.sort(pt)):Pt}static from(e){switch(e.length){case 0:return X;case 1:return e[0];default:return new i(e.every(t=>t instanceof Z)?e:e.reduce((t,n)=>t.concat(n instanceof Z?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Ed(i,e,t,n,r,o,s){let l=i.slice();for(let c=0,d=o;c<t.maps.length;c++){let u=0;t.maps[c].forEach((p,h,f,m)=>{let g=m-f-(h-p);for(let b=0;b<l.length;b+=3){let D=l[b+1];if(D<0||p>D+d-u)continue;let A=l[b]+d-u;h>=A?l[b+1]=p<=A?-2:-1:p>=d&&g&&(l[b]+=g,l[b+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(i[c]+o),u=d-r;if(u<0||u>=n.content.size){a=!0;continue}let p=t.map(i[c+1]+o,-1),h=p-r,{index:f,offset:m}=n.content.findIndex(u),g=n.maybeChild(f);if(g&&m==u&&m+g.nodeSize==h){let b=l[c+2].mapInner(t,g,d+1,i[c]+o+1,s);b!=X?(l[c]=u,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Od(l,i,e,t,r,o,s),d=Xn(c,n,0,s);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,p=0;u<d.children.length;u+=3){let h=d.children[u];for(;p<l.length&&l[p]<h;)p+=3;l.splice(p,0,d.children[u],d.children[u+1],d.children[u+2])}}return new Z(e.sort(pt),l)}function Nl(i,e){if(!e||!i.length)return i;let t=[];for(let n=0;n<i.length;n++){let r=i[n];t.push(new be(r.from+e,r.to+e,r.type))}return t}function Od(i,e,t,n,r,o,s){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(n,r,c);u?t.push(u):s.onRemove&&s.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<i.length;a+=3)i[a+1]==-1&&l(i[a+2],e[a]+o+1);return t}function El(i,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,r=null;for(let o=0,s;o<i.length;o++)(s=i[o])&&s.from>t&&s.to<n&&((r||(r=[])).push(s),i[o]=null);return r}function Ol(i){let e=[];for(let t=0;t<i.length;t++)i[t]!=null&&e.push(i[t]);return e}function Xn(i,e,t,n){let r=[],o=!1;e.forEach((l,a)=>{let c=El(i,l,a+t);if(c){o=!0;let d=Xn(c,l,t+a+1,n);d!=X&&r.push(a,a+l.nodeSize,d)}});let s=Nl(o?Ol(i):i,-t).sort(pt);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(n.onRemove&&n.onRemove(s[l].spec),s.splice(l--,1));return s.length||r.length?new Z(s,r):X}function pt(i,e){return i.from-e.from||i.to-e.to}function Sr(i){let e=i;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let r=t+1;r<e.length;r++){let o=e[r];if(o.from==n.from){o.to!=n.to&&(e==i&&(e=i.slice()),e[r]=o.copy(o.from,n.to),Ws(e,r+1,o.copy(n.to,o.to)));continue}else{o.from<n.to&&(e==i&&(e=i.slice()),e[t]=n.copy(n.from,o.from),Ws(e,r,n.copy(o.from,n.to)));break}}}return e}function Ws(i,e,t){for(;e<i.length&&pt(t,i[e])>0;)e++;i.splice(e,0,t)}function Qi(i){let e=[];return i.someProp("decorations",t=>{let n=t(i.state);n&&n!=X&&e.push(n)}),i.cursorWrapper&&e.push(Z.create(i.state.doc,[i.cursorWrapper.deco])),Gn.from(e)}var Td={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Id=re&&He<=11,mr=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},gr=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new mr,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let r=0;r<n.length;r++)this.queue.push(n[r]);re&&He<=11&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),Id&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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,Td)),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(Rs(this.view)){if(this.suppressingSelectionUpdates)return Te(this.view);if(re&&He<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ft(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let o=e.focusNode;o;o=zt(o))t.add(o);for(let o=e.anchorNode;o;o=zt(o))if(t.has(o)){n=o;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Rs(e)&&!this.ignoreSelectionChange(n),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(o=o<0?u.from:Math.min(u.from,o),s=s<0?u.to:Math.max(u.to,s),u.typeOver&&(l=!0))}if(ue&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,p]=d;u.parentNode&&u.parentNode.parentNode==p.parentNode?p.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let p of d){let h=p.parentNode;h&&h.nodeName=="LI"&&(!u||Pd(e,u)!=h)&&p.remove()}}}let c=null;o<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Qn(n)&&(c=xr(e))&&c.eq(S.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Te(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||r)&&(o>-1&&(e.docView.markDirty(o,s),Dd(e)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Te(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,o=e.nextSibling;if(re&&He<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:p}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(r=u),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(o=p)}let s=r&&r.parentNode==e.target?W(r)+1:0,l=n.localPosFromDOM(e.target,s,-1),a=o&&o.parentNode==e.target?W(o):e.target.childNodes.length,c=n.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},qs=new WeakMap,Ks=!1;function Dd(i){if(!qs.has(i)&&(qs.set(i,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(i.dom).whiteSpace)!==-1)){if(i.requiresGeckoHackNode=ue,Ks)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."),Ks=!0}}function Js(i,e){let t=e.startContainer,n=e.startOffset,r=e.endContainer,o=e.endOffset,s=i.domAtPos(i.state.selection.anchor);return ft(s.node,s.offset,r,o)&&([t,n,r,o]=[r,o,t,n]),{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:o}}function Ad(i,e){if(e.getComposedRanges){let r=e.getComposedRanges(i.root)[0];if(r)return Js(i,r)}let t;function n(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return i.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),i.dom.removeEventListener("beforeinput",n,!0),t?Js(i,t):null}function Pd(i,e){for(let t=e.parentNode;t&&t!=i.dom;t=t.parentNode){let n=i.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function Rd(i,e,t){let{node:n,fromOffset:r,toOffset:o,from:s,to:l}=i.docView.parseRange(e,t),a=i.domSelectionRange(),c,d=a.anchorNode;if(d&&i.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],Qn(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Q&&i.input.lastKeyCode===8)for(let g=o;g>r;g--){let b=n.childNodes[g-1],D=b.pmViewDesc;if(b.nodeName=="BR"&&!D){o=g;break}if(!D||D.size)break}let u=i.state.doc,p=i.someProp("domParser")||ze.fromSchema(i.state.schema),h=u.resolve(s),f=null,m=p.parse(n,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:r,to:o,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:zd,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),f={anchor:g+s,head:b+s}}return{doc:m,sel:f,from:s,to:l}}function zd(i){let e=i.pmViewDesc;if(e)return e.parseRule();if(i.nodeName=="BR"&&i.parentNode){if(ee&&/^(ul|ol)$/i.test(i.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(i.parentNode.lastChild==i||ee&&/^(tr|table)$/i.test(i.parentNode.nodeName))return{ignore:!0}}else if(i.nodeName=="IMG"&&i.getAttribute("mark-placeholder"))return{ignore:!0};return null}var Bd=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Ld(i,e,t,n,r){let o=i.input.compositionPendingChanges||(i.composing?i.input.compositionID:0);if(i.input.compositionPendingChanges=0,e<0){let v=i.input.lastSelectionTime>Date.now()-50?i.input.lastSelectionOrigin:null,B=xr(i,v);if(B&&!i.state.selection.eq(B)){if(Q&&Oe&&i.input.lastKeyCode===13&&Date.now()-100<i.input.lastKeyCodeTime&&i.someProp("handleKeyDown",Sa=>Sa(i,lt(13,"Enter"))))return;let ie=i.state.tr.setSelection(B);v=="pointer"?ie.setMeta("pointer",!0):v=="key"&&ie.scrollIntoView(),o&&ie.setMeta("composition",o),i.dispatch(ie)}return}let s=i.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=i.state.doc.resolve(t).after(l+1);let a=i.state.selection,c=Rd(i,e,t),d=i.state.doc,u=d.slice(c.from,c.to),p,h;i.input.lastKeyCode===8&&Date.now()-100<i.input.lastKeyCodeTime?(p=i.state.selection.to,h="end"):(p=i.state.selection.from,h="start"),i.input.lastKeyCode=null;let f=Hd(u.content,c.doc.content,c.from,p,h);if(f&&i.input.domChangeCount++,(Bt&&i.input.lastIOSEnter>Date.now()-225||Oe)&&r.some(v=>v.nodeType==1&&!Bd.test(v.nodeName))&&(!f||f.endA>=f.endB)&&i.someProp("handleKeyDown",v=>v(i,lt(13,"Enter")))){i.input.lastIOSEnter=0;return}if(!f)if(n&&a instanceof T&&!a.empty&&a.$head.sameParent(a.$anchor)&&!i.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))f={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let v=js(i,i.state.doc,c.sel);if(v&&!v.eq(i.state.selection)){let B=i.state.tr.setSelection(v);o&&B.setMeta("composition",o),i.dispatch(B)}}return}i.state.selection.from<i.state.selection.to&&f.start==f.endB&&i.state.selection instanceof T&&(f.start>i.state.selection.from&&f.start<=i.state.selection.from+2&&i.state.selection.from>=c.from?f.start=i.state.selection.from:f.endA<i.state.selection.to&&f.endA>=i.state.selection.to-2&&i.state.selection.to<=c.to&&(f.endB+=i.state.selection.to-f.endA,f.endA=i.state.selection.to)),re&&He<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>c.from&&c.doc.textBetween(f.start-c.from-1,f.start-c.from+1)==" \xA0"&&(f.start--,f.endA--,f.endB--);let m=c.doc.resolveNoCache(f.start-c.from),g=c.doc.resolveNoCache(f.endB-c.from),b=d.resolve(f.start),D=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=f.endA;if((Bt&&i.input.lastIOSEnter>Date.now()-225&&(!D||r.some(v=>v.nodeName=="DIV"||v.nodeName=="P"))||!D&&m.pos<c.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(c.doc.textBetween(m.pos,g.pos,"","")))&&i.someProp("handleKeyDown",v=>v(i,lt(13,"Enter")))){i.input.lastIOSEnter=0;return}if(i.state.selection.anchor>f.start&&Vd(d,f.start,f.endA,m,g)&&i.someProp("handleKeyDown",v=>v(i,lt(8,"Backspace")))){Oe&&Q&&i.domObserver.suppressSelectionUpdates();return}Q&&f.endB==f.start&&(i.input.lastChromeDelete=Date.now()),Oe&&!D&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==f.endA&&(f.endB-=2,g=c.doc.resolveNoCache(f.endB-c.from),setTimeout(()=>{i.someProp("handleKeyDown",function(v){return v(i,lt(13,"Enter"))})},20));let A=f.start,he=f.endA,Je=v=>{let B=v||i.state.tr.replace(A,he,c.doc.slice(f.start-c.from,f.endB-c.from));if(c.sel){let ie=js(i,B.doc,c.sel);ie&&!(Q&&i.composing&&ie.empty&&(f.start!=f.endB||i.input.lastChromeDelete<Date.now()-100)&&(ie.head==A||ie.head==B.mapping.map(he)-1)||re&&ie.empty&&ie.head==A)&&B.setSelection(ie)}return o&&B.setMeta("composition",o),B.scrollIntoView()},bn;if(D)if(m.pos==g.pos){re&&He<=11&&m.parentOffset==0&&(i.domObserver.suppressSelectionUpdates(),setTimeout(()=>Te(i),20));let v=Je(i.state.tr.delete(A,he)),B=d.resolve(f.start).marksAcross(d.resolve(f.endA));B&&v.ensureMarks(B),i.dispatch(v)}else if(f.endA==f.endB&&(bn=Fd(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start())))){let v=Je(i.state.tr);bn.type=="add"?v.addMark(A,he,bn.mark):v.removeMark(A,he,bn.mark),i.dispatch(v)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let v=m.parent.textBetween(m.parentOffset,g.parentOffset),B=()=>Je(i.state.tr.insertText(v,A,he));i.someProp("handleTextInput",ie=>ie(i,A,he,v,B))||i.dispatch(B())}else i.dispatch(Je());else i.dispatch(Je())}function js(i,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:br(i,e.resolve(t.anchor),e.resolve(t.head))}function Fd(i,e){let t=i.firstChild.marks,n=e.firstChild.marks,r=t,o=n,s,l,a;for(let d=0;d<n.length;d++)r=n[d].removeFromSet(r);for(let d=0;d<t.length;d++)o=t[d].removeFromSet(o);if(r.length==1&&o.length==0)l=r[0],s="add",a=d=>d.mark(l.addToSet(d.marks));else if(r.length==0&&o.length==1)l=o[0],s="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(y.from(c).eq(i))return{mark:l,type:s}}function Vd(i,e,t,n,r){if(t-e<=r.pos-n.pos||Yi(n,!0,!1)<r.pos)return!1;let o=i.resolve(e);if(!n.parent.isTextblock){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=i.resolve(Yi(o,!0,!0));return!s.parent.isTextblock||s.pos>t||Yi(s,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(s.parent.content)}function Yi(i,e,t){let n=i.depth,r=e?i.end():i.pos;for(;n>0&&(e||i.indexAfter(n)==i.node(n).childCount);)n--,r++,e=!1;if(t){let o=i.node(n).maybeChild(i.indexAfter(n));for(;o&&!o.isLeaf;)o=o.firstChild,r++}return r}function Hd(i,e,t,n,r){let o=i.findDiffStart(e,t);if(o==null)return null;let{a:s,b:l}=i.findDiffEnd(e,t+i.size,t+e.size);if(r=="end"){let a=Math.max(0,o-Math.min(s,l));n-=s+a-o}if(s<o&&i.size<e.size){let a=n<=o&&n>=s?o-n:0;o-=a,o&&o<e.size&&Us(e.textBetween(o-1,o+1))&&(o+=a?1:-1),l=o+(l-s),s=o}else if(l<o){let a=n<=o&&n>=l?o-n:0;o-=a,o&&o<i.size&&Us(i.textBetween(o-1,o+1))&&(o+=a?1:-1),s=o+(s-l),l=o}return{start:o,endA:s,endB:l}}function Us(i){if(i.length!=2)return!1;let e=i.charCodeAt(0),t=i.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}var pn=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new ur,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Zs),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Qs(this),Xs(this),this.nodeViews=Ys(this),this.docView=Os(this.state.doc,Gs(this),Qi(this),this.dom,this),this.domObserver=new gr(this,(n,r,o,s)=>Ld(this,n,r,o,s)),this.domObserver.start(),dd(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&&pr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Zs),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];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){var n;let r=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(Sl(this),s=!0),this.state=e;let l=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Ys(this);Wd(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&pr(this),this.editable=Qs(this),Xs(this);let a=Qi(this),c=Gs(this),d=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",u=o||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(r.selection))&&(s=!0);let p=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Ec(this);if(s){this.domObserver.stop();let h=u&&(re||Q)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&$d(r.selection,e.selection);if(u){let f=Q?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=wd(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Os(e.doc,c,a,this.dom,this)),f&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Gc(this))?Te(this,h):(pl(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),!((n=this.dragging)===null||n===void 0)&&n.node&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():p&&Oc(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof w){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&_s(this,t.getBoundingClientRect(),e)}else _s(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let o=n.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==n.node&&(r=o)}this.dragging=new jn(e.slice,e.move,r<0?void 0:w.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(r=t?t(l):l))return r}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let l=o[s].props[e];if(l!=null&&(r=t?t(l):l))return r}}hasFocus(){if(re){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Tc(this.dom),Te(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Rc(this,e)}coordsAtPos(e,t=1){return sl(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return Vc(this,t||this.state,e)}pasteHTML(e,t){return dn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return dn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return kr(this,e)}destroy(){this.docView&&(ud(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Qi(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,yc())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return fd(this,e)}domSelectionRange(){let e=this.domSelection();return e?ee&&this.root.nodeType===11&&wc(this.dom.ownerDocument)==this.dom&&Ad(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};pn.prototype.dispatch=function(i){let e=this._props.dispatchTransaction;e?e.call(this,i):this.updateState(this.state.apply(i))};function Gs(i){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(i.editable),i.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(i.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[be.node(0,i.state.doc.content.size,e)]}function Xs(i){if(i.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),i.cursorWrapper={dom:e,deco:be.widget(i.state.selection.from,e,{raw:!0,marks:i.markCursor})}}else i.cursorWrapper=null}function Qs(i){return!i.someProp("editable",e=>e(i.state)===!1)}function $d(i,e){let t=Math.min(i.$anchor.sharedDepth(i.head),e.$anchor.sharedDepth(e.head));return i.$anchor.start(t)!=e.$anchor.start(t)}function Ys(i){let e=Object.create(null);function t(n){for(let r in n)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=n[r])}return i.someProp("nodeViews",t),i.someProp("markViews",t),e}function Wd(i,e){let t=0,n=0;for(let r in i){if(i[r]!=e[r])return!0;t++}for(let r in e)n++;return t!=n}function Zs(i){if(i.spec.state||i.spec.filterTransaction||i.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var qd=["ol",0],Kd=["ul",0],Jd=["li",0],Tl={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs(i){return{order:i.hasAttribute("start")?+i.getAttribute("start"):1}}}],toDOM(i){return i.attrs.order==1?qd:["ol",{start:i.attrs.order},0]}},Il={parseDOM:[{tag:"ul"}],toDOM(){return Kd}},Dl={parseDOM:[{tag:"li"}],toDOM(){return Jd},defining:!0};function Al(i,e=null){return function(t,n){let{$from:r,$to:o}=t.selection,s=r.blockRange(o);if(!s)return!1;let l=n?t.tr:null;return jd(l,s,i,e)?(n&&n(l.scrollIntoView()),!0):!1}}function jd(i,e,t,n=null){let r=!1,o=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);o=new tt(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new tt(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let l=Ot(o,t,n,e);return l?(i&&Ud(i,e,l,r,t),!0):!1}function Ud(i,e,t,n,r){let o=y.empty;for(let d=t.length-1;d>=0;d--)o=y.from(t[d].type.create(t[d].attrs,o));i.step(new V(e.start-(n?2:0),e.end,e.start,e.end,new x(o,0,0),t.length,!0));let s=0;for(let d=0;d<t.length;d++)t[d].type==r&&(s=d+1);let l=t.length-s,a=e.start+t.length-(n?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,p=!0;d<u;d++,p=!1)!p&&Be(i.doc,a,l)&&(i.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return i}function Pl(i,e){return function(t,n){let{$from:r,$to:o,node:s}=t.selection;if(s&&s.isBlock||r.depth<2||!r.sameParent(o))return!1;let l=r.node(-1);if(l.type!=i)return!1;if(r.parent.content.size==0&&r.node(-1).childCount==r.indexAfter(-1)){if(r.depth==3||r.node(-3).type!=i||r.index(-2)!=r.node(-2).childCount-1)return!1;if(n){let u=y.empty,p=r.index(-1)?1:r.index(-2)?2:3;for(let b=r.depth-p;b>=r.depth-3;b--)u=y.from(r.node(b).copy(u));let h=r.indexAfter(-1)<r.node(-2).childCount?1:r.indexAfter(-2)<r.node(-3).childCount?2:3;u=u.append(y.from(i.createAndFill()));let f=r.before(r.depth-(p-1)),m=t.tr.replace(f,r.after(-h),new x(u,4-p,0)),g=-1;m.doc.nodesBetween(f,m.doc.content.size,(b,D)=>{if(g>-1)return!1;b.isTextblock&&b.content.size==0&&(g=D+1)}),g>-1&&m.setSelection(S.near(m.doc.resolve(g))),n(m.scrollIntoView())}return!0}let a=o.pos==r.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(r.pos,o.pos),d=a?[e?{type:i,attrs:e}:null,{type:a}]:void 0;return Be(c.doc,r.pos,2,d)?(n&&n(c.split(r.pos,2,d).scrollIntoView()),!0):!1}}function Mr(i){return function(e,t){let{$from:n,$to:r}=e.selection,o=n.blockRange(r,s=>s.childCount>0&&s.firstChild.type==i);return o?t?n.node(o.depth-1).type==i?Gd(e,t,i,o):Xd(e,t,o):!0:!1}}function Gd(i,e,t,n){let r=i.tr,o=n.end,s=n.$to.end(n.depth);o<s&&(r.step(new V(o-1,s,o,s,new x(y.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new tt(r.doc.resolve(n.$from.pos),r.doc.resolve(s),n.depth));let l=rt(n);if(l==null)return!1;r.lift(n,l);let a=r.doc.resolve(r.mapping.map(o,-1)-1);return ot(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function Xd(i,e,t){let n=i.tr,r=t.parent;for(let h=t.end,f=t.endIndex-1,m=t.startIndex;f>m;f--)h-=r.child(f).nodeSize,n.delete(h-1,h+1);let o=n.doc.resolve(t.start),s=o.nodeAfter;if(n.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==r.childCount,c=o.node(-1),d=o.index(-1);if(!c.canReplace(d+(l?0:1),d+1,s.content.append(a?y.empty:y.from(r))))return!1;let u=o.pos,p=u+s.nodeSize;return n.step(new V(u-(l?1:0),p+(a?1:0),u+1,p-1,new x((l?y.empty:y.from(r.copy(y.empty))).append(a?y.empty:y.from(r.copy(y.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function vr(i){return function(e,t){let{$from:n,$to:r}=e.selection,o=n.blockRange(r,c=>c.childCount>0&&c.firstChild.type==i);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let l=o.parent,a=l.child(s-1);if(a.type!=i)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=y.from(c?i.create():null),u=new x(y.from(i.create(null,y.from(l.type.create(null,d)))),c?3:1,0),p=o.start,h=o.end;t(e.tr.step(new V(p-(c?3:1),h,p,h,u,1,!0)).scrollIntoView())}return!0}}var Yd={attrs:{href:{},title:{default:null},target:{default:"_blank"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(i){return{href:i.getAttribute("href"),title:i.getAttribute("title"),target:i.getAttribute("target")}}}],toDOM(i){let{href:e,title:t,target:n}=i.attrs;return["a",{href:e,title:t,target:n},0]}},Zd={parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM(){return["em",0]}},eu={parseDOM:[{tag:"strong"},{tag:"b",getAttrs:i=>i.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:i=>/^(?:bold(?:er)?|[5-9]\d{2,})$/.test(i)&&null}],toDOM(){return["strong",0]}},tu={parseDOM:[{tag:"code"}],toDOM(){return["code",0]}},nu={parseDOM:[{tag:"u"},{style:"text-decoration=underline",consuming:!1}],toDOM(){return["u",0]}},iu={parseDOM:[{tag:"s"},{tag:"strike"},{style:"text-decoration=line-through"}],toDOM(){return["s",0]}},ru={attrs:{color:{default:null}},parseDOM:[{style:"color",getAttrs:i=>({color:i})}],toDOM(i){let{color:e}=i.attrs;return["span",{style:`color:${e};`},0]}},ou={attrs:{backgroundColor:{default:null}},parseDOM:[{style:"background-color",getAttrs:i=>({backgroundColor:i})}],toDOM(i){let{backgroundColor:e}=i.attrs;return["span",{style:`background-color:${e};`},0]}},su={attrs:{},parseDOM:[{tag:"sup"},{style:"vertical-align=super"}],toDOM(){return["sup",0]}},lu={attrs:{},parseDOM:[{tag:"sub"},{style:"vertical-align=sub"}],toDOM(){return["sub",0]}},au={link:Yd,em:Zd,strong:eu,code:tu,u:nu,s:iu,text_color:ru,text_background_color:ou,sup:su,sub:lu},cu={content:"block+"},du={group:"inline"},uu={content:"inline*",group:"block",attrs:{align:{default:null},indent:{default:null}},parseDOM:[{tag:"p",getAttrs(i){let{textAlign:e}=i.style,t=i.getAttribute("align")||e||null,n=i.getAttribute("data-indent")||null;return{align:t,indent:parseInt(n,10)||null}}}],toDOM(i){let{align:e,indent:t}=i.attrs,n={textAlign:e!=="left"?e:null,marginLeft:t!==null?`${t*40}px`:null};return["p",{style:Sn(n)||null,"data-indent":t??null},0]}},pu={content:"block+",group:"block",defining:!0,attrs:{indent:{default:null}},parseDOM:[{tag:"blockquote",getAttrs(i){let e=i.getAttribute("data-indent")||null;return{indent:parseInt(e,10)||null}}}],toDOM(i){let{indent:e}=i.attrs,t={marginLeft:e!==null?`${e*40}px`:null};return["blockquote",{style:Sn(t)||null,"data-indent":e??null},0]}},fu={group:"block",parseDOM:[{tag:"hr"}],toDOM(){return["hr"]}},hu={attrs:{level:{default:1},align:{default:null},indent:{default:null}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",getAttrs(i){let{textAlign:e}=i.style,t=i.getAttribute("align")||e||null,n=i.getAttribute("data-indent")||null;return{level:1,align:t,indent:parseInt(n,10)||null}}},{tag:"h2",getAttrs(i){let{textAlign:e}=i.style,t=i.getAttribute("align")||e||null,n=i.getAttribute("data-indent")||null;return{level:2,align:t,indent:parseInt(n,10)||null}}},{tag:"h3",getAttrs(i){let{textAlign:e}=i.style,t=i.getAttribute("align")||e||null,n=i.getAttribute("data-indent")||null;return{level:3,align:t,indent:parseInt(n,10)||null}}},{tag:"h4",getAttrs(i){let{textAlign:e}=i.style,t=i.getAttribute("align")||e||null,n=i.getAttribute("data-indent")||null;return{level:4,align:t,indent:parseInt(n,10)||null}}},{tag:"h5",getAttrs(i){let{textAlign:e}=i.style,t=i.getAttribute("align")||e||null,n=i.getAttribute("data-indent")||null;return{level:5,align:t,indent:parseInt(n,10)||null}}},{tag:"h6",getAttrs(i){let{textAlign:e}=i.style,t=i.getAttribute("align")||e||null,n=i.getAttribute("data-indent")||null;return{level:6,align:t,indent:parseInt(n,10)||null}}}],toDOM(i){let{level:e,align:t,indent:n}=i.attrs,r={textAlign:t!=="left"?t:null,marginLeft:n!==null?`${n*40}px`:null},s={style:Sn(r)||null,"data-indent":n??null};return[`h${e}`,s,0]}},mu={content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return["pre",["code",0]]}},gu={inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return["br"]}},yu={inline:!0,attrs:{src:{},alt:{default:null},title:{default:null},width:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(i){return{src:i.getAttribute("src"),title:i.getAttribute("title"),alt:i.getAttribute("alt"),width:i.getAttribute("width")}}}],toDOM(i){let{src:e,alt:t,title:n,width:r}=i.attrs;return["img",{src:e,alt:t,title:n,width:r}]}},xu=_e(L({},Dl),{content:"paragraph block*"}),bu=_e(L({},Tl),{content:"list_item+",group:"block"}),ku=_e(L({},Il),{content:"list_item+",group:"block"}),Cu={doc:cu,text:du,paragraph:uu,blockquote:pu,horizontal_rule:fu,heading:hu,hard_break:gu,code_block:mu,image:yu,list_item:xu,ordered_list:bu,bullet_list:ku},qe=new In({marks:au,nodes:Cu});var zl=(i,e)=>i.selection.empty?!1:(e&&e(i.tr.deleteSelection().scrollIntoView()),!0);function wu(i,e){let{$cursor:t}=i.selection;return!t||(e?!e.endOfTextblock("backward",i):t.parentOffset>0)?null:t}var _u=(i,e,t)=>{let n=wu(i,t);if(!n)return!1;let r=Bl(n);if(!r){let s=n.blockRange(),l=s&&rt(s);return l==null?!1:(e&&e(i.tr.lift(s,l).scrollIntoView()),!0)}let o=r.nodeBefore;if(Vl(i,r,e,-1))return!0;if(n.parent.content.size==0&&(Ft(o,"end")||w.isSelectable(o)))for(let s=n.depth;;s--){let l=Bn(i.doc,n.before(s),n.after(s),x.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=i.tr.step(l);a.setSelection(Ft(o,"end")?S.findFrom(a.doc.resolve(a.mapping.map(r.pos,-1)),-1):w.create(a.doc,r.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||n.node(s-1).childCount>1)break}return o.isAtom&&r.depth==n.depth-1?(e&&e(i.tr.delete(r.pos-o.nodeSize,r.pos).scrollIntoView()),!0):!1};function Ft(i,e,t=!1){for(let n=i;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}var Su=(i,e,t)=>{let{$head:n,empty:r}=i.selection,o=n;if(!r)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",i):n.parentOffset>0)return!1;o=Bl(n)}let s=o&&o.nodeBefore;return!s||!w.isSelectable(s)?!1:(e&&e(i.tr.setSelection(w.create(i.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Bl(i){if(!i.parent.type.spec.isolating)for(let e=i.depth-1;e>=0;e--){if(i.index(e)>0)return i.doc.resolve(i.before(e+1));if(i.node(e).type.spec.isolating)break}return null}function Mu(i,e){let{$cursor:t}=i.selection;return!t||(e?!e.endOfTextblock("forward",i):t.parentOffset<t.parent.content.size)?null:t}var vu=(i,e,t)=>{let n=Mu(i,t);if(!n)return!1;let r=Ll(n);if(!r)return!1;let o=r.nodeAfter;if(Vl(i,r,e,1))return!0;if(n.parent.content.size==0&&(Ft(o,"start")||w.isSelectable(o))){let s=Bn(i.doc,n.before(),n.after(),x.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=i.tr.step(s);l.setSelection(Ft(o,"start")?S.findFrom(l.doc.resolve(l.mapping.map(r.pos)),1):w.create(l.doc,l.mapping.map(r.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&r.depth==n.depth-1?(e&&e(i.tr.delete(r.pos,r.pos+o.nodeSize).scrollIntoView()),!0):!1},Nu=(i,e,t)=>{let{$head:n,empty:r}=i.selection,o=n;if(!r)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",i):n.parentOffset<n.parent.content.size)return!1;o=Ll(n)}let s=o&&o.nodeAfter;return!s||!w.isSelectable(s)?!1:(e&&e(i.tr.setSelection(w.create(i.doc,o.pos)).scrollIntoView()),!0)};function Ll(i){if(!i.parent.type.spec.isolating)for(let e=i.depth-1;e>=0;e--){let t=i.node(e);if(i.index(e)+1<t.childCount)return i.doc.resolve(i.after(e+1));if(t.type.spec.isolating)break}return null}var Fl=(i,e)=>{let{$from:t,$to:n}=i.selection,r=t.blockRange(n),o=r&&rt(r);return o==null?!1:(e&&e(i.tr.lift(r,o).scrollIntoView()),!0)},Er=(i,e)=>{let{$head:t,$anchor:n}=i.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(i.tr.insertText(`
`).scrollIntoView()),!0)};function Or(i){for(let e=0;e<i.edgeCount;e++){let{type:t}=i.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var Tr=(i,e)=>{let{$head:t,$anchor:n}=i.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let r=t.node(-1),o=t.indexAfter(-1),s=Or(r.contentMatchAt(o));if(!s||!r.canReplaceWith(o,o,s))return!1;if(e){let l=t.after(),a=i.tr.replaceWith(l,l,s.createAndFill());a.setSelection(S.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Ir=(i,e)=>{let t=i.selection,{$from:n,$to:r}=t;if(t instanceof le||n.parent.inlineContent||r.parent.inlineContent)return!1;let o=Or(r.parent.contentMatchAt(r.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!n.parentOffset&&r.index()<r.parent.childCount?n:r).pos,l=i.tr.insert(s,o.createAndFill());l.setSelection(T.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Dr=(i,e)=>{let{$cursor:t}=i.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(Be(i.doc,o))return e&&e(i.tr.split(o).scrollIntoView()),!0}let n=t.blockRange(),r=n&&rt(n);return r==null?!1:(e&&e(i.tr.lift(n,r).scrollIntoView()),!0)};function Eu(i){return(e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof w&&e.selection.node.isBlock)return!n.parentOffset||!Be(e.doc,n.pos)?!1:(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],s,l,a=!1,c=!1;for(let h=n.depth;;h--)if(n.node(h).isBlock){a=n.end(h)==n.pos+(n.depth-h),c=n.start(h)==n.pos-(n.depth-h),l=Or(n.node(h-1).contentMatchAt(n.indexAfter(h-1)));let m=i&&i(r.parent,a,n);o.unshift(m||(a&&l?{type:l}:null)),s=h;break}else{if(h==1)return!1;o.unshift(null)}let d=e.tr;(e.selection instanceof T||e.selection instanceof le)&&d.deleteSelection();let u=d.mapping.map(n.pos),p=Be(d.doc,u,o.length,o);if(p||(o[0]=l?{type:l}:null,p=Be(d.doc,u,o.length,o)),!p)return!1;if(d.split(u,o.length,o),!a&&c&&n.node(s).type!=l){let h=d.mapping.map(n.before(s)),f=d.doc.resolve(h);l&&n.node(s-1).canReplaceWith(f.index(),f.index()+1,l)&&d.setNodeMarkup(d.mapping.map(n.before(s)),l)}return t&&t(d.scrollIntoView()),!0}}var Ar=Eu();var Ou=(i,e)=>(e&&e(i.tr.setSelection(new le(i.doc))),!0);function Tu(i,e,t){let n=e.nodeBefore,r=e.nodeAfter,o=e.index();return!n||!r||!n.type.compatibleContent(r.type)?!1:!n.content.size&&e.parent.canReplace(o-1,o)?(t&&t(i.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(r.isTextblock||ot(i.doc,e.pos))?!1:(t&&t(i.tr.join(e.pos).scrollIntoView()),!0)}function Vl(i,e,t,n){let r=e.nodeBefore,o=e.nodeAfter,s,l,a=r.type.spec.isolating||o.type.spec.isolating;if(!a&&Tu(i,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=r.contentMatchAt(r.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(t){let h=e.pos+o.nodeSize,f=y.empty;for(let b=s.length-1;b>=0;b--)f=y.from(s[b].create(null,f));f=y.from(r.copy(f));let m=i.tr.step(new V(e.pos-1,h,e.pos,h,new x(f,1,0),s.length,!0)),g=m.doc.resolve(h+2*s.length);g.nodeAfter&&g.nodeAfter.type==r.type&&ot(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=o.type.spec.isolating||n>0&&a?null:S.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),p=u&&rt(u);if(p!=null&&p>=e.depth)return t&&t(i.tr.lift(u,p).scrollIntoView()),!0;if(c&&Ft(o,"start",!0)&&Ft(r,"end")){let h=r,f=[];for(;f.push(h),!h.isTextblock;)h=h.lastChild;let m=o,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let b=y.empty;for(let A=f.length-1;A>=0;A--)b=y.from(f[A].copy(b));let D=i.tr.step(new V(e.pos-f.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new x(b,f.length,0),0,!0));t(D.scrollIntoView())}return!0}}return!1}function Hl(i){return function(e,t){let n=e.selection,r=i<0?n.$from:n.$to,o=r.depth;for(;r.node(o).isInline;){if(!o)return!1;o--}return r.node(o).isTextblock?(t&&t(e.tr.setSelection(T.create(e.doc,i<0?r.start(o):r.end(o)))),!0):!1}}var Iu=Hl(-1),Du=Hl(1);function $l(i,e=null){return function(t,n){let{$from:r,$to:o}=t.selection,s=r.blockRange(o),l=s&&Ot(s,i,e);return l?(n&&n(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Zn(i,e=null){return function(t,n){let r=!1;for(let o=0;o<t.selection.ranges.length&&!r;o++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[o];t.doc.nodesBetween(s,l,(a,c)=>{if(r)return!1;if(!(!a.isTextblock||a.hasMarkup(i,e)))if(a.type==i)r=!0;else{let d=t.doc.resolve(c),u=d.index();r=d.parent.canReplaceWith(u,u+1,i)}})}if(!r)return!1;if(n){let o=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];o.setBlockType(l,a,i,e)}n(o.scrollIntoView())}return!0}}function Au(i,e,t,n){for(let r=0;r<e.length;r++){let{$from:o,$to:s}=e[r],l=o.depth==0?i.inlineContent&&i.type.allowsMarkType(t):!1;if(i.nodesBetween(o.pos,s.pos,(a,c)=>{if(l||!n&&a.isAtom&&a.isInline&&c>=o.pos&&c+a.nodeSize<=s.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function Pu(i){let e=[];for(let t=0;t<i.length;t++){let{$from:n,$to:r}=i[t];n.doc.nodesBetween(n.pos,r.pos,(o,s)=>{if(o.isAtom&&o.content.size&&o.isInline&&s>=n.pos&&s+o.nodeSize<=r.pos)return s+1>n.pos&&e.push(new It(n,n.doc.resolve(s+1))),n=n.doc.resolve(s+1+o.content.size),!1}),n.pos<r.pos&&e.push(new It(n,r))}return e}function mt(i,e=null,t){let n=(t&&t.removeWhenPresent)!==!1,r=(t&&t.enterInlineAtoms)!==!1,o=!(t&&t.includeWhitespace);return function(s,l){let{empty:a,$cursor:c,ranges:d}=s.selection;if(a&&!c||!Au(s.doc,d,i,r))return!1;if(l)if(c)i.isInSet(s.storedMarks||c.marks())?l(s.tr.removeStoredMark(i)):l(s.tr.addStoredMark(i.create(e)));else{let u,p=s.tr;r||(d=Pu(d)),n?u=!d.some(h=>s.doc.rangeHasMark(h.$from.pos,h.$to.pos,i)):u=!d.every(h=>{let f=!1;return p.doc.nodesBetween(h.$from.pos,h.$to.pos,(m,g,b)=>{if(f)return!1;f=!i.isInSet(m.marks)&&!!b&&b.type.allowsMarkType(i)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,h.$from.pos-g),Math.min(m.nodeSize,h.$to.pos-g))))}),!f});for(let h=0;h<d.length;h++){let{$from:f,$to:m}=d[h];if(!u)p.removeMark(f.pos,m.pos,i);else{let g=f.pos,b=m.pos,D=f.nodeAfter,A=m.nodeBefore,he=o&&D&&D.isText?/^\s*/.exec(D.text)[0].length:0,Je=o&&A&&A.isText?/\s*$/.exec(A.text)[0].length:0;g+he<b&&(g+=he,b-=Je),p.addMark(g,b,i.create(e))}}l(p.scrollIntoView())}return!0}}function Vt(...i){return function(e,t,n){for(let r=0;r<i.length;r++)if(i[r](e,t,n))return!0;return!1}}var Nr=Vt(zl,_u,Su),Rl=Vt(zl,vu,Nu),Ie={Enter:Vt(Er,Ir,Dr,Ar),"Mod-Enter":Tr,Backspace:Nr,"Mod-Backspace":Nr,"Shift-Backspace":Nr,Delete:Rl,"Mod-Delete":Rl,"Mod-a":Ou},Wl={"Ctrl-h":Ie.Backspace,"Alt-Backspace":Ie["Mod-Backspace"],"Ctrl-d":Ie.Delete,"Ctrl-Alt-Backspace":Ie["Mod-Delete"],"Alt-Delete":Ie["Mod-Delete"],"Alt-d":Ie["Mod-Delete"],"Ctrl-a":Iu,"Ctrl-e":Du};for(let i in Ie)Wl[i]=Ie[i];var Ru=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,ql=Ru?Wl:Ie;var fe=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?zu(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function zu(i){return function(e,t,n,r){let o=i;if(t[1]){let s=t[0].lastIndexOf(t[1]);o+=t[0].slice(s+t[1].length),n+=s;let l=n-r;l>0&&(o=t[0].slice(s-l,s)+o,n=r)}return e.tr.insertText(o,n,r)}}var Bu=500;function Jl({rules:i}){let e=new G({state:{init(){return null},apply(t,n){let r=t.getMeta(this);return r||(t.selectionSet||t.docChanged?null:n)}},props:{handleTextInput(t,n,r,o){return Kl(t,n,r,o,i,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:n}=t.state.selection;n&&Kl(t,n.pos,n.pos,"",i,e)})}}},isInputRules:!0});return e}function Kl(i,e,t,n,r,o){if(i.composing)return!1;let s=i.state,l=s.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-Bu),l.parentOffset,null,"\uFFFC")+n;for(let c=0;c<r.length;c++){let d=r[c];if(!d.inCodeMark&&l.marks().some(f=>f.type.spec.code))continue;if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let u=d.match.exec(a);if(!u||u[0].length<n.length)continue;let p=e-(u[0].length-n.length);if(!d.inCodeMark){let f=!1;if(s.doc.nodesBetween(p,l.pos,m=>{m.isInline&&m.marks.some(g=>g.type.spec.code)&&(f=!0)}),f)continue}let h=d.handler(s,u,p,t);if(h)return d.undoable&&h.setMeta(o,{transform:h,from:e,to:t,text:n}),i.dispatch(h),!0}return!1}var jl=new fe(/--$/,"\u2014",{inCodeMark:!1}),Ul=new fe(/\.\.\.$/,"\u2026",{inCodeMark:!1}),Lu=new fe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),Fu=new fe(/"$/,"\u201D",{inCodeMark:!1}),Vu=new fe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),Hu=new fe(/'$/,"\u2019",{inCodeMark:!1}),Gl=[Lu,Fu,Vu,Hu];function ei(i,e,t=null,n){return new fe(i,(r,o,s,l)=>{let a=t instanceof Function?t(o):t,c=r.tr.delete(s,l),d=c.doc.resolve(s),u=d.blockRange(),p=u&&Ot(u,e,a);if(!p)return null;c.wrap(u,p);let h=c.doc.resolve(s-1).nodeBefore;return h&&h.type==e&&ot(c.doc,s-1)&&(!n||n(o,h))&&c.join(s-1),c})}function Pr(i,e,t=null){return new fe(i,(n,r,o,s)=>{let l=n.doc.resolve(o),a=t instanceof Function?t(r):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?n.tr.delete(o,s).setBlockType(o,o,e,a):null})}var ti=(i,e)=>{let{from:t,$from:n,to:r,empty:o}=i.selection;return o?!!e.isInSet(i.storedMarks||n.marks()):i.doc.rangeHasMark(t,r,e)},$u=(i,e)=>{for(let t=e.depth;t>0;t-=1)if(e.node(t).type===i)return e.node(t).type;return null},Rr=(i,e,t={})=>{let{selection:n}=i,{$from:r,to:o}=n,s=$u(e,r);return!Object.entries(t).length||!s?!!s:o<=r.end()&&r.parent.hasMarkup(e,t)},Xl=i=>{let e=[],{selection:t,storedMarks:n}=i,{from:r,to:o,empty:s,$from:l}=t;return s?e=n||l.marks():i.doc.nodesBetween(r,o,a=>{e=[...e,...a.marks]}),e},zr=i=>{let e=[],{selection:{from:t,to:n}}=i;return i.doc.nodesBetween(t,n,r=>{e.push(r)}),e},Br=(i,e,t)=>{for(let n of e){let{$from:r,$to:o}=n,s=r.depth===0?i.type.allowsMarkType(t):!1;if(i.nodesBetween(r.pos,o.pos,l=>s?!1:(s=l.inlineContent&&l.type.allowsMarkType(t),!0)),s)return!0}return!1},Lr=(i,e,t)=>new fe(i,(n,r,o,s)=>{let{tr:l}=n,a=o,c=s,[d,,u]=r,p=d.search(/\S/);if(u){let h=o+d.indexOf(u),f=h+u.length;f<s&&l.delete(f,s),h>o&&l.delete(o+p,h),c=o+u.length+p}return l.addMark(a,c,e.create(t)),l.removeStoredMark(e),l}),Ql=(i,e)=>{let{$from:t}=i.selection;for(let n=t.depth;n>=0;n-=1){let r=t.index(n);if(t.node(n).canReplaceWith(r,r,e))return!0}return!1};var Yl=()=>(i,e)=>{let{doc:t,selection:n,tr:r,schema:o}=i,{$head:{pos:s},from:l,to:a}=n,c=o.marks.link;if(l===a){let d=t.resolve(s),u=s-d.textOffset,p=u+d.parent.child(d.index()).nodeSize;r.removeMark(u,p,c)}else r.removeMark(l,a,c);return r.docChanged?(e?.(r),!0):!1},Fr=(i,e={})=>(t,n)=>{let{tr:r,selection:o}=t,{empty:s,ranges:l,$from:a,$to:c}=o;if(s&&o instanceof T){let{$cursor:d}=o;if(!d||!Br(t.doc,l,i)||(r.addStoredMark(i.create(e)),!r.storedMarksSet))return!1;n?.(r)}else{if(r.addMark(a.pos,c.pos,i.create(e)),!r.docChanged)return!1;n?.(r.scrollIntoView())}return!0},Zl=i=>(e,t)=>{let{tr:n,selection:r,storedMarks:o,doc:s}=e,{empty:l,ranges:a}=r;if(l&&r instanceof T){let{$cursor:c}=r;if(!c||!Br(e.doc,a,i))return!1;if(i.isInSet(o||c.marks()))return n.removeStoredMark(i),t?.(n),!0}else{for(let c of a){let{$from:d,$to:u}=c;s.rangeHasMark(d.pos,u.pos,i)&&n.removeMark(d.pos,u.pos,i)}if(!n.docChanged)return!1;t?.(n.scrollIntoView())}return!1};var ni=200,q=function(){};q.prototype.append=function(e){return e.length?(e=q.from(e),!this.length&&e||e.length<ni&&this.leafAppend(e)||this.length<ni&&e.leafPrepend(this)||this.appendInner(e)):this};q.prototype.prepend=function(e){return e.length?q.from(e).append(this):this};q.prototype.appendInner=function(e){return new Wu(this,e)};q.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?q.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};q.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};q.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};q.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(o,s){return r.push(e(o,s))},t,n),r};q.from=function(e){return e instanceof q?e:e&&e.length?new ea(e):q.empty};var ea=(function(i){function e(n){i.call(this),this.values=n}i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,o){return r==0&&o==this.length?this:new e(this.values.slice(r,o))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,o,s,l){for(var a=o;a<s;a++)if(r(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,s,l){for(var a=o-1;a>=s;a--)if(r(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=ni)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=ni)return new e(r.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(q);q.empty=new ea([]);var Wu=(function(i){function e(t,n){i.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,r,o,s){var l=this.left.length;if(r<l&&this.left.forEachInner(n,r,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(n,Math.max(r-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,r,o,s){var l=this.left.length;if(r>l&&this.right.forEachInvertedInner(n,r-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(n,Math.min(r,l),o,s)===!1)return!1},e.prototype.sliceInner=function(n,r){if(n==0&&r==this.length)return this;var o=this.left.length;return r<=o?this.left.slice(n,r):n>=o?this.right.slice(n-o,r-o):this.left.slice(n,o).append(this.right.slice(0,r-o))},e.prototype.leafAppend=function(n){var r=this.right.leafAppend(n);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(n){var r=this.left.leafPrepend(n);if(r)return new e(r,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e})(q),Vr=q;var qu=500,yt=class i{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let r,o;t&&(r=this.remapping(n,this.items.length),o=r.maps.length);let s=e.tr,l,a,c=[],d=[];return this.items.forEach((u,p)=>{if(!u.step){r||(r=this.remapping(n,p+1),o=r.maps.length),o--,d.push(u);return}if(r){d.push(new ke(u.map));let h=u.step.map(r.slice(o)),f;h&&s.maybeStep(h).doc&&(f=s.mapping.maps[s.mapping.maps.length-1],c.push(new ke(f,void 0,void 0,c.length+d.length))),o--,f&&r.appendMap(f,o)}else s.maybeStep(u.step);if(u.selection)return l=r?u.selection.map(r.slice(o)):u.selection,a=new i(this.items.slice(0,n).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,n,r){let o=[],s=this.eventCount,l=this.items,a=!r&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),p=new ke(e.mapping.maps[d],u,t),h;(h=a&&a.merge(p))&&(p=h,d?o.pop():l=l.slice(0,l.length-1)),o.push(p),t&&(s++,t=void 0),r||(a=p)}let c=s-n.depth;return c>Ju&&(l=Ku(l,c),s-=c),new i(l.append(o),s)}remapping(e,t){let n=new tn;return this.items.forEach((r,o)=>{let s=r.mirrorOffset!=null&&o-r.mirrorOffset>=e?n.maps.length-r.mirrorOffset:void 0;n.appendMap(r.map,s)},e,t),n}addMaps(e){return this.eventCount==0?this:new i(this.items.append(e.map(t=>new ke(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},r);let a=t;this.items.forEach(p=>{let h=o.getMirror(--a);if(h==null)return;s=Math.min(s,h);let f=o.maps[h];if(p.step){let m=e.steps[h].invert(e.docs[h]),g=p.selection&&p.selection.map(o.slice(a+1,h));g&&l++,n.push(new ke(f,m,g))}else n.push(new ke(f))},r);let c=[];for(let p=t;p<s;p++)c.push(new ke(o.maps[p]));let d=this.items.slice(0,r).append(c).append(n),u=new i(d,l);return u.emptyItemCount()>qu&&(u=u.compress(this.items.length-n.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)r.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(n)),c=a&&a.getMap();if(n--,c&&t.appendMap(c,n),a){let d=s.selection&&s.selection.map(t.slice(n));d&&o++;let u=new ke(c.invert(),a,d),p,h=r.length-1;(p=r.length&&r[h].merge(u))?r[h]=p:r.push(u)}}else s.map&&n--},this.items.length,0),new i(Vr.from(r.reverse()),o)}};yt.empty=new yt(Vr.empty,0);function Ku(i,e){let t;return i.forEach((n,r)=>{if(n.selection&&e--==0)return t=r,!1}),i.slice(t)}var ke=class i{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new i(t.getMap().invert(),t,this.selection)}}},Ce=class{constructor(e,t,n,r,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=o}},Ju=20;function ju(i,e,t,n){let r=t.getMeta(gt),o;if(r)return r.historyState;t.getMeta(Xu)&&(i=new Ce(i.done,i.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return i;if(s&&s.getMeta(gt))return s.getMeta(gt).redo?new Ce(i.done.addTransform(t,void 0,n,ii(e)),i.undone,ta(t.mapping.maps),i.prevTime,i.prevComposition):new Ce(i.done,i.undone.addTransform(t,void 0,n,ii(e)),null,i.prevTime,i.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=i.prevTime==0||!s&&i.prevComposition!=l&&(i.prevTime<(t.time||0)-n.newGroupDelay||!Uu(t,i.prevRanges)),c=s?Hr(i.prevRanges,t.mapping):ta(t.mapping.maps);return new Ce(i.done.addTransform(t,a?e.selection.getBookmark():void 0,n,ii(e)),yt.empty,c,t.time,l??i.prevComposition)}else return(o=t.getMeta("rebased"))?new Ce(i.done.rebased(t,o),i.undone.rebased(t,o),Hr(i.prevRanges,t.mapping),i.prevTime,i.prevComposition):new Ce(i.done.addMaps(t.mapping.maps),i.undone.addMaps(t.mapping.maps),Hr(i.prevRanges,t.mapping),i.prevTime,i.prevComposition)}function Uu(i,e){if(!e)return!1;if(!i.docChanged)return!0;let t=!1;return i.mapping.maps[0].forEach((n,r)=>{for(let o=0;o<e.length;o+=2)n<=e[o+1]&&r>=e[o]&&(t=!0)}),t}function ta(i){let e=[];for(let t=i.length-1;t>=0&&e.length==0;t--)i[t].forEach((n,r,o,s)=>e.push(o,s));return e}function Hr(i,e){if(!i)return null;let t=[];for(let n=0;n<i.length;n+=2){let r=e.map(i[n],1),o=e.map(i[n+1],-1);r<=o&&t.push(r,o)}return t}function Gu(i,e,t){let n=ii(e),r=gt.get(e).spec.config,o=(t?i.undone:i.done).popEvent(e,n);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(t?i.done:i.undone).addTransform(o.transform,e.selection.getBookmark(),r,n),a=new Ce(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(gt,{redo:t,historyState:a})}var $r=!1,na=null;function ii(i){let e=i.plugins;if(na!=e){$r=!1,na=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){$r=!0;break}}return $r}var gt=new ae("history"),Xu=new ae("closeHistory");function ia(i={}){return i={depth:i.depth||100,newGroupDelay:i.newGroupDelay||500},new G({key:gt,state:{init(){return new Ce(yt.empty,yt.empty,null,0,-1)},apply(e,t,n){return ju(t,n,e,i)}},config:i,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n=="historyUndo"?oi:n=="historyRedo"?mn:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function ri(i,e){return(t,n)=>{let r=gt.getState(t);if(!r||(i?r.undone:r.done).eventCount==0)return!1;if(n){let o=Gu(r,t,i);o&&n(e?o.scrollIntoView():o)}return!0}}var oi=ri(!1,!0),mn=ri(!0,!0),pm=ri(!1,!1),fm=ri(!0,!1);var De={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:"'"},li={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Qu=typeof navigator<"u"&&/Mac/.test(navigator.platform),Yu=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(z=0;z<10;z++)De[48+z]=De[96+z]=String(z);var z;for(z=1;z<=24;z++)De[z+111]="F"+z;var z;for(z=65;z<=90;z++)De[z]=String.fromCharCode(z+32),li[z]=String.fromCharCode(z);var z;for(si in De)li.hasOwnProperty(si)||(li[si]=De[si]);var si;function ra(i){var e=Qu&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||Yu&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?li:De)[i.keyCode]||i.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var Zu=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ep=typeof navigator<"u"&&/Win/.test(navigator.platform);function tp(i){let e=i.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,r,o,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))Zu?s=!0:r=!0;else throw new Error("Unrecognized modifier name: "+a)}return n&&(t="Alt-"+t),r&&(t="Ctrl-"+t),s&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function np(i){let e=Object.create(null);for(let t in i)e[tp(t)]=i[t];return e}function Wr(i,e,t=!0){return e.altKey&&(i="Alt-"+i),e.ctrlKey&&(i="Ctrl-"+i),e.metaKey&&(i="Meta-"+i),t&&e.shiftKey&&(i="Shift-"+i),i}function gn(i){return new G({props:{handleKeyDown:ip(i)}})}function ip(i){let e=np(i);return function(t,n){let r=ra(n),o,s=e[Wr(r,n)];if(s&&s(t.state,t.dispatch,t))return!0;if(r.length==1&&r!=" "){if(n.shiftKey){let l=e[Wr(r,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(ep&&n.ctrlKey&&n.altKey)&&(o=De[n.keyCode])&&o!=r){let l=e[Wr(o,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var rp=["imgEl"],op=i=>({"NgxEditor__Resizer--Active":i});function sp(i,e){if(i&1){let t=je();N(0,"span",4)(1,"span",5),R("mousedown",function(r){K(t);let o=_();return J(o.startResizing(r,"left"))}),M(),N(2,"span",6),R("mousedown",function(r){K(t);let o=_();return J(o.startResizing(r,"right"))}),M(),N(3,"span",7),R("mousedown",function(r){K(t);let o=_();return J(o.startResizing(r,"left"))}),M(),N(4,"span",8),R("mousedown",function(r){K(t);let o=_();return J(o.startResizing(r,"right"))}),M()()}}var lp=["ngxEditor"],ap=["*"];function cp(i,e){if(i&1&&(N(0,"div",12),Y(1),E(2,"async"),M()),i&2){let t=_(2);C(),Re(" ",O(2,1,(t.href.errors==null?null:t.href.errors.pattern)&&t.getLabel("enterValidUrl"))," ")}}function dp(i,e){if(i&1&&(N(0,"div",12),Y(1),M()),i&2){let t=_(2);C(),Re(" ",(t.text.errors==null?null:t.text.errors.required)&&"This is required"," ")}}function up(i,e){if(i&1&&(N(0,"div",4)(1,"div",5)(2,"label"),j(3,"input",13),Y(4),E(5,"async"),M()()()),i&2){let t=_(2);C(4),Re(" ",O(5,1,t.getLabel("openInNewTab"))," ")}}function pp(i,e){if(i&1){let t=je();N(0,"div",2)(1,"form",3),R("ngSubmit",function(r){K(t);let o=_();return J(o.insertLink(r))}),N(2,"div",4)(3,"div",5)(4,"label",6),Y(5),E(6,"async"),M(),j(7,"input",7),H(8,cp,3,3,"div",8),M()(),N(9,"div",4)(10,"div",5)(11,"label",6),Y(12),E(13,"async"),M(),j(14,"input",9),H(15,dp,2,1,"div",8),M()(),H(16,up,6,3,"div",10),N(17,"button",11),Y(18),E(19,"async"),M()()()}if(i&2){let t=_();C(),k("formGroup",t.form),C(3),k("htmlFor",t.getId("link-popup-url")),C(),Pe(O(6,12,t.getLabel("url"))),C(2),k("id",t.getId("link-popup-url")),C(),k("ngIf",t.href.touched&&t.href.invalid),C(3),k("htmlFor",t.getId("link-popup-label")),C(),Pe(O(13,14,t.getLabel("text"))),C(2),k("id",t.getId("link-popup-label")),C(),k("ngIf",t.text.touched&&t.text.invalid),C(),k("ngIf",t.options.showOpenInNewTab),C(),k("disabled",!t.form.valid),C(),Pe(O(19,16,t.getLabel("insert")))}}var fp=(i,e)=>({"NgxEditor__Dropdown--Active":i,"NgxEditor--Disabled":e});function hp(i,e){if(i&1){let t=je();N(0,"button",4),E(1,"async"),R("mousedown",function(r){let o=K(t).$implicit,s=_(2);return J(s.onDropdownItemMouseClick(r,o))})("keydown.enter",function(r){let o=K(t).$implicit,s=_(2);return J(s.onDropdownItemKeydown(r,o))})("keydown.space",function(r){let o=K(t).$implicit,s=_(2);return J(s.onDropdownItemKeydown(r,o))}),Y(2),E(3,"async"),M()}if(i&2){let t=e.$implicit,n=_(2);k("ngClass",wn(8,fp,t===n.activeItem,n.disabledItems.includes(t)))("ariaLabel",O(1,4,n.getName(t))),po("aria-selected",t===n.activeItem),C(2),Re(" ",O(3,6,n.getName(t))," ")}}function mp(i,e){if(i&1&&(N(0,"div",2),H(1,hp,4,11,"button",3),M()),i&2){let t=_();C(),k("ngForOf",t.items)("ngForTrackBy",t.trackByIndex)}}function gp(i,e){if(i&1&&(N(0,"div",12),Y(1),E(2,"async"),M()),i&2){let t=_(2);C(),Re(" ",O(2,1,(t.src.errors==null?null:t.src.errors.pattern)&&t.getLabel("enterValidUrl"))," ")}}function yp(i,e){if(i&1){let t=je();N(0,"div",2)(1,"form",3),R("ngSubmit",function(r){K(t);let o=_();return J(o.insertLink(r))}),N(2,"div",4)(3,"div",5)(4,"label",6),Y(5),E(6,"async"),M(),j(7,"input",7),H(8,gp,3,3,"div",8),M()(),N(9,"div",4)(10,"div",5)(11,"label",6),Y(12),E(13,"async"),M(),j(14,"input",9),M()(),N(15,"div",4)(16,"div",5)(17,"label",6),Y(18),E(19,"async"),M(),j(20,"input",10),M()(),N(21,"button",11),Y(22),E(23,"async"),M()()()}if(i&2){let t=_();C(),k("formGroup",t.form),C(3),k("htmlFor",t.getId("image-popup-url")),C(),Pe(O(6,13,t.getLabel("url"))),C(2),k("id",t.getId("image-popup-url")),C(),k("ngIf",t.src.touched&&t.src.invalid),C(3),k("htmlFor",t.getId("image-popup-label")),C(),Pe(O(13,15,t.getLabel("altText"))),C(2),k("id",t.getId("image-popup-label")),C(3),k("htmlFor",t.getId("image-popup-title")),C(),Pe(O(19,17,t.getLabel("title"))),C(2),k("id",t.getId("image-popup-title")),C(),k("disabled",!t.form.valid||!t.form.dirty),C(),Pe(O(23,19,t.getLabel("insert")))}}var xp=(i,e)=>({backgroundColor:i,color:e}),bp=i=>({"NgxEditor__Color--Active":i});function kp(i,e){if(i&1){let t=je();N(0,"button",7),R("mousedown",function(r){let o=K(t).$implicit,s=_(3);return J(s.onColorSelectMouseClick(r,o))})("keydown.enter",function(){let r=K(t).$implicit,o=_(3);return J(o.onColorSelectKeydown(r))})("keydown.space",function(){let r=K(t).$implicit,o=_(3);return J(o.onColorSelectKeydown(r))}),M()}if(i&2){let t=e.$implicit,n=_(3);k("ngStyle",wn(3,xp,t,n.getContrastYIQ(t)))("title",t)("ngClass",xi(6,bp,n.activeColors.includes(t)))}}function Cp(i,e){if(i&1&&(N(0,"div",5),H(1,kp,1,8,"button",6),M()),i&2){let t=e.$implicit,n=_(2);C(),k("ngForOf",t)("ngForTrackBy",n.trackByIndex)}}function wp(i,e){if(i&1){let t=je();N(0,"div",2),H(1,Cp,2,2,"div",3),N(2,"button",4),R("mousedown",function(r){K(t);let o=_();return J(o.onRemoveMouseClick(r))})("keydown.enter",function(){K(t);let r=_();return J(r.onRemoveKeydown())})("keydown.space",function(){K(t);let r=_();return J(r.onRemoveKeydown())}),Y(3),E(4,"async"),M()()}if(i&2){let t=_();C(),k("ngForOf",t.presets)("ngForTrackBy",t.trackByIndex),C(),k("disabled",!t.isActive),C(),Re(" ",O(4,4,t.getLabel("remove"))," ")}}var _p=(i,e)=>({"NgxEditor--Disabled":i,"NgxEditor__MenuBar--Reverse":e});function Sp(i,e){if(i&1&&j(0,"ngx-toggle-command",7),i&2){let t=_().$implicit,n=_(2);Se(n.iconContainerClass),k("toolbarItem",t)}}function Mp(i,e){if(i&1&&j(0,"ngx-insert-command",7),i&2){let t=_().$implicit,n=_(2);Se(n.iconContainerClass),k("toolbarItem",t)}}function vp(i,e){if(i&1&&(wt(0),j(1,"ngx-link",8),_t()),i&2){let t=_().$implicit,n=_(2);C(),Se(n.iconContainerClass),k("options",n.getLinkOptions(t))}}function Np(i,e){if(i&1&&j(0,"ngx-image"),i&2){let t=_(3);Se(t.iconContainerClass)}}function Ep(i,e){if(i&1&&j(0,"ngx-dropdown",10),i&2){let t=e.$implicit,n=_(4);Se(n.dropdownContainerClass),k("group",t.key)("items",t.value)}}function Op(i,e){if(i&1&&(wt(0),H(1,Ep,1,4,"ngx-dropdown",9),E(2,"keyvalue"),_t()),i&2){let t=_().$implicit,n=_(2);C(),k("ngForOf",O(2,2,n.getDropdownItems(t)))("ngForTrackBy",n.trackByIndex)}}function Tp(i,e){if(i&1&&j(0,"ngx-color-picker",11),i&2){let t=_(3);Se(t.iconContainerClass),k("presets",t.presets)}}function Ip(i,e){if(i&1&&j(0,"ngx-color-picker",12),i&2){let t=_(3);Se(t.iconContainerClass),k("presets",t.presets)}}function Dp(i,e){if(i&1&&j(0,"div"),i&2){let t=_(3);Se(t.seperatorClass)}}function Ap(i,e){if(i&1&&(wt(0),H(1,Sp,1,3,"ngx-toggle-command",3)(2,Mp,1,3,"ngx-insert-command",3)(3,vp,2,3,"ng-container",2)(4,Np,1,2,"ngx-image",4)(5,Op,3,4,"ng-container",2)(6,Tp,1,3,"ngx-color-picker",5)(7,Ip,1,3,"ngx-color-picker",6)(8,Dp,1,2,"div",4),_t()),i&2){let t=e.$implicit,n=e.last,r=_().last,o=_();C(),k("ngIf",o.toggleCommands.includes(t)),C(),k("ngIf",o.insertCommands.includes(t)),C(),k("ngIf",o.isLinkItem(t)),C(),k("ngIf",t==="image"),C(),k("ngIf",o.isDropDown(t)),C(),k("ngIf",t==="text_color"),C(),k("ngIf",t==="background_color"),C(),k("ngIf",n&&!r)}}function Pp(i,e){if(i&1&&(wt(0),H(1,Ap,9,8,"ng-container",1),_t()),i&2){let t=e.$implicit,n=_();C(),k("ngForOf",t)("ngForTrackBy",n.trackByIndex)}}function Rp(i,e){if(i&1&&(wt(0),fo(1,13),_t()),i&2){let t=_();C(),k("ngTemplateOutlet",t.customMenuRef)}}var zp=(i=!0)=>new G({key:new ae("editable"),state:{init(){return i},apply(e,t){return e.getMeta("UPDATE_EDITABLE")??t}},props:{editable(e){return this.getState(e)},attributes(e){return this.getState(e)?null:{class:"NgxEditor__Content--Disabled"}}}}),Bp="NgxEditor__Placeholder",Lp=i=>new G({key:new ae("placeholder"),state:{init(){return i??""},apply(e,t){return e.getMeta("UPDATE_PLACEHOLDER")??t}},props:{decorations(e){let{doc:t}=e,{textContent:n,childCount:r}=t,o=this.getState(e);if(!o||r>1)return Z.empty;let s=[],l=(a,c)=>{if(a.type.isBlock&&a.childCount===0&&n.length===0){let d=c,u=c+a.nodeSize,p=be.node(d,u,{class:Bp,"data-placeholder":o,"data-align":a.attrs.align??null});s.push(p)}return!1};return t.descendants(l),Z.create(t,s)}}}),Fp=(i={})=>new G({key:new ae("attributes"),props:{attributes:i}}),Vp=i=>new G({key:new ae("focus"),props:{handleDOMEvents:{focus:()=>(i(),!1)}}}),Hp=i=>new G({key:new ae("blur"),props:{handleDOMEvents:{blur:()=>(i(),!1)}}}),$p=(()=>{class i{src;alt="";title="";outerWidth="";selected=!1;view;imageResize=new Cn;imgEl;startResizing(t,n){t.preventDefault(),this.resizeImage(t,n)}resizeImage(t,n){let r=t.pageX,o=this.imgEl.nativeElement.clientWidth,s=n==="left",{width:l}=window.getComputedStyle(this.view.dom),a=parseInt(l,10),c=u=>{let h=u.pageX-r,f=s?o-h:o+h;f>a||f<20||(this.outerWidth=`${f}px`)},d=u=>{u.preventDefault(),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",d),this.imageResize.emit()};document.addEventListener("mousemove",c),document.addEventListener("mouseup",d)}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=me({type:i,selectors:[["ngx-image-view"]],viewQuery:function(n,r){if(n&1&&hi(rp,7),n&2){let o;mi(o=gi())&&(r.imgEl=o.first)}},inputs:{src:"src",alt:"alt",title:"title",outerWidth:"outerWidth",selected:"selected",view:"view"},outputs:{imageResize:"imageResize"},standalone:!1,decls:4,vars:9,consts:[["imgEl",""],[1,"NgxEditor__ImageWrapper",3,"ngClass"],["class","NgxEditor__ResizeHandle",4,"ngIf"],[3,"src","alt","title"],[1,"NgxEditor__ResizeHandle"],[1,"NgxEditor__ResizeHandle--TL",3,"mousedown"],[1,"NgxEditor__ResizeHandle--TR",3,"mousedown"],[1,"NgxEditor__ResizeHandle--BL",3,"mousedown"],[1,"NgxEditor__ResizeHandle--BR",3,"mousedown"]],template:function(n,r){n&1&&(N(0,"span",1),H(1,sp,5,0,"span",2),j(2,"img",3,0),M()),n&2&&(go("width",r.outerWidth),k("ngClass",xi(7,op,r.selected)),C(),k("ngIf",r.selected),C(),k("src",r.src,lo)("alt",r.alt)("title",r.title))},dependencies:[jt,Ge],styles:["*[_ngcontent-%COMP%], *[_ngcontent-%COMP%]:before, *[_ngcontent-%COMP%]:after{box-sizing:border-box}img[_ngcontent-%COMP%]{width:100%;height:100%}.NgxEditor__ImageWrapper[_ngcontent-%COMP%]{position:relative;display:inline-block;line-height:0;padding:2px}.NgxEditor__ImageWrapper.NgxEditor__Resizer--Active[_ngcontent-%COMP%]{padding:1px;border:1px solid #1a73e8}.NgxEditor__ImageWrapper[_ngcontent-%COMP%] .NgxEditor__ResizeHandle[_ngcontent-%COMP%]{position:absolute;height:100%;width:100%}.NgxEditor__ImageWrapper[_ngcontent-%COMP%] .NgxEditor__ResizeHandle[_ngcontent-%COMP%] .NgxEditor__ResizeHandle--TL[_ngcontent-%COMP%], .NgxEditor__ImageWrapper[_ngcontent-%COMP%] .NgxEditor__ResizeHandle[_ngcontent-%COMP%] .NgxEditor__ResizeHandle--BL[_ngcontent-%COMP%], .NgxEditor__ImageWrapper[_ngcontent-%COMP%] .NgxEditor__ResizeHandle[_ngcontent-%COMP%] .NgxEditor__ResizeHandle--TR[_ngcontent-%COMP%], .NgxEditor__ImageWrapper[_ngcontent-%COMP%] .NgxEditor__ResizeHandle[_ngcontent-%COMP%] .NgxEditor__ResizeHandle--BR[_ngcontent-%COMP%]{position:absolute;width:7px;height:7px;background-color:#1a73e8;border:1px solid white}.NgxEditor__ImageWrapper[_ngcontent-%COMP%] .NgxEditor__ResizeHandle[_ngcontent-%COMP%] .NgxEditor__ResizeHandle--BR[_ngcontent-%COMP%]{bottom:-5px;right:-5px;cursor:se-resize}.NgxEditor__ImageWrapper[_ngcontent-%COMP%] .NgxEditor__ResizeHandle[_ngcontent-%COMP%] .NgxEditor__ResizeHandle--TR[_ngcontent-%COMP%]{top:-5px;right:-5px;cursor:ne-resize}.NgxEditor__ImageWrapper[_ngcontent-%COMP%] .NgxEditor__ResizeHandle[_ngcontent-%COMP%] .NgxEditor__ResizeHandle--TL[_ngcontent-%COMP%]{top:-5px;left:-5px;cursor:nw-resize}.NgxEditor__ImageWrapper[_ngcontent-%COMP%] .NgxEditor__ResizeHandle[_ngcontent-%COMP%] .NgxEditor__ResizeHandle--BL[_ngcontent-%COMP%]{bottom:-5px;left:-5px;cursor:sw-resize}"]})}return i})(),qr=class{dom;view;getPos;applicationRef;imageComponentRef;resizeSubscription;node;updating=!1;constructor(e,t,n,r){this.applicationRef=r.get(uo),this.imageComponentRef=yo($p,{environmentInjector:this.applicationRef.injector}),this.applicationRef.attachView(this.imageComponentRef.hostView),this.setNodeAttributes(e.attrs),this.imageComponentRef.instance.view=t,this.dom=this.imageComponentRef.location.nativeElement,this.view=t,this.node=e,this.getPos=n,this.resizeSubscription=this.imageComponentRef.instance.imageResize.subscribe(()=>{this.handleResize()})}computeChanges(e,t){return JSON.stringify(e)===JSON.stringify(t)}setNodeAttributes(e){this.imageComponentRef.instance.src=e.src,this.imageComponentRef.instance.alt=e.alt,this.imageComponentRef.instance.title=e.title,this.imageComponentRef.instance.outerWidth=e.width}handleResize=()=>{if(this.updating)return;let{state:e,dispatch:t}=this.view,{tr:n}=e,r=n.setNodeMarkup(this.getPos(),void 0,_e(L({},this.node.attrs),{width:this.imageComponentRef.instance.outerWidth})),o=r.doc.resolve(this.getPos()),s=new w(o);r.setSelection(s),t(r)};update(e){return e.type!==this.node.type?!1:(this.node=e,this.computeChanges(this.node.attrs,e.attrs)&&(this.updating=!0,this.setNodeAttributes(e.attrs),this.updating=!1),!0)}ignoreMutation(){return!0}selectNode(){this.imageComponentRef.instance.selected=!0}deselectNode(){this.imageComponentRef.instance.selected=!1}destroy(){this.resizeSubscription.unsubscribe(),this.applicationRef.detachView(this.imageComponentRef.hostView)}},Wp=i=>new G({key:new ae("image-resize"),props:{nodeViews:{image:(e,t,n)=>new qr(e,t,n,i)}}}),qp=/(?:https?:\/\/)?[\w-]+(?:\.[\w-]+)+\.?(?:\d+)?(?:\/\S*)?$/,ga=i=>{let e=[];return i.forEach(t=>{if(t.isText){let n=t.text,r=0,o=qp.exec(n);if(o){let s=o.index,l=s+o[0].length,{link:a}=t.type.schema.marks;s>0&&e.push(t.cut(r,s));let c=n.slice(s,l);e.push(t.cut(s,l).mark(a.create({href:c}).addToSet(t.marks))),r=l}r<n.length&&e.push(t.cut(r))}else e.push(t.copy(ga(t.content)))}),y.fromArray(e)},Kp=()=>new G({key:new ae("linkify"),props:{transformPasted:i=>new x(ga(i.content),i.openStart,i.openEnd)}}),ya=i=>typeof i=="string",Jp=()=>window.trustedTypes,xa=i=>Jp()?.isHTML(i)??!1,ba=i=>ya(i)||xa(i),ka={type:"doc",content:[{type:"paragraph"}]},jp=(i,e)=>{let t=e??qe,n=t.nodeFromJSON(i),r=Me.fromSchema(t).serializeFragment(n.content),o=document.createElement("div");return o.appendChild(r),o.innerHTML},Up=(i,e,t)=>{let n=e??qe,r=document.createElement("div");return r.innerHTML=i,ze.fromSchema(n).parse(r,t).toJSON()},xn=(i,e,t)=>{if(!i)return e.nodeFromJSON(ka);if(!ba(i))return e.nodeFromJSON(i);let n=Up(i,e,t);return e.nodeFromJSON(n)},ig=(()=>{class i{renderer;injector;elementRef;constructor(t,n,r){this.renderer=t,this.injector=n,this.elementRef=r}ngxEditor;editor;outputFormat;placeholder="Type Here...";focusOut=new Cn;focusIn=new Cn;unsubscribe=new Kt;onChange=()=>{};onTouched=()=>{};writeValue(t){!this.outputFormat&&ba(t)&&(this.outputFormat="html"),this.editor.setContent(t??ka)}registerOnChange(t){this.onChange=t}registerOnTouched(t){this.onTouched=t}setDisabledState(t){this.setMeta("UPDATE_EDITABLE",!t),this.renderer.setProperty(this.elementRef.nativeElement,"disabled",t)}handleChange(t){if(this.outputFormat==="html"){let n=jp(t,this.editor.schema);this.onChange(n);return}this.onChange(t)}setMeta(t,n){let{dispatch:r,state:{tr:o}}=this.editor.view;r(o.setMeta(t,n))}setPlaceholder(t){this.setMeta("UPDATE_PLACEHOLDER",t)}registerPlugins(){this.editor.registerPlugin(zp()),this.editor.registerPlugin(Lp(this.placeholder)),this.editor.registerPlugin(Fp({class:"NgxEditor__Content"})),this.editor.registerPlugin(Vp(()=>{this.focusIn.emit()})),this.editor.registerPlugin(Hp(()=>{this.focusOut.emit(),this.onTouched()})),this.editor.features.resizeImage&&this.editor.registerPlugin(Wp(this.injector)),this.editor.features.linkOnPaste&&this.editor.registerPlugin(Kp())}ngOnInit(){if(!this.editor)throw new Mt("Required editor instance for initializing editor component");this.registerPlugins(),this.renderer.appendChild(this.ngxEditor.nativeElement,this.editor.view.dom),this.editor.valueChanges.pipe(to(this.unsubscribe)).subscribe(t=>{this.handleChange(t)})}ngOnChanges(t){t.placeholder&&!t.placeholder.isFirstChange()&&this.setPlaceholder(t.placeholder.currentValue)}ngOnDestroy(){this.unsubscribe.next(),this.unsubscribe.complete()}static \u0275fac=function(n){return new(n||i)(P(ao),P(oo),P(kt))};static \u0275cmp=me({type:i,selectors:[["ngx-editor"]],viewQuery:function(n,r){if(n&1&&hi(lp,7),n&2){let o;mi(o=gi())&&(r.ngxEditor=o.first)}},inputs:{editor:"editor",outputFormat:"outputFormat",placeholder:"placeholder"},outputs:{focusOut:"focusOut",focusIn:"focusIn"},standalone:!1,features:[yi([{provide:wo,useExisting:no(()=>i),multi:!0}]),so],ngContentSelectors:ap,decls:3,vars:0,consts:[["ngxEditor",""],[1,"NgxEditor"]],template:function(n,r){n&1&&(ho(),N(0,"div",1,0),mo(2),M())},styles:[`:root{--ngx-editor-border-radius: 4px;--ngx-editor-background-color: #fff;--ngx-editor-text-color: #000;--ngx-editor-placeholder-color: #6c757d;--ngx-editor-border-color: rgba(0, 0, 0, .2);--ngx-editor-wrapper-border-color: rgba(0, 0, 0, .2);--ngx-editor-menubar-bg-color: #fff;--ngx-editor-menubar-padding: 3px;--ngx-editor-menubar-height: 30px;--ngx-editor-blockquote-color: #ddd;--ngx-editor-blockquote-border-width: 3px;--ngx-editor-icon-size: 30px;--ngx-editor-popup-bg-color: #fff;--ngx-editor-popup-border-radius: 4px;--ngx-editor-popup-shadow: rgba(60, 64, 67, .15) 0px 2px 6px 2px;--ngx-editor-menu-item-border-radius: 2px;--ngx-editor-menu-item-active-color: #1a73e8;--ngx-editor-menu-item-hover-bg-color: #f1f1f1;--ngx-editor-menu-item-active-bg-color: #e8f0fe;--ngx-editor-seperator-color: #ccc;--ngx-editor-bubble-bg-color: #000;--ngx-editor-bubble-text-color: #fff;--ngx-editor-bubble-item-hover-color: #636262;--ngx-editor-bubble-seperator-color: #fff;--ngx-editor-focus-ring-color: #5e9ed6;--ngx-editor-error-color: red;--ngx-editor-click-pointer: default}.NgxEditor{background:var(--ngx-editor-background-color);color:var(--ngx-editor-text-color);background-clip:padding-box;border-radius:var(--ngx-editor-border-radius);border:1px solid var(--ngx-editor-border-color);position:relative}.NgxEditor--Disabled{opacity:.5!important;pointer-events:none!important}.NgxEditor__Placeholder:before{color:var(--ngx-editor-placeholder-color);opacity:1;-webkit-user-select:none;user-select:none;position:absolute;cursor:text;content:attr(data-placeholder)}.NgxEditor__Placeholder[data-align=right]:before{position:relative}.NgxEditor__Content{padding:8px;white-space:pre-wrap;outline:none;font-variant-ligatures:none;font-feature-settings:"liga" 0}.NgxEditor__Content p{margin:0 0 10px}.NgxEditor__Content blockquote{padding-left:16px;border-left:var(--ngx-editor-blockquote-border-width) solid var(--ngx-editor-blockquote-color);margin-left:0;margin-right:0}.NgxEditor__Content--Disabled{-webkit-user-select:none;user-select:none;pointer-events:none}.NgxEditor__Wrapper{border:1px solid var(--ngx-editor-wrapper-border-color);border-radius:var(--ngx-editor-border-radius)}.NgxEditor__Wrapper .NgxEditor__MenuBar{border-top-left-radius:var(--ngx-editor-border-radius);border-top-right-radius:var(--ngx-editor-border-radius);border-bottom:1px solid var(--ngx-editor-border-color)}.NgxEditor__Wrapper .NgxEditor{border-top-left-radius:0;border-top-right-radius:0;border:none}.NgxEditor__MenuBar{display:flex;flex-wrap:wrap;padding:var(--ngx-editor-menubar-padding);background-color:var(--ngx-editor-menubar-bg-color);gap:.25rem .1rem}.NgxEditor__MenuBar button:not(:disabled),.NgxEditor__MenuBar [role=button]:not(:disabled){cursor:var(--ngx-editor-click-pointer, default)}.NgxEditor__MenuItem{display:flex;align-items:center;justify-content:center;position:relative;flex-shrink:0}.NgxEditor__MenuItem.NgxEditor__MenuItem--IconContainer{display:flex;align-items:center;justify-content:center}.NgxEditor__MenuItem .NgxEditor__MenuItem--Icon{all:unset;appearance:none;height:var(--ngx-editor-icon-size);width:var(--ngx-editor-icon-size);transition:.2s ease-in-out;display:inline-flex;align-items:center;justify-content:center;border-radius:var(--ngx-editor-menu-item-border-radius)}.NgxEditor__MenuItem .NgxEditor__MenuItem--Icon+.NgxEditor__MenuItem--Icon{margin-left:2px}.NgxEditor__MenuItem .NgxEditor__MenuItem--Icon:focus-visible{outline:1px solid var(--ngx-editor-focus-ring-color)}.NgxEditor__MenuItem .NgxEditor__MenuItem--Icon:hover{background-color:var(--ngx-editor-menu-item-hover-bg-color)}.NgxEditor__MenuItem.NgxEditor__MenuItem--Text{padding:0 5px}.NgxEditor__MenuItem.NgxEditor__MenuItem--Active,.NgxEditor__MenuItem .NgxEditor__MenuItem--Active{background-color:var(--ngx-editor-menu-item-active-bg-color);color:var(--ngx-editor-menu-item-active-color)}.NgxEditor__Dropdown{min-width:64px;position:relative;display:flex;align-items:center;flex-shrink:0}.NgxEditor__Dropdown:hover{background-color:var(--ngx-editor-menu-item-hover-bg-color)}.NgxEditor__Dropdown .NgxEditor__Dropdown--Text{all:unset;appearance:none;display:flex;align-items:center;justify-content:center;padding:0 5px;height:100%;width:100%}.NgxEditor__Dropdown .NgxEditor__Dropdown--Text:focus-visible{outline:1px solid var(--ngx-editor-focus-ring-color)}.NgxEditor__Dropdown .NgxEditor__Dropdown--Text:after{display:inline-block;content:"";margin-left:24px;vertical-align:4px;border-top:4px solid;border-right:4px solid transparent;border-bottom:0;border-left:4px solid transparent}.NgxEditor__Dropdown .NgxEditor__Dropdown--DropdownMenu{position:absolute;left:0;box-shadow:var(--ngx-editor-popup-shadow);border-radius:var(--ngx-editor-popup-border-radius);background-color:var(--ngx-editor-popup-bg-color);z-index:10;width:100%;top:calc(var(--ngx-editor-menubar-height) + 2px);display:flex;flex-direction:column}.NgxEditor__Dropdown .NgxEditor__Dropdown--Item{all:unset;appearance:none;padding:8px;white-space:nowrap;color:inherit}.NgxEditor__Dropdown .NgxEditor__Dropdown--Item:focus-visible{outline:1px solid var(--ngx-editor-focus-ring-color)}.NgxEditor__Dropdown .NgxEditor__Dropdown--Item:hover{background-color:var(--ngx-editor-menu-item-hover-bg-color)}.NgxEditor__Dropdown .NgxEditor__Dropdown--Selected,.NgxEditor__Dropdown .NgxEditor__Dropdown--Open{color:var(--ngx-editor-menu-item-active-color);background-color:var(--ngx-editor-menu-item-active-bg-color)}.NgxEditor__Dropdown .NgxEditor__Dropdown--Active{background-color:var(--ngx-editor-menu-item-active-bg-color)}.NgxEditor__Dropdown .NgxEditor__Dropdown--Active:hover{background-color:var(--ngx-editor-menu-item-hover-bg-color)}.NgxEditor__MenuBar--Reverse .NgxEditor__Dropdown--DropdownMenu{top:unset;bottom:calc(var(--ngx-editor-menubar-height) + 2px)}.NgxEditor__MenuBar--Reverse .NgxEditor__Dropdown--Text:after{transform:rotate(180deg)}.NgxEditor__MenuBar--Reverse .NgxEditor__Popup{top:unset;bottom:calc(var(--ngx-editor-menubar-height) + 2px)}.NgxEditor__Popup{position:absolute;top:calc(var(--ngx-editor-menubar-height) + 2px);box-shadow:var(--ngx-editor-popup-shadow);border-radius:var(--ngx-editor-popup-border-radius);background-color:var(--ngx-editor-popup-bg-color);z-index:10;min-width:192px;padding:8px}.NgxEditor__Popup .NgxEditor__Popup--FormGroup{margin-bottom:8px}.NgxEditor__Popup .NgxEditor__Popup--FormGroup label{margin-bottom:3px}.NgxEditor__Popup .NgxEditor__Popup--FormGroup input[type=text],.NgxEditor__Popup .NgxEditor__Popup--FormGroup input[type=url]{padding:2px 4px}.NgxEditor__Popup .NgxEditor__Popup--Col{display:flex;flex-direction:column;position:relative}.NgxEditor__Popup .NgxEditor__Popup--Label{font-size:85%}.NgxEditor__Seperator{border-left:1px solid var(--ngx-editor-seperator-color);margin:0 5px}.NgxEditor__HelpText{font-size:80%}.NgxEditor__HelpText.NgxEditor__HelpText--Error{color:var(--ngx-editor-error-color)}
`],encapsulation:2})}return i})(),Ke=(()=>{class i{editor;customMenuRefChange=new Kt;setCustomMenuRef(t){this.customMenuRefChange.next(t)}static \u0275fac=function(n){return new(n||i)};static \u0275prov=kn({token:i,factory:i.\u0275fac,providedIn:"root"})}return i})(),we=class{name;constructor(e){this.name=e}apply(){return(e,t)=>{let{schema:n}=e,r=n.marks[this.name];return r?Fr(r)(e,t):!1}}toggle(){return(e,t)=>{let{schema:n}=e,r=n.marks[this.name];return r?mt(r)(e,t):!1}}isActive(e){let{schema:t}=e,n=t.marks[this.name];return n?ti(e,n):!1}canExecute(e){return this.toggle()(e)}},Kr=class{toggle(){return(e,t)=>{let{schema:n}=e,r=n.nodes.blockquote;return r?this.isActive(e)?Fl(e,t):$l(r)(e,t):!1}}isActive(e){let{schema:t}=e,n=t.nodes.blockquote;return n?Rr(e,n):!1}canExecute(e){return this.toggle()(e)}},Jr=class{insert(){return(e,t)=>{let{schema:n,tr:r}=e,o=n.nodes.horizontal_rule;return o?(t(r.replaceSelectionWith(o.create()).scrollIntoView()),!0):!1}}canExecute(e){return Ql(e,e.schema.nodes.horizontal_rule)}},$t=class{isBulletList=!1;constructor(e=!1){this.isBulletList=e}getType(e){return this.isBulletList?e.nodes.bullet_list:e.nodes.ordered_list}toggle(){return(e,t)=>{let{schema:n}=e,r=this.getType(n);return r?this.isActive(e)?Mr(n.nodes.list_item)(e,t):Al(r)(e,t):!1}}isActive(e){let{schema:t}=e,n=this.getType(t);return n?Rr(e,n):!1}canExecute(e){return this.toggle()(e)}},Ae=class{level;constructor(e){this.level=e}apply(){return(e,t)=>{let{schema:n}=e,r=n.nodes.heading;return r?Zn(r)(e,t):!1}}toggle(){return(e,t)=>{let{schema:n,selection:r,doc:o}=e,s=n.nodes.heading;if(!s)return!1;let l=r.$from.before(1),c=o.nodeAt(l)?.attrs??{};return this.isActive(e)?Zn(n.nodes.paragraph,c)(e,t):Zn(s,_e(L({},c),{level:this.level}))(e,t)}}isActive(e){let{schema:t}=e,n=zr(e),r=t.nodes.heading;if(!r)return!1;let o=[r,t.nodes.text,t.nodes.blockquote];return!!n.filter(a=>o.includes(a.type)).find(a=>a.attrs.level===this.level)}canExecute(e){return this.toggle()(e)}},xt=class{align;constructor(e){this.align=e}toggle(){return(e,t)=>{let{doc:n,selection:r,tr:o,schema:s}=e,{from:l,to:a}=r,c=!1;return n.nodesBetween(l,a,(d,u)=>{let p=d.type;if([s.nodes.paragraph,s.nodes.heading].includes(p)){c=!0;let h=d.attrs.align===this.align?null:this.align;o.setNodeMarkup(u,p,_e(L({},d.attrs),{align:h}))}return!0}),c?(o.docChanged&&t?.(o),!0):!1}}isActive(e){return!!zr(e).find(r=>r.attrs.align===this.align)}canExecute(e){return this.toggle()(e)}},Gp={strict:!0},jr=class{update(e){return(t,n)=>{let{schema:r,selection:o}=t,s=r.marks.link;return!s||o.empty?!1:mt(s,e)(t,n)}}insert(e,t){return(n,r)=>{let{schema:o,tr:s}=n;if(!o.marks.link)return!1;let a={href:t.href,title:t.title??e,target:t.target??"_blank"},c=o.text(e,[o.marks.link.create(a)]);return s.replaceSelectionWith(c,!1).scrollIntoView(),s.docChanged?(r?.(s),!0):!1}}isActive(e,t=Gp){if(t.strict)return!0;let{schema:n}=e,r=n.marks.link;return r?ti(e,r):!1}remove(e,t){return Yl()(e,t)}canExecute(e){let t={href:""};return this.insert("Exec",t)(e)||this.update(t)(e)}},Ca=class{insert(e,t){return(n,r)=>{let{schema:o,tr:s,selection:l}=n,a=o.nodes.image;if(!a)return!1;let c=L({width:null,src:e},t);!c.width&&l instanceof w&&l.node.type===a&&(c.width=l.node.attrs.width),s.replaceSelectionWith(a.createAndFill(c));let d=s.doc.resolve(s.selection.anchor-s.selection.$anchor.nodeBefore.nodeSize);return s.setSelection(new w(d)).scrollIntoView(),s.docChanged?(r?.(s),!0):!1}}isActive(e){let{selection:t}=e;return t instanceof w?t.node.type.name==="image":!1}},Ht=class{name;attrName;constructor(e,t="color"){this.name=e,this.attrName=t}apply(e){return(t,n)=>{let{schema:r,selection:o,doc:s}=t,l=r.marks[this.name];if(!l)return!1;let{from:a,to:c,empty:d}=o;if(!d&&a+1===c){let u=s.nodeAt(a);if(u?.isAtom&&!u.isText&&u.isLeaf)return!1}return Fr(l,e)(t,n)}}isActive(e){let{schema:t}=e,n=t.marks[this.name];return n?ti(e,n):!1}getActiveColors(e){if(!this.isActive(e))return[];let{schema:t}=e;return Xl(e).filter(o=>o.type===t.marks[this.name]).map(o=>o.attrs[this.attrName]).filter(Boolean)}remove(){return(e,t)=>{let{schema:n}=e,r=n.marks[this.name];return r?Zl(r)(e,t):!1}}canExecute(e){let t=this.name==="text_color"?{color:""}:{backgroundColor:""};return this.apply(t)(e)}},Xp=["link"],Ur=class{insert(){return(e,t)=>{let{tr:n}=e,{ranges:r,empty:o}=n.selection;return o||(Object.entries(e.schema.marks).forEach(([s,l])=>{Xp.includes(s)||r.forEach(a=>{n.removeMark(a.$from.pos,a.$to.pos,l)})}),t(n)),!0}}canExecute(){return!0}},Qp=["paragraph","heading","blockquote"],oa=0,sa=10,Yp=(i,e,t)=>{let n=i.doc.nodeAt(e);if(!n)return!1;let r=n.attrs.indent??0,o=vo(r+(t==="increase"?1:-1),oa,sa);if(o===r||o<oa||o>sa)return!1;let s=_e(L({},n.attrs),{indent:o});return i.setNodeMarkup(e,n.type,s),!0},Wt=class{method="increase";constructor(e){this.method=e}insert(){return(e,t)=>{let{tr:n,doc:r}=e,{from:o,to:s}=n.selection,l=!1;return r.nodesBetween(o,s,(a,c)=>{let d=a.type;return Qp.includes(d.name)?(l=Yp(n,c,this.method),!1):!a.type.name.includes("list")}),l?(n.docChanged&&t?.(n),!0):!1}}canExecute(e){return this.insert()(e)}},ci=class{mode="undo";constructor(e){this.mode=e}insert(){return(e,t)=>this.mode==="undo"?oi(e,t):mn(e,t)}canExecute(e){return this.insert()(e)}},Zp=new we("strong"),ef=new we("em"),tf=new we("code"),nf=new we("u"),rf=new we("s"),of=new Kr,sf=new Jr,lf=new Ur,af=new $t(!0),cf=new $t(!1),df=new Ae(1),uf=new Ae(2),pf=new Ae(3),ff=new Ae(4),hf=new Ae(5),mf=new Ae(6),gf=new xt("left"),yf=new xt("center"),xf=new xt("right"),bf=new xt("justify"),kf=new jr,Cf=new Ca,wf=new Ht("text_color","color"),_f=new Ht("text_background_color","backgroundColor"),Sf=new Wt("increase"),Mf=new Wt("decrease"),vf=new we("sup"),Nf=new we("sub"),Ef=new ci("undo"),Of=new ci("redo"),di={bold:Zp,italic:ef,code:tf,underline:nf,strike:rf,blockquote:of,bullet_list:af,ordered_list:cf,h1:df,h2:uf,h3:pf,h4:ff,h5:hf,h6:mf,align_left:gf,align_center:yf,align_right:xf,align_justify:bf,superscript:vf,subscript:Nf},la={horizontal_rule:sf,format_clear:lf,indent:Sf,outdent:Mf,undo:Ef,redo:Of},yn=kf,aa=Cf,Tf=wf,If=_f,Gr={bold:"Bold",italic:"Italic",code:"Code",underline:"Underline",strike:"Strike",blockquote:"Blockquote",bullet_list:"Bullet List",ordered_list:"Ordered List",heading:"Heading",h1:"Header 1",h2:"Header 2",h3:"Header 3",h4:"Header 4",h5:"Header 5",h6:"Header 6",align_left:"Left Align",align_center:"Center Align",align_right:"Right Align",align_justify:"Justify",text_color:"Text Color",background_color:"Background Color",horizontal_rule:"Horizontal rule",format_clear:"Clear Formatting",insertLink:"Insert Link",removeLink:"Remove Link",insertImage:"Insert Image",indent:"Increase Indent",outdent:"Decrease Indent",superscript:"Superscript",subscript:"Subscript",undo:"Undo",redo:"Redo",url:"URL",text:"Text",openInNewTab:"Open in new tab",insert:"Insert",altText:"Alt Text",title:"Title",remove:"Remove",enterValidUrl:"Please enter a valid URL"},Xr=class{locals=Gr;constructor(e={}){this.locals=L(L({},Gr),e)}get=e=>{let t=this.locals[e];return t?eo(t)?t:ui(t):ui("")}},Df=`
<path d="M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z" />
`,Af=`
<path d="M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z" />
`,Pf=`
<path d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"/>
`,Rf=`
<path d="M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"/>
`,zf=`
<path d="M6.85,7.08C6.85,4.37,9.45,3,12.24,3c1.64,0,3,0.49,3.9,1.28c0.77,0.65,1.46,1.73,1.46,3.24h-3.01 c0-0.31-0.05-0.59-0.15-0.85c-0.29-0.86-1.2-1.28-2.25-1.28c-1.86,0-2.34,1.02-2.34,1.7c0,0.48,0.25,0.88,0.74,1.21 C10.97,8.55,11.36,8.78,12,9H7.39C7.18,8.66,6.85,8.11,6.85,7.08z M21,12v-2H3v2h9.62c1.15,0.45,1.96,0.75,1.96,1.97 c0,1-0.81,1.67-2.28,1.67c-1.54,0-2.93-0.54-2.93-2.51H6.4c0,0.55,0.08,1.13,0.24,1.58c0.81,2.29,3.29,3.3,5.67,3.3 c2.27,0,5.3-0.89,5.3-4.05c0-0.3-0.01-1.16-0.48-1.94H21V12z"/>
`,Bf=`
<path d="M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"/>
`,Lf=`
<path d="M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"/>
`,Ff=`
<path d="M0 0h24v24H0z" fill="none"/><path d="M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"/>
`,Vf=`
<path d="M0 0h24v24H0z" fill="none"/><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>
`,Hf=`
<path d="M17 7h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1 0 1.43-.98 2.63-2.31 2.98l1.46 1.46C20.88 15.61 22 13.95 22 12c0-2.76-2.24-5-5-5zm-1 4h-2.19l2 2H16zM2 4.27l3.11 3.11C3.29 8.12 2 9.91 2 12c0 2.76 2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1 0-1.59 1.21-2.9 2.76-3.07L8.73 11H8v2h2.73L13 15.27V17h1.73l4.01 4L20 19.74 3.27 3 2 4.27z"/>
`,$f=`
<path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/>
`,Wf=`
<path d="M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z"/>
`,qf=`
<path d="M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z"/>
`,Kf=`
<path d="M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z"/>
`,Jf=`
<path d="M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zm0-6v2h18V3H3z"/>
`,jf=`
<path d="M2,20h20v4H2V20z M5.49,17h2.42l1.27-3.58h5.65L16.09,17h2.42L13.25,3h-2.5L5.49,17z M9.91,11.39l2.03-5.79h0.12l2.03,5.79 H9.91z"/>
`,Uf=`
<path d="M16.56,8.94L7.62,0L6.21,1.41l2.38,2.38L3.44,8.94c-0.59,0.59-0.59,1.54,0,2.12l5.5,5.5C9.23,16.85,9.62,17,10,17 s0.77-0.15,1.06-0.44l5.5-5.5C17.15,10.48,17.15,9.53,16.56,8.94z M5.21,10L10,5.21L14.79,10H5.21z M19,11.5c0,0-2,2.17-2,3.5 c0,1.1,0.9,2,2,2s2-0.9,2-2C21,13.67,19,11.5,19,11.5z M2,20h20v4H2V20z"/>
`,Gf=`
<g>
<rect fill="none" fill-rule="evenodd" height="24" width="24"/>
<rect fill-rule="evenodd" height="2" width="16" x="4" y="11"/>
</g>
`,Xf=`
<path d="M0 0h24v24H0z" fill="none"/><path d="M3.27 5L2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21 18 19.73 3.55 5.27 3.27 5zM6 5v.18L8.82 8h2.4l-.72 1.68 2.1 2.1L14.21 8H20V5H6z"/>
`,Qf='<path d="M0 0h24v24H0V0z" fill="none"/><path d="M3 21h18v-2H3v2zM3 8v8l4-4-4-4zm8 9h10v-2H11v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z"/>',Yf='<path d="M0 0h24v24H0V0z" fill="none"/><path d="M11 17h10v-2H11v2zm-8-5l4 4V8l-4 4zm0 9h18v-2H3v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z"/>',Zf='<g><rect fill="none" height="20" width="20"/><path d="M17,6l-1,0v1h2v1l-3,0V6c0-0.55,0.45-1,1-1l1,0l0-1h-2V3l2,0c0.55,0,1,0.45,1,1v1C18,5.55,17.55,6,17,6z M5.63,16h1.9 l2.43-3.87h0.08L12.47,16h1.9l-3.32-5.2l3.1-4.8h-1.91l-2.19,3.56H9.96L7.75,6h-1.9l3.09,4.8L5.63,16z"/></g>',eh='<g><rect fill="none" height="20" width="20"/><path d="M17,15l-1,0v1h2v1h-3v-2c0-0.55,0.45-1,1-1l1,0l0-1h-2v-1l2,0c0.55,0,1,0.45,1,1v1C18,14.55,17.55,15,17,15z M5.63,14h1.9 l2.43-3.87h0.08L12.47,14h1.9l-3.32-5.2l3.1-4.8h-1.91l-2.19,3.56H9.96L7.75,4h-1.9l3.09,4.8L5.63,14z"/></g>',th='<path d="M0 0h24v24H0V0z" fill="none"/><path d="M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"/>',nh='<path d="M0 0h24v24H0V0z" fill="none"/><path d="M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"/>',ih=20,rh=20,oh="currentColor",wa={bold:Df,italic:Af,code:Pf,underline:Rf,strike:zf,ordered_list:Bf,bullet_list:Lf,blockquote:Ff,link:Vf,unlink:Hf,image:$f,align_left:Wf,align_center:qf,align_right:Kf,align_justify:Jf,text_color:jf,color_fill:Uf,horizontal_rule:Gf,format_clear:Xf,indent:Qf,outdent:Yf,superscript:Zf,subscript:eh,undo:th,redo:nh,path:"<path></path>"},Qr=class{static get(e,t=oh){let n=wa[e];return n&&(n.includes("<path")||n.includes("<g"))?`
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill=${t}
height=${ih}
width=${rh}
>
${n}
</svg>
`:n}},Yr=(()=>{class i{locals={};icons={};static \u0275fac=function(n){return new(n||i)};static \u0275prov=kn({token:i,factory:i.\u0275fac,providedIn:"root"})}return i})(),bt=(()=>{class i{config;constructor(t){this.config=t}get locals(){return new Xr(this.config.locals)}getIcon(t){return this.config.icons[t]?this.config.icons[t]:Qr.get(t)}static \u0275fac=function(n){return new(n||i)(ro(Yr,8))};static \u0275prov=kn({token:i,factory:i.\u0275fac,providedIn:"root"})}return i})(),ca=i=>({locals:i.locals??{},icons:i.icons??{}}),qt=(()=>{class i{sanitizer;constructor(t){this.sanitizer=t}transform(t){return xa(t)?t:this.sanitizer.bypassSecurityTrustHtml(t)}static \u0275fac=function(n){return new(n||i)(P(Co,16))};static \u0275pipe=co({name:"sanitizeHtml",type:i,pure:!0,standalone:!1})}return i})(),sh=(()=>{class i{ngxeService;menuService;toolbarItem;get name(){return this.toolbarItem}html;editorView;isActive=!1;disabled=!1;updateSubscription;constructor(t,n){this.ngxeService=t,this.menuService=n}toggle(){let{state:t,dispatch:n}=this.editorView;di[this.name].toggle()(t,n)}onMouseClick(t){t.preventDefault(),t.button===0&&this.toggle()}onKeydown(){this.toggle()}update=t=>{let{state:n}=t,r=di[this.name];this.isActive=r.isActive(n),this.disabled=!r.canExecute(n)};getTitle(t){return this.ngxeService.locals.get(t)}ngOnInit(){this.html=this.ngxeService.getIcon(this.name),this.editorView=this.menuService.editor.view,this.updateSubscription=this.menuService.editor.update.subscribe(t=>{this.update(t)})}ngOnDestroy(){this.updateSubscription.unsubscribe()}static \u0275fac=function(n){return new(n||i)(P(bt),P(Ke))};static \u0275cmp=me({type:i,selectors:[["ngx-toggle-command"]],inputs:{toolbarItem:"toolbarItem"},standalone:!1,decls:4,vars:14,consts:[["type","button",1,"NgxEditor__MenuItem--Icon",3,"mousedown","keydown.enter","keydown.space","disabled","innerHTML","title","ariaLabel"]],template:function(n,r){n&1&&(N(0,"button",0),E(1,"sanitizeHtml"),E(2,"async"),E(3,"async"),R("mousedown",function(s){return r.onMouseClick(s)})("keydown.enter",function(){return r.onKeydown()})("keydown.space",function(){return r.onKeydown()}),M()),n&2&&(Ue("NgxEditor__MenuItem--Active",r.isActive)("NgxEditor--Disabled",r.disabled),k("disabled",r.disabled)("innerHTML",O(1,8,r.html),Ct)("title",O(2,10,r.getTitle(r.name)))("ariaLabel",O(3,12,r.getTitle(r.name))))},dependencies:[Xe,qt],encapsulation:2})}return i})(),lh=(()=>{class i{ngxeService;menuService;toolbarItem;get name(){return this.toolbarItem}html;editorView;disabled=!1;updateSubscription;constructor(t,n){this.ngxeService=t,this.menuService=n}onMouseClick(t){t.preventDefault(),t.button===0&&this.insert()}onKeydown(){this.insert()}insert(){let{state:t,dispatch:n}=this.editorView;la[this.name].insert()(t,n)}update=t=>{let{state:n}=t,r=la[this.name];this.disabled=!r.canExecute(n)};getTitle(t){return this.ngxeService.locals.get(t)}ngOnInit(){this.html=this.ngxeService.getIcon(this.name),this.editorView=this.menuService.editor.view,this.updateSubscription=this.menuService.editor.update.subscribe(t=>{this.update(t)})}ngOnDestroy(){this.updateSubscription.unsubscribe()}static \u0275fac=function(n){return new(n||i)(P(bt),P(Ke))};static \u0275cmp=me({type:i,selectors:[["ngx-insert-command"]],inputs:{toolbarItem:"toolbarItem"},standalone:!1,decls:4,vars:12,consts:[[1,"NgxEditor__MenuItem--Icon",3,"mousedown","keydown.enter","keydown.space","disabled","innerHTML","title","ariaLabel"]],template:function(n,r){n&1&&(N(0,"button",0),E(1,"sanitizeHtml"),E(2,"async"),E(3,"async"),R("mousedown",function(s){return r.onMouseClick(s)})("keydown.enter",function(){return r.onKeydown()})("keydown.space",function(){return r.onKeydown()}),M()),n&2&&(Ue("NgxEditor--Disabled",r.disabled),k("disabled",r.disabled)("innerHTML",O(1,6,r.html),Ct)("title",O(2,8,r.getTitle(r.name)))("ariaLabel",O(3,10,r.getTitle(r.name))))},dependencies:[Xe,qt],encapsulation:2})}return i})(),da={showOpenInNewTab:!0},ah=(()=>{class i{el;ngxeService;menuService;options=da;showPopup=!1;isActive=!1;canExecute=!0;componentId=Ni();form;editorView;updateSubscription;constructor(t,n,r){this.el=t,this.ngxeService=n,this.menuService=r}get icon(){return this.ngxeService.getIcon(this.isActive?"unlink":"link")}get title(){return this.ngxeService.locals.get(this.isActive?"removeLink":"insertLink")}get href(){return this.form.get("href")}get text(){return this.form.get("text")}onDocumentClick(t){!this.el.nativeElement.contains(t.target)&&this.showPopup&&this.hidePopup()}getId(t){return`${t}-${this.componentId}`}getLabel(t){return this.ngxeService.locals.get(t)}hidePopup(){this.showPopup=!1,this.form.reset({href:"",text:"",openInNewTab:!0}),this.text.enable()}togglePopup(){let{state:t,dispatch:n}=this.editorView;if(this.isActive){yn.remove(t,n);return}this.showPopup=!this.showPopup,this.showPopup&&this.setText()}onTogglePopupMouseClick(t){t.button===0&&this.togglePopup()}onTogglePopupKeydown(){this.togglePopup()}setText=()=>{let{state:{selection:t,doc:n}}=this.editorView,{empty:r,from:o,to:s}=t,l=r?"":n.textBetween(o,s);l&&(this.text.patchValue(l),this.text.disable())};update=t=>{let{state:n}=t;this.isActive=yn.isActive(n,{strict:!1}),this.canExecute=yn.canExecute(n)};insertLink(t){t.preventDefault();let{text:n,href:r,openInNewTab:o}=this.form.getRawValue(),{dispatch:s,state:l}=this.editorView,{selection:a}=l,c;this.options.showOpenInNewTab&&(c=o?"_blank":"_self");let d={title:r,href:r,target:c};a.empty?(yn.insert(n,d)(l,s),this.editorView.focus()):yn.update(d)(l,s),this.hidePopup()}ngOnInit(){this.editorView=this.menuService.editor.view,this.form=new _i({href:new Qe("",[St.required,St.pattern(this.menuService.editor.linkValidationPattern)]),text:new Qe("",[St.required]),openInNewTab:new Qe(!0)}),this.updateSubscription=this.menuService.editor.update.subscribe(t=>{this.update(t)})}ngOnDestroy(){this.updateSubscription.unsubscribe()}static \u0275fac=function(n){return new(n||i)(P(kt),P(bt),P(Ke))};static \u0275cmp=me({type:i,selectors:[["ngx-link"]],hostBindings:function(n,r){n&1&&R("mousedown",function(s){return r.onDocumentClick(s)},Jt)},inputs:{options:[2,"options","options",t=>L(L({},da),t)]},standalone:!1,decls:5,vars:16,consts:[["type","button","aria-haspopup","dialog",1,"NgxEditor__MenuItem--Icon",3,"mousedown","keydown.enter","keydown.space","disabled","innerHTML","title","ariaLabel","ariaExpanded"],["class","NgxEditor__Popup",4,"ngIf"],[1,"NgxEditor__Popup"],[1,"NgxEditor__Popup--Form",3,"ngSubmit","formGroup"],[1,"NgxEditor__Popup--FormGroup"],[1,"NgxEditor__Popup--Col"],[1,"NgxEditor__Popup--Label",3,"htmlFor"],["type","url","formControlName","href","autocomplete","off",3,"id"],["class","NgxEditor__HelpText NgxEditor__HelpText--Error",4,"ngIf"],["type","text","formControlName","text","autocomplete","off",3,"id"],["class","NgxEditor__Popup--FormGroup",4,"ngIf"],["type","submit",3,"disabled"],[1,"NgxEditor__HelpText","NgxEditor__HelpText--Error"],["type","checkbox","formControlName","openInNewTab"]],template:function(n,r){n&1&&(N(0,"button",0),E(1,"sanitizeHtml"),E(2,"async"),E(3,"async"),R("mousedown",function(s){return r.onTogglePopupMouseClick(s)})("keydown.enter",function(){return r.onTogglePopupKeydown()})("keydown.space",function(){return r.onTogglePopupKeydown()}),M(),H(4,pp,20,18,"div",1)),n&2&&(Ue("NgxEditor__MenuItem--Active",r.isActive||r.showPopup)("NgxEditor--Disabled",!r.canExecute),k("disabled",!r.canExecute)("innerHTML",O(1,10,r.icon),Ct)("title",O(2,12,r.title))("ariaLabel",O(3,14,r.title))("ariaExpanded",r.showPopup),C(4),k("ngIf",r.showPopup))},dependencies:[Ge,Si,ki,_o,Ci,wi,Mi,vi,Xe,qt],encapsulation:2})}return i})(),ch=(()=>{class i{ngxeService;menuService;el;editorView;updateSubscription;group;items;isDropdownOpen=!1;disabledItems=[];activeItem;constructor(t,n,r){this.ngxeService=t,this.menuService=n,this.el=r}get isSelected(){return!!(this.activeItem||this.isDropdownOpen)}get isDropdownDisabled(){return this.disabledItems.length===this.items.length}onDocumentClick(t){!this.el.nativeElement.contains(t)&&this.isDropdownOpen&&(this.isDropdownOpen=!1)}getName(t){return this.ngxeService.locals.get(t)}getIsDropdownActive(t){return this.activeItem===t}toggleDropdown(){this.isDropdownOpen=!this.isDropdownOpen}onToggleDropdownMouseClick(t){t.preventDefault(),t.button===0&&this.toggleDropdown()}onToggleDropdownKeydown(){this.toggleDropdown()}trackByIndex(t){return t}selectItem(t){let n=di[t],{state:r,dispatch:o}=this.editorView;n.toggle()(r,o),this.isDropdownOpen=!1}onDropdownItemMouseClick(t,n){t.preventDefault(),t.button===0&&this.selectItem(n)}onDropdownItemKeydown(t,n){t.preventDefault(),this.selectItem(n)}update=t=>{let{state:n}=t;this.disabledItems=[];let r=[];this.items.forEach(o=>{let s=di[o];s.isActive(n)&&r.push(o),s.canExecute(n)||this.disabledItems.push(o)}),r.length===1?[this.activeItem]=r:this.activeItem=null};ngOnInit(){this.editorView=this.menuService.editor.view,this.updateSubscription=this.menuService.editor.update.subscribe(t=>{this.update(t)})}ngOnDestroy(){this.updateSubscription.unsubscribe()}static \u0275fac=function(n){return new(n||i)(P(bt),P(Ke),P(kt))};static \u0275cmp=me({type:i,selectors:[["ngx-dropdown"]],hostBindings:function(n,r){n&1&&R("mousedown",function(s){return r.onDocumentClick(s.target)},Jt)},inputs:{group:"group",items:"items"},standalone:!1,decls:5,vars:13,consts:[["type","button","aria-haspopup","listbox",1,"NgxEditor__Dropdown--Text",3,"mousedown","keydown.enter","keydown.space","disabled","ariaLabel","ariaExpanded"],["class","NgxEditor__Dropdown--DropdownMenu","role","listbox",4,"ngIf"],["role","listbox",1,"NgxEditor__Dropdown--DropdownMenu"],["type","button","class","NgxEditor__Dropdown--Item","role","option",3,"ngClass","ariaLabel","mousedown","keydown.enter","keydown.space",4,"ngFor","ngForOf","ngForTrackBy"],["type","button","role","option",1,"NgxEditor__Dropdown--Item",3,"mousedown","keydown.enter","keydown.space","ngClass","ariaLabel"]],template:function(n,r){n&1&&(N(0,"button",0),E(1,"async"),R("mousedown",function(s){return r.onToggleDropdownMouseClick(s)})("keydown.enter",function(){return r.onToggleDropdownKeydown()})("keydown.space",function(){return r.onToggleDropdownKeydown()}),Y(2),E(3,"async"),M(),H(4,mp,2,2,"div",1)),n&2&&(Ue("NgxEditor__Dropdown--Selected",r.isSelected)("NgxEditor--Disabled",r.isDropdownDisabled),k("disabled",r.isDropdownDisabled)("ariaLabel",O(1,9,r.getName(r.activeItem||r.group)))("ariaExpanded",r.isDropdownOpen),C(2),Re(" ",O(3,11,r.getName(r.activeItem||r.group)),`
`),C(2),k("ngIf",r.isDropdownOpen))},dependencies:[jt,_n,Ge,Xe],encapsulation:2})}return i})(),dh=(()=>{class i{el;ngxeService;menuService;showPopup=!1;isActive=!1;componentId=Ni();updateSubscription;form=new _i({src:new Qe("",[St.required,St.pattern(`(https?://)?([\\da-z.-]+)\\.([a-z.]{2,6})[/\\w .-]*/??([^#
\r]*)?#?([^
\r]*)`)]),alt:new Qe(""),title:new Qe("")});editorView;constructor(t,n,r){this.el=t,this.ngxeService=n,this.menuService=r}get icon(){return this.ngxeService.getIcon("image")}get src(){return this.form.get("src")}onDocumentClick(t){!this.el.nativeElement.contains(t.target)&&this.showPopup&&this.hideForm()}getId(t){return`${t}-${this.componentId}`}getLabel(t){return this.ngxeService.locals.get(t)}hideForm(){this.showPopup=!1,this.form.reset({src:"",alt:"",title:""})}togglePopup(){this.showPopup=!this.showPopup,this.showPopup&&this.fillForm()}onTogglePopupMouseClick(t){t.button===0&&this.togglePopup()}onTogglePopupKeydown(){this.togglePopup()}fillForm(){let{state:t}=this.editorView,{selection:n}=t;if(n instanceof w&&this.isActive){let{src:r,alt:o="",title:s=""}=n.node.attrs;this.form.setValue({src:r,alt:o,title:s})}}update=t=>{let{state:n}=t;this.isActive=aa.isActive(n)};insertLink(t){t.preventDefault();let{src:n,alt:r,title:o}=this.form.getRawValue(),{dispatch:s,state:l}=this.editorView,a={alt:r,title:o};aa.insert(n,a)(l,s),this.editorView.focus(),this.hideForm()}ngOnInit(){this.editorView=this.menuService.editor.view,this.updateSubscription=this.menuService.editor.update.subscribe(t=>{this.update(t)})}ngOnDestroy(){this.updateSubscription.unsubscribe()}static \u0275fac=function(n){return new(n||i)(P(kt),P(bt),P(Ke))};static \u0275cmp=me({type:i,selectors:[["ngx-image"]],hostBindings:function(n,r){n&1&&R("mousedown",function(s){return r.onDocumentClick(s)},Jt)},standalone:!1,decls:5,vars:13,consts:[["type","button","aria-haspopup","dialog",1,"NgxEditor__MenuItem--Icon",3,"mousedown","keydown.enter","keydown.space","innerHTML","title","ariaLabel","ariaExpanded"],["class","NgxEditor__Popup",4,"ngIf"],[1,"NgxEditor__Popup"],[1,"NgxEditor__Popup--Form",3,"ngSubmit","formGroup"],[1,"NgxEditor__Popup--FormGroup"],[1,"NgxEditor__Popup--Col"],[1,"NgxEditor__Popup--Label",3,"htmlFor"],["type","url","formControlName","src","autocomplete","off",3,"id"],["class","NgxEditor__HelpText NgxEditor__HelpText--Error",4,"ngIf"],["type","text","formControlName","alt","autocomplete","off",3,"id"],["type","text","formControlName","title","autocomplete","off",3,"id"],["type","submit",3,"disabled"],[1,"NgxEditor__HelpText","NgxEditor__HelpText--Error"]],template:function(n,r){n&1&&(N(0,"button",0),E(1,"sanitizeHtml"),E(2,"async"),E(3,"async"),R("mousedown",function(s){return r.onTogglePopupMouseClick(s)})("keydown.enter",function(){return r.onTogglePopupKeydown()})("keydown.space",function(){return r.onTogglePopupKeydown()}),M(),H(4,yp,24,21,"div",1)),n&2&&(Ue("NgxEditor__MenuItem--Active",r.isActive||r.showPopup),k("innerHTML",O(1,7,r.icon),Ct)("title",O(2,9,r.getLabel("insertImage")))("ariaLabel",O(3,11,r.getLabel("insertImage")))("ariaExpanded",r.showPopup),C(4),k("ngIf",r.showPopup))},dependencies:[Ge,Si,ki,Ci,wi,Mi,vi,Xe,qt],encapsulation:2})}return i})(),uh=(()=>{class i{el;menuService;ngxeService;presets;type;constructor(t,n,r){this.el=t,this.menuService=n,this.ngxeService=r}get title(){return this.getLabel(this.type==="text_color"?"text_color":"background_color")}get icon(){return this.ngxeService.getIcon(this.type==="text_color"?"text_color":"color_fill")}get command(){return this.type==="text_color"?Tf:If}updateSubscription;editorView;showPopup=!1;isActive=!1;activeColors=[];canExecute=!0;getContrastYIQ(t){let n=t.replace("#",""),r=parseInt(n.substring(0,2),16),o=parseInt(n.substring(2,4),16),s=parseInt(n.substring(4,6),16);return(r*299+o*587+s*114)/1e3>=128?"black":"white"}onDocumentClick(t){!this.el.nativeElement.contains(t.target)&&this.showPopup&&this.hidePopup()}hidePopup(){this.showPopup=!1}togglePopup(){this.showPopup=!this.showPopup}onTogglePopupMouseClick(t){t.preventDefault(),t.button===0&&this.togglePopup()}onTogglePopupKeydown(){this.togglePopup()}remove(){let{state:t,dispatch:n}=this.editorView;this.command.remove()(t,n),this.hidePopup()}onRemoveMouseClick(t){t.preventDefault(),t.button===0&&(t.preventDefault(),this.remove())}onRemoveKeydown(){this.remove()}trackByIndex(t){return t}selectColor(t){let{state:n,dispatch:r}=this.editorView;if(this.type==="text_color"){let o={color:t};this.command.apply(o)(n,r)}else{let o={backgroundColor:t};this.command.apply(o)(n,r)}this.editorView.hasFocus()||this.editorView.focus(),this.hidePopup()}onColorSelectMouseClick(t,n){t.preventDefault(),t.button===0&&this.selectColor(n)}onColorSelectKeydown(t){this.selectColor(t)}update=t=>{let{state:n}=t;this.canExecute=this.command.canExecute(n),this.isActive=this.command.isActive(n),this.activeColors=[],this.isActive&&(this.activeColors=this.command.getActiveColors(n))};getLabel(t){return this.ngxeService.locals.get(t)}ngOnInit(){this.editorView=this.menuService.editor.view,this.updateSubscription=this.menuService.editor.update.subscribe(t=>{this.update(t)})}ngOnDestroy(){this.updateSubscription.unsubscribe()}static \u0275fac=function(n){return new(n||i)(P(kt),P(Ke),P(bt))};static \u0275cmp=me({type:i,selectors:[["ngx-color-picker"]],hostBindings:function(n,r){n&1&&R("mousedown",function(s){return r.onDocumentClick(s)},Jt)},inputs:{presets:"presets",type:"type"},standalone:!1,decls:5,vars:15,consts:[["type","button",1,"NgxEditor__MenuItem--Icon",3,"mousedown","keydown.enter","keydown.space","disabled","innerHTML","title","ariaLabel"],["class","NgxEditor__Popup",4,"ngIf"],[1,"NgxEditor__Popup"],["class","NgxEditor__ColorContainer",4,"ngFor","ngForOf","ngForTrackBy"],[1,"NgxEditor__MenuItem--Button",3,"mousedown","keydown.enter","keydown.space","disabled"],[1,"NgxEditor__ColorContainer"],["class","NgxEditor__Color",3,"ngStyle","title","ngClass","mousedown","keydown.enter","keydown.space",4,"ngFor","ngForOf","ngForTrackBy"],[1,"NgxEditor__Color",3,"mousedown","keydown.enter","keydown.space","ngStyle","title","ngClass"]],template:function(n,r){n&1&&(N(0,"button",0),E(1,"sanitizeHtml"),E(2,"async"),E(3,"async"),R("mousedown",function(s){return r.onTogglePopupMouseClick(s)})("keydown.enter",function(){return r.onTogglePopupKeydown()})("keydown.space",function(){return r.onTogglePopupKeydown()}),M(),H(4,wp,5,6,"div",1)),n&2&&(Ue("NgxEditor__MenuItem--Active",r.isActive||r.showPopup)("NgxEditor--Disabled",!r.canExecute),k("disabled",!r.canExecute)("innerHTML",O(1,9,r.icon),Ct)("title",O(2,11,r.title))("ariaLabel",O(3,13,r.title)),C(4),k("ngIf",r.showPopup))},dependencies:[jt,_n,Ge,xo,Xe,qt],styles:['@charset "UTF-8";.NgxEditor__Popup[_ngcontent-%COMP%]{width:230px}.NgxEditor__ColorContainer[_ngcontent-%COMP%]{display:flex;justify-content:space-between}.NgxEditor__ColorContainer[_ngcontent-%COMP%] + .NgxEditor__ColorContainer[_ngcontent-%COMP%]{margin-top:5px}.NgxEditor__Color[_ngcontent-%COMP%]{border:none;outline:none;border-radius:6px;width:24px;height:24px;flex-shrink:0}.NgxEditor__Color[_ngcontent-%COMP%]:focus-visible{outline:1px solid var(--ngx-editor-focus-ring-color);outline-offset:1px}.NgxEditor__Color--Active[_ngcontent-%COMP%]:after{content:"\\2714";font-size:90%}.NgxEditor__MenuItem--Button[_ngcontent-%COMP%]{margin-top:5px}']})}return i})();var ph=[["bold","italic"],[{heading:["h1","h2","h3","h4","h5","h6"]}],["link","image"],["text_color","background_color"]];var fh=["#b60205","#d93f0b","#fbca04","#0e8a16","#006b75","#1d76db","#0052cc","#5319e7","#e99695","#f9d0c4","#fef2c0","#c2e0c6","#bfdadc","#c5def5","#bfd4f2","#d4c5f9"],lg=(()=>{class i{menuService;toolbar=ph;colorPresets=fh;disabled=!1;editor;customMenuRef=null;dropdownPlacement="bottom";toggleCommands=["bold","italic","underline","strike","code","blockquote","ordered_list","bullet_list","align_left","align_center","align_right","align_justify","superscript","subscript"];insertCommands=["horizontal_rule","format_clear","indent","outdent","undo","redo"];iconContainerClass=["NgxEditor__MenuItem","NgxEditor__MenuItem--IconContainer"];dropdownContainerClass=["NgxEditor__Dropdown"];seperatorClass=["NgxEditor__Seperator"];constructor(t){this.menuService=t}get presets(){let n=[];return this.colorPresets.forEach((r,o)=>{let s=Math.floor(o/8);n[s]||n.push([]),n[s].push(r)}),n}trackByIndex(t){return t}isDropDown(t){return!!t?.heading}getDropdownItems(t){return t}isLinkItem(t){return t==="link"?!0:typeof t=="object"&&typeof t?.link=="object"}isLinkWithOptions(t){return typeof t=="object"&&typeof t?.link=="object"}getLinkOptions(t){return t?.link}ngOnInit(){if(!this.editor)throw new Mt("Required editor instance to initialize menu component");this.menuService.editor=this.editor}static \u0275fac=function(n){return new(n||i)(P(Ke))};static \u0275cmp=me({type:i,selectors:[["ngx-editor-menu"]],inputs:{toolbar:"toolbar",colorPresets:"colorPresets",disabled:"disabled",editor:"editor",customMenuRef:"customMenuRef",dropdownPlacement:"dropdownPlacement"},standalone:!1,features:[yi([Ke])],decls:3,vars:7,consts:[[1,"NgxEditor__MenuBar",3,"ngClass"],[4,"ngFor","ngForOf","ngForTrackBy"],[4,"ngIf"],[3,"toolbarItem","class",4,"ngIf"],[3,"class",4,"ngIf"],["type","text_color",3,"class","presets",4,"ngIf"],["type","background_color",3,"class","presets",4,"ngIf"],[3,"toolbarItem"],[3,"options"],[3,"class","group","items",4,"ngFor","ngForOf","ngForTrackBy"],[3,"group","items"],["type","text_color",3,"presets"],["type","background_color",3,"presets"],[3,"ngTemplateOutlet"]],template:function(n,r){n&1&&(N(0,"div",0),H(1,Pp,2,2,"ng-container",1)(2,Rp,2,1,"ng-container",2),M()),n&2&&(k("ngClass",wn(4,_p,r.disabled,r.dropdownPlacement==="top")),C(),k("ngForOf",r.toolbar)("ngForTrackBy",r.trackByIndex),C(),k("ngIf",r.customMenuRef))},dependencies:[jt,_n,Ge,bo,sh,lh,ah,ch,dh,uh,ko],encapsulation:2})}return i})();var hh=(()=>{class i{static \u0275fac=function(n){return new(n||i)};static \u0275mod=fi({type:i});static \u0275inj=pi({providers:[qt],imports:[bi,So]})}return i})(),ai=new io("NgxEditorConfig"),ua={locals:Gr,icons:wa},ag=(()=>{class i{static forRoot(t=ua){return{ngModule:i,providers:[{provide:ai,useValue:t},{provide:Yr,useFactory:ca,deps:[ai]}]}}static forChild(t=ua){return{ngModule:i,providers:[{provide:ai,useValue:t},{provide:Yr,useFactory:ca,deps:[ai]},bt]}}static \u0275fac=function(n){return new(n||i)};static \u0275mod=fi({type:i});static \u0275inj=pi({imports:[bi,hh]})}return i})(),mh=i=>i===null||i.length===0,pa=i=>i!==null&&typeof i.length=="number",gh=i=>{if(!i)return!0;let{childCount:e,firstChild:t}=i;return!!(e===1&&t?.isTextblock&&t.content.size===0)},fa=class{static required(e){return t=>{let n=e||qe,r=xn(t.value,n);return gh(r)?{required:!0}:null}}static maxLength(e,t){return n=>{let r=t||qe,s=xn(n.value,r).textContent;return pa(s)&&s.length>e?{maxlength:{requiredLength:e,actualLength:s.length}}:null}}static minLength(e,t){return n=>{let r=t||qe,s=xn(n.value,r).textContent;return mh(s)||!pa(s)?null:s.length<e?{minlength:{requiredLength:e,actualLength:s.length}}:null}}},oe=(i,e=!1)=>(t,n)=>{let r=new we(i);return e?r.toggle()(t,n):r.apply()(t,n)},Zr=class{view;state;tr;constructor(e){if(!e)throw new Mt("Required view to initialize commands.");this.view=e,this.state=e.state,this.tr=this.view.state.tr}applyTrx=e=>{this.state=this.state.apply(e??this.tr),this.tr=this.state.tr,this.tr.setMeta("APPLIED_TRX",!0)};dispatch=e=>{this.applyTrx(e)};exec(){if(!this.tr.getMeta("APPLIED_TRX"))return!1;let e=!this.view.state.doc.eq(this.state.doc);this.view.updateState(this.state);let t=this.tr.setMeta("FORCE_EMIT",e);return this.view.dispatch(t),!0}focus(e="end"){let t=e==="start"?S.atStart(this.state.doc):S.atEnd(this.state.doc);return this.tr.setSelection(t),this.applyTrx(),this.view.focus(),this}scrollIntoView(){return this.tr.scrollIntoView(),this.applyTrx(),this}insertText(e){return this.tr.insertText(e),this.applyTrx(),this}insertNewLine(){return Vt(...[Er,Ir,Dr,Ar])(this.state,this.dispatch),this}applyMark(e){return oe(e,!1)(this.state,this.dispatch),this}toggleMark(e){return oe(e,!0)(this.state,this.dispatch),this}bold(){return oe("strong")(this.state,this.dispatch),this}toggleBold(){return oe("strong",!0)(this.state,this.dispatch),this}italics(){return oe("em")(this.state,this.dispatch),this}toggleItalics(){return oe("em",!0)(this.state,this.dispatch),this}underline(){return oe("u")(this.state,this.dispatch),this}toggleUnderline(){return oe("u",!0)(this.state,this.dispatch),this}strike(){return oe("s")(this.state,this.dispatch),this}toggleStrike(){return oe("s",!0)(this.state,this.dispatch),this}code(){return oe("code")(this.state,this.dispatch),this}toggleCode(){return oe("code",!0)(this.state,this.dispatch),this}superscript(){return oe("sup")(this.state,this.dispatch),this}subscript(){return oe("sub")(this.state,this.dispatch),this}toggleOrderedList(){return new $t(!1).toggle()(this.state,this.dispatch),this}toggleBulletList(){return new $t(!0).toggle()(this.state,this.dispatch),this}toggleHeading(e){return new Ae(e).toggle()(this.state,this.dispatch),this}insertLink(e,t){return new jr().insert(e,t)(this.state,this.dispatch),this}updateLink(e){return new jr().update(e)(this.state,this.dispatch),this}insertImage(e,t={}){return new Ca().insert(e,t)(this.state,this.dispatch),this}textColor(e){return new Ht("text_color").apply({color:e})(this.state,this.dispatch),this}backgroundColor(e){return new Ht("text_background_color").apply({backgroundColor:e})(this.state,this.dispatch),this}removeTextColor(){return new Ht("text_color").remove()(this.state,this.dispatch),this}removeBackgroundColor(){return new Ht("text_background_color").remove()(this.state,this.dispatch),this}align(e){return new xt(e).toggle()(this.state,this.dispatch),this}insertHTML(e){let{selection:t,schema:n,tr:r}=this.state,{from:o,to:s}=t,l=document.createElement("div");l.innerHTML=ya(e)?e.trim():e;let a=ze.fromSchema(n).parseSlice(l),c=r.replaceRange(o,s,a);return this.applyTrx(c),this}indent(){return new Wt("increase").insert()(this.state,this.dispatch),this}outdent(){return new Wt("decrease").insert()(this.state,this.dispatch),this}},yh=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,xh=i=>ei(/^\s*>\s$/,i),bh=i=>ei(/^(?:\d+)\.\s$/,i,e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])),kh=i=>ei(/^\s*(?:[-+*])\s$/,i),Ch=i=>Pr(/^```$/,i),wh=(i,e)=>Pr(new RegExp(`^(#{1,${e}})\\s$`),i,t=>({level:t[1].length})),_h=i=>Lr(/(?:^|\s)(?:(\*\*|__)(?:([^*_]+))(\*\*|__))$/,i),Sh=i=>Lr(/(?:^|\s)(?:(\*|_)(?:([^*_]+))(\*|_))$/,i),Mh=i=>{let e=Gl.concat(Ul,jl);return e.push(_h(i.marks.strong)),e.push(Sh(i.marks.em)),e.push(xh(i.nodes.blockquote)),e.push(bh(i.nodes.ordered_list)),e.push(kh(i.nodes.bullet_list)),e.push(Ch(i.nodes.code_block)),e.push(wh(i.nodes.heading,6)),Jl({rules:e})},vh=(i,e)=>{let t={};t["Mod-z"]=oi,yh?t["Shift-Mod-z"]=mn:t["Mod-y"]=mn;let n=[gn({"Mod-b":mt(i.marks.strong),"Mod-i":mt(i.marks.em),"Mod-u":mt(i.marks.u),"Mod-`":mt(i.marks.code)}),gn({Enter:Pl(i.nodes.list_item),"Shift-Enter":Vt(Tr,(r,o)=>{let{tr:s}=r,l=i.nodes.hard_break;return o(s.replaceSelectionWith(l.create()).scrollIntoView()),!0}),"Mod-[":Mr(i.nodes.list_item),"Mod-]":vr(i.nodes.list_item),Tab:vr(i.nodes.list_item)}),gn(ql)];return e.history&&n.push(gn(t)),n},Nh=(i,e)=>{let t=[];return e.keyboardShortcuts&&t.push(...vh(i,{history:e.history})),e.history&&t.push(ia()),e.inputRules&&t.push(Mh(i)),t},_a={linkOnPaste:!0,resizeImage:!0},ha={content:null,history:!0,keyboardShortcuts:!0,inputRules:!0,schema:qe,plugins:[],nodeViews:{},attributes:{},features:_a,handleScrollToSelection:null,linkValidationPattern:`(https?://)?([\\da-z.-]+)\\.([a-z.]{2,6})[/\\w .-]*/??([^#
\r]*)?#?([^
\r]*)|(mailto:.*[@].*)`},ma=class{options;view;constructor(e=ha){this.options=L(L({},ha),e),this.createEditor()}valueChangesSubject=new Kt;updateSubject=new Kt;get valueChanges(){return this.valueChangesSubject.asObservable()}get update(){return this.updateSubject.asObservable()}get schema(){return this.options.schema||qe}get linkValidationPattern(){return this.options.linkValidationPattern}get commands(){return new Zr(this.view)}get features(){return L(L({},_a),this.options.features)}handleTransactions(e){let t=this.view.state.apply(e);if(this.view.updateState(t),this.updateSubject.next(this.view),!e.docChanged&&!e.getMeta("FORCE_EMIT"))return;let n=t.doc.toJSON();this.valueChangesSubject.next(n)}createEditor(){let{options:e,schema:t}=this,{content:n=null,nodeViews:r}=e,{history:o=!0,keyboardShortcuts:s=!0,inputRules:l=!0}=e,a=xn(n,t,e.parseOptions),c=e.plugins??[],d=e.attributes??{},u=Nh(t,{history:o,keyboardShortcuts:s,inputRules:l});this.view=new pn(null,{state:Vn.create({doc:a,schema:t,plugins:[...u,...c]}),nodeViews:r,dispatchTransaction:this.handleTransactions.bind(this),attributes:d,handleScrollToSelection:e.handleScrollToSelection})}setContent(e){if(Mo(e))return;let{state:t}=this.view,{tr:n,doc:r}=t,o=xn(e,this.schema,this.options.parseOptions);n.replaceWith(0,t.doc.content.size,o),!r.eq(n.doc)&&n.docChanged&&this.view.dispatch(n)}registerPlugin(e){let{state:t}=this.view,n=[...t.plugins,e],r=t.reconfigure({plugins:n});this.view.updateState(r)}destroy(){this.view.destroy()}};export{ig as a,lg as b,ag as c,fa as d,ma as e};